Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Plugin Development. Problem setting vertical text direction for table

Status
Not open for further replies.

smashik

Programmer
May 17, 2006
3
BY
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.
 
Found the solution.
Need to use kCellAttrRotationFollowStoryBoss
2 - is vertical text flow
1 - is horizontal text flow
 
More correct are the following values for attribute:
0 - cell story flow is opposite to frame story flow
1 - cell story flow is equal to frame story flow
2 - force to use vertical story flow
3 - force to use horizontal story flow
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top