If anyone can assist with a method that searches for a string in an open office writer document using the UNO API with Java it would be very helpful. Once it searches for string and finds string can it then(even hidden) move the cursor to that string.
I can then use the below getPageNumber method to return the page number and print that page on headed paper.
Any help much appreciated
public int getNumberOfPages()
{
XController xController = OODocument.getCurrentDocument().getXFrame().getController();
XTextViewCursorSupplier supTextViewCursor =
(XTextViewCursorSupplier) UnoRuntime.queryInterface(
XTextViewCursorSupplier.class, xController);
XTextViewCursor curTextView = supTextViewCursor.getViewCursor();
XPageCursor curPage =
(XPageCursor) UnoRuntime.queryInterface(
XPageCursor.class, curTextView);
curPage.jumpToLastPage();
System.out.println("pages = " + curPage.getPage());
return curPage.getPage();
}
public int getPageNumber()
{
XController xController = OODocument.getCurrentDocument().getXFrame().getController();
XTextViewCursorSupplier supTextViewCursor =
(XTextViewCursorSupplier) UnoRuntime.queryInterface(
XTextViewCursorSupplier.class, xController);
XTextViewCursor curTextView = supTextViewCursor.getViewCursor();
XPageCursor curPage =
(XPageCursor) UnoRuntime.queryInterface(
XPageCursor.class, curTextView);
System.out.println("current page = " + curPage.getPage());
return curPage.getPage();
}
I know it can be done using a combination of possibly the below
curTextView.setString("zzzzz");
curTextView.getText();
curTextView.gotoRange(arg0, arg1)
or XTextRange.
Thanks