Package com.sun.star.beans

Examples of com.sun.star.beans.StringPair


    /* TODO: test partial selection, test UNDO/REDO */

    // #i109601# NestedTextContent and XChild
    public void testMetaXChild() throws Exception
    {
        StringPair id1 = new StringPair("content.xml", mkName("id"));
        StringPair id2 = new StringPair("content.xml", mkName("id"));
        StringPair id3 = new StringPair("content.xml", mkName("id"));
        StringPair id4 = new StringPair("content.xml", mkName("id"));
        StringPair id5 = new StringPair("content.xml", mkName("id"));
        StringPair id6 = new StringPair("content.xml", mkName("id"));
        TreeNode meta1 = new MetaNode(id1);
        TreeNode meta2 = new MetaNode(id2);
        TreeNode meta3 = new MetaFieldNode(id3);
        TreeNode meta4 = new MetaNode(id4);
        TreeNode meta5 = new MetaNode(id5);
        TreeNode meta6 = new MetaFieldNode(id6);
        TreeNode root = new TreeNode()
            .appendChild( meta1.dup()
                .appendChild( new TextNode("1") ) )
            .appendChild( new TextNode("2") )
            .appendChild( meta2.dup()
                .appendChild( meta3.dup()
                    .appendChild( new TextNode("34") )
                    .appendChild( meta4.dup()
                        .appendChild( new TextNode("56") ) )
                    .appendChild( meta5.dup() )
                    .appendChild( new TextNode("7") ) ) )
            .appendChild( new TextNode("8") )
            .appendChild( meta6.dup()
                .appendChild( new TextNode("9") ) );

        RangeInserter inserter = new RangeInserter(m_xDoc);
        TreeNode text = new TextNode("123456789");
        inserter.insertRange( new Range(0, 0, text) );
        XTextContent xMeta1 = inserter.insertRange( new Range(0, 1, meta1) );
        XTextContent xMeta2 = inserter.insertRange( new Range(3, 8, meta2) );
        XTextContent xMeta3 = inserter.insertRange( new Range(4, 9, meta3) );
        XTextContent xMeta4 = inserter.insertRange( new Range(7, 9, meta4) );
        XTextContent xMeta5 = inserter.insertRange( new Range(10, 10, meta5) );
        XTextContent xMeta6 = inserter.insertRange( new Range(13, 14, meta6) );

        doTest(root, false);

        XText xDocText = m_xDoc.getText();
        XTextCursor xDocTextCursor = xDocText.createTextCursor();
        XParagraphCursor xParagraphCursor = (XParagraphCursor)
            UnoRuntime.queryInterface(XParagraphCursor.class, xDocTextCursor);
        xParagraphCursor.gotoNextParagraph(false); // second paragraph
        // X12XX34X56X78X9
        // 1  23  4  5  6
        //  1       452  6
        //            3
        StringPair [] nestedTextContent = new StringPair[] {
            null,
            id1,
            id1,
            null,
            id2,
            id3,
            id3,
            id3,
            id4,
            id4,
            id4,
            id5,
            id3,
            null,
            id6,
            id6,
        };
        XPropertySet xPropertySet = (XPropertySet)
            UnoRuntime.queryInterface(XPropertySet.class, xDocTextCursor);
        for (int i = 0; i < nestedTextContent.length; ++i) {
            Object oNTC = xPropertySet.getPropertyValue("NestedTextContent");
            XTextContent xNTC = (XTextContent)
                UnoRuntime.queryInterface(XTextContent.class, oNTC);
            if (null == nestedTextContent[i]) {
                assure("unexpected NestedTextContent at: " + i, null == xNTC);
            } else {
                XMetadatable xMetadatable = (XMetadatable)
                    UnoRuntime.queryInterface(XMetadatable.class, xNTC);
                StringPair xmlid = xMetadatable.getMetadataReference();
                assure("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);
            assure("setParent(): allowed?", false);
        } catch (NoSupportException e) { /* expected */ }
        assure("getParent(): not null", xChild1.getParent() == null);
        assure("getParent(): not null", xChild2.getParent() == null);
        assure("getParent(): not null", xChild6.getParent() == null);
        {
            Object xParent3 = xChild3.getParent();
            assure("getParent(): null", null != xParent3);
            XMetadatable xMetadatable = (XMetadatable)
                UnoRuntime.queryInterface(XMetadatable.class, xParent3);
            StringPair xmlid = xMetadatable.getMetadataReference();
            assure("getParent(): wrong", MetaNode.eq(xmlid, id2));
        }{
            Object xParent4 = xChild4.getParent();
            assure("getParent(): null", null != xParent4);
            XMetadatable xMetadatable = (XMetadatable)
                UnoRuntime.queryInterface(XMetadatable.class, xParent4);
            StringPair xmlid = xMetadatable.getMetadataReference();
            assure("getParent(): wrong", MetaNode.eq(xmlid, id3));
        }{
            Object xParent5 = xChild5.getParent();
            assure("getParent(): null", null != xParent5);
            XMetadatable xMetadatable = (XMetadatable)
                UnoRuntime.queryInterface(XMetadatable.class, xParent5);
            StringPair xmlid = xMetadatable.getMetadataReference();
            assure("getParent(): wrong", MetaNode.eq(xmlid, id3));
        }
    }
View Full Code Here


        XNameAccess xBookmarks = xBMS.getBookmarks();
        XMetadatable xMark1 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xBookmarks.getByName("mk1"));
        assure("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);
        assure("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"));
        assure("mark3",
                eq(xMark3.getMetadataReference(),
                    new StringPair("content.xml", "id91")));

        log.println("...done");

        log.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"));
        assure("idsection1", eq(xSection1.getMetadataReference(),
                    new StringPair("content.xml", "idSection1")));

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

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

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

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

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

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

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

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

        log.println("...done");

        log.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"));
        assure("idTOC", eq(xIndex1.getMetadataReference(),
                    new StringPair("content.xml", "idTOC")));
        XMetadatable xIndex1s = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xSections.getByName("Table of Contents1"));
        assure("idTOC", eq(xIndex1s.getMetadataReference(),
                    new StringPair("content.xml", "idTOC")));

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

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

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

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

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

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

        log.println("...done");
    }
