Delete change bars

New Here ,
Oct 21, 2019 Oct 21, 2019

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

172

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Oct 21, 2019 Oct 21, 2019

Copy link to clipboard

Copied

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);
}

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Oct 21, 2019 Oct 21, 2019

Copy link to clipboard

Copied

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

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines