diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-01-22 10:06:11 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-01-22 10:09:50 +0100 |
commit | f2be1cf932c1306871ca4704d51f3849b439d28c (patch) | |
tree | f269faf02e49e30921f7b0e1b4a5260e00bed084 /sdext | |
parent | 6e0676324e96a05ad1d211a3a59e5c0ad3efcac5 (diff) |
pdf import: Kill cut'n'paste, and fix a memory leak.
Change-Id: I9460e458e9ac5274d68bd11b0ed77b06d664ce0e
Diffstat (limited to 'sdext')
-rw-r--r-- | sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx | 70 |
1 files changed, 22 insertions, 48 deletions
diff --git a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx index d80ef66719cc..20c45c49a1dd 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; } |