Examples of OdfFileDom


Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

   *            - the source document
   */
  void copyForeignStyleRef(OdfElement sourceCloneEle, Document srcDoc) {
    try {
      ArrayList<String> tempList = new ArrayList<String>();
      OdfFileDom srcContentDom = srcDoc.getContentDom();
      XPath xpath = srcContentDom.getXPath();
      // 1. collect all the referred style element which has "style:name"
      // attribute
      // 1.1. style:name of content.xml
      String styleQName = "style:name";
      NodeList srcStyleDefNodeList = (NodeList) xpath.evaluate(
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

  // delete all the xlink:href object which is contained in slideElement and
  // does not referred by other slides
  boolean deleteLinkedRef(OdfElement odfEle) {
    boolean success = true;
    try {
      OdfFileDom contentDom = getContentDom();
      XPath xpath = contentDom.getXPath();
      NodeList linkNodes = (NodeList) xpath.evaluate("//*[@xlink:href]", contentDom, XPathConstants.NODESET);
      for (int i = 0; i < linkNodes.getLength(); i++) {
        OdfElement object = (OdfElement) linkNodes.item(i);
        String refObjPath = object.getAttributeNS(OdfDocumentNamespace.XLINK.getUri(), "href");
        int relation = odfEle.compareDocumentPosition(object);
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

      // 2.1. get the list of the style definition
      ArrayList<OdfElement> removeStyles = new ArrayList<OdfElement>();
      OdfOfficeAutomaticStyles autoStyles = getContentDom().getAutomaticStyles();

      NodeList stylesList = autoStyles.getChildNodes();
      OdfFileDom contentDom = getContentDom();
      XPath xpath = contentDom.getXPath();

      // 2.2. get the reference of each style which occurred in the
      // current page
      for (int i = 0; i < stylesList.getLength(); i++) {
        Node item = stylesList.item(i);
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

    mOwnerDocument = (Document) ((OdfFileDom) drawElement.getOwnerDocument()).getDocument();
    mElement = (DrawFrameElement) drawElement.getParentNode();
    if (mElement == null) {
      Logger.getLogger(Image.class.getName()).log(Level.WARNING,
          "The image has no parent frame. A new frame will be created as its parent");
      OdfFileDom ownerDom = (OdfFileDom) drawElement.getOwnerDocument();
      mElement = ownerDom.newOdfElement(DrawFrameElement.class);
      mElement.appendChild(drawElement);
    }
    mFrame = Frame.getInstanceof(mElement);
    mImageElement = drawElement;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

  public static Image newImage(FrameContainer container, URI uri) {
    Image mImage;

    try {
      OdfElement parent = container.getFrameContainerElement();
      OdfFileDom ownerDom = (OdfFileDom) parent.getOwnerDocument();
      DrawFrameElement fElement = ownerDom.newOdfElement(DrawFrameElement.class);
      parent.appendChild(fElement);
      DrawImageElement imageElement = fElement.newDrawImageElement();
      // set uri and copy resource
      String packagePath = insertImageResourceIntoPackage((OdfSchemaDocument) ownerDom.getDocument(), uri);
      packagePath = packagePath.replaceFirst(ownerDom.getDocument().getDocumentPath(), "");
      URI newURI = configureInsertedImage((OdfSchemaDocument) ownerDom.getDocument(), imageElement, packagePath,
          false);

      // create image object
      mImage = new Image(imageElement);
      mImage.mImageURI = newURI;
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

  public static Image newImage(Frame frame, URI uri) {
    Image mImage;

    try {
      DrawFrameElement fElement = (DrawFrameElement) frame.getDrawFrameElement();
      OdfFileDom ownerDom = (OdfFileDom) fElement.getOwnerDocument();
      DrawImageElement imageElement = fElement.newDrawImageElement();
      // set uri and copy resource
      String packagePath = insertImageResourceIntoPackage((OdfSchemaDocument) ownerDom.getDocument(), uri);
      packagePath = packagePath.replaceFirst(ownerDom.getDocument().getDocumentPath(), "");
      URI newURI = configureInsertedImage((OdfSchemaDocument) ownerDom.getDocument(), imageElement, packagePath,
          true);

      // create image object
      mImage = new Image(imageElement);
      mImage.mImageURI = newURI;
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

   *         is no such element.
   */
  public OdfOfficeStyles getDocumentStyles() {
    if (mDocumentStyles == null) {
      try {
        OdfFileDom stylesDom = getStylesDom();
        if (stylesDom != null) {
          mDocumentStyles = OdfElement.findFirstChildNode(OdfOfficeStyles.class, stylesDom.getFirstChild());
        } else {
          return null;
        }
      } catch (Exception ex) {
        Logger.getLogger(OdfSchemaDocument.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

   * return the office:master-styles element of this document.
   * @return the office:master-styles element
   */
  public OdfOfficeMasterStyles getOfficeMasterStyles() {
    try {
      OdfFileDom fileDom = getStylesDom();
      if (fileDom != null) {
        return OdfElement.findFirstChildNode(OdfOfficeMasterStyles.class, fileDom.getFirstChild());
      }
    } catch (Exception ex) {
      Logger.getLogger(OdfSchemaDocument.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

   *         yet such an element, it is created.
   */
  public OdfOfficeStyles getOrCreateDocumentStyles() {
    if (mDocumentStyles == null) {
      try {
        OdfFileDom stylesDom = getStylesDom();
        Node parent = stylesDom != null ? stylesDom.getFirstChild() : null;
        if (parent != null) {
          mDocumentStyles = OdfElement.findFirstChildNode(OdfOfficeStyles.class, parent);
          if (mDocumentStyles == null) {
            mDocumentStyles = stylesDom.newOdfElement(OdfOfficeStyles.class);
            parent.insertBefore(mDocumentStyles, parent.getFirstChild());
          }
        }
      } catch (Exception ex) {
        Logger.getLogger(OdfSchemaDocument.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom

   */
  @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!");
      }
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.