Hi Tobias,

I am using OpenOffice 2.0 and the OS is Windows XP Professional.

  XComponentContext xContext = null;
   try
   {

     xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
   }
   catch (BootstrapException ex)
   {
   }
   System.out.println("Connected to a running office ...");

   // Get the remote office service manager
   XMultiComponentFactory xMCF = xContext.getServiceManager();

    // Get the root frame (i.e. desktop) of openoffice framework.
   Object oDesktop = null;
   try
   {
     oDesktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
       xContext);
   }
   catch (com.sun.star.uno.Exception ex1)
   {
   }

  // Desktop has 3 interfaces. The XComponentLoader interface provides
ability to load
   // components.
   XComponentLoader xCompLoader = (XComponentLoader)
   UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,
oDesktop);

   // URL of the component to be loaded
   String sUrl = "file:/M:/Aloizio_SS/docExemplo.doc";

  // the boolean property Hidden tells the office to open a file in hidden
mode
  PropertyValue[] loadProps = new PropertyValue[1];
  loadProps[0] = new PropertyValue();
  loadProps[0].Name = "Hidden";
  loadProps[0].Value = new Boolean(true);


   // Load the document, which will be displayed. More param info in apidoc
   XComponent xComp = null;
   try
   {
     xComp = xCompLoader.loadComponentFromURL(sUrl, "_blank", 0,loadProps);
   }
   catch (java.lang.Exception ex2)
   {
     ex2.printStackTrace();
     System.out.print("Erro");
   }

   // Get the textdocument
   XTextDocument aTextDocument = (XTextDocument)UnoRuntime.queryInterface(
                 com.sun.star.text.XTextDocument.class, xComp);

   String storeUrl = "file:/M:/Aloizio_SS/docExemplo.rtf";
   XStorable xStorable =
(XStorable)UnoRuntime.queryInterface(XStorable.class, aTextDocument);
   PropertyValue[] storeProps = new PropertyValue[1];
   storeProps[0] = new PropertyValue();
   storeProps[0].Name = "FilterName";
   storeProps[0].Value = "Rich Text Format";

   xStorable.storeAsURL(storeUrl, storeProps);


-- 
View this message in context: 
http://www.nabble.com/Problem-to-convert-DOC-file-to-RTF-file-tf1920663.html#a5269135
Sent from the openoffice - api dev forum at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to