use of org.apache.poi.hwpf.usermodel.Bookmark in project poi by apache.
the class TestBookmarksTables method test.
public void test() {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("pageref.doc");
Bookmarks bookmarks = doc.getBookmarks();
assertEquals(1, bookmarks.getBookmarksCount());
Bookmark bookmark = bookmarks.getBookmark(0);
assertEquals("userref", bookmark.getName());
assertEquals(27, bookmark.getStart());
assertEquals(38, bookmark.getEnd());
}
use of org.apache.poi.hwpf.usermodel.Bookmark in project poi by apache.
the class TestBookmarksTables method testReplaceTextBefore.
public void testReplaceTextBefore() {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("pageref.doc");
Bookmark bookmark = doc.getBookmarks().getBookmark(0);
Range range = new Range(bookmark.getStart(), bookmark.getEnd(), doc);
range.replaceText("1destin2ation3", false);
bookmark = doc.getBookmarks().getBookmark(0);
assertEquals("userref", bookmark.getName());
assertEquals(27, bookmark.getStart());
assertEquals(41, bookmark.getEnd());
}
use of org.apache.poi.hwpf.usermodel.Bookmark in project poi by apache.
the class WordToFoConverter method processBookmarks.
@Override
protected void processBookmarks(HWPFDocumentCore wordDocument, Element currentBlock, Range range, int currentTableLevel, List<Bookmark> rangeBookmarks) {
Element parent = currentBlock;
for (Bookmark bookmark : rangeBookmarks) {
Element bookmarkElement = foDocumentFacade.createInline();
final String idName = "bookmark_" + bookmark.getName();
// make sure ID used once
if (setId(bookmarkElement, idName)) {
/*
* if it just empty fo:inline without "id" attribute doesn't
* making sense to add it to DOM
*/
parent.appendChild(bookmarkElement);
parent = bookmarkElement;
}
}
if (range != null)
processCharacters(wordDocument, currentTableLevel, range, parent);
}
Aggregations