libreofficeapi/UNO:如何在writer中水平右对齐表格单元格中的文本 我用C++从另一个应用程序控制LyBruts/OpenOffice,但我想如果你也知道java桥,你可以帮助我。因此,基本上我想加载一个文档(works),设置单元格的文本(works),并将一个表格单元格设置为水平对齐(我不知道怎么做):

libreofficeapi/UNO:如何在writer中水平右对齐表格单元格中的文本 我用C++从另一个应用程序控制LyBruts/OpenOffice,但我想如果你也知道java桥,你可以帮助我。因此,基本上我想加载一个文档(works),设置单元格的文本(works),并将一个表格单元格设置为水平对齐(我不知道怎么做):,api,libreoffice,openoffice.org,uno,libreoffice-basic,Api,Libreoffice,Openoffice.org,Uno,Libreoffice Basic,我有: //加载文档 参考rDoc=myLoader->loadComponentFromURL(…); //拿桌子 参考rTablesSuppl(rDocument,UNO_查询); Any Any=rTablesSuppl->getTextTables()->getByName(“表1”); 参考rTable(任何,UNO_查询); //在单元格中设置文本 参考安排(rTable,UNO_查询); 参考rCell=rRange->getCellByPosition(x,y); 参考rText

我有:

//加载文档
参考rDoc=myLoader->loadComponentFromURL(…);
//拿桌子
参考rTablesSuppl(rDocument,UNO_查询);
Any Any=rTablesSuppl->getTextTables()->getByName(“表1”);
参考rTable(任何,UNO_查询);
//在单元格中设置文本
参考安排(rTable,UNO_查询);
参考rCell=rRange->getCellByPosition(x,y);
参考rTextRange(rCell,UNO_查询);
rTextRange->setString(“MyNewText”);
//右对齐“MyNewText”
????
知道如何继续吗?

注意。。。虽然我有C++的经验,但是我使用java来进行LO API编程,所以下面可能有点偏离。你可能需要稍微调整一下才能让事情顺利进行

在Java中,我使用单元格名称获取单元格,在单元格中右对齐文本,如下所示:

XCell xCell = xTextTable.getCellByName(cellname);
XText xText = UnoRuntime.queryInterface(XText.class, xCell);
XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xText.getStart());
xPropertySet.setPropertyValue("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT);
Reference< XPropertySet > xPropSet( rTextRange, UNO_QUERY );
xPropSet->getPropertyValue("ParaAdjust") >>= com::sun::star::style::ParagraphAdjust.RIGHT;
<>在C++中,用单元格的位置来获得单元格,我认为粗略的翻译是:

Reference<XCell> rCell = rRange->getCellByPosition(x, y);
Reference<XText> rText(rCell, UNO_QUERY);
Reference< XPropertySet > xPropSet( rText->getStart(), UNO_QUERY );
xPropSet->getPropertyValue("ParaAdjust") >>= com::sun::star::style::ParagraphAdjust.RIGHT;
Reference< XPropertySet > xPropSet( rTextRange, UNO_QUERY );
xPropSet->getPropertyValue("ParaAdjust") >>= com::sun::star::style::ParagraphAdjust.RIGHT;