View Full Code Here

        return prefix + String.valueOf(m_Count++);
    }

    private StringPair mkId(String prefix)
    {
        return new StringPair("content.xml", mkName(prefix));
    }
View Full Code Here

        return new StringPair("content.xml", mkName(prefix));
    }

    private StringPair mkId_(String id)
    {
        return new StringPair("content.xml", id);
    }
View Full Code Here

        public String getStringValue() { return ""; }
        public String getNamespace() { return ""; }
        public String getLocalName() { return ""; }

        public StringPair getMetadataReference()
            { return new StringPair(m_Stream, m_XmlId); }
View Full Code Here

        public String getStringValue() { return ""; }
        public String getNamespace() { return ""; }
        public String getLocalName() { return ""; }

        public StringPair getMetadataReference()
            { return new StringPair(m_Stream, m_XmlId); }
View Full Code Here

            TreeNode node = children.next();
            String type = node.getType();
            if (type.equals("Bookmark")) {
                BookmarkNode bkmk = (BookmarkNode) node;
                String name = bkmk.getName();
                StringPair id = bkmk.getXmlId();
                if (bkmk.isPoint()) {
                    insertBookmark(m_xCursor, name, id);
                } else if (bkmk.isStart()) {
                    m_BookmarkStarts.put(name, m_xCursor.getStart());
                } else {
View Full Code Here

class BookmarkNode extends MarkNode
{
    private StringPair m_XmlId;
    StringPair getXmlId() { return m_XmlId; }
    BookmarkNode dup() { return new BookmarkNode(getName(), getXmlId()); }
    BookmarkNode(String name) { this(name, new StringPair())}
View Full Code Here

}

class BookmarkStartNode extends BookmarkNode
{
    BookmarkStartNode dup() { return new BookmarkStartNode(getName()); }
    BookmarkStartNode(String name) { this(name, new StringPair()); }
View Full Code Here

}

class BookmarkEndNode extends BookmarkNode
{
    BookmarkEndNode dup() { return new BookmarkEndNode(getName()); }
    BookmarkEndNode(String name) { this(name, new StringPair()); }
View Full Code Here

TOP

Related Classes of com.sun.star.beans.StringPair

Copyright © 2018 www.massapicom. 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.