2014-12-14 1 views
0

좋은 Office Access (NOA)를 사용하여 OpenOffice Writer를 OCR 프로그램에 포함 시키려고합니다. 문서에 텍스트 모양을 추가하려면 아래 코드를 참조하십시오. 그러나 위치를 변경하는 방법을 모르겠습니다. 누군가 나를 도와주세요!OpenOffice API for Java에서 텍스트 모양의 위치를 ​​변경하는 방법은 무엇입니까?

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(); 
} 

답변

0
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>); 
관련 문제