Examples of XMetadatable


Examples of com.sun.star.rdf.XMetadatable

            System.out.println("...done");

            System.out.println("Checking RDFa in loaded test document...");

            XMetadatable xPara;
            Pair<Statement[], Boolean> result;

            Statement x_FooBarLit1 = new Statement(foo, bar, mkLit("1"), null);
            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
View Full Code Here

Examples of com.sun.star.rdf.XMetadatable

                XServiceInfo xService = (XServiceInfo)
                    UnoRuntime.queryInterface(XServiceInfo.class, xField);
                if (xService.supportsService(
                        "com.sun.star.text.textfield.MetadataField"))
                {
                    XMetadatable xMeta = (XMetadatable)
                        UnoRuntime.queryInterface(XMetadatable.class, xField);
                    StringPair xmlid = xMeta.getMetadataReference();
                    node = new MetaFieldNode(xmlid);
                    m_Stack.push(node);
                    XEnumerationAccess xEA = (XEnumerationAccess)
                        UnoRuntime.queryInterface(XEnumerationAccess.class,
                        xMeta);
                    XEnumeration xEnumChildren = xEA.createEnumeration();
                    TreeNode node2 = convertChildren(xEnumChildren);
                    assertSame("stack error: meta-field", node2, node);
                } else {
                    XPropertySet xFieldPropSet = (XPropertySet)
                        UnoRuntime.queryInterface(XPropertySet.class, xField);
                    String content = (String)
                        xFieldPropSet.getPropertyValue("Content");
                    boolean isFixed = (Boolean)
                        xFieldPropSet.getPropertyValue("IsFixed");
                    assertTrue("field not fixed?", isFixed);
                    node = new TextFieldNode(content);
                }
            } else if (type.equals("Footnote")) {
                Object xNote = xPropSet.getPropertyValue("Footnote");
                XFootnote xFootnote = (XFootnote)
                    UnoRuntime.queryInterface(XFootnote.class, xNote);
                String label = xFootnote.getLabel();
                node = new FootnoteNode(label);
            } else if (type.equals("Frame")) {
                XContentEnumerationAccess xCEA = (XContentEnumerationAccess)
                    UnoRuntime.queryInterface(XContentEnumerationAccess.class,
                        xPortion);
                XEnumeration xContentEnum = xCEA.createContentEnumeration("");
                while (xContentEnum.hasMoreElements()) {
                    Object xFrame = xContentEnum.nextElement();
                    XPropertySet xFramePropSet = (XPropertySet)
                        UnoRuntime.queryInterface(XPropertySet.class, xFrame);
                    TextContentAnchorType anchor = (TextContentAnchorType)
                        xFramePropSet.getPropertyValue("AnchorType");
                    XNamed xNamed = (XNamed)
                        UnoRuntime.queryInterface(XNamed.class, xFrame);
                    String name = xNamed.getName();
                    node = new FrameNode(name, anchor);
                    m_Stack.peek().appendChild(node);
                }
                continue;
            } else if (type.equals("ControlCharacter")) {
                short c = (Short)
                    xPropSet.getPropertyValue("ControlCharacter");
                node = new ControlCharacterNode(c);
            } else if (type.equals("Bookmark")) {
                Object xMark = xPropSet.getPropertyValue("Bookmark");
                XNamed xNamed = (XNamed)
                    UnoRuntime.queryInterface(XNamed.class, xMark);
                String name = xNamed.getName();
                XMetadatable xMetadatable = (XMetadatable)
                    UnoRuntime.queryInterface(XMetadatable.class, xMark);
                StringPair xmlid = xMetadatable.getMetadataReference();
                boolean isCollapsed = (Boolean)
                    xPropSet.getPropertyValue("IsCollapsed");
                if (isCollapsed) {
                    node = new BookmarkNode(name, xmlid);
                } else {
                    boolean isStart = (Boolean)
                        xPropSet.getPropertyValue("IsStart");
                    if (isStart) {
                        node = new BookmarkStartNode(name, xmlid);
                    } else {
                        node = new BookmarkEndNode(name, xmlid);
                    }
                }
            } else if (type.equals("ReferenceMark")) {
                Object xMark = xPropSet.getPropertyValue("ReferenceMark");
                XNamed xNamed = (XNamed)
                    UnoRuntime.queryInterface(XNamed.class, xMark);
                String name = xNamed.getName();
                boolean isCollapsed = (Boolean)
                    xPropSet.getPropertyValue("IsCollapsed");
                if (isCollapsed) {
                    node = new ReferenceMarkNode(name);
                } else {
                    boolean isStart = (Boolean)
                        xPropSet.getPropertyValue("IsStart");
                    if (isStart) {
                        node = new ReferenceMarkStartNode(name);
                    } else {
                        node = new ReferenceMarkEndNode(name);
                    }
                }
            } else if (type.equals("DocumentIndexMark")) {
                Object xMark = xPropSet.getPropertyValue("DocumentIndexMark");
                XPropertySet xMarkSet = (XPropertySet)
                    UnoRuntime.queryInterface(XPropertySet.class, xMark);
                String name = (String) xMarkSet.getPropertyValue("PrimaryKey");
                boolean isCollapsed = (Boolean)
                    xPropSet.getPropertyValue("IsCollapsed");
                if (isCollapsed) {
                    node = new DocumentIndexMarkNode(name);
                } else {
                    boolean isStart = (Boolean)
                        xPropSet.getPropertyValue("IsStart");
                    if (isStart) {
                        node = new DocumentIndexMarkStartNode(name);
                    } else {
                        node = new DocumentIndexMarkEndNode(name);
                    }
                }
            } else if (type.equals("SoftPageBreak")) {
                node = new SoftPageBreakNode();
            } else if (type.equals("Ruby")) {
                boolean isStart = (Boolean)
                    xPropSet.getPropertyValue("IsStart");
                if (isStart) {
                    // ARRGH!!! stupid api...
                    // the text is ONLY at the start!
                    String ruby = (String)
                        xPropSet.getPropertyValue("RubyText");
                    node = new RubyNode(ruby);
                    m_Stack.push(node);
                    continue;
                } else {
                    node = m_Stack.pop();
                    assertTrue("stack error: Ruby expected; is: " +
                               node.toString(), node instanceof RubyNode);
                }
            } else if (type.equals("InContentMetadata")) {
                Object xMeta = xPropSet.getPropertyValue("InContentMetadata");
                XMetadatable xMetadatable = (XMetadatable)
                    UnoRuntime.queryInterface(XMetadatable.class, xMeta);
                StringPair xmlid = xMetadatable.getMetadataReference();
                node = new MetaNode(xmlid);
                m_Stack.push(node);
                XEnumerationAccess xEA = (XEnumerationAccess)
                    UnoRuntime.queryInterface(XEnumerationAccess.class, xMeta);
                XEnumeration xEnumChildren = xEA.createEnumeration();
View Full Code Here

Examples of com.sun.star.rdf.XMetadatable

    {
        XTextContent xContent = makeBookmark(name);
        xContent.attach(xCursor);
        if (!xmlid.First.equals(""))
        {
            XMetadatable xMetadatable = (XMetadatable)
                UnoRuntime.queryInterface(XMetadatable.class, xContent);
            xMetadatable.setMetadataReference(xmlid);
        }
    }
View Full Code Here

Examples of com.sun.star.rdf.XMetadatable

            XTextContent xNTC = (XTextContent)
                UnoRuntime.queryInterface(XTextContent.class, oNTC);
            if (null == nestedTextContent[i]) {
                assertNull("unexpected NestedTextContent at: " + i, xNTC);
            } else {
                XMetadatable xMetadatable = (XMetadatable)
                    UnoRuntime.queryInterface(XMetadatable.class, xNTC);
                StringPair xmlid = xMetadatable.getMetadataReference();
                assertTrue("wrong NestedTextContent at: " + i,
                    MetaNode.eq(nestedTextContent[i], xmlid));
            }
            xDocTextCursor.goRight((short)1, false);
        }

        XChild xChild1 = (XChild)
            UnoRuntime.queryInterface(XChild.class, xMeta1);
        XChild xChild2 = (XChild)
            UnoRuntime.queryInterface(XChild.class, xMeta2);
        XChild xChild3 = (XChild)
            UnoRuntime.queryInterface(XChild.class, xMeta3);
        XChild xChild4 = (XChild)
            UnoRuntime.queryInterface(XChild.class, xMeta4);
        XChild xChild5 = (XChild)
            UnoRuntime.queryInterface(XChild.class, xMeta5);
        XChild xChild6 = (XChild)
            UnoRuntime.queryInterface(XChild.class, xMeta6);
        try {
            xChild1.setParent(xChild4);
            fail("setParent(): allowed?");
        } catch (NoSupportException e) { /* expected */ }
        assertNull("getParent(): not null", xChild1.getParent());
        assertNull("getParent(): not null", xChild2.getParent());
        assertNull("getParent(): not null", xChild6.getParent());
        {
            Object xParent3 = xChild3.getParent();
            assertNotNull("getParent(): null", xParent3);
            XMetadatable xMetadatable = (XMetadatable)
                UnoRuntime.queryInterface(XMetadatable.class, xParent3);
            StringPair xmlid = xMetadatable.getMetadataReference();
            assertTrue("getParent(): wrong", MetaNode.eq(xmlid, id2));
        }{
            Object xParent4 = xChild4.getParent();
            assertNotNull("getParent(): null", xParent4);
            XMetadatable xMetadatable = (XMetadatable)
                UnoRuntime.queryInterface(XMetadatable.class, xParent4);
            StringPair xmlid = xMetadatable.getMetadataReference();
            assertTrue("getParent(): wrong", MetaNode.eq(xmlid, id3));
        }{
            Object xParent5 = xChild5.getParent();
            assertNotNull("getParent(): null", xParent5);
            XMetadatable xMetadatable = (XMetadatable)
                UnoRuntime.queryInterface(XMetadatable.class, xParent5);
            StringPair xmlid = xMetadatable.getMetadataReference();
            assertTrue("getParent(): wrong", MetaNode.eq(xmlid, id3));
        }
    }
