Re: Formatted Text Control Question

Bob Keeney wrote:
> I'm doing some funny things with FTCustom objects (think mail merge
> fields).  I have a need to be able to iterate through the document and
> pull the text out of the FTCustom object, clear the FTCustom object
> and replace it with the text I pulled out.  And all non-destructive
> until they save the final document.
>
> I think I'll have to iterate through all of the paragraphs in the
> document and then iterate through each paragraph to get the objects.
> I think that part seems relatively straightforward.
>
> The part I'm having trouble wrapping my mind around is how to replace
> my FTCustom object with the text from that object.  Make sense?


Go through the FTParagraphs and look for custom objects and
replace them with FTStyleRuns with the desired text and
attributes. Make sure you mark all the paragraphs dirty that you
change (or if you are lazy call updateFull at the end). You can
just delete the custom object and use FTParagraph.insertObject
insert your style run. You may also do it in a more manual way by
directly inserting the style run if you need more speed (instead
of using insertObject).

How you do this in a non-destructive way until you save seems a
little like a mind bender, but you could use the tag field to
store the custom object. That way you can flip them at will. There
is a problem where the user can edit style run and totally mess it
up for you depending on your requirements. Another thing to do is
to save an XML string of the document in memory that allows you to
restore the original content at will.

Without knowing the full extent of the requirements of what you
want to accomplish, I can't give a complete answer, but I hope
this points you in the right direction.

FTC Website: 
http://www.truenorthsoftware.com/FormattedTextControl/FormattedTextControl.html
Set List Options (digest and vacation modes): www.freelists.org/list/ftcdev
List Archive: www.freelists.org/archives/ftcdev
Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with "unsubscribe" in 
the subject field.



Other related posts: