Hi,
I've tried doing it this way, but it still doesn't work. The
xPropertySetInfo has the property "TextFrame", but the xTextFrame equals
null. Does anybody have an idea why?
XPropertySet xPropertySet =
(XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xTextRange);
XPropertySetInfo xPropertySetInfo =
xPropertySet.getPropertySetInfo();
XTextFrame xTextFrame = null;
if
(xPropertySetInfo.hasPropertyByName("TextFrame")) {
try {
xTextFrame = (XTextFrame)
UnoRuntime.queryInterface(XTextFrame.class,
xPropertySet.getPropertyValue("TextFrame"));
if (!xTextFrame.equals(null)) {
//do something with xTextFrame
}
} catch (UnknownPropertyException ex) {
System.out.println(ex.getMessage());
}
}
}
Peter Eberlein-3 wrote:
>
>> Hello,
>>
>> I'm trying do find text frames in the selected text range. My code
>> recognizes paragraphs and texttables in the selection. I need to add
>> textframes recognision.
>>
> you have to query for the XPropertySetInfo:
>
> e.g.
>
> if (object instanceof XTextRange) {XPropertySet xPropertySet =
> (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, object);
>
> XPropertySetInfo xPropertySetInfo = xPropertySet.getPropertySetInfo();
>
>
> XTextSection xTextSection = null;
> XTextFrame xTextFrame = null;
> XCell xCell = null;
>
> if (xPropertySetInfo.hasPropertyByName("TextSection")) {
> xTextSection = (XTextSection)
> UnoRuntime.queryInterface(XTextSection.class,
> xPropertySet.getPropertyValue("TextSection"));
> }
>
> if (xPropertySetInfo.hasPropertyByName("TextFrame")) {
> xTextFrame = (XTextFrame) UnoRuntime.queryInterface(XTextFrame.class,
> xPropertySet.getPropertyValue("TextFrame"));
> }
>
> if (xPropertySetInfo.hasPropertyByName("Cell")) {
> xCell = (XCell) UnoRuntime.queryInterface(XCell.class,
> xPropertySet.getPropertyValue("Cell"));
> }
> }
>
--
View this message in context:
http://www.nabble.com/Finding-text-frames-in-selected-textrange-tp23962545p23981287.html
Sent from the openoffice - sw dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]