Access to Text Content

From Apache OpenOffice Wiki
< Documentation‎ | DevGuide
Revision as of 12:31, 1 November 2007 by Jsc (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The service supports the modification of simple or formatted text contents. Changing text contents and text formatting is provided by the interface as discussed in First Steps. Refer to chapter Editing Text for further information. It implements the interfaces that provides access to the paragraphs of the text and the interface to insert and modify text contents. For detailed information about text handling, see Editing Text.

 // --- Insert two text paragraphs into the cell. --- xText = (
     UnoRuntime.queryInterface(, xCell); xTextCursor = xText.createTextCursor();
 xText.insertString(xTextCursor, "Text in first line.", false);
 xText.insertControlCharacter(xTextCursor,, false);
 xText.insertString(xTextCursor, "Some more text.", false);
 // --- Query the separate paragraphs. ---
 String aText; xParaEA =
     ( UnoRuntime.queryInterface(, xCell); xParaEnum = xParaEA.createEnumeration();
 // Go through the paragraphs
 while (xParaEnum.hasMoreElements()) {
     Object aPortionObj = xParaEnum.nextElement(); xPortionEA =
         ( UnoRuntime.queryInterface(
   , aPortionObj); xPortionEnum = xPortionEA.createEnumeration();
     aText = "";
     // Go through all text portions of a paragraph and construct string.
     while (xPortionEnum.hasMoreElements()) { xRange =
             ( xPortionEnum.nextElement();
         aText += xRange.getString();
     System.out.println("Paragraph text: " + aText);

The SheetCell interface contains methods that provide access to the collection of text fields in the cell. For details on inserting text fields, refer to Text Fields.


Content on this page is licensed under the Public Documentation License (PDL).
Personal tools