コード例 #1
0
  private void insertBookmark(XTextCursor crsr, String name, String content)
      throws com.sun.star.uno.Exception {
    XMultiServiceFactory xDocFactory =
        UnoRuntime.queryInterface(XMultiServiceFactory.class, m_xDoc);

    Object xBookmark = xDocFactory.createInstance("com.sun.star.text.Bookmark");
    XTextContent xBookmarkAsTextContent = UnoRuntime.queryInterface(XTextContent.class, xBookmark);
    crsr.setString(content);
    XNamed xBookmarkAsNamed = UnoRuntime.queryInterface(XNamed.class, xBookmark);
    xBookmarkAsNamed.setName(name);
    m_xDoc.getText().insertTextContent(crsr, xBookmarkAsTextContent, true);
  }
コード例 #2
0
 private void insertRefMark(
     OOComponentHelper ooHandle, XTextCursor thisCursor, String referenceName) {
   Object referenceMark = ooHandle.createInstance("com.sun.star.text.ReferenceMark");
   XNamed xRefMark = ooQueryInterface.XNamed(referenceMark);
   xRefMark.setName(referenceName);
   XTextContent xContent = ooQueryInterface.XTextContent(xRefMark);
   try {
     thisCursor.getText().insertTextContent(thisCursor, xContent, true);
   } catch (Exception ex) {
     log.error("insertReferenceMark :" + ex.getMessage());
   }
 }