From cbeb91fe1848731ca604da034da1adce3bb9bddd Mon Sep 17 00:00:00 2001 From: Raphael Cotty Date: Fri, 29 Oct 2021 15:17:40 +0200 Subject: [PATCH] Linux port --- CodeGenerator/CodeGenerator.qbs | 9 ++ JBIG2_Viewer/JBIG2_Viewer.qbs | 9 ++ Pdf4Qt.qbs | 24 +++++ Pdf4QtDocDiff/Pdf4QtDocDiff.qbs | 11 +++ Pdf4QtDocDiff/differencesdockwidget.cpp | 2 +- Pdf4QtDocDiff/mainwindow.cpp | 16 +++ Pdf4QtDocDiff/mainwindow.h | 4 + .../Pdf4QtDocPageOrganizer.qbs | 11 +++ Pdf4QtLib/Pdf4QtLib.qbs | 43 ++++++++ Pdf4QtLib/sources/pdfaction.cpp | 4 +- Pdf4QtLib/sources/pdfannotation.cpp | 2 +- Pdf4QtLib/sources/pdfccittfaxdecoder.cpp | 14 --- Pdf4QtLib/sources/pdfccittfaxdecoder.h | 14 ++- Pdf4QtLib/sources/pdfcms.cpp | 16 ++- Pdf4QtLib/sources/pdfcolorspaces.cpp | 8 +- Pdf4QtLib/sources/pdfcolorspaces.h | 2 +- Pdf4QtLib/sources/pdfconstants.h | 2 + Pdf4QtLib/sources/pdfdocumentbuilder.cpp | 6 ++ Pdf4QtLib/sources/pdfdocumentbuilder.h | 1 + Pdf4QtLib/sources/pdfencoding.cpp | 1 + Pdf4QtLib/sources/pdfexecutionpolicy.h | 4 +- Pdf4QtLib/sources/pdffont.cpp | 97 ++++++++++++++++--- Pdf4QtLib/sources/pdfform.cpp | 4 +- Pdf4QtLib/sources/pdfitemmodels.h | 2 +- Pdf4QtLib/sources/pdfobject.h | 1 + Pdf4QtLib/sources/pdfpagecontentprocessor.h | 24 ++--- Pdf4QtLib/sources/pdfpainter.h | 2 +- Pdf4QtLib/sources/pdfparser.cpp | 2 +- Pdf4QtLib/sources/pdfpattern.h | 1 + Pdf4QtLib/sources/pdfsignaturehandler.cpp | 11 ++- Pdf4QtLib/sources/pdftextlayout.cpp | 2 +- Pdf4QtLib/sources/pdftransparencyrenderer.h | 2 +- Pdf4QtLib/sources/pdfutils.cpp | 18 ++++ Pdf4QtLib/sources/pdfutils.h | 4 + Pdf4QtLib/sources/pdfvisitor.h | 6 +- Pdf4QtViewer/Pdf4QtViewer.qbs | 18 ++++ Pdf4QtViewer/pdfprogramcontroller.cpp | 8 +- Pdf4QtViewer/pdfsendmail.cpp | 3 + Pdf4QtViewer/pdfsidebarwidget.cpp | 2 +- Pdf4QtViewer/pdfviewermainwindow.cpp | 12 +++ Pdf4QtViewer/pdfviewermainwindow.h | 4 + Pdf4QtViewer/pdfviewermainwindowlite.cpp | 16 ++- Pdf4QtViewer/pdfviewermainwindowlite.h | 4 + Pdf4QtViewerLite/Pdf4QtViewerLite.qbs | 7 ++ .../AudioBookPlugin/AudioBookPlugin.qbs | 11 +++ .../DimensionsPlugin/DimensionsPlugin.qbs | 11 +++ .../OutputPreviewPlugin.qbs | 12 +++ .../RedactPlugin/RedactPlugin.qbs | 12 +++ .../SoftProofingPlugin/SoftProofingPlugin.qbs | 12 +++ Pdf4QtViewerProfi/Pdf4QtViewerProfi.qbs | 8 ++ PdfExampleGenerator/PdfExampleGenerator.qbs | 7 ++ PdfTool/PdfTool.qbs | 7 ++ UnitTests/UnitTests.qbs | 7 ++ qbs/imports/Pdf4QtApp.qbs | 17 ++++ qbs/imports/Pdf4QtLibrary.qbs | 16 +++ qbs/imports/Pdf4QtPlugin.qbs | 11 +++ qbs/imports/Pdf4QtProduct.qbs | 9 ++ .../pdf4qtbuildconfig/pdf4qtbuildconfig.qbs | 6 ++ 58 files changed, 529 insertions(+), 70 deletions(-) create mode 100644 CodeGenerator/CodeGenerator.qbs create mode 100644 JBIG2_Viewer/JBIG2_Viewer.qbs create mode 100644 Pdf4Qt.qbs create mode 100644 Pdf4QtDocDiff/Pdf4QtDocDiff.qbs create mode 100644 Pdf4QtDocPageOrganizer/Pdf4QtDocPageOrganizer.qbs create mode 100644 Pdf4QtLib/Pdf4QtLib.qbs create mode 100644 Pdf4QtViewer/Pdf4QtViewer.qbs create mode 100644 Pdf4QtViewerLite/Pdf4QtViewerLite.qbs create mode 100644 Pdf4QtViewerPlugins/AudioBookPlugin/AudioBookPlugin.qbs create mode 100644 Pdf4QtViewerPlugins/DimensionsPlugin/DimensionsPlugin.qbs create mode 100644 Pdf4QtViewerPlugins/OutputPreviewPlugin/OutputPreviewPlugin.qbs create mode 100644 Pdf4QtViewerPlugins/RedactPlugin/RedactPlugin.qbs create mode 100644 Pdf4QtViewerPlugins/SoftProofingPlugin/SoftProofingPlugin.qbs create mode 100644 Pdf4QtViewerProfi/Pdf4QtViewerProfi.qbs create mode 100644 PdfExampleGenerator/PdfExampleGenerator.qbs create mode 100644 PdfTool/PdfTool.qbs create mode 100644 UnitTests/UnitTests.qbs create mode 100644 qbs/imports/Pdf4QtApp.qbs create mode 100644 qbs/imports/Pdf4QtLibrary.qbs create mode 100644 qbs/imports/Pdf4QtPlugin.qbs create mode 100644 qbs/imports/Pdf4QtProduct.qbs create mode 100644 qbs/modules/pdf4qtbuildconfig/pdf4qtbuildconfig.qbs diff --git a/CodeGenerator/CodeGenerator.qbs b/CodeGenerator/CodeGenerator.qbs new file mode 100644 index 0000000..4bf6b63 --- /dev/null +++ b/CodeGenerator/CodeGenerator.qbs @@ -0,0 +1,9 @@ +Pdf4QtApp { + name: "CodeGenerator" + files: [ + "*.cpp", + "*.h", + "*.ui", + ] + Depends { name: "Qt"; submodules: ["xml"] } +} diff --git a/JBIG2_Viewer/JBIG2_Viewer.qbs b/JBIG2_Viewer/JBIG2_Viewer.qbs new file mode 100644 index 0000000..9165413 --- /dev/null +++ b/JBIG2_Viewer/JBIG2_Viewer.qbs @@ -0,0 +1,9 @@ +Pdf4QtApp { + name: "JBIG2_Viewer" + files: [ + "*.cpp", + "*.h", + "*.ui", + ] + Depends { name: "Qt"; submodules: ["widgets"] } +} diff --git a/Pdf4Qt.qbs b/Pdf4Qt.qbs new file mode 100644 index 0000000..397fb15 --- /dev/null +++ b/Pdf4Qt.qbs @@ -0,0 +1,24 @@ +import qbs + +Project { + name: "Pdf4Qt" + qbsSearchPaths: ["qbs"] + references: [ + "Pdf4QtLib/Pdf4QtLib.qbs", + "Pdf4QtViewer/Pdf4QtViewer.qbs", + "Pdf4QtViewerLite/Pdf4QtViewerLite.qbs", + "CodeGenerator/CodeGenerator.qbs", + "JBIG2_Viewer/JBIG2_Viewer.qbs", + "Pdf4QtDocPageOrganizer/Pdf4QtDocPageOrganizer.qbs", + "Pdf4QtDocDiff/Pdf4QtDocDiff.qbs", + "Pdf4QtViewerPlugins/AudioBookPlugin/AudioBookPlugin.qbs", + "Pdf4QtViewerPlugins/DimensionsPlugin/DimensionsPlugin.qbs", + "Pdf4QtViewerPlugins/OutputPreviewPlugin/OutputPreviewPlugin.qbs", + "Pdf4QtViewerPlugins/RedactPlugin/RedactPlugin.qbs", + "Pdf4QtViewerPlugins/SoftProofingPlugin/SoftProofingPlugin.qbs", + "Pdf4QtViewerProfi/Pdf4QtViewerProfi.qbs", + "PdfExampleGenerator/PdfExampleGenerator.qbs", + "PdfTool/PdfTool.qbs", + "UnitTests/UnitTests.qbs", + ] +} diff --git a/Pdf4QtDocDiff/Pdf4QtDocDiff.qbs b/Pdf4QtDocDiff/Pdf4QtDocDiff.qbs new file mode 100644 index 0000000..3de568f --- /dev/null +++ b/Pdf4QtDocDiff/Pdf4QtDocDiff.qbs @@ -0,0 +1,11 @@ +Pdf4QtApp { + name: "Pdf4QtDocDiff" + files: [ + "*.cpp", + "*.h", + "*.ui", + "resources.qrc", + ] + cpp.includePaths: ["."] + Depends { name: "Qt"; submodules: ["widgets"] } +} diff --git a/Pdf4QtDocDiff/differencesdockwidget.cpp b/Pdf4QtDocDiff/differencesdockwidget.cpp index 33df982..12dfb53 100644 --- a/Pdf4QtDocDiff/differencesdockwidget.cpp +++ b/Pdf4QtDocDiff/differencesdockwidget.cpp @@ -248,7 +248,7 @@ void DifferencesDockWidget::update() QTreeWidgetItem* parent = topItems.back(); QTreeWidgetItem* item = new QTreeWidgetItem(parent, QStringList() << m_diffResult->getMessage(i)); - item->setData(0, Qt::UserRole, i); + item->setData(0, Qt::UserRole, QVariant(static_cast(i))); QColor color = getColorForIndex(i); diff --git a/Pdf4QtDocDiff/mainwindow.cpp b/Pdf4QtDocDiff/mainwindow.cpp index ec40d9f..76231c3 100644 --- a/Pdf4QtDocDiff/mainwindow.cpp +++ b/Pdf4QtDocDiff/mainwindow.cpp @@ -44,8 +44,10 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_progress(new pdf::PDFProgress(this)), +#ifdef Q_OS_WIN m_taskbarButton(new QWinTaskbarButton(this)), m_progressTaskbarIndicator(nullptr), +#endif m_cmsManager(nullptr), m_pdfWidget(nullptr), m_settingsDockWidget(nullptr), @@ -62,7 +64,9 @@ MainWindow::MainWindow(QWidget* parent) : setMinimumSize(pdf::PDFWidgetUtils::scaleDPI(this, QSize(800, 600))); // Initialize task bar progress +#ifdef Q_OS_WIN m_progressTaskbarIndicator = m_taskbarButton->progress(); +#endif m_settingsDockWidget = new SettingsDockWidget(&m_settings, this); addDockWidget(Qt::LeftDockWidgetArea, m_settingsDockWidget);; @@ -186,7 +190,9 @@ MainWindow::~MainWindow() void MainWindow::showEvent(QShowEvent* event) { Q_UNUSED(event); +#ifdef Q_OS_WIN m_taskbarButton->setWindow(windowHandle()); +#endif } void MainWindow::closeEvent(QCloseEvent* event) @@ -839,9 +845,13 @@ std::optional MainWindow::openDocument() void MainWindow::onProgressStarted(pdf::ProgressStartupInfo info) { +#ifdef Q_OS_WIN m_progressTaskbarIndicator->setRange(0, 100); m_progressTaskbarIndicator->reset(); m_progressTaskbarIndicator->show(); +#else + Q_UNUSED(info); +#endif } void MainWindow::onProgressStep(int percentage) @@ -852,12 +862,18 @@ void MainWindow::onProgressStep(int percentage) } pdf::PDFTemporaryValueChange guard(&m_isChangingProgressStep, true); +#ifdef Q_OS_WIN m_progressTaskbarIndicator->setValue(percentage); +#else + Q_UNUSED(percentage); +#endif } void MainWindow::onProgressFinished() { +#ifdef Q_OS_WIN m_progressTaskbarIndicator->hide(); +#endif } } // namespace pdfdocdiff diff --git a/Pdf4QtDocDiff/mainwindow.h b/Pdf4QtDocDiff/mainwindow.h index 467f60f..805a112 100644 --- a/Pdf4QtDocDiff/mainwindow.h +++ b/Pdf4QtDocDiff/mainwindow.h @@ -27,8 +27,10 @@ #include #include +#ifdef Q_OS_WIN #include #include +#endif namespace Ui { @@ -121,8 +123,10 @@ private: Ui::MainWindow* ui; pdf::PDFProgress* m_progress; +#ifdef Q_OS_WIN QWinTaskbarButton* m_taskbarButton; QWinTaskbarProgress* m_progressTaskbarIndicator; +#endif pdf::PDFCMSManager* m_cmsManager; pdf::PDFWidget* m_pdfWidget; SettingsDockWidget* m_settingsDockWidget; diff --git a/Pdf4QtDocPageOrganizer/Pdf4QtDocPageOrganizer.qbs b/Pdf4QtDocPageOrganizer/Pdf4QtDocPageOrganizer.qbs new file mode 100644 index 0000000..d5c3b4c --- /dev/null +++ b/Pdf4QtDocPageOrganizer/Pdf4QtDocPageOrganizer.qbs @@ -0,0 +1,11 @@ +Pdf4QtApp { + name: "Pdf4QtDocPageOrganizer" + files: [ + "*.cpp", + "*.h", + "*.ui", + "resources.qrc", + ] + cpp.includePaths: ["."] + Depends { name: "Qt"; submodules: ["widgets"] } +} diff --git a/Pdf4QtLib/Pdf4QtLib.qbs b/Pdf4QtLib/Pdf4QtLib.qbs new file mode 100644 index 0000000..5b05c59 --- /dev/null +++ b/Pdf4QtLib/Pdf4QtLib.qbs @@ -0,0 +1,43 @@ +import qbs + +Pdf4QtLibrary { + name: "Pdf4QtLib" + Depends { name: "Qt"; submodules: ["core", "gui", "widgets"] } + Depends { name: "openssl" } + Depends { name: "freetype2" } + Depends { name: "libjpeg" } + Depends { name: "libopenjp2" } + Depends { name: "lcms2" } + Depends { + condition: qbs.toolchain.contains("gcc") + name: "tbb" + } + Depends { + condition: qbs.hostOS.contains("linux") + name: "fontconfig" + } + files: [ + "sources/*.cpp", + "sources/*.h", + "sources/*.ui", + "cmaps.qrc", + ] + Export { + Depends { name: "cpp" } + Depends { name: "Qt"; submodules: ["core", "gui", "widgets"] } + cpp.includePaths: ["sources"] + Depends { name: "openssl" } + Depends { name: "freetype2" } + Depends { name: "libjpeg" } + Depends { name: "libopenjp2" } + Depends { name: "lcms2" } + Depends { + condition: qbs.toolchain.contains("gcc") + name: "tbb" + } + Depends { + condition: qbs.hostOS.contains("linux") + name: "fontconfig" + } + } +} diff --git a/Pdf4QtLib/sources/pdfaction.cpp b/Pdf4QtLib/sources/pdfaction.cpp index f5a499b..f014322 100644 --- a/Pdf4QtLib/sources/pdfaction.cpp +++ b/Pdf4QtLib/sources/pdfaction.cpp @@ -322,7 +322,7 @@ PDFActionPtr PDFAction::parseImpl(const PDFObjectStorage* storage, PDFObject obj PDFFormAction::FieldScope fieldScope = PDFFormAction::FieldScope::All; PDFFileSpecification url = PDFFileSpecification::parse(storage, dictionary->get("F")); PDFFormAction::FieldList fieldList = PDFFormAction::parseFieldList(storage, dictionary->get("Fields"), fieldScope); - PDFActionSubmitForm::SubmitFlags flags = static_cast(loader.readIntegerFromDictionary(dictionary, "Flags", 0)); + PDFActionSubmitForm::SubmitFlags flags = static_cast(loader.readIntegerFromDictionary(dictionary, "Flags", 0)); QByteArray charset = loader.readStringFromDictionary(dictionary, "CharSet"); if (fieldScope == PDFFormAction::FieldScope::Include && @@ -337,7 +337,7 @@ PDFActionPtr PDFAction::parseImpl(const PDFObjectStorage* storage, PDFObject obj { PDFFormAction::FieldScope fieldScope = PDFFormAction::FieldScope::All; PDFFormAction::FieldList fieldList = PDFFormAction::parseFieldList(storage, dictionary->get("Fields"), fieldScope); - PDFActionResetForm::ResetFlags flags = static_cast(loader.readIntegerFromDictionary(dictionary, "Flags", 0)); + PDFActionResetForm::ResetFlags flags = static_cast(loader.readIntegerFromDictionary(dictionary, "Flags", 0)); if (fieldScope == PDFFormAction::FieldScope::Include && flags.testFlag(PDFActionResetForm::IncludeExclude)) diff --git a/Pdf4QtLib/sources/pdfannotation.cpp b/Pdf4QtLib/sources/pdfannotation.cpp index cd79e79..cf0080e 100644 --- a/Pdf4QtLib/sources/pdfannotation.cpp +++ b/Pdf4QtLib/sources/pdfannotation.cpp @@ -848,7 +848,7 @@ PDFAnnotationPtr PDFAnnotation::parse(const PDFObjectStorage* storage, PDFObject result->m_lastModifiedString = loader.readTextStringFromDictionary(dictionary, "M", QString()); } - result->m_flags = Flags(loader.readIntegerFromDictionary(dictionary, "F", 0)); + result->m_flags = Flags(static_cast(loader.readIntegerFromDictionary(dictionary, "F", 0))); result->m_appearanceStreams = PDFAppeareanceStreams::parse(storage, dictionary->get("AP")); result->m_appearanceState = loader.readNameFromDictionary(dictionary, "AS"); diff --git a/Pdf4QtLib/sources/pdfccittfaxdecoder.cpp b/Pdf4QtLib/sources/pdfccittfaxdecoder.cpp index 216c111..7a3b004 100644 --- a/Pdf4QtLib/sources/pdfccittfaxdecoder.cpp +++ b/Pdf4QtLib/sources/pdfccittfaxdecoder.cpp @@ -28,20 +28,6 @@ constexpr uint8_t operator "" _bitlength() return sizeof...(Digits); } -enum CCITT_2D_Code_Mode -{ - Pass, - Horizontal, - Vertical_3L, - Vertical_2L, - Vertical_1L, - Vertical_0, - Vertical_1R, - Vertical_2R, - Vertical_3R, - Invalid -}; - struct PDFCCITT2DModeInfo { CCITT_2D_Code_Mode mode; diff --git a/Pdf4QtLib/sources/pdfccittfaxdecoder.h b/Pdf4QtLib/sources/pdfccittfaxdecoder.h index d36361c..54f0338 100644 --- a/Pdf4QtLib/sources/pdfccittfaxdecoder.h +++ b/Pdf4QtLib/sources/pdfccittfaxdecoder.h @@ -72,7 +72,19 @@ struct PDFCCITTFaxDecoderParameters PDFImageData::MaskingType maskingType = PDFImageData::MaskingType::None; }; -enum CCITT_2D_Code_Mode; +enum CCITT_2D_Code_Mode +{ + Pass, + Horizontal, + Vertical_3L, + Vertical_2L, + Vertical_1L, + Vertical_0, + Vertical_1R, + Vertical_2R, + Vertical_3R, + Invalid +}; class PDFCCITTFaxDecoder { diff --git a/Pdf4QtLib/sources/pdfcms.cpp b/Pdf4QtLib/sources/pdfcms.cpp index 91b4ddd..6154a6c 100644 --- a/Pdf4QtLib/sources/pdfcms.cpp +++ b/Pdf4QtLib/sources/pdfcms.cpp @@ -1732,7 +1732,7 @@ PDFColorProfileIdentifiers PDFCMSManager::getExternalProfilesImpl() const QStringList directories(m_settings.profileDirectory); -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) std::array buffer = { }; DWORD bufferSize = DWORD(buffer.size() * sizeof(WCHAR)); if (GetColorDirectoryW(NULL, buffer.data(), &bufferSize)) @@ -1743,8 +1743,20 @@ PDFColorProfileIdentifiers PDFCMSManager::getExternalProfilesImpl() const QString directory = QString::fromWCharArray(buffer.data(), int(charactersWithoutNull)); directories << QDir::fromNativeSeparators(directory); } +#elif defined(Q_OS_UNIX) + QDir directory(QStringLiteral("/usr/share/color/icc")); + if (directory.exists()) + { + QStringList colorDirectories = directory.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + for (const QString colorDirectory : colorDirectories) + { + QString colorDirectoryName = directory.absoluteFilePath(colorDirectory); + directories << QDir::fromNativeSeparators(colorDirectoryName); + } + } +#else + static_assert(false, "Implement this for another OS!"); #endif - for (const QString& directory : directories) { PDFColorProfileIdentifiers externalProfiles = getExternalColorProfiles(directory); diff --git a/Pdf4QtLib/sources/pdfcolorspaces.cpp b/Pdf4QtLib/sources/pdfcolorspaces.cpp index e38b031..231e68d 100644 --- a/Pdf4QtLib/sources/pdfcolorspaces.cpp +++ b/Pdf4QtLib/sources/pdfcolorspaces.cpp @@ -731,7 +731,7 @@ bool PDFAbstractColorSpace::transform(const PDFAbstractColorSpace* source, for (PDFColorComponent gray : input) { const PDFColorComponent A = clip01(gray); - const PDFColorComponent xyzColor = std::powf(A, gamma); + const PDFColorComponent xyzColor = std::pow(A, gamma); Q_ASSERT(it != transformedInputColorsVector.end()); *it++ = xyzColor; @@ -981,7 +981,7 @@ bool PDFAbstractColorSpace::transform(const PDFAbstractColorSpace* source, XYZ[2] = *std::next(transformedOutputIt, 2); const PDFColorComponent gray = (XYZ[0] + XYZ[1] + XYZ[2]) * 0.333333333333333; - const PDFColorComponent grayWithGamma = std::powf(gray, gamma); + const PDFColorComponent grayWithGamma = std::pow(gray, gamma); Q_ASSERT(outputIt != output.cend()); *outputIt++ = grayWithGamma; } @@ -1271,7 +1271,7 @@ QColor PDFCalGrayColorSpace::getColor(const PDFColor& color, const PDFCMS* cms, Q_UNUSED(isRange01); const PDFColorComponent A = clip01(color[0]); - const PDFColorComponent xyzColor = std::powf(A, m_gamma); + const PDFColorComponent xyzColor = std::pow(A, m_gamma); PDFColor3 xyzColorCMS = { xyzColor, xyzColor, xyzColor }; QColor cmsColor = cms->getColorFromXYZ(m_whitePoint, xyzColorCMS, intent, reporter); @@ -1297,7 +1297,7 @@ void PDFCalGrayColorSpace::fillRGBBuffer(const std::vector& colors, unsig auto it = xyzColors.begin(); for (float gray : colors) { - const PDFColorComponent xyzColor = std::powf(clip01(gray), m_gamma); + const PDFColorComponent xyzColor = std::pow(clip01(gray), m_gamma); *it++ = xyzColor; *it++ = xyzColor; *it++ = xyzColor; diff --git a/Pdf4QtLib/sources/pdfcolorspaces.h b/Pdf4QtLib/sources/pdfcolorspaces.h index 0bc6dca..0399897 100644 --- a/Pdf4QtLib/sources/pdfcolorspaces.h +++ b/Pdf4QtLib/sources/pdfcolorspaces.h @@ -533,7 +533,7 @@ protected: PDFColor3 result = { }; for (size_t i = 0; i < color.size(); ++i) { - result[i] = std::powf(color[i], factors[i]); + result[i] = std::pow(color[i], factors[i]); } return result; } diff --git a/Pdf4QtLib/sources/pdfconstants.h b/Pdf4QtLib/sources/pdfconstants.h index 5ff7b68..e3a98d2 100644 --- a/Pdf4QtLib/sources/pdfconstants.h +++ b/Pdf4QtLib/sources/pdfconstants.h @@ -19,6 +19,8 @@ #ifndef PDFCONSTANTS_H #define PDFCONSTANTS_H +#include + namespace pdf { diff --git a/Pdf4QtLib/sources/pdfdocumentbuilder.cpp b/Pdf4QtLib/sources/pdfdocumentbuilder.cpp index 3b098b1..5a47f84 100644 --- a/Pdf4QtLib/sources/pdfdocumentbuilder.cpp +++ b/Pdf4QtLib/sources/pdfdocumentbuilder.cpp @@ -567,6 +567,12 @@ PDFObjectFactory& PDFObjectFactory::operator<<(int value) return *this; } +PDFObjectFactory& PDFObjectFactory::operator<<(PDFFormSubmitFlags flags) +{ + *this << PDFInteger(flags); + return *this; +} + PDFObjectFactory& PDFObjectFactory::operator<<(WrapName wrapName) { addObject(PDFObject::createName(qMove(wrapName.name))); diff --git a/Pdf4QtLib/sources/pdfdocumentbuilder.h b/Pdf4QtLib/sources/pdfdocumentbuilder.h index 7fd7bd1..d3cc6f3 100644 --- a/Pdf4QtLib/sources/pdfdocumentbuilder.h +++ b/Pdf4QtLib/sources/pdfdocumentbuilder.h @@ -125,6 +125,7 @@ public: PDFObjectFactory& operator<<(FileAttachmentIcon icon); PDFObjectFactory& operator<<(const PDFDestination& destination); PDFObjectFactory& operator<<(PageRotation pageRotation); + PDFObjectFactory& operator<<(PDFFormSubmitFlags flags); /// Treat containers - write them as array template()))> diff --git a/Pdf4QtLib/sources/pdfencoding.cpp b/Pdf4QtLib/sources/pdfencoding.cpp index a255eb1..2df2f4b 100644 --- a/Pdf4QtLib/sources/pdfencoding.cpp +++ b/Pdf4QtLib/sources/pdfencoding.cpp @@ -21,6 +21,7 @@ #include #include +#include namespace pdf { diff --git a/Pdf4QtLib/sources/pdfexecutionpolicy.h b/Pdf4QtLib/sources/pdfexecutionpolicy.h index b53b61e..c84619a 100644 --- a/Pdf4QtLib/sources/pdfexecutionpolicy.h +++ b/Pdf4QtLib/sources/pdfexecutionpolicy.h @@ -133,7 +133,7 @@ public: } else { - std::for_each(std::execution::sequenced_policy(), first, last, f); + std::for_each(std::execution::seq, first, last, f); } } @@ -143,7 +143,7 @@ public: Q_UNUSED(scope); // We always sort by single thread - std::sort(std::execution::sequenced_policy(), first, last, f); + std::sort(std::execution::seq, first, last, f); } /// Returns number of active threads for given scope diff --git a/Pdf4QtLib/sources/pdffont.cpp b/Pdf4QtLib/sources/pdffont.cpp index 33a669c..fa39178 100644 --- a/Pdf4QtLib/sources/pdffont.cpp +++ b/Pdf4QtLib/sources/pdffont.cpp @@ -20,6 +20,7 @@ #include "pdfparser.h" #include "pdfnametounicode.h" #include "pdfexception.h" +#include "pdfutils.h" #include #include @@ -33,17 +34,17 @@ #include #include #include - -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) #include "Windows.h" #pragma comment(lib, "Gdi32") #pragma comment(lib, "User32") +#elif defined(Q_OS_UNIX) +#include #endif namespace pdf { - /// Storage class for system fonts class PDFSystemFontInfoStorage { @@ -59,6 +60,13 @@ public: private: explicit PDFSystemFontInfoStorage(); +#ifdef Q_OS_UNIX + static void checkFontConfigError(FcBool result); +#endif + + /// Create a postscript name for comparation purposes + static QString getFontPostscriptName(QString fontName); + #ifdef Q_OS_WIN /// Callback for enumerating fonts static int CALLBACK enumerateFontProc(const LOGFONT* font, const TEXTMETRIC* textMetrics, DWORD fontType, LPARAM lParam); @@ -66,9 +74,6 @@ private: /// Retrieves font data for desired font static QByteArray getFontData(const LOGFONT* font, HDC hdc); - /// Create a postscript name for comparation purposes - static QString getFontPostscriptName(QString fontName); - struct FontInfo { QString faceName; @@ -96,14 +101,9 @@ const PDFSystemFontInfoStorage* PDFSystemFontInfoStorage::getInstance() QByteArray PDFSystemFontInfoStorage::loadFont(const FontDescriptor* descriptor, StandardFontType standardFontType, PDFRenderErrorReporter* reporter) const { QByteArray result; - -#ifdef Q_OS_WIN - HDC hdc = GetDC(NULL); - - const BYTE lfItalic = (descriptor->italicAngle != 0.0 ? TRUE : FALSE); + QString fontName; // Exact match font face name - QString fontName; switch (standardFontType) { case StandardFontType::TimesRoman: @@ -147,6 +147,9 @@ QByteArray PDFSystemFontInfoStorage::loadFont(const FontDescriptor* descriptor, } } +#if defined(Q_OS_WIN) + HDC hdc = GetDC(NULL); + const BYTE lfItalic = (descriptor->italicAngle != 0.0 ? TRUE : FALSE); if (!fontName.isEmpty()) { for (const FontInfo& fontInfo : m_fontInfos) @@ -251,7 +254,61 @@ QByteArray PDFSystemFontInfoStorage::loadFont(const FontDescriptor* descriptor, } ReleaseDC(NULL, hdc); -#endif +#elif defined(Q_OS_UNIX) + FcPattern* p = FcPatternBuild(nullptr, FC_FAMILY, FcTypeString, fontName.constData(), nullptr); + if (!p) + { + throw PDFException(PDFTranslationContext::tr("FontConfig error building pattern for font %1").arg(fontName)); + } + + constexpr const std::array, 9> weights{ + std::pair{100, FC_WEIGHT_EXTRALIGHT}, + std::pair{200, FC_WEIGHT_LIGHT}, + std::pair{300, FC_WEIGHT_BOOK}, + std::pair{400, FC_WEIGHT_NORMAL}, + std::pair{500, FC_WEIGHT_MEDIUM}, + std::pair{600, FC_WEIGHT_DEMIBOLD}, + std::pair{700, FC_WEIGHT_BOLD}, + std::pair{800, FC_WEIGHT_EXTRABOLD}, + std::pair{900, FC_WEIGHT_EXTRABOLD}}; + auto wit = std::lower_bound(weights.cbegin(), weights.cend(), descriptor->fontWeight, [](const std::pair& data, PDFReal key) { return data.first < key; }); + if (wit != weights.cend()) + { + checkFontConfigError(FcPatternAddInteger(p, FC_WEIGHT, wit->second)); + } + + constexpr const std::array, 9> stretches{ + std::pair{QFont::UltraCondensed, FC_WIDTH_ULTRACONDENSED}, + std::pair{QFont::ExtraCondensed, FC_WIDTH_EXTRACONDENSED}, + std::pair{QFont::Condensed, FC_WIDTH_CONDENSED}, + std::pair{QFont::SemiCondensed, FC_WIDTH_SEMICONDENSED}, + std::pair{QFont::Unstretched, FC_WIDTH_NORMAL}, + std::pair{QFont::SemiExpanded, FC_WIDTH_SEMIEXPANDED}, + std::pair{QFont::Expanded, FC_WIDTH_EXPANDED}, + std::pair{QFont::ExtraExpanded, FC_WIDTH_EXTRAEXPANDED}, + std::pair{QFont::UltraExpanded, FC_WIDTH_ULTRAEXPANDED}}; + + auto sit = std::find_if(stretches.cbegin(), stretches.cend(), [&](const std::pair& item) { return item.first == descriptor->fontStretch; }); + if (sit != stretches.cend()) + { + checkFontConfigError(FcPatternAddInteger(p, FC_WIDTH, sit->second)); + } + + checkFontConfigError(FcConfigSubstitute(nullptr, p, FcMatchPattern)); + FcDefaultSubstitute(p); + FcResult res = FcResultNoMatch; + FcPattern* match = FcFontMatch(nullptr, p, &res); + if (match) + { + FcChar8* s = nullptr; + if (FcPatternGetString(match, FC_FILE, 0, &s) == FcResultMatch) + { + QFile f(QString::fromUtf8(reinterpret_cast(s))); + f.open(QIODevice::ReadOnly); + result = f.readAll(); + f.close(); + } + } if (result.isEmpty() && standardFontType == StandardFontType::Invalid) { @@ -260,6 +317,7 @@ QByteArray PDFSystemFontInfoStorage::loadFont(const FontDescriptor* descriptor, } return result; +#endif } PDFSystemFontInfoStorage::PDFSystemFontInfoStorage() @@ -325,6 +383,17 @@ QByteArray PDFSystemFontInfoStorage::getFontData(const LOGFONT* font, HDC hdc) return byteArray; } +#endif + +#ifdef Q_OS_UNIX +void PDFSystemFontInfoStorage::checkFontConfigError(FcBool result) +{ + if (!result) + { + throw PDFException(PDFTranslationContext::tr("Fontconfig error")); + } +} +#endif QString PDFSystemFontInfoStorage::getFontPostscriptName(QString fontName) { @@ -336,8 +405,6 @@ QString PDFSystemFontInfoStorage::getFontPostscriptName(QString fontName) return fontName.remove(QChar(' ')).remove(QChar('-')).remove(QChar(',')).trimmed(); } -#endif - PDFFont::PDFFont(FontDescriptor fontDescriptor) : m_fontDescriptor(qMove(fontDescriptor)) { diff --git a/Pdf4QtLib/sources/pdfform.cpp b/Pdf4QtLib/sources/pdfform.cpp index ef9a604..64d9e3c 100644 --- a/Pdf4QtLib/sources/pdfform.cpp +++ b/Pdf4QtLib/sources/pdfform.cpp @@ -523,7 +523,7 @@ PDFForm PDFForm::parse(const PDFDocument* document, PDFObject object) form.m_formType = FormType::AcroForm; form.m_needAppearances = loader.readBooleanFromDictionary(formDictionary, "NeedAppearances", false); - form.m_signatureFlags = static_cast(loader.readIntegerFromDictionary(formDictionary, "SigFlags", 0)); + form.m_signatureFlags = static_cast(static_cast(loader.readIntegerFromDictionary(formDictionary, "SigFlags", 0))); form.m_calculationOrder = loader.readReferenceArrayFromDictionary(formDictionary, "CO"); form.m_resources = formDictionary->get("DR"); form.m_defaultAppearance = loader.readOptionalStringFromDictionary(formDictionary, "DA"); @@ -761,7 +761,7 @@ PDFFormFieldPointer PDFFormField::parse(const PDFObjectStorage* storage, PDFObje formField->m_fieldNames[Partial] = loader.readTextStringFromDictionary(fieldDictionary, "T", QString()); formField->m_fieldNames[UserCaption] = loader.readTextStringFromDictionary(fieldDictionary, "TU", QString()); formField->m_fieldNames[Export] = loader.readTextStringFromDictionary(fieldDictionary, "TM", QString()); - formField->m_fieldFlags = fieldDictionary->hasKey("Ff") ? static_cast(loader.readIntegerFromDictionary(fieldDictionary, "Ff", 0)) : parentFlags; + formField->m_fieldFlags = fieldDictionary->hasKey("Ff") ? static_cast(static_cast(loader.readIntegerFromDictionary(fieldDictionary, "Ff", 0))) : parentFlags; formField->m_value = fieldDictionary->hasKey("V") ? fieldDictionary->get("V") : parentV; formField->m_defaultValue = fieldDictionary->hasKey("DV") ? fieldDictionary->get("DV") : parentDV; formField->m_additionalActions = PDFAnnotationAdditionalActions::parse(storage, fieldDictionary->get("AA"), fieldDictionary->get("A")); diff --git a/Pdf4QtLib/sources/pdfitemmodels.h b/Pdf4QtLib/sources/pdfitemmodels.h index 25f1afb..0222219 100644 --- a/Pdf4QtLib/sources/pdfitemmodels.h +++ b/Pdf4QtLib/sources/pdfitemmodels.h @@ -248,7 +248,7 @@ class PDF4QTLIBSHARED_EXPORT PDFThumbnailsItemModel : public QAbstractItemModel Q_OBJECT public: - explicit inline PDFThumbnailsItemModel(const PDFDrawWidgetProxy* proxy, QObject* parent); + explicit PDFThumbnailsItemModel(const PDFDrawWidgetProxy* proxy, QObject* parent); bool isEmpty() const; diff --git a/Pdf4QtLib/sources/pdfobject.h b/Pdf4QtLib/sources/pdfobject.h index 91a084f..4a90652 100644 --- a/Pdf4QtLib/sources/pdfobject.h +++ b/Pdf4QtLib/sources/pdfobject.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace pdf { diff --git a/Pdf4QtLib/sources/pdfpagecontentprocessor.h b/Pdf4QtLib/sources/pdfpagecontentprocessor.h index 6fdccc2..d3dabac 100644 --- a/Pdf4QtLib/sources/pdfpagecontentprocessor.h +++ b/Pdf4QtLib/sources/pdfpagecontentprocessor.h @@ -812,18 +812,6 @@ private: template T readOperand(size_t index) const; - template<> - PDFReal readOperand(size_t index) const; - - template<> - PDFInteger readOperand(size_t index) const; - - template<> - PDFOperandName readOperand(size_t index) const; - - template<> - PDFOperandString readOperand(size_t index) const; - template inline T readOperand() const { return readOperand(index); } @@ -1093,6 +1081,18 @@ private: PDFInteger m_structuralParentKey; }; +template<> +PDFReal PDFPageContentProcessor::readOperand(size_t index) const; + +template<> +PDFInteger PDFPageContentProcessor::readOperand(size_t index) const; + +template<> +PDFPageContentProcessor::PDFOperandName PDFPageContentProcessor::readOperand(size_t index) const; + +template<> +PDFPageContentProcessor::PDFOperandString PDFPageContentProcessor::readOperand(size_t index) const; + } // namespace pdf #endif // PDFPAGECONTENTPROCESSOR_H diff --git a/Pdf4QtLib/sources/pdfpainter.h b/Pdf4QtLib/sources/pdfpainter.h index 40e2a40..480be2e 100644 --- a/Pdf4QtLib/sources/pdfpainter.h +++ b/Pdf4QtLib/sources/pdfpainter.h @@ -356,7 +356,7 @@ class PDF4QTLIBSHARED_EXPORT PDFPrecompiledPageGenerator : public PDFPainterBase using BaseClass = PDFPainterBase; public: - explicit inline PDFPrecompiledPageGenerator(PDFPrecompiledPage* precompiledPage, + explicit PDFPrecompiledPageGenerator(PDFPrecompiledPage* precompiledPage, PDFRenderer::Features features, const PDFPage* page, const PDFDocument* document, diff --git a/Pdf4QtLib/sources/pdfparser.cpp b/Pdf4QtLib/sources/pdfparser.cpp index 84addf6..77ea9e2 100644 --- a/Pdf4QtLib/sources/pdfparser.cpp +++ b/Pdf4QtLib/sources/pdfparser.cpp @@ -163,7 +163,7 @@ PDFLexicalAnalyzer::Token PDFLexicalAnalyzer::fetch() real = -real; } - return !treatAsReal ? Token(TokenType::Integer, integer) : Token(TokenType::Real, real); + return !treatAsReal ? Token(TokenType::Integer, QVariant(static_cast(integer))) : Token(TokenType::Real, real); } case CHAR_LEFT_BRACKET: diff --git a/Pdf4QtLib/sources/pdfpattern.h b/Pdf4QtLib/sources/pdfpattern.h index 584291f..1240ed4 100644 --- a/Pdf4QtLib/sources/pdfpattern.h +++ b/Pdf4QtLib/sources/pdfpattern.h @@ -24,6 +24,7 @@ #include "pdfmeshqualitysettings.h" #include +#include #include diff --git a/Pdf4QtLib/sources/pdfsignaturehandler.cpp b/Pdf4QtLib/sources/pdfsignaturehandler.cpp index 780bb65..b2c0f92 100644 --- a/Pdf4QtLib/sources/pdfsignaturehandler.cpp +++ b/Pdf4QtLib/sources/pdfsignaturehandler.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2021 Jakub Melka + // Copyright (C) 2020-2021 Jakub Melka // // This file is part of PDF4QT. // @@ -35,6 +35,9 @@ #include #include +#ifdef Q_OS_UNIX +#include +#endif namespace pdf { @@ -1833,7 +1836,13 @@ QDateTime PDFPublicKeySignatureHandler::getDateTimeFromASN(const ASN1_TIME* time tm internalTime = { }; if (ASN1_TIME_to_tm(time, &internalTime) > 0) { +#if defined(Q_OS_WIN) time_t localTime = _mkgmtime(&internalTime); +#elif defined(Q_OS_UNIX) + time_t localTime = timegm(&internalTime); +#else + static_assert(false, "Implement this for another OS!"); +#endif result = QDateTime::fromSecsSinceEpoch(localTime, Qt::UTC); } } diff --git a/Pdf4QtLib/sources/pdftextlayout.cpp b/Pdf4QtLib/sources/pdftextlayout.cpp index 708adce..c099983 100644 --- a/Pdf4QtLib/sources/pdftextlayout.cpp +++ b/Pdf4QtLib/sources/pdftextlayout.cpp @@ -1194,7 +1194,7 @@ PDFTextFlows PDFTextFlow::createTextFlows(const PDFTextLayout& layout, FlowFlags #if defined(Q_OS_WIN) lineBreak = QString("\r\n"); #elif defined(Q_OS_UNIX) - linebreak = QString("\n"); + lineBreak = QString("\n"); #elif defined(Q_OS_MAC) lineBreak = QString("\r"); #else diff --git a/Pdf4QtLib/sources/pdftransparencyrenderer.h b/Pdf4QtLib/sources/pdftransparencyrenderer.h index d538076..355713a 100644 --- a/Pdf4QtLib/sources/pdftransparencyrenderer.h +++ b/Pdf4QtLib/sources/pdftransparencyrenderer.h @@ -622,7 +622,7 @@ struct PDFTransparencyRendererSettings Q_DECLARE_FLAGS(Flags, Flag) /// Flags - Flags flags = DisplayImages | DisplayText | DisplayVectorGraphics | DisplayShadings | DisplayTilingPatterns; + Flags flags = static_cast(DisplayImages | DisplayText | DisplayVectorGraphics | DisplayShadings | DisplayTilingPatterns); /// Active color mask uint32_t activeColorMask = PDFPixelFormat::getAllColorsMask(); diff --git a/Pdf4QtLib/sources/pdfutils.cpp b/Pdf4QtLib/sources/pdfutils.cpp index 7725e8d..c2cf2a0 100644 --- a/Pdf4QtLib/sources/pdfutils.cpp +++ b/Pdf4QtLib/sources/pdfutils.cpp @@ -243,7 +243,11 @@ std::vector PDFDependentLibraryInfo::getLibraryInfo() libjpegInfo.library = tr("libjpeg"); libjpegInfo.license = tr("permissive + ack."); libjpegInfo.url = tr("https://www.ijg.org/"); +#if defined(Q_OS_UNIX) + libjpegInfo.version = tr("%1").arg(JPEG_LIB_VERSION); +#else libjpegInfo.version = tr("%1.%2").arg(JPEG_LIB_VERSION_MAJOR).arg(JPEG_LIB_VERSION_MINOR); +#endif result.emplace_back(qMove(libjpegInfo)); // FreeType @@ -573,4 +577,18 @@ QColor PDFColorScale::map(PDFReal value) const return QColor::fromRgbF(r, g, b); } +QDataStream& operator<<(QDataStream& stream, long unsigned int i) +{ + stream << quint64(i); + return stream; +} + +QDataStream& operator>>(QDataStream& stream, long unsigned int &i) +{ + quint64 value = 0; + stream >> value; + i = value; + return stream; +} + } // namespace pdf diff --git a/Pdf4QtLib/sources/pdfutils.h b/Pdf4QtLib/sources/pdfutils.h index 04de974..f7e55a9 100644 --- a/Pdf4QtLib/sources/pdfutils.h +++ b/Pdf4QtLib/sources/pdfutils.h @@ -735,6 +735,8 @@ QDataStream& operator>>(QDataStream& stream, std::vector& vector) return stream; } +QDataStream& operator<<(QDataStream& stream, long unsigned int i); + template QDataStream& operator<<(QDataStream& stream, const std::vector& vector) { @@ -746,6 +748,8 @@ QDataStream& operator<<(QDataStream& stream, const std::vector& vector) return stream; } +QDataStream& operator>>(QDataStream& stream, long unsigned int &i); + template QDataStream& operator>>(QDataStream& stream, std::array& array) { diff --git a/Pdf4QtLib/sources/pdfvisitor.h b/Pdf4QtLib/sources/pdfvisitor.h index 8abdc5d..8d76a2f 100644 --- a/Pdf4QtLib/sources/pdfvisitor.h +++ b/Pdf4QtLib/sources/pdfvisitor.h @@ -162,7 +162,7 @@ struct PDFApplyVisitorImpl const PDFObjectStorage::PDFObjects& objects = storage.getObjects(); const PDFObject& trailerDictionary = storage.getTrailerDictionary(); - std::for_each(std::execution::parallel_policy(), objects.cbegin(), objects.cend(), [visitor](const PDFObjectStorage::Entry& entry) { entry.object.accept(visitor); }); + std::for_each(std::execution::par, objects.cbegin(), objects.cend(), [visitor](const PDFObjectStorage::Entry& entry) { entry.object.accept(visitor); }); trailerDictionary.accept(visitor); } }; @@ -187,7 +187,7 @@ struct PDFApplyVisitorImpl visitor->merge(&localVisitor); }; - std::for_each(std::execution::parallel_policy(), objects.cbegin(), objects.cend(), process); + std::for_each(std::execution::par, objects.cbegin(), objects.cend(), process); trailerDictionary.accept(visitor); } }; @@ -201,7 +201,7 @@ struct PDFApplyVisitorImpl const PDFObjectStorage::PDFObjects& objects = storage.getObjects(); const PDFObject& trailerDictionary = storage.getTrailerDictionary(); - std::for_each(std::execution::sequenced_policy(), objects.cbegin(), objects.cend(), [](const PDFObjectStorage::Entry& entry) { entry.object.accept(visitor); }); + std::for_each(std::execution::seq, objects.cbegin(), objects.cend(), [visitor](const PDFObjectStorage::Entry& entry) { entry.object.accept(visitor); }); trailerDictionary.accept(visitor); } }; diff --git a/Pdf4QtViewer/Pdf4QtViewer.qbs b/Pdf4QtViewer/Pdf4QtViewer.qbs new file mode 100644 index 0000000..5bf64ea --- /dev/null +++ b/Pdf4QtViewer/Pdf4QtViewer.qbs @@ -0,0 +1,18 @@ +Pdf4QtLibrary { + name: "Pdf4QtViewer" + files: [ + "*.h", + "*.cpp", + "*.ui", + "pdf4qtviewer.qrc", + ] + cpp.includePaths: ["."] + cpp.defines: ['QT_INSTALL_DIRECTORY=""'] + Depends { name: "Qt"; submodules: ["printsupport", "texttospeech", "network", "xml"] } + Depends { name: "Pdf4QtLib" } + Export { + Depends { name: "cpp" } + cpp.includePaths: ["."] + Depends { name: "Pdf4QtLib" } + } +} diff --git a/Pdf4QtViewer/pdfprogramcontroller.cpp b/Pdf4QtViewer/pdfprogramcontroller.cpp index 0ed5d5f..821320d 100644 --- a/Pdf4QtViewer/pdfprogramcontroller.cpp +++ b/Pdf4QtViewer/pdfprogramcontroller.cpp @@ -1769,9 +1769,15 @@ void PDFProgramController::updatePageLayoutActions() void PDFProgramController::loadPlugins() { +#if defined(Q_OS_WIN) QDir directory(QApplication::applicationDirPath() + "/pdfplugins"); QStringList availablePlugins = directory.entryList(QStringList("*.dll")); - +#elif defined(Q_OS_UNIX) + QDir directory(QApplication::applicationDirPath() + "/../pdfplugins"); + QStringList availablePlugins = directory.entryList(QStringList("*.so")); +#else + static_assert(false, "Implement this for another OS!"); +#endif for (const QString& availablePlugin : availablePlugins) { QString pluginFileName = directory.absoluteFilePath(availablePlugin); diff --git a/Pdf4QtViewer/pdfsendmail.cpp b/Pdf4QtViewer/pdfsendmail.cpp index 39affd0..46244b6 100644 --- a/Pdf4QtViewer/pdfsendmail.cpp +++ b/Pdf4QtViewer/pdfsendmail.cpp @@ -84,6 +84,9 @@ bool PDFSendMail::sendMail(QWidget* parent, QString subject, QString fileName) return false; } + return false; +#elif defined(Q_OS_UNIX) + // TODO return false; #else static_assert(false, "Implement this for another OS!"); diff --git a/Pdf4QtViewer/pdfsidebarwidget.cpp b/Pdf4QtViewer/pdfsidebarwidget.cpp index 3e410db..a6e6783 100644 --- a/Pdf4QtViewer/pdfsidebarwidget.cpp +++ b/Pdf4QtViewer/pdfsidebarwidget.cpp @@ -464,7 +464,7 @@ void PDFSidebarWidget::updateSignatures(const std::vectorsetData(0, Qt::UserRole, m_certificateInfos.size() - 1); + certRoot->setData(0, Qt::UserRole, QVariant(static_cast(m_certificateInfos.size() - 1))); } auto addName = [certRoot, ¤tCertificateInfo, &infoIcon](pdf::PDFCertificateInfo::NameEntry nameEntry, QString caption) diff --git a/Pdf4QtViewer/pdfviewermainwindow.cpp b/Pdf4QtViewer/pdfviewermainwindow.cpp index b6678cb..d1c1e56 100644 --- a/Pdf4QtViewer/pdfviewermainwindow.cpp +++ b/Pdf4QtViewer/pdfviewermainwindow.cpp @@ -90,8 +90,10 @@ PDFViewerMainWindow::PDFViewerMainWindow(QWidget* parent) : m_pageZoomSpinBox(nullptr), m_isLoadingUI(false), m_progress(new pdf::PDFProgress(this)), +#ifdef Q_OS_WIN m_taskbarButton(new QWinTaskbarButton(this)), m_progressTaskbarIndicator(nullptr), +#endif m_progressDialog(nullptr), m_isChangingProgressStep(false) { @@ -103,7 +105,9 @@ PDFViewerMainWindow::PDFViewerMainWindow(QWidget* parent) : adjustToolbar(ui->mainToolBar); // Initialize task bar progress +#ifdef Q_OS_WIN m_progressTaskbarIndicator = m_taskbarButton->progress(); +#endif // Initialize actions m_actionManager->setAction(PDFActionManager::Open, ui->actionOpen); @@ -347,9 +351,11 @@ void PDFViewerMainWindow::onProgressStarted(pdf::ProgressStartupInfo info) m_progressDialog->setCancelButton(nullptr); } +#ifdef Q_OS_WIN m_progressTaskbarIndicator->setRange(0, 100); m_progressTaskbarIndicator->reset(); m_progressTaskbarIndicator->show(); +#endif m_programController->setIsBusy(true); m_programController->updateActionsAvailability(); @@ -369,7 +375,9 @@ void PDFViewerMainWindow::onProgressStep(int percentage) m_progressDialog->setValue(percentage); } +#ifdef Q_OS_WIN m_progressTaskbarIndicator->setValue(percentage); +#endif } void PDFViewerMainWindow::onProgressFinished() @@ -380,7 +388,9 @@ void PDFViewerMainWindow::onProgressFinished() m_progressDialog->deleteLater(); m_progressDialog = nullptr; } +#ifdef Q_OS_WIN m_progressTaskbarIndicator->hide(); +#endif m_programController->setIsBusy(false); m_programController->updateActionsAvailability(); @@ -507,7 +517,9 @@ void PDFViewerMainWindow::closeEvent(QCloseEvent* event) void PDFViewerMainWindow::showEvent(QShowEvent* event) { Q_UNUSED(event); +#ifdef Q_OS_WIN m_taskbarButton->setWindow(windowHandle()); +#endif } void PDFViewerMainWindow::dragEnterEvent(QDragEnterEvent* event) diff --git a/Pdf4QtViewer/pdfviewermainwindow.h b/Pdf4QtViewer/pdfviewermainwindow.h index 56c0085..a178d3f 100644 --- a/Pdf4QtViewer/pdfviewermainwindow.h +++ b/Pdf4QtViewer/pdfviewermainwindow.h @@ -38,8 +38,10 @@ #include #include #include +#ifdef Q_OS_WIN #include #include +#endif #include #include @@ -118,8 +120,10 @@ private: QDoubleSpinBox* m_pageZoomSpinBox; bool m_isLoadingUI; pdf::PDFProgress* m_progress; +#ifdef Q_OS_WIN QWinTaskbarButton* m_taskbarButton; QWinTaskbarProgress* m_progressTaskbarIndicator; +#endif QProgressDialog* m_progressDialog; bool m_isChangingProgressStep; diff --git a/Pdf4QtViewer/pdfviewermainwindowlite.cpp b/Pdf4QtViewer/pdfviewermainwindowlite.cpp index d41aa4c..225472a 100644 --- a/Pdf4QtViewer/pdfviewermainwindowlite.cpp +++ b/Pdf4QtViewer/pdfviewermainwindowlite.cpp @@ -15,8 +15,8 @@ // You should have received a copy of the GNU Lesser General Public License // along with PDF4QT. If not, see . -#include "PDFViewerMainWindowLite.h" -#include "ui_PDFViewerMainWindowLite.h" +#include "pdfviewermainwindowlite.h" +#include "ui_pdfviewermainwindowlite.h" #include "pdfaboutdialog.h" #include "pdfsidebarwidget.h" @@ -88,8 +88,10 @@ PDFViewerMainWindowLite::PDFViewerMainWindowLite(QWidget* parent) : m_pageZoomSpinBox(nullptr), m_isLoadingUI(false), m_progress(new pdf::PDFProgress(this)), +#ifdef Q_OS_WIN m_taskbarButton(new QWinTaskbarButton(this)), m_progressTaskbarIndicator(nullptr), +#endif m_progressDialog(nullptr), m_isChangingProgressStep(false) { @@ -101,7 +103,9 @@ PDFViewerMainWindowLite::PDFViewerMainWindowLite(QWidget* parent) : adjustToolbar(ui->mainToolBar); // Initialize task bar progress +#ifdef Q_OS_WIN m_progressTaskbarIndicator = m_taskbarButton->progress(); +#endif // Initialize actions m_actionManager->setAction(PDFActionManager::Open, ui->actionOpen); @@ -271,9 +275,11 @@ void PDFViewerMainWindowLite::onProgressStarted(pdf::ProgressStartupInfo info) m_progressDialog->setCancelButton(nullptr); } +#ifdef Q_OS_WIN m_progressTaskbarIndicator->setRange(0, 100); m_progressTaskbarIndicator->reset(); m_progressTaskbarIndicator->show(); +#endif m_programController->setIsBusy(true); m_programController->updateActionsAvailability(); @@ -293,7 +299,9 @@ void PDFViewerMainWindowLite::onProgressStep(int percentage) m_progressDialog->setValue(percentage); } +#ifdef Q_OS_WIN m_progressTaskbarIndicator->setValue(percentage); +#endif } void PDFViewerMainWindowLite::onProgressFinished() @@ -304,7 +312,9 @@ void PDFViewerMainWindowLite::onProgressFinished() m_progressDialog->deleteLater(); m_progressDialog = nullptr; } +#ifdef Q_OS_WIN m_progressTaskbarIndicator->hide(); +#endif m_programController->setIsBusy(false); m_programController->updateActionsAvailability(); @@ -410,7 +420,9 @@ void PDFViewerMainWindowLite::closeEvent(QCloseEvent* event) void PDFViewerMainWindowLite::showEvent(QShowEvent* event) { Q_UNUSED(event); +#ifdef Q_OS_WIN m_taskbarButton->setWindow(windowHandle()); +#endif } void PDFViewerMainWindowLite::dragEnterEvent(QDragEnterEvent* event) diff --git a/Pdf4QtViewer/pdfviewermainwindowlite.h b/Pdf4QtViewer/pdfviewermainwindowlite.h index bf6f374..2c10e2a 100644 --- a/Pdf4QtViewer/pdfviewermainwindowlite.h +++ b/Pdf4QtViewer/pdfviewermainwindowlite.h @@ -38,8 +38,10 @@ #include #include #include +#ifdef Q_OS_WIN #include #include +#endif #include #include @@ -114,8 +116,10 @@ private: QDoubleSpinBox* m_pageZoomSpinBox; bool m_isLoadingUI; pdf::PDFProgress* m_progress; +#ifdef Q_OS_WIN QWinTaskbarButton* m_taskbarButton; QWinTaskbarProgress* m_progressTaskbarIndicator; +#endif QProgressDialog* m_progressDialog; bool m_isChangingProgressStep; diff --git a/Pdf4QtViewerLite/Pdf4QtViewerLite.qbs b/Pdf4QtViewerLite/Pdf4QtViewerLite.qbs new file mode 100644 index 0000000..aa6beec --- /dev/null +++ b/Pdf4QtViewerLite/Pdf4QtViewerLite.qbs @@ -0,0 +1,7 @@ +Pdf4QtApp { + name: "Pdf4QtViewerLite" + files: [ + "*.cpp" + ] + Depends { name: "Pdf4QtViewer" } +} diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/AudioBookPlugin.qbs b/Pdf4QtViewerPlugins/AudioBookPlugin/AudioBookPlugin.qbs new file mode 100644 index 0000000..8c2a2c1 --- /dev/null +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/AudioBookPlugin.qbs @@ -0,0 +1,11 @@ +import qbs + +Pdf4QtPlugin { + name: "AudioBookPlugin" + files: [ + "*.h", + "*.cpp", + "*.ui", + "icons.qrc", + ] +} diff --git a/Pdf4QtViewerPlugins/DimensionsPlugin/DimensionsPlugin.qbs b/Pdf4QtViewerPlugins/DimensionsPlugin/DimensionsPlugin.qbs new file mode 100644 index 0000000..4681568 --- /dev/null +++ b/Pdf4QtViewerPlugins/DimensionsPlugin/DimensionsPlugin.qbs @@ -0,0 +1,11 @@ +import qbs + +Pdf4QtPlugin { + name: "DimensionsPlugin" + files: [ + "*.h", + "*.cpp", + "*.ui", + "icons.qrc", + ] +} diff --git a/Pdf4QtViewerPlugins/OutputPreviewPlugin/OutputPreviewPlugin.qbs b/Pdf4QtViewerPlugins/OutputPreviewPlugin/OutputPreviewPlugin.qbs new file mode 100644 index 0000000..d76bf0b --- /dev/null +++ b/Pdf4QtViewerPlugins/OutputPreviewPlugin/OutputPreviewPlugin.qbs @@ -0,0 +1,12 @@ +import qbs + +Pdf4QtPlugin { + name: "OutputPreviewPlugin.qbs" + files: [ + "*.h", + "*.cpp", + "*.ui", + "icons.qrc", + ] + cpp.includePaths: ["."] +} diff --git a/Pdf4QtViewerPlugins/RedactPlugin/RedactPlugin.qbs b/Pdf4QtViewerPlugins/RedactPlugin/RedactPlugin.qbs new file mode 100644 index 0000000..63e4a06 --- /dev/null +++ b/Pdf4QtViewerPlugins/RedactPlugin/RedactPlugin.qbs @@ -0,0 +1,12 @@ +import qbs + +Pdf4QtPlugin { + name: "RedactPlugin.qbs" + files: [ + "*.h", + "*.cpp", + "*.ui", + "icons.qrc", + ] + cpp.includePaths: ["."] +} diff --git a/Pdf4QtViewerPlugins/SoftProofingPlugin/SoftProofingPlugin.qbs b/Pdf4QtViewerPlugins/SoftProofingPlugin/SoftProofingPlugin.qbs new file mode 100644 index 0000000..f5f96bd --- /dev/null +++ b/Pdf4QtViewerPlugins/SoftProofingPlugin/SoftProofingPlugin.qbs @@ -0,0 +1,12 @@ +import qbs + +Pdf4QtPlugin { + name: "SoftProofingPlugin.qbs" + files: [ + "*.h", + "*.cpp", + "*.ui", + "icons.qrc", + ] + cpp.includePaths: ["."] +} diff --git a/Pdf4QtViewerProfi/Pdf4QtViewerProfi.qbs b/Pdf4QtViewerProfi/Pdf4QtViewerProfi.qbs new file mode 100644 index 0000000..5e01572 --- /dev/null +++ b/Pdf4QtViewerProfi/Pdf4QtViewerProfi.qbs @@ -0,0 +1,8 @@ +Pdf4QtApp { + name: "Pdf4QtViewerProfi" + files: [ + "*.cpp", + "app-icon.ico" + ] + Depends { name: "Pdf4QtViewer" } +} diff --git a/PdfExampleGenerator/PdfExampleGenerator.qbs b/PdfExampleGenerator/PdfExampleGenerator.qbs new file mode 100644 index 0000000..bf4d966 --- /dev/null +++ b/PdfExampleGenerator/PdfExampleGenerator.qbs @@ -0,0 +1,7 @@ +Pdf4QtApp { + name: "PdfExampleGenerator" + files: [ + "*.cpp", + "*.h", + ] +} diff --git a/PdfTool/PdfTool.qbs b/PdfTool/PdfTool.qbs new file mode 100644 index 0000000..8fb5757 --- /dev/null +++ b/PdfTool/PdfTool.qbs @@ -0,0 +1,7 @@ +Pdf4QtApp { + name: "PdfTool" + files: [ + "*.h", + "*.cpp", + ] +} diff --git a/UnitTests/UnitTests.qbs b/UnitTests/UnitTests.qbs new file mode 100644 index 0000000..1c0a06c --- /dev/null +++ b/UnitTests/UnitTests.qbs @@ -0,0 +1,7 @@ +Pdf4QtApp { + name: "UnitTests" + files: [ + "*.cpp", + ] + Depends { name: "Qt"; submodules: ["test"] } +} diff --git a/qbs/imports/Pdf4QtApp.qbs b/qbs/imports/Pdf4QtApp.qbs new file mode 100644 index 0000000..d6c3d46 --- /dev/null +++ b/qbs/imports/Pdf4QtApp.qbs @@ -0,0 +1,17 @@ +import qbs.FileInfo + +Pdf4QtProduct { + Depends { name: "cpp" } + type: "application" + cpp.rpaths: FileInfo.joinPaths(cpp.rpathOrigin, "..", "lib") + + Depends { name: "Pdf4QtLib" } + Group { + fileTagsFilter: product.type + qbs.install: true + qbs.installDir: targetInstallDir + qbs.installSourceBase: buildDirectory + } + targetInstallDir: pdf4qtbuildconfig.appInstallDir +} + diff --git a/qbs/imports/Pdf4QtLibrary.qbs b/qbs/imports/Pdf4QtLibrary.qbs new file mode 100644 index 0000000..178a4be --- /dev/null +++ b/qbs/imports/Pdf4QtLibrary.qbs @@ -0,0 +1,16 @@ +Pdf4QtProduct { + Depends { name: "cpp" } + property stringList libType: "dynamiclibrary" + type: libType + cpp.sonamePrefix: qbs.targetOS.contains("macos") ? "@rpath" : undefined + cpp.rpaths: cpp.rpathOrigin + + Group { + fileTagsFilter: "dynamiclibrary" + qbs.install: install + qbs.installDir: targetInstallDir + qbs.installSourceBase: buildDirectory + } + targetInstallDir: pdf4qtbuildconfig.libInstallDir +} + diff --git a/qbs/imports/Pdf4QtPlugin.qbs b/qbs/imports/Pdf4QtPlugin.qbs new file mode 100644 index 0000000..0d45d3d --- /dev/null +++ b/qbs/imports/Pdf4QtPlugin.qbs @@ -0,0 +1,11 @@ +Pdf4QtLibrary { + Depends { name: "Pdf4QtLib" } + + Group { + fileTagsFilter: "dynamiclibrary" + qbs.install: install + qbs.installDir: "pdfplugins" + qbs.installSourceBase: buildDirectory + } +} + diff --git a/qbs/imports/Pdf4QtProduct.qbs b/qbs/imports/Pdf4QtProduct.qbs new file mode 100644 index 0000000..055e81d --- /dev/null +++ b/qbs/imports/Pdf4QtProduct.qbs @@ -0,0 +1,9 @@ +Product { + Depends { name: "pdf4qtbuildconfig" } + Depends { name: "cpp" } + Depends { name: "Qt.core" } + cpp.cxxLanguageVersion: "c++2a" + property bool install: true + property string targetInstallDir +} + diff --git a/qbs/modules/pdf4qtbuildconfig/pdf4qtbuildconfig.qbs b/qbs/modules/pdf4qtbuildconfig/pdf4qtbuildconfig.qbs new file mode 100644 index 0000000..5d3c664 --- /dev/null +++ b/qbs/modules/pdf4qtbuildconfig/pdf4qtbuildconfig.qbs @@ -0,0 +1,6 @@ +Module { + property string libDirName: "lib" + property string appInstallDir: "bin" + property string libInstallDir: qbs.targetOS.contains("windows") ? "bin" : libDirName +} +