Examples of OdfContentDom


Examples of org.odftoolkit.odfdom.dom.OdfContentDom

  @Test
  public void testReplaceWithSimpleField_fixed_time_field() {
    try {
      search = new TextNavigation("ReplaceDateTarget", doc);
      // count the initial date field count. should be 1.
      OdfContentDom contentDom = doc.getContentDom();
      NodeList nodeList = contentDom.getElementsByTagName(TextTimeElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextTimeElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 3 "ReplaceDateTarget" to FixedDateField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithSimpleField(Field.FieldType.FIXED_TIME_FIELD);
        i++;
      }
      nodeList = contentDom.getElementsByTagName(TextTimeElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextTimeElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
      doc.save(ResourceUtilities.newTestOutputFile(SAVE_FILE_REPLACE));
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

  public void testReplaceWithSimpleField_previous_page_number_field() {
    try {
      search = new TextNavigation("ReplaceDateTarget", doc);
     
      // count the initial date field count. should be 1.
      OdfContentDom contentDom = doc.getContentDom();
     
      NodeList nodeList1 = contentDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      for(int k =0;k<nodeList1.getLength();k++){
        //
        Node nv = nodeList1.item(k);
        NamedNodeMap nameMap = nv.getAttributes();
        Node nfix = nameMap.getNamedItem("text:select-page");
        nfix.setNodeValue("previous");
      }
     
      NodeList nodeList = contentDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 3 "ReplaceDateTarget" to FixedDateField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithSimpleField(Field.FieldType.PREVIOUS_PAGE_NUMBER_FIELD);
        i++;
      }
      nodeList = contentDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
      doc.save(ResourceUtilities.newTestOutputFile(SAVE_FILE_REPLACE));
     
      //validate
      TextDocument doc1 = (TextDocument) Document.loadDocument(ResourceUtilities.getAbsolutePath(SAVE_FILE_REPLACE));
      OdfContentDom contentDom1 = doc1.getContentDom();
     
      nodeList = contentDom1.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      for(int k =0;k<nodeList.getLength();k++){
        Node nv = nodeList.item(k);
        NamedNodeMap nameMap = nv.getAttributes();
        Node nfix = nameMap.getNamedItem("text:select-page");
        Assert.assertEquals("previous", nfix.getNodeValue());
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

  @Test
  public void testReplaceWithSimpleField_current_page_number_field() {
    try {
      search = new TextNavigation("ReplaceDateTarget", doc);
      // count the initial date field count. should be 1.
      OdfContentDom contentDom = doc.getContentDom();
     
      NodeList nodeList1 = contentDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      for(int k =0;k<nodeList1.getLength();k++){
        //
        Node nv = nodeList1.item(k);
        NamedNodeMap nameMap = nv.getAttributes();
        Node nfix = nameMap.getNamedItem("text:select-page");
        nfix.setNodeValue("current");
      }
     
      NodeList nodeList = contentDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 3 "ReplaceDateTarget" to FixedDateField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithSimpleField(Field.FieldType.CURRENT_PAGE_NUMBER_FIELD);
        i++;
      }
     
      //value
      nodeList = contentDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile(SAVE_FILE_REPLACE));
     
      //validate
      TextDocument doc1 = (TextDocument) Document.loadDocument(ResourceUtilities.getAbsolutePath(SAVE_FILE_REPLACE));
      OdfContentDom contentDom1 = doc1.getContentDom();
     
      nodeList = contentDom1.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      for(int k =0;k<nodeList.getLength();k++){
        Node nv = nodeList.item(k);
        NamedNodeMap nameMap = nv.getAttributes();
        Node nfix = nameMap.getNamedItem("text:select-page");
        System.out.println(nfix.getNodeValue());
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

  @Test
  public void testReplaceWithSimpleField_next_page_number_field() {
    try {
      search = new TextNavigation("ReplaceDateTarget", doc);
      // count the initial date field count. should be 1.
      OdfContentDom contentDom = doc.getContentDom();
     
      NodeList nodeList1 = contentDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      for(int k =0;k<nodeList1.getLength();k++){
        //
        Node nv = nodeList1.item(k);
        NamedNodeMap nameMap = nv.getAttributes();
        Node nfix = nameMap.getNamedItem("text:select-page");
        nfix.setNodeValue("next");
      }
     
      NodeList nodeList = contentDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 3 "ReplaceDateTarget" to FixedDateField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithSimpleField(Field.FieldType.NEXT_PAGE_NUMBER_FIELD);
        i++;
      }
     
      //validate
      nodeList = contentDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile(SAVE_FILE_REPLACE));
     
      //validate
      TextDocument doc1 = (TextDocument) Document.loadDocument(ResourceUtilities.getAbsolutePath(SAVE_FILE_REPLACE));
      OdfContentDom contentDom1 = doc1.getContentDom();
     
      nodeList = contentDom1.getElementsByTagName(TextPageNumberElement.ELEMENT_NAME.getQName());
      for(int k =0;k<nodeList.getLength();k++){
        Node nv = nodeList.item(k);
        NamedNodeMap nameMap = nv.getAttributes();
        Node nfix = nameMap.getNamedItem("text:select-page");
        System.out.println(nfix.getNodeValue());
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

  @Test
  public void testReplaceWithSimpleField_page_count_field() {
    try {
      search = new TextNavigation("ReplaceDateTarget", doc);
      // count the initial date field count. should be 1.
      OdfContentDom contentDom = doc.getContentDom();
     
      NodeList nodeList = contentDom.getElementsByTagName(TextPageCountElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextPageCountElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 3 "ReplaceDateTarget" to FixedDateField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithSimpleField(Field.FieldType.PAGE_COUNT_FIELD);
        i++;
      }
     
      //validate
      nodeList = contentDom.getElementsByTagName(TextPageCountElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextPageCountElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
     
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

  @Test
  public void testReplaceWithSimpleField_title_field() {
    try {
      search = new TextNavigation("ReplaceDateTarget", doc);
      // count the initial date field count. should be 1.
      OdfContentDom contentDom = doc.getContentDom();
     
      NodeList nodeList = contentDom.getElementsByTagName(TextTitleElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextTitleElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 3 "ReplaceDateTarget" to FixedDateField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithSimpleField(Field.FieldType.TITLE_FIELD);
        i++;
      }
     
      //validate
      nodeList = contentDom.getElementsByTagName(TextTitleElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextTitleElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
     
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

  @Test
  public void testReplaceWithSimpleField_subject_field() {
    try {
      search = new TextNavigation("ReplaceDateTarget", doc);
      // count the initial date field count. should be 1.
      OdfContentDom contentDom = doc.getContentDom();
     
      NodeList nodeList = contentDom.getElementsByTagName(TextSubjectElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextSubjectElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 3 "ReplaceDateTarget" to FixedDateField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithSimpleField(Field.FieldType.SUBJECT_FIELD);
        i++;
      }
     
      //validate
      nodeList = contentDom.getElementsByTagName(TextSubjectElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextSubjectElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
     
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

  @Test
  public void testReplaceWithSimpleField_author_name_field() {
    try {
      search = new TextNavigation("ReplaceDateTarget", doc);
      // count the initial date field count. should be 1.
      OdfContentDom contentDom = doc.getContentDom();
     
      NodeList nodeList = contentDom.getElementsByTagName(TextAuthorNameElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextAuthorNameElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 3 "ReplaceDateTarget" to FixedDateField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithSimpleField(Field.FieldType.AUTHOR_NAME_FIELD);
        i++;
      }
     
      //validate
      nodeList = contentDom.getElementsByTagName(TextAuthorNameElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextAuthorNameElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
     
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

  @Test
  public void testReplaceWithSimpleField_author_initials_field() {
    try {
      search = new TextNavigation("ReplaceDateTarget", doc);
      // count the initial date field count. should be 1.
      OdfContentDom contentDom = doc.getContentDom();
     
      NodeList nodeList = contentDom.getElementsByTagName(TextAuthorInitialsElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextAuthorInitialsElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 3 "ReplaceDateTarget" to FixedDateField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithSimpleField(Field.FieldType.AUTHOR_INITIALS_FIELD);
        i++;
      }
     
      //validate
      nodeList = contentDom.getElementsByTagName(TextAuthorInitialsElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextAuthorInitialsElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
     
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfContentDom

  @Test
  public void testReplaceWithSimpleField_chapter_field() {
    try {
      search = new TextNavigation("ReplaceDateTarget", doc);
      // count the initial date field count. should be 1.
      OdfContentDom contentDom = doc.getContentDom();
     
      NodeList nodeList = contentDom.getElementsByTagName(TextChapterElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextChapterElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 3 "ReplaceDateTarget" to FixedDateField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithSimpleField(Field.FieldType.CHAPTER_FIELD);
        i++;
      }
     
      //validate
      nodeList = contentDom.getElementsByTagName(TextChapterElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextChapterElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
     
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.