If the .docx the OQ was talking of, was successfully loaded by OOo, AOO, LibO, the usage of the API will not depend on the "format" of the source file. What's in RAM simply is a TextDocument for the software supporting all the respective services.
The information you (the OQ) found may be slightly misleading. It's true that TextTable objects are returned like paragraphs if the first-level objects contained in the text get enumerated. However TextTable objects don't support specific paragraph services. To the contrary they contain cells which in turn can enumerate paragraphs - and interspersed TextTable objects again.
All the TextTable objects contained in a TextDocument are also accessible from the
.TextTables object of the document by index. Their cells are accessible then using their names which are found in the sequence
.CellNames of the table. Accessing them one by one using something like
myCell = myTextTable.getCellByName(theCellNamIfound) you can either analyze them for paragraphs and additional TextContent (TextTable, TextFrame, ...) - or (e.g.) just ask them for their
.String property.
You see: TextTable objects are really simple and handy. I love them. Joking aside:
The attached example demonstrates the usage of some of the mentioned objects and methods in Basic. Java can surely do everything better and simpler. (Sorry. A joke again.)
(There are 2 cells containing a second paragraph. You see: Only interested in strings, you can also split them in parts per paragraph without enumetrating the text.)
The raw Basic code:
Code: Select all
Sub getTextTableCellStrings
doc = ThisComponent
tTable = doc.TextTables(0)
cellNames = tTable.cellNames
u = Ubound(cellNames)
Dim tStrings(u, 1)
For j = 0 To u
j_cName = cellNames(j)
j_cell = tTable.getCellByName(j_cName)
tStrings(j, 0) = j_cName
tStrings(j, 1) = j_cell.String
If InStr(j_cell.String, Chr(13) & Chr(10))<>0 Then Print "Internal new paragraph In cell: " & j_cName & "!"
Next j
Print "You can now evaluate the array ""tStrings"" for the contained strings."
End Sub
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München