Quantcast
Channel: Adobe Community : Popular Discussions - Adobe FrameMaker
Viewing all articles
Browse latest Browse all 23442

Applying a condition to a paragraph

$
0
0

Greetings,

 

I want to iterate through all paragraphs in a document and for each paragraph with the "comment" style, I want to apply an existing condition called "Comment" (as per p. 126 of the FDK Programmer's Guide)

 

The script below iterates, selects the correct text, but it doesn't apply the condition.  I suspect I am not adding the correct information to the condid variable. I've tried adding the object or just the Id integer value of the condition without success.

 

If I apply the condition manually to a paragraph and then run a script to look at the property values, Framemaker seems to apply the condition object to "osval" which is different than what the FDK states (isval).  And, of course, "osval" seems to be undocumented. So, I'm stumped on what Frame is expecting.

 

I'd appreciate any pointers.

 

Thanks.

 


#target framemaker

if (app.ActiveDoc.ObjectValid()) {
    processDoc(app.ActiveDoc);
}
else{
    Alert("No doc open");
}

 

function processDoc(doc) {
 
    var txtFrame= doc.MainFlowInDoc.FirstTextFrameInFlow;
    var pgf = txtFrame.FirstPgf;
   
    var CondObj=doc.GetNamedObject(Constants.FO_CondFmt,"Comment");
     
   
    while (pgf.ObjectValid()){

        var stylename="Comment";
        var paraname=pgf.Name;
        if (paraname == stylename){

          //get text selection for paragraph
            var tr = new TextRange();               
            tr.beg.obj = tr.end.obj = pgf;
            tr.beg.offset = 0;
          //Retrieve the text from the paragraph
            var txtstring = "";
            var textItems = pgf.GetText(Constants.FTI_String | Constants.FTI_LineEnd);
            for (var i = 0; i < textItems.len; i += 1) {
                txtstring += (textItems[i].sdata);
            }
          //Get length + line end          
            tr.end.offset = txtstring.length+1;
          // set text selection
            doc.TextSelection = tr;

 

 

          // Set up the Condition object          
            var condid = new Ints();
            condid.push(CondObj);
           
          // Create the properties and apply to the selection
            var newprops = AllocatePropVals(1);
            newprops[0].propIdent.num = Constants.FP_InCond;
            newprops[0].propVal.valType = Constants.FT_Ints;
            newprops[0].propVal.isval = condid;          

 

            FA_errno = Constants.FE_Success;
            doc.SetTextPropVal(tr, newprops);
           
            if (FA_errno != Constants.FE_Success){
                $.writeln ("Error : " + FA_errno);
            }
        }
        pgf=pgf.NextPgfInFlow;
    }

}


Viewing all articles
Browse latest Browse all 23442

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>