Пишем программу для создания книг FB2. - Юрий Карпов
Шрифт:
Интервал:
Закладка:
Width = 27
Height = 13
Caption = 'Lang.'
end
object Lsrc_lang: TLabel
Left = 456
Top = 176
Width = 49
Height = 13
Caption = 'Src. Lang.'
end
object LTome: TLabel
Left = 200
Top = 176
Width = 27
Height = 13
Caption = 'Tome'
end
object book_title: TEdit
Left = 64
Top = 56
Width = 217
Height = 21
TabOrder = 0
end
object FB2_file: TEdit
Left = 8
Top = 24
Width = 273
Height = 21
TabOrder = 1
end
object Au: TGroupBox
Left = 296
Top = 8
Width = 185
Height = 153
Caption = ' Authors '
TabOrder = 2
object ListBox3: TListBox
Left = 8
Top = 15
Width = 169
Height = 106
ItemHeight = 13
TabOrder = 0
end
object Button10: TButton
Left = 152
Top = 124
Width = 25
Height = 25
Caption = '...'
TabOrder = 1
OnClick = Button10Click
end
end
object GroupBox1: TGroupBox
Left = 8
Top = 88
Width = 273
Height = 73
Caption = ' Genre '
ParentShowHint = False
ShowHint = False
TabOrder = 3
object GenresBox: TListBox
Left = 8
Top = 15
Width = 225
Height = 50
ItemHeight = 13
TabOrder = 0
end
object Button4: TButton
Left = 240
Top = 40
Width = 25
Height = 25
Caption = '…'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 1
OnClick = Button4Click
end
end
object GroupBox3: TGroupBox
Left = 480
Top = 8
Width = 185
Height = 153
Caption = ' Translator '
TabOrder = 4
object ListBox2: TListBox
Left = 8
Top = 15
Width = 169
Height = 106
ItemHeight = 13
TabOrder = 0
end
object Button7: TButton
Left = 152
Top = 124
Width = 25
Height = 25
Caption = '…'
TabOrder = 1
OnClick = Button7Click
end
end
object sequence: TEdit
Left = 40
Top = 192
Width = 169
Height = 21
TabOrder = 5
end
object tome: TEdit
Left = 216
Top = 192
Width = 33
Height = 21
TabOrder = 6
end
object Lang: TComboBox
Left = 376
Top = 192
Width = 65
Height = 21
ItemHeight = 13
TabOrder = 7
Text = 'ru'
Items.Strings = (
'ru'
'en')
end
object SLang: TComboBox
Left = 456
Top = 192
Width = 145
Height = 21
ItemHeight = 13
TabOrder = 8
end
object Button9: TButton
Left = 88
Top = 238
Width = 121
Height = 17
Caption = 'Load annotation'
TabOrder = 9
OnClick = Button9Click
end
end
end
object TabSheet3: TTabSheet
Caption = 'document-info'
ImageIndex = 2
object Lurl: TLabel
Left = 32
Top = 40
Width = 28
Height = 13
Caption = 'src-url'
end
object LID: TLabel
Left = 32
Top = 120
Width = 11
Height = 13
Caption = 'ID'
end
object Lversion: TLabel
Left = 24
Top = 200
Width = 34
Height = 13
Caption = 'version'
end
object url: TEdit
Left = 40
Top = 64
Width = 553
Height = 21
TabOrder = 0
end
object id: TEdit
Left = 40
Top = 144
Width = 241
Height = 21
TabOrder = 1
end
object version: TEdit
Left = 40
Top = 224
Width = 65
Height = 21
TabOrder = 2
Text = '1.0'
end
end
object TabSheet6: TTabSheet
Caption = 'publish-info'
ImageIndex = 3
object LISBN: TLabel
Left = 40
Top = 80
Width = 25
Height = 13
Caption = 'ISBN'
end
object LBook_name: TLabel
Left = 16
Top = 32
Width = 54
Height = 13
Caption = 'Book name'
end
object Lpublisher: TLabel
Left = 16
Top = 128
Width = 42
Height = 13
Caption = 'publisher'
end
object Lcity: TLabel
Left = 32
Top = 200
Width = 16
Height = 13
Caption = 'city'
end
object Lyear: TLabel
Left = 280
Top = 200
Width = 20
Height = 13
Caption = 'year'
end
object isbn: TEdit
Left = 80
Top = 72
Width = 217
Height = 21
TabOrder = 0
end
object Book_name: TEdit
Left = 80
Top = 24
Width = 561
Height = 21
TabOrder = 1
end
object publisher: TEdit
Left = 80
Top = 120
Width = 553
Height = 21
TabOrder = 2
end
object year: TEdit
Left = 312
Top = 196
Width = 57
Height = 21
TabOrder = 3
end
object city: TEdit
Left = 80
Top = 192
Width = 145
Height = 21
TabOrder = 4
end
end
object TabSheet2: TTabSheet
Caption = 'Content'
ImageIndex = 1
object Panel1: TPanel
Left = 0
Top = 0
Width = 706
Height = 41
Align = alTop
TabOrder = 0
end
object Panel2: TPanel
Left = 0
Top = 41
Width = 265
Height = 348
Align = alLeft
BevelOuter = bvNone
TabOrder = 1
object Button12: TButton
Left = 216
Top = 123
Width = 33
Height = 25
Caption = '>'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -21
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 0
OnClick = Button12Click
end
object RG: TRadioGroup
Left = 16
Top = 72
Width = 177
Height = 193
Caption = ' Styles '
ItemIndex = 0
Items.Strings = (
'Normal'
'Epigraph'
'Text-author'
'Subtitle'
'Poem'
'Citation'
'None')
TabOrder = 1
end
object GroupBox2: TGroupBox
Left = 16
Top = 0
Width = 177
Height = 65
Caption = ' Heading '
TabOrder = 2
object Button1: TButton
Left = 16
Top = 24
Width = 25
Height = 25
Caption = '-'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -24
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 72
Top = 24
Width = 33
Height = 25
Caption = 'H1'
TabOrder = 1
OnClick = Button2Click
end
object Button5: TButton
Left = 128
Top = 24
Width = 25
Height = 25
Caption = '+'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 2
OnClick = Button5Click
end
end
end
object ListBox1: TListBox
Left = 265
Top = 41
Width = 441
Height = 348
Align = alClient
Font.Charset = RUSSIAN_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Courier'
Font.Style = []
ItemHeight = 13
ParentFont = False
TabOrder = 2
OnClick = ListBox1Click
OnDblClick = ListBox1DblClick
end
end
object TabSheet4: TTabSheet
Caption = 'End Notes'
ImageIndex = 4
object Panel4: TPanel
Left = 0
Top = 0
Width = 706
Height = 41
Align = alTop
TabOrder = 0
object Button3: TButton
Left = 8
Top = 8
Width = 105
Height = 25
Caption = 'Load End Notes'
TabOrder = 0
OnClick = Button3Click
end
end
object EndNotesList: TListBox
Left = 0
Top = 41
Width = 706
Height = 348
Align = alClient
ItemHeight = 13
TabOrder = 1
end
end
end
object MainMenu1: TMainMenu
Left = 208
Top = 32
object File1: TMenuItem
Caption = 'File'
object Open1: TMenuItem
Caption = 'Open'
OnClick = Open1Click
end
object SaveasFB21: TMenuItem
Caption = 'Save as FB2'
OnClick = SaveasFB21Click
end
end
end
object OpenDialog1: TOpenDialog
Filter = 'Text|*.txt|Any file|*.*'
FilterIndex = 2
Left = 240
Top = 32
end
object SaveDialog1: TSaveDialog
Filter = 'FB2 |*.fb2'
Left = 272
Top = 32
end
end
// конец кода
Код файла Unit1.pas соответствующего Form1
// начало кода
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Menus, CheckLst, ComCtrls,
genres, UmFB2, dm, authors;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
File1: TMenuItem;
Open1: TMenuItem;
SaveasFB21: TMenuItem;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Annotation: TMemo;
TabSheet3: TTabSheet;
Lurl: TLabel;
LID: TLabel;
Lversion: TLabel;
url: TEdit;
id: TEdit;
version: TEdit;
TabSheet6: TTabSheet;
LISBN: TLabel;
LBook_name: TLabel;
Lpublisher: TLabel;
Lcity: TLabel;
Lyear: TLabel;
isbn: TEdit;
Book_name: TEdit;
publisher: TEdit;
year: TEdit;
city: TEdit;
TabSheet2: TTabSheet;
Panel1: TPanel;
Panel2: TPanel;
Button12: TButton;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
ListBox1: TListBox;
TabSheet4: TTabSheet;
Panel4: TPanel;
Button3: TButton;
EndNotesList: TListBox;
RG: TRadioGroup;
Panel3: TPanel;
Lbook_title: TLabel;
LProject: TLabel;
LAnnotation: TLabel;
Lsequence: TLabel;
LLang: TLabel;
Lsrc_lang: TLabel;
LTome: TLabel;
book_title: TEdit;
FB2_file: TEdit;
Au: TGroupBox;
ListBox3: TListBox;
Button10: TButton;
GroupBox1: TGroupBox;
GenresBox: TListBox;
Button4: TButton;
GroupBox3: TGroupBox;
ListBox2: TListBox;
Button7: TButton;
sequence: TEdit;
tome: TEdit;
Lang: TComboBox;
SLang: TComboBox;
Button9: TButton;
GroupBox2: TGroupBox;
Button1: TButton;
Button2: TButton;
Button5: TButton;
procedure Open1Click(Sender: TObject);
procedure SaveasFB21Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Path: ANSIstring;
implementation
uses EditStr;
{$R *.dfm}
procedure LoadTXT(FName: string);
var
L: TStringList;
i, j: integer;
s, ss: string;
begin
L:= TStringList.Create;
L.LoadFromFile(fname);
for i:= 0 to L.Count - 1 do
begin
s:= ''; ss:= L[i];
for j:= 1 to length(Ss) do
begin // просматриваем строку
case ss[j] of
'<': S:= S + '<'; // знак < вызывает сбой в читалке
'>': S:= S + '>'; // заменяем, на всякий случай