00001
00002
00003
00004
00005
00006
00007 #include "DlgImportCroppingNonPdf.h"
00008 #include "ImportCroppingUtilNonPdf.h"
00009 #include "NonPdf.h"
00010 #include <QApplication>
00011 #include <QImage>
00012 #include <QString>
00013
00014 NonPdf::NonPdf ()
00015 {
00016 }
00017
00018 NonPdfReturn NonPdf::load (const QString &fileName,
00019 QImage &image,
00020 ImportCropping importCropping,
00021 bool isErrorReportRegressionTest) const
00022 {
00023 ImportCroppingUtilNonPdf importCroppingUtil;
00024 bool cropping = importCroppingUtil.applyImportCropping (isErrorReportRegressionTest,
00025 importCropping);
00026
00027 NonPdfReturn rtn;
00028 QApplication::setOverrideCursor(Qt::BusyCursor);
00029 if (cropping) {
00030
00031 rtn = loadWithCropping (fileName,
00032 image);
00033
00034 } else {
00035
00036 rtn = loadWithoutCropping (fileName,
00037 image);
00038
00039 }
00040 QApplication::restoreOverrideCursor();
00041
00042 return rtn;
00043 }
00044
00045 NonPdfReturn NonPdf::loadWithCropping (const QString &fileName,
00046 QImage &image) const
00047 {
00048 NonPdfReturn nonPdfReturn = NON_PDF_RETURN_FAILED;
00049
00050
00051 DlgImportCroppingNonPdf dlg (fileName);
00052 if (dlg.exec() == QDialog::Accepted) {
00053
00054
00055 image = dlg.image ();
00056
00057 if (!image.isNull()) {
00058 nonPdfReturn = NON_PDF_RETURN_SUCCESS;
00059 }
00060
00061 } else {
00062 nonPdfReturn = NON_PDF_RETURN_CANCELED;
00063 }
00064
00065 return nonPdfReturn;
00066 }
00067
00068 NonPdfReturn NonPdf::loadWithoutCropping (const QString &fileName,
00069 QImage &image) const
00070 {
00071 NonPdfReturn nonPdfReturn = NON_PDF_RETURN_FAILED;
00072
00073 if (image.load (fileName)) {
00074 nonPdfReturn = NON_PDF_RETURN_SUCCESS;
00075 }
00076
00077 return nonPdfReturn;
00078 }