Package com.sun.star.text

Examples of com.sun.star.text.XSentenceCursor


    protected void TextCursorExample ()
    {
        try
        {
            // First, get the XSentenceCursor interface of our text cursor
            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);
        }
View Full Code Here


        assure("gotoStartOfWord(): succeeded", !bSuccess);

        // XSentenceCursor
        xText.setString("This is a sentence. Another sentence.");
        xTextCursor.gotoStart(false);
        XSentenceCursor xSentenceCursor = (XSentenceCursor)
            UnoRuntime.queryInterface(XSentenceCursor.class, xTextCursor);

        bSuccess = xSentenceCursor.gotoNextSentence(true);
        assure("gotoNextSentence(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assure("gotoNextSentence(): wrong string: " + string,
                    "This is a sentence. ".equals(string));
        }
        bSuccess = xSentenceCursor.gotoNextSentence(false);
        assure("gotoNextSentence(): succeeded", !bSuccess);
        // FIXME:
        // the sentence cursor seems to work differently than the word cursor
        xText.setString("This is a sentence. Another sentence. Sentence 3.");
        xTextCursor.gotoEnd(false);
        bSuccess = xSentenceCursor.gotoPreviousSentence(true);
        assure("gotoPreviousSentence(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assure("gotoPreviousSentence(): wrong string: " + string,
                    "Another sentence. Sentence 3.".equals(string));
        }
        bSuccess = xSentenceCursor.gotoPreviousSentence(false);
        assure("gotoPreviousSentence(): succeeded", !bSuccess);
        bSuccess = xSentenceCursor.gotoEndOfSentence(true);
        assure("gotoEndOfSentence(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assure("gotoEndOfSentence(): wrong string: " + string,
                    "This is a sentence.".equals(string));
        }
        xTextCursor.gotoEnd(false);
        bSuccess = xSentenceCursor.gotoStartOfSentence(true);
        assure("gotoStartOfSentence(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assure("gotoStartOfSentence(): wrong string: " + string,
                    "Sentence 3.".equals(string));
        }
        xText.setString("");
        bSuccess = xSentenceCursor.gotoEndOfSentence(false);
        assure("gotoEndOfSentence(): succeeded", !bSuccess);
        bSuccess = xSentenceCursor.gotoStartOfSentence(false);
        assure("gotoStartOfSentence(): succeeded", !bSuccess);

        XParagraphCursor xParagraphCursor = (XParagraphCursor)
            UnoRuntime.queryInterface(XParagraphCursor.class, xTextCursor);
View Full Code Here

    protected void TextCursorExample ()
    {
            try
            {
                    // First, get the XSentenceCursor interface of our text cursor
                    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

        assertFalse("gotoStartOfWord(): succeeded", bSuccess);

        // XSentenceCursor
        xText.setString("This is a sentence. Another sentence.");
        xTextCursor.gotoStart(false);
        XSentenceCursor xSentenceCursor = (XSentenceCursor)
            UnoRuntime.queryInterface(XSentenceCursor.class, xTextCursor);

        bSuccess = xSentenceCursor.gotoNextSentence(true);
        assertTrue("gotoNextSentence(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assertEquals("gotoNextSentence(): wrong string",
                         "This is a sentence. ", string);
        }
        bSuccess = xSentenceCursor.gotoNextSentence(false);
        assertFalse("gotoNextSentence(): succeeded", bSuccess);
        // FIXME:
        // the sentence cursor seems to work differently than the word cursor
        xText.setString("This is a sentence. Another sentence. Sentence 3.");
        xTextCursor.gotoEnd(false);
        bSuccess = xSentenceCursor.gotoPreviousSentence(true);
        assertTrue("gotoPreviousSentence(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assertEquals("gotoPreviousSentence(): wrong string",
                         "Another sentence. Sentence 3.", string);
        }
        bSuccess = xSentenceCursor.gotoPreviousSentence(false);
        assertFalse("gotoPreviousSentence(): succeeded", bSuccess);
        bSuccess = xSentenceCursor.gotoEndOfSentence(true);
        assertTrue("gotoEndOfSentence(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assertEquals("gotoEndOfSentence(): wrong string",
                         "This is a sentence.", string);
        }
        xTextCursor.gotoEnd(false);
        bSuccess = xSentenceCursor.gotoStartOfSentence(true);
        assertTrue("gotoStartOfSentence(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assertEquals("gotoStartOfSentence(): wrong string",
                         "Sentence 3.", string);
        }
        xText.setString("");
        bSuccess = xSentenceCursor.gotoEndOfSentence(false);
        assertFalse("gotoEndOfSentence(): succeeded", bSuccess);
        bSuccess = xSentenceCursor.gotoStartOfSentence(false);
        assertFalse("gotoStartOfSentence(): succeeded", bSuccess);

        XParagraphCursor xParagraphCursor = (XParagraphCursor)
            UnoRuntime.queryInterface(XParagraphCursor.class, xTextCursor);
