Difference between revisions of "Documentation/DevGuide/Database/Document Links"
Line 10: | Line 10: | ||
Each data source can maintain an arbitrary number of document links. The primary purpose of this function is to provide a collection of database forms used with a database. | Each data source can maintain an arbitrary number of document links. The primary purpose of this function is to provide a collection of database forms used with a database. | ||
− | {{Note|This feature is highly deprecated and should not be used anymore. Since | + | {{Note|This feature is highly deprecated and should not be used anymore. Since OpenOffice.org 2.0.0, documents are stored within a database file, and not only linked from a data source.}} |
The links are available at the <idl>com.sun.star.sdb.XBookmarksSupplier</idl> interface of a data source that has one method: | The links are available at the <idl>com.sun.star.sdb.XBookmarksSupplier</idl> interface of a data source that has one method: | ||
− | + | <syntaxhighlight lang="idl"> | |
com::sun::star::container::XNameAccess getBookmarks() | com::sun::star::container::XNameAccess getBookmarks() | ||
− | </ | + | </syntaxhighlight> |
− | The returned service is a <idl>com.sun.star.sdb.DefinitionContainer</idl>. The <code>DefinitionContainer</code> is not only | + | The returned service is a <idl>com.sun.star.sdb.DefinitionContainer</idl>. The <code>DefinitionContainer</code> is not only a <code>XNameAccess</code>, but a <idl>com.sun.star.container.XNameContainer</idl>, that is, new links are added using <code>insertByName()</code> as described in the chapter [[Documentation/DevGuide/FirstSteps/First Steps|First Steps]]. Besides the name access, links are obtained through <idl>com.sun.star.container.XIndexAccess</idl> and <idl>com.sun.star.container.XEnumerationAccess</idl>. |
− | The returned bookmarks are simple strings containing URLs. Usually forms | + | The returned bookmarks are simple strings containing URLs. Usually forms are stored at ''file:///'' URLs. The following example adds a new document to the data source Bibliography: |
− | + | <syntaxhighlight lang="java"> | |
public static void addDocumentLink(XMultiServiceFactory _rMSF) throws com.sun.star.uno.Exception { | public static void addDocumentLink(XMultiServiceFactory _rMSF) throws com.sun.star.uno.Exception { | ||
XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface( | XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface( | ||
Line 40: | Line 40: | ||
xBookmarksContainer.insertByName("MyLink", "file:///home/ada01/Form_Ada01_DSADMIN.Table1.odt"); | xBookmarksContainer.insertByName("MyLink", "file:///home/ada01/Form_Ada01_DSADMIN.Table1.odt"); | ||
} | } | ||
− | + | </syntaxhighlight> | |
To load a linked document, use the bookmark URL with the method <code>loadComponentFromUrl()</code> at the <idl>com.sun.star.frame.XComponentLoader</idl> interface of the <idl>com.sun.star.frame.Desktop</idl> singleton that is available at the global service manager. For details about the Desktop, see [[Documentation/DevGuide/OfficeDev/Office Development|Office Development]]. | To load a linked document, use the bookmark URL with the method <code>loadComponentFromUrl()</code> at the <idl>com.sun.star.frame.XComponentLoader</idl> interface of the <idl>com.sun.star.frame.Desktop</idl> singleton that is available at the global service manager. For details about the Desktop, see [[Documentation/DevGuide/OfficeDev/Office Development|Office Development]]. | ||
Latest revision as of 13:54, 21 December 2020
- Forms and Reports
- Document Links
- Tables and Columns
Each data source can maintain an arbitrary number of document links. The primary purpose of this function is to provide a collection of database forms used with a database.
This feature is highly deprecated and should not be used anymore. Since OpenOffice.org 2.0.0, documents are stored within a database file, and not only linked from a data source. |
The links are available at the com.sun.star.sdb.XBookmarksSupplier interface of a data source that has one method:
com::sun::star::container::XNameAccess getBookmarks()
The returned service is a com.sun.star.sdb.DefinitionContainer. The DefinitionContainer
is not only a XNameAccess
, but a com.sun.star.container.XNameContainer, that is, new links are added using insertByName()
as described in the chapter First Steps. Besides the name access, links are obtained through com.sun.star.container.XIndexAccess and com.sun.star.container.XEnumerationAccess.
The returned bookmarks are simple strings containing URLs. Usually forms are stored at file:/// URLs. The following example adds a new document to the data source Bibliography:
public static void addDocumentLink(XMultiServiceFactory _rMSF) throws com.sun.star.uno.Exception { XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class,_rMSF.createInstance("com.sun.star.sdb.DatabaseContext")); // we use the predefined Bibliography data source XDataSource xDS = (XDataSource)UnoRuntime.queryInterface( XDataSource.class, xNameAccess.getByName("Bibliography")); // we need the XBookmarksSupplier interface of the data source XBookmarksSupplier xBookmarksSupplier = ( XBookmarksSupplier )UnoRuntime.queryInterface( XBookmarksSupplier.class, xDS); // get container with bookmark URLs XNameAccess xBookmarks = xBookmarksSupplier.getBookmarks(); XNameContainer xBookmarksContainer = (XNameContainer)UnoRuntime.queryInterface( XNameContainer.class, xBookmarks); // insert new link xBookmarksContainer.insertByName("MyLink", "file:///home/ada01/Form_Ada01_DSADMIN.Table1.odt"); }
To load a linked document, use the bookmark URL with the method loadComponentFromUrl()
at the com.sun.star.frame.XComponentLoader interface of the com.sun.star.frame.Desktop singleton that is available at the global service manager. For details about the Desktop, see Office Development.
Content on this page is licensed under the Public Documentation License (PDL). |