I'm struggling with getting the correct width of newly created XTextTable.
Here is the portion of the code I'm using to create and insert text table into the text document.
Code: Select all
public object CreateTable(object document, int rowCount, int colCount)
{
object table = null;
try
{
XMultiServiceFactory docFactory = (XMultiServiceFactory)document;
table = docFactory.createInstance("com.sun.star.text.TextTable");
((XTextTable)table).initialize(rowCount, colCount);
}
catch (Exception e)
{
LogException($"{MethodBase.GetCurrentMethod().DeclaringType.ToString()}.{MethodBase.GetCurrentMethod().Name}", e);
}
return table;
}
Code: Select all
public void InsertTextContentAtRange(object content, object range)
{
try
{
XText rangeText = ((XTextRange)range).getText();
rangeText.insertTextContent((XTextRange)range, (XTextContent)content, true);
}
catch (Exception e)
{
LogException($"{MethodBase.GetCurrentMethod().DeclaringType.ToString()}.{MethodBase.GetCurrentMethod().Name}", e);
}
}
Visually table looks OK and fits the document but I can't calculate width properly for other functions.
E.g. properly set columns width, insert line shape into table cell with width of this table cell, etc.
Tried creating table with relative width, tried setting width manually, tried different hori orientation options.
Nothing is working except with HoriOrient = Center it actually shows that table is wide and goes beyond document.
---
Actually same happens in Writer application if I create new document and insert table manually.
Inspector shows that the width property of the table is 115596 which is way bigger than expected.
If I interact with table somehow(drag border, change hori orientation, etc.) the width is changed to a proper value.
Using LibreOffice 7.3.1.3 X64 with Win10 X64.
---
Could you please help me with this.
Thanks.