Post on 15-Jun-2015
2. UNO based ODF Toolkit API
3. What we have ODF OpenOffice.org Idea Vision 4. What we have the vision 5.
What we have 6.
Why UNO 7.
What it could be tomorrow 8.
What it could be tomorrow 9. What it could be tomorrow document creation // create an empty TextDocument org.openoffice.uodft.text.XTextDocument xDoc =org.openoffice.uodft.text.TextDocument.create(xContext); // load an TextDocument try { org.openoffice.uodft.text.XTextDocument xDoc =org.openoffice.uodft.text.TextDocument.load(xContext, "file:///somewhere/HelloODFToolkit.odt"); } catch (org.openoffice.uodft.document.DocumentError e) { // do some error handling } Fake: this API's does not exist! 10. What it could be tomorrow document saving try { XTextDocument xDoc = ... // do some manipulation // save a TextDocument xDoc.save(); // save under a new name xDoc.saveAs("file:///somewhere/newname.odt"); } catch (org.openoffice.uodft.document.DocumentError e) { // do some error handling } Fake: this API's does not exist! 11. What it could be tomorrow adding content try { // append a string at the end xDoc.append("Hello UNO based ODF Toolkit!"); // new line should be interpreted as paragraph end xDoc.append(" When can we use this API?"); // append new a Paragraph Paragraph para = text.Paragraph.createWithString(xContext, "a paragraph can be created directly with a string"); xDoc.appendContent(para); } catch ( ... ) {// do some error handling} Fake: this API's does not exist! 12. What it could be tomorrow adding content try { // create a new ParagraphStyle ParagraphStyle myStyle = text.ParagraphStyle.create( xContext, "MyStyleName"); newStyle.setCategory(ParagrpahStyleCategory.LIST); // set more style specific attribtues newStyle.setXXX(...); // append a new Paragraph Paragraph para = text.Paragraph.createWithStyle( xContext, "some text", myStyle); para.append(" and more text for this paragraph."); xDoc.appendContent(para); } catch ( ... ) {// do some error handling} Fake: this API's does not exist! 13. What it could be tomorrow adding content try { // append a new graphic object TextGraphicObject graphic = text.TextGraphicObject.create( xContext, "file:///somewhere/picture.png", false); // set some attributes graphic.setSize(8000, 5000); graphic.setTransparency(80); graphic.setMargin(5); xDoc.appendContent(graphic); } catch ( ... ) {// do some error handling} Fake: this API's does not exist! 14. What it could be tomorrow manipulate content try { // get navigation cursor XParagraphCursor xCursor = xDoc.getParagraphCursor(); xCursor.gotoStart(false); do { if (xCursor.getParagraph().getText().equals("...")) xCursor.getParagraph().setStyle( xDoc.getStyleManager().getStyleByName("MyStyle")); } while (xCursor.gotoNextParagraph(false); } catch ( ... ) {// do some error handling} Fake: this API's does not exist! 15. What it could be tomorrow manipulate content try { // get navigation cursor XParagraphCursor xCursor = xDoc.getParagraphCursor(); xCursor.gotoStart(false); do { if (xCursor.getParagraph().getText().equals("...")) xCursor.getParagraph().setStyle( xDoc.getStyleManager().getStyleByName("MyStyle")); } while (xCursor.gotoNextParagraph(false); } catch ( ... ) {// do some error handling} Fake: this API's does not exist! 16. What it could be tomorrow manipulate content try { // create a new empty Spreadsheet document XSpreadsheetDocument xDoc = XSpreadsheetDocument.create(xContext); // insert a new Sheet by index xDoc.insertSheet(3, "MySheet"); // manipulate cells by index xDoc.getCell("B", 50).setString("Result"); xDoc.getCell("B", 51).setFormula("=sum(A1:A45"); } catch ( ... ) {// do some error handling} Fake: this API's does not exist! 17. What it could be tomorrow manipulate content try { long[] data = { 2,4,5,8,89,56 }; long[][] matrix = { { 2,4,5,8,89,56 }, { 5,67,7,8,99,4 } }; // set data array in a row, address Sheet directxDoc.setData(1, "B2", data); // set data array in a column, get Sheet first by indexxDoc.getSheet(3).setData("2B", data); // set data array in a column, address Sheet direct xDoc.setDataMatrix(1, "B2", matrix); } catch ( ... ) {// do some error handling} Fake: this API's does not exist! 18.
Summary 19. Q & A 20. UNO basedODF Toolkit API