Engauge Digitizer 2
Loading...
Searching...
No Matches
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-qt6.h"
9#include <QApplication>
10
11using namespace Poppler;
12
16
17bool ImportCroppingUtilPdf::applyImportCropping (bool isErrorReportRegressionTest,
18 const QString &fileName,
19 ImportCropping importCropping,
20 std::unique_ptr<Document> &document) const
21{
22 document.reset();
23 bool cropping = false;
24
25 if (!isErrorReportRegressionTest) {
26
27 // Simple check to prevent complaints from poppler code
28 if (fileName.right (4).toLower () == ".pdf") {
29
30 // Try to read the file
31 QApplication::setOverrideCursor (Qt::BusyCursor); // Since load could take a while
32 document = Document::load (fileName);
33 QApplication::restoreOverrideCursor();
34 if (document != nullptr) {
35 if (!document->isLocked ()) {
36
37 cropping = (importCropping == IMPORT_CROPPING_ALWAYS ||
38 (importCropping == IMPORT_CROPPING_MULTIPAGE_PDFS && document->numPages () > 1));
39 }
40 }
41 }
42 }
43
44 return cropping;
45}
ImportCropping
@ IMPORT_CROPPING_MULTIPAGE_PDFS
@ IMPORT_CROPPING_ALWAYS
bool applyImportCropping(bool isRegression, const QString &fileName, ImportCropping importCropping, std::unique_ptr< Poppler::Document > &document) const
For pdf files, skip cropping dialog during regression testing, otherwise crop if it is always turned ...
ImportCroppingUtilPdf()
Single constructor.