⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updftextwriter.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 5 页
字号:



    //whether the markings of a new page are currently written
    FWritingPageMarkings: Boolean;
    //whether the page markings at the top of the page is written, else it is
    //the text at its bottom
    FWritingPageHeader: Boolean;


    //the current indention
    FIndention: TPDFValue;


    //current vertical position in the current page, where the next text will
    //be written
    FYPos: TPDFValue;
    //current horizontal position in the current page, where the next text will
    //be written
    FXPos: TPDFValue;
    //the rectangle in the page where text should be written (without headers
    //and footers)
    FPageRect: TPDFRect;
    //the width of the writable area of the page,
    //i.e. ~[link FPageRect].Right - FPageRect.Left
    FLineWidth: TPDFValue;
    //the position of the start of the line
    //~[code = ~[link FPageRect].Left + ~[link FIndention]]
    FLeftLineStart: TPDFValue;


    //alignment of the text (in the current paragraph)
    FAlignment: TTextAlignment;












    //the number of the current page
    FPage: Integer;
    //if the number of the page should be written with roman letters instead
    //with latin digits
    FRomanPageNumber: Boolean;
    //if sections shouldn't start a new page (used in the index and the
    //user documentation)
    FSectionSamePage: Boolean;



    //number of the current chapter/part of the documentation
    FMainSectionNumber: Integer;
    //number of the current section
    FSectionNumber: Integer;
    //number of the current subsection
    FSubSectionNumber: Integer;
    //number of the item section
    FItemSectionNumber: Integer;
    //title of the current chapter/part of the documentation
    FMainSectionName: String;
    //title of the current section
    FSectionName: String;
    //title of the current subsection
    FSubSectionName: String;
    //title of the current item of the documentation
    FItemSectionName: String;


    //the root of the outline of the document; also used to generate the table
    //of contents
    FOutlineRoot: TOutlineEntry;
    //the entry of the current chapter/part of the documentation
    FMainSectionOutlineEntry: POutlineEntry;
    //the entry for the current section
    FSectionOutlineEntry: POutlineEntry;
    //the entry for the current subsection
    FSubSectionOutlineEntry: POutlineEntry;























    //a simple stack of font settings, used in different positions, number of
    //entries is in ~[link FFontSettingCount]
    FFontSettings: TFontSettings;
    //the number of valid entries in the stack ~[link FFontSettings]
    FFontSettingCount: Integer;

    //whether a list marker has been written and the line not ended yet
    FListMarkerWritten: Boolean;

    //TICPDFDoc(TFormMain(Application.MainForm).FState.FGenerate.FGenerator).FTextWriter.FTable,r

    //the definition of a table to write the text into
    FTable: TTableDefinition;

    //the number of characters in the current paragraph, i.e. the number of
    //valid entries in ~[link FParagraph], ~[link FCharWidths] and
    //~[link FBreakable]
    FParagraphCharacterCount: Integer;

    //text of current paragraph;
    //only the first ~[link FParagraphCharacterCount] characters are valid
    FParagraph: TCharacterArray;
    //widths of each character (or symbol or image) in the paragraph;
    //only the first ~[link FParagraphCharacterCount] characters are valid
    FCharWidths: TPDFValueArray;
    //the kind of the characters/tokens in the paragraph;
    //only the first ~[link FParagraphCharacterCount] characters are valid
    FBreakable: TCharacterBreakables;

    //attributes of the different tokens in the paragraph;
    //always at least one entry, with StartIndex = 1;
    //the number of valid entries is in ~[link FAttributeCount]
    FAttributes: TParagraphAttributes;
    //the number of valid entries in ~[link FAttributes], the attributes of the
    //current paragraph
    FAttributeCount: Integer;

    //the links on the texts, the number of valid entries is in
    //~[link FLinkCount]
    FLinks: TParagraphLinks;
    //the number of valid entries in ~[link FLinks] of link in the current
    //paragraph
    FLinkCount: Integer;
    //the handle of the font (color) of the link pushed on the stack of fonts
    FLinkFontHandle: Integer;
    //whether currently text inside a link is being written
    FInLink: Boolean;





    //Adds the text objects for the paragraph or each cell to the manager.
    procedure AddTextObjects(const Table      :TTableDefinition;
                             const Paragraph  :TCharacterArray;
                             const CharWidths :TPDFValueArray;
                             const Breakable  :TCharacterBreakables;
                             const Attributes :TParagraphAttributes;
                             const Links      :TParagraphLinks;
                                   Manager    :TPDFTextWriterManager);
    //Writes the text of the paragraph or row of the table.
    procedure WriteParagraphOrTableRow;


    //Ensures that there is enough room in the buffers for the paragraph.
    function EnsureParagraphBuffers(NeededSpace: Integer): Integer;

    //Starts a new link inside the paragraph.
    procedure StartParagraphLink(LinkType: TLinkType; const Target: String);



    //Writes the heading of a section.
    procedure WriteTitleText(Level: TTableOfContentsDetailLevel;
                             const LabelName, Title: String;
                             HelpContext: THelpContext);


    //Frees the outline of the documentation.
    procedure FreeOutline(Entry: POutlineEntry);


  public
    //Creates the object to write text formatted to a PDF file and initializes
    //all its settings.
    constructor Create;
    //Frees the object to write text formatted to a PDF file and the outline.
    destructor Destroy; override;


    //Sets the alignment of the (next) paragraph.
    procedure SetParagraphAlignment(Alignment: TTextAlignment);


    //Pushes another font on the stack.
    function PushFont(Font: TPdfFontType; Style: TPdfFontStyles;
                      Size: TPDFValue; Color: TColor): Integer;
    //Pushes another font on the stack.
    function PushFontRec(const Font: TFontSetting): Integer;
    //Removes the specified font from the stack, it must be the last and
    //therefore current one.
    procedure PopFont(Handle: Integer);
    //The current font on the stack, i.e. the last one. If it is empty the
    //default font is returned.
    function CurrentFont: TFontSetting;


    //Sets the font of the following text in the paragraph/the current cell.
    procedure SetParagraphFont(const Font: TFontSetting);
    //Sets the font of the whole table row, must be called before adding text.
    procedure SetTableRowFont(const Font: TFontSetting);

    //Adds text to the paragraph.
    procedure AddText(const Text: String);
    //Adds a symbol to the paragraph.
    procedure AddSymbol(Symbol: TSymbol);
    //Adds an image to the paragraph.
    procedure AddImage(const Name: String; Links: TImageLinkList;
                      ImageWidth: TPDFValue);
    //Ends the current cell and starts the next cell of the table.
    procedure AddCellChange;


    //Adds localized text to the paragraph.
    procedure AddLocalized(Text: TDocumentationTexts);
    //Adds text in another font style to the paragraph.
    procedure AddStyledText(const Text: String; Style: TPdfFontStyle);
    //Adds localized text in another font style to the paragraph.
    procedure AddStyledLocalized(Text: TDocumentationTexts;
                                 Style: TPdfFontStyle);

    //Starts a link in the paragraph.
    procedure StartLink(LinkType: TLinkType; const Target: String);
    //Ends the link in the paragraph.
    procedure EndLink;



    //Ends and writes the paragraph.
    function FlushLine: Boolean;


    //Whether a new paragraph has already been started and it is not empty
    //anymore.
    function InParagraph: Boolean;



    //Writes the marker of an item in a list.
    procedure WriteListMarker(Bullet: Boolean; const Text: String;
                              IndentWidth: TPDFValue);






    //Sets the indentation of the following text.
    procedure SetLeftMargin(LeftMargin: TPDFValue);

    //Defines a table in which the following paragraphs will be written, each
    //as a row.
    procedure DefineTable(const Table: array of TTableCellDefinition);
    //Ends a table after the paragraph of the last row.
    procedure EndTable;

    //Returns the width of the current line in the paragraph.
    function CurrentLineWidth: TPDFValue;



    //Ends the current line (paragraph) and starts a new one.
    procedure EndLine;
    //Ends the current paragraph and starts a new one (after an empty line).
    procedure EndParagraph;



    //Ensures there is room for an image (or other object) and calculates its
    //horizontally centered position.
    function MakeRoomForImage(Width, Height: TPDFValue): TPDFPoint;
    //Moves the text insertion point below a drawn image.
    function MoveBelowImage(Top, Height: TPDFValue): Boolean;

    //Adds an image as an own paragraph horizontally centered in the page.
    function ShowCenteredImage(const ImageName: String;
                               Width, Height: TPDFValue;
                               var Position: TPDFPoint): Boolean;





    //Returns a string expressing the current position in the documentaton by
    //the number of its section, subsection and so on.
    function GetSectionString: String;

    //Writes the header and footer of the current page.
    procedure WritePageMarkings;

    //Starts a new page.
    procedure NewPage(FirstPage: Boolean = False);
    //Starts a new page if the current is not still empty.
    procedure ClearPage;
    //Starts a new page if the given number of lines won't fit on the current
    //one.
    procedure EnsurePageLines(Lines: Integer);



    //Registers the current position in the document by the internal name.
//    procedure CreateDestination(const LabelName: String);


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -