Examples of XWordCursor


Examples of com.sun.star.text.XWordCursor

            XTextContent oTSC = (XTextContent) UnoRuntime.queryInterface(
                                        XTextContent.class, oTS);
            oText.insertTextContent(oCursor, oTSC, false);

            XWordCursor oWordC = (XWordCursor) UnoRuntime.queryInterface(
                                         XWordCursor.class, oCursor);
            oCursor.setString("End of TextSection");
            oCursor.gotoStart(false);
            oCursor.setString("Start of TextSection ");
            oWordC.gotoEndOfWord(false);

            XInterface oTS2 = (XInterface) oDocMSF.createInstance(
                                      "com.sun.star.text.TextSection");
            oTSC = (XTextContent) UnoRuntime.queryInterface(XTextContent.class,
                                                            oTS2);
View Full Code Here

Examples of com.sun.star.text.XWordCursor

                    ("com.sun.star.text.TextSection");
            instance = oDocMSF.createInstance("com.sun.star.text.TextSection");
            XTextContent oTSC = (XTextContent)
                    UnoRuntime.queryInterface(XTextContent.class, oTS);
            oText.insertTextContent(oCursor, oTSC, false);
            XWordCursor oWordC = (XWordCursor)
                UnoRuntime.queryInterface(XWordCursor.class, oCursor);
            oCursor.setString("End of TextSection");
            oCursor.gotoStart(false);
            oCursor.setString("Start of TextSection ");
            oWordC.gotoEndOfWord(false);
            XInterface oTS2 = (XInterface) oDocMSF.createInstance
                ("com.sun.star.text.TextSection");
            oTSC = (XTextContent)UnoRuntime.queryInterface(XTextContent.class, oTS2);
            oText.insertTextContent(oCursor, oTSC, false);
View Full Code Here

Examples of com.sun.star.text.XWordCursor

            XSentenceCursor xSentenceCursor = (XSentenceCursor)
                UnoRuntime.queryInterface(XSentenceCursor.class, mxDocCursor );
            // Goto the next cursor, without selecting it
            xSentenceCursor.gotoNextSentence( false );
            // Get the XWordCursor interface of our text cursor
            XWordCursor xWordCursor = (XWordCursor) UnoRuntime.queryInterface(
                XWordCursor.class, mxDocCursor );
            // Skip the first four words of this sentence and select the fifth
            xWordCursor.gotoNextWord( false );
            xWordCursor.gotoNextWord( false );
            xWordCursor.gotoNextWord( false );
            xWordCursor.gotoNextWord( false );
            xWordCursor.gotoNextWord( true );
            // Use the XSimpleText interface to insert a word at the current cursor
            // location, over-writing the current selection (the fifth word
            // selected above)
            mxDocText.insertString ( xWordCursor, "old ", true );

            // Access the property set of the cursor, and set the currently
            // selected text (which is the string we just inserted) to be bold
            XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(
                XPropertySet.class, mxDocCursor );
            xCursorProps.setPropertyValue ( "CharWeight",
                             new Float(com.sun.star.awt.FontWeight.BOLD) );

            // replace the '.' at the end of the sentence with a new string
            xSentenceCursor.gotoEndOfSentence( false );
            xWordCursor.gotoPreviousWord( true );
            mxDocText.insertString (xWordCursor,
                                    ", which has been changed with text cursors!",
                                    true);
        }
        catch ( Exception e )
View Full Code Here

Examples of com.sun.star.text.XWordCursor

        } catch (RuntimeException e) { /* expected */ }

        // XWordCursor
        xText.setString("Two words");
        xTextCursor.gotoStart(false);
        XWordCursor xWordCursor = (XWordCursor)
            UnoRuntime.queryInterface(XWordCursor.class, xTextCursor);

        bSuccess = xWordCursor.gotoNextWord(true);
        assure("gotoNextWord(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assure("gotoNextWord(): wrong string: " + string,
                    "Two ".equals(string));
        }
        bSuccess = xWordCursor.gotoNextWord(false);
        assure("gotoNextWord(): succeeded", !bSuccess);
        xTextCursor.collapseToEnd();
        bSuccess = xWordCursor.gotoPreviousWord(true);
        assure("gotoPreviousWord(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assure("gotoPreviousWord(): wrong string: " + string,
                    "words".equals(string));
        }
        bSuccess = xWordCursor.gotoPreviousWord(false);
        assure("gotoPreviousWord(): succeeded", !bSuccess);
        bSuccess = xWordCursor.gotoEndOfWord(true);
        assure("gotoEndOfWord(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assure("gotoEndOfWord(): wrong string: " + string,
                    "Two".equals(string));
        }
        xTextCursor.gotoEnd(false);
        bSuccess = xWordCursor.gotoStartOfWord(true);
        assure("gotoStartOfWord(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assure("gotoStartOfWord(): wrong string: " + string,
                    "words".equals(string));
        }
        xText.setString("");
        bSuccess = xWordCursor.gotoEndOfWord(false);
        assure("gotoEndOfWord(): succeeded", !bSuccess);
        bSuccess = xWordCursor.gotoStartOfWord(false);
        assure("gotoStartOfWord(): succeeded", !bSuccess);

        // XSentenceCursor
        xText.setString("This is a sentence. Another sentence.");
        xTextCursor.gotoStart(false);
View Full Code Here

Examples of com.sun.star.text.XWordCursor

            XTextContent oTSC = (XTextContent) UnoRuntime.queryInterface(
                                        XTextContent.class, oTS);
            oText.insertTextContent(oCursor, oTSC, false);

            XWordCursor oWordC = (XWordCursor) UnoRuntime.queryInterface(
                                         XWordCursor.class, oCursor);
            oCursor.setString("End of TextSection");
            oCursor.gotoStart(false);
            oCursor.setString("Start of TextSection ");
            oWordC.gotoEndOfWord(false);

            XInterface oTS2 = (XInterface) oDocMSF.createInstance(
                                      "com.sun.star.text.TextSection");
            oTSC = (XTextContent) UnoRuntime.queryInterface(XTextContent.class,
                                                            oTS2);
View Full Code Here

Examples of com.sun.star.text.XWordCursor

                    XSentenceCursor xSentenceCursor = (XSentenceCursor) UnoRuntime.queryInterface(
                            XSentenceCursor.class, mxDocCursor );
                    // Goto the next cursor, without selecting it
                    xSentenceCursor.gotoNextSentence( false );
                    // Get the XWordCursor interface of our text cursor
                    XWordCursor xWordCursor = (XWordCursor) UnoRuntime.queryInterface(
                        XWordCursor.class, mxDocCursor );
                    // Skip the first four words of this sentence and select the fifth
                    xWordCursor.gotoNextWord( false );
                    xWordCursor.gotoNextWord( false );
                    xWordCursor.gotoNextWord( false );
                    xWordCursor.gotoNextWord( false );
                    xWordCursor.gotoNextWord( true );
                    // Use the XSimpleText interface to insert a word at the current cursor
                    // location, over-writing
                    // the current selection (the fifth word selected above)
                    mxDocText.insertString ( xWordCursor, "old ", true );

                    // Access the property set of the cursor, and set the currently selected text
                    // (which is the string we just inserted) to be bold
                    XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(
                            XPropertySet.class, mxDocCursor );
                    xCursorProps.setPropertyValue ( "CharWeight", new Float (
                            com.sun.star.awt.FontWeight.BOLD ) );

                    // replace the '.' at the end of the sentence with a new string
                    xSentenceCursor.gotoEndOfSentence( false );
                    xWordCursor.gotoPreviousWord( true );
                    mxDocText.insertString ( xWordCursor,
                        ", which has been changed with text cursors!", true);
            }
            catch ( Exception e )
            {
View Full Code Here

Examples of com.sun.star.text.XWordCursor

    public static void createExampleData( XText xText ) {
       
        try {
            xText.setString( "This is an example sentence" );
           
            XWordCursor xWordCursor = (XWordCursor) UnoRuntime.queryInterface(
                XWordCursor.class, xText.getStart() );
           
            xWordCursor.gotoNextWord(false);
            xWordCursor.gotoNextWord(false);
            xWordCursor.gotoEndOfWord(true);
           
            XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(
                XPropertySet.class, xWordCursor );
            xPropertySet.setPropertyValue("CharWeight", new Float( com.sun.star.awt.FontWeight.BOLD ) );
           
View Full Code Here

Examples of com.sun.star.text.XWordCursor

            XTextContent oTSC = (XTextContent) UnoRuntime.queryInterface(
                                        XTextContent.class, oTS);
            oText.insertTextContent(oCursor, oTSC, false);

            XWordCursor oWordC = (XWordCursor) UnoRuntime.queryInterface(
                                         XWordCursor.class, oCursor);
            oCursor.setString("End of TextSection");
            oCursor.gotoStart(false);
            oCursor.setString("Start of TextSection ");
            oWordC.gotoEndOfWord(false);

            XInterface oTS2 = (XInterface) oDocMSF.createInstance(
                                      "com.sun.star.text.TextSection");
            oTSC = (XTextContent) UnoRuntime.queryInterface(XTextContent.class,
                                                            oTS2);
View Full Code Here

Examples of com.sun.star.text.XWordCursor

                    ("com.sun.star.text.TextSection");
            instance = oDocMSF.createInstance("com.sun.star.text.TextSection");
            XTextContent oTSC = (XTextContent)
                    UnoRuntime.queryInterface(XTextContent.class, oTS);
            oText.insertTextContent(oCursor, oTSC, false);
            XWordCursor oWordC = (XWordCursor)
                UnoRuntime.queryInterface(XWordCursor.class, oCursor);
            oCursor.setString("End of TextSection");
            oCursor.gotoStart(false);
            oCursor.setString("Start of TextSection ");
            oWordC.gotoEndOfWord(false);
            XInterface oTS2 = (XInterface) oDocMSF.createInstance
                ("com.sun.star.text.TextSection");
            oTSC = (XTextContent)UnoRuntime.queryInterface(XTextContent.class, oTS2);
            oText.insertTextContent(oCursor, oTSC, false);
View Full Code Here

Examples of com.sun.star.text.XWordCursor

        } catch (RuntimeException e) { /* expected */ }

        // XWordCursor
        xText.setString("Two words");
        xTextCursor.gotoStart(false);
        XWordCursor xWordCursor = (XWordCursor)
            UnoRuntime.queryInterface(XWordCursor.class, xTextCursor);

        bSuccess = xWordCursor.gotoNextWord(true);
        assertTrue("gotoNextWord(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assertEquals("gotoNextWord(): wrong string",
                         "Two ", string);
        }
        bSuccess = xWordCursor.gotoNextWord(false);
        assertFalse("gotoNextWord(): succeeded", bSuccess);
        xTextCursor.collapseToEnd();
        bSuccess = xWordCursor.gotoPreviousWord(true);
        assertTrue("gotoPreviousWord(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assertEquals("gotoPreviousWord(): wrong string",
                         "words", string);
        }
        bSuccess = xWordCursor.gotoPreviousWord(false);
        assertFalse("gotoPreviousWord(): succeeded", bSuccess);
        bSuccess = xWordCursor.gotoEndOfWord(true);
        assertTrue("gotoEndOfWord(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assertEquals("gotoEndOfWord(): wrong string",
                         "Two", string);
        }
        xTextCursor.gotoEnd(false);
        bSuccess = xWordCursor.gotoStartOfWord(true);
        assertTrue("gotoStartOfWord(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assertEquals("gotoStartOfWord(): wrong string",
                         "words", string);
        }
        xText.setString("");
        bSuccess = xWordCursor.gotoEndOfWord(false);
        assertFalse("gotoEndOfWord(): succeeded", bSuccess);
        bSuccess = xWordCursor.gotoStartOfWord(false);
        assertFalse("gotoStartOfWord(): succeeded", bSuccess);

        // XSentenceCursor
        xText.setString("This is a sentence. Another sentence.");
        xTextCursor.gotoStart(false);
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.