Posts by ehimmer

    The popup grid dialog invoked from WPACreateTable1 seems to have issues. Creating a 1 row 1 column doesn't work half the time and if you attempt to create a multi-row/col table and the dialog flickers just before you click it sometimes also does not insert the table.

    I know you have a dialog based example to create a table, but the grid method is faster... when it works. Have you run into these issues before?

    WPTools 9.1.820

    Is there an option to make a paragraph color restrict itself to be within the indents? Hey, told a customer I would at least ask. ;) He currently uses a one row one column table to do this.

    Thanks, that seems to do the trick! Sorry for the long narrative. I'm used to other developers needing detailed scenarios to fully understand the issue and sometimes my explanations just makes it worse.

    Sorry, I thought it was obvious. I do not want the font to change when using LoadFromString. If the font in the WPRichText is Times New Roman, it should be Times New Roman when added to the main WPRichText and should not change the font of any existing text in the host WPRichText. My example tries to show that using or not using the -nodefaultfont causes both of this to occur and can make things worse depending on the circumstances.

    This font changing is a disaster for us. This did not occur in WPTools5 but both of our beta testers have run into this font changing issue with our new version using WPTool 9.1. In my example I tried to solve the problem using -nodefaultfont but doesn't help.

    So the problem I need to solve to how to keep the font from changing with LoadFromString. It only seems to occur if the text is defaulting to using f0 when it doesn't have any specific font index selection. That is the problem that needs to be solved. It should be assigned one when using LoadFromString or something I can do to make it have a a font index selection prior to the LoadFromString so that the font table doesn't change which can cause other text that has no specific font index assigned to suddenly changes to a different font should f0 represent a different font than it was prior to the LoadFromString.

    If the host WPRichText has f0 as Arial and f1 as Times New Roman. How do I use LoadFromString which is loading a WPRIchText where the text has not specific font index associated to it? Currently it just then uses f0 which is Arial, but in the WPRichText being loaded f0 was Times New Roman. So after the LoadFromString it is now Arial but should be Times New Roman.

    If I do not use -nodefaultfont, then it sort of works but the font table changes but should not, IMHO. Instead the text that has no font index should have one added to it that indexes the correct font, and adds that font to the table if missing.

    With all that being said. I did an experiment...

    In a normal procedure, a user will export their comments from the old version that uses WPTools5 and import them into our new version that uses WPTools9. Many of these exported comments do not have a specific font index assigned. In only those cases, it ends up using f0 which is Times New Roman. These are the ones that have the problem and cause the font changing issue I need solved.

    Now what I tried was to then use the old version to import them in and export them once more for import into our new version. Somehow, all those comments that did not have a specific font index now do. And the problem is solved. So whatever WPTools5 did to solve assigning a font index to text that has none is what I need to be able to do within WPTools9.


    This is what WPTools9 ends up with in a typical export/import from WPTools5 into WPTools9:

    1. {\*\bkmkstart $linked:<all>}\cf0 There was no kickout flashing details observed at the lower bottom edges of the roof lines interfaces and the sidewalls that continues past the edges of the roofs. The lack of this kickout flashing may and will most likely allow water to penetrate at these points.{\*\bkmkend $linked:<all>}

    Font Table which makes the text Times New Roman even though no font index is present:

    1. {\fonttbl{\f0\fnil\fcharset1 Times New Roman;}{\f1\fnil\fcharset2 Symbol;}

    This is what WPTools9 ends up with after my experiment where I import the re-exported comments:

    1. {\*\bkmkstart $linked:<all>}\f1\cf0 There was no kickout flashing details observed at the lower bottom edges of the roof lines interfaces and the sidewalls that continues past the edges of the roofs. The lack of this kickout flashing may and will most likely allow water to penetrate at these points.{\*\bkmkend $linked:<all>}

    Font table:

    1. {\fonttbl{\f0\fnil\fcharset1 Arial;}{\f1\fnil\fcharset1 Times New Roman;}{\f2\fnil\fcharset2 Symbol;}

    Notice that the text "There was no kickout..." now has a font index assigned to it (f1) whereas before it did not. Having that f1 (which references Times New Roman) is key. Also, the font table was been updated but the text is still Times New Roman. So somehow it properly updated the font table by adding Times New Roman as f1 and added the font index to the text. WPTools9 is not doing this for text with no previous font index assignment.

    I tried ignoreFonts and that just made things worse in other situations because it truly ignored the loaded text fonts. Where I am having an issue is where the text being loaded has no font index assigned to it, so it appears to use the default font 0 index. When loaded and since it has no font index assigned, it takes on the receiving end's font 0 when I use the -nodefaultfont. If I don't use that option, it changes the font table and toggles other text that also does not have a font index assigned to it if f0 was replaced by the loaded text. Text that has a font index assigned gets updated to reference the correct new index.

    Is there a way to force all text to have a font index assigned to it? I could apply this before doing the LoadFromString.

    The process I use is I create a temp WPRichText, LoadFromStream fromthe database into the temp WPRichText and then do a LoadFromString into the main WPRichText. There are reasons I don't go directly into the main WPRichText that I won't get into (other than to say I clone linked images and rename duplicates) but I could use that temp WPRichText to force a font index selection to any text that doesn't have one assigned.

    I have a WPRichText where f0 (default font) is set to Arial and f1 is set to Times New Roman. I know about the -nodefaultfont option, but please read thru.. I hope I explain this clearly.

    I Issue two LoadFromStrings, the first has a default font of Times New Roman and the 2nd has a default font of Arial:

    Loaded via: pWP.LoadFromString(vWP.AsANSIString('WPTOOLS'), 'WPTOOLS');

    Keep in mind that all the text is marked to be Times New Roman, so it might be f0 or f1 depending on the font table.

    The first LoadFromString results in the new text (f0 in its font table is Times New Roman) as showing in Times New Roman and the font table now has the default font as Times New Roman instead of Arial.

    When I load the 2nd one which has a default font of Arial and f1 as Times New Roman, the font table is switched back to a default font of Arial and as such the first loaded text switches to Arial.

    Not good since everything should be in Times New Roman. So I add the option -nodefaultfont for the LoadFromString:

    pWP.LoadFromString(vWP.AsANSIString('WPTOOLS'), 'WPTOOLS,-nodefaultfont');

    The first LoadFromString is wrong right away. It shows as Arial because the font table has f0 as Arial (the string being loaded has the default as Times New Roman, but that option doesn't change the font table).

    Is there an option that will not touch the host WPRichText's font table (but add to it if needed) and remap the fonts from the one being loaded? In other words, I need an option that will see that the WPRichText being loaded has a default font of Times New Roman and will only add to and/or remap the text to the existing font table so that it stays Times New Roman? i.e. if the host has Times New Roman as f1, then f0 in the loaded WPRichText gets reassigned as f1?

    One more thing to note. The Loaded text does not have an actual font assigned to the text whereas the original text does, so it gets remapped to the new font table and the loaded text does not.

    I hope that was clear.

    What about an option to prevent the row height from changing when adding an image to a table cell? It wouldn't matter if the image doesn't fill the cell width in that case. Right now adding an image to a table cell always fills the width and expands the cell (row) height.

    I suppose I might be able to handle this in code by scaling the image myself based on the cell height when pasting into the cell. What do you think before I look into it... possible?

    If I have a large image in a table cell it fits the cell. I can then adjust the table column width and the image sizes to fit the cell which increases or decreases the row height as needed. Is there a way to do the opposite, i.e. Adjust the row height to cause the cell width to increase or decrease? I have a customer that never wants the row height to change once he sets it up a certain way, so if he inserts an image he wants the width of the cell to change to maintain the aspect ratio. Currently the row height changes which throws off his page breaks, but if he also wanted to adjust the row height, the column width should change to maintain the aspect ratio.

    The column width does not necessarily have to decrease, but they would like to be able to auto size the image to the row height, expanding the column width only if needed.

    That is nice, I did not know that was available, sorry. Turns out I had to select a lot more than just the wpsec_SelectHeaderFooter. Looks like I have to pretty much select everything except those relating to page numbering in my case since I want a new section to be almost like an independent new document.

    I gave up. I tried to track it down for you, but for now I went with your suggestion to use WPRichText.Memo._InClipboardOP in the RequestHTTPImage event to keep track of the image usage and seems to do what I need. So thanks for that suggestion!

    I think, in your free time (ha), you should investigate why the TextObject is being reset to an initial state. I even tried just saving the WPTextObj in the RequestHTTPImage event (i.e. savedTextObj := TextObject) to see what happens, and sure enough in the BeforePasteImage event savedTextObj was in an initial state. So something is resetting the actual text object itself when pasting only a linked image vs more than a linked image.

    Updated made no difference. I'll send you an example if this doesn't help...

    When pasting a linked image with or without surrounding text, it gets put onto the FProcessImages correctly in the TWPToolsReaderWriter.AddProcessedImage:

    1. (50, wpobjlmage, S1DB94040, [], [], S1DBD3050, -1, '5295_Highway_17_Canon_Ga_021.jpg', '5295_Highway_17_Canon_Ga_021.jpg', ", ", nil, nil, ", 0, 0, 0,4320, 3352, (nil,nil), (nil.nil), (nil, nil), 0, 0, wpwrAutomatic, nil, [])

    However, if you only copied/pasted the linked image without surrounding text, then in TWPCustomRtfEdit.PasteFromClipboard's NowLoadFromStream procedure it looks like this when pulled from FProcessImages using the line anImageObj := Reader.ProcessedImageObj(i) and ultimately ends up this way in WPRichText1.InsertedObj and as such makes TxtObj nil in WPRichText1BeforePasteImage:

    1. (0, wpoifbjCustom, nil, [], [], nil, 0, ", ", ", ", nil, nil, ", 0, 0, 0, 0, 0, (nil,nil), (nil,nil), (nil,nil), 0, 0, wpwrAutomatic, nil, [])

    But when pasted with more than just the linked image it correctly pulls it like this (just as it was put onto it) and all is good:

    1. (50, wpobjlmage, S1DB94040, [], [], S1DBD3050, -1, '5295_Highway_17_Canon_Ga_021.jpg', '5295_Highway_17_Canon_Ga_021.jpg', ", ", nil, nil, ", 0, 0, 0,4320, 3352, (nil,nil), (nil.nil), (nil, nil), 0, 0, wpwrAutomatic, nil, [])

    In trying to help by tracing thru it, I cannot find where it gets lost or corrupted when just copy/pasting a linked image. Seems to start out the same, but ends up completely different.

    I am using the July 21 version. I see you now have and update from July 24 and will try that.

    But yes, I understand linked image is pasted as text. I am trying to point out that just selecting the image does not work the same as if I selected more than just the image for copy/paste. Both paste as linked images fine, I have no issue with that and is perfect, however in BeforePastImage event the TxtObj parameter is nil when just the image had been selected and not nil when more than the image had been selected. I would hope it would be not nil in both cases.

    I will check with the latest and if TxtObj is still nil, I will send you an example. Maybe it will be more clear.

    Sorry, sometimes I tend to say too much that clouds the real issue.

    Consider this... you have two WPRichTexts side by side. The one on the left has some text and a linked image. If you select just the linked image, copy it (using Ctrl+C) and paste it (using Ctrl+V) into the WPRichtext on the right, the TxtObj in the BeforePasteImage is nil (bad for me). However, if you select any of the text along with the linked image on the left then copy and paste it into the WPRichText on the right, TxtObj in BeforePasteImage is NOT nil, which is good because I can extract the image name from it.

    So it seems just copying and pasting a linked image by itself is not performing correctly.

    I replaced your WPAPaste1 action with my own Paste action and have it almost exactly like I need it. It checks to see what is being inserted and skips it if it is just an image. This does prevent an image I copied from a web page from being pasted, but still allows a linked image to be pasted, whether or not it is in conjunction with with text.

    However, when pasting just a linked image without text, both TxtObj and WPRichText1.InsertedObj.ObjRef are nil in the BeforePasteImage event, and WPRichText1.InsertedObj.Source is blank, so I do not know the name of the source to be able to manage it in my thumbnail panels. Yet it still seems to insert it as a linked image because if I look at the RTF or reload the WPRIchText, they all seem to be correct as a linked image. If I pasted that linked image along with surrounding text, TxtObj, WPRichText1.InsertedObj.ObjRef and WPRichText1.InsertedObj.Source are all available and I can get the name that I need. Is there an issue there? I really need that source, stream or file name.

    I also noticed that it hits the RequestHTTPImage event just before the BeforePasteImage event, so it seems to know what is being pasted because the Source is as expected.

    This is what I added to my paste action:

    1. if fActiveEditor = nil then exit;
    2. if not (
    3. ClipBoard.HasFormat(CF_METAFILEPICT) or
    4. ClipBoard.HasFormat(CF_ENHMETAFILE) or
    5. ClipBoard.HasFormat(CF_BITMAP) or
    6. ClipBoard.HasFormat(CF_PICTURE) ) then
    7. begin
    8. fActiveEditor.PasteFromClipboard;
    9. end;

    BeforePaste event?

    Note also that I added item 4 to my previous post before seeing your post. It seems even copying just the linked image it is pasted as a non-linked image, i.e. only pasted as a linked image if it was part of text.

    If I cannot convert a non-linked image to a linked image, I would prefer to not allow it to be inserted or to immediately remove it to prevent customer confusion.

    OK, except in my quick test:

    1. When inserting an image copied from a web page (Right click, copy image), InsertedObj is not nil, but ObjRef and TxtObj are both nil (using Ctrl+V to paste it).

    2. When inserting a signature image, InsertObj is nil and TxtObj is not (using WPRichText1.PasteFromClipboard to paste it)

    3. When inserting text that includes a linked image copied (Ctrl+C) from another WPRichText, InsertedObj, ObjRef and TxtObj are all not nil. (using Ctrl+V to paste it)

    4. When copying just the image from another WPRichText (Ctrl+C), pasting it (Ctrl+V) into another WPRichText is treated as a non-linked image (same as 1 above)

    So how do I then stop the non-linked image (1) from being inserted such as pasting an image grabbed from a web page? And why is pasting using Ctrl+V different than using WPRichText1.PasteFromClipboard?

    Actually, It would be even better if I could intercept the non-linked image being pasted and convert it into a linked image by pulling it into my database (this way I could scale it, add borders etc as the user configured it).

    (I thought setting TxtObj to nil would do it but it is already nil... so much for my great testing in my old version since that is what I was doing there but just saw that it didn't work there either for all these years, lol).