Beiträge von jredoc

    I have solved the central question by not using SetNumberStyle but iterating through the paragraphs individually. See code below.

    The question is now how to place a bullet in each paragraph. If I select a symbol from the bullet dialog the current paragraph will be indented and the selected symbol will be placed in front of the paragraph. The question is now how to capture that symbol after it is selected so I can place in the front of the paragraph as done below?

    if SpeedButtonSectionNumbers.Down = True then
    begin
    with WPRichText1 do
    begin

    tempParStyle := WPRichText1.ParStyles.AddStyle('Numbering');
    tempParStyle.ASet(WPAT_IndentFirst, -300);
    tempParStyle.ASet(WPAT_IndentLeft, 360);

    I := 1;
    tempParagraph := FirstPar;

    while tempParagraph <> nil do
    begin
    if tempParagraph.ContainsText = True then
    begin
    if tempParagraph.IsCharStyle(1, WPSTY_Bold) = False then
    begin
    tempString := IntToStr(I) + '. ';
    tempString := tempString + tempParagraph.GetText(False,False);
    tempParagraph.SetText(tempString, WPRichText1.AttrHelper.CharAttr);
    tempParagraph.SetStyle('Numbering', False, False);

    I := I + 1;
    end
    else
    begin
    I := 1;
    end;
    end;

    tempParagraph := tempParagraph.NextPar;
    end;

    ReformatAll(True,True);
    end;
    end

    TIA

    John

    Julian

    Your suggestions

    a) does FormatOptionEx wpfAutoRestartSimpleNumbering helps here?

    this had no effect;

    b) to switch OFF the numbering please do not use SetNumberStyle, Instead assign 0 to property CurrAttr.NumberStyle.

    Resolved the issue of multiple line paragraphs having lines > 1 continuing to be indented after numbering is turned off.


    The continuing problem is that if two carriage returns are issued after a paragraph to create a blank line between paragraphs, the blank line continues to be numbered.

    It appears that numbering is based on the start of a paragraph and a paragraph is defined as the characters between two carriage returns. If so, it seems logical that there would be a way to prevent numbering of a blank line (or paragraph with no text or spaces between the carriage returns)

    Further suggestions?

    TIA

    John

    After looking at the numbering demo I have the following questions.

    a) it appears that after each carriage return a new number is issued. If formating is done after the document is created and two carriage returns are issued to create a blank line between paragraphs, the blank line is also numbered.

    Is there a mechanism to prevent numbering of blank lines between paragraphs?

    b) If I use the code below and raise the speed button, the numbering is removed, but in paragraphs consisting of more than one line, all lines after the first line continue to remain indented.

    Is there a mechanism to restore the entire paragraph back to its "non indented" state via code?

    c) I do not think this is possible, but one does not know what one does not know. Instead of using the case statement to define the tempStyle variable (see the OnClick method below), is it possible to: a) take the text of the wwDBComboBoxNumber b) type cast the string as a TWPNumberStyle and c) eliminate the case statement? Something like the following?

    Code
    var  tempString: String;  tempPointer: PChar;  tempStyle: TWPNumberStyle;begin  tempStyle := wwDBComboBoxNumberStyle.Text as TWPNumberStyle;


    or


    TIA

    John

    What is the solution if I am using a dynamically created CustomRTFEdit component which has no insertpoints property?

    tempRTFEdit := TWPCustomRTFEdit.CreateDynamic;
    tempWPPDFExport:= TWPPDFExport.Create(nil);

    try
    begin
    with tempWPPDFExport do
    begin
    Filename := tempPDFPathAndName;
    Source := tempRTFEdit;
    FontMode := wpUseTrueTypeFonts;
    CidFontMode := wpCIDOff;
    PDFAMode := wpdfaOff;
    CompressStreamMethod := wpCompressNone;
    AutoLaunch := False; // Do not show when completed
    end;

    tempRTFEdit.LoadFromFile(tempRTFPathAndName,true,'AUTO');
    tempRTFEdit.ReformatAll(true,false);
    tempWPPDFExport.Print;

    TIA

    John

    With Delphi 2009, WPTools 6.05.7 and wPDF 3.55

    If I save a document in WPRichText component that contains merged fields and then create a pdf file using the code below, the merge field markers are displayed in the pdf document. Is there a mechanism to prevent the display of these markers?

    tempRTFPathAndName := tempFilePath + adsTablePtLetters.FieldByName('FileName').AsString;

    tempPDFPathAndName := tempRTFPathAndName;
    tempPDFPathAndName := Copy(tempPDFPathAndName, 1, Length(tempPDFPathAndName) - 3);
    tempPDFPathAndName := tempPDFPathAndName + 'pdf';

    tempRTFEdit := TWPCustomRTFEdit.CreateDynamic;
    tempWPPDFExport:= TWPPDFExport.Create(nil);

    try
    begin
    with tempWPPDFExport do
    begin
    Filename := tempPDFPathAndName;
    Source := tempRTFEdit;
    FontMode := wpUseTrueTypeFonts;
    CidFontMode := wpCIDOff;
    PDFAMode := wpdfaOff;
    CompressStreamMethod := wpCompressNone;
    AutoLaunch := False; // Do not show when completed
    end;

    tempRTFEdit.LoadFromFile(tempRTFPathAndName,true,'AUTO');
    tempRTFEdit.ReformatAll(true,false);
    tempWPPDFExport.Print;
    end
    except
    begin
    MessageDlg('A pdf file was unable to be created from the ' + tempRTFPathAndName + ' file.',
    mtError, [mbOK], 0);
    tempContinue := False;
    end;

    if tempWPPDFExport.Printing then
    begin
    tempWPPDFExport.EndDoc;
    end;

    tempWPPDFExport.Free;
    tempRTFEdit.Free;
    Screen.Cursor := crDefault;
    end;

    After loading an existing rtf file into a WPRichText component I need to prevent modification of text, formatting etc under certain conditions. If I simply set WPRichText.enabled := False then the vertical scroll bar is also inactive and multiple page text can not be viewed.

    It would be very nice to have a BeforeModify event associated with the WPRichText component. Does anyone have alternative solutions?

    TIA

    John

    I can create a pdf from the WPRichText component utilizing the code below.

    WPPDFExport:= TWPPDFExport.Create(nil);
    WPPDFExport.Source := WPRichText1;
    try
    begin
    WPPDFExport.FileName := tempEMailAttachment;
    WPPDFExport.Print;
    end;
    finally
    WPPDFExport.Free;
    end;

    Is there a mechanism to create a pdf by directly loading the rtf file that was created from the WPRichText1 component? This would be more direct than reloading the rtf file into the WPRichText1 component and then using this component as the WPPDFExport.Source as in the code above.

    TIA

    John

    Hello


    The scenerio involves
    a) A datamodule with multiple tables each attached to a datasource and a wpmmDataProvider
    b) all WPMMDataProviders are attached to a single WPRichText component
    c) each WPMMDataProvider is attached to a subsequent WPMMDataProvider via the NextDataProvider property and the last WPMMDataProvider is attached to the first WPMMDataProvider

    d) Each table has a common field "socialsecurity" all other field names are different
    e) The tables are filtered by "SocialSecurity" and in some cases this results in no records being displayed.

    f) WPRichText1.InsertPointAttr.hidden := True;
    g) The ShowFieldNames := False for all of the WPMMDataProviders then

    If all tables have one or more records then the information in the socialsecurity field displays in the associated merge field. However, if one or more of the tables have no records then the socialsecurity information is not displayed. Why?

    I have tried - to no avail
    a) having the last WPMMDataProvider not attached back to the first WPMMDataProvider
    b) making all tables with a record count of 0 inactive

    Any help would be greatly appreciated.

    John

    Answer to 2a)

    Mechanism to determine if merge fields are present
    procedure TformWordProcessor.SpeedButton2Click(Sender: TObject);
    var
    tempTextObjList: TWPTextObjList;
    I: Integer;
    begin
    tempTextObjList := TWPTextObjList.Create;

    WPRichText1.FieldGetList(tempTextObjList, True, '');

    if tempTextObjList.Count > 0 then
    begin
    showmessage('Merge fields present');
    for I := 1 to tempTextObjList.Count - 1 do
    begin
    showmessage(tempTextObjList.Items[I].Name);
    end;
    end
    else
    begin
    showmessage('Merge fields not present');
    end;
    tempTextObjList.Destroy;
    end;

    John

    I have two questions

    1) If an infopower datasource TwwDataSource is used to attach a table to a WPMMDataProvider instead of a TDataSource, the mailmerge4 demo does not display the field values when

    WPRichText1.InsertPointAttr.hidden := False;
    formMailMerge.WPMMDataProvider2.ShowFieldNames := True;

    Is there a solution for this?

    2) If an existing template containing mailmerge fields is opened in a WPRichText component is there a mechanism to determine via code:
    a) if the document, in fact, contains mailmerge fields,
    b) what the name of the database field referenced by the mailmerge field is and
    c) the name of the database table that is referenced?

    TIA

    John

    I can move to the beginning or end of a document by using the MovePosition(wpmEnd, False) or MovePosition(wpmHome, False)

    There was discussion in the user group about using CPPosition to move to a specific page, For example page 6 would be CPPostion := 6; However, this code in version 5.21 now moves the cursor six characters forward.

    What is the mechanism to move to a specific page number?

    Suggestions?

    TIA

    John Eastman

    I have a project which was upgraded from WPTools4 to WPTools5.

    In the WPToos5 environment, if I create the OnPaintExternalPage event I get a complier error - Undeclared Identifier 'TCanvas'.

    I suspect that with the unit changes from WPTools4 to 5 I am missing a unit. Does anyone know which one?

    TIA

    John Eastman