Hi Zbigniew,
Am 26.01.2011 10:28, schrieb Zbigniew Szot:
Hello

I have problem in finding relation between placement of a text section
and a text range .
Things are easy when section and range are placed in main document,
and get complicated when at least one of them is "nested" inside text table.
In this case they belong to differend XText object and
XTextRangeCompare can not be used (exception  would be thrown).
The only reasonable way to do this seems to be to compare of an anchor
of the nested XText with position of the section/range placed in main
document.

Problem is that I don't know which one is nested (posibly both of them
are nested).
My question is: how can I determin relation between two XText objects
which are part of one document.

Finding out that XText is nested and determination of its parent would
be very helpful.

I wouldn't like to "steal" text view cursor from user to figure it
out, and would love to find solution based on "model level" analize.

Shure.
Maybe you must call the snippet recursively to find out the last parent:
a table can be in a frame, which can be in a section and so on.

if (object instanceof XTextRange) {
        
XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, object);
        XPropertySetInfo xPropertySetInfo = xPropertySet.getPropertySetInfo();


        /*
        * check if xTextRange resides in sidea cell, a section or a frame
        */

        XTextSection xTextSection = null;
        XTextFrame xTextFrame = null;
        XCell xCell = null;
        // getPropertyValue gives either null  or adequate object

        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")) {//or TextTable
xCell = (XCell) UnoRuntime.queryInterface(XCell.class, xPropertySet.getPropertyValue("Cell"));// or TextTable
        }
}

HTH

Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to