Package com.sun.star.beans

Examples of com.sun.star.beans.StringPair


    public boolean test()
  {
    try
    {
      StringPair[][] aRelations =
        { { new StringPair( "Id", "Num1" ) },
          { new StringPair( "Target", "TargetURLValue" ), new StringPair( "Id", "Num6" ) },
          { new StringPair( "Target", "" ), new StringPair( "Id", "Num7" ) },
          { new StringPair( "Id", "Num2" ), new StringPair( "TargetMode", "Internal" ), new StringPair( "Type", "unknown" ), new StringPair( "Target", "URL value" ) },
          { new StringPair( "Id", "Num3" ), new StringPair( "TargetMode", "Internal" ), new StringPair( "Type", "unknown" ), new StringPair( "Target", "URL value" ) },
          { new StringPair( "Id", "Num4" ), new StringPair( "TargetMode", "Internal" ), new StringPair( "Type", "unknown" ), new StringPair( "Target", "URL value" ) },
          { new StringPair( "Id", "Num5" ), new StringPair( "TargetMode", "" ), new StringPair( "Type", "unknown" ), new StringPair( "Target", "URL value" ) }
        };

      // create temporary storage based on arbitrary medium
      // after such a storage is closed it is lost
      XStorage xTempStorage = m_aTestHelper.createTempStorage( m_xMSF, m_xStorageFactory );
View Full Code Here


    }

    @Test public void testBookmarkPointXmlId() throws Exception
    {
        String name = mkName("mark");
        StringPair id = mkId("id");
        TreeNode root = new TreeNode();
        TreeNode bkmk = new BookmarkNode(name, id);
        TreeNode text = new TextNode("abc");
        root.appendChild(bkmk);
        root.appendChild(text);
View Full Code Here

    }

    @Test public void testBookmarkXmlId() throws Exception
    {
        String name = mkName("mark");
        StringPair id = mkId("id");
        TreeNode root = new TreeNode();
        TreeNode bkm1 = new BookmarkStartNode(name, id);
        TreeNode text = new TextNode("abc");
        TreeNode bkm2 = new BookmarkEndNode(name, id);
        root.appendChild(bkm1);
View Full Code Here

        doTest(root);
    }

    @Test public void testMeta() throws Exception
    {
        StringPair id = new StringPair("content.xml", mkName("id"));
        TreeNode root = new TreeNode();
        TreeNode meta = new MetaNode(id);
        TreeNode text = new TextNode("abc");
        root.appendChild(new TextNode("123"));
        meta.appendChild(text);
View Full Code Here

        doTest(root);
    }

    @Test public void testMetaEmpty() throws Exception
    {
        StringPair id = new StringPair("content.xml", mkName("id"));
        TreeNode root = new TreeNode();
        TreeNode meta = new MetaNode(id);
//        TreeNode text = new TextNode("");
//        meta.appendChild(text);
        root.appendChild(meta);
View Full Code Here

        doTest(root);
    }

    @Test public void testMetaField() throws Exception
    {
        StringPair id = new StringPair("content.xml", mkName("id"));
        TreeNode root = new TreeNode();
        TreeNode meta = new MetaFieldNode(id);
        TreeNode text = new TextNode("abc");
        root.appendChild(new TextNode("123"));
        meta.appendChild(text);
View Full Code Here

        doTest(root);
    }

    @Test public void testMetaFieldEmpty() throws Exception
    {
        StringPair id = new StringPair("content.xml", mkName("id"));
        TreeNode root = new TreeNode();
        TreeNode meta = new MetaFieldNode(id);
//        TreeNode text = new TextNode("");
//        meta.appendChild(text);
        root.appendChild(meta);
View Full Code Here

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

    // #i109601# NestedTextContent and XChild
    @Test 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]) {
                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

        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

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

    private StringPair mkId(String prefix)
    {
        return new StringPair("content.xml", mkName(prefix));
    }
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.