Examples of OdfMediaType


Examples of org.odftoolkit.odfdom.doc.OdfDocument.OdfMediaType

  public OdfPackageDocument loadDocument(String internalPath) {
    OdfPackageDocument doc = getCachedDocument(internalPath);
    if (doc == null) {
      String mediaTypeString = getMediaTypeString();
      // ToDo: Issue 265 - Remove dependency to higher layer by factory
      OdfMediaType odfMediaType = OdfMediaType.getOdfMediaType(mediaTypeString);
      if (odfMediaType == null) {
        doc = new OdfPackageDocument(this, internalPath, mediaTypeString);
      } else {
        try {
          String documentMediaType = getMediaTypeString(internalPath);
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfDocument.OdfMediaType

  public OdfPackageDocument loadDocument(String internalPath) {
    OdfPackageDocument doc = getCachedDocument(internalPath);
    if (doc == null) {
      String mediaTypeString = getMediaTypeString();
      // ToDo: Issue 265 - Remove dependency to higher layer by factory
      OdfMediaType odfMediaType = OdfMediaType.getOdfMediaType(mediaTypeString);
      if (odfMediaType == null) {
        doc = new OdfPackageDocument(this, internalPath, mediaTypeString);
      } else {
        try {
          String documentMediaType = getMediaTypeString(internalPath);
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfDocument.OdfMediaType

      OdfDocument doc = OdfDocument.loadDocument(ResourceUtilities.getAbsolutePath(TEST_FILE_EMBEDDED));
      Map<String, OdfDocument> embeddedDocs = doc.loadSubDocuments();
      for (String childDocPath : embeddedDocs.keySet()) {
        OdfDocument childDoc = embeddedDocs.get(childDocPath);
        String embedFileName = childDoc.getDocumentPath();
        OdfMediaType embedMediaType = OdfMediaType.getOdfMediaType(childDoc.getMediaTypeString());
        //use '_' replace '/', because '/' is not the valid char in file path
        embedFileName = embedFileName.replaceAll("/", "_") + "." + embedMediaType.getSuffix();
        childDoc.save(TEST_FILE_FOLDER + embedFileName);
        LOG.log(Level.INFO, "Save file : {0}", TEST_FILE_FOLDER + embedFileName);
        OdfDocument embeddedDoc = OdfDocument.loadDocument(ResourceUtilities.getAbsolutePath(embedFileName));
        Assert.assertEquals(embeddedDoc.getMediaTypeString(), embedMediaType.getMediaTypeString());
      }
    } catch (Exception ex) {
      LOG.log(Level.SEVERE, null, ex);
      Assert.fail("Failed with " + ex.getClass().getName() + ": '" + ex.getMessage() + "'");
    }
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfDocument.OdfMediaType

  public OdfPackageDocument loadDocument(String internalPath) {
    OdfPackageDocument doc = getCachedDocument(internalPath);
    if (doc == null) {
      String mediaTypeString = getMediaTypeString();
      // ToDo: Issue 265 - Remove dependency to higher layer by factory
      OdfMediaType odfMediaType = OdfMediaType.getOdfMediaType(mediaTypeString);
      if (odfMediaType == null) {
        doc = new OdfPackageDocument(this, internalPath, mediaTypeString);
      } else {
        try {
          String documentMediaType = getMediaTypeString(internalPath);
View Full Code Here

Examples of org.odftoolkit.simple.Document.OdfMediaType

   
    try {
      String spreadDocPath = ResourceUtilities.getAbsolutePath(TEST_FILE);
      SpreadsheetDocument spreadDoc = SpreadsheetDocument.loadDocument(spreadDocPath);
      Assert.assertNotNull(spreadDoc);
      OdfMediaType odfMediaType = spreadDoc.getOdfMediaType();
      Assert.assertEquals(Document.OdfMediaType.SPREADSHEET_TEMPLATE, odfMediaType);
    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
View Full Code Here

Examples of org.odftoolkit.simple.Document.OdfMediaType

  public void testGetSuffix() throws Exception{
    try {
      String spreadDocPath = ResourceUtilities.getAbsolutePath(TEST_FILE);
      SpreadsheetDocument spreadDoc = SpreadsheetDocument.loadDocument(spreadDocPath);
      Assert.assertNotNull(spreadDoc);
      OdfMediaType odfMediaType = spreadDoc.getOdfMediaType();
      String suffix = odfMediaType.getSuffix();
      Assert.assertEquals("ots", suffix);
    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
View Full Code Here

Examples of org.odftoolkit.simple.Document.OdfMediaType

  public void testGetMediaTypeString() throws Exception {
    try {
      TextDocument tdoc = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath(EMPTY_TEXT_DOCUMENT_PATH));
      Assert.assertNotNull(tdoc);
     
      OdfMediaType odfMedia = tdoc.getOdfMediaType();
      String mediaType = odfMedia.getMediaTypeString();
      Assert.assertEquals("application/vnd.oasis.opendocument.text", mediaType);
    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
View Full Code Here

Examples of org.odftoolkit.simple.Document.OdfMediaType

 
  @Test
  public void testNewTextDocument() throws Exception {
    try {
      TextDocument tdoc = TextDocument.newTextDocument(TextDocument.OdfMediaType.TEXT_MASTER);
      OdfMediaType odfMediaA = tdoc.getOdfMediaType();
      String filePath = ResourceUtilities.getAbsolutePath("");
      tdoc.save(filePath + "testNewTextDocument.odt");

      //validate
      TextDocument tdocument = TextDocument.loadDocument(filePath + "testNewTextDocument.odt");
      OdfMediaType odfMediaB = tdocument.getOdfMediaType();
      Assert.assertEquals(odfMediaA, odfMediaB);
    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
View Full Code Here

Examples of org.odftoolkit.simple.Document.OdfMediaType

  @Test
  public void testLoadDocumentResource() throws Exception {
    try {
      TextDocument tdocument = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("headerFooterHidden.odt"));
      Assert.assertNotNull(tdocument);
      OdfMediaType odfMediaB = tdocument.getOdfMediaType();
      Assert.assertEquals("application/vnd.oasis.opendocument.text", odfMediaB.getMediaTypeString());
    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
   
View Full Code Here

Examples of org.odftoolkit.simple.Document.OdfMediaType

    try {
      String filePath = ResourceUtilities.getAbsolutePath("headerFooterHidden.odt");
      File file = new File(filePath);
      TextDocument tdocument = TextDocument.loadDocument(file);
      Assert.assertNotNull(tdocument);
      OdfMediaType odfMediaB = tdocument.getOdfMediaType();
      Assert.assertEquals("application/vnd.oasis.opendocument.text", odfMediaB.getMediaTypeString());
    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
   
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.