use of com.sun.star.text.XTextCursor in project jabref by JabRef.
the class OOBibBase method italicizeOrBold.
private void italicizeOrBold(XTextCursor position, boolean italicize, int start, int end) throws UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException {
XTextRange range = position.getStart();
XTextCursor cursor = position.getText().createTextCursorByRange(range);
cursor.goRight((short) start, false);
cursor.goRight((short) (end - start), true);
XPropertySet xcp = UnoRuntime.queryInterface(XPropertySet.class, cursor);
if (italicize) {
xcp.setPropertyValue("CharPosture", com.sun.star.awt.FontSlant.ITALIC);
} else {
xcp.setPropertyValue("CharWeight", com.sun.star.awt.FontWeight.BOLD);
}
}
use of com.sun.star.text.XTextCursor in project zotero-libreoffice-integration by zotero.
the class ReferenceMark method delete.
public void delete() throws Exception {
if (isWholeRange()) {
((XComponent) UnoRuntime.queryInterface(XComponent.class, text)).dispose();
} else {
XTextCursor dupRange = text.createTextCursorByRange(range);
text.removeTextContent(textContent);
range = dupRange;
// dispose of a Bookmark or TextSection
if (isDisposable) {
((XComponent) UnoRuntime.queryInterface(XComponent.class, textContent)).dispose();
}
}
}
use of com.sun.star.text.XTextCursor in project zotero-libreoffice-integration by zotero.
the class ReferenceMark method prepareMultiline.
protected void prepareMultiline() throws Exception {
if (!isTextSection) {
// need to convert to TextSection
delete();
// if this is not done, it's hard to add text after the TextSection
if (doc.textRangeCompare.compareRegionEnds(doc.text.getEnd(), range.getEnd()) == 0) {
doc.text.insertControlCharacter(doc.text.getEnd(), ControlCharacter.PARAGRAPH_BREAK, false);
doc.text.insertControlCharacter(doc.text.getEnd(), ControlCharacter.PARAGRAPH_BREAK, false);
XTextCursor cursor = doc.text.createTextCursorByRange(doc.text.getEnd());
cursor.goLeft((short) 1, false);
cursor.goLeft((short) 1, true);
range = cursor;
}
named = (XNamed) UnoRuntime.queryInterface(XNamed.class, doc.docFactory.createInstance("com.sun.star.text.TextSection"));
named.setName(rawCode);
textContent = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, named);
textContent.attach(range);
isTextSection = true;
isDisposable = true;
}
}
use of com.sun.star.text.XTextCursor in project zotero-libreoffice-integration by zotero.
the class ReferenceMark method select.
public void select() throws Exception {
XTextCursor cursor = doc.getSelection();
cursor.gotoRange(range, false);
if (isTextSection) {
cursor.goLeft((short) 1, true);
}
}
use of com.sun.star.text.XTextCursor in project zotero-libreoffice-integration by zotero.
the class Document method insertField.
public ReferenceMark insertField(String fieldType, int noteType) throws Exception {
// duplicate selection cursor
XTextViewCursor selectionCursor = getSelection();
XTextCursor rangeToInsert = (XParagraphCursor) UnoRuntime.queryInterface(XParagraphCursor.class, selectionCursor.getText().createTextCursorByRange(selectionCursor));
return insertMarkAtRange(fieldType, noteType, rangeToInsert, null, null);
}
Aggregations