Package org.odftoolkit.odfdom.pkg

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom


  }

  public boolean removeList(List list) {
    OdfElement containerElement = getListContainerElement();
    Node child = containerElement.getFirstChild();
    OdfFileDom ownerDocument = (OdfFileDom) containerElement.getOwnerDocument();
    Document doc = (Document) ownerDocument.getDocument();
    while (child != null) {
      if (child instanceof TextListElement) {
        TextListElement listElement1 = (TextListElement) child;
        String id1 = listElement1.getXmlIdAttribute();
        TextListElement listElement2 = list.getOdfElement();
View Full Code Here


   * @return the slide index in the owner document
   * <p>
   * -1, if the odf element which can represent this slide is not in the document DOM tree
   */
  public int getSlideIndex() {
    OdfFileDom contentDom = (OdfFileDom) maSlideElement.getOwnerDocument();
    NodeList slideNodes = contentDom.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
    for (int i = 0; i < slideNodes.getLength(); i++) {
      DrawPageElement slideEle = (DrawPageElement) slideNodes.item(i);
      if (slideEle == maSlideElement)//should not equals here, see OdfElement.equals(Object obj)
      {
        return i;
View Full Code Here

  public void setSlideName(String name) {
    if (name == null) {
      throw new IllegalArgumentException("slide name is null is not accepted in the presentation document");
    }
    //check if name is unique in this presentation
    OdfFileDom contentDom = (OdfFileDom) maSlideElement.getOwnerDocument();
    NodeList slideNodes = contentDom.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
    for (int i = 0; i < slideNodes.getLength(); i++) {
      DrawPageElement slideEle = (DrawPageElement) slideNodes.item(i);
      OdfSlide slide = OdfSlide.getInstance(slideEle);
      String slideName = slide.getSlideName();
      if (slideName.equals(name)) {
View Full Code Here

  public OdfTextListStyle getListStyle() {
    OdfTextListStyle style = null;

    String listName = getTextStyleNameAttribute();
    if (listName != null && listName.length() > 0) {
      OdfFileDom fileDom = (OdfFileDom) this.ownerDocument;
      OdfOfficeAutomaticStyles autoStyles = null;
      if(fileDom instanceof OdfContentDom){
        autoStyles = ((OdfContentDom) fileDom).getAutomaticStyles();
      }else if(fileDom instanceof OdfStylesDom){
        autoStyles = ((OdfStylesDom) fileDom).getAutomaticStyles();
      }     
      if (autoStyles != null) {
        style = autoStyles.getListStyle(listName);
      }
      if (style == null) {
        OdfOfficeStyles styles = ((OdfSchemaDocument) fileDom.getDocument()).getDocumentStyles();
        if (styles != null) {
          style = styles.getListStyle(listName);
        }
      }
    } else {
View Full Code Here

   */
  public OdfTextListStyle getOrCreateLocalListStyle() {
    OdfTextListStyle listStyle = getListStyle();
    if (listStyle == null) {
      OdfOfficeAutomaticStyles autoStyles = null;
      OdfFileDom fileDom = ((OdfFileDom) this.ownerDocument);
      if(fileDom instanceof OdfContentDom){
        autoStyles = ((OdfContentDom) fileDom).getOrCreateAutomaticStyles();
      }else if(fileDom instanceof OdfStylesDom){
        autoStyles = ((OdfStylesDom) fileDom).getOrCreateAutomaticStyles();
     
View Full Code Here

   *
   * @param styleFamily  The <code>OdfStyleFamily</code> element
   * @return an <code>OdfStyle</code> element
   */
  public OdfStyle newStyle(OdfStyleFamily styleFamily) {
    OdfFileDom dom = (OdfFileDom) this.ownerDocument;
    OdfStyle newStyle = dom.newOdfElement(OdfStyle.class);
    newStyle.setStyleFamilyAttribute(styleFamily.getName());

    newStyle.setStyleNameAttribute(newUniqueStyleName(styleFamily));

    this.appendChild(newStyle);
View Full Code Here

   * Create an <code>OdfTextListStyle</code> element
   *
   * @return an <code>OdfTextListStyle</code> element
   */
  public OdfTextListStyle newListStyle() {
    OdfFileDom dom = (OdfFileDom) this.ownerDocument;
    OdfTextListStyle newStyle = dom.newOdfElement(OdfTextListStyle.class);

    newStyle.setStyleNameAttribute(newUniqueStyleName(OdfStyleFamily.List));

    this.appendChild(newStyle);

View Full Code Here

   * Process text that may have a currency symbol ($) in it.
   * @param text string to be processed
   * @param currencySymbol the currency symbol under consideration
   */
  private void processText(String text, String currencySymbol) {
    OdfFileDom dom = (OdfFileDom) this.getOwnerDocument();
    int currencyPos = text.indexOf(currencySymbol);
    if (currencyPos >= 0) {
      emitText(text.substring(0, currencyPos));
      NumberCurrencySymbolElement cSymbol = new NumberCurrencySymbolElement(dom);
      cSymbol.appendChild(dom.createTextNode(currencySymbol));
      this.appendChild(cSymbol);
      emitText(text.substring(currencyPos + currencySymbol.length()));
    } else {
      emitText(text);
    }
View Full Code Here

    mbFinishFindInHeaderFooter = false;
  }

  //the matched text might exist in header/footer
  private TextSelection findInHeaderFooter(TextSelection selected) {
    OdfFileDom styledom = null;
    OdfOfficeMasterStyles masterpage = null;
    OdfElement element = null;

    if (selected != null) {
      OdfElement containerElement = selected.getContainerElement();
      int index = selected.getIndex();
      OdfWhitespaceProcessor textProcessor = new OdfWhitespaceProcessor();
      String content = textProcessor.getText(containerElement);

      int nextIndex = -1;
      Pattern pattern = Pattern.compile(mPatternText);
      Matcher matcher = pattern.matcher(content);
      //start from the end index of the selected item
      if (matcher.find(index + selected.getText().length())) {
        // here just consider \n\r\t occupy one char
        nextIndex = matcher.start();
        int eIndex = matcher.end();
        mCurrentText = content.substring(nextIndex, eIndex);
      }
      if (nextIndex != -1) {
        TextSelection item = new TextSelection(mCurrentText, selected.getContainerElement(), nextIndex);
        return item;
      }
    }
    try {
      styledom = mTextDocument.getStylesDom();
      NodeList list = styledom.getElementsByTagName("office:master-styles");
      if (styledom == null) {
        return null;
      }
      if (list.getLength() > 0) {
        masterpage = (OdfOfficeMasterStyles) list.item(0);
View Full Code Here

    // trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");

    LOG.log(Level.INFO, "---------- {0}.xml transformed and compared ---------", odfFileNamePrefix);
    // The XML file (e.g. content.xml) is transformed by XSLT into the similar/identical XML file
    ByteArrayOutputStream xmlBytes = new ByteArrayOutputStream();
    OdfFileDom fileDom = null;
    if (odfFileNamePrefix.equals("content")) {
      fileDom = odfdoc.getContentDom();
    } else {
      fileDom = odfdoc.getStylesDom();
    }
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.pkg.OdfFileDom

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.