[Libreoffice-commits] core.git: sdext/source

Jan Holesovsky kendy at collabora.com
Thu Jan 22 01:10:25 PST 2015


 sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx |   70 ++++++---------------
 1 file changed, 22 insertions(+), 48 deletions(-)

New commits:
commit f2be1cf932c1306871ca4704d51f3849b439d28c
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Thu Jan 22 10:06:11 2015 +0100

    pdf import: Kill cut'n'paste, and fix a memory leak.
    
    Change-Id: I9460e458e9ac5274d68bd11b0ed77b06d664ce0e

diff --git a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx
index d80ef66..20c45c4 100644
--- a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx
@@ -17,8 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <boost/scoped_ptr.hpp>
-
 #include "pdfioutdev_gpl.hxx"
 #ifdef WNT
 # include <io.h>
@@ -117,53 +115,29 @@ int main(int argc, char **argv)
                  pOwnerPasswordStr,
                  pUserPasswordStr );
 
+    // Check various permissions for aDoc.
+    PDFDoc &rDoc = aDoc.isOk()? aDoc: aErrDoc;
+
+    pdfi::PDFOutDev aOutDev(&rDoc);
+
+    // tell the receiver early - needed for proper progress calculation
+    const int nPages = rDoc.isOk()? rDoc.getNumPages(): 0;
+    aOutDev.setPageNum(nPages);
+
+    // virtual resolution of the PDF OutputDev in dpi
+    static const int PDFI_OUTDEV_RESOLUTION = 7200;
+
+    // do the conversion
+    for (int i = 1; i <= nPages; ++i)
+    {
+        rDoc.displayPage(&aOutDev,
+                i,
+                PDFI_OUTDEV_RESOLUTION,
+                PDFI_OUTDEV_RESOLUTION,
+                0, gTrue, gTrue, gTrue);
+        rDoc.processLinks(&aOutDev, i);
+    }
 
-   // Check various permissions.
-   if ( !aDoc.isOk() )
-   {
-        pdfi::PDFOutDev* pOutDev( new pdfi::PDFOutDev(&aErrDoc) );
-
-        const int nPages = aErrDoc.isOk() ? aErrDoc.getNumPages() : 0;
-
-        // tell receiver early - needed for proper progress calculation
-        pOutDev->setPageNum( nPages );
-
-        // virtual resolution of the PDF OutputDev in dpi
-        static const int PDFI_OUTDEV_RESOLUTION=7200;
-
-       // do the conversion
-       for( int i=1; i<=nPages; ++i )
-       {
-          aErrDoc.displayPage( pOutDev,
-                            i,
-                            PDFI_OUTDEV_RESOLUTION,
-                            PDFI_OUTDEV_RESOLUTION,
-                            0, gTrue, gTrue, gTrue );
-          aErrDoc.processLinks( pOutDev, i );
-       }
-   }
-   else
-   {
-      boost::scoped_ptr<pdfi::PDFOutDev> pOutDev( new pdfi::PDFOutDev(&aDoc) );
-
-      // tell receiver early - needed for proper progress calculation
-      pOutDev->setPageNum( aDoc.getNumPages() );
-
-      // virtual resolution of the PDF OutputDev in dpi
-      static const int PDFI_OUTDEV_RESOLUTION=7200;
-
-      // do the conversion
-      const int nPages = aDoc.getNumPages();
-      for( int i=1; i<=nPages; ++i )
-      {
-        aDoc.displayPage( pOutDev.get(),
-                          i,
-                          PDFI_OUTDEV_RESOLUTION,
-                          PDFI_OUTDEV_RESOLUTION,
-                          0, gTrue, gTrue, gTrue );
-        aDoc.processLinks( pOutDev.get(), i );
-      }
-   }
     return 0;
 }
 


More information about the Libreoffice-commits mailing list