diff --git a/PdfForQtLib/PdfForQtLib.pro b/PdfForQtLib/PdfForQtLib.pro index 571ddcc..048f79e 100644 --- a/PdfForQtLib/PdfForQtLib.pro +++ b/PdfForQtLib/PdfForQtLib.pro @@ -238,6 +238,14 @@ qt_plugin_platform.files = $$[QT_INSTALL_PLUGINS]/platforms/qwindows$${SUFFIX}.d qt_plugin_platform.path = $$DESTDIR/install/platforms INSTALLS += qt_plugin_platform +qt_plugin_style.files = $$[QT_INSTALL_PLUGINS]/styles/qwindowsvistastyle$${SUFFIX}.dll +qt_plugin_style.path = $$DESTDIR/install/styles +INSTALLS += qt_plugin_style + +qt_plugin_imageformat.files = $$[QT_INSTALL_PLUGINS]/imageformats/q*$${SUFFIX}.dll +qt_plugin_imageformat.path = $$DESTDIR/install/imageformats +INSTALLS += qt_plugin_imageformat + qt_plugin_iconengine.files = $$[QT_INSTALL_PLUGINS]/iconengines/qsvgicon$${SUFFIX}.dll qt_plugin_iconengine.path = $$DESTDIR/install/iconengines INSTALLS += qt_plugin_iconengine diff --git a/PdfForQtLib/sources/pdfdrawspacecontroller.cpp b/PdfForQtLib/sources/pdfdrawspacecontroller.cpp index c08ad5e..ef69574 100644 --- a/PdfForQtLib/sources/pdfdrawspacecontroller.cpp +++ b/PdfForQtLib/sources/pdfdrawspacecontroller.cpp @@ -647,7 +647,7 @@ QMatrix PDFDrawWidgetProxy::createPagePointToDevicePointMatrix(const PDFPage* pa void PDFDrawWidgetProxy::draw(QPainter* painter, QRect rect) { - drawPages(painter, rect); + drawPages(painter, rect, m_features); for (IDocumentDrawInterface* drawInterface : m_drawInterfaces) { @@ -668,7 +668,7 @@ QColor PDFDrawWidgetProxy::getPaperColor() return paperColor; } -void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect) +void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect, PDFRenderer::Features features) { painter->fillRect(rect, Qt::lightGray); QMatrix baseMatrix = painter->worldMatrix(); @@ -696,11 +696,11 @@ void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect) const PDFPage* page = m_controller->getDocument()->getCatalog()->getPage(item.pageIndex); QMatrix matrix = createPagePointToDevicePointMatrix(page, placedRect) * baseMatrix; - compiledPage->draw(painter, page->getCropBox(), matrix, m_features); + compiledPage->draw(painter, page->getCropBox(), matrix, features); PDFTextLayoutGetter layoutGetter = m_textLayoutCompiler->getTextLayoutLazy(item.pageIndex); // Draw text blocks/text lines, if it is enabled - if (m_features.testFlag(PDFRenderer::DebugTextBlocks)) + if (features.testFlag(PDFRenderer::DebugTextBlocks)) { m_textLayoutCompiler->makeTextLayout(); const PDFTextLayout& layout = layoutGetter; @@ -723,7 +723,7 @@ void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect) painter->restore(); } - if (m_features.testFlag(PDFRenderer::DebugTextLines)) + if (features.testFlag(PDFRenderer::DebugTextLines)) { m_textLayoutCompiler->makeTextLayout(); const PDFTextLayout& layout = layoutGetter; @@ -750,17 +750,20 @@ void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect) painter->restore(); } - for (IDocumentDrawInterface* drawInterface : m_drawInterfaces) + if (!features.testFlag(PDFRenderer::DenyExtraGraphics)) { - painter->save(); - drawInterface->drawPage(painter, item.pageIndex, compiledPage, layoutGetter, matrix); - painter->restore(); + for (IDocumentDrawInterface* drawInterface : m_drawInterfaces) + { + painter->save(); + drawInterface->drawPage(painter, item.pageIndex, compiledPage, layoutGetter, matrix); + painter->restore(); + } } const qint64 drawTimeNS = timer.nsecsElapsed(); // Draw rendering times - if (m_features.testFlag(PDFRenderer::DisplayTimes)) + if (features.testFlag(PDFRenderer::DisplayTimes)) { QFont font = m_widget->font(); font.setPointSize(12); @@ -868,6 +871,7 @@ PDFInteger PDFDrawWidgetProxy::getPageUnderPoint(QPoint point, QPointF* pagePoin // topleft point of the block. But block maybe doesn't start at (0, 0), // so we must also use translation from the block beginning. QRect placedRect = item.pageRect.translated(m_horizontalOffset - m_layout.blockRect.left(), m_verticalOffset - m_layout.blockRect.top()); + placedRect.adjust(0, 0, 1, 1); if (placedRect.contains(point)) { if (pagePoint) diff --git a/PdfForQtLib/sources/pdfdrawspacecontroller.h b/PdfForQtLib/sources/pdfdrawspacecontroller.h index b27445d..cb2ccf8 100644 --- a/PdfForQtLib/sources/pdfdrawspacecontroller.h +++ b/PdfForQtLib/sources/pdfdrawspacecontroller.h @@ -244,7 +244,8 @@ public: /// Rectangle is space in the widget, which is used for painting the PDF. /// \param painter Painter to paint the PDF pages /// \param rect Rectangle in which the content is painted - void drawPages(QPainter* painter, QRect rect); + /// \param features Rendering features + void drawPages(QPainter* painter, QRect rect, PDFRenderer::Features features); /// Draws thumbnail image of the given size (so larger of the page size /// width or height equals to pixel size and the latter size is rescaled diff --git a/PdfForQtLib/sources/pdfpainter.cpp b/PdfForQtLib/sources/pdfpainter.cpp index 407abc8..53f3324 100644 --- a/PdfForQtLib/sources/pdfpainter.cpp +++ b/PdfForQtLib/sources/pdfpainter.cpp @@ -501,6 +501,7 @@ void PDFPrecompiledPage::draw(QPainter* painter, const QRectF& cropBox, const QM Q_ASSERT(pagePointToDevicePointMatrix.isInvertible()); painter->save(); + painter->setWorldMatrix(QMatrix()); if (features.testFlag(PDFRenderer::ClipToCropBox)) { diff --git a/PdfForQtLib/sources/pdfrenderer.h b/PdfForQtLib/sources/pdfrenderer.h index 1a27ae3..2ddca95 100644 --- a/PdfForQtLib/sources/pdfrenderer.h +++ b/PdfForQtLib/sources/pdfrenderer.h @@ -56,6 +56,7 @@ public: DebugTextBlocks = 0x0040, ///< Debug text block layout algorithm DebugTextLines = 0x0080, ///< Debug text line layout algorithm InvertColors = 0x0100, ///< Invert colors + DenyExtraGraphics = 0x0200, ///< Do not display additional graphics, for example from tools }; Q_DECLARE_FLAGS(Features, Feature) diff --git a/PdfForQtLib/sources/pdfwidgettool.cpp b/PdfForQtLib/sources/pdfwidgettool.cpp index 1fbc213..89b4196 100644 --- a/PdfForQtLib/sources/pdfwidgettool.cpp +++ b/PdfForQtLib/sources/pdfwidgettool.cpp @@ -908,7 +908,7 @@ void PDFMagnifierTool::drawPostRendering(QPainter* painter, QRect rect) const // because origin at (100, 100) is now at position (50, 50) after scale. So, if it has to remain // the same, we must translate by -(50, 50). painter->translate(m_mousePos * (1.0 / m_magnifierZoom - 1.0)); - getProxy()->drawPages(painter, rect); + getProxy()->drawPages(painter, rect, getProxy()->getFeatures()); painter->restore(); painter->setPen(Qt::black); @@ -1135,7 +1135,7 @@ void PDFScreenshotTool::onRectanglePicked(PDFInteger pageIndex, QRectF pageRecta { QPainter painter(&image); painter.translate(-selectedRectangle.topLeft()); - getProxy()->drawPages(&painter, getProxy()->getWidget()->rect()); + getProxy()->drawPages(&painter, getProxy()->getWidget()->rect(), getProxy()->getFeatures() | PDFRenderer::DenyExtraGraphics); } QApplication::clipboard()->setImage(image, QClipboard::Clipboard);