I'm try to use Nice Office Access (NOA) to embbed OpenOffice Writer to my OCR program. I can add text shape to document see code below, but I don't know how to change its position. Someone help me!
try {
// Init office
HashMap configuration = new HashMap();
configuration.put(IOfficeApplication.APPLICATION_HOME_KEY, OPEN_OFFICE_ORG_PATH);
configuration.put(IOfficeApplication.APPLICATION_TYPE_KEY, IOfficeApplication.LOCAL_APPLICATION);
officeAplication = OfficeApplicationRuntime.getApplication(configuration);
officeAplication.setConfiguration(configuration);
officeAplication.activate();
// Init frame and get service
IFrame officeFrame = officeAplication.getDesktopService().constructNewOfficeFrame(panRight);
IDocumentService documentService = officeAplication.getDocumentService();
ITextDocument textDocument = (ITextDocument) documentService.constructNewDocument(officeFrame, IDocument.WRITER, DocumentDescriptor.DEFAULT);
ITextService textService = textDocument.getTextService();
ITextContentService textContentService = textService.getTextContentService();
IText text = textService.getText();
ITextCursorService textCursorService = text.getTextCursorService();
ITextCursor textCursor = textCursorService.getTextCursor();
// Insert text shape
TextInfo textInfo = new TextInfo("Hello", VertOrientation.TOP, HoriOrientation.LEFT, 100, true, true, 100, true, true, 0xFFFFFF, TextContentAnchorType.AT_PAGE);
ITextDocumentTextShape textDocumentTextShape = textContentService.constructNewTextShape(textInfo);
textContentService.insertTextContent(textDocumentTextShape);
XText xText = textDocumentTextShape.getXText();
XTextRange xTextRange = xText.createTextCursor();
XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextRange);
xTextProps.setPropertyValue("CharFontName", "Courier New");
xTextProps.setPropertyValue("CharWeight", new Float(FontWeight.BOLD));
xTextProps.setPropertyValue("CharPosture", FontSlant.ITALIC);
xTextProps.setPropertyValue("CharHeight", new Float(28));
xText.insertString(xText.getEnd(), "My First OpenOffice Document", true);
// Now it is time to disable two commands in the frame
officeFrame.disableDispatch(GlobalCommands.CLOSE_DOCUMENT);
officeFrame.disableDispatch(GlobalCommands.QUIT_APPLICATION);
officeFrame.updateDispatches();
} catch (Throwable throwable) {
throwable.printStackTrace();
}