Java sidebar extensions and LibreOffice

fma fma3110 at gmail.com
Tue Feb 10 05:52:57 PST 2015


I found it!!!
Still don't know what's going on behind the scenes, but at least the panel
is now visible.
In the build path of the extension, I changed the pointing of *unoil.jar*
from the file included in the path of AOO installation (
/<aoo_installation_path>\program\classes/ ) to the one in the installation
path of LO ( /<aoo_installation_path>\program\classes/ ).
This raised an error in *AnalogClockPanel.java*, which was asking for adding
the unimplemented method *getMinimalWidth()*: I added it, generated the oxt
file and...  Voila!... the extension now runs fine on LO 4.4 too.
Unfortunately, I have now two problems with my custom extension, which
manipulates in several ways the active text document.
In details, I have two operations running fine in AOO 4.1.1 but having
unexpected results in LO 4.4; here they are:

*Code snippet 1 *- expected behaviour: formatting the whole document with
font Arial Black, size 14, justified; current behaviour: only the last
paragraph is formatted

/// active writer document
XTextDocument xTextDocument = (XTextDocument)
UnoRuntime.queryInterface(XTextDocument.class, xCurrentComponent);

// creating text range and cursor
XText xText = xTextDocument.getText();
XTextRange xTextRange = xText.createTextCursor();

// going to the end of document
((XTextCursor)xTextRange).gotoEnd(true);

// getting properties
XPropertySet xTextProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xTextRange);

// setting font size
xTextProps.setPropertyValue("CharHeight", new Float(14));

// justifying
xTextProps.setPropertyValue("ParaAdjust",com.sun.star.style.ParagraphAdjust.BLOCK);

// setting font
xTextProps.setPropertyValue("CharFontName", "Arial Black");
/

*Code snippet 2* - expected behaviour: inserting a page break just before
each paragraph starting with the word "Chapter"; current behaviour: nothing
happens

/XTextCursor xTextCursor = xText.createTextCursor();

// using a search descriptor to perform insert operations
XSearchable xSearchable = (XSearchable)
UnoRuntime.queryInterface(XSearchable.class, xTextDocument);
XSearchDescriptor xSearchDescriptor = xSearchable.createSearchDescriptor(); 

xSearchDescriptor.setPropertyValue("SearchRegularExpression", new
Boolean(true));
xSearchDescriptor.setPropertyValue("SearchCaseSensitive", new
Boolean(true));
xSearchDescriptor.setSearchString("Chapter");

XInterface xInterface= (XInterface)
xSearchable.findFirst(xSearchDescriptor); 
while (xInterface != null){

XTextRange xStart = (com.sun.star.text.XTextRange)
UnoRuntime.queryInterface(com.sun.star.text.XTextRange.class, xInterface); 

xTextCursor.gotoRange(xStart, false); 

XPropertySet cursorProperty = UnoRuntime.queryInterface(XPropertySet.class,
xTextCursor);    

cursorProperty.setPropertyValue("BreakType", BreakType.PAGE_BEFORE);
//$NON-NLS-1$

xInterface = (XInterface) xSearchable.findNext(xInterface,
xSearchDescriptor); 
} /

Any ideas about the reasons of the misbehaviour?
Thanks in advance and best regards



--
View this message in context: http://nabble.documentfoundation.org/Java-sidebar-extensions-and-LibreOffice-tp4139084p4139618.html
Sent from the Dev mailing list archive at Nabble.com.


More information about the LibreOffice mailing list