View Full Code Here

Examples of com.sun.star.rdf.XMetadatable

        xDocTextCursor.goRight((short)3, false);
        xDocTextCursor.goRight((short)2, true);
        xDocText.insertTextContent(xDocTextCursor, xMeta, true);
//        xMeta.attach(xDocTextCursor);

        XMetadatable xMetadatable = (XMetadatable)
            UnoRuntime.queryInterface(XMetadatable.class, xMeta);
        xMetadatable.setMetadataReference(meta.getXmlId());
        XText xText = (XText) UnoRuntime.queryInterface(XText.class, xMeta);

        XText xParentText = xText.getText();
        assertNotNull("getText(): no parent", xParentText);
View Full Code Here

Examples of com.sun.star.rdf.XMetadatable

        xDocTextCursor.goRight((short)7, false);
        xDocTextCursor.goRight((short)2, true);
        xDocText.insertTextContent(xDocTextCursor, xMeta, true);
        xDocTextCursor.gotoStart(true);

        XMetadatable xMetadatable = (XMetadatable)
            UnoRuntime.queryInterface(XMetadatable.class, xMeta);
        xMetadatable.setMetadataReference(met1.getXmlId());
        XText xText = (XText) UnoRuntime.queryInterface(XText.class, xMeta);

        XTextRange xStart = xText.getStart();
        assertNotNull("getStart(): no start", xStart);
        XTextRange xEnd = xText.getEnd();
