| View previous topic :: View next topic |
| Author |
Message |
Hagar Delest Super User


Joined: 06 Feb 2006 Posts: 5167 Location: France
|
Posted: Tue Dec 19, 2006 5:56 am Post subject: [Solved] Spot a ReferenceMark in a table (Writer document ) |
|
|
I've a piece of code to check if a selection has been referenced as a ReferenceMark.
| Code: | oPortionEnum = oTextElement.createEnumeration
do while oPortionEnum.hasMoreElements
oPortion = oPortionEnum.nextElement
if oPortion.TextPortionType = "ReferenceMark" then
msgbox "Bingo"
exit do
end if
loop |
It works well for text in ... main text (If oTextElement.supportsService("com.sun.star.text.Paragraph") ). But is there a way to check it also when the ReferenceMark is inside a table cell (of a Writer document) ? Or do I have to create a new Enumeration ?
I'm stuck here :
| Code: | If oTextElement.SupportsService("com.sun.star.text.TextTable") then 'If table...
rows = oTextElement.getRows().count 'Prepare to iterate through it.
cols = oTextElement.getColumns().count
For r = 0 to rows - 1 'Iterate.
For c = 0 to cols - 1
Cell = oTextElement.getCellByPosition(c,r)
elementCursor = Cell.createTextCursor |
_________________ Now on the EN user community forum
Last edited by Hagar Delest on Wed Dec 20, 2006 1:41 am; edited 1 time in total |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8995 Location: Lexinton, Kentucky, USA
|
Posted: Tue Dec 19, 2006 7:43 am Post subject: |
|
|
Here's my effort to enumerate both text and table portions: | Code: | Sub MainEnumerator
MainEnum = ThisComponent.Text.createEnumeration
While MainEnum.hasMoreElements
thisMain = MainEnum.nextElement
If Not thisMain.SupportsService("com.sun.star.text.TextTable") then
PortionEnum = thisMain.createEnumeration
EnumeratePortions(PortionEnum)
Else CellNames = thisMain.getCellNames
For C = 0 to uBound(CellNames())
oCell = thisMain.getCellByName(CellNames(C))
ParaEnum = oCell.createEnumeration
While ParaEnum.hasMoreElements
thisPara = ParaEnum.nextElement
PortionEnum = thisPara.createEnumeration
EnumeratePortions(PortionEnum)
Wend
Next
EndIf
Wend
End Sub
Sub EnumeratePortions(PortionEnum)
While PortionEnum.hasMoreElements
thisPortion = PortionEnum.nextElement
If thisPortion.TextPortionType <> "Text" then
Print thisPortion.TextPortionType
EndIf
Wend
End Sub
|
Last edited by JohnV on Wed Dec 20, 2006 6:27 am; edited 1 time in total |
|
| Back to top |
|
 |
Hagar Delest Super User


Joined: 06 Feb 2006 Posts: 5167 Location: France
|
Posted: Wed Dec 20, 2006 1:42 am Post subject: |
|
|
Many thanks John, it works like a charm. _________________ Now on the EN user community forum |
|
| Back to top |
|
 |
|