[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - desktop/source include/LibreOfficeKit sd/CppunitTest_sd_import_tests.mk sdext/source sd/qa

Mihai Varga mihai.varga at collabora.com
Thu Feb 26 08:50:38 PST 2015


 desktop/source/lib/init.cxx                           |   17 +++++-
 include/LibreOfficeKit/LibreOfficeKit.h               |    3 +
 include/LibreOfficeKit/LibreOfficeKit.hxx             |   11 +++-
 sd/CppunitTest_sd_import_tests.mk                     |    2 
 sd/qa/unit/data/pdf/txtpic.pdf                        |binary
 sd/qa/unit/import-tests.cxx                           |   43 ++++++++++++++++
 sd/qa/unit/sdmodeltestbase.hxx                        |   12 +++-
 sdext/source/pdfimport/inc/wrapper.hxx                |    6 +-
 sdext/source/pdfimport/pdfiadaptor.cxx                |   15 ++++-
 sdext/source/pdfimport/pdfiadaptor.hxx                |    3 -
 sdext/source/pdfimport/wrapper/wrapper.cxx            |   14 +++--
 sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |   46 +++++++++++++++++-
 sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx |    2 
 sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx    |   20 ++++++-
 14 files changed, 170 insertions(+), 24 deletions(-)

New commits:
commit 5e71cbe3f9a8c70e5c36570ff530c3fe30e825e1
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Wed Feb 25 10:20:56 2015 +0200

    SkipImages option for PDF import
    
    This option allows images and drawings to be skipped while importing
    a PDF, the main reason was performance improvement where images were
    not needed.
    And I've also added unit tests for it.
    
    Change-Id: I6595d3ff22d5389eab4fe8450460d083f626d216
    Reviewed-on: https://gerrit.libreoffice.org/14628
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ce32535..fa1662e 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -238,6 +238,9 @@ static void                    lo_destroy       (LibreOfficeKit* pThis);
 static int                     lo_initialize    (LibreOfficeKit* pThis, const char* pInstallPath);
 static LibreOfficeKitDocument* lo_documentLoad  (LibreOfficeKit* pThis, const char* pURL);
 static char *                  lo_getError      (LibreOfficeKit* pThis);
+static LibreOfficeKitDocument* lo_documentLoadWithOptions  (LibreOfficeKit* pThis,
+                                                            const char* pURL,
+                                                            const char* pOptions);
 
 struct LibLibreOffice_Impl : public _LibreOfficeKit
 {
@@ -253,6 +256,7 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit
             m_pOfficeClass->destroy = lo_destroy;
             m_pOfficeClass->documentLoad = lo_documentLoad;
             m_pOfficeClass->getError = lo_getError;
+            m_pOfficeClass->documentLoadWithOptions = lo_documentLoadWithOptions;
 
             gOfficeClass = m_pOfficeClass;
         }
@@ -279,6 +283,11 @@ static uno::Reference<css::lang::XMultiComponentFactory> xFactory;
 
 static LibreOfficeKitDocument* lo_documentLoad(LibreOfficeKit* pThis, const char* pURL)
 {
+    return lo_documentLoadWithOptions(pThis, pURL, NULL);
+}
+
+static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis, const char* pURL, const char* pOptions)
+{
     LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
 
     OUString aURL = getAbsoluteURL(pURL);
@@ -291,10 +300,15 @@ static LibreOfficeKitDocument* lo_documentLoad(LibreOfficeKit* pThis, const char
 
     try
     {
+        uno::Sequence<css::beans::PropertyValue> aFilterOptions(1);
+        aFilterOptions[0] = css::beans::PropertyValue( OUString("FilterOptions"),
+                                                       0,
+                                                       uno::makeAny(OUString::createFromAscii(pOptions)),
+                                                       beans::PropertyState_DIRECT_VALUE);
         uno::Reference<lang::XComponent> xComponent;
         xComponent = xComponentLoader->loadComponentFromURL(
                                             aURL, OUString("_blank"), 0,
-                                            uno::Sequence<css::beans::PropertyValue>());
+                                            aFilterOptions);
 
         if (xComponent.is())
             return new LibLODocument_Impl(xComponent);
@@ -309,7 +323,6 @@ static LibreOfficeKitDocument* lo_documentLoad(LibreOfficeKit* pThis, const char
 
     return NULL;
 }
-
 static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const char* pFormat, const char* pFilterOptions)
 {
     LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index d7b8e41..fbf4001 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -64,6 +64,9 @@ struct _LibreOfficeKitClass
   void                    (*destroy)       (LibreOfficeKit *pThis);
   LibreOfficeKitDocument* (*documentLoad)  (LibreOfficeKit *pThis, const char *pURL);
   char*                   (*getError)      (LibreOfficeKit *pThis);
+  LibreOfficeKitDocument* (*documentLoadWithOptions)  (LibreOfficeKit* pThis,
+                                                       const char* pURL,
+                                                       const char* pOptions);
 };
 
 #define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index f1255f4..d58e071 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -105,11 +105,18 @@ public:
         mpThis->pClass->destroy(mpThis);
     }
 
