Beiträge von EricSchreiber

    We use a descendent of TWPRichText with a lot of extra and custom functionality added on. One feature of TWPRichText we make a lot of use of is Protected Text. We display it in a different color, count it separately for billing purposes, etc.

    Now we would like to add a new function very similar to Protected text. Call it Qualified text. It would coexist with Protected text, and would be used in much the same ways - special color display, special counting, and so on. Pretty much exactly the same kind of behavior as Protected text already offers.

    Has anyone done anything like this? Is there some existing aspect of TWPRichText we could make use of, or should we roll our own? Obviously we'd like to avoid modifying the original TWPRichText code, and instead implement new behavior in our descendent component.

    I'm open to any suggestions on how to proceed.

    Oh, believe me, I know the problem here is entirely within Word!

    I was just hoping there was some existing way to load an RTF (ideally in WPT) that had been mucked up with all the extra garbage in Word, then parse it to determine which RTF control words and such actually were relevant, and output a minimalist version.

    For example, a document uses one or two fonts, but when Word touches it, suddenly the font table has a dozen or more entries in it. Ideally, there would be a way to strip the unused ones out. And the 6KB "themedata" section that Word adds. And the list goes on and on.

    Aside: Long ago in the BBS days, a lot of us sysops used ANSI sequences to give our boards color menus and such. There was a tool we used to draw the ANSI screens, but like Word it added a lot of stuff that wasn't strictly necessary, and we invariably ended up hand-tweaking the code to make it as small as possible for transfer across slow modems. The more things change, the more they stay the same.

    I think I've found the solution for our problem. I've replaced the call to Finder.MoveToFoundPositionEnd with explicitly setting the CPPosition. I would have expected that they'd be functionally the same, but apparently not...

    Code
    if Finder.Next (BookmarkChar) then
    begin
      // Finder.MoveToFoundPositionEnd;
      CPPosition := Finder.FoundPosition + Finder.FoundLength;
    end;

    Delphi 2007
    WPTools 6.16.2

    We have some specialized functions that programmatically move the text cursor around to various locations on a TWPRichText, using the Finder to home in on specific key sequences (Finder.MoveToFoundPositionEnd). The existing text at those locations may be in a variety of formats - e.g plain, bold, italic, specific font faces or sizes, etc.

    We have a problem where, for example, the text cursor jumps to a location where the text is bold...

    This is some bold text

    Newly typed text at that location however is not bold.

    This is inserted into some bold text

    If instead of using our programmatic navigation we simply click on that same location with the mouse, the text is bold (or red or italic or whatever) just like it should be. So, clearly in using the Finder we're missing some crucial command that says "Anything typed here should be in the same format as the text around it."

    How can we force the CurrAttr to refresh/update itself to match the text attributes at the text cursor location?

    Thanks

    Is there any existing way to 'clean' an RTF document, stripping out unnecessary tags? For example, WPTools creates a fairly clean RTF file, that clocks in at 7KB. If I open and then save that file in Word, it bloats up to 36KB. Word just adds a lot of extra RTF junk code.

    Our system can bounce RTF files around through several external systems, and users can paste in text from outside sources, like Word. We'd like a way to strip out RTF control words that have no meaningful effect on the documents.

    Thanks in advance.