Package com.sun.star.text

Examples of com.sun.star.text.XTextDocument


     *
     * Has <b>OK</b> status if the returned value is positive.
     */
    public void _getPage(){
        log.println( "test for getPage()" );
        XTextDocument myText = (XTextDocument)tEnv.getObjRelation( "TEXTDOC" );
        XText aText = myText.getText();
        XTextCursor myCursor = aText.createTextCursor();

        try{
            for (int i = 0; i < 10; i++){
                for (int j = 0; j < 20; j++){
View Full Code Here


    {
        super.prepareDocument();

        // insert a table with exactly one cell. The content of this table will be synced with
        // the content of a form control
        XTextDocument textDoc = (XTextDocument)UnoRuntime.queryInterface( XTextDocument.class,  m_document.getDocument() );
        XText documentText = textDoc.getText();
        XTextCursor textCursor = documentText.createTextCursor();
        documentText.insertString( textCursor, "Below, there's a table cell, and a text field. ", false );
        documentText.insertString( textCursor, "Both are linked via an external value binding.\n", false );
        documentText.insertString( textCursor, "That means that anything you insert into the table cell is reflected in the ", false );
        documentText.insertString( textCursor, "text field, and vice versa.\n", false );
View Full Code Here

    try {
         if ( aURL.Protocol.compareTo("com.CompPad.addon:") == 0 )
        {
            XFrame xFrame = m_xFrame;
            XTextDocument xTextDoc = (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,
                    xFrame.getController().getModel());

            myLogger.log(
                    Level.FINE, "xTextDoc "+xTextDoc);
            XMultiComponentFactory xServiceManager =
View Full Code Here

        com.sun.star.lang.XComponent xc = xEOS.getEmbeddedObject();
        ((XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xc)).setPropertyValue("Formula",formulaText);
    }
    /* Get current frame from context */
    private static XFrame getFrameFromContext(XComponentContext xContext) throws java.lang.Exception{
            XTextDocument xTextDoc=null;
            XMultiComponentFactory xServiceManager =
                    xContext.getServiceManager();
            Object odesktop = xServiceManager.createInstanceWithContext(
                    "com.sun.star.frame.Desktop", xContext);
            XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
View Full Code Here

            properties[2].Value=Boolean.valueOf(true);
            XComponentLoader loader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class,xFrame);
            XComponent xComp  = null;
            xComp = loader.loadComponentFromURL(fName, "_blank", 0, properties);

            XTextDocument textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,xComp);
            XStorable storable = (XStorable) UnoRuntime.queryInterface(
                XStorable.class, xComp) ;
            /*XStorable storable = (XStorable) UnoRuntime.queryInterface(
                XStorable.class, xFrame.getController().getModel()) ; */
            PropertyValue[] propertyValue = new PropertyValue[ 3 ];
View Full Code Here

            properties[2].Value=Boolean.valueOf(true);
            XComponentLoader loader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class,xFrame);
            XComponent xComp  = null;
            xComp = loader.loadComponentFromURL(fName, "_blank", 0, properties);

            XTextDocument textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,xComp);
            XStorable storable = (XStorable) UnoRuntime.queryInterface(
                XStorable.class, xComp) ;
            /*XStorable storable = (XStorable) UnoRuntime.queryInterface(
                XStorable.class, xFrame.getController().getModel()) ; */
            PropertyValue[] propertyValue = new PropertyValue[ 3 ];
View Full Code Here

        public static void openInOpenOffice(Component parent,final String fName, XFrame xFrame) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.io.IOException {
            if (!Configuration.isUseExec()) {
                String sLoadUrl = Util.fileNameToOOoURL(fName);
                XComponentLoader loader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class,xFrame);
                XComponent xComp = loader.loadComponentFromURL(sLoadUrl, "_blank", 0, new PropertyValue[0]);
                XTextDocument aTextDocument = (XTextDocument)UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class, xComp);
            } else {
                // bad luck, we need to use direct method to run OO.org :-(
                String cmd[] = {"open", Configuration.getPathForOOoExec(parent) , fName};
                try {
                    Runtime.getRuntime().exec(cmd);
View Full Code Here

     * otherwise this document remains open
     * @return returns the created Textdocument
     */
    public XTextDocument openFromDialog(String url, String createButton,
                                        boolean destroyLocal) {
        XTextDocument xLocalDoc = WriterTools.createTextDoc(m_xMSF);
        XComponent comp = (XComponent) UnoRuntime.queryInterface(
                                  XComponent.class, xLocalDoc);
        DialogThread diagThread = new DialogThread(comp, m_xMSF, url);
        diagThread.start();
        shortWait();

        if (createButton.length() > 1) {
            XExtendedToolkit tk = getToolkit();
            AccessibilityTools at = new AccessibilityTools();
            Object atw = tk.getActiveTopWindow();

            XWindow xWindow = (XWindow) UnoRuntime.queryInterface(
                                      XWindow.class, atw);

            XAccessible xRoot = at.getAccessibleObject(xWindow);
            XAccessibleContext buttonContext = at.getAccessibleObjectForRole(
                                                       xRoot,
                                                       AccessibleRole.PUSH_BUTTON,
                                                       createButton);

            XAccessibleAction buttonAction = (XAccessibleAction) UnoRuntime.queryInterface(
                                                     XAccessibleAction.class,
                                                     buttonContext);

            try {
                System.out.println("Name: " +
                                   buttonContext.getAccessibleName());
                buttonAction.doAccessibleAction(0);
            } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
                System.out.println("Couldn't press button");
            }

            shortWait();
        }

        XDesktop xDesktop = getDesktop();

        XTextDocument returnDoc = (XTextDocument) UnoRuntime.queryInterface(
                                          XTextDocument.class,
                                          xDesktop.getCurrentComponent());

        if (destroyLocal) {
            closeDoc(xLocalDoc);
View Full Code Here

            int GroupFieldCount = getRecordParser().GroupFieldNames.length;
            int FieldCount = getRecordParser().FieldColumns.length;
            Object[] OldGroupFieldValues = new Object[GroupFieldCount];
            XTextTable[] xGroupBaseTables = new XTextTable[GroupFieldCount];
            int RecordFieldCount = FieldCount - GroupFieldCount;
            XTextDocument xTextDocument = getDoc().xTextDocument;
            XTextCursor xTextCursor = ReportTextDocument.createTextCursor(getDoc().xTextDocument.getText());
            xTextDocument.lockControllers();

            if (getRecordParser().ResultSet.next() == true)
            {
                replaceUserFields();
                Helper.setUnoPropertyValue(xTextCursor, "PageDescName", "First Page");
View Full Code Here

            PropertyValue[] loadProps = new PropertyValue[1];
            loadProps[0] = new PropertyValue();
            loadProps[0].Name = "Hidden";
            loadProps[0].Value = new Boolean(true);
            xComp = util.DesktopTools.openNewDoc(xMSF, "swriter", loadProps);
            XTextDocument xText = (XTextDocument) UnoRuntime.queryInterface(
                        XTextDocument.class, xComp);

            XRepositorySupplier xRS = (XRepositorySupplier)
                UnoRuntime.queryInterface(XRepositorySupplier.class, xComp);
            assure("xRS null", null != xRS);
            XDocumentMetadataAccess xDMA = (XDocumentMetadataAccess)
                UnoRuntime.queryInterface(XDocumentMetadataAccess.class, xRS);
            assure("xDMA null", null != xDMA);
            xRep = xRS.getRDFRepository();
            assure("xRep null", null != xRep);

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

            log.println("Checking that new repository is initialized...");

            XURI xBaseURI = (XURI) xDMA;
            String baseURI = xBaseURI.getStringValue();
            assure("new: baseURI",
                null != xBaseURI && !xBaseURI.getStringValue().equals(""));

            assure("new: # graphs", 1 == xRep.getGraphNames().length);
            XURI manifest = URI.createNS(xContext, xBaseURI.getStringValue(),
                manifestPath);
            xManifest = xRep.getGraph(manifest);
            assure("new: manifest graph", null != xManifest);

            Statement[] manifestStmts = getManifestStmts(xBaseURI);
            xStmtsEnum = xRep.getStatements(null, null, null);
            assure("new: manifest graph", eq(xStmtsEnum, manifestStmts));

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

            log.println("Checking some invalid args...");

            String content = "behold, for i am the content.";
            XTextRange xTR = new TestRange(content);
            XMetadatable xM = (XMetadatable) xTR;

            try {
                xDMA.getElementByURI(null);
                assure("getElementByURI: null allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.getMetadataGraphsWithType(null);
                assure("getMetadataGraphsWithType: null URI allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.addMetadataFile("", new XURI[0]);
                assure("addMetadataFile: empty filename allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.addMetadataFile("/foo", new XURI[0]);
                assure("addMetadataFile: absolute filename allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.addMetadataFile("fo\"o", new XURI[0]);
                assure("addMetadataFile: invalid filename allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.addMetadataFile("../foo", new XURI[0]);
                assure("addMetadataFile: filename with .. allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.addMetadataFile("foo/../../bar", new XURI[0]);
                assure("addMetadataFile: filename with nest .. allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.addMetadataFile("foo/././bar", new XURI[0]);
                assure("addMetadataFile: filename with nest . allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.addMetadataFile("content.xml", new XURI[0]);
                assure("addMetadataFile: content.xml allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.addMetadataFile("styles.xml", new XURI[0]);
                assure("addMetadataFile: styles.xml allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.addMetadataFile("meta.xml", new XURI[0]);
                assure("addMetadataFile: meta.xml allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.addMetadataFile("settings.xml", new XURI[0]);
                assure("addMetadataFile: settings.xml allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.importMetadataFile(FileFormat.RDF_XML, null, "foo",
                    foo, new XURI[0]);
                assure("importMetadataFile: null stream allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                XInputStream xFooIn =
                    new StreamSimulator(tempDir + "empty.rdf", true, param);
                xDMA.importMetadataFile(FileFormat.RDF_XML, xFooIn, "",
                    foo, new XURI[0]);
                assure("importMetadataFile: empty filename allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                XInputStream xFooIn =
                    new StreamSimulator(tempDir + "empty.rdf", true, param);
                xDMA.importMetadataFile(FileFormat.RDF_XML, xFooIn, "meta.xml",
                    foo, new XURI[0]);
                assure("importMetadataFile: meta.xml filename allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                XInputStream xFooIn =
                    new StreamSimulator(tempDir + "empty.rdf", true, param);
                xDMA.importMetadataFile(FileFormat.RDF_XML,
                    xFooIn, "foo", null, new XURI[0]);
                assure("importMetadataFile: null base URI allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                XInputStream xFooIn =
                    new StreamSimulator(tempDir + "empty.rdf", true, param);
                xDMA.importMetadataFile(FileFormat.RDF_XML,
                    xFooIn, "foo", rdf_type, new XURI[0]);
                assure("importMetadataFile: non-absolute base URI allowed",
                    false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.removeMetadataFile(null);
                assure("removeMetadataFile: null URI allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.addContentOrStylesFile("");
                assure("addContentOrStylesFile: empty filename allowed",
                    false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.addContentOrStylesFile("/content.xml");
                assure("addContentOrStylesFile: absolute filename allowed",
                    false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.addContentOrStylesFile("foo.rdf");
                assure("addContentOrStylesFile: invalid filename allowed",
                    false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.removeContentOrStylesFile("");
                assure("removeContentOrStylesFile: empty filename allowed",
                    false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.loadMetadataFromStorage(null, foo, null);
                assure("loadMetadataFromStorage: null storage allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.storeMetadataToStorage(null/*, base*/);
                assure("storeMetadataToStorage: null storage allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.loadMetadataFromMedium(new PropertyValue[0]);
                assure("loadMetadataFromMedium: empty medium allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }
            try {
                xDMA.storeMetadataToMedium(new PropertyValue[0]);
                assure("storeMetadataToMedium: empty medium allowed", false);
            } catch (IllegalArgumentException e) {
                // ignore
            }

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

            log.println("Checking file addition/removal...");

            xDMA.removeContentOrStylesFile(contentPath);
            xStmtsEnum = xManifest.getStatements(null, null, null);
            assure("removeContentOrStylesFile (content)",
                eq(xStmtsEnum, new Statement[] {
                        manifestStmts[0], manifestStmts[2], manifestStmts[4]
                    }));

            xDMA.addContentOrStylesFile(contentPath);
            xStmtsEnum = xManifest.getStatements(null, null, null);
            assure("addContentOrStylesFile (content)",
                eq(xStmtsEnum, manifestStmts));

            xDMA.removeContentOrStylesFile(stylesPath);
            xStmtsEnum = xManifest.getStatements(null, null, null);
            assure("removeContentOrStylesFile (styles)",
                eq(xStmtsEnum, new Statement[] {
                        manifestStmts[0], manifestStmts[1], manifestStmts[3]
                    }));

            xDMA.addContentOrStylesFile(stylesPath);
            xStmtsEnum = xManifest.getStatements(null, null, null);
            assure("addContentOrStylesFile (styles)",
                eq(xStmtsEnum, manifestStmts));

            XURI xFoo = URI.createNS(xContext, xBaseURI.getStringValue(),
                fooPath);
            Statement xM_BaseHaspartFoo =
                new Statement(xBaseURI, pkg_hasPart, xFoo, manifest);
            Statement xM_FooTypeMetadata =
                new Statement(xFoo, rdf_type, pkg_MetadataFile, manifest);
            Statement xM_FooTypeBar =
                new Statement(xFoo, rdf_type, bar, manifest);
            xDMA.addMetadataFile(fooPath, new XURI[] { bar });
            xStmtsEnum = xManifest.getStatements(null, null, null);
            assure("addMetadataFile",
                eq(xStmtsEnum, merge(manifestStmts, new Statement[] {
                        xM_BaseHaspartFoo, xM_FooTypeMetadata, xM_FooTypeBar
                    })));

            XURI[] graphsBar = xDMA.getMetadataGraphsWithType(bar);
            assure("getMetadataGraphsWithType",
                graphsBar.length == 1 && eq(graphsBar[0], xFoo));


            xDMA.removeMetadataFile(xFoo);
            xStmtsEnum = xManifest.getStatements(null, null, null);
            assure("removeMetadataFile",
                eq(xStmtsEnum, manifestStmts));

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

            log.println("Checking mapping...");

            XEnumerationAccess xTextEnum = (XEnumerationAccess)
                UnoRuntime.queryInterface(XEnumerationAccess.class,
                    xText.getText());
            Object o = xTextEnum.createEnumeration().nextElement();
            XMetadatable xMeta1 = (XMetadatable) UnoRuntime.queryInterface(
                        XMetadatable.class, o);

            XURI uri;
View Full Code Here

TOP

Related Classes of com.sun.star.text.XTextDocument

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.