Re: [api-dev] Sequence of Texttables
In addition to what Andrew provided here, there is yet another way, which is probably not that good but can be taken into account: Using the viewcursor you can go from the beginning to the end of the document regularly checking if the property TextTable of the viewcursor is void (IsEmpty(cur.TextTable)) . Nevertheless the enumeration way is the more reliable one. Do note, that right now in the 680 line (2.0 beta) thisComponent is broken, so use Stardesktop.getCurrentComponent() instead and make sure you run the macro from the menu and not from the Basic IDE.2005/6/15, Andrew Douglas Pitonyak [EMAIL PROTECTED]: Martin Thoma wrote:Hello! I have a text-document which contains some tables:Table1 (Named MyTable)Table2 (Named My 2nd Table)I copy+paste (executeDispatch) Table1 some times into the document: Table1 (Named MyTable)NewTable (Named Table 4)NewTable (Named Table 5)NewTable (Named Table 6)NewTable (Named Table 7) Table2 (Named My 2nd Table)What I need is to access the NewTables in the right order.I tried to use getTextTables, because I thought it returns the tables in theorder they are in to document, but it gives: Table1 (Named MyTable)Table2 (Named My 2nd Table)NewTable (Named Table 4)NewTable (Named Table 5)NewTable (Named Table 6) NewTable (Named Table 7)I coulnd't rely on the table-name, because I don't know which tables arealready inside the document.My idea now is to store all table-names before the copy+paste, use getTextTables and compare the names with the tables-names I stored - but Ihave to be sure that the first table I get will be the first I inserted(Table 4) and not some other of the new tables (like Table 6). Will this ALWAYS be the case?RegardsMartinIf I understand your problem correctly, you want to enumerate the texttables in the order that they are contained in the document. Is this correct? If so, remember that TextTables are stored as a paragraph, soyou will find them while enumerating paragraphs.Sub EnumerateTextTablesInOrderDim oEnumDim s$Dim oParoEnum = ThisComponent.getText().createEnumeration()Do While oEnum.hasMoreElements()oPar = oEnum.nextElement()If oPar.supportsService(com.sun.star.text.TextTable) Thens = s oPar.getName () CHR$(10)End IfLoopMsgBox s, 0, Text TablesEnd Sub--Andrew PitonyakMy Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htmFree Info:http://www.pitonyak.org/oo.php -To unsubscribe, e-mail: [EMAIL PROTECTED]For additional commands, e-mail: [EMAIL PROTECTED]-- Best RegardsChristian Junker
Re: [api-dev] Sequence of Texttables
At 14:02 14/06/05, you wrote: Martin Thoma wrote: Hello! I have a text-document which contains some tables: Table1 (Named MyTable) Table2 (Named My 2nd Table) I copy+paste (executeDispatch) Table1 some times into the document: Table1 (Named MyTable) NewTable (Named Table 4) NewTable (Named Table 5) NewTable (Named Table 6) NewTable (Named Table 7) Table2 (Named My 2nd Table) What I need is to access the NewTables in the right order. I tried to use getTextTables, because I thought it returns the tables in the order they are in to document, but it gives: Table1 (Named MyTable) Table2 (Named My 2nd Table) NewTable (Named Table 4) NewTable (Named Table 5) NewTable (Named Table 6) NewTable (Named Table 7) I coulnd't rely on the table-name, because I don't know which tables are already inside the document. My idea now is to store all table-names before the copy+paste, use getTextTables and compare the names with the tables-names I stored - but I have to be sure that the first table I get will be the first I inserted (Table 4) and not some other of the new tables (like Table 6). Will this ALWAYS be the case? Hi, you cannot rely on the order of tables. I'd suggest to sort the names you get from getTextTables/getElementNames to find the new table name quickly. If you copy/paste the table only (without surrounding text) you can query at the view cursor for the TextTable property and then ask this for it's name because this cursor will be located within the new table. Regards, Oliver Hallo, Had the same problem with inserting frames and i renamed the frames on the spot like: oFrame.Name = P + iPagenr + _Kad_ + iHCpos +_ + iVCpos + _ + (tot + 1) ' (is unique) and thats gives me names depending on the position in the document Fernand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Sequence of Texttables
Martin Thoma wrote: Hello! I have a text-document which contains some tables: Table1 (Named MyTable) Table2 (Named My 2nd Table) I copy+paste (executeDispatch) Table1 some times into the document: Table1 (Named MyTable) NewTable (Named Table 4) NewTable (Named Table 5) NewTable (Named Table 6) NewTable (Named Table 7) Table2 (Named My 2nd Table) What I need is to access the NewTables in the right order. I tried to use getTextTables, because I thought it returns the tables in the order they are in to document, but it gives: Table1 (Named MyTable) Table2 (Named My 2nd Table) NewTable (Named Table 4) NewTable (Named Table 5) NewTable (Named Table 6) NewTable (Named Table 7) I coulnd't rely on the table-name, because I don't know which tables are already inside the document. My idea now is to store all table-names before the copy+paste, use getTextTables and compare the names with the tables-names I stored - but I have to be sure that the first table I get will be the first I inserted (Table 4) and not some other of the new tables (like Table 6). Will this ALWAYS be the case? Hi, you cannot rely on the order of tables. I'd suggest to sort the names you get from getTextTables/getElementNames to find the new table name quickly. If you copy/paste the table only (without surrounding text) you can query at the view cursor for the TextTable property and then ask this for it's name because this cursor will be located within the new table. Regards, Oliver - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Sequence of Texttables
Martin Thoma wrote: Hello! I have a text-document which contains some tables: Table1 (Named MyTable) Table2 (Named My 2nd Table) I copy+paste (executeDispatch) Table1 some times into the document: Table1 (Named MyTable) NewTable (Named Table 4) NewTable (Named Table 5) NewTable (Named Table 6) NewTable (Named Table 7) Table2 (Named My 2nd Table) What I need is to access the NewTables in the right order. I tried to use getTextTables, because I thought it returns the tables in the order they are in to document, but it gives: Table1 (Named MyTable) Table2 (Named My 2nd Table) NewTable (Named Table 4) NewTable (Named Table 5) NewTable (Named Table 6) NewTable (Named Table 7) I coulnd't rely on the table-name, because I don't know which tables are already inside the document. My idea now is to store all table-names before the copy+paste, use getTextTables and compare the names with the tables-names I stored - but I have to be sure that the first table I get will be the first I inserted (Table 4) and not some other of the new tables (like Table 6). Will this ALWAYS be the case? Regards Martin If I understand your problem correctly, you want to enumerate the text tables in the order that they are contained in the document. Is this correct? If so, remember that TextTables are stored as a paragraph, so you will find them while enumerating paragraphs. Sub EnumerateTextTablesInOrder Dim oEnum Dim s$ Dim oPar oEnum = ThisComponent.getText().createEnumeration() Do While oEnum.hasMoreElements() oPar = oEnum.nextElement() If oPar.supportsService(com.sun.star.text.TextTable) Then s = s oPar.getName() CHR$(10) End If Loop MsgBox s, 0, Text Tables End Sub -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]