Difference between revisions of "Documentation/DevGuide/Drawings/Storing"
OOoWikiBot (Talk | contribs) m (FINAL VERSION FOR L10N) |
|||
Line 10: | Line 10: | ||
<!--<idltopic>com.sun.star.frame.XStorable</idltopic>--> | <!--<idltopic>com.sun.star.frame.XStorable</idltopic>--> | ||
Documents are storable through their interface <idl>com.sun.star.frame.XStorable</idl>. The [[Documentation/DevGuide/OfficeDev/Office Development|Office Development]] discusses this in detail. An <code>XStorable</code> implements these operations: | Documents are storable through their interface <idl>com.sun.star.frame.XStorable</idl>. The [[Documentation/DevGuide/OfficeDev/Office Development|Office Development]] discusses this in detail. An <code>XStorable</code> implements these operations: | ||
− | + | <syntaxhighlight lang="java"> | |
boolean hasLocation() | boolean hasLocation() | ||
string getLocation() | string getLocation() | ||
Line 18: | Line 18: | ||
[in] sequence < com::sun::star::beans::PropertyValue > aArgs) | [in] sequence < com::sun::star::beans::PropertyValue > aArgs) | ||
void storeToURL( [in] string aURL, | void storeToURL( [in] string aURL, | ||
− | [in] sequence < com::sun::star::beans::PropertyValue > aArgs) | + | [in] sequence < com::sun::star::beans::PropertyValue > aArgs)</syntaxhighlight> |
The method names should be evident. The method <code>storeAsUrl()</code> is the exact representation of '''File - Save As''', that is, it changes the current document location. In contrast, <code>storeToUrl()</code> 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 {{PRODUCTNAME}} 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: | The method names should be evident. The method <code>storeAsUrl()</code> is the exact representation of '''File - Save As''', that is, it changes the current document location. In contrast, <code>storeToUrl()</code> 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 {{PRODUCTNAME}} 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: | ||
Line 25: | Line 25: | ||
In ''TypeDetection.xml'', find <code><Filter/></code> elements, their <code>cfg:name</code> attribute contains the required strings for <code>FilterName</code>. 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: | In ''TypeDetection.xml'', find <code><Filter/></code> elements, their <code>cfg:name</code> attribute contains the required strings for <code>FilterName</code>. 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: | ||
− | + | <syntaxhighlight lang="xml"> | |
<Filter cfg:name="StarDraw 5.0"> | <Filter cfg:name="StarDraw 5.0"> | ||
<Installed cfg:type="boolean">true</Installed> | <Installed cfg:type="boolean">true</Installed> | ||
Line 34: | Line 34: | ||
10,draw_StarDraw_50,com.sun.star.drawing.DrawingDocument,,268435559,,5050,, | 10,draw_StarDraw_50,com.sun.star.drawing.DrawingDocument,,268435559,,5050,, | ||
</Data> | </Data> | ||
− | </Filter> | + | </Filter></syntaxhighlight> |
The following method stores a document using this filter: | The following method stores a document using this filter: | ||
− | + | <syntaxhighlight lang="java"> | |
/** Store a document, using the StarDraw 5.0 Filter */ | /** Store a document, using the StarDraw 5.0 Filter */ | ||
protected void storeDocComponent(XComponent xDoc, String storeUrl) throws java.lang.Exception { | protected void storeDocComponent(XComponent xDoc, String storeUrl) throws java.lang.Exception { | ||
Line 46: | Line 46: | ||
storeProps[0].Value = "StarDraw 5.0"; | storeProps[0].Value = "StarDraw 5.0"; | ||
xStorable.storeAsURL(storeUrl, storeProps); | xStorable.storeAsURL(storeUrl, storeProps); | ||
− | } | + | }</syntaxhighlight> |
− | If an empty array of <code>PropertyValue</code> structs is passed, the native .odg format of {{ | + | If an empty array of <code>PropertyValue</code> structs is passed, the native .odg format of {{AOo}} is used. |
{{PDL1}} | {{PDL1}} | ||
[[Category:Documentation/Developer's Guide/Drawing Documents and Presentation Documents]] | [[Category:Documentation/Developer's Guide/Drawing Documents and Presentation Documents]] |
Latest revision as of 14:09, 20 December 2020
Documents are storable through their interface com.sun.star.frame.XStorable. 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 OpenOffice.org 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:
<OfficePath>\share\config\registry\instance\org\openoffice\Office\TypeDetection.xml
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> </UIName> <Data cfg:type="string"> 10,draw_StarDraw_50,com.sun.star.drawing.DrawingDocument,,268435559,,5050,, </Data> </Filter>
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 Apache OpenOffice is used.
Content on this page is licensed under the Public Documentation License (PDL). |