Hello All,
I am working on plugin development for InDesign CS2/CS2J. And I need
to set vertical text direction for table cell. I know how text
direction is set for TextFrame, using IStoryOption, but for table cell
IStoryOption is not available.
I have tried 2 different approaches: using
IWaxRun::SetVerticalWritingMode and using
IStoryPropertiesSuite::SetTextDirection and both did not work, however
InDesign executes code correctly and gives kSuccess to me.
Here is the code for both cases:
1. GridAddress gridAddress(m_nRowIndex, m_nColIndex);
do
{
InterfacePtr<ITableModel> pTableModel(tableRef,
ITableModel::kDefaultIID);
InterfacePtr<ICellContent>
cellContent(pTableModel->QueryCellContentBoss(gridAddress));
if (!cellContent)
break;
InterfacePtr<ITextParcelList> textParcelList(cellContent,
UseDefaultIID());
if (!textParcelList)
break;
InterfacePtr<IWaxStrand> waxStrand(textParcelList->GetWaxStrandRef(),
UseDefaultIID());
if (waxStrand == nil)
break;
K2::scoped_ptr<IWaxIterator>
waxIterator(waxStrand->NewWaxIterator());
if (waxIterator == nil)
break;
const IWaxLine* waxLine = waxIterator->GetFirstWaxLine(0);
while(waxLine){
int runCnt = waxLine->GetRunCount();
for(int i=0; i<runCnt; ++i) {
InterfacePtr<IWaxRun> waxRun( waxLine->QueryRun(i) );
if(waxRun == nil)
continue;
waxRun->SetVerticalWritingMode(true);
}
waxLine = waxIterator->GetNextWaxLine();
}
waxIterator.reset();
curStatus = kSuccess;
} while(false);
2. GridArea gridArea(rowIndex, colIndex, rowIndex+1, colIndex+1);
do
{
InterfacePtr<IActiveContext>
ac(gSession->GetActiveContext(),UseDefaultIID());
InterfacePtr<ISelectionManager>
selectionManager(ac->GetContextSelection());
if (selectionManager == nil)
break;
InterfacePtr<ITableSelectionSuite>
tableSelectionSuite(selectionManager, UseDefaultIID());
if (!tableSelectionSuite)
break;
if (selectionManager->SelectionExists (kInvalidClass,
ISelectionManager::kAnySelection))
selectionManager->DeselectAll(nil);
InterfacePtr<ITableModel> pTableModel(tableRef,
ITableModel::kDefaultIID);
if (!pTableData)
break;
tableSelectionSuite->Select(pTableModel, gridArea,
ITableSelectionSuite::kReplace, kTrue);
InterfacePtr<IStoryPropertiesSuite>
storyPrefs(ac->GetContextSelection(), UseDefaultIID());
if (!storyPrefs)
break;
curStatus =
storyPrefs->SetTextDirection(IStoryPropertiesSuite::kDirVertical);
} while (false);
What I can say about InDesign CS2J vertical text direction feature is
that it is almost 100% a story thread property, as it can be set only
to text frame or table cell, not to a part of text.
I agree both cases that I use are strange and I do not believe this
is a correct solution, what I am thinking of correct solution must be
some sort of setting story thread property using IStoryOptions similar
interace. But so far did not find anything.
Could you please give me any advice and help for this problem.
Thanks.
I am working on plugin development for InDesign CS2/CS2J. And I need
to set vertical text direction for table cell. I know how text
direction is set for TextFrame, using IStoryOption, but for table cell
IStoryOption is not available.
I have tried 2 different approaches: using
IWaxRun::SetVerticalWritingMode and using
IStoryPropertiesSuite::SetTextDirection and both did not work, however
InDesign executes code correctly and gives kSuccess to me.
Here is the code for both cases:
1. GridAddress gridAddress(m_nRowIndex, m_nColIndex);
do
{
InterfacePtr<ITableModel> pTableModel(tableRef,
ITableModel::kDefaultIID);
InterfacePtr<ICellContent>
cellContent(pTableModel->QueryCellContentBoss(gridAddress));
if (!cellContent)
break;
InterfacePtr<ITextParcelList> textParcelList(cellContent,
UseDefaultIID());
if (!textParcelList)
break;
InterfacePtr<IWaxStrand> waxStrand(textParcelList->GetWaxStrandRef(),
UseDefaultIID());
if (waxStrand == nil)
break;
K2::scoped_ptr<IWaxIterator>
waxIterator(waxStrand->NewWaxIterator());
if (waxIterator == nil)
break;
const IWaxLine* waxLine = waxIterator->GetFirstWaxLine(0);
while(waxLine){
int runCnt = waxLine->GetRunCount();
for(int i=0; i<runCnt; ++i) {
InterfacePtr<IWaxRun> waxRun( waxLine->QueryRun(i) );
if(waxRun == nil)
continue;
waxRun->SetVerticalWritingMode(true);
}
waxLine = waxIterator->GetNextWaxLine();
}
waxIterator.reset();
curStatus = kSuccess;
} while(false);
2. GridArea gridArea(rowIndex, colIndex, rowIndex+1, colIndex+1);
do
{
InterfacePtr<IActiveContext>
ac(gSession->GetActiveContext(),UseDefaultIID());
InterfacePtr<ISelectionManager>
selectionManager(ac->GetContextSelection());
if (selectionManager == nil)
break;
InterfacePtr<ITableSelectionSuite>
tableSelectionSuite(selectionManager, UseDefaultIID());
if (!tableSelectionSuite)
break;
if (selectionManager->SelectionExists (kInvalidClass,
ISelectionManager::kAnySelection))
selectionManager->DeselectAll(nil);
InterfacePtr<ITableModel> pTableModel(tableRef,
ITableModel::kDefaultIID);
if (!pTableData)
break;
tableSelectionSuite->Select(pTableModel, gridArea,
ITableSelectionSuite::kReplace, kTrue);
InterfacePtr<IStoryPropertiesSuite>
storyPrefs(ac->GetContextSelection(), UseDefaultIID());
if (!storyPrefs)
break;
curStatus =
storyPrefs->SetTextDirection(IStoryPropertiesSuite::kDirVertical);
} while (false);
What I can say about InDesign CS2J vertical text direction feature is
that it is almost 100% a story thread property, as it can be set only
to text frame or table cell, not to a part of text.
I agree both cases that I use are strange and I do not believe this
is a correct solution, what I am thinking of correct solution must be
some sort of setting story thread property using IStoryOptions similar
interace. But so far did not find anything.
Could you please give me any advice and help for this problem.
Thanks.