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

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

Participant ,
Jan 10, 2024 Jan 10, 2024

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
236
Translate
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 @Chamari_Silva ,

 

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.
 
- Rahu
...
Translate
Contributor ,
Jan 10, 2024 Jan 10, 2024

Hi @Chamari_Silva ,

 

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

Thank you so much Rahul

Translate
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

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.

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

Thank you Oliver. This is great help. 

Translate
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