-    inline Document* documentLoad(const char* pUrl)
+    inline Document* documentLoad(const char* pUrl, const char* pFilterOptions = NULL)
     {
-        LibreOfficeKitDocument* pDoc = mpThis->pClass->documentLoad(mpThis, pUrl);
+        LibreOfficeKitDocument* pDoc = NULL;
+
+        if (LIBREOFFICEKIT_HAS(mpThis, documentLoadWithOptions))
+            pDoc = mpThis->pClass->documentLoadWithOptions(mpThis, pUrl, pFilterOptions);
+        else
+            pDoc = mpThis->pClass->documentLoad(mpThis, pUrl);
+
         if (pDoc == NULL)
             return NULL;
+
         return new Document(pDoc);
     }
 
diff --git a/sd/CppunitTest_sd_import_tests.mk b/sd/CppunitTest_sd_import_tests.mk
index e065850..994c756 100644
--- a/sd/CppunitTest_sd_import_tests.mk
+++ b/sd/CppunitTest_sd_import_tests.mk
@@ -77,6 +77,7 @@ $(eval $(call gb_CppunitTest_use_components,sd_import_tests,\
     embeddedobj/util/embobj \
     filter/source/config/cache/filterconfig1 \
     filter/source/svg/svgfilter \
+    filter/source/xmlfilteradaptor/xmlfa \
     forms/util/frm \
     framework/util/fwk \
     i18npool/util/i18npool \
@@ -88,6 +89,7 @@ $(eval $(call gb_CppunitTest_use_components,sd_import_tests,\
     sd/util/sd \
     sd/util/sdfilt \
     sd/util/sdd \
+    sdext/source/pdfimport/pdfimport \
     sfx2/util/sfx \
     sot/util/sot \
     svl/source/fsstor/fsstorage \
diff --git a/sd/qa/unit/data/pdf/txtpic.pdf b/sd/qa/unit/data/pdf/txtpic.pdf
new file mode 100644
index 0000000..220c582
Binary files /dev/null and b/sd/qa/unit/data/pdf/txtpic.pdf differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index acb2bb6..d374c73 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -23,6 +23,8 @@
 #include <editeng/postitem.hxx>
 #include <rsc/rscsfx.hxx>
 
+#include <sfx2/sfxsids.hrc>
+#include <svl/stritem.hxx>
 #include <svx/svdotext.hxx>
 #include <svx/svdoashp.hxx>
 #include <svx/svdograf.hxx>
@@ -92,8 +94,11 @@ public:
     void testShapeLineStyle();
     void testBnc862510_6();
     void testBnc862510_7();
+    void testPDFImport();
+    void testPDFImportSkipImages();
 
     CPPUNIT_TEST_SUITE(SdImportTest);
+
     CPPUNIT_TEST(testDocumentLayout);
     CPPUNIT_TEST(testSmoketest);
     CPPUNIT_TEST(testN759180);
@@ -123,6 +128,7 @@ public:
     CPPUNIT_TEST(testShapeLineStyle);
     CPPUNIT_TEST(testBnc862510_6);
     CPPUNIT_TEST(testBnc862510_7);
+    CPPUNIT_TEST(testPDFImport);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -1068,6 +1074,43 @@ void SdImportTest::testBnc862510_7()
     xDocShRef->DoClose();
 }
 
+void SdImportTest::testPDFImport()
+{
+    ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pdf/txtpic.pdf"), PDF);
+    SdDrawDocument *pDoc = xDocShRef->GetDoc();
+    CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+    uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
+    uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
+    CPPUNIT_ASSERT_MESSAGE( "no exactly two shapes", xPage->getCount() == 2 );
+
+    uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
+    CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape.is() );
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
+    CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
+
+    xDocShRef->DoClose();
+}
+
+void SdImportTest::testPDFImportSkipImages()
+{
+    SfxAllItemSet *pParams = new SfxAllItemSet( SfxGetpApp()->GetPool() );
+    pParams->Put( SfxStringItem ( SID_FILE_FILTEROPTIONS, OUString("SkipImages") ) );
+
+    ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pdf/txtpic.pdf"), PDF, pParams);
+    SdDrawDocument *pDoc = xDocShRef->GetDoc();
+    CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+    uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
+    uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
+    CPPUNIT_ASSERT_MESSAGE( "no exactly one shape", xPage->getCount() == 1 );
+
+    uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
+    CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape.is() );
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
+    CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index b1472ce..583fe09 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -23,6 +23,7 @@
 #include <rtl/strbuf.hxx>
 #include <sfx2/docfile.hxx>
 #include <sfx2/docfilt.hxx>
+#include <svl/itemset.hxx>
 
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
 #include <drawinglayer/XShapeDumper.hxx>
@@ -39,10 +40,14 @@ struct FileFormat
 };
 
 // These values are taken from "Flags" in filter/source/config/fragments/filters/*
+// You need to turn value of oor:name="Flags" to SFX_FILTER_*, see
+// include/comphelper/documentconstants.hxx for the possible values.
+// Note: 3RDPARTYFILTER == SFX_FILTER_STARONEFILTER
 #define ODP_FORMAT_TYPE  ( SFX_FILTER_IMPORT | SFX_FILTER_EXPORT | SFX_FILTER_TEMPLATE | SFX_FILTER_OWN | SFX_FILTER_DEFAULT | SFX_FILTER_ENCRYPTION | SFX_FILTER_PREFERED )
 #define PPT_FORMAT_TYPE  ( SFX_FILTER_IMPORT | SFX_FILTER_EXPORT | SFX_FILTER_ALIEN )
 #define PPTX_FORMAT_TYPE ( SFX_FILTER_IMPORT | SFX_FILTER_EXPORT | SFX_FILTER_ALIEN | SFX_FILTER_STARONEFILTER | SFX_FILTER_PREFERED )
 #define HTML_FORMAT_TYPE ( SFX_FILTER_EXPORT | SFX_FILTER_ALIEN )
+#define PDF_FORMAT_TYPE  ( SFX_FILTER_STARONEFILTER | SFX_FILTER_ALIEN | SFX_FILTER_IMPORT | SFX_FILTER_PREFERED )
 
 /** List of file formats we support in Impress unit tests.
 
@@ -58,6 +63,7 @@ FileFormat aFileFormats[] =
     { "ppt",  "MS PowerPoint 97", "Microsoft PowerPoint 97/2000/XP/2003", "sdfilt", PPT_FORMAT_TYPE },
     { "pptx", "Impress Office Open XML", "Office Open XML Presentation", "", PPTX_FORMAT_TYPE },
     { "html", "graphic_HTML", "graphic_HTML", "", HTML_FORMAT_TYPE },
+    { "pdf",  "draw_pdf_import", "pdf_Portable_Document_Format", "", PDF_FORMAT_TYPE },
     { 0, 0, 0, 0, 0 }
 };
 
@@ -65,6 +71,7 @@ FileFormat aFileFormats[] =
 #define PPT  1
 #define PPTX 2
 #define HTML 3
+#define PDF  4
 
 /// Base class for filter tests loading or roundtriping a document, and asserting the document model.
 class SdModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest
@@ -94,7 +101,7 @@ public:
 
 protected:
     /// Load the document.
-    sd::DrawDocShellRef loadURL( const OUString &rURL, sal_Int32 nFormat )
+    sd::DrawDocShellRef loadURL( const OUString &rURL, sal_Int32 nFormat, SfxAllItemSet *pParams = 0 )
     {
         FileFormat *pFmt = getFormat(nFormat);
         CPPUNIT_ASSERT_MESSAGE( "missing filter info", pFmt->pName != NULL );
@@ -112,8 +119,7 @@ protected:
         aFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
 
         ::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell();
-        SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
-        pSrcMed->SetFilter(aFilter);
+        SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ, aFilter, pParams);
         if ( !xDocShRef->DoLoad(pSrcMed) || !xDocShRef.Is() )
         {
             if (xDocShRef.Is())
diff --git a/sdext/source/pdfimport/inc/wrapper.hxx b/sdext/source/pdfimport/inc/wrapper.hxx
index 8f0fc10..6bafce4 100644
--- a/sdext/source/pdfimport/inc/wrapper.hxx
+++ b/sdext/source/pdfimport/inc/wrapper.hxx
@@ -40,7 +40,8 @@ namespace pdfi
                                     css::task::XInteractionHandler >& xIHdl,
                               const OUString&                               rPwd,
                               const css::uno::Reference<
-                                    css::uno::XComponentContext >&    xContext );
+                                    css::uno::XComponentContext >&    xContext,
+                              const OUString&        rFilterOptions = OUString());
     bool xpdf_ImportFromStream( const css::uno::Reference<
                                       css::io::XInputStream >&          xInput,
                                 const ContentSinkSharedPtr&                        rSink,
@@ -48,7 +49,8 @@ namespace pdfi
                                       css::task::XInteractionHandler >& xIHdl,
                                 const OUString&                               rPwd,
                                 const css::uno::Reference<
-                                      css::uno::XComponentContext >&    xContext );
+                                      css::uno::XComponentContext >&    xContext,
+                                const OUString&        rFilterOptions = OUString() );
 }
 
 #endif // INCLUDED_SDEXT_SOURCE_PDFIMPORT_INC_WRAPPER_HXX
diff --git a/sdext/source/pdfimport/pdfiadaptor.cxx b/sdext/source/pdfimport/pdfiadaptor.cxx
index a6cb098..6162d27 100644
--- a/sdext/source/pdfimport/pdfiadaptor.cxx
+++ b/sdext/source/pdfimport/pdfiadaptor.cxx
@@ -221,7 +221,8 @@ bool PDFIRawAdaptor::parse( const uno::Reference<io::XInputStream>&       xInput
                             const OUString&                          rPwd,
                             const uno::Reference<task::XStatusIndicator>& xStatus,
                             const XmlEmitterSharedPtr&                    rEmitter,
-                            const OUString&                          rURL )
+                            const OUString&                          rURL,
+                            const OUString&                          rFilterOptions )
 {
     // container for metaformat
     boost::shared_ptr<PDFIProcessor> pSink(
@@ -234,9 +235,11 @@ bool PDFIRawAdaptor::parse( const uno::Reference<io::XInputStream>&       xInput
     bool bSuccess=false;
 
     if( xInput.is() )
-        bSuccess = xpdf_ImportFromStream( xInput, pSink, xIHdl, rPwd, m_xContext );
+        bSuccess = xpdf_ImportFromStream( xInput, pSink, xIHdl,
+                                          rPwd, m_xContext, rFilterOptions );
     else
-        bSuccess = xpdf_ImportFromFile( rURL, pSink, xIHdl, rPwd, m_xContext );
+        bSuccess = xpdf_ImportFromFile( rURL, pSink, xIHdl,
+                                        rPwd, m_xContext, rFilterOptions );
 
     if( bSuccess )
         pSink->emit(*rEmitter,*m_pVisitorFactory);
@@ -271,6 +274,7 @@ sal_Bool SAL_CALL PDFIRawAdaptor::importer( const uno::Sequence< beans::Property
     uno::Reference< task::XInteractionHandler > xInteractionHandler;
     OUString aURL;
     OUString aPwd;
+    OUString aFilterOptions;
     const beans::PropertyValue* pAttribs = rSourceData.getConstArray();
     sal_Int32 nAttribs = rSourceData.getLength();
     for( sal_Int32 i = 0; i < nAttribs; i++, pAttribs++ )
@@ -286,12 +290,15 @@ sal_Bool SAL_CALL PDFIRawAdaptor::importer( const uno::Sequence< beans::Property
             pAttribs->Value >>= xInteractionHandler;
         else if ( pAttribs->Name == "Password" )
             pAttribs->Value >>= aPwd;
+        else if ( pAttribs->Name == "FilterOptions" )
+            pAttribs->Value >>= aFilterOptions;
     }
     if( !xInput.is() )
         return sal_False;
 
     XmlEmitterSharedPtr pEmitter = createSaxEmitter(rHdl);
-    const bool bSuccess = parse(xInput,xInteractionHandler, aPwd, xStatus,pEmitter,aURL);
+    const bool bSuccess = parse(xInput, xInteractionHandler,
+                                aPwd, xStatus, pEmitter, aURL, aFilterOptions);
 
     // tell input stream that it is no longer needed
     xInput->closeInput();
diff --git a/sdext/source/pdfimport/pdfiadaptor.hxx b/sdext/source/pdfimport/pdfiadaptor.hxx
index a88f3df..0b7c749 100644
--- a/sdext/source/pdfimport/pdfiadaptor.hxx
+++ b/sdext/source/pdfimport/pdfiadaptor.hxx
@@ -88,7 +88,8 @@ namespace pdfi
                     const OUString&                                                          rPwd,
                     const css::uno::Reference<css::task::XStatusIndicator>& xStatus,
                     const XmlEmitterSharedPtr&                                                    rEmitter,
-                    const OUString&                                                          rURL );
+                    const OUString&                                                          rURL,
+                    const OUString&                                         rFilterOptions = OUString());
 
     public:
         explicit PDFIRawAdaptor( const css::uno::Reference<
diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx
index 79d64fd..4f715f0 100644
--- a/sdext/source/pdfimport/wrapper/wrapper.cxx
+++ b/sdext/source/pdfimport/wrapper/wrapper.cxx
@@ -1011,7 +1011,8 @@ bool xpdf_ImportFromFile( const OUString&                             rURL,
                           const ContentSinkSharedPtr&                        rSink,
                           const uno::Reference< task::XInteractionHandler >& xIHdl,
                           const OUString&                               rPwd,
-                          const uno::Reference< uno::XComponentContext >&    xContext )
+                          const uno::Reference< uno::XComponentContext >&    xContext,
+                          const OUString&                                    rFilterOptions )
 {
     OSL_ASSERT(rSink);
 
@@ -1054,8 +1055,10 @@ bool xpdf_ImportFromFile( const OUString&                             rURL,
 
     // spawn separate process to keep LGPL/GPL code apart.
 
-    rtl_uString*  args[] = { aSysUPath.pData, errPathname.pData };
-    sal_Int32 nArgs = 2;
+    OUString aOptFlag("-o");
+    rtl_uString*  args[] = { aSysUPath.pData, errPathname.pData,
+                             aOptFlag.pData, rFilterOptions.pData };
+    sal_Int32 nArgs = rFilterOptions.isEmpty() ? 2 : 4;
 
     oslProcess    aProcess;
     oslFileHandle pIn  = NULL;
@@ -1160,7 +1163,8 @@ bool xpdf_ImportFromStream( const uno::Reference< io::XInputStream >&         xI
                             const ContentSinkSharedPtr&                       rSink,
                             const uno::Reference<task::XInteractionHandler >& xIHdl,
                             const OUString&                              rPwd,
-                            const uno::Reference< uno::XComponentContext >&   xContext )
+                            const uno::Reference< uno::XComponentContext >&   xContext,
+                            const OUString&                                   rFilterOptions )
 {
     OSL_ASSERT(xInput.is());
     OSL_ASSERT(rSink);
@@ -1203,7 +1207,7 @@ bool xpdf_ImportFromStream( const uno::Reference< io::XInputStream >&         xI
     osl_closeFile( aFile );
 
     if ( bSuccess )
-        bSuccess = xpdf_ImportFromFile( aURL, rSink, xIHdl, rPwd, xContext );
+        bSuccess = xpdf_ImportFromFile( aURL, rSink, xIHdl, rPwd, xContext, rFilterOptions );
     osl_removeFile( aURL.pData );
 
     return bSuccess;
diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index 129f2b9..94dc813 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -533,7 +533,8 @@ void PDFOutDev::printPath( GfxPath* pPath ) const
 PDFOutDev::PDFOutDev( PDFDoc* pDoc ) :
     m_pDoc( pDoc ),
     m_aFontMap(),
-    m_pUtf8Map( new UnicodeMap((char*)"UTF-8", gTrue, &mapUTF8) )
+    m_pUtf8Map( new UnicodeMap((char*)"UTF-8", gTrue, &mapUTF8) ),
+    m_bSkipImages(false)
 {
 }
 PDFOutDev::~PDFOutDev()
@@ -633,6 +634,8 @@ void PDFOutDev::updateCTM(GfxState* state,
 
 void PDFOutDev::updateLineDash(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     assert(state);
 
     double* dashArray; int arrayLen; double startOffset;
@@ -650,36 +653,48 @@ void PDFOutDev::updateLineDash(GfxState *state)
 
 void PDFOutDev::updateFlatness(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     assert(state);
     printf( "updateFlatness %d\n", state->getFlatness() );
 }
 
 void PDFOutDev::updateLineJoin(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     assert(state);
     printf( "updateLineJoin %d\n", state->getLineJoin() );
 }
 
 void PDFOutDev::updateLineCap(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     assert(state);
     printf( "updateLineCap %d\n", state->getLineCap() );
 }
 
 void PDFOutDev::updateMiterLimit(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     assert(state);
     printf( "updateMiterLimit %f\n", normalize(state->getMiterLimit()) );
 }
 
 void PDFOutDev::updateLineWidth(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     assert(state);
     printf( "updateLineWidth %f\n", normalize(state->getLineWidth()) );
 }
 
 void PDFOutDev::updateFillColor(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     assert(state);
 
     GfxRGB aRGB;
@@ -694,6 +709,8 @@ void PDFOutDev::updateFillColor(GfxState *state)
 
 void PDFOutDev::updateStrokeColor(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     assert(state);
 
     GfxRGB aRGB;
@@ -708,11 +725,15 @@ void PDFOutDev::updateStrokeColor(GfxState *state)
 
 void PDFOutDev::updateFillOpacity(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     updateFillColor(state);
 }
 
 void PDFOutDev::updateStrokeOpacity(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     updateStrokeColor(state);
 }
 
@@ -775,6 +796,8 @@ void PDFOutDev::updateRender(GfxState *state)
 
 void PDFOutDev::stroke(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     assert(state);
 
     printf( "strokePath" );
@@ -784,6 +807,8 @@ void PDFOutDev::stroke(GfxState *state)
 
 void PDFOutDev::fill(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     assert(state);
 
     printf( "fillPath" );
@@ -793,6 +818,8 @@ void PDFOutDev::fill(GfxState *state)
 
 void PDFOutDev::eoFill(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     assert(state);
 
     printf( "eoFillPath" );
@@ -802,6 +829,8 @@ void PDFOutDev::eoFill(GfxState *state)
 
 void PDFOutDev::clip(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     assert(state);
 
     printf( "clipPath" );
@@ -811,6 +840,8 @@ void PDFOutDev::clip(GfxState *state)
 
 void PDFOutDev::eoClip(GfxState *state)
 {
+    if (m_bSkipImages)
+        return;
     assert(state);
 
     printf( "eoClipPath" );
@@ -896,6 +927,8 @@ void PDFOutDev::drawImageMask(GfxState* pState, Object*, Stream* str,
 #endif
                               GBool /*inlineImg*/ )
 {
+    if (m_bSkipImages)
+        return;
     OutputBuffer aBuf; initBuf(aBuf);
 
     printf( "drawMask %d %d %d", width, height, invert );
@@ -925,6 +958,8 @@ void PDFOutDev::drawImage(GfxState*, Object*, Stream* str,
 #endif
                           int* maskColors, GBool /*inlineImg*/ )
 {
+    if (m_bSkipImages)
+        return;
     OutputBuffer aBuf; initBuf(aBuf);
     OutputBuffer aMaskBuf;
 
@@ -980,6 +1015,8 @@ void PDFOutDev::drawMaskedImage(GfxState*, Object*, Stream* str,
 #endif
                                )
 {
+    if (m_bSkipImages)
+        return;
     OutputBuffer aBuf;     initBuf(aBuf);
     printf( "drawImage %d %d 0", width, height );
     writePng_( aBuf, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskInvert, true );
@@ -1000,6 +1037,8 @@ void PDFOutDev::drawSoftMaskedImage(GfxState*, Object*, Stream* str,
 #endif
                                    )
 {
+    if (m_bSkipImages)
+        return;
     OutputBuffer aBuf;     initBuf(aBuf);
     printf( "drawImage %d %d 0", width, height );
     writePng_( aBuf, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskColorMap, true );
@@ -1012,6 +1051,11 @@ void PDFOutDev::setPageNum( int nNumPages )
     printf("setPageNum %d\n", nNumPages);
 }
 
+void PDFOutDev::setSkipImages( bool bSkipImages )
+{
+    m_bSkipImages = bSkipImages;
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
index a1fe931..d8e691c 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
@@ -138,6 +138,7 @@ namespace pdfi
         mutable boost::unordered_map< long long,
                                FontAttributes > m_aFontMap;
         UnicodeMap*                             m_pUtf8Map;
+        bool                                    m_bSkipImages;
 
         int  parseFont( long long nNewId, GfxFont* pFont, GfxState* state ) const;
         void writeFontFile( GfxFont* gfxFont ) const;
@@ -267,6 +268,7 @@ namespace pdfi
                                         ) SAL_OVERRIDE;
 
         void setPageNum( int nNumPages );
+        void setSkipImages ( bool bSkipImages );
     };
 }
 
diff --git a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx
index d80ef66..7c77aa3 100644
--- a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx
@@ -29,7 +29,8 @@ FILE* g_binary_out=stderr;
 
 static const char *ownerPassword = "\001";
 static const char *userPassword  = "\001";
-static const char *outputFile   = "\001";
+static const char *outputFile    = "\001";
+static const char *options       = "\001";
 
 int main(int argc, char **argv)
 {
@@ -43,6 +44,14 @@ int main(int argc, char **argv)
             for (int j = k; j < argc; ++j)
                 argv[j] = argv[j+2];
         }
+        else if (!strcmp(argv[k], "-o"))
+        {
+            options = argv[k+1];
+            argc -= 2;
+            for (int j = k; j < argc; ++j)
+                argv[j] = argv[j+2];
+        }
+
         else if (!strcmp(argv[k], "-opw"))
         {
             ownerPassword = argv[k+1];
@@ -60,9 +69,6 @@ int main(int argc, char **argv)
     ++k;
     }
 
-    if( argc != 3 )
-        return 1;
-
     // read config file
     globalParams = new GlobalParams();
     globalParams->setErrQuiet(gTrue);
@@ -122,6 +128,9 @@ int main(int argc, char **argv)
    if ( !aDoc.isOk() )
    {
         pdfi::PDFOutDev* pOutDev( new pdfi::PDFOutDev(&aErrDoc) );
+        if (!strcmp(options, "SkipImages")) {
+            pOutDev->setSkipImages(true);
+        }
 
         const int nPages = aErrDoc.isOk() ? aErrDoc.getNumPages() : 0;
 
@@ -145,6 +154,9 @@ int main(int argc, char **argv)
    else
    {
       boost::scoped_ptr<pdfi::PDFOutDev> pOutDev( new pdfi::PDFOutDev(&aDoc) );
+      if (!strcmp(options, "SkipImages")) {
+        pOutDev->setSkipImages(true);
+      }
 
       // tell receiver early - needed for proper progress calculation
       pOutDev->setPageNum( aDoc.getNumPages() );


More information about the Libreoffice-commits mailing list