diff options
author | Hossein <hossein@libreoffice.org> | 2024-03-10 22:14:39 +0100 |
---|---|---|
committer | Hossein <hossein@libreoffice.org> | 2024-03-11 00:14:32 +0100 |
commit | 93c5a2513c7cb2f737a0e1f8de0b101bdc6337d4 (patch) | |
tree | 3cf60bdda08c044a58ad90b155abcaf8695653cd /odk | |
parent | 0783eeba65ec51051d072b6d4c6d32b3b45bee61 (diff) |
Enable commented part in HelloTextTableShape.java
Commented code in the HelloTextTableShape.java example demonstrates the
use of bookmarks. This part is now enabled.
Change-Id: Iace525be0d53b01bed8b5a6a123384a678d1d761
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164636
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
Diffstat (limited to 'odk')
-rw-r--r-- | odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape/java/HelloTextTableShape.java | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape/java/HelloTextTableShape.java b/odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape/java/HelloTextTableShape.java index 66bb2d8d6420..2ea20e61b61f 100644 --- a/odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape/java/HelloTextTableShape.java +++ b/odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape/java/HelloTextTableShape.java @@ -46,6 +46,7 @@ import com.sun.star.text.XTextDocument; import com.sun.star.text.XText; import com.sun.star.text.XTextCursor; import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextRange; import com.sun.star.table.XCellRange; import com.sun.star.table.XCell; import com.sun.star.table.TableBorder; @@ -58,6 +59,10 @@ import com.sun.star.container.XIndexAccess; import com.sun.star.drawing.XDrawPagesSupplier; import com.sun.star.drawing.XDrawPageSupplier; import com.sun.star.drawing.XDrawPage; +import com.sun.star.container.XNamed; +import com.sun.star.text.XBookmarksSupplier; +import com.sun.star.text.XTextTablesSupplier; +import com.sun.star.container.XNameAccess; public class HelloTextTableShape { @@ -139,7 +144,7 @@ public class HelloTextTableShape { manipulateText(xShapeText); manipulateShape(xWriterShape); -/* more code snippets used in the manual: + // more code snippets used in the manual: Object bookmark = xWriterFactory.createInstance ( "com.sun.star.text.Bookmark" ); // name the bookmark @@ -150,22 +155,18 @@ public class HelloTextTableShape { // get XTextContent interface and insert it at the end of the document XTextContent xTextContent = (XTextContent) UnoRuntime.queryInterface ( XTextContent.class, bookmark ); - //mxDocText.insertTextContent ( mxDocText.getEnd(), xTextContent, false ); xText.insertTextContent ( xText.getEnd(), xTextContent, false ); - //query BookmarksSupplier - XBookmarksSupplier xBookmarksSupplier = (XBookmarksSupplier)UnoRuntime.queryInterface( - XBookmarksSupplier.class, xWriterComponent); - XNameAccess xNamedBookmarks = xBookmarksSupplier.getBookmarks(); - Object foundBookmark = xNamedBookmarks.getByName("MyUniqueBookmarkName"); - XTextContent xFoundBookmark = (XTextContent)UnoRuntime.queryInterface(XTextContent.class, foundBookmark); - XTextRange xFound = xFoundBookmark.getAnchor(); - xFound.setString(" The throat mike, glued to her neck, " + //query BookmarksSupplier + XBookmarksSupplier xBookmarksSupplier = (XBookmarksSupplier)UnoRuntime.queryInterface( + XBookmarksSupplier.class, xWriterComponent); + XNameAccess xNamedBookmarks = xBookmarksSupplier.getBookmarks(); + Object foundBookmark = xNamedBookmarks.getByName("MyUniqueBookmarkName"); + XTextContent xFoundBookmark = (XTextContent)UnoRuntime.queryInterface(XTextContent.class, foundBookmark); + XTextRange xFound = xFoundBookmark.getAnchor(); + xFound.setString(" The throat mike, glued to her neck, " + "looked as much as possible like an analgesic dermadisk."); - - - // first query the XTextTablesSupplier interface from our document XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface( XTextTablesSupplier.class, xWriterComponent); @@ -187,7 +188,6 @@ public class HelloTextTableShape { XPropertySet.class, table); xTableProps.setPropertyValue("BackColor", Integer.valueOf(0xC8FFB9)); } - */ } catch( com.sun.star.lang.DisposedException e ) { //works from Patch 1 xRemoteContext = null; |