Search in sources :

Example 1 with XTextSection

use of com.sun.star.text.XTextSection in project jabref by JabRef.

the class OOBibBase method clearBibTextSectionContent2.

private void clearBibTextSectionContent2() throws NoSuchElementException, WrappedTargetException, IllegalArgumentException, CreationException {
    // Check if the section exists:
    XTextSectionsSupplier supplier = UnoRuntime.queryInterface(XTextSectionsSupplier.class, mxDoc);
    if (supplier.getTextSections().hasByName(OOBibBase.BIB_SECTION_NAME)) {
        XTextSection section = (XTextSection) ((Any) supplier.getTextSections().getByName(OOBibBase.BIB_SECTION_NAME)).getObject();
        // Clear it:
        XTextCursor cursor = text.createTextCursorByRange(section.getAnchor());
        cursor.gotoRange(section.getAnchor(), false);
        cursor.setString("");
    } else {
        createBibTextSection2(atEnd);
    }
}
Also used : XTextSectionsSupplier(com.sun.star.text.XTextSectionsSupplier) XTextSection(com.sun.star.text.XTextSection) XTextCursor(com.sun.star.text.XTextCursor)

Example 2 with XTextSection

use of com.sun.star.text.XTextSection in project jabref by JabRef.

the class OOBibBase method populateBibTextSection.

private void populateBibTextSection(Map<BibEntry, BibDatabase> entries, OOBibStyle style) throws NoSuchElementException, WrappedTargetException, PropertyVetoException, UnknownPropertyException, UndefinedParagraphFormatException, IllegalArgumentException, CreationException {
    XTextSectionsSupplier supplier = UnoRuntime.queryInterface(XTextSectionsSupplier.class, mxDoc);
    XTextSection section = (XTextSection) ((Any) supplier.getTextSections().getByName(OOBibBase.BIB_SECTION_NAME)).getObject();
    XTextCursor cursor = text.createTextCursorByRange(section.getAnchor());
    OOUtil.insertTextAtCurrentLocation(text, cursor, (String) style.getProperty(OOBibStyle.TITLE), (String) style.getProperty(OOBibStyle.REFERENCE_HEADER_PARAGRAPH_FORMAT));
    insertFullReferenceAtCursor(cursor, entries, style, (String) style.getProperty(OOBibStyle.REFERENCE_PARAGRAPH_FORMAT));
    insertBookMark(OOBibBase.BIB_SECTION_END_NAME, cursor);
}
Also used : XTextSectionsSupplier(com.sun.star.text.XTextSectionsSupplier) XTextSection(com.sun.star.text.XTextSection) XTextCursor(com.sun.star.text.XTextCursor)

Aggregations

XTextCursor (com.sun.star.text.XTextCursor)2 XTextSection (com.sun.star.text.XTextSection)2 XTextSectionsSupplier (com.sun.star.text.XTextSectionsSupplier)2