Epoque51 schreef:
Hi,

I'm trying to use a java example (DocumentSaver.java ) from the SDK to save
a word.doc document to word.html format.
I actually modified only this in the example :

           propertyValue[1] = new PropertyValue();
           propertyValue[1].Name = "FilterName";
           propertyValue[1].Value = "swriter: HTML (StarWriter)";
For making HTML out of OO: use Henrik Just Writer2Latex who is far most the best HTML exportFilter. In basic it sound like "oDocument.storeToURL( ConvertToURL(sFile), Array( MakePropertyValue("FilterName", "XHTML 1.0 strict File" )) "

For the moment W2L handels only Linked (not embedded images) Henrik is working on a export off embedded Images with a document -INdepended output directory. I personaly use the API to do a export off the embedded images and change the links to external-links so the HTML is no longer depended to any directory structure

Hope it helps

Fernand
And It's almost working but unfortunately, when I have some pictures into
word.doc, IMG html tags into word.html are not correct as the conversion
writes :

<IMG SRC="../word_html_m47c3a3cd.png">

instead of :

<IMG SRC="word_html_m47c3a3cd.png">

(work.html and word_html_m47c3a3cd.png are actually in the same directory)

Does anybody know how to correct this ?

I would be grateful if you could help me

thx

Here you can find the code :

import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.AnyConverter;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XStorable;
import com.sun.star.util.XCloseable;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.bridge.XUnoUrlResolver;

/** The purpose of this class is to open a specified text document and save
this
* file to a specified URL. The type of the saved file is
* "swriter: HTML (StarWriter)".
*/
public class DocumentSaver {
   /** The main method of the application.
    * @param args The program needs two arguments:
    * - full file name to open,
    * - full file name to save.
    */
   public static void main(String args[]) {
       if ( args.length < 2 ) {
           System.out.println("usage: java -jar DocumentSaver.jar" +
                              "\"<URL|path to load>\" \"<URL|path to
save>\"");
           System.out.println("\ne.g.:");
           System.out.println("java -jar DocumentSaver " +
                              "\"file:///f:/TestPrint.doc\"" +
                              "\"file:///f:/TestPrint.html\"");
           System.exit(1);
       }

       com.sun.star.uno.XComponentContext xContext = null;

       try {
           // get the remote office component context
           xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
           System.out.println("Connected to a running office ...");

           // get the remote office service manager
           com.sun.star.lang.XMultiComponentFactory xMCF =
xContext.getServiceManager();

           Object oDesktop = xMCF.createInstanceWithContext("
com.sun.star.frame.Desktop", xContext);

           XComponentLoader xCompLoader =
(XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class,
oDesktop);

           java.io.File sourceFile = new java.io.File(args[0]);
           StringBuffer sLoadUrl = new StringBuffer("file:///");
           sLoadUrl.append(sourceFile.getCanonicalPath().replace('\\',
'/'));

           sourceFile = new java.io.File(args[1]);
           StringBuffer sSaveUrl = new StringBuffer("file:///");
           sSaveUrl.append(sourceFile.getCanonicalPath().replace('\\',
'/'));

           PropertyValue[] propertyValue = new PropertyValue[1];
           propertyValue[0] = new com.sun.star.beans.PropertyValue();
           propertyValue[0].Name = "Hidden";
           propertyValue[0].Value = new Boolean(true);

           Object oDocToStore = xCompLoader.loadComponentFromURL(
sLoadUrl.toString(), "_blank", 0, propertyValue );

           XStorable xStorable = (XStorable)UnoRuntime.queryInterface(
XStorable.class, oDocToStore );

           propertyValue = new PropertyValue[ 2 ];
           propertyValue[0] = new PropertyValue();
           propertyValue[0].Name = "Overwrite";
           propertyValue[0].Value = new Boolean(true);
           propertyValue[1] = new PropertyValue();
           propertyValue[1].Name = "FilterName";
           propertyValue[1].Value = "swriter: HTML (StarWriter)";

           xStorable.storeToURL( sSaveUrl.toString(), propertyValue );

System.out.println("\nDocument \"" + sLoadUrl + "\" saved under
\"" +
                              sSaveUrl + "\"\n");

           XCloseable xCloseable = (XCloseable)UnoRuntime.queryInterface(
XCloseable.class, oDocToStore);

           if (xCloseable != null ) {
               xCloseable.close(false);
           } else
           {
               XComponent xComp = (XComponent)UnoRuntime.queryInterface(
XComponent.class, oDocToStore );
               xComp.dispose();
           }


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

Reply via email to