Skip to main content
Participant
Oct 21, 2019 1:57 PM UTC
Question

Delete change bars

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 is closed to new replies. Start a new post to keep the conversation going.

2 replies

frameexpert
Community Expert
Community Expert
Oct 21, 2019 2:37 PM UTC

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);
}
Translate
www.frameexpert.com
frameexpert
Community Expert
Community Expert
Oct 21, 2019 2:39 PM UTC

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

Translate
www.frameexpert.com