Difference between revisions of "Documentation/DevGuide/Database/Document Links"
m (1 revision(s)) |
m |
||
Line 12: | Line 12: | ||
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: | ||
− | + | <source lang="idl"> | |
com::sun::star::container::XNameAccess getBookmarks() | com::sun::star::container::XNameAccess getBookmarks() | ||
− | + | </source> | |
The returned service is a <idl>com.sun.star.sdb.DefinitionContainer</idl>. The <code>DefinitionContainer</code> is not only an <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 service is a <idl>com.sun.star.sdb.DefinitionContainer</idl>. The <code>DefinitionContainer</code> is not only an <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 are are stored at ''file:///'' URLs. The following example adds a new document to the data source Bibliography: | The returned bookmarks are simple strings containing URLs. Usually forms are are stored at ''file:///'' URLs. The following example adds a new document to the data source Bibliography: | ||
− | + | <source 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 39: | Line 39: | ||
xBookmarksContainer.insertByName("MyLink", "file:///home/ada01/Form_Ada01_DSADMIN.Table1.odt"); | xBookmarksContainer.insertByName("MyLink", "file:///home/ada01/Form_Ada01_DSADMIN.Table1.odt"); | ||
} | } | ||
− | + | </source> | |
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]]. | ||
{{PDL1}} | {{PDL1}} | ||
[[Category: Database Access]] | [[Category: Database Access]] |
Revision as of 10:28, 19 April 2008
- 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.
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 an 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 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). |