Skip to main content
Participating Frequently
May 14, 2010
Answered

FDK - Paragraph properties

  • May 14, 2010
  • 1 reply
  • 1336 views

Hello,

I am having trouble getting the properties of a paragraph, such as:

  1. FontSize
  2. FontWeight (of the paragraph in general, ignoring any character formats within it).
  3. List identifier, if it is a paragraph list, else value is 0.

I have tried the following:

F_PropValT fontSize = F_ApiGetPropVal(docId, pgfId, FP_FontSize); //this returns a zero.

(and)

StringT pgfName;

F_PropValsT proplist;

//******Get ID of flow, textFrame, pgfId.******

pgfName = F_ApiGetString(docId, pgfId, FP_Name);

//******Get ID for paragraph format.******

pgfFmtId = F_ApiGetNamedObject(docId, FO_PgfFmt, pgfName);

proplist = F_ApiGetProps(docId, pgfFmtId);

IntT i = F_ApiGetPropIndex(&proplist, FP_FontSize);

Then, shouldn't "proplist.val.propVal.u.ival" hold the font-size? //but it returns a zero.

........

//******de-allocate pgfName, proplist here.******

 

And for the list identifier, how do we get the identifier of the inner-most list item, say "i" in the example below?

1. First item in the list

            a. Sub item in this list

                        i. Sub-sub-item in this list

I assume, it is the FP_AutoNumString property together with the FP_PgfNumber property to get the nested list format and its value. But I didn't have any luck.

This is what I am trying to achieve,

  • For each paragraph in a flow, get the above mentioned paragraph properties.
  • Create a new format name based on its font-size, weight and list number, (say, a new format name "FS14-FWB-LS-i" - for font-size: 14 pts, font-weight: bold, list identifier: i).
  • Add this entry to the Paragraph catalog and apply this format (name) to the paragraph.

I would appreciate any help..

Thanks in advance,

    This topic has been closed for replies.
    Correct answer Russ Ward

    Hi Russ,

    It works now! Please ignore my previous post.

    I noticed that I need to create a new format name from the Paragraph designer and check the "Store in Catalog" option for the entry to be in the property set/library - the paragraph catalog.

    Doing this with the FDK, I needed to create the format instead of getting it, like:

    .......

    ........

    formatName = F_ApiGetString(docId, pgfId, FP_Name);

    fmtId = F_ApiNewNamedObject(docId, FO_PgfFmt, formatName);

    F_ApiSetString(docId, fmtId, FP_Name, newFormatName);
    proplist = F_ApiGetProps(docId, fmtId);
    if(F_StrCmp(pgfName, formatName) == 0){
            F_ApiSetProps(docId, pgfId, &proplist);

    }

    ........

    ........ and this works.

    Now I understand and thanks again for your detailed explanation.

    Regarding the list identifiers, I might have used the wrong terminology. Please see example below. If I have a nested list in a document like:

    1. First list item

    2. Second list item

         a. Second sub list item

              i. Second sub sub list item

    3. Third list item

    Then how do we retrieve the identifier "i" for the innermost list item?

    Many thanks,

    pnk


    And yes, I think you figured it out, but to expand on your findings... when you paste a paragraph from Word, FrameMaker has to create a new paragraph (ie, a new FO_Pgf) object. And, since an FO_Pgf object has an FP_Name property, it has to be set to something, so FM just sets it to the style name from Word. It doesn't actually create a format with that name, just sets the name property on a single paragraph object.

    You will see that format name in the paragraph designer afterwards, in the GUI. But that is all just part of the illusion. The designer simply shows the FP_Name property of whichever paragraph the insertion point is in. But as mentioned earlier, there is no real link between a paragraph and any format. "Assigning" a format is really just a property exchange, with no association remaining afterwards.

    Russ

    1 reply

    May 15, 2010

    If you haven't yet tried posting there, you might find more FDK-specific assistance on the Framers Dev list,

        http://groups.yahoo.com/group/frame_dev/

    Sheila

    Legend
    May 17, 2010

    Hi pnk,

    I think for the most part you are doing things the right way. I followed your methodology and did not have any problem retrieving the font size. Before I go on, remember that the FP_FontSize is a MetricT property, not an IntT, but you should be able to see some kind of integer representation of it (ie, not zero).

    You have:

    F_PropValT fontSize =  F_ApiGetPropVal(docId, pgfId, FP_FontSize); //this returns a zero

    I did the same thing and had no problem (although I split up the variable declaration and the function call). After that call, for an 11 pt paragraph, I get:

    fontSize.propVal.u.ival == 720896


    Also, the following is simpler and returns the same result:

    MetricT metric;

    metric = F_ApiGetMetric(docId, pgfId, FP_FontSize);

    I also tried out the following and got the same result, although this is certainly a more roundabout approach:

      pgfName = F_ApiGetString(docId, pgfId,  FP_Name);

      pgfFmtId = F_ApiGetNamedObject(docId, FO_PgfFmt, pgfName );

      proplist =  F_ApiGetProps(docId, pgfFmtId);

      i = F_ApiGetPropIndex(&proplist, FP_FontSize);

    ...and after that, proplist.val.propVal.u.ival == 720896. Again, though, note that I separated the variable declaration from the function call again.

    So, I'm not exactly sure what to tell you beyond that. I think your approach looks fine, must be something simple with your code construct. I assume you have made sure that your pgfId and other variables are valid.

    Russ

    pnk80Author
    Participating Frequently
    May 26, 2010

    Hi Russ,

    Thank you very much. I've got the font-size and font-weight properties now. I would appreciate your time, for the doubt I have below. Doesn't the following command rename a Paragraph Catalog format name?

    F_ApiSetString(docId, pgfId, FP_Name, fmt);   

    I am trying to rename a paragraph's format name in the catalog, so I can use the new name in my conversion table. The above command doesn't work, so I tried the following: (declarations, memory alloc/dealloc not shown)

    /*Create a new pgf format name - 'fmt' is a character array which stores the new name*/

    newPgfId = F_ApiNewNamedObject(docId, FO_PgfFmt, fmt);

    proplist = F_ApiGetProps(docId, pgfId);

    F_ApiSetProps(docId, newPgfId, &proplist); //set the properties of the current pgfId to the newPgfId.

    /*Now apply the new pgf format to the current paragraph - 'pgfId'*/

    tr = F_ApiGetTextRange(docId, pgfId, FP_TextSelection);

    props = F_ApiGetProps(docId, newPgfId);

    F_ApiSetProps(docId, tr.beg.objId, &props);

    But this doesn't work too. What am I missing here?

    Another question I have is regarding the traversal of a nested paragraph - I need the innermost paragraph's list identifier. I would be glad if you can point me in the right direction.

    Many thanks,

    pnk