Hi Tobias,
Thank you very much,
ymw
I will try to translate this into Java. Maybe anybody already got a
solution for Java?
mmmm ... something like the following should do the same ... xTextDoc is
supposed to be your writer document ...
public static void main(String[] args) {
XTextDocument xTextDoc = ....
XIndexAccess Ranges = (XIndexAccess)
UnoRuntime.queryInterface(XIndexAccess.class,
xTextDoc.getCurrentSeletion());
XEnumerationAccess aRange = (XEnumerationAccess)
UnoRuntime.queryInterface(XEnumerationAccess.class,
Ranges.getByIndex(0));
if (containsTable(aRange)) {
System.out.println("selected Range contains a TextTable");
} else {
System.out.println("selected Range doesn't contain a
TextTable");
}
}
private boolean containsRange(XEnumerationAccess aRange) {
boolean ret = false;
XEnumeration aEnum = aRange.createEnumeration();
while aEnum.hasMoreElements() {
aPortion = (XServiceInfo)
UnoRuntime.queryInterface(
XServiceInfo.class,aEnum.nextElement());
if aPortion.supportsService("com.sun.star.text.TextTable") {
ret=true;
}
}
return ret;
}
the following basic macro checks the current selection in a writer
document for TextTables ...
====================================
Sub Main
Ranges = thiscomponent.currentcontroller.selection
aRange = Ranges(0)
if containsTable(aRange) then
msgbox "selected Range contains a TextTable"
else
msgbox "selected Range doesn't contain a TextTable"
endif
End Sub
function containsTable(aRange) as Boolean
ret = false
aEnum = aRange.createEnumeration
while aEnum.hasMoreElements
aPortion = aEnum.nextElement
if aPortion.supportsService("com.sun.star.text.TextTable") then
ret=true
endif
wend
containsTable=ret
end function
====================================
hope that helps
Regards
Stephan
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]