Examples of QDomElement


Examples of com.trolltech.qt.xml.QDomElement

  }
 

  // Fix the contents of the node back to ENML.
  private void fixNode(QDomNode node) {
    QDomElement scanChecked = node.toElement();
    if (scanChecked.hasAttribute("checked")) {
      System.out.println(scanChecked.attribute("checked"));
      if (!scanChecked.attribute("checked").equalsIgnoreCase("true"))
        scanChecked.setAttribute("checked", "false");
    }
    if (node.nodeName().equalsIgnoreCase("#comment") || node.nodeName().equalsIgnoreCase("script")) {
      node.parentNode().removeChild(node);
    }
    if (node.nodeName().equalsIgnoreCase("input")) {
      QDomElement e = node.toElement();
      e.setTagName("en-todo");
      String value = e.attribute("value");
      if (value.trim().equals(""))
        value = "false";
      e.removeAttribute("value");
      e.removeAttribute("unchecked");
      e.setAttribute("checked", value);
      e.removeAttribute("onclick");
      e.removeAttribute("onmouseover");
      e.removeAttribute("type");
    }

    if (node.nodeName().equalsIgnoreCase("a")) {
      node = fixLinkNode(node);
    }
    // Restore image resources
    if (node.nodeName().equalsIgnoreCase("img")) {
      QDomElement e = node.toElement();
      String enType = e.attribute("en-tag");
     
      // Check if we have an en-crypt tag.  Change it from an img to en-crypt
      if (enType.equalsIgnoreCase("en-crypt")) {
       
        String encrypted = e.attribute("alt");
       
        QDomText crypt = doc.createTextNode(encrypted);
        e.appendChild(crypt);
       
        e.removeAttribute("v:shapes");
        e.removeAttribute("en-tag");
        e.removeAttribute("contenteditable");
        e.removeAttribute("alt");
        e.removeAttribute("src");
        e.removeAttribute("id");
        e.removeAttribute("onclick");
        e.removeAttribute("onmouseover");
        e.setTagName("en-crypt");
        node.removeChild(e);
        return;
      }

      // Check if we have a LaTeX image.  Remove the parent link tag
      if (enType.equalsIgnoreCase("en-latex")) {
        enType = "en-media";
        QDomNode parent = e.parentNode();
        parent.removeChild(e);
        parent.parentNode().replaceChild(e, parent);
      }
     
      // If we've gotten this far, we have an en-media tag
      e.setTagName(enType);
      resources.add(e.attribute("guid"));
      e.removeAttribute("guid");
      e.removeAttribute("src");
      e.removeAttribute("en-new");
      e.removeAttribute("en-tag");
    }
   
    // Tags like <ul><ul><li>1</li></ul></ul> are technically valid, but Evernote
    // expects that a <ul> tag only has a <li>, so we will need to change them
    // to this:  <ul><li><ul><li>1</li></ul></li></ul>
    if (node.nodeName().equalsIgnoreCase("ul")) {
      QDomNode firstChild = node.firstChild();
      QDomElement childElement = firstChild.toElement();
      if (childElement.nodeName().equalsIgnoreCase("ul")) {
        QDomElement newElement = doc.createElement("li");
        node.insertBefore(newElement, firstChild);
        node.removeChild(firstChild);
        newElement.appendChild(firstChild);
      }
    }
   
    if (node.nodeName().equalsIgnoreCase("en-hilight")) {
      QDomElement e = node.toElement();
      QDomText newText = doc.createTextNode(e.text());
      e.parentNode().replaceChild(newText,e);
    }
    if (node.nodeName().equalsIgnoreCase("span")) {
      QDomElement e = node.toElement();
      if (e.attribute("class").equalsIgnoreCase("en-hilight") || e.attribute("class").equalsIgnoreCase("en-spell")) {
        QDomText newText = doc.createTextNode(e.text());
        e.parentNode().replaceChild(newText,e);
      }
      if (e.attribute("pdfnavigationtable").equalsIgnoreCase("true")) {
        node.parentNode().removeChild(node);
      }
    }
   
    // Fix up encryption tag
    if (node.nodeName().equalsIgnoreCase("en-crypt-temp")) {
      QDomElement e = node.toElement();
      e.setTagName("en-crypt");
      String crypt = e.attribute("value");
      e.removeAttribute("value");
      QDomText cryptValue = doc.createTextNode(crypt);
      e.appendChild(cryptValue);
    }
  }
View Full Code Here

Examples of com.trolltech.qt.xml.QDomElement

    }
  }

 
  private QDomNode fixLinkNode(QDomNode node) {
    QDomElement e = node.toElement();
    String enTag = e.attribute("en-tag");
    if (enTag.equalsIgnoreCase("en-media")) {
      e.setTagName("en-media");
      e.removeAttribute("en-type");
      e.removeAttribute("en-tag");
      e.removeAttribute("en-new");
      resources.add(e.attribute("guid"));
      e.removeAttribute("href");
      e.removeAttribute("guid");
      e.setNodeValue("");
      e.removeChild(e.firstChildElement());
    }
    return e;
  }
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.