Examples of OdfTextSpan


Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

      element = new OdfTextParagraph((OdfFileDom) mCellElement.getOwnerDocument());
      mCellElement.appendChild(element);
    } else {
      String formerContent = element.getTextContent();
      while (formerContent == null || "".equals(formerContent)) {
        OdfTextSpan span = OdfElement.findFirstChildNode(OdfTextSpan.class, element);
        if (span == null) {
          break;
        }
        formerContent = span.getTextContent();
        element = span;
      }
    }
    if ((stylename != null) && (stylename.length() > 0)) {
      element.setStyleName(stylename);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

      // Make sure the embedded document is being loaded

      // Add text element
      TextPElement para = (TextPElement) xpath.evaluate("//text:p[1]", contentDom, XPathConstants.NODE);
      LOG.log(Level.INFO, "First para: {0}", para.getTextContent());
      OdfTextSpan spanElem = new OdfTextSpan(contentDom);
      spanElem.setTextContent(TEST_SPAN_TEXT);
      para.appendChild(spanElem);

      // Add frame and image element
      TextPElement paraLast = (TextPElement) xpath.evaluate("//text:p[last()]", contentDom, XPathConstants.NODE);
      addImageToDocument(contentDom, paraLast);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

      Assert.assertEquals(embDocsNumber + 1, emb_embDocs.size());

      Document emb_embDoc = rootDocument.getEmbeddedDocument(embDoc.getDocumentPath() + pathOfSecondInnerDoc);
      contentDom = emb_embDoc.getContentDom();
      TextPElement para = (TextPElement) xpath.evaluate("//text:p[1]", contentDom, XPathConstants.NODE);
      OdfTextSpan spanElem = new OdfTextSpan(contentDom);
      spanElem.setTextContent(TEST_SPAN_TEXT);
      para.appendChild(spanElem);

      // embDoc.save(ResourceUtilities.newTestOutputFile("222debug.odt"));
      rootDocument.save(TEST_FILE_EMBEDDED_EMBEDDED);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

      Assert.assertNotNull(doc1);

      OdfContentDom contentDom = doc1.getContentDom();
      XPath xpath = contentDom.getXPath();
      TextPElement para = (TextPElement) xpath.evaluate("//text:p[1]", contentDom, XPathConstants.NODE);
      OdfTextSpan spanElem = new OdfTextSpan(contentDom);
      spanElem.setTextContent(TEST_SPAN_TEXT);
      para.appendChild(spanElem);
      // save the embed document to a stand alone document
      doc1.save(TEST_FILE_SAVE_EMBEDDED_OUT);
      // Load test
      Document loadedDoc = Document.loadDocument(TEST_FILE_SAVE_EMBEDDED_OUT);
      OdfContentDom contentDom2 = loadedDoc.getContentDom();
      OdfTextSpan span = (OdfTextSpan) xpath.evaluate("//text:span[last()]", contentDom2, XPathConstants.NODE);
      Assert.assertEquals(span.getTextContent(), TEST_SPAN_TEXT);
      List<Document> embDocs3 = docWithEmbeddedObjects.getEmbeddedDocuments(Document.OdfMediaType.TEXT);

      // Writer Doc
      Document doc3 = embDocs3.get(0);
      Assert.assertNotNull(doc3);
      OdfContentDom contentDom3 = doc3.getContentDom();
      TextPElement para2 = (TextPElement) xpath.evaluate("//text:p[1]", contentDom3, XPathConstants.NODE);
      addImageToDocument(contentDom3, para2);
      TextPElement para3 = (TextPElement) xpath.evaluate("//text:p[last()]", contentDom3, XPathConstants.NODE);
      addFrameForEmbeddedDoc(contentDom3, para3, "NewEmbedded");
      doc3.insertDocument(TextDocument.newTextDocument(), "/NewEmbedded/");
      Document doc4 = doc3.getEmbeddedDocument("NewEmbedded");
      Assert.assertNotNull(doc4);
      OdfContentDom contentDom4 = doc4.getContentDom();
      para = (TextPElement) xpath.evaluate("//text:p[1]", contentDom4, XPathConstants.NODE);
      spanElem = new OdfTextSpan(contentDom4);
      spanElem.setTextContent(TEST_SPAN_TEXT);
      para.appendChild(spanElem);
      doc3.save(TEST_FILE_SAVE_EMBEDDED_OUT2);

      Document testLoad = Document.loadDocument(TEST_FILE_SAVE_EMBEDDED_OUT2);
      NodeList linkNodes = (NodeList) xpath.evaluate("//*[@xlink:href]", testLoad.getContentDom(),
          XPathConstants.NODE);
      for (int i = 0; i < linkNodes.getLength(); i++) {
        OdfElement object = (OdfElement) linkNodes.item(i);
        String refObjPath = object.getAttributeNS(OdfDocumentNamespace.XLINK.getUri(), "href");
        Assert.assertTrue(refObjPath.equals("Pictures/" + TEST_PIC) || refObjPath.equals("./NewEmbedded"));
      }
      Assert.assertNotNull(testLoad.getPackage().getFileEntry("Pictures/" + TEST_PIC));
      Document embedDocOftestLoad = testLoad.getEmbeddedDocument("NewEmbedded/");
      contentDom4 = embedDocOftestLoad.getContentDom();
      OdfTextSpan span4 = (OdfTextSpan) xpath.evaluate("//text:span[last()]", contentDom4, XPathConstants.NODE);
      Assert.assertNotNull(span4);
      Assert.assertEquals(span4.getTextContent(), TEST_SPAN_TEXT);
    } catch (Exception ex) {
      ex.printStackTrace();
      Logger.getLogger(DocumentCreationTest.class.getName()).log(Level.SEVERE, null, ex);
      Assert.fail("Failed with " + ex.getClass().getName() + ": '" + ex.getMessage() + "'");
    }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

          int nextLength = value.length() - endLength;

          Node nextNode = node.getNextSibling();
          Node parNode = node.getParentNode();
          // init text:a
          OdfTextSpan textSpan = new OdfTextSpan(
              (OdfFileDom) node.getOwnerDocument());
          Node newNode = null;
          if (nextLength >= 0) {
            textSpan.setTextContent(value.substring(fromindex,
                endLength));
            newNode = node.cloneNode(true);
            newNode.setNodeValue(value.substring(endLength, value.length()));
            leftLength = 0;
          } else {
            textSpan.setTextContent(value.substring(fromindex,
                value.length()));
            leftLength = endLength - value.length();
          }
          textSpan.setProperties(style.getStyleProperties());

          if (nextNode != null) {
            parNode.insertBefore(textSpan, nextNode);
            if (newNode != null) {
              parNode.insertBefore(newNode, nextNode);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

    OdfElement parentElement = getContainerElement();

    int leftLength = getText().length();
    int index = mIndexInContainer;
    delete(index, leftLength, parentElement);
    OdfTextSpan textSpan = new OdfTextSpan((OdfFileDom) parentElement.getOwnerDocument());
    textSpan.addContentWhitespace(newText);
    /*if (startElement instanceof OdfStyleBase)
    textSpan.setProperties(((OdfStyleBase) startElement)
    .getStyleProperties());*/
    mIsInserted = false;
    insertSpan(textSpan, index, parentElement);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

    if (positionItem instanceof TextSelection) {
      indexOfNew = ((TextSelection) positionItem).getIndex();
      newElement = ((TextSelection) positionItem).getContainerElement();
    }

    OdfTextSpan textSpan = getSpan((OdfFileDom) positionItem.getElement().getOwnerDocument());
    mIsInserted = false;
    insertSpan(textSpan, indexOfNew, newElement);
    adjustStyle(newElement, textSpan, null);
    SelectionManager.refreshAfterPasteAtFrontOf(this, positionItem);
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

    if (positionItem instanceof TextSelection) {
      indexOfNew = ((TextSelection) positionItem).getIndex() + ((TextSelection) positionItem).getText().length();
      newElement = ((TextSelection) positionItem).getContainerElement();
    }

    OdfTextSpan textSpan = getSpan((OdfFileDom) positionItem.getElement().getOwnerDocument());

    mIsInserted = false;
    insertSpan(textSpan, indexOfNew, newElement);
    adjustStyle(newElement, textSpan, null);
    SelectionManager.refreshAfterPasteAtEndOf(this, positionItem);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

    if (parentElement != null) {
      Node copyParentNode = parentElement.cloneNode(true);
      if (ownerDoc != parentElement.getOwnerDocument()) {
        copyParentNode = ownerDoc.adoptNode(copyParentNode);
      }
      OdfTextSpan textSpan = new OdfTextSpan(ownerDoc);
      int sIndex = mIndexInContainer;
      int eIndex = sIndex + mMatchedText.length();
      // delete the content except the selection string
      // delete from the end to start, so that the postion will not be
      // impact by delete action
      OdfWhitespaceProcessor textProcessor = new OdfWhitespaceProcessor();
      delete(eIndex, textProcessor.getText(copyParentNode).length() - eIndex, copyParentNode);
      delete(0, sIndex, copyParentNode);
      optimize(copyParentNode);
      Node childNode = copyParentNode.getFirstChild();
      while (childNode != null) {
        textSpan.appendChild(childNode.cloneNode(true));
        childNode = childNode.getNextSibling();
      }
      // apply text style for the textSpan
      if (copyParentNode instanceof OdfStylableElement) {
        applyTextStyleProperties(getTextStylePropertiesDeep((OdfStylableElement) copyParentNode),
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

      Node node = parentNode.getFirstChild();
      while (node != null) {
        if (node.getNodeType() == Node.TEXT_NODE) {
          if (node.getTextContent().length() > 0) {
            Node nextNode = node.getNextSibling();
            OdfTextSpan span = new OdfTextSpan((OdfFileDom) node.getOwnerDocument());
            span.appendChild(node);
            if (nextNode != null) {
              parentNode.insertBefore(span, nextNode);
            } else {
              parentNode.appendChild(span);
            }
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.