Examples of OdfContentDom


Examples of org.odftoolkit.odfdom.dom.OdfContentDom

   *                 If the imageURI is relative first the user.dir is taken to make it absolute.
   * @return         Returns the internal package path of the image, which was created based on the given URI.
   * */
  public String newImage(URI imageUri) {
    try {
      OdfContentDom contentDom = this.getContentDom();
      OdfDrawFrame drawFrame = contentDom.newOdfElement(OdfDrawFrame.class);
      XPath xpath = contentDom.getXPath();
      if (this instanceof OdfSpreadsheetDocument) {
        TableTableCellElement lastCell = (TableTableCellElement) xpath.evaluate("//table:table-cell[last()]", contentDom, XPathConstants.NODE);
        lastCell.appendChild(drawFrame);
        drawFrame.removeAttribute("text:anchor-type");

View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

    InputStream in = FormUtils.class.getResourceAsStream("/forms/odt/sampleDeliveryForm.odt");

    if (in != null) {
      OdfTextDocument oDoc = OdfTextDocument.loadDocument(in);
      OdfContentDom contentDom = oDoc.getContentDom();

      /*
      OfficeTextElement contentRoot = oDoc.getContentRoot();
      NodeList nl = contentRoot.getElementsByTagName("TABLE");
      for (int i = 0; i < nl.getLength(); i++) {
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

   *            the Document which this ImageDecorator will be used on.
   * @param imageUri
   *            the image location.
   */
  public ImageDecorator(Document doc, URI imageUri) {
    OdfContentDom contentDocument;
    try {
      contentDocument = doc.getContentDom();
      styles = contentDocument.getAutomaticStyles();
      OdfOfficeStyles documentStyles = doc.getDocumentStyles();
      listStyle = styles.getListStyle(DEFAULT_NAME);
      // create image style
      if (listStyle == null) {
        listStyle = styles.newListStyle();
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

   *
   * @param doc
   *            the Document which this NumberDecorator will be used on.
   */
  public NumberDecorator(Document doc) {
    OdfContentDom contentDocument;
    try {
      contentDocument = doc.getContentDom();
      styles = contentDocument.getAutomaticStyles();
      OdfOfficeStyles documentStyles = doc.getDocumentStyles();
      listStyle = styles.getListStyle(DEFAULT_NAME);
      // create number style
      if (listStyle == null) {
        listStyle = styles.newListStyle();
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

      mDocument = doc;
      // init chart container by searching the embeded document
      mCharts = new HashMap<String, Chart>();
      List<Document> charts = mDocument.getEmbeddedDocuments(Document.OdfMediaType.CHART);
      for (Document chartDoc : charts) {
        OdfContentDom contentDom = chartDoc.getContentDom();
        ChartChartElement chartEle = (ChartChartElement) contentDom.getXPath().evaluate("//chart:chart[1]",
            contentDom, XPathConstants.NODE);
        String documentPath = chartDoc.getDocumentPath();
        mCharts.put(documentPath, new Chart(chartEle, documentPath));
      }
    } catch (Exception ex) {
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

    try {
      String sName = mDocument.getDocumentPath() + "/" + title + "_" + System.currentTimeMillis();
      // embed this chart document
      ChartDocument newChartDocument = ChartDocument.newChartDocument();
      mDocument.insertDocument(newChartDocument, sName);
      OdfContentDom contentDom = newChartDocument.getContentDom();
      ChartChartElement chartEle = (ChartChartElement) (contentDom.getXPath().evaluate("//chart:chart[1]",
          contentDom, XPathConstants.NODE));
      Chart chart = new Chart(chartEle, sName);
      chart.setChartTitle(title);
      chart.setChartType(ChartType.BAR);
      chart.setUseLegend(true);
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

  public Chart getChartById(String chartId) {
    try {
      Document embedChartDoc = mDocument.getEmbeddedDocument(chartId);
      if (embedChartDoc != null) {
        OdfContentDom contentDom = embedChartDoc.getContentDom();
        ChartChartElement chartEle = (ChartChartElement) contentDom.getXPath().evaluate("//chart:chart[1]",
            contentDom, XPathConstants.NODE);
        Chart chart = new Chart(chartEle, chartId);
        if (mCharts.get(chartId) != null) {
          return chart;
        }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

  @Test
  public void testContentNode() {
    try {
      Document odfdoc = Document.loadDocument(ResourceUtilities.getAbsolutePath(TEST_FILE));

      OdfContentDom contentDom = odfdoc.getContentDom();

      // test content.xml:automatic-styles
      OdfOfficeAutomaticStyles autoStyles = contentDom.getAutomaticStyles();
      Assert.assertNotNull(autoStyles);

      OdfStyle style = autoStyles.getStyle("P1", OdfStyleFamily.Paragraph);
      Assert.assertNotNull(style);
      Assert.assertEquals(style.getStyleNameAttribute(), "P1");
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

 
  @Test
  public void testGetContentRootDoc() throws Exception {
    try {
      Document odt = Document.loadDocument(ResourceUtilities.getAbsolutePath(TEST_FILE_WITHOUT_OPT));
      OdfContentDom odfcon = odt.getContentDom();
      Assert.assertNotNull(odfcon);
    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

  }
 
  private void validPageBreakExist(TextDocument newDoc, Paragraph paragraph) throws Exception {
    Node paragraphNode = paragraph.getOdfElement().getNextSibling();
    Assert.assertTrue(paragraphNode instanceof TextPElement);
    OdfContentDom contentDocument = newDoc.getContentDom();
    OdfOfficeAutomaticStyles styles = contentDocument.getAutomaticStyles();
    OdfStyle style = styles.getStyle(((TextPElement) paragraphNode).getStyleName(), OdfStyleFamily.Paragraph);
    Assert.assertNotNull(style);
    Node paragraphPropertiesNode = style.getFirstChild();
    Assert.assertNotNull(paragraphPropertiesNode instanceof StyleParagraphPropertiesElement);
    Assert.assertEquals(((StyleParagraphPropertiesElement) paragraphPropertiesNode).getFoBreakBeforeAttribute(),
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.