From 5f468a9407aab28c46af6c3cd7c34d869bed084f Mon Sep 17 00:00:00 2001 From: Benjamin Adler Date: Fri, 29 Oct 2010 01:34:03 +0200 Subject: [PATCH] Some more cleanups --- poppler/PDFDoc.h | 6 +++--- poppler/PSOutputDev.cc | 10 +++++----- poppler/PSOutputDev.h | 1 - poppler/Page.cc | 13 +++---------- poppler/Page.h | 6 +++--- qt4/src/poppler-page.cc | 2 +- test/perf-test.cc | 4 ---- utils/HtmlOutputDev.h | 2 +- 8 files changed, 16 insertions(+), 28 deletions(-) diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h index e4c807f..f9fe434 100644 --- a/poppler/PDFDoc.h +++ b/poppler/PDFDoc.h @@ -127,7 +127,7 @@ public: // Display a page. void displayPage(OutputDev *out, int page, double hDPI, double vDPI, int rotate, - /*GBool useMediaBox, GBool crop*/Page::PageBox cropBox, GBool printing, + Page::PageBox cropBox, GBool printing, GBool (*abortCheckCbk)(void *data) = NULL, void *abortCheckCbkData = NULL, GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL, @@ -136,7 +136,7 @@ public: // Display a range of pages. void displayPages(OutputDev *out, int firstPage, int lastPage, double hDPI, double vDPI, int rotate, - /*GBool useMediaBox, GBool crop*/Page::PageBox cropBox, GBool printing, + Page::PageBox cropBox, GBool printing, GBool (*abortCheckCbk)(void *data) = NULL, void *abortCheckCbkData = NULL, GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL, @@ -145,7 +145,7 @@ public: // Display part of a page. void displayPageSlice(OutputDev *out, int page, double hDPI, double vDPI, int rotate, - /*GBool useMediaBox, GBool crop*/Page::PageBox cropBox, GBool printing, + Page::PageBox cropBox, GBool printing, int sliceX, int sliceY, int sliceW, int sliceH, GBool (*abortCheckCbk)(void *data) = NULL, void *abortCheckCbkData = NULL, diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index ae0c518..f1efdbc 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -2941,7 +2941,7 @@ void PSOutputDev::setupForm(Ref id, Object *strObj) { } GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, - int rotateA, /*GBool useMediaBox, GBool crop*/ Page::PageBox cropBox, + int rotateA, Page::PageBox pageBox, int sliceX, int sliceY, int sliceW, int sliceH, GBool printing, Catalog *catalog, @@ -2964,7 +2964,7 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, if (!forceRasterize) { scan = new PreScanOutputDev(); - page->displaySlice(scan, 72, 72, rotateA, cropBox, + page->displaySlice(scan, 72, 72, rotateA, pageBox, sliceX, sliceY, sliceW, sliceH, printing, catalog, abortCheckCbk, abortCheckCbkData); rasterize = scan->usesTransparency(); @@ -2998,13 +2998,13 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, } splashOut->startDoc(xref); page->displaySlice(splashOut, splashDPI, splashDPI, rotateA, - cropBox, + pageBox, sliceX, sliceY, sliceW, sliceH, printing, catalog, abortCheckCbk, abortCheckCbkData); // start the PS page - page->makeBox(splashDPI, splashDPI, rotateA, cropBox, gFalse, - sliceX, sliceY, sliceW, sliceH, &box/*, &crop*/); + page->makeBox(splashDPI, splashDPI, rotateA, pageBox, gFalse, + sliceX, sliceY, sliceW, sliceH, &box); rotateA += page->getRotate(); if (rotateA >= 360) { rotateA -= 360; diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h index 955f6b7..22c83f5 100644 --- a/poppler/PSOutputDev.h +++ b/poppler/PSOutputDev.h @@ -162,7 +162,6 @@ public: // before returning false. virtual GBool checkPageSlice(Page *page, double hDPI, double vDPI, int rotate, - //GBool useMediaBox, GBool crop, Page::PageBox cropBox, int sliceX, int sliceY, int sliceW, int sliceH, GBool printing, Catalog *catalog, diff --git a/poppler/Page.cc b/poppler/Page.cc index 0a040be..0f080f1 100644 --- a/poppler/Page.cc +++ b/poppler/Page.cc @@ -413,7 +413,6 @@ void Page::display(OutputDev *out, double hDPI, double vDPI, Gfx *Page::createGfx(OutputDev *out, double hDPI, double vDPI, int rotate, - // GBool useMediaBox, GBool crop, Page::PageBox pageBox, int sliceX, int sliceY, int sliceW, int sliceH, GBool printing, Catalog *catalog, @@ -455,17 +454,11 @@ Gfx *Page::createGfx(OutputDev *out, double hDPI, double vDPI, printf("***** Rotate = %d\n", attrs->getRotate()); } - PDFRectangle *pdfRectangleToUseForCropping = NULL; + PDFRectangle *pdfRectangleToUseForCropping = getPDFRectangleOfPageBox(pageBox); + + // Using the MediaBox means no cropping, see the clipping in Gfx c'tor. if (pageBox == Page::MediaBox) { pdfRectangleToUseForCropping = NULL; - } else if (pageBox == Page::CropBox) { - pdfRectangleToUseForCropping = cropBox; - } else if (pageBox == Page::BleedBox) { - pdfRectangleToUseForCropping = bleedBox; - } else if (pageBox == Page::TrimBox) { - pdfRectangleToUseForCropping = trimBox; - } else if (pageBox == Page::ArtBox) { - pdfRectangleToUseForCropping = artBox; } gfx = new Gfx(xref, out, num, attrs->getResourceDict(), catalog, diff --git a/poppler/Page.h b/poppler/Page.h index 3247723..73cbf8f 100644 --- a/poppler/Page.h +++ b/poppler/Page.h @@ -202,7 +202,7 @@ public: Object *getActions(Object *obj) { return actions.fetch(xref, obj); } Gfx *createGfx(OutputDev *out, double hDPI, double vDPI, - int rotate, /*GBool useMediaBox, GBool crop*/Page::PageBox cropBox, + int rotate, Page::PageBox cropBox, int sliceX, int sliceY, int sliceW, int sliceH, GBool printing, Catalog *catalog, GBool (*abortCheckCbk)(void *data), @@ -212,7 +212,7 @@ public: // Display a page. void display(OutputDev *out, double hDPI, double vDPI, - int rotate, /*GBool useMediaBox, GBool crop*/Page::PageBox cropBox, + int rotate, Page::PageBox cropBox, GBool printing, Catalog *catalog, GBool (*abortCheckCbk)(void *data) = NULL, void *abortCheckCbkData = NULL, @@ -221,7 +221,7 @@ public: // Display part of a page. void displaySlice(OutputDev *out, double hDPI, double vDPI, - int rotate, /*GBool useMediaBox, GBool crop*/Page::PageBox cropBox, + int rotate, Page::PageBox cropBox, int sliceX, int sliceY, int sliceW, int sliceH, GBool printing, Catalog *catalog, GBool (*abortCheckCbk)(void *data) = NULL, diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc index 57bde7e..8929be0 100644 --- a/qt4/src/poppler-page.cc +++ b/qt4/src/poppler-page.cc @@ -213,7 +213,7 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h, SplashOutputDev *splash_output = static_cast(m_page->parentDoc->getOutputDev()); m_page->parentDoc->doc->displayPageSlice(splash_output, m_page->index + 1, xres, yres, - rotation, ::Page::CropBox/*false, true*/, false, x, y, w, h); + rotation, ::Page::CropBox, false, x, y, w, h); SplashBitmap *bitmap = splash_output->getBitmap(); int bw = bitmap->getWidth(); diff --git a/test/perf-test.cc b/test/perf-test.cc index e2459d4..3d50374 100644 --- a/test/perf-test.cc +++ b/test/perf-test.cc @@ -443,8 +443,6 @@ SplashBitmap *PdfEnginePoppler::renderBitmap(int pageNo, double zoomReal, int ro double hDPI = (double)PDF_FILE_DPI * zoomReal * 0.01; double vDPI = (double)PDF_FILE_DPI * zoomReal * 0.01; -// GBool useMediaBox = gFalse; -// GBool crop = gTrue; GBool doLinks = gTrue; _pdfDoc->displayPage(_outputDev, pageNo, hDPI, vDPI, rotation, Page::CropBox, doLinks, NULL, NULL); @@ -870,8 +868,6 @@ static void RenderPdfAsText(const char *fileName) msTimer.start(); int rotate = 0; -// GBool useMediaBox = gFalse; -// GBool crop = gTrue; GBool doLinks = gFalse; pdfDoc->displayPage(textOut, curPage, 72, 72, rotate, Page::CropBox, doLinks); txt = textOut->getText(0.0, 0.0, 10000.0, 10000.0); diff --git a/utils/HtmlOutputDev.h b/utils/HtmlOutputDev.h index 55cc7b4..9718626 100644 --- a/utils/HtmlOutputDev.h +++ b/utils/HtmlOutputDev.h @@ -250,7 +250,7 @@ public: //----- initialization and control virtual GBool checkPageSlice(Page *page, double hDPI, double vDPI, - int rotate, Page::PageBox cropBox/*GBool useMediaBox, GBool crop*/, + int rotate, Page::PageBox cropBox, int sliceX, int sliceY, int sliceW, int sliceH, GBool printing, Catalog * catalogA, GBool (* abortCheckCbk)(void *data) = NULL, -- 1.6.3.3