From Apache OpenOffice Wiki
Jump to: navigation, search

Documents are storable through their interface The Office Development discusses this in detail. An XStorable implements these operations:

 boolean hasLocation()
 string getLocation()
 boolean isReadonly()
 void store() 
 void storeAsURL( [in] string aURL, 
     [in] sequence < com::sun::star::beans::PropertyValue > aArgs)
 void storeToURL( [in] string aURL, 
     [in] sequence < com::sun::star::beans::PropertyValue > aArgs)

The method names should be evident. The method storeAsUrl() is the exact representation of File - Save As, that is, it changes the current document location. In contrast, storeToUrl() stores a copy to a new location, but leaves the current document URL untouched. There are also store arguments. A filter name can be passed that tells to use older StarOffice Draw file formats. Exporting is a different matter as shown below. The property needed is FilterName which is a string argument that takes filter names defined in the configuration file:


In TypeDetection.xml, find <Filter/> elements, their cfg:name attribute contains the required strings for FilterName. The correct filter name for StarDraw 5.x files is "StarDraw 5.0". The following is the element in TypeDetection.xml that describes the StarDraw 5.0 document filter:

 <Filter cfg:name="StarDraw 5.0">
     <Installed cfg:type="boolean">true</Installed>
     <UIName cfg:type="string" cfg:localized="true">
         <cfg:value xml:lang="en-US">StarDraw 5.0</cfg:value>

The following method stores a document using this filter:

 /** Store a document, using the StarDraw 5.0 Filter */
 protected void storeDocComponent(XComponent xDoc, String storeUrl) throws java.lang.Exception {
     XStorable xStorable = (XStorable)UnoRuntime.queryInterface(XStorable.class, xDoc);
     PropertyValue[] storeProps = new PropertyValue[1];
     storeProps[0] = new PropertyValue();
     storeProps[0].Name = "FilterName";
     storeProps[0].Value = "StarDraw 5.0"; 
     xStorable.storeAsURL(storeUrl, storeProps); 

If an empty array of PropertyValue structs is passed, the native .odg format of is used.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages