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

📄 sectappendu.pas

📁 wptools5 pro 完整源代码 Msword界面的文本编辑器源代码
💻 PAS
字号:
unit SectAppendU;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, WPRTEDefs, WPCTRMemo, WPRTEPAint, ExtCtrls, WPCTRRich,
  WPUtil, WPPrvFrm;

type
  TWPALL = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    WP2: TWPRichText;
    WP1: TWPRichText;
    Panel3: TPanel;
    WP3: TWPRichText;
    Panel4: TPanel;
    Panel5: TPanel;
    WPAll: TWPRichText;
    Append: TButton;
    TestRTF: TButton;
    TestWPT: TButton;
    Append2: TButton;
    AppendWithStrings: TButton;
    Button2: TButton;
    WPPreviewDlg1: TWPPreviewDlg;
    procedure AppendClick(Sender: TObject);
    procedure TestRTFClick(Sender: TObject);
    procedure TestWPTClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Append2Click(Sender: TObject);
    procedure AppendWithStringsClick(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  WPALL: TWPALL;

implementation

{$R *.dfm}

{ This code shows how sections are created and appended to a editor.
You can also use the function TWPRTFDataCollection.AppendAsSection which does
basically the same. See Append2Click() }
procedure TWPALL.AppendClick(Sender: TObject);
   procedure AppendText(Source : TWPRTFDataCollection);
   var sectionprops : TWPRTFSectionProps ;
       i   : Integer;
       textblock : TWPRTFDataBlock;
   begin
     // Create a new Page if required
     if WPAll.IsEmpty then
          WPAll.CheckHasBody
     else WPAll.InputString(#12);
     // Create new section properties
     sectionprops := WPALL.HeaderFooter.AddSectionProps;
     // Assign the default page size
     sectionprops.Assign(Source.Header);
     sectionprops.Select := [wpsec_PageSize,wpsec_Margins];
     // Copy all header + footer into certain section
     for i:=0 to Source.Count-1 do
       if Source[i].Kind in [wpHeader, wpFooter] then
       begin
         textblock := WPALL.HeaderFooter.Append(
           Source[i].Kind,
           Source[i].Range,
           Source[i].Name);
         textblock.UsedForSectionID := sectionprops.SectionID;
         textblock.RtfText.Assign(Source[i].RTFText);
       end;
     // The current paragraph starts this section
     WPAll.ActiveParagraph.SectionID := sectionprops.SectionID;
     include(WPAll.ActiveParagraph.prop,paprNewSection);
     // Copy the text as part of a certain section
     WPAll.CPPosition := MaxInt;
     WPAll.SelectionAsString := Source.AsANSIString('WPTOOLS');
   end;
begin
  WPAll.Clear;
  AppendText(WP1.HeaderFooter);
  AppendText(WP2.HeaderFooter);
  AppendText(WP3.HeaderFooter);
end;

procedure TWPALL.Append2Click(Sender: TObject);
begin
  WPAll.HeaderFooter.AppendAsSection(WP1.HeaderFooter);
  WPAll.HeaderFooter.AppendAsSection(WP2.HeaderFooter);
  WPAll.HeaderFooter.AppendAsSection(WP3.HeaderFooter);
end;

{ We use strings in WPTOOLS format. A section is started
  with the </newsection> tag which also inserts a page break.
  </newsection> is never written in WPTOOLS format it
  is only used to make it possible to concat text
  without using a instance of the WPTools editor }
procedure TWPALL.AppendWithStringsClick(Sender: TObject);
begin
  WPAll.AsString := '<newsection/>' + WP1.AsANSIString('WPTOOLS')
   +'<newsection/> ' + WP2.AsANSIString('WPTOOLS')
   +'<newsection/> ' + WP3.AsANSIString('WPTOOLS');
  // Using <newsection pagebreak=0/> no page break will be inserted
end;

procedure TWPALL.TestRTFClick(Sender: TObject);
begin
  WPAll.AsString := WPAll.AsANSIString('RTF');
end;

procedure TWPALL.TestWPTClick(Sender: TObject);
begin
  WPAll.AsString := WPAll.AsANSIString('WPTOOLS');
end;

procedure TWPALL.FormCreate(Sender: TObject);
begin
 WPAll.AutoZoom := wpAutoZoomAsManyAsPossibleInRow;
 WPAll.FormatOptions := [wpDisableSpeedReformat];
 WPAll.ViewOptions := [wpDontGrayHeaderFooterInLayout];
end;





procedure TWPALL.Button2Click(Sender: TObject);
begin
   WPPreviewDlg1.Execute;
end;

end.

⌨️ 快捷键说明

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