如何在OpenOffice API for Java中更改文本形状的位置?

如何在OpenOffice API for Java中更改文本形状的位置?,java,openoffice-writer,Java,Openoffice Writer,我正在尝试使用Nice Office Access NOA将OpenOffice Writer添加到我的OCR程序中。我可以将文本形状添加到文档中,请参见下面的代码,但我不知道如何更改其位置。有人帮帮我 try { // Init office HashMap configuration = new HashMap(); configuration.put(IOfficeApplication.APPLICATION_HOME_KEY, OPEN_OFFICE_ORG_P

我正在尝试使用Nice Office Access NOA将OpenOffice Writer添加到我的OCR程序中。我可以将文本形状添加到文档中,请参见下面的代码,但我不知道如何更改其位置。有人帮帮我

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();
}
xTextProps1.setPropertyValue("HoriOrient", HoriOrientation.NONE);
xTextProps1.setPropertyValue("HoriOrientRelation", RelOrientation.PAGE_FRAME);
xTextProps1.setPropertyValue("HoriOrientPosition", <X position>);

xTextProps1.setPropertyValue("VertOrient", VertOrientation.NONE);
xTextProps1.setPropertyValue("VertOrientRelation", RelOrientation.PAGE_FRAME);
xTextProps1.setPropertyValue("VertOrientPosition", <Y position>);