Engauge Digitizer  2
ImportCroppingUtilPdf.cpp
Go to the documentation of this file.
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 
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 = nullptr;
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 != nullptr) {
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 }
IMPORT_CROPPING_MULTIPAGE_PDFS
Definition: ImportCropping.h:15
ImportCroppingUtilPdf::applyImportCropping
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 ...
Definition: ImportCroppingUtilPdf.cpp:17
ImportCroppingUtilPdf::ImportCroppingUtilPdf
ImportCroppingUtilPdf()
Single constructor.
Definition: ImportCroppingUtilPdf.cpp:13
IMPORT_CROPPING_ALWAYS
Definition: ImportCropping.h:16
Document
Storage of one imported image and the data attached to that image.
Definition: Document.h:40
ImportCropping
ImportCropping
Definition: ImportCropping.h:9
ImportCroppingUtilPdf.h
Poppler
Definition: DlgImportCroppingPdf.h:13