View Full Code Here

    protected void TextCursorExample ()
    {
        try
        {
            // First, get the XSentenceCursor interface of our text cursor
            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);
        }
View Full Code Here

    protected void TextCursorExample ()
    {
        try
        {
            // First, get the XSentenceCursor interface of our text cursor
            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);
        }
View Full Code Here

        assure("gotoStartOfWord(): succeeded", !bSuccess);

        // XSentenceCursor
        xText.setString("This is a sentence. Another sentence.");
        xTextCursor.gotoStart(false);
        XSentenceCursor xSentenceCursor = (XSentenceCursor)
            UnoRuntime.queryInterface(XSentenceCursor.class, xTextCursor);

        bSuccess = xSentenceCursor.gotoNextSentence(true);
        assure("gotoNextSentence(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assure("gotoNextSentence(): wrong string: " + string,
                    "This is a sentence. ".equals(string));
        }
        bSuccess = xSentenceCursor.gotoNextSentence(false);
        assure("gotoNextSentence(): succeeded", !bSuccess);
        // FIXME:
        // the sentence cursor seems to work differently than the word cursor
        xText.setString("This is a sentence. Another sentence. Sentence 3.");
        xTextCursor.gotoEnd(false);
        bSuccess = xSentenceCursor.gotoPreviousSentence(true);
        assure("gotoPreviousSentence(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assure("gotoPreviousSentence(): wrong string: " + string,
                    "Another sentence. Sentence 3.".equals(string));
        }
        bSuccess = xSentenceCursor.gotoPreviousSentence(false);
        assure("gotoPreviousSentence(): succeeded", !bSuccess);
        bSuccess = xSentenceCursor.gotoEndOfSentence(true);
        assure("gotoEndOfSentence(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assure("gotoEndOfSentence(): wrong string: " + string,
                    "This is a sentence.".equals(string));
        }
        xTextCursor.gotoEnd(false);
        bSuccess = xSentenceCursor.gotoStartOfSentence(true);
        assure("gotoStartOfSentence(): failed", bSuccess);
        {
            String string = xTextCursor.getString();
            assure("gotoStartOfSentence(): wrong string: " + string,
                    "Sentence 3.".equals(string));
        }
        xText.setString("");
        bSuccess = xSentenceCursor.gotoEndOfSentence(false);
        assure("gotoEndOfSentence(): succeeded", !bSuccess);
        bSuccess = xSentenceCursor.gotoStartOfSentence(false);
        assure("gotoStartOfSentence(): succeeded", !bSuccess);

        XParagraphCursor xParagraphCursor = (XParagraphCursor)
            UnoRuntime.queryInterface(XParagraphCursor.class, xTextCursor);
View Full Code Here

    protected void TextCursorExample ()
    {
            try
            {
                    // First, get the XSentenceCursor interface of our text cursor
                    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

   * @date 13.12.2006
   */
  public boolean supportsSentenceCursor() {
    if (this.xSentenceCursor != null)
      return true;
    XSentenceCursor xSentenceCursor = (XSentenceCursor) UnoRuntime
        .queryInterface(XSentenceCursor.class, xTextCursor);
    if (xSentenceCursor != null) {
      this.xSentenceCursor = xSentenceCursor;
      return true;
    }
View Full Code Here

   * @date 13.12.2006
   */
  public boolean supportsSentenceCursor() {
    if(this.xSentenceCursor != null)
      return true;
    XSentenceCursor xSentenceCursor = (XSentenceCursor)UnoRuntime.queryInterface(XSentenceCursor.class, xTextCursor);
    if(xSentenceCursor != null) {
      this.xSentenceCursor = xSentenceCursor;
      return true;
    }
    return false;
View Full Code Here

TOP

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

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.