StimVinsh / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

ODF2XHTMLConverter+XWPF2XHTMLConverter doesn't populate the options like URIResolver. #78

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Since 0.9.4, it seems that 
fr.opensagres.xdocreport.converter.odt.odfdom.xhtml.ODF2XHTMLConverter doesn't 
populate correctly the options of the econvert( InputStream in, OutputStream 
out, Options options )

So there is a bug in the demo webapp 
http://xdocreport.opensagres.cloudbees.net/processReport.jsp when we wish 
convert report to html with a iframe preview (the image doesn't appears), 
because the URIResolver is not populated corretly.

Code is commented : 

/*
     * private XHTMLOptions toODFOptions(Options o) { XHTMLOptions options = XHTMLOptions.create(); final IURIResolver
     * resolver = (IURIResolver) o .getProperty(IURIResolver.class.getName()); if (resolver != null) {
     * options.URIResolver(new org.odftoolkit.odfdom.converter.IURIResolver() { public String resolve(String uri) {
     * return resolver.resolve(uri); } }); } return options; }
     */

There is the same problem with XWPF2XHTMLConverter.

@Leszek : could you explain me why you have commented this line? Is it possible 
for you to fix this problem?

Once you have fixed that (or if you explain me how to fix that), I will create 
JUNit.

Many thanks

Regards Angelo

Original issue reported on code.google.com by angelo.z...@gmail.com on 17 Feb 2012 at 4:35

GoogleCodeExporter commented 8 years ago
The mechanism has changed. You can set uri resolver directly in XHMLOptions 
using chaining methods - there is no need to set it via some key

This should work:
Options.getFrom(...).via(...).subOptions(XHTMLOptions.create().URIResolver(...))

Original comment by abe...@gmail.com on 17 Feb 2012 at 7:48

GoogleCodeExporter commented 8 years ago
@Angelo - did you try this new mechanism?
I don't consider this issue as a 'real' bug.

Original comment by abe...@gmail.com on 20 Feb 2012 at 9:18

GoogleCodeExporter commented 8 years ago
Hi Leszek,

Ok I understand this mechanism, but Options must support the old mecanism too 
because you must create an Options without knowing XHTMLOptions class. In 
webapp demo for instance, IURIResolver must be created and XHTMLOptions (from 
the odt and docx converter) is not knwown because as XDocReport is modular 
XHTMLOptions from the odt/docx converter could be not in the classpath.

In teh webapp demo, IURIResolver is created like this: 

----------------------------------------------------------
Options options = Options.getFrom( "ODT" );
        OptionsHelper.setURIResolver( options, new fr.opensagres.xdocreport.converter.IURIResolver()
        {

            public String resolve( String uri )
            {
                return null;
            }
        } );
----------------------------------------------------------

As you can see fr.opensagres.xdocreport.converter.IURIRseolver is generic (and 
don't belong to docx or odt converter).

I have modified the code to support the two mechanism 
(Options.getFrom(...).via(...).subOptions(XHTMLOptions.create().URIResolver(...)
)
 and the below mechanism).

I have created JUnit for that : 

 * http://code.google.com/p/xdocreport/source/browse/converter/fr.opensagres.xdocreport.converter.docx.xwpf/src/test/java/fr/opensagres/xdocreport/converter/docx/poi/itext/PDFViaITextOptionsTestCase.java
 * http://code.google.com/p/xdocreport/source/browse/converter/fr.opensagres.xdocreport.converter.docx.xwpf/src/test/java/fr/opensagres/xdocreport/converter/docx/poi/xhtml/XHTMLOptionsTestCase.java

 * http://code.google.com/p/xdocreport/source/browse/converter/fr.opensagres.xdocreport.converter.odt.odfdom/src/test/java/fr/opensagres/xdocreport/converter/odt/odfdom/itext/PDFViaITextOptionsTestCase.java
 * http://code.google.com/p/xdocreport/source/browse/converter/fr.opensagres.xdocreport.converter.odt.odfdom/src/test/java/fr/opensagres/xdocreport/converter/odt/odfdom/xhtml/XHTMLOptionsTestCase.java

So now the webapp demo is working with odt->xhtml and docx->xhtml to display 
image.

I have modified too your code to retrieve the system encoding that I have moved 
to 
http://code.google.com/p/xdocreport/source/browse/thirdparties-extension/fr.open
sagres.xdocreport.itext.extension/src/main/java/fr/opensagres/xdocreport/itext/e
xtension/font/AbstractFontRegistry.java to share it with docx+odt converter and 
I compute it once time.

If you are with my modification, you can close the bug.

Regards Angelo

Original comment by angelo.z...@gmail.com on 20 Feb 2012 at 10:01

GoogleCodeExporter commented 8 years ago
It's ok for me.

Original comment by abe...@gmail.com on 20 Feb 2012 at 11:05