Beiträge von cbarrer

    Hi

    I have problems when I read Microsoft Word documents that have automatic numbering.

    The problems are of three types:

    1. Indentation problems: unpredictable, unmanageable (some times indentfirst and indent left work, sometimes not). When I can manage them from WPTools, the next document works different, so the solution in one document doesn't work with the next.

    2. Some numbered paragraphs come without space separating it from the next, if I want to insert a blank paragraph a new automatic number is created.

    3. Sometimes numbering is absurd, for example it begins with 2, not 1. Or there are times when two or more continuos numbered paragraphs have the same number (2. ... / 2. ...)

    So, when a Word document is read, I want to change automatic numbered paragraphs for just plain text with numbers.

    A desired solution would be:

    - For each paragraph test to see if it is a numbered paragraph (ele := par.GetNumberStyleEle; // if ( ele <> nil ) then begin ... end;)
    - If it is a numbered paragraph: 1. read the number (how?); 2. delete the numbering style for the paragraph (how?); 3. Add the former number "manually" at the beginning of the paragraph.
    - I also would have to know which paragraphs are part of a group to mantain the sequence, or I would have to go first to the last paragraph of a numbered sequence and begin changing numbering with it.

    Can I do that? How?

    With kind regards,

    Carlos Borrero

    I would like to change automatic numbering for text with numbers I can change manually.

    How can I delete NumberStyles and change automatic numbers for editable text?

    With NumberStyles I have, for example:

    1. First text
    2. Second text
    3. Third text

    Without numbering I would see the same, but I could change 1., 2. and 3. manually.

    Does anybody know how to do that?

    I need to loop through all the text of a document and change font color depending on a certain condition.

    I tried a lot of different alternatives, some worked, some didn't.

    Tha alternatives that worked use CPAtt which I understand is deprecated. None of the alternatives that use GetCharAttr worked.

    Now my interest is to know how to use an alternative that doesn’t need a deprecated method, CPAttr.

    How and when can I use?:

    - TextCursor.CurrentCharAttr.AGet
    - TextCursor.CurrentCharAttr.ASetColor
    - CurrentCharAttr.GetColor / GetColorNR
    - CurrentCharAttr.SetColor / SetColorNR
    - CurrentCharAttr.SetBGColor

    How can I evaluate and get the font color of a certain char, using TextCursor.CurrentCharAttr or CurrentCharAttr?

    When do I have to use TextCursor.CurrentCharAttr and when just CurrentCharAttr ?

    I would like to know why the code I wrote that doesn’t work, doesn’t work?

    The alternatives I used are:

    Code
    var  par   : TParagraph;  i     : integer;  a     : TWPCharAttr;  props : TWPRTFProps;  col   : integer;  bgCol : Integer;begin // Change colors   // Works   with WPRichText do begin     CPPosition := 0;     col        := CurrAttr.ColorToNr(clBlack, false);     bgCol      := 0;     BeginUpdate;     repeat       if ( CPAttr.Color <> col ) then begin          CPAttr.Color := col;          CPAttr.IncludeStyle(afsBold);       end; // if ...       if ( CPAttr.BGColor <> bgCol ) then begin          CPAttr.BGColor := bgCol;          CPAttr.IncludeStyle(afsBold);          CPAttr.IncludeStyle(afsUnderline);          // CPAttr.Style   := CPAttr.Style + [afsBold] + [afsUnderline]; // Working alternative          // CurrAttr.AddStyle([afsBold, afsUnderline]); // Working alternative       end; // if ...     until not ( CPMoveNext );     EndUpdate;   end; // with ...      // Works, but is slower than the last method   with WPRichText do begin     CPPosition := 0;     col        := CurrAttr.ColorToNr(clBlack, false);     repeat       if ( TextCursor.CPAttr.Color <> col ) then begin          TextCursor.CPAttr.Color := col;          TextCursor.CPAttr.IncludeStyle(afsBold);          // TextCursor.CPAttr.Style := TextCursor.CPAttr.Style + [afsBold]; // Working alternative       end; // if ...     until not ( CPMoveNext );   end; // with ...   // Works   col                   := WPRichText.CurrAttr.ColorToNr(clBlack, false);   WPRichText.CPPosition := 0;   par                   := WPRichText.FirstPar;   props                 := WPRichText.ActiveText.RTFProps;   WPRichText.BeginUpdate;   while ( par <> nil ) do begin     for i := 0 to par.CharCount-1 do begin       if ( WPRichText.CPAttr.Color <> col ) then begin          props.Attributes.GetCharAttr(par.CharAttr[i], a);          props.AttrInterface.SetColor(a, clRed);          props.AttrInterface.IncludeStyle(a, afsBold);          props.Attributes.SetCharAttr(par.CharAttr[i], a);       end; // if ...        WPRichText.CPMoveNext;     end; // for ...     par := par.next;     WPRichText.CPMoveNext;   end; // while ...   WPRichText.EndUpdate;   WPRichText.Refresh;   // Doesn’t work   col   := WPRichText.CurrAttr.ColorToNr(clBlack, false);   par   := WPRichText.FirstPar;   props := WPRichText.ActiveText.RTFProps;   WPRichText.BeginUpdate;   while ( par <> nil ) do begin     for i := 0 to par.CharCount-1 do begin       props.Attributes.GetCharAttr(par.CharAttr[i], a);       // if not ( props.AttrInterface.GetColor(a, col) ) then begin // Doesn’t compile       if not ( props.AttrInterface.GetColorNR(a, col) ) then begin          props.Attributes.GetCharAttr(par.CharAttr[i], a);          props.AttrInterface.SetColor(a, clRed);          props.AttrInterface.IncludeStyle(a, afsBold);          props.Attributes.SetCharAttr(par.CharAttr[i], a);       end;     end;     par := par.next;   end;   WPRichText.EndUpdate;   WPRichText.Refresh;   // Doesn’t work   with WPRichText do begin     CPPosition := 0;     col        := CurrAttr.ColorToNr(clBlack, false);     BeginUpdate;     repeat       if not ( TextCursor.CurrentCharAttr.AGet(WPAT_CharColor, col) ) then begin       // if not ( TextCursor.CurrentCharAttr.AGet(WPAT_CharColor, clBlack) ) then begin // Doesn’t compile          TextCursor.CurrentCharAttr.ASetColor(WPAT_CharColor, col);          TextCursor.CurrentCharAttr.ASetAdd(WPAT_CharStyleON, WPSTY_BOLD);       end; // if ...     until not ( CPMoveNext );     EndUpdate;   end; // with ...      // Doesn’t work   with WPRichText do begin     col        := CurrAttr.ColorToNr(clBlack, false);     CPPosition := 0;     repeat       // if not ( CurrentCharAttr.GetColor(clBlack) ) then begin // Doesn’t compile       // if not ( CurrentCharAttr.GetColorNr(clBlack) ) then begin // Doesn’t compile       // if not ( CurrentCharAttr.GetColor(col) ) then begin // Doesn’t compile       if not ( CurrentCharAttr.GetColorNR(col) ) then begin          CurrentCharAttr.BeginUpdate;          CurrentCharAttr.SetColor(clBlack);          CurrentCharAttr.IncludeStyles([afsBold]);          CurrentCharAttr.EndUpdate;       end; // if ...     until not ( CPMoveNext );   end; // if ...   // Doesn’t work   with WPRichText do begin     CPPosition := 0;     col        := CurrAttr.ColorToNr(clBlack, false);     BeginUpdate;     repeat       if ( CurrAttr.GetColorEx(WPAT_CharColor) <> col ) then begin          CPAttr.Color := col;          CPAttr.IncludeStyle(afsBold);       end; // if ...     until not ( CPMoveNext );     EndUpdate;   end; // with ...   // Doesn’t work   with WPRichText do begin     CPPosition := 0;     col        := CurrAttr.ColorToNr(clBlack, false);     bgCol      := 0;     BeginUpdate;     repeat       if ( CurrAttr.Color <> col ) then begin          CurrAttr.Color := col;          CurrAttr.AddStyle([afsBold]);       end; // if ...       if ( CurrAttr.BKColor <> bgCol ) then begin          CurrAttr.BKColor := bgCol;          CurrAttr.AddStyle([afsBold, afsUnderline]);       end; // if ...     until not ( CPMoveNext );     EndUpdate;   end; // with ...   // Doesn’t work   with WPRichText do begin     CPPosition := 0;     col        := CurrAttr.ColorToNr(clBlack, false);     bgCol      := 0;     BeginUpdate;     repeat       if ( CPAttr.Color <> col ) then begin          CurrAttr.Color := col;          CurrAttr.AddStyle([afsBold]);       end; // if ...       if ( CPAttr.BGColor <> bgCol ) then begin          CurrAttr.BKColor := bgCol;          CurrAttr.AddStyle([afsBold, afsUnderline]);       end; // if ...     until not ( CPMoveNext );     EndUpdate;   end; // with ...   // Strange results, doesn’t work   with WPRichText do begin     CPPosition := 0;     col        := CurrAttr.ColorToNr(clBlack, false);     bgCol      := 0;     BeginUpdate;     repeat      if ( CurrAttr.Color <> col ) then begin       // if ( CurrAttr.Color <> clBlack ) then begin // This alternative compiles          CPAttr.Color := col;          CPAttr.IncludeStyle(afsBold);       end; // if ...       if ( CurrAttr.BKColor <> bgCol ) then begin          CPAttr.BGColor := bgCol;          CPAttr.IncludeStyle(afsBold);          CPAttr.IncludeStyle(afsUnderline);       end; // if ...     until not ( CPMoveNext );     EndUpdate;   end; // with ...end; // Change colors

    I also used:

    Code
    for i := 0 to WPRichText.TextColorCount - 1 do
      WPRichText.TextColors[i] := clBlack;

    This code led me to paragraphs unreadable, with black background.

    I understand I can also use styles, but as I am exporting the text to an RTF file that can be read by Microsoft Word, I didn't use styles.

    Kind regards,

    Carlos Borrero

    Hi:

    With a TWPRichText control I need to click on a thumbnail when LayouMode is wpThumbNailView, change to LayoutMode and show the corresponding page where the click was made.

    If the click was made over some text I want to position the cursor at the same place. If the click was made over areas with no text -or page numbers- I want the cursor positioned at the beggining of the corresponding page.

    I am using the following code, but it doesn't work:

    Code
    procedure TForm1.WPRichTextClick(Sender: TWPCustomRtfEdit; PageNo, X, Y: Integer; var Ignore: Boolean);
    begin
      if ( Sender.LayoutMode = wpThumbNailView ) then begin
         Sender.LayoutMode := wplayLayout;
         Sender.ScrollToPosition(Sender.CPPosition, X, Y);
      end; // if ...
    end;

    Kind regards,

    Carlos Borrero

    What is wrong with the following code?, it doesn't work, LocalHyperlinkObjects.Count is allways 0, no mather how many hyperlinks are in the document:

    Code
    LocalHyperlinkObjects := WPRichText.CodeListTags(wpobjHyperlink, '*ALL*', true);
    try
      for j := 0 to LocalHyperlinkObjects.Count - 1 do begin
         LocalHyperlinkObjects[j].Free;
      end; // for ...
    finally
      LocalHyperlinkObjects.Free;
    end;

    Kind regards,

    Carlos Borrero

    I need to read a MSWord document that has footnotes, copy the document on a second wprichtext control, and transform footnotes to text at the end of the document.

    The reference to an old footnote has to be replaced by a hyperlink that links to the text of the old footnote (at the end of the document), and the old footnote number has to have another hyperlink that links to the reference of the footnote.

    Do you have any ideas, please?

    Kind regards,

    Carlos Borrero

    Hi:

    I want to get to a certain point in text that has a hyperlink, test it's data and delete it or change it depending on a condition.

    Also, how can I create a list of all the embebded data on hyperlinks in a document? I will test each item on the list, change it depending on a condition and then will go back to the document to change embebded data on hyperlinks. How can I do that?

    Any ideas that could help me?

    Kind regards,

    Carlos Borrero

    Hi:

    Using WPTools 6 I need to get to a certain line of text that has two hyperlinks, and form a string with plain text plus sign '&', plus hyperlink hidden data, just after the text that corresponds to each hyperlink.

    For example, I need to have the following string:

    "I want to travel to Berlin&[HLK_Data1] and to Munich&[HLK_Data2] this year".

    Can you please help me?

    Kind regards,

    Carlos Borrero

    I have an application compiled on 2005 10 24, that uses WPTools V. 4.25. This application reads rtf documents generated with another application that also uses V. 4.25.

    All of a sudden (until this week) my old reading application began to show some documents with huge spacing between lines.

    If I copy some of these lines, paste them to Word from Microsoft and check paragraph properties, it appears that spacing is set to "minimum 50 points".

    How can I solve this problem, what properties to I have to change in my rtf documents, or in my old reading application?

    Kind regards.

    Carlos Borrero

    Julian:

    Thank you for your answer, but I don't know how to solve the problem.

    You advise me to write WPRichText1.GetLineFromXY. Do you mean to copy the procedure that is part of WPTools5, on my program, using WPTools6?

    If the answer is yes, in what file can I find GetLineFromXY? Do I need to write GetPointFromParLin also?

    Kind regards.

    Carlos Borrero

    1. I Need to show a special hint window next to a hyperlink when mouse moves over it.

    To do that I need to know the screen coordinates, I have been trying the X and Y coordinates that event onMouseMove returns, but those don't seem to be the appropiate ones.

    Can you please tell me how to calculate those screen coordinates?

    2. I need to move the cursor over a hyperlink when the mouse moves over it.

    How does WPRichText do that?

    Kind regards.

    Carlos Borrero

    The following code doesn't work either:


    The problems seems to be on the following line:
    LocalLinea := WPRichText_Work.TextCursor.active_line;

    I suppose WPRichText_Work.TextCursor.active_line reads the line number, within a paragraph.

    But seems it doesn't.

    Any ideas on how to know the line number within a paragraph that corresponds to CPPosition?

    LineOffset and LineLength need to have this parameter.

    Kind regards,

    Carlos Borrero

    I use the following code to read three lines of text:

    What is the equivalent code using WPTools6?

    Thank you in advance for your help.

    Kind regards,

    Carlos Borrero