Joined: 12 Feb 2010
|Posted: Fri Feb 12, 2010 3:15 pm Post subject: Copy Writer cells containing embedded math objects
|I want to copy an entire cell from one Writer table to another using OOo Basic. I'm able to do this when the original cell consists of a string or a number. But I want to do this for a cell that contains a combination of strings, Math objects (fancy formulas) and numbers. Below is a simple example that copies string-containing cells from Table1 to Table2. It works great for strings. When I use this for a cell that contains one or more math equations in addition ordinary string-text on one side or the other, it omits the math equation, but copies the strings.
Looking in this forum and elsewhere, I've seen examples of people constructing an equation character-by-character from scratch in Basic, then building an object from it. I'd like to avoid that if possible. In fact, if possible I don't really want to have to know whether the cell contains equations or not, much less parse them out and then put them back in. Is there some way my program can simply and cleanly copy the "entire contents" of the cell out and paste the "entire contents" into another cell?
Here's the example code that works for strings, but not strings plus math equations.
Sub Test_01 ' copy cells from first table to existing, conformant, second table.
Dim Doc As Object
Dim TextTables As Object
Dim Table1 As Object
Dim Table2 As Object
Dim CellNames1 as object
Dim CellNames2 as object
Dim Cell1 As Object
Dim Cell2 As Object
Dim I As Integer
Dim J As Integer
Doc = ThisComponent
TextTables = Doc.getTextTables()
Table1 = TextTables(0)
CellNames1 = Table1.getCellNames()
Table2 = TextTables(1)
CellNames2 = Table2.getCellNames()
For J = 0 to UBound(CellNames1) ' Loop on cells
Cell1 = Table1.getCellByName(CellNames1(J))
Cell2 = Table2.getCellByName(CellNames2(J))
Cell2.string = Cell1.string
end sub 'Test_01
Any ideas? Thanks.