Package ag.ion.bion.officelayer.text

Examples of ag.ion.bion.officelayer.text.ITextDocument


    try {
      IOfficeApplication officeAplication = OfficeApplicationRuntime.getApplication(configuration);
      officeAplication.activate();
      IDocumentService documentService = officeAplication.getDocumentService();
      IDocument document = documentService.constructNewDocument(IDocument.WRITER, DocumentDescriptor.DEFAULT);
      ITextDocument textDocument = (ITextDocument)document;
      textDocument.addCloseListener(new SnippetDocumentCloseListener(officeAplication));

      /*
       * Now do the work with text content.
       */
      placeSomeTextContent(textDocument);
 
View Full Code Here


     
      // we expect a file, beeing placed in the user home directory, otherwise use another url
      String url = System.getProperty("user.home") +System.getProperty("file.separator")+ DOCUMENT_NAME;
      IDocument document = documentService.loadDocument(url);
     
      ITextDocument textDocument = (ITextDocument)document;
      textDocument.addCloseListener(new SnippetDocumentCloseListener(officeAplication));

    }
    catch (OfficeApplicationException exception) {
      exception.printStackTrace();
    }
View Full Code Here

      IOfficeApplication officeAplication = OfficeApplicationRuntime.getApplication(configuration)
      officeAplication.setConfiguration(configuration);
      officeAplication.activate();
      IDocumentService documentService = officeAplication.getDocumentService();
      IDocument document = documentService.constructNewDocument(IDocument.WRITER, DocumentDescriptor.DEFAULT);
      ITextDocument textDocument = (ITextDocument)document;
      //First some text ...
      textDocument.getTextService().getText().setText("This is a text content for a search example with NOA.");
     
      //OK - now we need a search query
      SearchDescriptor searchDescriptor = new SearchDescriptor("NOA");
      searchDescriptor.setIsCaseSensitive(true);
      //Perform the search ...
      ISearchResult searchResult = textDocument.getSearchService().findFirst(searchDescriptor);
      if(!searchResult.isEmpty()) {
        //...and now select the result
        ITextRange[] textRanges = searchResult.getTextRanges();
        textDocument.setSelection(new TextRangeSelection(textRanges[0]));
      }
    }
    catch (OfficeApplicationException exception) {
      exception.printStackTrace();
    }
