Beiträge von ehimmer

    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:

    Code
    (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:

    Code
    (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:

    Code
    (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:

    Code
      if fActiveEditor = nil then exit;
    
      if not (
        ClipBoard.HasFormat(CF_METAFILEPICT) or
        ClipBoard.HasFormat(CF_ENHMETAFILE) or
        ClipBoard.HasFormat(CF_BITMAP) or
        ClipBoard.HasFormat(CF_PICTURE) ) then
      begin
        fActiveEditor.PasteFromClipboard;
      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).

    In WPT5, the BeforePasteImage event was not triggered if pasting a linked image. However, in WPT9 it does. This is actually a good thing so I'm not complaining. However, is there an easy way to know if I'm pasting a linked image vs a non-linked image in that event?

    FYI: I allow a non-linked image ONLY if it was from a signature capture (I know this by using a flag), otherwise I do not allow a non-linked image to be inserted. For linked images, I keep track of how many times it is referenced (not just in the currently loaded WPRIchText, but in the database for the combined report comment set). I need to keep track in order to know whether to place a thumbnail of it in the either the used or unused image panel (I did not do this in my old app that used WPT5). So knowing that a user is coping/pasting a linked image is important to me and where pasting a non-linked image is not important (and not allowed).

    Thanks, that would be perfect as I can see it being useful to be able to be switched on/off by an application. The reason we need it is that an owner of a company creates templates that employees use, and they are not allowed to modify parts of a template (or unlock that locked text). Being able to remove all the text in a template kind of defeats the purpose of locked areas of a template, so we needed a way for owners to prevent an employee from being able to do delete all text and freely put in what they wanted and remove what they didn't.

    I use the setting ppProtectSelectedTextToo which works as long as all the text is not selected. For example, if I select most of the text including some protected text, using the DEL key does not do anything other than unselecting the selected text. However, if I select all text, such as with Ctrl+A, and hit the DEL key, all the text is deleted. Is there any way to stop that behavior since it ends up deleting protected text?

    Would it be possible in a future release to expose FIncrement as a public property for a TWPValueEdit (part of WPUtil.pas)? I'd like euInch to increment by .05 (72) not .10 (144) and euTwips to increment by 10 not 1 without having to edit WPUtil on each WPTools update. It is currently hard coded in the SetUnit procedure.

    Thanks,

    Eric

    It is a TMS issue. I was just seeing if by chance you knew of any technique to force focus back to the editor after an action completed.

    However, TMS has already replied and duplicated the issue, and will be providing a fix in their next update. So all good I hope :)

    I ran into a problem using the TMS Toolbar and focus. I have contacted them on it, but thought I'd run it by you as well.

    If I have a button on the TMS TAdvToolbar with an action such as WPABullets1 assigned to it, it works fine and focus stays with the editor. However, with their TAdvDockPanel, if the toolbar won't fit on it, it shrinks down width-wise and the buttons can be invoked using the side option dropdown menu of the toolbar. If I then click the bullet button from the dropdown menu, focus does not stay with the editor but instead focus is placed on some totally unrelated panel. On buttons where I have my own actions set, I can force focus back to the editor after the respective dropdown button action is finished. Is something like that possible with your actions, like one of the events that occur due to an action completion?

    I can't find any info about the event OnCheckProtection. What is it used for, when does it trigger and how do I get it to trigger?

    I am trying to change the down state of a button based on if the cursor is on protected text. I tried to use the OnChangeCursorPos event, but it fails me, For example, if I select a word that is not protected, I click the button which adds protection. I then click on another word that is not protected. The OnChangeCursorPos fires where I do this:

    WPRichText1.TextCursor.GetCharAttr;

    btnLockUnlock.Down := afsProtected in WPRichText1.CurrAttr.Style;


    but afsProtected in WPRichText1.CurrAttr.Style is still true until I move cursor/caret again. Simply clicking between protected and unprotected text works, it just doesn't seem to right after I added protection, as if unselecting of the word on the move is interfering somehow and pulls the wrong attribute. Or I should be doing something before doing the GetCharAttr in the event or after adding protection?

    This is why I was looking into what OnCheckProtection does, but I cannot find any documentation on it.