Examples of XTextCursor


Examples of com.sun.star.text.XTextCursor

            log.println("creating a textdocument");
            xTextDoc = WriterTools.createTextDoc(
                               (XMultiServiceFactory) Param.getMSF());

            XText oText = xTextDoc.getText();
            XTextCursor oCursor = oText.createTextCursor();

            log.println("inserting some lines");

            try {
                for (int i = 0; i < 5; i++) {
                    oText.insertString(oCursor, "Paragraph Number: " + i,
                                       false);
                    oText.insertString(oCursor,
                                       " The quick brown fox jumps over the lazy Dog: SwXParagraph",
                                       false);
                    oText.insertControlCharacter(oCursor,
                                                 ControlCharacter.PARAGRAPH_BREAK,
                                                 false);
                    oText.insertString(oCursor,
                                       "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph",
                                       false);
                    oText.insertControlCharacter(oCursor,
                                                 ControlCharacter.PARAGRAPH_BREAK,
                                                 false);
                    oText.insertControlCharacter(oCursor,
                                                 ControlCharacter.LINE_BREAK,
                                                 false);
                }
                            for (int i = 0; i < 11; i++) {
                oText.insertString(oCursor, "xTextDoc ", false);
                           
            }
            } catch (com.sun.star.lang.IllegalArgumentException e) {
                e.printStackTrace(log);
                throw new StatusException("Couldn't insert lines", e);
            }

            //insert two sections parent and child           
            XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(
                                                   XMultiServiceFactory.class,
                                                   xTextDoc);

            XInterface oTS;
            XTextSection xTS;

            XTextSectionsSupplier oTSSupp = (XTextSectionsSupplier) UnoRuntime.queryInterface(
                                                    XTextSectionsSupplier.class,
                                                    xTextDoc);
            XNameAccess oTSSuppName = oTSSupp.getTextSections();

            oTS = (XInterface) 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);

            XIndexAccess oTSSuppIndex = (XIndexAccess) UnoRuntime.queryInterface(
                                                XIndexAccess.class,
                                                oTSSuppName);
            log.println(
                    "getting a TextSection with the XTextSectionSupplier()");
            xTS = (XTextSection) UnoRuntime.queryInterface(XTextSection.class,
                                                           oTSSuppIndex.getByIndex(0));

            XNamed xTSName = (XNamed) UnoRuntime.queryInterface(XNamed.class,
                                                                xTS);
            xTSName.setName("SwXTextSection");

            log.println("    adding TextTable");
            the_table = SOfficeFactory.createTextTable(xTextDoc, 6, 4);

            XNamed the_name = (XNamed) UnoRuntime.queryInterface(XNamed.class,
                                                                 the_table);
            the_name.setName("SwXTextDocument");
            SOfficeFactory.insertTextContent(xTextDoc,
                                             (XTextContent) the_table);

            log.println("    adding ReferenceMark");

            XInterface aMark = (XInterface) oDocMSF.createInstance(
                                       "com.sun.star.text.ReferenceMark");
            the_name = (XNamed) UnoRuntime.queryInterface(XNamed.class, aMark);
            the_name.setName("SwXTextDocument");

            XTextContent oTC = (XTextContent) UnoRuntime.queryInterface(
                                       XTextContent.class, aMark);
            SOfficeFactory.insertTextContent(xTextDoc, (XTextContent) oTC);

            log.println("    adding TextGraphic");
            WriterTools.insertTextGraphic(xTextDoc, oDocMSF, 5200, 4200, 4400,
                                          4000, "space-metal.jpg",
                                          "SwXTextDocument");

            log.println("    adding EndNote");

            XInterface aEndNote = (XInterface) oDocMSF.createInstance(
                                          "com.sun.star.text.Endnote");
            oTC = (XTextContent) UnoRuntime.queryInterface(XTextContent.class,
                                                           aEndNote);
            SOfficeFactory.insertTextContent(xTextDoc, (XTextContent) oTC);

            log.println("    adding Bookmark");
            SOfficeFactory.insertTextContent(xTextDoc,
                                             (XTextContent) SOfficeFactory.createBookmark(
                                                     xTextDoc));

            log.println("    adding DocumentIndex");
            oTC = SOfficeFactory.createIndex(xTextDoc,
                                             "com.sun.star.text.DocumentIndex");
            SOfficeFactory.insertTextContent(xTextDoc, (XTextContent) oTC);

            log.println("    adding TextFrame");

            XTextFrame frame = SOfficeFactory.createTextFrame(xTextDoc, 500,
                                                              500);
            oTC = (XTextContent) UnoRuntime.queryInterface(XTextContent.class,
                                                           frame);
            SOfficeFactory.insertTextContent(xTextDoc, (XTextContent) oTC);

            log.println("creating a second textdocument");
            xSecondTextDoc = WriterTools.createTextDoc(
                                     (XMultiServiceFactory) Param.getMSF());
        } catch (com.sun.star.uno.Exception e) {
            // Some exception occures.FAILED
            e.printStackTrace(log);
            throw new StatusException("Couldn't create document", e);
        }

        if (xTextDoc != null) {
            log.println("Creating instance...");

            XText oText = xTextDoc.getText();
            XTextCursor oTextCursor = oText.createTextCursor();

            for (int i = 0; i < 11; i++) {
                oText.insertString(oTextCursor, "xTextDoc ", false);
            }
View Full Code Here

Examples of com.sun.star.text.XTextCursor

        // get the bodytext of textdocument here
        log.println("getting the TextCursor");

        final XSimpleText aText = xTextDoc.getText();
        final XTextCursor textCursor = aText.createTextCursor();
        oObj = textCursor;

        log.println("inserting some text");

        try {
            for (int i = 0; i < 3; i++) {
                aText.insertString(textCursor, "" + (3 - i), false);

                for (int j = 0; j < 5; j++) {
                    aText.insertString(textCursor, "XTextCursor,XTextCursor",
                                       false);
                    aText.insertString(textCursor, "The quick brown fox ",
                                       false);
                    aText.insertString(textCursor, "jumps over the lazy dog ",
                                       false);
                }

                aText.insertControlCharacter(textCursor,
                                             ControlCharacter.PARAGRAPH_BREAK,
                                             false);
                aText.insertControlCharacter(textCursor,
                                             ControlCharacter.LINE_BREAK,
                                             false);
            }
        } catch (com.sun.star.lang.IllegalArgumentException e) {
            log.println("Error, insert text to text document.");
            e.printStackTrace(log);
        }

        log.println("creating a new environment for SwXTextCursor object");

        TestEnvironment tEnv = new TestEnvironment(oObj);

        tEnv.addObjRelation("XTEXT", xTextDoc.getText());

        XPropertySet xCursorProp = (XPropertySet) UnoRuntime.queryInterface(
                                           XPropertySet.class, oObj);
        tEnv.addObjRelation("PropertyNames", getPropertyNames(xCursorProp));

        //Adding relation for util.XSortable
        final XParagraphCursor paragrCursor = (XParagraphCursor) UnoRuntime.queryInterface(
                                                      XParagraphCursor.class,
                                                      oObj);
        final PrintWriter finalLog = log;

        tEnv.addObjRelation("SORTCHECKER",
                            new ifc.util._XSortable.XSortChecker() {
            PrintWriter out = finalLog;

            public void setPrintWriter(PrintWriter log) {
                out = log;
            }

            public void prepareToSort() {
                textCursor.gotoEnd(false);

                try {
                    aText.insertControlCharacter(textCursor,
                                                 ControlCharacter.PARAGRAPH_BREAK,
                                                 false);
                    aText.insertString(textCursor, "4", false);
                    aText.insertControlCharacter(textCursor,
                                                 ControlCharacter.PARAGRAPH_BREAK,
                                                 false);
                    aText.insertString(textCursor, "b", false);
                    aText.insertControlCharacter(textCursor,
                                                 ControlCharacter.PARAGRAPH_BREAK,
                                                 false);
                    aText.insertString(textCursor, "3", false);
                    aText.insertControlCharacter(textCursor,
                                                 ControlCharacter.PARAGRAPH_BREAK,
                                                 false);
                    aText.insertString(textCursor, "a", false);
                    aText.insertControlCharacter(textCursor,
                                                 ControlCharacter.PARAGRAPH_BREAK,
                                                 false);
                    aText.insertString(textCursor, "23", false);
                    aText.insertControlCharacter(textCursor,
                                                 ControlCharacter.PARAGRAPH_BREAK,
                                                 false);
                    aText.insertString(textCursor, "ab", false);
                    aText.insertControlCharacter(textCursor,
                                                 ControlCharacter.PARAGRAPH_BREAK,
                                                 false);
                } catch (com.sun.star.lang.IllegalArgumentException e) {
                    out.println("Unexpected exception:" + e);
                }

                out.println(
                        "Preparing cursor to sorting. Text before sorting:");
                paragrCursor.gotoEnd(true);

                for (int i = 0; i < 6; i++) {
                    paragrCursor.gotoPreviousParagraph(true);
                }

                out.println(textCursor.getString());
            }

            public boolean checkSort(boolean isSortNumbering,
                                     boolean isSortAscending) {
                out.println("Sort checking...");
View Full Code Here

Examples of com.sun.star.text.XTextCursor

        // 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();

        XTextTable table = (XTextTable)UnoRuntime.queryInterface( XTextTable.class,
            m_document.createInstance( "com.sun.star.text.TextTable" )
        );
        table.initialize( 1, 1 );
View Full Code Here

Examples of com.sun.star.text.XTextCursor

    }

    public void selectFirstPage(TextTableHandler oTextTableHandler) {
        try {
            XPageCursor xPageCursor = (XPageCursor) UnoRuntime.queryInterface(XPageCursor.class, xTextViewCursorSupplier.getViewCursor());
            XTextCursor xViewTextCursor = (XTextCursor) UnoRuntime.queryInterface(XTextCursor.class, xPageCursor);
            xPageCursor.jumpToFirstPage();
            xPageCursor.jumpToStartOfPage();
            Helper.setUnoPropertyValue(xPageCursor, "PageDescName", "First Page");
            Object oPageStyles = xStyleFamiliesSupplier.getStyleFamilies().getByName("PageStyles");
            XNameAccess xName = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oPageStyles);
            Object oPageStyle = xName.getByName("First Page");
            XIndexAccess xAllTextTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, oTextTableHandler.xTextTablesSupplier.getTextTables());
            XTextContent xTextTable = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, xAllTextTables.getByIndex(0));
            XTextRange xRange = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, xTextTable.getAnchor().getText());
            xViewTextCursor.gotoRange(xRange, false);
//            if (xPageCursor.getPage() == (short) 1) {
//                Helper.setUnoPropertyValue(xTextTable, "PageDescName", "First Page");
//                TextTableHandler.resetBreakTypeofTextTable(xTextTable);
//            }
            //      }
            XTextRange xHeaderRange = (XTextRange) Helper.getUnoPropertyValue(oPageStyle, "HeaderText", XTextRange.class);
            if (!com.sun.star.uno.AnyConverter.isVoid(xHeaderRange)) {
                xViewTextCursor.gotoRange(xHeaderRange, false);
                xViewTextCursor.collapseToStart();
            } else
                System.out.println("No Headertext available");

        } catch (com.sun.star.uno.Exception exception) {
            exception.printStackTrace(System.out);
View Full Code Here

Examples of com.sun.star.text.XTextCursor

            TestParameters tParam, PrintWriter log ) throws StatusException {
        XInterface oObj = null;

        log.println( "creating a test environment" );
        XText oText = xTextDoc.getText();
        XTextCursor oCursor = oText.createTextCursor();

        for (int i=0; i<3; i++) {
            try {
                oText.insertString( oCursor, "Paragraph Number: " + i, false);
                oText.insertControlCharacter( oCursor,
View Full Code Here

Examples of com.sun.star.text.XTextCursor

            e.printStackTrace(log);
            throw new StatusException("Couldn't create footnote", e);
        }

        XText oText = xTextDoc.getText();
        XTextCursor oCursor = oText.createTextCursor();

        log.println("inserting the footnote into text document");
        try {
            oText.insertTextContent(oCursor, oFootnote, false);
        } catch (com.sun.star.lang.IllegalArgumentException e) {
View Full Code Here

Examples of com.sun.star.text.XTextCursor

        Object FieldMaster = null;
        XPropertySet PFieldMaster = null;
        XDependentTextField xTF = null;
        XEnumerationAccess xFEA = null;
        XText the_Text;
        XTextCursor the_Cursor;
        XTextContent the_Field;

        log.println( "creating a test environment" );
        XMultiServiceFactory oDocMSF = (XMultiServiceFactory)
            UnoRuntime.queryInterface( XMultiServiceFactory.class, xTextDoc );
View Full Code Here

Examples of com.sun.star.text.XTextCursor

        }
        XNamed oObjN = (XNamed) UnoRuntime.queryInterface(XNamed.class, oObj);
        oObjN.setName(Name);
        XTextContent oObjTC = (XTextContent)
            UnoRuntime.queryInterface(XTextContent.class, oObj);
        XTextCursor oCursor = oText.createTextCursor();
        try {
            oText.insertTextContent(oCursor, oObjTC, false);
        } catch ( com.sun.star.lang.IllegalArgumentException e ){
            e.printStackTrace( log );
            throw new StatusException(" Couldn't insert ReferenceMark01", e);
View Full Code Here

Examples of com.sun.star.text.XTextCursor

   
    private void fillWriterDocWithContent(XTextDocument xTextDoc){
        try{
            log.println( "inserting some lines" );
            XText oText = xTextDoc.getText();
            XTextCursor oCursor = oText.createTextCursor();
            for (int i=0; i<5; i++){
                oText.insertString( oCursor,"Paragraph Number: " + i, false);
                oText.insertString( oCursor,
                " The quick brown fox jumps over the lazy Dog: SwXParagraph",
                false);
View Full Code Here

Examples of com.sun.star.text.XTextCursor

        TestParameters Param, PrintWriter log) {

        XInterface oObj = null;

        XText oText = xTextDoc.getText();
        XTextCursor oCursor = oText.createTextCursor();

        log.println( "inserting some lines" );
        try {
            for (int i=0; i<5; i++){
                oText.insertString( oCursor,"Paragraph Number: " + i, 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.