Engauge Digitizer  2
ImportCroppingUtilPdf.cpp
1 /******************************************************************************************************
2  * (C) 2016 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #include "ImportCroppingUtilPdf.h"
8 #include "poppler-qt5.h"
9 #include <QApplication>
10 
11 using namespace Poppler;
12 
14 {
15 }
16 
17 bool ImportCroppingUtilPdf::applyImportCropping (bool isErrorReportRegressionTest,
18  const QString &fileName,
19  ImportCropping importCropping,
20  Document *&document) const
21 {
22  document = 0;
23 
24  bool cropping = false;
25 
26  if (!isErrorReportRegressionTest) {
27 
28  // Simple check to prevent complaints from poppler code
29  if (fileName.right (4).toLower () == ".pdf") {
30 
31  // Try to read the file
32  QApplication::setOverrideCursor (Qt::BusyCursor); // Since load could take a while
33  document = Document::load (fileName);
34  QApplication::restoreOverrideCursor();
35  if (document != 0) {
36  if (!document->isLocked ()) {
37 
38  cropping = (importCropping == IMPORT_CROPPING_ALWAYS ||
39  (importCropping == IMPORT_CROPPING_MULTIPAGE_PDFS && document->numPages () > 1));
40  }
41  }
42  }
43  }
44 
45  return cropping;
46 }
ImportCroppingUtilPdf()
Single constructor.
bool applyImportCropping(bool isRegression, const QString &fileName, ImportCropping importCropping, Poppler::Document *&document) const
For pdf files, skip cropping dialog during regression testing, otherwise crop if it is always turned ...
Storage of one imported image and the data attached to that image.
Definition: Document.h:41