Beiträge von Fragnani

    Hi,

    Well, you didn't say you wanted to move between tables in the original post :)

    There is no 'automatic way' to move between tables. You must navigate through paragraphs, checking if ParagraphType is wpIsTable. But while doing this, check if you are 'still in the same table' (ParentTable, I guess), otherwise, it will not work.

    Alessandro Fragnani

    Hi,

    1. First you need do 'find the header'. WPTools 5 allows various headers on the sema file, but to simplify, just use

    Code
    WorkOnText := wpIsHeader;

    2. Then you move the Caret to the end of the 'activetext', and add an empty line:

    Code
    oWPRichText.CPPosition := MaxInt;oWPRichText.InputString(#13);

    3. Now you define the text attributes (center alignment in your case):

    Code
    oWPRichText.CurrAttr.Alignment := paralCenter;

    4. And at last, add your text

    Code
    oWPRichText.InputString(PChar('my text'));

    You may hit the wall with some 'text formats', so take care of:

      a) fields (protected areas)
      b) borders
      c) shading
      d) textstyles


    If you change anything, call this two functions to 'refresh' the things:

    Code
    oWPRichText.ChangeApplied;
    oWPRichText.DoUpdateCharAttr;


    Hope this helps

    Alessandro Fragnani

    I have Addict (version 3.4.3), but I can't find it. It only has AutoReplace, which does not:

    1. Shows a hint window with the 'replaceable text'
    2. Allow 'replaceable text' to be RTF/HTML Format

    Doing the autocomplete myself, I was able to add this features

    Alessandro

    Hi Marcio

    I had to work with some steps:

    1. At OnKeyPress, check for possible autocompletes. I only recognize the 'prefix' starting at the forth character, like MSWord does
    2. If has, show the hint. I created my own THintWindow
    3. Also at OnKeyPress, if the key is ENTER, I replace the 'prefix' by the autocomplete text
    4. In some places, like MouseDown, KeyDown and KeyPress (when is a different key), I release the HintWindow.

    Finding the 'prefix' is the worst algorithm, because I had to work with WPWordDelimiterArray and par.ANSIChr, to ignore invalid characters. The rest, is simple.

    Alessandro

    Hi,

    I have some .DOC files that are being converted to .RTF files, using MSWord OLE instructions. Everything is ok. Then I load the .RTF files in TWPRichText to make some processing, like replacing the header with my own header, adding some content to the body, etc. Then I save the .RTF file. When I do this, it appears in the beggining of the body a word (SomeNameXX)that originally wasn't there. Looking at the RTF file I noted that this word is the \company tag, in \info section. Searching at the original .RTF file created with MSWord, the tag is a bit different, being handled as a \* tag kind. Looking at WPIOWriteRTF.pas unit, I found that besides company, also manager, category and hlinkbase are handled equally, and should has the same problem.

    Original .RTF file create with MSWord:

    Code
    {\info{\title  }{\author Administrador}{\operator alessandrofm}{\creatim\yr2008\mo8\dy1\hr16\min16}{\revtim\yr2008\mo8\dy1\hr16\min25}{\version3}{\edmins10}{\nofpages1}{\nofwords170}{\nofchars918}{\*\company SomeNameXX}

    .RTF file created with WPTools

    Code
    {\info{\*\title  }{\*\author Administrador}{\*\operator alessandrofm}{\company SomeNameXX}}{\*\userprops {\propname myownrtfvariable}\proptype30{\staticval 09/07/2008 16:35:26}

    WPIOWriteRTF.pas code handling this tags:

    Code
    if (s = 'manager') or (s = 'company') or (s = 'category') or (s = 'hlinkbase') then
                  s := '{\' + s + #32
                else s := '{\*\' + s + #32;
                WriteString(s);

    Why isn't being used the \* tag there, so it should be ignored and content and handled as a simple info tag?

    Oh, by the way, I cannot turn off saving RTF Variables, because I need UserProps to be saved.

    Thanks for your help

    Alessandro

    Hi,

    I have a routine that was processing some RTF files, that originally contained 'linked images' (using old StreamLoadEvent in WPTools 4), and after executing it in WPTools 5, without HTTPImageRequest event, the linked images now appears as a 'white box with red borders'. The files were already processed, and I need to 'restore' the linked images as a separate routine.

    I could create the routine to 'restore the original linked image', doing some stringreplace code, but now I'm having a problem with the size (width / height) of the image itself. The image that is inside the RTF file may have different size of the original image (because the user decided to resize it), but I don't know how to get the size of the 'white box image'. I tried to use WPRichText.TextObjects list, but the image itself doesn't seems to be a textobject. I couldn't find a way to get its dimensions. Does anyone has an idea how to do this?

    The 'white box' image has this rtf code:

    Code
    {\*\wptools\wpomode0\wpoframe0{\*\wppicname{brasoes\\\\1.bmp}}{\*\wppicsource{brasoes\\1.bmp}}{110e190054575054656d7053617665546578744f626a48656c70657200545046301854575054656d7053617665546578744f626a48656c7065720007576964746854570325050848656967687454570348050c57726974655254464d6f6465070c776f624175746f6d617469630545787472610655547970653a31323b4e616d653a22627261736f65735c5c312e626d70223b536f757263653a5b5b627261736f65735c312e626d705d5d3b57696474683a313331373b4865696768743a313335323b577261703a303b064f626a546167020000003f3f3f00}}

    And the 'desired rtf code' should be this:

    Code
    {\*\wppicname{brasoes\\\\1.bmp}}{\*\wppicsource{brasoes\\1.bmp}}{\field{\*\fldinst{INCLUDEPICTURE "brasoes\\\\1.bmp" MERGEFORMAT \\d \\w2610 \\h885}}}

    Thanks for your help

    Alessandro

    Hi,

    Does anyone knows if it is possible to custom draw fields (basically the color) based on a specified condition? I would like to have my 'special fields' being draw in a different color from the one defined in AutomaticTextAttr.TextColor.

    Thanks in advance

    Alessandro Fragnani

    Hi Julian,

    I tried your suggestion, but it simply has no effect. I removed the TextColor definition from "AutomaticTextAttr" and added, at the end of OnMailMergeGetText the following code:

    Code
    TWPRichText(Sender).SelectedTextAttr.SetColor(clRed);

    Is there anything else that must be done?

    I tried another approach. I found a OnGetAttributeColor event in TWPRichText, and defined UseOnGetAttColorEvent to TRUE. The 'normal fields' are correctly drawn, but the 'table fields' are ignored.

    Do you have any other idea ?

    Code
    procedure TMyForm.wpRTFGetAttributeColor(Sender: TObject; var CharStyle: TCharacterAttr; par: TParagraph; posinpar: Integer;
    begin
      if TWPRTFEnginePaint(Sender).RTFData.RTFProps.Environment._globale_printing = 0 then
        CharStyle.TextColor := clRed
      else
        CharStyle.TextColor := clNone;
    end;

    Is there any reason for this event never fires?

    Thanks in advance

    Alessandro Fragnani

    Hi Julian,

    Well, I don't know what kind of 'speed issues' you mean, but it if a table has ProtectedTextAttr set, with a similar color combination, the text is drawn as expected.

    So, what do you suggest me to solve this issue?

    Off course that I could color the text itself 'by hand' based on the color of AutomaticTextAttr, but I can't do this. Basically because while printing, I need it to be 'black' (bacause I'm using AlsoUseForPrintout = FALSE). Unless I would have a speedy routine that could be used to simulate the expected behavior.

    Thanks in advance.

    Alessandro Fragnani

    Hi,

    I have a merging process that, in some cases, needs to result a 'table'. To accomplish it, I'm using an additional WPRichText, in which I create the table, via code, using AppendNewTable, AppendNewRow and AppendNewCell, adding the cell contents using cell.SetText('the text', cha).

    The Merged WTPRichText, that contains my template, has defined AutomaticTextAttr.TextColor as clRED, but when the merging process is called and the table created, the contents of the cell doesn't appears as RED. I also define AutomaticTextAttr.BackgroundColor as clSILVER, and the background color of the text in the cells also aren't SILVER.

    Off course that I'm using UseTextColor and UseBackgroundColor as TRUE.

    If instead of a table I return a simple text, the font color is RED, as expected.

    Any ideas?

    Thanks in advance.

    Alessandro Fragnani

    Hi Julian,

    Yes, I found it later. The HTML is now almost good, but the RTF itself is not just like it was before (when using absolute values). The column widhts are not as good as was before. But it must be something else. I will check it later and maybe come back here for more help :)

    Thanks for your help

    Alessandro Fragnani

    Hi,

    I'm creating tables 'in code' using 'AppendNewTable', 'AppendNewRow' and 'AppendNewCell'. I have a routine that determines the width of each cell (that combined, sums like the page width, minus a gap), but I use 'absolute values', instead of 'percentual'.

    When I'm converting the RTF File created, instead of 'centered', 'autosized tables', I have tables 'aligned to right, with fixed width.

    Is there an easy/quick way to set the table width itself to be '100%' of the page, so the column widths should 'internally convert it to percent instead of absolute values', or should I change my entire routine to use percent, instead of absolute? I tryied using ASet(WPAT_BoxWidth_PC, 100), with no success (the table width was messed up).

    Thanks in advance

    Alessandro Fragnani

    Hi,

    How can I determine the width of piece of text (a word, for instance)? I know Canvas.TextWidth(text) returns this in normal Windows application, but it doesn´t work for WPTools since zooming/scaling, etc.

    I'm asking because I have to create a dynamic table, which each column may have any size. So, I have to get each column name, discover its width, and create the cell, with that width (plus a spacing between borders).

    Thanks in advance

    Alessandro Fragnani

    Hi Julian,

    Unfortunatelly the use of BeforeInitializePar is unacceptable. This event is fired all the time and I have no way to find out if I must process that paragraph or not (at least I couldn't find one). It will be an unnecessary overhead.

    Then I was looking for some virtual procedure that I could override, but unfortunatelly TWPRTFDataCollection.Undo is not virtual. Then I thought that should exists a BeforeUndo/AfterUndo, and I found TWPRTFDataCollection.BeforeUndoApply and TWPRTFDataCollection.AfterUndoApply, but none is fired, never! Why this? Looking at TWPRTFDataCollection.UndoStack function I noted that it connects OnBeforeApply and OnAfterApply events to BeforeUndoApply and AfterUndoApply, but while in TWPUndoStack.DoBeforeApply and procedure TWPUndoStack.DoAfterApply, it never gets the code to call the event. In "Before" because you always send Source as nil. In "After'" because FApplied is False.

    Could you take a look?

    Thanks in advance.

    Alessandro

    Hi Julian,

    The zooming change is a bit better, but still big while greater than 100 (now around 40 instead of 70) and 6 instead o 14 while smaller than 100. The expected behavior was to be "constant", like 2 or 10, but I guess it doesn't respect that because of the "messages infrastructure" that WPTools 5 has. It is probably handling a lot of MouseWheel messages before the reformat is fired by Iddle times.

    Anyway, what about the "Ctrl Key"? Do you intend to change anything? Is your statement "Thanks for the suggestion" related to this?

    Thanks for your help

    Alessandro Fragnani