Skip to main content
Legend
September 12, 2013
Answered

Technique to undo a character format application?

  • September 12, 2013
  • 1 reply
  • 1441 views

Hi,

Seems that answers to complicated questions are a bit sparse in these parts, but I'll try again anyway

I'm wondering if there is any technique to reliably undo a character format application change; that is, an application of properties to a range of text with SetTextProps(). It is fairly simple to remember a list of original properties (PropVals) and the original text range (TextRange), then reapply those original properties to the whole range. However, within a text range, each character can have its own unique set of properties. So, remembering one set of original properties is not enough... seems I have to remember the properties of every single character in the range, the reapply character-by-character, in order to ensure that the new property application is completely undone.

When you apply a character format in the GUI, FM reliably allows an undo, restoring each affected character to its original state. Surely it isn't remembering a PropVals array for every single character (?)  I'm just wondering if there is another trick here. It's entirely possible if FM is internally using another trick, it isn't one that I can feasibly replicate.

Thanks,

Russ

This topic has been closed for replies.
Correct answer 4everJang

Hi Russ,

If you use a GetText method and use the Constants.FTI_CharPropsChange you should get an array of text items where each item has one particular set of properties. You should be able to save those for later restore. There should be no need to save the properties of each single character.

Ciao

Jang

1 reply

4everJang
4everJangCorrect answer
Legend
September 12, 2013

Hi Russ,

If you use a GetText method and use the Constants.FTI_CharPropsChange you should get an array of text items where each item has one particular set of properties. You should be able to save those for later restore. There should be no need to save the properties of each single character.

Ciao

Jang

Russ WardAuthor
Legend
September 13, 2013

Hi Jang,

Thanks for the tip. This would streamline things a bit, I think, but I would still need to store multiple property sets at each point where the properties change, right? I'd have to also retain the text items, so I could step through all the offsets, retrieve the historic properties, then apply them to the correct range.

Just thinking out loud here, trying to asses whether this is worth it.

Russ

Russ WardAuthor
Legend
September 13, 2013

Hi Jang (you might need to look at this on the forum websie),

Effectively, I want to be able to restore a range of text to its original format, after the original format is completely overwritten. For example:

Here is someTEXT

Imagine that someone applies a character format that wipes all that out:

Here is some text

I want to restore the text to its original format. In the GUI, the FrameMaker Undo command successfully does that. I have a script that applies formatting and I'd like to replicate the undo, if its feasible. Naturally, the FM undo will not undo a script action.

I am talking about text ranges only. By the way, how do you store a "safety paragraph?" Using the clipboard is not an option in this case.

Thanks,

Russ


I had to edit the message to get the weird formatting to show up right. This forum engine really needs a preview step before actual submission.