How to apply <ICompositionStyle> to text box item

New Here ,
Feb 16, 2010 Feb 16, 2010

Copy link to clipboard

Copied

Hi,

I am trying to modify TabStop for text frame in Indesign document.

For that I am doing following:

//Get IGeometry for textframe

InterfacePtr<IGeometry> iGeometry(frameUIDRef, IID_IGEOMETRY);

//Get IMultiColumnTextFrame for textframe

InterfacePtr<IMultiColumnTextFrame> iMultiColumnTextFrame(parentUIDRef.GetDataBase(), Utils<IFrameUtils>()->GetTextFrameUID(iGeometry), IID_IMULTICOLUMNTEXTFRAME);

//Get ITextModel for IMultiColumnTextFrame

InterfacePtr<ITextModel> textModel(iMultiColumnTextFrame->QueryTextModel());

//Get IComposeScanner for  ITextModel

InterfacePtr <IComposeScanner> composer(textModel, IID_ICOMPOSESCANNER);

//Get drawingStyle from IComposeScanner

IDrawingStyle* drawingStyle = composer->GetCompleteStyleAt(0,&len);

//Get ICompositionStyle from drawingStyle

InterfacePtr <ICompositionStyle> compositionStyle(drawingStyle, IID_ICOMPOSITIONSTYLE);

//Get TabStopTable from ICompositionStyle

TabStopTable iTabStopTable;

iTabStopTable = compositionStyle->GetTabRuler() ;

//Check TabStopTable  values

PMReal tabVal = iTabStopTable.GetDefaultTabInterval();

for(int32 i=0; i<iTabStopTable.size() ; i++ )

{

     PMReal tabpos = iTabStopTable.GetPosition();

     LogFile<<

"iTabStopTable[" << i << "].position = " << ToDouble(tabpos)<< endl;

}

//Till here it is working fine, I am able to read existing TabStop values.

//But I am not getting the way to set new TabStop values.

//I tried below code for setting this, but it is not working.

iTabStopTable.clear();

TabStop iTabStop = TabStop();

iTabStop.SetPosition(10);

iTabStopTable.Insert(iTabStop);

compositionStyle->SetTabRuler(iTabStopTable);

Please suggest me way to set new TabStop value to text frame.

Is there any way, so that we can set ICompositionStyle to textframe item.

Waiting for your important suggestions.

Thanks & Regards,

   Avinash

TOPICS
SDK

Views

804

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
Guide ,
Feb 16, 2010 Feb 16, 2010

Copy link to clipboard

Copied

Composition style is an intermediate state produced by the composer.

For each property there, at any valid location (e.g. text index or range), the composer finds the matching attribute and copies the value.

To change a value, you have to apply an attribute. E.g. tabs reside within kTextAttrTabsBoss.

To apply an attribute to the selection, see ITextAttributeSuite.

If you have the text model, see ITextAttrUtils.

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
Participant ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Thanks Dirk! It was helpful to me.

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
Explorer ,
Apr 26, 2021 Apr 26, 2021

Copy link to clipboard

Copied

Hello Avinash,

Can you share the final version of your code, with the suggested fix ?

Very best regards,

Olivier

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