Package org.odftoolkit.odfdom.pkg.manifest

Examples of org.odftoolkit.odfdom.pkg.manifest.OdfFileEntry


      //he has to insert it to the sub document of docA and update the xlink:href link
      docA.insertDocument(docB, "DOCB/");
      //save
      docA.save(TEST_FILE_FOLDER + TEST_FILE_EMBEDDED_SIDEBYSIDE_SAVE_OUT);
      OdfDocument testLoad = OdfDocument.loadDocument(TEST_FILE_FOLDER + TEST_FILE_EMBEDDED_SIDEBYSIDE_SAVE_OUT);
      OdfFileEntry imageEntry = testLoad.getPackage().getFileEntry(OdfPackage.OdfFile.IMAGE_DIRECTORY.getPath() + SLASH + TEST_PIC);
      Assert.assertNotNull(imageEntry);
      Map<String, OdfDocument> embDocs = testLoad.loadSubDocuments(OdfDocument.OdfMediaType.SPREADSHEET);
      for(String embedDocPath : embDocs.keySet()){
        OdfDocument doc1 = embDocs.get(embedDocPath);
        imageEntry = doc1.getPackage().getFileEntry(doc1.getDocumentPath() + OdfPackage.OdfFile.IMAGE_DIRECTORY.getPath() + SLASH + TEST_PIC_ANOTHER);
View Full Code Here


      table1.setTableName("NewTable");
      Assert.assertNotNull(docB);
      Assert.assertNull(odtDoc1.loadSubDocument("DOCB/"));
      docA.save(TEST_FILE_FOLDER + TEST_FILE_EMBEDDED_INCLUDED_SAVE_OUT);
      OdfDocument testLoad = OdfDocument.loadDocument(TEST_FILE_FOLDER + TEST_FILE_EMBEDDED_INCLUDED_SAVE_OUT);
      OdfFileEntry imageEntry = testLoad.getPackage().getFileEntry(OdfPackage.OdfFile.IMAGE_DIRECTORY.getPath() + SLASH + TEST_PIC);
      Assert.assertNotNull(imageEntry);
      Map<String, OdfDocument> embDocs = testLoad.loadSubDocuments(OdfDocument.OdfMediaType.SPREADSHEET);
      for (String childDocPath : embDocs.keySet()) { 
        OdfDocument doc1 = embDocs.get(childDocPath);
        imageEntry = doc1.getPackage().getFileEntry(doc1.getDocumentPath() + OdfPackage.OdfFile.IMAGE_DIRECTORY.getPath() + SLASH + TEST_PIC_ANOTHER);
View Full Code Here

      embedContentDom = embeddedDoc.getContentDom();
      header = (TextHElement) xpath.evaluate("//text:h[1]", embedContentDom, XPathConstants.NODE);
      Assert.assertTrue(header.getTextContent().contains(TEST_SPAN_TEXT));
      header.setTextContent("");
      String packagePath = embeddedDoc.getDocumentPath() + SLASH + OdfPackage.OdfFile.IMAGE_DIRECTORY.getPath() + SLASH + TEST_PIC;
      OdfFileEntry imageEntry = embeddedDoc.getPackage().getFileEntry(packagePath);
      Assert.assertNotNull(imageEntry);
      embeddedDoc.newImage(ResourceUtilities.getURI(TEST_PIC_ANOTHER));
      //save the "DocA" as the standalone document
      embeddedDoc.save(TEST_FILE_FOLDER + TEST_FILE_MODIFIED_EMBEDDED_SAVE_STANDALONE);
      //load the standalone document and check the content
      OdfDocument standaloneDoc = OdfDocument.loadDocument(ResourceUtilities.getAbsolutePath(TEST_FILE_MODIFIED_EMBEDDED_SAVE_STANDALONE));
      embedContentDom = standaloneDoc.getContentDom();
      header = (TextHElement) xpath.evaluate("//text:h[1]", embedContentDom, XPathConstants.NODE);
      Assert.assertTrue(header.getTextContent().length() == 0);
      imageEntry = standaloneDoc.getPackage().getFileEntry(OdfPackage.OdfFile.IMAGE_DIRECTORY.getPath() + SLASH + TEST_PIC);
      Assert.assertNotNull(imageEntry);
      OdfFileEntry anotherImageEntry = standaloneDoc.getPackage().getFileEntry(OdfPackage.OdfFile.IMAGE_DIRECTORY.getPath() + SLASH + TEST_PIC_ANOTHER);
      Assert.assertNotNull(anotherImageEntry);
    } catch (Exception ex) {
      LOG.log(Level.SEVERE, null, ex);
      Assert.fail("Failed with " + ex.getClass().getName() + ": '" + ex.getMessage() + "'");
    }
View Full Code Here

    }
    return aLogger.hasError();
  }

  private boolean isEncrypted(String aEntryName, Logger aLogger) {
    OdfFileEntry aFileEntry = getPackage(aLogger).getFileEntry(aEntryName);
    if (aFileEntry != null) {
      EncryptionDataElement aEncData = aFileEntry.getEncryptionData();
      if (aEncData != null) {
        aLogger.logFatalError("stream content is encrypted. Validataion of encrypted content is not supported.");
        return true;
      }
    }
View Full Code Here

      doc2 = OdfPresentationDocument.loadDocument(ResourceUtilities.getAbsolutePath(TEST_PRESENTATION_FILE_ANOTHER));

      // copy slide at index 2 of doc to the index 2 of doc2
      int nEmbedDoc = doc2.loadSubDocuments().size();
      String embedDocName = "Object 3/";
      OdfFileEntry fileEntry = doc2.getPackage().getFileEntry(embedDocName);
      Assert.assertNull(fileEntry);
      OdfSlide newPage1 = doc2.copyForeignSlide(2, doc, 2);
      Assert.assertTrue(2 == newPage1.getSlideIndex());
      // slide at index 2 of doc contains an embedded document called
      // "Object 3"
View Full Code Here

      int embDocsNumber = embDocs.size();
      // the document "Object 1/
      OdfDocument embDoc = embDocs.get("Object 1/");
      String pathOfSecondInnerDoc = "Object in Object1/";
      embDoc.insertDocument(OdfTextDocument.newTextDocument(), pathOfSecondInnerDoc);
      OdfFileEntry fileEntry = embDoc.getPackage().getFileEntry(embDoc.getDocumentPath() + pathOfSecondInnerDoc);
      Assert.assertNotNull(fileEntry);

      // get "Object 1/content.xml"
      OdfContentDom contentDom = embDoc.getContentDom();
      XPath xpath = contentDom.getXPath();
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.pkg.manifest.OdfFileEntry

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.