Difference between revisions of "Documentation/DevGuide/Text/Saving Text Documents"
OOoWikiBot (Talk | contribs) m (Robot: Changing Category:Documentation/Developers Guide/Text Documents) |
OOoWikiBot (Talk | contribs) m (FINAL VERSION FOR L10N) |
||
Line 5: | Line 5: | ||
|NextPage=Documentation/DevGuide/Text/Printing Text Documents | |NextPage=Documentation/DevGuide/Text/Printing Text Documents | ||
}} | }} | ||
− | {{DISPLAYTITLE:Saving Text Documents}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/Text/{{SUBPAGENAME}}}} |
+ | {{DISPLAYTITLE:Saving Text Documents}} | ||
=== Storing === | === Storing === | ||
<!--<idltopic>com.sun.star.frame.XStorable</idltopic>--> | <!--<idltopic>com.sun.star.frame.XStorable</idltopic>--> |
Revision as of 10:07, 14 May 2009
Storing
Documents are storable through their interface com.sun.star.frame.XStorable. This interface is discussed in detail in Office Development. An XStorable
implements these operations:
boolean hasLocation() string getLocation() boolean isReadonly() void store() void storeAsURL( [in] string aURL, sequence< com::sun::star::beans::PropertyValue > aArgs) void storeToURL( [in] string aURL, sequence< com::sun::star::beans::PropertyValue > aArgs)
The method names are 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.
Exporting
For exporting purposes, a filter name can be passed to storeAsURL()
and storeToURL()
that triggers an export to other file formats. The property needed for this purpose is the string argument FilterName that takes filter names defined in the configuration file:
<OfficePath>\share\config\registry\instance\org\openoffice\Office\TypeDetection.xml
In TypeDetection.xml, look for <Filter/>
elements, their cfg:name
attribute contains the needed strings for FilterName
. The proper filter name for StarWriter 5.x is "StarWriter 5.0", and the export format "MS Word 97" is also popular. This is the element in TypeDetection.xml that describes the MS Word 97 filter:
<Filter cfg:name="MS Word 97"> <Installed cfg:type="boolean">true</Installed> <UIName cfg:type="string" cfg:localized="true"> <cfg:value xml:lang="en-US">Microsoft Word 97/2000/XP</cfg:value> </UIName> 3,writer_MS_Word_97,com.sun.star.text.TextDocument,,67,CWW8,0,, </Filter>
The following method stores a document using this filter:
/** Store a document, using the MS Word 97/2000/XP 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 = "MS Word 97"; xStorable.storeAsURL(storeUrl, storeProps); }
If an empty array of PropertyValue
structs is passed, the native .odt format of OpenOffice.org is used.
Content on this page is licensed under the Public Documentation License (PDL). |