OpenOffice Java API를 사용하여 문서 섹션을 복사하여 다른 문서 섹션 위에 붙여 넣어야합니다. 지금까지 원본 문서 섹션의 텍스트를 복사하여 대상 문서의 섹션 위에 붙여 넣었습니다 (아래 예제 참조).OpenOffice Java API (UNO API)를 사용하여 ODT (Openoffice Writer) 문서 섹션을 다른 문서로 복사
그러나 문제는 텍스트가 아닌 요소 (그래픽, 형식, 표 등)가 대상 문서에 붙여지지 않는다는 것입니다.
// Read source file text
XComponent xComponentSource = this.ooHelper.loadDocument("file://" + fSource);
// Get sections
XTextSectionsSupplier textSectionsSupplierSource = (XTextSectionsSupplier)UnoRuntime.queryInterface(XTextSectionsSupplier.class, xComponentSource);
XNameAccess nameAccessSource = textSectionsSupplierOrigen.getTextSections();
// Get sections by name
XTextSection textSectionSource = (XTextSection)UnoRuntime.queryInterface(XTextSection.class, nameAccessOrigen.getByName("SeccEditable"));
//Get section text
String sectionSource = textSectionSource.getAnchor().getString();
은, 코드 섹션이 동일 선택 대상 섹션을 통해 텍스트를 붙여 넣으려면, 나는 문자열을 설정합니다
나는 소스 섹션의 텍스트를 추출하는 데 사용한 코드는 :
textSectionDest.getAnchor().setString(sectionSource);
API Javadoc을 읽었으며 전체 섹션을 복사하는 방법을 찾지 못했습니다. 그것을 할 방법이 있습니까?
이 OOOForum 자습서는 도움이됩니다. [내용을 가져 와서 다른 문서로 전송] (http://www.oooforum.org/forum/viewtopic.phtml?t=71000). –