Skip to main content
Participant
October 21, 2019
Question

Delete change bars

  • October 21, 2019
  • 1 reply
  • 305 views

Hi All,

I like to remove with an ESTK file all changes bars of a FM file.
If the Doc.ClearAllChangebars() command may be used to clear the global change bar setting of a FM file, it does not remove nor change any CharTag that may use a ChangeBar style defined in the Character Catalog.

I am able to find all CharTags equal to ChangeBar in a FM file and get its character string.
But I am stuck to change a CharTag font definition and set it equivalent to the definition of <Default Para Font> of the Character Catalog.
Have you any suggestion to do it?

Thanks,

JM

This topic has been closed for replies.

1 reply

frameexpert
Community Expert
Community Expert
October 21, 2019

Here is a function that will apply the default paragraph formatting to a TextRange. It takes a TextRange (textRange), a Pgf or TextLine (textObj), and the document object (doc). If you pass undefined as the textRange parameter, then the default formatting will be applied to the entire Pgf or TextLine. Note that for Pgf objects, the underlying paragraph format (PgfFmt) must exist in the document or the function will not change anything.

function applyDefaultParaFont (textRange, textObj, doc) {
    
    var pgfFmt, prop, textLoc;
    
    if (textRange) {
        if (textObj.constructor.name === "Pgf") {
            pgfFmt = doc.GetNamedPgfFmt (textObj.Name);
            if (pgfFmt.ObjectValid () === 1) {
                doc.SetTextProps (textRange, pgfFmt.GetProps ());
            }
        }
        else { // Text line
            textLoc = new TextLoc (textObj, 0);
            prop = doc.GetProps (textLoc);
            doc.SetTextProps (textRange, prop);
        }
    }
    else { // Apply to whole paragraph or text line.
        textRange = new TextRange (new TextLoc (textObj, 0),
            new TextLoc (textObj, Constants.FV_OBJ_END_OFFSET));
        if (textObj.constructor.name === "Pgf") {
            pgfFmt = doc.GetNamedPgfFmt (textObj.Name);
            if (pgfFmt.ObjectValid () === 1) {
                doc.SetTextProps (textRange, pgfFmt.GetProps ());
            }
        }
        else { // Text line
            textLoc = new TextLoc (textObj, 0);
            prop = doc.GetProps (textLoc);
            doc.SetTextProps (textRange, prop);
        }
    }

    prop = new PropVal ();
    prop.propIdent.num = Constants.FP_CharTag;
    prop.propVal.valType = Constants.FT_String;
    prop.propVal.sval = "";
    doc.SetTextPropVal (textRange, prop);
}
www.frameexpert.com
frameexpert
Community Expert
Community Expert
October 21, 2019

Too bad the code view on this new forum interface doesn't have line numbers.

www.frameexpert.com