View Full Code Here

Examples of com.sun.star.rdf.XMetadatable

                        throws Exception {
                    return inserter.makeMeta();
                }
                void postInserted(TreeNode node, XTextContent xContent)
                        throws Exception {
                    XMetadatable xMetadatable = (XMetadatable)
                        UnoRuntime.queryInterface(XMetadatable.class, xContent);
                    xMetadatable.setMetadataReference(
                            ((MetaNode)node).getXmlId());
                }
            });
    }
View Full Code Here

Examples of com.sun.star.rdf.XMetadatable

        XTextCursor xDocTextCursor = xDocText.createTextCursor();
        xDocTextCursor.goRight((short)3, false);
        xDocTextCursor.goRight((short)2, true);
        xDocText.insertTextContent(xDocTextCursor, xMeta, true);

        XMetadatable xMetadatable = (XMetadatable)
            UnoRuntime.queryInterface(XMetadatable.class, xMeta);
        xMetadatable.setMetadataReference(met1.getXmlId());
        XText xText = (XText) UnoRuntime.queryInterface(XText.class, xMeta);
        XTextRange xStart = null;
        XTextRange xEnd = null;

        {
View Full Code Here

Examples of com.sun.star.rdf.XMetadatable

        XTextField xMetaField = inserter.makeMetaField();

        xDocText.insertTextContent(xDocTextCursor, xMetaField, true);

        XMetadatable xMetadatable = (XMetadatable)
            UnoRuntime.queryInterface(XMetadatable.class, xMetaField);
        xMetadatable.ensureMetadataReference();

        xGraph.addStatement(xMetadatable, xOdfPrefix, xPrefix);
        xGraph.addStatement(xMetadatable, xOdfSuffix, xSuffix);
        assertEquals("getPresentation(): wrong",
                     "fooabcbar", xMetaField.getPresentation(false));
View Full Code Here

Examples of com.sun.star.rdf.XMetadatable

            UnoRuntime.queryInterface(XDocumentRepository.class,
                xRS.getRDFRepository());
        XBookmarksSupplier xBMS = (XBookmarksSupplier)
            UnoRuntime.queryInterface(XBookmarksSupplier.class, xTextDoc);
        XNameAccess xBookmarks = xBMS.getBookmarks();
        XMetadatable xMark1 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xBookmarks.getByName("mk1"));
        assertTrue("mark1",
                eq(xMark1.getMetadataReference(),
                    new StringPair("content.xml", "id90")));

        XMetadatable xMark2 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xBookmarks.getByName("mk2"));
        Pair<Statement[], Boolean> result = xRepo.getStatementRDFa(xMark2);
        assertTrue("mark2", (result.First.length == 1)
            && result.First[0].Subject.getStringValue().equals("uri:foo")
            && result.First[0].Predicate.getStringValue().equals("uri:bar")
            && result.First[0].Object.getStringValue().contains("a fooish bar")
            );

        XMetadatable xMark3 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xBookmarks.getByName("mk3"));
        assertTrue("mark3",
                eq(xMark3.getMetadataReference(),
                    new StringPair("content.xml", "id91")));

        System.out.println("...done");

        System.out.println("Checking sections in loaded test document...");

        XTextSectionsSupplier xTSS = (XTextSectionsSupplier)
            UnoRuntime.queryInterface(XTextSectionsSupplier.class, xTextDoc);

        XNameAccess xSections = xTSS.getTextSections();

        XMetadatable xSection1 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xSections.getByName("Section 1"));
        assertTrue("idsection1", eq(xSection1.getMetadataReference(),
                    new StringPair("content.xml", "idSection1")));

        XMetadatable xSection2 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xSections.getByName("Section 2"));
        assertTrue("idSection2", eq(xSection2.getMetadataReference(),
                    new StringPair("content.xml", "idSection2")));

        XMetadatable xSection3 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class,
                xSections.getByName("Table of Contents1_Head"));
        assertTrue("idTOCTitle", eq(xSection3.getMetadataReference(),
                    new StringPair("content.xml", "idTOCTitle")));

        XMetadatable xSection4 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class,
                xSections.getByName("Alphabetical Index1_Head"));
        assertTrue("idAITitle", eq(xSection4.getMetadataReference(),
                    new StringPair("content.xml", "idAITitle")));

        XMetadatable xSection5 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class,
                xSections.getByName("Illustration Index1_Head"));
        assertTrue("idIITitle", eq(xSection5.getMetadataReference(),
                    new StringPair("content.xml", "idIITitle")));

        XMetadatable xSection6 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class,
                xSections.getByName("Index of Tables1_Head"));
        assertTrue("idIOTTitle", eq(xSection6.getMetadataReference(),
                    new StringPair("content.xml", "idIOTTitle")));

        XMetadatable xSection7 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class,
                xSections.getByName("User-Defined1_Head"));
        assertTrue("idUDTitle", eq(xSection7.getMetadataReference(),
                    new StringPair("content.xml", "idUDTitle")));

        XMetadatable xSection8 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class,
                xSections.getByName("Table of Objects1_Head"));
        assertTrue("idTOOTitle", eq(xSection8.getMetadataReference(),
                    new StringPair("content.xml", "idTOOTitle")));

        XMetadatable xSection9 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xSections.getByName("Bibliography1_Head"));
        assertTrue("idBibTitle", eq(xSection9.getMetadataReference(),
                    new StringPair("content.xml", "idBibTitle")));

        System.out.println("...done");

        System.out.println("Checking indexes in loaded test document...");

        XDocumentIndexesSupplier xDIS = (XDocumentIndexesSupplier)
            UnoRuntime.queryInterface(XDocumentIndexesSupplier.class, xTextDoc);
        XIndexAccess xIndexesIA = xDIS.getDocumentIndexes();
        XNameAccess xIndexes =
            UnoRuntime.queryInterface(XNameAccess.class, xIndexesIA);

        XMetadatable xIndex1 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xIndexes.getByName("Table of Contents1"));
        assertTrue("idTOC", eq(xIndex1.getMetadataReference(),
                    new StringPair("content.xml", "idTOC")));
        XMetadatable xIndex1s = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xSections.getByName("Table of Contents1"));
        assertTrue("idTOC", eq(xIndex1s.getMetadataReference(),
                    new StringPair("content.xml", "idTOC")));

        XMetadatable xIndex2 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xIndexes.getByName("Alphabetical Index1"));
        assertTrue("idAI", eq(xIndex2.getMetadataReference(),
                    new StringPair("content.xml", "idAI")));
        XMetadatable xIndex2s = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xSections.getByName("Alphabetical Index1"));
        assertTrue("idAI", eq(xIndex2s.getMetadataReference(),
                    new StringPair("content.xml", "idAI")));

        XMetadatable xIndex3 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xIndexes.getByName("Illustration Index1"));
        assertTrue("idII", eq(xIndex3.getMetadataReference(),
                    new StringPair("content.xml", "idII")));
        XMetadatable xIndex3s = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xSections.getByName("Illustration Index1"));
        assertTrue("idII", eq(xIndex3s.getMetadataReference(),
                    new StringPair("content.xml", "idII")));

        XMetadatable xIndex4 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xIndexes.getByName("Index of Tables1"));
        assertTrue("idIOT", eq(xIndex4.getMetadataReference(),
                    new StringPair("content.xml", "idIOT")));
        XMetadatable xIndex4s = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xSections.getByName("Index of Tables1"));
        assertTrue("idIOT", eq(xIndex4s.getMetadataReference(),
                    new StringPair("content.xml", "idIOT")));

        XMetadatable xIndex5 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xIndexes.getByName("User-Defined1"));
        assertTrue("idUD", eq(xIndex5.getMetadataReference(),
                    new StringPair("content.xml", "idUD")));
        XMetadatable xIndex5s = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xSections.getByName("User-Defined1"));
        assertTrue("idUD", eq(xIndex5s.getMetadataReference(),
                    new StringPair("content.xml", "idUD")));

        XMetadatable xIndex6 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xIndexes.getByName("Table of Objects1"));
        assertTrue("idTOO", eq(xIndex6.getMetadataReference(),
                    new StringPair("content.xml", "idTOO")));
        XMetadatable xIndex6s = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xSections.getByName("Table of Objects1"));
        assertTrue("idTOO", eq(xIndex6s.getMetadataReference(),
                    new StringPair("content.xml", "idTOO")));

        XMetadatable xIndex7 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xIndexes.getByName("Bibliography1"));
        assertTrue("idBib", eq(xIndex7.getMetadataReference(),
                    new StringPair("content.xml", "idBib")));
        XMetadatable xIndex7s = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xSections.getByName("Bibliography1"));
        assertTrue("idBib", eq(xIndex7s.getMetadataReference(),
                    new StringPair("content.xml", "idBib")));

        System.out.println("...done");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.