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. 
I've tried to check if xInterface supports service "TextFrame", but it
doesn't (regardless of the anchor type).
I've tried using XTextFramesSupplier but it's null. 
This is my code:

        XSelectionSupplier xSelSupplier = (XSelectionSupplier)
UnoRuntime.queryInterface(
                XSelectionSupplier.class, xController);
        Object oSelection = xSelSupplier.getSelection();
        XServiceInfo xServInfo = (XServiceInfo) UnoRuntime.queryInterface(
                XServiceInfo.class, oSelection);

        if (xServInfo.supportsService(
                "com.sun.star.text.TextRanges")) {
            com.sun.star.container.XIndexAccess xIndexAccess =
(com.sun.star.container.XIndexAccess) UnoRuntime.queryInterface(
                    com.sun.star.container.XIndexAccess.class, oSelection);

            int count = xIndexAccess.getCount();
            com.sun.star.text.XTextRange xTextRange = null;
            for (int i = 0; i < count; i++) {
                try {
                    xTextRange = (com.sun.star.text.XTextRange)
UnoRuntime.queryInterface(
                            com.sun.star.text.XTextRange.class,
                            xIndexAccess.getByIndex(i));
                    {
                        XEnumerationAccess xEnumerationAccess =
(XEnumerationAccess) UnoRuntime.queryInterface(
                                XEnumerationAccess.class, xTextRange);
                        if (!xEnumerationAccess.equals(null)) {
                            XEnumeration xParaEnum =
xEnumerationAccess.createEnumeration();
                            if (!xParaEnum.equals(null)) {
                                while (xParaEnum.hasMoreElements()) {
                                    XInterface xInterface = null;
                                    try {
                                        xInterface = (XInterface)
UnoRuntime.queryInterface(XInterface.class, xParaEnum.nextElement());

                                    } catch (NoSuchElementException ex) {
                                       
Logger.getLogger(SWriter.class.getName()).log(Level.SEVERE, null, ex);
                                    }
                                    if (!xInterface.equals(null)) {
                                        XServiceInfo xServiceInfo =
(XServiceInfo) UnoRuntime.queryInterface(
                                                XServiceInfo.class,
xInterface);
                                        if (!xServiceInfo.equals(null)) {
                                            if
(xServiceInfo.supportsService("com.sun.star.text.TextTable")) {
                                                    //do something with the
text table
                                            } else {
                                                if
(xServiceInfo.supportsService("com.sun.star.text.Paragraph")) {
                                                    //do something with the
paragraph
                                                }
                       ...
}


Any hint will be greatly appreciated, thanks. 


-- 
View this message in context: 
http://www.nabble.com/Finding-text-frames-in-selected-textrange-tp23962545p23962545.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]

Reply via email to