Examples of OdfFileDom


Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

    }
  }

  private static Document getOwnerDocument(TableContainer tableContainer) {
    OdfElement containerElement = tableContainer.getTableContainerElement();
    OdfFileDom ownerDocument = (OdfFileDom) containerElement.getOwnerDocument();
    return (Document) ownerDocument.getDocument();
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

  private static TableTableElement createTable(TableContainer container, int numRows, int numCols,
      int headerRowNumber, int headerColumnNumber, double marginLeft, double marginRight) throws Exception {
    Document document = getOwnerDocument(container);
    OdfElement containerElement = container.getTableContainerElement();
    OdfFileDom dom = (OdfFileDom) containerElement.getOwnerDocument();
    double tableWidth = getTableWidth(container, marginLeft, marginRight);

    boolean isTextDocument = document instanceof TextDocument;

    // check arguments
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

  /**
   * This method is invoked by appendRow. When a table has no row, the first
   * row is a default row.
   */
  private TableTableRowElement createDefaultRow(int columnCount, boolean createRepeatedCell) {
    OdfFileDom dom = (OdfFileDom) mTableElement.getOwnerDocument();
    TableTableRowElement aRow = (TableTableRowElement) OdfXMLFactory.newOdfElement(dom, OdfName.newName(
        OdfDocumentNamespace.TABLE, "table-row"));
    if (createRepeatedCell) {
      TableTableCellElement aCell = (TableTableCellElement) OdfXMLFactory.newOdfElement(dom, OdfName.newName(
          OdfDocumentNamespace.TABLE, "table-cell"));
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

    // trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");

    LOG.log(Level.INFO, "---------- {0}.xml transformed and compared ---------", odfFileNamePrefix);
    // The XML file (e.g. content.xml) is transformed by XSLT into the similar/identical XML file
    ByteArrayOutputStream xmlBytes = new ByteArrayOutputStream();
    OdfFileDom fileDom = null;
    if (odfFileNamePrefix.equals("content")) {
      fileDom = odfdoc.getContentDom();
    } else {
      fileDom = odfdoc.getStylesDom();
    }
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

      Assert.fail(e.getMessage());
    }
  }

  private void testStyle(OdfStyle testStyle) throws Exception {
    OdfFileDom fileDom = (OdfFileDom) testStyle.getOwnerDocument();
    OdfOfficeAutomaticStyles autoStyles = null;
    if (testStyle.getStyleParentStyleNameAttribute() != null) {
      if (fileDom instanceof OdfContentDom) {
        autoStyles = ((OdfContentDom) fileDom).getAutomaticStyles();
      } else if (fileDom instanceof OdfStylesDom) {
        autoStyles = ((OdfStylesDom) fileDom).getAutomaticStyles();
      }
      OdfStyle parentStyle = autoStyles.getStyle(testStyle.getStyleParentStyleNameAttribute(), testStyle.getFamily());
      if (parentStyle == null) {
        parentStyle = ((Document) fileDom.getDocument()).getDocumentStyles().getStyle(testStyle.getStyleParentStyleNameAttribute(), testStyle.getFamily());
      }

      Assert.assertNotNull(parentStyle);
    }
    if (testStyle.hasOdfAttribute(OdfName.newName(OdfDocumentNamespace.STYLE, "list-style-name"))) {
      if (testStyle.getStyleListStyleNameAttribute() != null) {
        OdfTextListStyle listStyle = autoStyles.getListStyle(testStyle.getStyleListStyleNameAttribute());
        if (listStyle == null) {
          listStyle = ((Document) fileDom.getDocument()).getDocumentStyles().getListStyle(testStyle.getStyleListStyleNameAttribute());
        }

        Assert.assertNotNull(listStyle);
      }
    }
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

    try {
      Document odfDocument = Document.loadDocument(ResourceUtilities.getAbsolutePath(SOURCE));
      Assert.assertTrue(odfDocument.getPackage().contains("content.xml"));
      String baseURI = odfDocument.getBaseURI();
      Assert.assertEquals(ResourceUtilities.getURI(SOURCE).toString(), baseURI);
      OdfFileDom odfContent = odfDocument.getContentDom();
      String odf12 = OfficeVersionAttribute.Value._1_2.toString();
      OfficeDocumentContentElement content = (OfficeDocumentContentElement) odfContent.getDocumentElement();
      String version = content.getOfficeVersionAttribute();
      Assert.assertFalse(version.equals(odf12));

      NodeList lst = odfContent.getElementsByTagNameNS(OdfDocumentNamespace.TEXT.getUri(), "p");
      Node node = lst.item(0);
      String oldText = "Changed!!!";
      node.setTextContent(oldText);

      odfDocument.save(ResourceUtilities.newTestOutputFile(TARGET));
      odfDocument = Document.loadDocument(ResourceUtilities.getAbsolutePath(TARGET));

      odfContent = odfDocument.getContentDom();
      // ToDo: Will be used for issue 60: Load & Save of previous ODF versions (ie. ODF 1.0, ODF 1.1)
      //Assert.assertTrue(odfContent.getRootElement().getOfficeVersionAttribute().equals(odf12));
      lst = odfContent.getElementsByTagNameNS(OdfDocumentNamespace.TEXT.getUri(), "p");
      node = lst.item(0);
      String newText = node.getTextContent();
      Assert.assertTrue(newText.equals(oldText));

      node = lst.item(1);
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

  /*
   * Return the matched text might exist in header/footer.
   */
  private TextSelection findInHeaderFooter(TextSelection selected) {
    OdfFileDom styledom = null;
    OdfOfficeMasterStyles masterpage = null;
    OdfElement element = null;

    if (selected != null) {
      OdfElement containerElement = selected.getContainerElement();
      int index = selected.getIndex();
      String content = TextExtractor.getText(containerElement);

      int nextIndex = -1;
      Matcher matcher = mPattern.matcher(content);
      // start from the end index of the selected item
      if (matcher.find(index + selected.getText().length())) {
        // here just consider \n\r\t occupy one char
        nextIndex = matcher.start();
        int eIndex = matcher.end();
        mNextText = content.substring(nextIndex, eIndex);
      }
      if (nextIndex != -1) {
        return createSelection(selected.getContainerElement(), nextIndex);
      }
    }
    try {
      styledom = mDocument.getStylesDom();
      NodeList list = styledom.getElementsByTagName("office:master-styles");
      if (styledom == null) {
        return null;
      }
      if (list.getLength() > 0) {
        masterpage = (OdfOfficeMasterStyles) list.item(0);
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

    if (validate() == false) {
      throw new InvalidNavigationException("No matched string at this position");
    }
    // create annotation element
    OdfElement parentElement = getContainerElement();
    OdfFileDom dom = (OdfFileDom) parentElement.getOwnerDocument();
    OfficeAnnotationElement annotationElement = dom.newOdfElement(OfficeAnnotationElement.class);
    // set creator
    DcCreatorElement dcCreatorElement = annotationElement.newDcCreatorElement();
    if (creator == null) {
      creator = System.getProperty("user.name");
    }
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

   * @param srcDocument
   *            - the source document
   */
  void copyLinkedRefInBatch(OdfElement sourceCloneEle, Document srcDocument) {
    try {
      OdfFileDom fileDom = (OdfFileDom) sourceCloneEle.getOwnerDocument();
      XPath xpath;
      if (fileDom instanceof OdfContentDom) {
        xpath = ((OdfContentDom) fileDom).getXPath();
      } else {
        xpath = ((OdfStylesDom) fileDom).getXPath();
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

  // rename the object path and path reference of this slide element
  // notes: the source clone element is the copied one to avoid changing the
  // content of the source document.
  void copyLinkedRef(OdfElement sourceCloneEle) {
    try {
      OdfFileDom fileDom = (OdfFileDom) sourceCloneEle.getOwnerDocument();
      XPath xpath;
      if (fileDom instanceof OdfContentDom) {
        xpath = ((OdfContentDom) fileDom).getXPath();
      } else {
        xpath = ((OdfStylesDom) fileDom).getXPath();
      }
      OdfPackageDocument srcDoc = fileDom.getDocument();
      // new a map to put the original name and the rename string, in case
      // that the same name might be referred by the slide several times.
      HashMap<String, String> objectRenameMap = new HashMap<String, String>();
      NodeList linkNodes = (NodeList) xpath.evaluate(".//*[@xlink:href]", sourceCloneEle, XPathConstants.NODESET);
      for (int i = 0; i <= linkNodes.getLength(); i++) {
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.