• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

How can I find the paragraph style (styleUID) of each cell in a table?

Explorer ,
Jan 10, 2024 Jan 10, 2024

Copy link to clipboard

Copied

Hi everyone, 
I need some help finding the paragraph style (styleUID) of each cell in a table.

So far this is what I have. 


InterfacePtr<ITableModel> tableModel(tableFrame->GetModelRef(), UseDefaultIID());

if (tableModel == nil) break;

int rows = tableModel->GetTotalRows().count;
int cols = tableModel->GetTotalCols().count;
UID currentStyle = kInvalidUID;
 
for (int r = 0; r < rows; r++)
{
for (int c = 0; c < cols; c++)
{
GridAddress address = GridAddress(r, c);
GridID gridid = tableModel->GetGridID(address);
InterfacePtr<ITableTextContainer> tableTextContainer(tableModel, UseDefaultIID());
if (tableTextContainer == nil)
break;
 
InterfacePtr<ITextModel> textModel(tableTextContainer->QueryTextModel());
if (textModel == nil)
break;
 
InterfacePtr<ITextStoryThreadDict> textStoryThreadDict(tableModel, UseDefaultIID());
if (textStoryThreadDict == nil)
break;
 
InterfacePtr<ITextStoryThread> textStoryThread(textStoryThreadDict->QueryThread(gridid));
if (textStoryThread == nil)
break;
 
InterfacePtr<ITextModel> iTextModel(textStoryThread->QueryTextModel());
if (iTextModel == nil)
break;
 
 
const UIDRef tableRef(::GetUIDRef(tableModel));
TextIndex threadStart, threadLength;
iTextModel->FindStoryThread(tableRef.GetUID(), gridid, &threadStart, &threadLength);
 
// how can I get the styleUID (Paragraph style) of this cell?
 
}
}
TOPICS
How to , SDK

Views

82

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

correct answers 1 Correct answer

Contributor , Jan 10, 2024 Jan 10, 2024

Hi @Chamari253904353k85 ,

 

Refer the below code snippet -

 

InterfacePtr<IAttributeStrand> iParaAttributeStrand(((IAttributeStrand*) iTextModel->QueryStrand(kParaAttrStrandBoss, IAttributeStrand::kDefaultIID)));
 
int32 outParaSpan = 0;
UID paraStyleUID = iParaAttributeStrand->GetStyleUID(threadStart, &outParaSpan);
 
IN Parameter - threadStart - is the TextIndex inside the cell.
OUT Parameter - outParaSpan - is the number of characters that have same paragraph style applied in the run.
 
Hope this helps.
 
...

Votes

Translate

Translate
Contributor ,
Jan 10, 2024 Jan 10, 2024

Copy link to clipboard

Copied

Hi @Chamari253904353k85 ,

 

Refer the below code snippet -

 

InterfacePtr<IAttributeStrand> iParaAttributeStrand(((IAttributeStrand*) iTextModel->QueryStrand(kParaAttrStrandBoss, IAttributeStrand::kDefaultIID)));
 
int32 outParaSpan = 0;
UID paraStyleUID = iParaAttributeStrand->GetStyleUID(threadStart, &outParaSpan);
 
IN Parameter - threadStart - is the TextIndex inside the cell.
OUT Parameter - outParaSpan - is the number of characters that have same paragraph style applied in the run.
 
Hope this helps.
 
- Rahul Rastogi
Adobe InDesign SDK Custom Plugin Developer
 

Votes

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 ,
Jan 11, 2024 Jan 11, 2024

Copy link to clipboard

Copied

Thank you so much Rahul

Votes

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
Engaged ,
Jan 11, 2024 Jan 11, 2024

Copy link to clipboard

Copied

Note that a cell may contain multiple paragraphs, each using a different paragraph style, thus the importance of outParaSpan and "the number of characters that have same paragraph style applied in the run" in @Rahul_Rastogi's answer.

Votes

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 ,
Jan 11, 2024 Jan 11, 2024

Copy link to clipboard

Copied

LATEST

Thank you Oliver. This is great help. 

Votes

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