Difference between revisions of "Documentation/DevGuide/Database/Document Links"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (FINAL VERSION FOR L10N)
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.  
  
{{Documentation/Note|This feature is highly deprecated and should not be used anymore. Since {{PRODUCTNAME}} {{OO2.0.0}}, documents are stored within a database file, and not only linked from a data source.}}
+
{{Note|This feature is highly deprecated and should not be used anymore. Since {{PRODUCTNAME}} {{OO2.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:

Revision as of 16:20, 3 July 2018



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.

Documentation note.png This feature is highly deprecated and should not be used anymore. Since OpenOffice.org 2.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 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).
Personal tools
In other languages