Examples of OdfPresentationDocument


Examples of org.odftoolkit.odfdom.doc.OdfPresentationDocument

  }

  @Test
  public void testNotCompressImages() throws Exception {
    //create test presentation
    OdfPresentationDocument odp = OdfPresentationDocument.newPresentationDocument();
    OfficePresentationElement officePresentation = odp.getContentRoot();
    DrawPageElement page = officePresentation.newDrawPageElement(null);
    DrawFrameElement frame = page.newDrawFrameElement();
    OdfDrawImage image = (OdfDrawImage) frame.newDrawImageElement();
    image.newImage(ResourceUtilities.getURI(IMAGE_TEST_FILE));
    odp.save(ResourceUtilities.newTestOutputFile(IMAGE_PRESENTATION));

    //test if the image is not compressed
    ZipInputStream zinput = new ZipInputStream(ResourceUtilities.getTestResourceAsStream(IMAGE_PRESENTATION));
    ZipEntry entry = zinput.getNextEntry();
    while (entry != null) {
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfPresentationDocument

   */
  @Test
  public void testXPathwithAlienNodes() throws Exception {
    try {
      OdfPresentationDocument odpWithSlides = OdfPresentationDocument.loadDocument(ResourceUtilities.getAbsolutePath(SOURCE_FILE_1));
      OdfFileDom contentDom = odpWithSlides.getContentDom();

      XPath xpath = contentDom.getXPath();
      // Test scenario 1 - see comment above
      Iterator<String> prefixes = contentDom.getPrefixes("urn:oasis:names:tc:opendocument:xmlns:office:1.0");
      // The first prefix have to be "office"
      String prefix = prefixes.next();
      Assert.assertTrue(prefix.equals("office") || prefix.equals("daisy"));
      if(prefix.equals("office")){
        prefix = prefixes.next();
        Assert.assertTrue(prefix.equals("daisy"));
      }else if(prefix.equals("daisy")){
        prefix = prefixes.next();
        Assert.assertTrue(prefix.equals("office"));
      }else{
        Assert.fail();
      }
      // There should be no further prefix
      Assert.assertFalse(prefixes.hasNext());

      Iterator<String> prefixes2 = contentDom.getPrefixes("urn://some-test-odfdom-namespace");
      prefix = prefixes2.next();
      Assert.assertTrue(prefix.equals("prefixOne") || prefix.equals("prefixTwo"));
      if(prefix.equals("prefixOne")){
        prefix = prefixes2.next();
        Assert.assertTrue(prefix.equals("prefixTwo"));       
      }else if(prefix.equals("prefixTwo")){
        prefix = prefixes2.next();
        Assert.assertTrue(prefix.equals("prefixOne"));       
      }else{
        Assert.fail();
      }
      // There should be no further prefix
      Assert.assertFalse(prefixes.hasNext());

      Node node = contentDom.getRootElement();
      odpWithSlides.save(ResourceUtilities.newTestOutputFile("XPathTest-ForeignPrefix-output.odp"));

      if (node instanceof OdfAlienElement) {
        Assert.fail("The none OOO default prefix for office: was not exchanged!");
      }
      NodeList linkNodes = (NodeList) xpath.evaluate(".//*[@xlink:href]", node, XPathConstants.NODESET);
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfPresentationDocument

   * A typical test, that deals with xlinks in SOURCE_FILE_2
   */
  @Test
  public void testCopyForeignSlide() {
    try {
      OdfPresentationDocument targetodp = OdfPresentationDocument.loadDocument(ResourceUtilities.getAbsolutePath(SOURCE_FILE_1));
      OdfPresentationDocument sourceodp = OdfPresentationDocument.loadDocument(ResourceUtilities.getAbsolutePath(SOURCE_FILE_2));

      int slidecount = sourceodp.getSlideCount();
      for (int i = 0; i < slidecount; i++) {
        targetodp.copyForeignSlide(i, sourceodp, i);
      }
      targetodp.save(ResourceUtilities.newTestOutputFile("XPathTest-ForeignPrefix2-output.odp"));
      targetodp.close();
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfPresentationDocument

   * @throws Exception
   */
  @Test
  public void testXPathIsMissingXLinkButItWillPassBecauseItTheSecondTestInThisUnitTest() throws Exception {
    try {
      OdfPresentationDocument odpWithSlides = OdfPresentationDocument.loadDocument(ResourceUtilities.getAbsolutePath(SOURCE_FILE_1));
      OdfFileDom contentDom = odpWithSlides.getContentDom();
      XPath xpath = contentDom.getXPath();

      Node node = odpWithSlides.getContentDom().getRootElement();
      NodeList linkNodes = (NodeList) xpath.evaluate(".//*[@xlink:href]", node, XPathConstants.NODESET);
      Assert.assertNotNull(linkNodes);
      Assert.assertEquals("urn:oasis:names:tc:opendocument:xmlns:office:1.0", xpath.getNamespaceContext().getNamespaceURI("office"));
      Assert.assertEquals("http://www.w3.org/1999/xlink", xpath.getNamespaceContext().getNamespaceURI("xlink"));

View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfPresentationDocument

  }
 
  @Test
  public void testNotCompressImages() throws Exception {
    // create test presentation
    OdfPresentationDocument odp = OdfPresentationDocument.newPresentationDocument();
    OfficePresentationElement officePresentation = odp.getContentRoot();
    DrawPageElement page = officePresentation.newDrawPageElement(null);
    DrawFrameElement frame = page.newDrawFrameElement();
    OdfDrawImage image = (OdfDrawImage) frame.newDrawImageElement();
    image.newImage(ResourceUtilities.getURI(IMAGE_TEST_FILE));
    odp.save(ResourceUtilities.newTestOutputFile(IMAGE_PRESENTATION));
   
    // test if the image is not compressed
    ZipInputStream zinput = new ZipInputStream(ResourceUtilities.getTestResourceAsStream(IMAGE_PRESENTATION));
    ZipEntry entry = zinput.getNextEntry();
    while (entry != null) {
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfPresentationDocument

   */
  @Test
  public void testXPathwithAlienNodes() throws Exception {
    try {
      OdfPresentationDocument odpWithSlides = OdfPresentationDocument.loadDocument(ResourceUtilities.getAbsolutePath(SOURCE_FILE_1));
      OdfFileDom contentDom = odpWithSlides.getContentDom();

      XPath xpath = contentDom.getXPath();
      // Test scenario 1 - see comment above
      Iterator<String> prefixes = contentDom.getPrefixes("urn:oasis:names:tc:opendocument:xmlns:office:1.0");
      // The first prefix have to be "office"
      String prefix = prefixes.next();
      Assert.assertTrue(prefix.equals("office") || prefix.equals("daisy"));
      if(prefix.equals("office")){
        prefix = prefixes.next();
        Assert.assertTrue(prefix.equals("daisy"));
      }else if(prefix.equals("daisy")){
        prefix = prefixes.next();
        Assert.assertTrue(prefix.equals("office"));
      }else{
        Assert.fail();
      }
      // There should be no further prefix
      Assert.assertFalse(prefixes.hasNext());
         
      Iterator<String> prefixes2 = contentDom.getPrefixes("urn://some-test-odfdom-namespace");
      prefix = prefixes2.next();
      Assert.assertTrue(prefix.equals("prefixOne") || prefix.equals("prefixTwo"));
      if(prefix.equals("prefixOne")){
        prefix = prefixes2.next();
        Assert.assertTrue(prefix.equals("prefixTwo"));       
      }else if(prefix.equals("prefixTwo")){
        prefix = prefixes2.next();
        Assert.assertTrue(prefix.equals("prefixOne"));       
      }else{
        Assert.fail();
      }
      // There should be no further prefix
      Assert.assertFalse(prefixes.hasNext());

      Node rootNode = contentDom.getRootElement();
      odpWithSlides.save(ResourceUtilities.newTestOutputFile("XPathTest-ForeignPrefix-output.odp"));

      if (rootNode instanceof OdfAlienElement) {
        Assert.fail("The none OOO default prefix for office: was not exchanged!");
      }
      NodeList styleNameAttributes = (NodeList) xpath.evaluate(".//*[@style:name]", rootNode, XPathConstants.NODESET);
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfPresentationDocument

   * A typical test, that deals with xlinks in SOURCE_FILE_2
   */
  @Test
  public void testCopyForeignSlide() {
    try {
      OdfPresentationDocument targetodp = OdfPresentationDocument.loadDocument(ResourceUtilities.getAbsolutePath(SOURCE_FILE_1));
      OdfPresentationDocument sourceodp = OdfPresentationDocument.loadDocument(ResourceUtilities.getAbsolutePath(SOURCE_FILE_2));

      int slidecount = sourceodp.getSlideCount();
      for (int i = 0; i < slidecount; i++) {
        targetodp.copyForeignSlide(i, sourceodp, i);
      }
      targetodp.save(ResourceUtilities.newTestOutputFile("XPathTest-ForeignPrefix2-output.odp"));
      targetodp.close();
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfPresentationDocument

   * @throws Exception
   */
  @Test
  public void testXPathIsMissingXLinkButItWillPassBecauseItTheSecondTestInThisUnitTest() throws Exception {
    try {
      OdfPresentationDocument odpWithSlides = OdfPresentationDocument.loadDocument(ResourceUtilities.getAbsolutePath(SOURCE_FILE_1));
      OdfFileDom contentDom = odpWithSlides.getContentDom();
      XPath xpath = contentDom.getXPath();

      Node node = odpWithSlides.getContentDom().getRootElement();
      NodeList linkNodes = (NodeList) xpath.evaluate(".//*[@xlink:href]", node, XPathConstants.NODESET);
      Assert.assertNotNull(linkNodes);
      Assert.assertEquals("urn:oasis:names:tc:opendocument:xmlns:office:1.0", xpath.getNamespaceContext().getNamespaceURI("office"));
      Assert.assertEquals("http://www.w3.org/1999/xlink", xpath.getNamespaceContext().getNamespaceURI("xlink"));

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.