View Full Code Here

    try {
      IOfficeApplication officeAplication = OfficeApplicationRuntime.getApplication(configuration);
      officeAplication.activate();
      IDocumentService documentService = officeAplication.getDocumentService();
      IDocument document = documentService.constructNewDocument(IDocument.WRITER, DocumentDescriptor.DEFAULT);
      ITextDocument textDocument = (ITextDocument)document;
      textDocument.addCloseListener(new SnippetDocumentCloseListener(officeAplication));
     
      /*
       * This stuff was already discussed in Snippet2 but now lets begin to
       * work with tables in text documents
       */
 
View Full Code Here

      if(rows.length > 0) {
        ITextTableCell[] cells = rows[rows.length - 1].getCells();
        String lastCellName = cells[cells.length - 1].getName().getName();       
        range = range + TextTableCellNameHelper.getColumnCharacter(lastCellName) + TextTableCellNameHelper.getRowCounterValue(lastCellName);
        ITextTableCellRange cellRange = getCellRange(range);
        ITextDocument textDocument = getTextDocument();
        if(textDocument.isOpen()) {
          XCell cell = getXTextTable().getCellByName(firstCell);
          XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, cell);
          if(xPropertySet != null) {
            Object value = xPropertySet.getPropertyValue("TextSection");
            boolean select = true;
            XTextSection xTextSection = (XTextSection)UnoRuntime.queryInterface(XTextSection.class, value);
            if(xTextSection != null) {
              XPropertySet xTextSectionPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextSection);
              if(xTextSectionPropertySet != null) {
                Boolean visible = (Boolean)xTextSectionPropertySet.getPropertyValue("IsVisible");
                select = visible.booleanValue();
              }
            }
            if(select)
              textDocument.setSelection(new XInterfaceObjectSelection(cellRange.getXCellRange()));
          }
        }
      }
    }
    catch(Throwable throwable) {
View Full Code Here

    try {
      ITextRange range = null;
      if (position.getType() != null && ITextRange.class.isAssignableFrom(position.getType())) {
        range = (ITextRange)position.getDestinationObject();
      }
      ITextDocument textDocument = textTable.getTextDocument();
      ITextContentService textContentService = textDocument.getTextService().getTextContentService();
      ITextTable newTable = textDocument.getTextTableService().constructTextTable(tablePropertyStore.getRows(), tablePropertyStore.getColumns());
           
      if (range != null) {
        textContentService.insertTextContent(range,newTable);
      }
      else {
View Full Code Here

*/
public class ETextTableTest extends TestCase {

  public void testETextTable() {
    IOfficeApplication officeApplication = OfficeApplicationRuntime.getLocalOfficeApplication();
    ITextDocument docu = null;
    try {
 
      LocalOfficeApplicationConfiguration localOfficeApplicationConfiguration = new LocalOfficeApplicationConfiguration();
      localOfficeApplicationConfiguration.setPort("8101");
      localOfficeApplicationConfiguration.setApplicationHomePath("d:\\Programme\\OpenOffice.org1.1.3");
      officeApplication.setConfiguration(localOfficeApplicationConfiguration);
      officeApplication.activate();
      docu = (ITextDocument)officeApplication.getDocumentService().loadDocument("file:///d:/java/eclipse/workspace/officeapi/test/testETables.sxw");
     
      ITextTable table = docu.getTextTableService().getTextTables()[0];
      ETextTable textTable = new ETextTable(docu,table);
     
      textTable.addRows(200); //o.k.
     
      textTable.getCell(10,1).setCellFormula("<A100>+<B3>");
      textTable.getCell(10,2).setCellFormula("<A100:A200>+<B3:B7>");
//      textTable.addRows(1,10);  // o.k.
//      textTable.addRows(100,10); //o.k.
////      textTable.addRows(1,82); // o.k.
////      textTable.addRows(1,83); // o.k.
////       
////      textTable.addRows(100,82); // o.k.
////       
//      textTable.addRows(1,220); // o.k.
//      textTable.addRows(100,220); // o.k.
       
//        IETextTableCellRange tableCellRange = textTable.getCellRange(0,100,5,110);
//        Object[][] objects = tableCellRange.getData();
//        for(int i = 0; i < objects.length; i++) {
//          for(int j = 0; j < objects[i].length; j++) {
//            objects[i][j] = i + "/" + j;
//          }
//        }
//        tableCellRange.setData(objects);
//        System.out.println(textTable.getColumn(0).getCellRange().getRangeName().getRangeName());
//        System.out.println(textTable.getColumn(0).getCellRange().getCells()[0].getName().getName());;
//        System.out.println(textTable.getRow(7).getCellRange().getRangeName().getRangeName());
//        System.out.println(textTable.getRows()[7].getCellRange().getRangeName().getRangeName());
//        System.out.println(textTable.getCellRange(0,30,5,50).getRangeName().getRangeName());
//       
//        System.out.println(textTable.getColumn(0).getCellRange().getRangeName().getRangeName());
       
//        System.out.println(textTable.getCellRange(0,30,5,150).getRangeName().getRangeName());
//        System.out.println(textTable.getCellRange(0,0,textTable.getColumnCount()-1,textTable.getRowCount()-1).getRangeName().getRangeName());
//        System.out.println(textTable.getColumn(0).getCellRange().getCell(0,200,textTable.getColumnCount()).getName().getName());
//        System.out.println(textTable.getColumn(0).getCellRange().getCell(0,125,textTable.getColumnCount()).getTableCell().getTextService().getText().getText());
//       
//        ITextTable[] textTables = textTable.getTextTableManagement().getTextTables();
//        for(int i = 0; i < textTables.length; i++) {
//          System.out.println(textTables[i].getName());
//        }
        docu.close();
      }
      catch (Exception excep) {
        try {
          docu.close();
          officeApplication.deactivate();
        }
        catch(Exception e) {
          fail();
        }
View Full Code Here

      LocalOfficeApplicationConfiguration configuration = new LocalOfficeApplicationConfiguration();
      configuration.setApplicationHomePath("c:\\Programme\\OpenOffice.org1.1.3");
      localOfficeApplication.setConfiguration(configuration);
      localOfficeApplication.activate();
     
      ITextDocument textDocument = (ITextDocument)localOfficeApplication.getDocumentService().constructNewDocument(IDocument.WRITER, new DocumentDescriptor());
      IPageService pageService = textDocument.getPageService();
      IPage page = pageService.getPage(0);
      IPageStyle pageStyle = page.getPageStyle();
      IPageStyleProperties pageStyleProperties = pageStyle.getProperties();
      boolean value = pageStyleProperties.getIsLandscape();
      Assert.assertEquals(false, value);
     
      ITextTable textTable = textDocument.getTextTableService().constructTextTable(5, 15);
      textDocument.getTextService().getTextContentService().insertTextContent(textTable);
      page = pageService.getPage(0);
      pageStyle = page.getPageStyle();
      pageStyleProperties = pageStyle.getProperties();
      value = pageStyleProperties.getIsLandscape();
      Assert.assertEquals(false, value);
View Full Code Here

     
      IDocument document = localOfficeApplication.getDocumentService().loadDocument(new FileInputStream(new File("test/testTexts.sxw")), new DocumentDescriptor());
      if (document != null) {
        System.out.println("Loaded document");
       
        ITextDocument textDocument = (ITextDocument)document;
             
       
        ITextContentEnumeration textEnumeration = textDocument.getTextService().getText().getTextContentEnumeration();
        IParagraph[] paragraphs = textEnumeration.getParagraphs();
       
       
        ITextRange newTextRange = textDocument.getViewCursorService().getViewCursor().getStartTextRange();
        XTextCursor cursor = newTextRange.getXTextRange().getText().createTextCursor();
        cursor.gotoEnd(false);
        newTextRange = new TextRange(textDocument, cursor);
        paragraphs[0].getCloneService().cloneToPosition(new CloneDestinationPosition(newTextRange, newTextRange.getClass()), true, null);
               
        textDocument.close();
        localOfficeApplication.deactivate();
      }
    }
    catch (Exception excep) {
      excep.printStackTrace();
View Full Code Here

      LocalOfficeApplication localOfficeApplication = new LocalOfficeApplication(null);
      LocalOfficeApplicationConfiguration configuration = new LocalOfficeApplicationConfiguration();
      configuration.setApplicationHomePath("d:\\Programme\\OpenOffice.org1.1.3");
      localOfficeApplication.setConfiguration(configuration);
      localOfficeApplication.activate();
      ITextDocument textDocument = (ITextDocument)localOfficeApplication.getDocumentService().constructNewDocument(IDocument.WRITER, new DocumentDescriptor());
     
      ITextTable textTable = textDocument.getTextTableService().constructTextTable(5, 15);
      textDocument.getTextService().getTextContentService().insertTextContent(textTable);
     
      ITextTableProperties tableProperties = textTable.getProperties();
      tableProperties.getCellWidths();
     
     
View Full Code Here

TOP

Related Classes of ag.ion.bion.officelayer.text.ITextDocument

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.