OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Converting .ODT to .Doc

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
maverick786us
General User
General User


Joined: 11 Jul 2012
Posts: 26

PostPosted: Tue Aug 07, 2012 3:27 am    Post subject: Converting .ODT to .Doc Reply with quote

I am using this code to convert .ODT file into .DOC. This whole code seems to work perfectly fine.

Code:

StartOpenOffice();

                unoidl.com.sun.star.uno.XComponentContext xLocalContext = uno.util.Bootstrap.bootstrap();
                unoidl.com.sun.star.lang.XMultiServiceFactory xRemoteFactory =
                                            (unoidl.com.sun.star.lang.XMultiServiceFactory)xLocalContext.getServiceManager();

                XComponentLoader aLoader = (XComponentLoader)xRemoteFactory.createInstance("com.sun.star.frame.Desktop");

                oWord.ActiveDocument.SaveAs(tempODTFile);
                oWord.ActiveDocument.Close();
               
                [b]XComponent xComponent = initDocument(aLoader, PathConverter(tempODTFile), "_blank");[/b]


Code:

private static void saveDocument(XComponent xComponent, string sourceFile, string destinationFile)
{
            PropertyValue[] propertyValues = new PropertyValue[1];
            propertyValues[0] = new PropertyValue();
            propertyValues[0].Name = "FilterName";
            propertyValues[0].Value = new uno.Any("MS Word 97");
            XStorable xcomponent1 = (xComponent) as XStorable;
            xcomponent1.storeToURL(destinationFile, propertyValues);
}


Now there is this experssion of initializing the document. I am using this expression to load the document

Code:

XComponent xComponent = aLoader.loadComponentFromURL(file, target, 0, openProps);


What is the procedure for releasing the document?
Back to top
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Tue Aug 07, 2012 7:13 am    Post subject: Reply with quote

Do you mean storetourl or storeasurl or something like this (in Java):

Code:
if doc.supportsService ("com.star.util.XCloseable") then
      doc.close True
   else
      doc.dispose
   end if

_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group