From edd100d3b8372b72857e8eb062ea8303e5f066b8 Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Mon, 4 Dec 2023 20:04:40 +0100 Subject: [PATCH] Issue #118: Continuation --- Pdf4QtLibCore/CMakeLists.txt | 8 +- Pdf4QtLibCore/sources/pdfaction.h | 6 +- Pdf4QtLibCore/sources/pdfannotation.cpp | 590 ++---------------- Pdf4QtLibCore/sources/pdfannotation.h | 77 +-- Pdf4QtLibCore/sources/pdfcatalog.h | 16 +- Pdf4QtLibCore/sources/pdfcertificatemanager.h | 4 +- Pdf4QtLibCore/sources/pdfcms.h | 4 +- Pdf4QtLibCore/sources/pdfcolorconvertor.h | 2 +- Pdf4QtLibCore/sources/pdfcolorspaces.h | 2 +- Pdf4QtLibCore/sources/pdfcompiler.h | 2 +- Pdf4QtLibCore/sources/pdfdiff.h | 6 +- Pdf4QtLibCore/sources/pdfdocument.h | 6 +- Pdf4QtLibCore/sources/pdfdocumentbuilder.h | 10 +- .../sources/pdfdocumentdrawinterface.h | 2 +- .../sources/pdfdocumentmanipulator.h | 2 +- Pdf4QtLibCore/sources/pdfdocumentreader.h | 2 +- Pdf4QtLibCore/sources/pdfdocumentsanitizer.h | 2 +- Pdf4QtLibCore/sources/pdfdocumenttextflow.h | 6 +- .../sources/pdfdocumenttextfloweditormodel.h | 2 +- Pdf4QtLibCore/sources/pdfdocumentwriter.h | 2 +- .../sources/pdfdrawspacecontroller.h | 2 +- Pdf4QtLibCore/sources/pdfencoding.h | 2 +- Pdf4QtLibCore/sources/pdfexecutionpolicy.h | 2 +- Pdf4QtLibCore/sources/pdffile.h | 18 +- Pdf4QtLibCore/sources/pdffont.h | 14 +- Pdf4QtLibCore/sources/pdfform.h | 4 +- Pdf4QtLibCore/sources/pdffunction.h | 12 +- Pdf4QtLibCore/sources/pdfglobal.h | 10 +- Pdf4QtLibCore/sources/pdficontheme.h | 2 +- Pdf4QtLibCore/sources/pdfimage.h | 2 +- Pdf4QtLibCore/sources/pdfimageconversion.h | 2 +- Pdf4QtLibCore/sources/pdfjavascriptscanner.h | 2 +- Pdf4QtLibCore/sources/pdfjbig2decoder.h | 8 +- Pdf4QtLibCore/sources/pdfnametounicode.h | 2 +- Pdf4QtLibCore/sources/pdfobject.h | 14 +- Pdf4QtLibCore/sources/pdfobjecteditormodel.h | 4 +- Pdf4QtLibCore/sources/pdfobjectutils.h | 4 +- Pdf4QtLibCore/sources/pdfoptimizer.h | 2 +- Pdf4QtLibCore/sources/pdfoptionalcontent.h | 2 +- Pdf4QtLibCore/sources/pdfoutline.h | 2 +- Pdf4QtLibCore/sources/pdfpage.h | 2 +- .../sources/pdfpagecontentprocessor.h | 4 +- Pdf4QtLibCore/sources/pdfpagenavigation.h | 2 +- Pdf4QtLibCore/sources/pdfpainter.h | 2 +- Pdf4QtLibCore/sources/pdfpainterutils.h | 2 +- Pdf4QtLibCore/sources/pdfparser.h | 4 +- Pdf4QtLibCore/sources/pdfplugin.h | 4 +- Pdf4QtLibCore/sources/pdfprogress.h | 2 +- Pdf4QtLibCore/sources/pdfredact.h | 2 +- Pdf4QtLibCore/sources/pdfrenderer.h | 12 +- Pdf4QtLibCore/sources/pdfsecurityhandler.h | 2 +- Pdf4QtLibCore/sources/pdfsignaturehandler.h | 8 +- Pdf4QtLibCore/sources/pdfsnapper.cpp | 1 - Pdf4QtLibCore/sources/pdfstreamfilters.h | 14 +- Pdf4QtLibCore/sources/pdfstructuretree.h | 16 +- .../sources/pdftexteditpseudowidget.cpp | 4 +- Pdf4QtLibCore/sources/pdftextlayout.h | 14 +- .../sources/pdftransparencyrenderer.h | 10 +- Pdf4QtLibCore/sources/pdfutils.h | 12 +- Pdf4QtLibCore/sources/pdfvisitor.h | 4 +- Pdf4QtLibWidgets/CMakeLists.txt | 8 +- Pdf4QtLibWidgets/sources/pdfadvancedtools.h | 22 +- .../sources/pdfcertificatemanagerdialog.h | 2 +- .../sources/pdfcreatecertificatedialog.h | 2 +- Pdf4QtLibWidgets/sources/pdfdrawwidget.h | 2 +- .../sources/pdfitemmodels.cpp | 0 .../sources/pdfitemmodels.h | 14 +- .../pdfpagecontenteditorstylesettings.h | 2 +- .../sources/pdfpagecontenteditortools.h | 14 +- .../sources/pdfpagecontenteditorwidget.h | 2 +- .../sources/pdfpagecontentelements.cpp | 0 .../sources/pdfpagecontentelements.h | 20 +- .../sources/pdfrenderingerrorswidget.h | 2 +- .../sources/pdfselectpagesdialog.h | 2 +- .../sources/pdfwidgetannotation.cpp | 513 +++++++++++++++ .../sources/pdfwidgetannotation.h | 95 +++ Pdf4QtLibWidgets/sources/pdfwidgettool.h | 12 +- Pdf4QtLibWidgets/sources/pdfwidgetutils.h | 2 +- 78 files changed, 873 insertions(+), 823 deletions(-) rename {Pdf4QtLibCore => Pdf4QtLibWidgets}/sources/pdfitemmodels.cpp (100%) rename {Pdf4QtLibCore => Pdf4QtLibWidgets}/sources/pdfitemmodels.h (95%) rename {Pdf4QtLibCore => Pdf4QtLibWidgets}/sources/pdfpagecontentelements.cpp (100%) rename {Pdf4QtLibCore => Pdf4QtLibWidgets}/sources/pdfpagecontentelements.h (96%) create mode 100644 Pdf4QtLibWidgets/sources/pdfwidgetannotation.cpp create mode 100644 Pdf4QtLibWidgets/sources/pdfwidgetannotation.h diff --git a/Pdf4QtLibCore/CMakeLists.txt b/Pdf4QtLibCore/CMakeLists.txt index 8c23854..4c3459d 100644 --- a/Pdf4QtLibCore/CMakeLists.txt +++ b/Pdf4QtLibCore/CMakeLists.txt @@ -34,7 +34,6 @@ add_library(Pdf4QtLibCore SHARED sources/pdffile.cpp sources/pdfform.cpp sources/pdficontheme.cpp - sources/pdfitemmodels.cpp sources/pdfjavascriptscanner.cpp sources/pdfjbig2decoder.cpp sources/pdfmultimedia.cpp @@ -44,7 +43,6 @@ add_library(Pdf4QtLibCore SHARED sources/pdfoptimizer.cpp sources/pdfoptionalcontent.cpp sources/pdfoutline.cpp - sources/pdfpagecontentelements.cpp sources/pdfpagenavigation.cpp sources/pdfpagetransition.cpp sources/pdfpainterutils.cpp @@ -92,7 +90,7 @@ include(GenerateExportHeader) GENERATE_EXPORT_HEADER(Pdf4QtLibCore EXPORT_MACRO_NAME - PDF4QTLIBSHARED_EXPORT + PDF4QTLIBCORESHARED_EXPORT EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/pdf4qtlibcore_export.h") target_link_libraries(Pdf4QtLibCore PRIVATE Qt6::Core Qt6::Gui Qt6::Xml Qt6::Svg) @@ -103,6 +101,10 @@ target_link_libraries(Pdf4QtLibCore PRIVATE freetype) target_link_libraries(Pdf4QtLibCore PRIVATE openjp2) target_link_libraries(Pdf4QtLibCore PRIVATE JPEG::JPEG) +if(PDF4QT_ENABLE_OPENGL) + target_link_libraries(Pdf4QtLibCore PRIVATE Qt6::OpenGL) +endif() + if(LINUX_GCC) target_link_libraries(Pdf4QtLibCore PUBLIC TBB::tbb) endif() diff --git a/Pdf4QtLibCore/sources/pdfaction.h b/Pdf4QtLibCore/sources/pdfaction.h index 9cf20cf..ef55c6a 100644 --- a/Pdf4QtLibCore/sources/pdfaction.h +++ b/Pdf4QtLibCore/sources/pdfaction.h @@ -79,7 +79,7 @@ enum class DestinationType /// destination has almost exactly same syntax as page destination, it should be checked, /// if indirect reference returned by function \p getPageReference references really page, /// or some structure element. -class PDF4QTLIBSHARED_EXPORT PDFDestination +class PDF4QTLIBCORESHARED_EXPORT PDFDestination { public: explicit inline PDFDestination() = default; @@ -144,7 +144,7 @@ private: using PDFActionPtr = QSharedPointer; /// Base class for action types. -class PDF4QTLIBSHARED_EXPORT PDFAction +class PDF4QTLIBCORESHARED_EXPORT PDFAction { public: explicit PDFAction() = default; @@ -186,7 +186,7 @@ private: /// Regular go-to action. Can contain also structure destinations, both regular page destination /// and structure destination are present, because if structure destination fails, then /// page destination can be used as fallback resolution. -class PDF4QTLIBSHARED_EXPORT PDFActionGoTo : public PDFAction +class PDF4QTLIBCORESHARED_EXPORT PDFActionGoTo : public PDFAction { public: explicit inline PDFActionGoTo(PDFDestination destination, PDFDestination structureDestination) : diff --git a/Pdf4QtLibCore/sources/pdfannotation.cpp b/Pdf4QtLibCore/sources/pdfannotation.cpp index e93e2a2..6e15a48 100644 --- a/Pdf4QtLibCore/sources/pdfannotation.cpp +++ b/Pdf4QtLibCore/sources/pdfannotation.cpp @@ -21,27 +21,14 @@ #include "pdfpainter.h" #include "pdfdrawspacecontroller.h" #include "pdfcms.h" -#include "pdfwidgetutils.h" #include "pdfpagecontentprocessor.h" #include "pdfparser.h" -#include "pdfdrawwidget.h" #include "pdfform.h" #include "pdfpainterutils.h" #include "pdfdocumentbuilder.h" -#include "pdfobjecteditorwidget.h" -#include "pdfselectpagesdialog.h" #include "pdfdbgheap.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include namespace pdf { @@ -1257,7 +1244,7 @@ QTransform PDFAnnotationManager::prepareTransformations(const QTransform& pagePo // be exactly zoom squared. Also, we will adjust to target device logical DPI, // if we, for example are using 4K, or 8K monitors. qreal zoom = 1.0 / qSqrt(qAbs(pagePointToDevicePointMatrix.determinant())); - zoom = PDFWidgetUtils::scaleDPI_x(device, zoom); + zoom = device->logicalDpiX() / 96.0; QRectF unzoomedRect(annotationRectangle.bottomLeft(), annotationRectangle.size() * zoom); unzoomedRect.translate(0, -unzoomedRect.height()); @@ -1709,483 +1696,6 @@ void PDFAnnotationManager::setTarget(Target target) m_target = target; } -PDFWidgetAnnotationManager::PDFWidgetAnnotationManager(PDFDrawWidgetProxy* proxy, QObject* parent) : - BaseClass(proxy->getFontCache(), proxy->getCMSManager(), proxy->getOptionalContentActivity(), proxy->getMeshQualitySettings(), proxy->getFeatures(), Target::View, parent), - m_proxy(proxy) -{ - Q_ASSERT(proxy); - m_proxy->registerDrawInterface(this); -} - -PDFWidgetAnnotationManager::~PDFWidgetAnnotationManager() -{ - m_proxy->unregisterDrawInterface(this); -} - -void PDFWidgetAnnotationManager::setDocument(const PDFModifiedDocument& document) -{ - BaseClass::setDocument(document); - - if (document.hasReset() || document.getFlags().testFlag(PDFModifiedDocument::Annotation)) - { - m_editableAnnotation = PDFObjectReference(); - m_editableAnnotationPage = PDFObjectReference(); - } -} - -void PDFWidgetAnnotationManager::shortcutOverrideEvent(QWidget* widget, QKeyEvent* event) -{ - Q_UNUSED(widget); - Q_UNUSED(event); -} - -void PDFWidgetAnnotationManager::keyPressEvent(QWidget* widget, QKeyEvent* event) -{ - Q_UNUSED(widget); - Q_UNUSED(event); -} - -void PDFWidgetAnnotationManager::keyReleaseEvent(QWidget* widget, QKeyEvent* event) -{ - Q_UNUSED(widget); - Q_UNUSED(event); -} - -void PDFWidgetAnnotationManager::mousePressEvent(QWidget* widget, QMouseEvent* event) -{ - Q_UNUSED(widget); - - updateFromMouseEvent(event); - - // Show context menu? - if (event->button() == Qt::RightButton) - { - PDFWidget* pdfWidget = m_proxy->getWidget(); - std::vector currentPages = pdfWidget->getDrawWidget()->getCurrentPages(); - - if (!hasAnyPageAnnotation(currentPages)) - { - // All pages doesn't have annotation - return; - } - - m_editableAnnotation = PDFObjectReference(); - m_editableAnnotationPage = PDFObjectReference(); - for (PDFInteger pageIndex : currentPages) - { - PageAnnotations& pageAnnotations = getPageAnnotations(pageIndex); - for (PageAnnotation& pageAnnotation : pageAnnotations.annotations) - { - if (!pageAnnotation.isHovered) - { - continue; - } - - if (!PDFAnnotation::isTypeEditable(pageAnnotation.annotation->getType())) - { - continue; - } - - m_editableAnnotation = pageAnnotation.annotation->getSelfReference(); - m_editableAnnotationPage = pageAnnotation.annotation->getPageReference(); - - if (!m_editableAnnotationPage.isValid()) - { - m_editableAnnotationPage = m_document->getCatalog()->getPage(pageIndex)->getPageReference(); - } - break; - } - } - - if (m_editableAnnotation.isValid()) - { - QMenu menu(tr("Annotation"), pdfWidget); - QAction* showPopupAction = menu.addAction(tr("Show Popup Window")); - QAction* copyAction = menu.addAction(tr("Copy to Multiple Pages")); - QAction* editAction = menu.addAction(tr("Edit")); - QAction* deleteAction = menu.addAction(tr("Delete")); - connect(showPopupAction, &QAction::triggered, this, &PDFWidgetAnnotationManager::onShowPopupAnnotation); - connect(copyAction, &QAction::triggered, this, &PDFWidgetAnnotationManager::onCopyAnnotation); - connect(editAction, &QAction::triggered, this, &PDFWidgetAnnotationManager::onEditAnnotation); - connect(deleteAction, &QAction::triggered, this, &PDFWidgetAnnotationManager::onDeleteAnnotation); - - m_editableAnnotationGlobalPosition = pdfWidget->mapToGlobal(event->pos()); - menu.exec(m_editableAnnotationGlobalPosition); - } - } -} - -void PDFWidgetAnnotationManager::mouseDoubleClickEvent(QWidget* widget, QMouseEvent* event) -{ - Q_UNUSED(widget); - Q_UNUSED(event); -} - -void PDFWidgetAnnotationManager::mouseReleaseEvent(QWidget* widget, QMouseEvent* event) -{ - Q_UNUSED(widget); - - updateFromMouseEvent(event); -} - -void PDFWidgetAnnotationManager::mouseMoveEvent(QWidget* widget, QMouseEvent* event) -{ - Q_UNUSED(widget); - - updateFromMouseEvent(event); -} - -void PDFWidgetAnnotationManager::wheelEvent(QWidget* widget, QWheelEvent* event) -{ - Q_UNUSED(widget); - Q_UNUSED(event); -} - -void PDFWidgetAnnotationManager::updateFromMouseEvent(QMouseEvent* event) -{ - PDFWidget* widget = m_proxy->getWidget(); - std::vector currentPages = widget->getDrawWidget()->getCurrentPages(); - - if (!hasAnyPageAnnotation(currentPages)) - { - // All pages doesn't have annotation - return; - } - - m_tooltip = QString(); - m_cursor = std::nullopt; - bool appearanceChanged = false; - - // We must update appearance states, and update tooltip - PDFWidgetSnapshot snapshot = m_proxy->getSnapshot(); - const bool isDown = event->buttons().testFlag(Qt::LeftButton); - const PDFAppeareanceStreams::Appearance hoverAppearance = isDown ? PDFAppeareanceStreams::Appearance::Down : PDFAppeareanceStreams::Appearance::Rollover; - - for (const PDFWidgetSnapshot::SnapshotItem& snapshotItem : snapshot.items) - { - PageAnnotations& pageAnnotations = getPageAnnotations(snapshotItem.pageIndex); - for (PageAnnotation& pageAnnotation : pageAnnotations.annotations) - { - if (pageAnnotation.annotation->isReplyTo()) - { - // Annotation is reply to another annotation, do not interact with it - continue; - } - - const PDFAppeareanceStreams::Appearance oldAppearance = pageAnnotation.appearance; - QRectF annotationRect = pageAnnotation.annotation->getRectangle(); - QTransform matrix = prepareTransformations(snapshotItem.pageToDeviceMatrix, widget, pageAnnotation.annotation->getEffectiveFlags(), m_document->getCatalog()->getPage(snapshotItem.pageIndex), annotationRect); - QPainterPath path; - path.addRect(annotationRect); - path = matrix.map(path); - - if (path.contains(event->pos())) - { - pageAnnotation.appearance = hoverAppearance; - pageAnnotation.isHovered = true; - - // Generate tooltip - if (m_tooltip.isEmpty()) - { - const PDFMarkupAnnotation* markupAnnotation = pageAnnotation.annotation->asMarkupAnnotation(); - if (markupAnnotation) - { - QString title = markupAnnotation->getWindowTitle(); - if (title.isEmpty()) - { - title = markupAnnotation->getSubject(); - } - if (title.isEmpty()) - { - title = PDFTranslationContext::tr("Info"); - } - - const size_t repliesCount = pageAnnotations.getReplies(pageAnnotation).size(); - if (repliesCount > 0) - { - title = PDFTranslationContext::tr("%1 (%2 replies)").arg(title).arg(repliesCount); - } - - m_tooltip = QString("

%1

%2

").arg(title, markupAnnotation->getContents()); - } - } - - const PDFAction* linkAction = nullptr; - const AnnotationType annotationType = pageAnnotation.annotation->getType(); - if (annotationType == AnnotationType::Link) - { - const PDFLinkAnnotation* linkAnnotation = dynamic_cast(pageAnnotation.annotation.data()); - Q_ASSERT(linkAnnotation); - - // We must check, if user clicked to the link area - QPainterPath activationPath = linkAnnotation->getActivationRegion().getPath(); - activationPath = snapshotItem.pageToDeviceMatrix.map(activationPath); - if (activationPath.contains(event->pos()) && linkAnnotation->getAction()) - { - m_cursor = QCursor(Qt::PointingHandCursor); - linkAction = linkAnnotation->getAction(); - } - } - if (annotationType == AnnotationType::Widget) - { - if (m_formManager && m_formManager->hasFormFieldWidgetText(pageAnnotation.annotation->getSelfReference())) - { - m_cursor = QCursor(Qt::IBeamCursor); - } - else - { - m_cursor = QCursor(Qt::ArrowCursor); - } - } - - // Generate popup window - if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::LeftButton) - { - const PDFMarkupAnnotation* markupAnnotation = pageAnnotation.annotation->asMarkupAnnotation(); - if (markupAnnotation) - { - QDialog* dialog = createDialogForMarkupAnnotations(widget, pageAnnotation, pageAnnotations); - - // Set proper dialog position - according to the popup annotation. If we - // do not have popup annotation, then try to use annotations rectangle. - if (const PageAnnotation* popupAnnotation = pageAnnotations.getPopupAnnotation(pageAnnotation)) - { - QPoint popupPoint = snapshotItem.pageToDeviceMatrix.map(popupAnnotation->annotation->getRectangle().bottomLeft()).toPoint(); - popupPoint = widget->mapToGlobal(popupPoint); - dialog->move(popupPoint); - } - else if (markupAnnotation->getRectangle().isValid()) - { - QPoint popupPoint = snapshotItem.pageToDeviceMatrix.map(markupAnnotation->getRectangle().bottomRight()).toPoint(); - popupPoint = widget->mapToGlobal(popupPoint); - dialog->move(popupPoint); - } - - dialog->exec(); - } - - if (linkAction) - { - Q_EMIT actionTriggered(linkAction); - } - } - } - else - { - pageAnnotation.appearance = PDFAppeareanceStreams::Appearance::Normal; - pageAnnotation.isHovered = false; - } - - const bool currentAppearanceChanged = oldAppearance != pageAnnotation.appearance; - if (currentAppearanceChanged) - { - // We have changed appearance - we must mark stream as dirty - pageAnnotation.appearanceStream.dirty(); - appearanceChanged = true; - } - } - } - - // If appearance has changed, then we must redraw the page - if (appearanceChanged) - { - Q_EMIT widget->getDrawWidgetProxy()->repaintNeeded(); - } -} - -void PDFWidgetAnnotationManager::onShowPopupAnnotation() -{ - PDFWidgetSnapshot snapshot = m_proxy->getSnapshot(); - for (const PDFWidgetSnapshot::SnapshotItem& snapshotItem : snapshot.items) - { - PageAnnotations& pageAnnotations = getPageAnnotations(snapshotItem.pageIndex); - for (PageAnnotation& pageAnnotation : pageAnnotations.annotations) - { - if (pageAnnotation.annotation->isReplyTo()) - { - // Annotation is reply to another annotation, do not interact with it - continue; - } - - if (pageAnnotation.annotation->getSelfReference() == m_editableAnnotation) - { - QDialog* dialog = createDialogForMarkupAnnotations(m_proxy->getWidget(), pageAnnotation, pageAnnotations); - dialog->move(m_editableAnnotationGlobalPosition); - dialog->exec(); - return; - } - } - } -} - -void PDFWidgetAnnotationManager::onCopyAnnotation() -{ - pdf::PDFSelectPagesDialog dialog(tr("Copy Annotation"), tr("Copy Annotation onto Multiple Pages"), - m_document->getCatalog()->getPageCount(), m_proxy->getWidget()->getDrawWidget()->getCurrentPages(), m_proxy->getWidget()); - if (dialog.exec() == QDialog::Accepted) - { - std::vector pages = dialog.getSelectedPages(); - const PDFInteger currentPageIndex = m_document->getCatalog()->getPageIndexFromPageReference(m_editableAnnotationPage); - - for (PDFInteger& pageIndex : pages) - { - --pageIndex; - } - - auto it = std::find(pages.begin(), pages.end(), currentPageIndex); - if (it != pages.end()) - { - pages.erase(it); - } - - if (pages.empty()) - { - return; - } - - PDFDocumentModifier modifier(m_document); - modifier.markAnnotationsChanged(); - - for (const PDFInteger pageIndex : pages) - { - modifier.getBuilder()->copyAnnotation(m_document->getCatalog()->getPage(pageIndex)->getPageReference(), m_editableAnnotation); - } - - if (modifier.finalize()) - { - Q_EMIT documentModified(PDFModifiedDocument(modifier.getDocument(), nullptr, modifier.getFlags())); - } - } -} - -void PDFWidgetAnnotationManager::onEditAnnotation() -{ - PDFEditObjectDialog dialog(EditObjectType::Annotation, m_proxy->getWidget()); - - PDFObject originalObject = m_document->getObjectByReference(m_editableAnnotation); - dialog.setObject(originalObject); - - if (dialog.exec() == PDFEditObjectDialog::Accepted) - { - PDFObject object = dialog.getObject(); - if (object != originalObject) - { - PDFDocumentModifier modifier(m_document); - modifier.markAnnotationsChanged(); - modifier.getBuilder()->setObject(m_editableAnnotation, object); - modifier.getBuilder()->updateAnnotationAppearanceStreams(m_editableAnnotation); - - if (modifier.finalize()) - { - Q_EMIT documentModified(PDFModifiedDocument(modifier.getDocument(), nullptr, modifier.getFlags())); - } - } - } -} - -void PDFWidgetAnnotationManager::onDeleteAnnotation() -{ - if (m_editableAnnotation.isValid()) - { - PDFDocumentModifier modifier(m_document); - modifier.markAnnotationsChanged(); - modifier.getBuilder()->removeAnnotation(m_editableAnnotationPage, m_editableAnnotation); - - if (modifier.finalize()) - { - Q_EMIT documentModified(PDFModifiedDocument(modifier.getDocument(), nullptr, modifier.getFlags())); - } - } -} - -QDialog* PDFWidgetAnnotationManager::createDialogForMarkupAnnotations(PDFWidget* widget, - const PageAnnotation& pageAnnotation, - const PageAnnotations& pageAnnotations) -{ - QDialog* dialog = new QDialog(widget->getDrawWidget()->getWidget(), Qt::Popup); - dialog->setAttribute(Qt::WA_DeleteOnClose, true); - createWidgetsForMarkupAnnotations(dialog, pageAnnotation, pageAnnotations); - return dialog; -} - -void PDFWidgetAnnotationManager::createWidgetsForMarkupAnnotations(QWidget* parentWidget, - const PageAnnotation& pageAnnotation, - const PageAnnotations& pageAnnotations) -{ - std::vector replies = pageAnnotations.getReplies(pageAnnotation); - replies.insert(replies.begin(), &pageAnnotation); - - QScrollArea* scrollArea = new QScrollArea(parentWidget); - scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - - QVBoxLayout* layout = new QVBoxLayout(parentWidget); - layout->addWidget(scrollArea); - layout->setContentsMargins(QMargins()); - - QWidget* frameWidget = new QWidget(scrollArea); - QVBoxLayout* frameLayout = new QVBoxLayout(frameWidget); - frameLayout->setSpacing(0); - scrollArea->setWidget(frameWidget); - - const PDFMarkupAnnotation* markupMainAnnotation = pageAnnotation.annotation->asMarkupAnnotation(); - QColor color = markupMainAnnotation->getDrawColorFromAnnotationColor(markupMainAnnotation->getColor(), 1.0); - QColor titleColor = QColor::fromHslF(color.hueF(), color.saturationF(), 0.2f, 1.0f); - QColor backgroundColor = QColor::fromHslF(color.hueF(), color.saturationF(), 0.9f, 1.0f); - - QString style = "QGroupBox { " - "border: 2px solid black; " - "border-color: rgb(%4, %5, %6); " - "margin-top: 3ex; " - "background-color: rgb(%1, %2, %3); " - "}" - "QGroupBox::title { " - "subcontrol-origin: margin; " - "subcontrol-position: top center; " - "padding: 0px 8192px; " - "background-color: rgb(%4, %5, %6); " - "color: #FFFFFF;" - "}"; - style = style.arg(backgroundColor.red()).arg(backgroundColor.green()).arg(backgroundColor.blue()).arg(titleColor.red()).arg(titleColor.green()).arg(titleColor.blue()); - - for (const PageAnnotation* annotation : replies) - { - const PDFMarkupAnnotation* markupAnnotation = annotation->annotation->asMarkupAnnotation(); - - if (!markupAnnotation) - { - // This should not happen... - continue; - } - - QGroupBox* groupBox = new QGroupBox(scrollArea); - frameLayout->addWidget(groupBox); - - QString title = markupAnnotation->getWindowTitle(); - if (title.isEmpty()) - { - title = markupAnnotation->getSubject(); - } - - QString dateTimeString = QLocale::system().toString(markupAnnotation->getCreationDate().toLocalTime(), QLocale::LongFormat); - title = QString("%1 (%2)").arg(title, dateTimeString).trimmed(); - - groupBox->setStyleSheet(style); - groupBox->setTitle(title); - QVBoxLayout* groupBoxLayout = new QVBoxLayout(groupBox); - - QLabel* label = new QLabel(groupBox); - label->setTextInteractionFlags(Qt::TextBrowserInteraction); - label->setWordWrap(true); - label->setText(markupAnnotation->getContents()); - label->setFixedWidth(PDFWidgetUtils::scaleDPI_x(label, 250)); - label->setMinimumHeight(label->sizeHint().height()); - groupBoxLayout->addWidget(label); - } - - frameWidget->setFixedSize(frameWidget->minimumSizeHint()); - parentWidget->setFixedSize(scrollArea->sizeHint()); -} void PDFSimpleGeometryAnnotation::draw(AnnotationDrawParameters& parameters) const { @@ -2326,7 +1836,7 @@ void PDFTextAnnotation::draw(AnnotationDrawParameters& parameters) const // Draw the ellipse painter.drawEllipse(ellipseRectangle); - QFont font = QApplication::font(); + QFont font = painter.font(); font.setPixelSize(16.0); QString text = getTextForIcon(m_iconName); @@ -2363,7 +1873,7 @@ QIcon PDFTextAnnotation::createIcon(QString key, QSize size) QString text = getTextForIcon(key); - QFont font = QApplication::font(); + QFont font = painter.font(); font.setPixelSize(size.height() * 0.75); QPainterPath textPath; @@ -2772,7 +2282,7 @@ void PDFAnnotation::drawLine(const PDFAnnotation::LineGeometryInfo& info, if (drawText) { - QFont font = QApplication::font(); + QFont font = painter.font(); font.setPixelSize(12.0); QFontMetricsF fontMetrics(font, painter.device()); @@ -3457,7 +2967,7 @@ void PDFAnnotation::drawCharacterSymbol(QString text, PDFReal opacity, Annotatio QRectF rectangle = getRectangle(); rectangle.setSize(QSizeF(rectSize, rectSize)); - QFont font = QApplication::font(); + QFont font = painter.font(); font.setPixelSize(16.0); QPainterPath textPath; @@ -3643,26 +3153,12 @@ void PDFWidgetAnnotation::draw(AnnotationDrawParameters& parameters) const painter->scale(1.0, -1.0); painter->setFont(font); - QStyleOptionButton option; - option.state = QStyle::State_Enabled; - option.rect = QRect(0, 0, qFloor(rectangle.width()), qFloor(rectangle.height())); - option.palette = QApplication::palette(); - - if (parameters.key.first == PDFAppeareanceStreams::Appearance::Rollover) - { - option.state |= QStyle::State_MouseOver; - } - - if (parameters.key.first == PDFAppeareanceStreams::Appearance::Down) - { - option.state |= QStyle::State_Sunken; - } - - option.features = QStyleOptionButton::None; - option.text = getContents(); - option.fontMetrics = fontMetrics; - - QApplication::style()->drawControl(QStyle::CE_PushButton, &option, painter, nullptr); + // Draw border + QRectF drawRect(0, 0, rectangle.width(), rectangle.height()); + painter->setPen(getPen()); + painter->setBrush(QBrush(Qt::lightGray)); + painter->drawRect(drawRect); + painter->drawText(drawRect, Qt::AlignCenter, getContents()); } else { @@ -3714,42 +3210,52 @@ void PDFWidgetAnnotation::draw(AnnotationDrawParameters& parameters) const } case PDFFormFieldButton::ButtonType::RadioButton: + { + QRectF rectangle = getRectangle(); + QPainter* painter = parameters.painter; + + rectangle.setWidth(rectangle.height()); + + painter->setPen(Qt::black); + painter->setBrush(Qt::NoBrush); + painter->drawEllipse(rectangle); + + if (parameters.key.second != "Off") + { + QRectF rectangleMark = rectangle; + rectangleMark.setWidth(rectangle.width() * 0.75); + rectangleMark.setHeight(rectangle.height() * 0.75); + rectangleMark.moveCenter(rectangle.center()); + + painter->setPen(Qt::NoPen); + painter->setBrush(QBrush(Qt::black)); + + painter->drawEllipse(rectangleMark); + } + break; + } + case PDFFormFieldButton::ButtonType::CheckBox: { QRectF rectangle = getRectangle(); QPainter* painter = parameters.painter; - painter->translate(rectangle.bottomLeft()); - painter->scale(1.0, -1.0); - QStyleOptionButton option; - option.state = QStyle::State_Enabled; - option.rect = QRect(0, 0, qFloor(rectangle.width()), qFloor(rectangle.height())); - option.palette = QApplication::palette(); + rectangle.setWidth(rectangle.height()); - if (parameters.key.first == PDFAppeareanceStreams::Appearance::Rollover) - { - option.state |= QStyle::State_MouseOver; - } - - if (parameters.key.first == PDFAppeareanceStreams::Appearance::Down) - { - option.state |= QStyle::State_Sunken; - } + painter->setPen(Qt::black); + painter->setBrush(Qt::NoBrush); + painter->drawRect(rectangle); if (parameters.key.second != "Off") { - option.state |= QStyle::State_On; - } - else - { - option.state |= QStyle::State_Off; - } + QRectF rectangleMark = rectangle; + rectangleMark.setWidth(rectangle.width() * 0.75); + rectangleMark.setHeight(rectangle.height() * 0.75); + rectangleMark.moveCenter(rectangle.center()); - option.features = QStyleOptionButton::None; - option.text = QString(); - - QStyle::PrimitiveElement element = (button->getButtonType() == PDFFormFieldButton::ButtonType::CheckBox) ? QStyle::PE_IndicatorCheckBox : QStyle::PE_IndicatorRadioButton; - QApplication::style()->drawPrimitive(element, &option, painter, nullptr); + painter->drawLine(rectangleMark.topLeft(), rectangleMark.bottomRight()); + painter->drawLine(rectangleMark.bottomLeft(), rectangleMark.topRight()); + } break; } diff --git a/Pdf4QtLibCore/sources/pdfannotation.h b/Pdf4QtLibCore/sources/pdfannotation.h index 6ebc3f7..ab09b29 100644 --- a/Pdf4QtLibCore/sources/pdfannotation.h +++ b/Pdf4QtLibCore/sources/pdfannotation.h @@ -44,7 +44,6 @@ namespace pdf { class PDFWidget; class PDFObjectStorage; -class PDFDrawWidgetProxy; class PDFFontCache; class PDFFormManager; class PDFModifiedDocument; @@ -783,7 +782,7 @@ enum class TextAnnotationIcon /// as if flag NoZoom and NoRotate were set). When this annotation is opened, /// it displays popup window containing the text of the note, font and size /// is implementation dependent by viewer application. -class PDF4QTLIBSHARED_EXPORT PDFTextAnnotation : public PDFMarkupAnnotation +class PDF4QTLIBCORESHARED_EXPORT PDFTextAnnotation : public PDFMarkupAnnotation { public: inline explicit PDFTextAnnotation() = default; @@ -1104,7 +1103,7 @@ enum class StampIntent /// Annotation for stamps. Displays text or graphics intended to look /// as if they were stamped on the paper. -class PDF4QTLIBSHARED_EXPORT PDFStampAnnotation : public PDFMarkupAnnotation +class PDF4QTLIBCORESHARED_EXPORT PDFStampAnnotation : public PDFMarkupAnnotation { public: inline explicit PDFStampAnnotation() = default; @@ -1433,7 +1432,7 @@ private: /// this object builds annotation's appearance streams, if necessary. This /// manager is intended to non-gui rendering. If widget annotation manager is used, /// then this object is not thread safe. -class PDF4QTLIBSHARED_EXPORT PDFAnnotationManager : public QObject, public IDocumentDrawInterface +class PDF4QTLIBCORESHARED_EXPORT PDFAnnotationManager : public QObject, public IDocumentDrawInterface { Q_OBJECT @@ -1623,76 +1622,6 @@ protected: Target m_target = Target::View; }; -/// Annotation manager for GUI rendering, it also manages annotations widgets -/// for parent widget. -class PDF4QTLIBSHARED_EXPORT PDFWidgetAnnotationManager : public PDFAnnotationManager, public IDrawWidgetInputInterface -{ - Q_OBJECT - -private: - using BaseClass = PDFAnnotationManager; - -public: - explicit PDFWidgetAnnotationManager(PDFDrawWidgetProxy* proxy, QObject* parent); - virtual ~PDFWidgetAnnotationManager() override; - - virtual void setDocument(const PDFModifiedDocument& document) override; - - virtual void shortcutOverrideEvent(QWidget* widget, QKeyEvent* event) override; - virtual void keyPressEvent(QWidget* widget, QKeyEvent* event) override; - virtual void keyReleaseEvent(QWidget* widget, QKeyEvent* event) override; - virtual void mousePressEvent(QWidget* widget, QMouseEvent* event) override; - virtual void mouseDoubleClickEvent(QWidget* widget, QMouseEvent* event) override; - virtual void mouseReleaseEvent(QWidget* widget, QMouseEvent* event) override; - virtual void mouseMoveEvent(QWidget* widget, QMouseEvent* event) override; - virtual void wheelEvent(QWidget* widget, QWheelEvent* event) override; - - /// Returns tooltip generated from annotation - virtual QString getTooltip() const override { return m_tooltip; } - - /// Returns current cursor - virtual const std::optional& getCursor() const override { return m_cursor; } - - virtual int getInputPriority() const override { return AnnotationPriority; } - -signals: - void actionTriggered(const PDFAction* action); - void documentModified(PDFModifiedDocument document); - -private: - void updateFromMouseEvent(QMouseEvent* event); - - void onShowPopupAnnotation(); - void onCopyAnnotation(); - void onEditAnnotation(); - void onDeleteAnnotation(); - - /// Creates dialog for markup annotations. This function is used only for markup annotations, - /// do not use them for other annotations (function can crash). - /// \param widget Dialog's parent widget - /// \param pageAnnotation Markup annotation - /// \param pageAnnotations Page annotations - QDialog* createDialogForMarkupAnnotations(PDFWidget* widget, - const PageAnnotation& pageAnnotation, - const PageAnnotations& pageAnnotations); - - /// Creates widgets for markup annotation main popup widget. Also sets - /// default size of parent widget. - /// \param parentWidget Parent widget, where widgets are created - /// \param pageAnnotation Markup annotation - /// \param pageAnnotations Page annotations - void createWidgetsForMarkupAnnotations(QWidget* parentWidget, - const PageAnnotation& pageAnnotation, - const PageAnnotations& pageAnnotations); - - PDFDrawWidgetProxy* m_proxy; - QString m_tooltip; - std::optional m_cursor; - QPoint m_editableAnnotationGlobalPosition; ///< Position, where action on annotation was executed - PDFObjectReference m_editableAnnotation; ///< Annotation to be edited or deleted - PDFObjectReference m_editableAnnotationPage; ///< Page of annotation above -}; - } // namespace pdf #endif // PDFANNOTATION_H diff --git a/Pdf4QtLibCore/sources/pdfcatalog.h b/Pdf4QtLibCore/sources/pdfcatalog.h index a16b2bc..17203c1 100644 --- a/Pdf4QtLibCore/sources/pdfcatalog.h +++ b/Pdf4QtLibCore/sources/pdfcatalog.h @@ -236,7 +236,7 @@ private: /// Document security store. Contains certificates, CRLs, OCSPs, and /// other data for signature validation. -class PDF4QTLIBSHARED_EXPORT PDFDocumentSecurityStore +class PDF4QTLIBCORESHARED_EXPORT PDFDocumentSecurityStore { public: explicit inline PDFDocumentSecurityStore() = default; @@ -301,7 +301,7 @@ private: /// Document extensions. Contains information about developer's extensions /// used in document. -class PDF4QTLIBSHARED_EXPORT PDFDeveloperExtensions +class PDF4QTLIBCORESHARED_EXPORT PDFDeveloperExtensions { public: explicit PDFDeveloperExtensions() = default; @@ -330,7 +330,7 @@ private: }; /// Web capture info -class PDF4QTLIBSHARED_EXPORT PDFWebCaptureInfo +class PDF4QTLIBCORESHARED_EXPORT PDFWebCaptureInfo { public: explicit PDFWebCaptureInfo() = default; @@ -349,7 +349,7 @@ private: std::vector m_commands; }; -class PDF4QTLIBSHARED_EXPORT PDFOutputIntentICCProfileInfo +class PDF4QTLIBCORESHARED_EXPORT PDFOutputIntentICCProfileInfo { public: explicit PDFOutputIntentICCProfileInfo() = default; @@ -377,7 +377,7 @@ private: }; /// Output intent -class PDF4QTLIBSHARED_EXPORT PDFOutputIntent +class PDF4QTLIBCORESHARED_EXPORT PDFOutputIntent { public: explicit PDFOutputIntent() = default; @@ -411,7 +411,7 @@ private: }; /// Legal attestations -class PDF4QTLIBSHARED_EXPORT PDFLegalAttestation +class PDF4QTLIBCORESHARED_EXPORT PDFLegalAttestation { public: explicit inline PDFLegalAttestation() = default; @@ -459,7 +459,7 @@ private: /// Document can contain requirements for viewer application. This class /// verifies, if this library and viewer application satisfies these requirements /// and returns result. -class PDF4QTLIBSHARED_EXPORT PDFDocumentRequirements +class PDF4QTLIBCORESHARED_EXPORT PDFDocumentRequirements { public: @@ -564,7 +564,7 @@ private: std::array m_actions; }; -class PDF4QTLIBSHARED_EXPORT PDFCatalog +class PDF4QTLIBCORESHARED_EXPORT PDFCatalog { public: inline PDFCatalog() = default; diff --git a/Pdf4QtLibCore/sources/pdfcertificatemanager.h b/Pdf4QtLibCore/sources/pdfcertificatemanager.h index 293cafc..083faed 100644 --- a/Pdf4QtLibCore/sources/pdfcertificatemanager.h +++ b/Pdf4QtLibCore/sources/pdfcertificatemanager.h @@ -26,7 +26,7 @@ namespace pdf { -class PDF4QTLIBSHARED_EXPORT PDFCertificateManager +class PDF4QTLIBCORESHARED_EXPORT PDFCertificateManager { public: PDFCertificateManager(); @@ -55,7 +55,7 @@ public: static bool isCertificateValid(QString fileName, QString password); }; -class PDF4QTLIBSHARED_EXPORT PDFSignatureFactory +class PDF4QTLIBCORESHARED_EXPORT PDFSignatureFactory { public: static bool sign(QString certificateName, QString password, QByteArray data, QByteArray& result); diff --git a/Pdf4QtLibCore/sources/pdfcms.h b/Pdf4QtLibCore/sources/pdfcms.h index 3686c3b..49992f2 100644 --- a/Pdf4QtLibCore/sources/pdfcms.h +++ b/Pdf4QtLibCore/sources/pdfcms.h @@ -264,7 +264,7 @@ public: using PDFCMSPointer = QSharedPointer; -class PDF4QTLIBSHARED_EXPORT PDFCMSGeneric : public PDFCMS +class PDF4QTLIBCORESHARED_EXPORT PDFCMSGeneric : public PDFCMS { public: explicit inline PDFCMSGeneric() = default; @@ -356,7 +356,7 @@ using PDFColorProfileIdentifiers = std::vector; /// It also handles settings, and it's changes. Constant functions /// is save to call from multiple threads, this also holds for some /// non-constant functions - manager is protected by mutexes. -class PDF4QTLIBSHARED_EXPORT PDFCMSManager : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFCMSManager : public QObject { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfcolorconvertor.h b/Pdf4QtLibCore/sources/pdfcolorconvertor.h index 6a37788..5364251 100644 --- a/Pdf4QtLibCore/sources/pdfcolorconvertor.h +++ b/Pdf4QtLibCore/sources/pdfcolorconvertor.h @@ -30,7 +30,7 @@ namespace pdf /// \brief Performs color conversions in the RGB color space. /// This class supports multiple modes of operation, making it /// useful for accessibility purposes, particularly for visually impaired users. -class PDF4QTLIBSHARED_EXPORT PDFColorConvertor +class PDF4QTLIBCORESHARED_EXPORT PDFColorConvertor { public: PDFColorConvertor(); diff --git a/Pdf4QtLibCore/sources/pdfcolorspaces.h b/Pdf4QtLibCore/sources/pdfcolorspaces.h index e47628c..46695f8 100644 --- a/Pdf4QtLibCore/sources/pdfcolorspaces.h +++ b/Pdf4QtLibCore/sources/pdfcolorspaces.h @@ -308,7 +308,7 @@ using PDFColorComponentMatrix_3x3 = PDFColorComponentMatrix<3, 3>; /// Represents PDF's color space (abstract class). Contains functions for parsing /// color spaces. -class PDF4QTLIBSHARED_EXPORT PDFAbstractColorSpace +class PDF4QTLIBCORESHARED_EXPORT PDFAbstractColorSpace { public: explicit PDFAbstractColorSpace() = default; diff --git a/Pdf4QtLibCore/sources/pdfcompiler.h b/Pdf4QtLibCore/sources/pdfcompiler.h index 83ee308..ab9ea20 100644 --- a/Pdf4QtLibCore/sources/pdfcompiler.h +++ b/Pdf4QtLibCore/sources/pdfcompiler.h @@ -148,7 +148,7 @@ private: std::map m_tasks; }; -class PDF4QTLIBSHARED_EXPORT PDFAsynchronousTextLayoutCompiler : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFAsynchronousTextLayoutCompiler : public QObject { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfdiff.h b/Pdf4QtLibCore/sources/pdfdiff.h index f5f5952..99be934 100644 --- a/Pdf4QtLibCore/sources/pdfdiff.h +++ b/Pdf4QtLibCore/sources/pdfdiff.h @@ -38,7 +38,7 @@ namespace pdf struct PDFDiffPageContext; -class PDF4QTLIBSHARED_EXPORT PDFDiffResult +class PDF4QTLIBCORESHARED_EXPORT PDFDiffResult { public: explicit PDFDiffResult(); @@ -236,7 +236,7 @@ private: }; /// Class for result navigation, can go to next, or previous result. -class PDF4QTLIBSHARED_EXPORT PDFDiffResultNavigator : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFDiffResultNavigator : public QObject { Q_OBJECT @@ -283,7 +283,7 @@ private: }; /// Diff engine for comparing two pdf documents. -class PDF4QTLIBSHARED_EXPORT PDFDiff : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFDiff : public QObject { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfdocument.h b/Pdf4QtLibCore/sources/pdfdocument.h index 6de194c..977f825 100644 --- a/Pdf4QtLibCore/sources/pdfdocument.h +++ b/Pdf4QtLibCore/sources/pdfdocument.h @@ -37,7 +37,7 @@ class PDFDocumentBuilder; /// Storage for objects. This class is not thread safe for writing (calling non-const functions). Caller must ensure /// locking, if this object is used from multiple threads. Calling const functions should be thread safe. -class PDF4QTLIBSHARED_EXPORT PDFObjectStorage +class PDF4QTLIBCORESHARED_EXPORT PDFObjectStorage { public: inline PDFObjectStorage() = default; @@ -146,7 +146,7 @@ private: /// then if object with valid data is not found, default value is used, and second one, /// without default value, if valid data are not found, then exception is thrown. /// This class uses Decorator design pattern. -class PDF4QTLIBSHARED_EXPORT PDFDocumentDataLoaderDecorator +class PDF4QTLIBCORESHARED_EXPORT PDFDocumentDataLoaderDecorator { public: explicit PDFDocumentDataLoaderDecorator(const PDFDocument* document); @@ -402,7 +402,7 @@ private: }; /// PDF document main class. -class PDF4QTLIBSHARED_EXPORT PDFDocument +class PDF4QTLIBCORESHARED_EXPORT PDFDocument { Q_DECLARE_TR_FUNCTIONS(pdf::PDFDocument) diff --git a/Pdf4QtLibCore/sources/pdfdocumentbuilder.h b/Pdf4QtLibCore/sources/pdfdocumentbuilder.h index 30f4551..0cd2384 100644 --- a/Pdf4QtLibCore/sources/pdfdocumentbuilder.h +++ b/Pdf4QtLibCore/sources/pdfdocumentbuilder.h @@ -92,7 +92,7 @@ struct WrapEmptyArray { }; /// Factory for creating various PDF objects, such as simple objects, /// dictionaries, arrays etc. -class PDF4QTLIBSHARED_EXPORT PDFObjectFactory +class PDF4QTLIBCORESHARED_EXPORT PDFObjectFactory { public: inline explicit PDFObjectFactory() = default; @@ -207,7 +207,7 @@ private: /// to draw graphics elements on it. Content stream can have various /// resources, which can, if selected be dereferenced, so content /// stream is encapsulated and doesn't contain references. -class PDF4QTLIBSHARED_EXPORT PDFContentStreamBuilder +class PDF4QTLIBCORESHARED_EXPORT PDFContentStreamBuilder { public: @@ -264,7 +264,7 @@ private: /// to draw graphics elements on it. Content stream can have various /// resources, which can, if selected be dereferenced, so content /// stream is encapsulated and doesn't contain references. -class PDF4QTLIBSHARED_EXPORT PDFPageContentStreamBuilder +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentStreamBuilder { public: @@ -314,7 +314,7 @@ private: Mode m_mode; }; -class PDF4QTLIBSHARED_EXPORT PDFDocumentBuilder +class PDF4QTLIBCORESHARED_EXPORT PDFDocumentBuilder { public: /// Creates a new blank document (with no pages) @@ -1588,7 +1588,7 @@ private: /// This class serves for document modification. While document is modified, /// modification flags are gathered. At the end of the modification, it is checked, /// if document was really changed. -class PDF4QTLIBSHARED_EXPORT PDFDocumentModifier +class PDF4QTLIBCORESHARED_EXPORT PDFDocumentModifier { public: explicit PDFDocumentModifier(const PDFDocument* originalDocument); diff --git a/Pdf4QtLibCore/sources/pdfdocumentdrawinterface.h b/Pdf4QtLibCore/sources/pdfdocumentdrawinterface.h index eb663ff..8834d59 100644 --- a/Pdf4QtLibCore/sources/pdfdocumentdrawinterface.h +++ b/Pdf4QtLibCore/sources/pdfdocumentdrawinterface.h @@ -33,7 +33,7 @@ namespace pdf class PDFPrecompiledPage; class PDFTextLayoutGetter; -class PDF4QTLIBSHARED_EXPORT IDocumentDrawInterface +class PDF4QTLIBCORESHARED_EXPORT IDocumentDrawInterface { public: explicit inline IDocumentDrawInterface() = default; diff --git a/Pdf4QtLibCore/sources/pdfdocumentmanipulator.h b/Pdf4QtLibCore/sources/pdfdocumentmanipulator.h index e0c8ef7..0a1d208 100644 --- a/Pdf4QtLibCore/sources/pdfdocumentmanipulator.h +++ b/Pdf4QtLibCore/sources/pdfdocumentmanipulator.h @@ -30,7 +30,7 @@ namespace pdf /// to a new document, where pages are inserted/removed/moved, or joined /// from another documents, or blank pages/image pages inserted. Document /// is also optimized. -class PDF4QTLIBSHARED_EXPORT PDFDocumentManipulator +class PDF4QTLIBCORESHARED_EXPORT PDFDocumentManipulator { Q_DECLARE_TR_FUNCTIONS(pdf::PDFDocumentManipulator) diff --git a/Pdf4QtLibCore/sources/pdfdocumentreader.h b/Pdf4QtLibCore/sources/pdfdocumentreader.h index a8acabd..e3643da 100644 --- a/Pdf4QtLibCore/sources/pdfdocumentreader.h +++ b/Pdf4QtLibCore/sources/pdfdocumentreader.h @@ -35,7 +35,7 @@ class PDFParsingContext; /// This class is a reader of PDF document from various devices (file, io device, /// byte buffer). This class doesn't throw exceptions, to check errors, use /// appropriate functions. -class PDF4QTLIBSHARED_EXPORT PDFDocumentReader +class PDF4QTLIBCORESHARED_EXPORT PDFDocumentReader { Q_DECLARE_TR_FUNCTIONS(pdf::PDFDocumentReader) diff --git a/Pdf4QtLibCore/sources/pdfdocumentsanitizer.h b/Pdf4QtLibCore/sources/pdfdocumentsanitizer.h index 67a03d3..7eb2de7 100644 --- a/Pdf4QtLibCore/sources/pdfdocumentsanitizer.h +++ b/Pdf4QtLibCore/sources/pdfdocumentsanitizer.h @@ -27,7 +27,7 @@ class PDFAnnotation; /// Class for sanitizing documents. Can remove sensitive content from the document, /// except the content streams. Sanitization is configurable, user can specify, /// which content should be removed. -class PDF4QTLIBSHARED_EXPORT PDFDocumentSanitizer : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFDocumentSanitizer : public QObject { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfdocumenttextflow.h b/Pdf4QtLibCore/sources/pdfdocumenttextflow.h index a39a150..fc964c6 100644 --- a/Pdf4QtLibCore/sources/pdfdocumenttextflow.h +++ b/Pdf4QtLibCore/sources/pdfdocumenttextflow.h @@ -29,7 +29,7 @@ class PDFDocument; /// Text flow extracted from document. Text flow can be created \p PDFDocumentTextFlowFactory. /// Flow can contain various items, not just text ones. Also, some manipulation functions /// are available, they can modify text flow by various content. -class PDF4QTLIBSHARED_EXPORT PDFDocumentTextFlow +class PDF4QTLIBCORESHARED_EXPORT PDFDocumentTextFlow { public: @@ -104,7 +104,7 @@ private: }; /// This factory creates text flow for whole document -class PDF4QTLIBSHARED_EXPORT PDFDocumentTextFlowFactory +class PDF4QTLIBCORESHARED_EXPORT PDFDocumentTextFlowFactory { public: explicit PDFDocumentTextFlowFactory() = default; @@ -150,7 +150,7 @@ private: /// Editor which can edit document text flow, modify user text, /// change order of text items, restore original state of a text flow, /// and many other features. -class PDF4QTLIBSHARED_EXPORT PDFDocumentTextFlowEditor +class PDF4QTLIBCORESHARED_EXPORT PDFDocumentTextFlowEditor { public: inline PDFDocumentTextFlowEditor() = default; diff --git a/Pdf4QtLibCore/sources/pdfdocumenttextfloweditormodel.h b/Pdf4QtLibCore/sources/pdfdocumenttextfloweditormodel.h index ccc4096..fb7a852 100644 --- a/Pdf4QtLibCore/sources/pdfdocumenttextfloweditormodel.h +++ b/Pdf4QtLibCore/sources/pdfdocumenttextfloweditormodel.h @@ -27,7 +27,7 @@ namespace pdf { class PDFDocumentTextFlowEditor; -class PDF4QTLIBSHARED_EXPORT PDFDocumentTextFlowEditorModel : public QAbstractTableModel +class PDF4QTLIBCORESHARED_EXPORT PDFDocumentTextFlowEditorModel : public QAbstractTableModel { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfdocumentwriter.h b/Pdf4QtLibCore/sources/pdfdocumentwriter.h index 7524da9..e51ca9b 100644 --- a/Pdf4QtLibCore/sources/pdfdocumentwriter.h +++ b/Pdf4QtLibCore/sources/pdfdocumentwriter.h @@ -29,7 +29,7 @@ namespace pdf /// Class used for writing PDF documents to the desired target device (or file, /// buffer, etc.). If writing is not successful, then error message is returned. -class PDF4QTLIBSHARED_EXPORT PDFDocumentWriter +class PDF4QTLIBCORESHARED_EXPORT PDFDocumentWriter { Q_DECLARE_TR_FUNCTIONS(pdf::PDFDocumentWriter) diff --git a/Pdf4QtLibCore/sources/pdfdrawspacecontroller.h b/Pdf4QtLibCore/sources/pdfdrawspacecontroller.h index b013120..d9478a0 100644 --- a/Pdf4QtLibCore/sources/pdfdrawspacecontroller.h +++ b/Pdf4QtLibCore/sources/pdfdrawspacecontroller.h @@ -194,7 +194,7 @@ struct PDFWidgetSnapshot /// This is a proxy class to draw space controller using widget. We have two spaces, pixel space /// (on the controlled widget) and device space (device is draw space controller). -class PDF4QTLIBSHARED_EXPORT PDFDrawWidgetProxy : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFDrawWidgetProxy : public QObject { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfencoding.h b/Pdf4QtLibCore/sources/pdfencoding.h index a38a3d5..8e74bbf 100644 --- a/Pdf4QtLibCore/sources/pdfencoding.h +++ b/Pdf4QtLibCore/sources/pdfencoding.h @@ -35,7 +35,7 @@ using EncodingTable = std::array; /// This class can convert byte stream to the QString in unicode encoding. /// PDF has several encodings, see PDF Reference 1.7, Appendix D. -class PDF4QTLIBSHARED_EXPORT PDFEncoding +class PDF4QTLIBCORESHARED_EXPORT PDFEncoding { public: explicit PDFEncoding() = delete; diff --git a/Pdf4QtLibCore/sources/pdfexecutionpolicy.h b/Pdf4QtLibCore/sources/pdfexecutionpolicy.h index c84619a..4e21c61 100644 --- a/Pdf4QtLibCore/sources/pdfexecutionpolicy.h +++ b/Pdf4QtLibCore/sources/pdfexecutionpolicy.h @@ -33,7 +33,7 @@ struct PDFExecutionPolicyHolder; /// Defines thread execution policy based on settings and actual number of page content /// streams being processed. It can regulate number of threads executed at each /// point, where execution policy is used. -class PDF4QTLIBSHARED_EXPORT PDFExecutionPolicy +class PDF4QTLIBCORESHARED_EXPORT PDFExecutionPolicy { public: diff --git a/Pdf4QtLibCore/sources/pdffile.h b/Pdf4QtLibCore/sources/pdffile.h index 2b166c6..5cdfd7e 100644 --- a/Pdf4QtLibCore/sources/pdffile.h +++ b/Pdf4QtLibCore/sources/pdffile.h @@ -31,7 +31,7 @@ class PDFObjectStorage; /// Each identifier consists of two parts - permanent identifier, which /// is unique identifier based on original document, and changing identifier, /// which is updated when document is being modified. -class PDF4QTLIBSHARED_EXPORT PDFFileIdentifier +class PDF4QTLIBCORESHARED_EXPORT PDFFileIdentifier { public: explicit inline PDFFileIdentifier() = default; @@ -49,7 +49,7 @@ private: /// Provides description of collection item property field. It describes it's /// kind, data type, if content of the property should be presented to the user, /// and ordering, visibility and editability. -class PDF4QTLIBSHARED_EXPORT PDFCollectionField +class PDF4QTLIBCORESHARED_EXPORT PDFCollectionField { public: explicit inline PDFCollectionField() = default; @@ -96,7 +96,7 @@ private: /// Collection schema. Contains a list of defined fields. /// Schema can be queried for field definition. -class PDF4QTLIBSHARED_EXPORT PDFCollectionSchema +class PDF4QTLIBCORESHARED_EXPORT PDFCollectionSchema { public: explicit inline PDFCollectionSchema() = default; @@ -123,7 +123,7 @@ private: /// Collection of file attachments. In the PDF file, attached files /// can be grouped in collection (if they are related to each other). -class PDF4QTLIBSHARED_EXPORT PDFCollection +class PDF4QTLIBCORESHARED_EXPORT PDFCollection { public: explicit inline PDFCollection() = default; @@ -242,7 +242,7 @@ private: }; /// Collection folder. Can contain subfolders and files. -class PDF4QTLIBSHARED_EXPORT PDFCollectionFolder +class PDF4QTLIBCORESHARED_EXPORT PDFCollectionFolder { public: explicit inline PDFCollectionFolder() = default; @@ -277,7 +277,7 @@ private: /// Collection item. Contains properties of the collection item, /// for example, embedded file. -class PDF4QTLIBSHARED_EXPORT PDFCollectionItem +class PDF4QTLIBCORESHARED_EXPORT PDFCollectionItem { public: explicit inline PDFCollectionItem() = default; @@ -316,7 +316,7 @@ private: /// Collection navigator. It contains modes of display. Interactive /// PDF processor should display first layout it is capable of. -class PDF4QTLIBSHARED_EXPORT PDFCollectionNavigator +class PDF4QTLIBCORESHARED_EXPORT PDFCollectionNavigator { public: explicit inline PDFCollectionNavigator() = default; @@ -347,7 +347,7 @@ private: Layouts m_layouts = None; }; -class PDF4QTLIBSHARED_EXPORT PDFEmbeddedFile +class PDF4QTLIBCORESHARED_EXPORT PDFEmbeddedFile { public: explicit PDFEmbeddedFile() = default; @@ -372,7 +372,7 @@ private: }; /// File specification -class PDF4QTLIBSHARED_EXPORT PDFFileSpecification +class PDF4QTLIBCORESHARED_EXPORT PDFFileSpecification { public: explicit PDFFileSpecification() = default; diff --git a/Pdf4QtLibCore/sources/pdffont.h b/Pdf4QtLibCore/sources/pdffont.h index 7215c7b..c44a34e 100644 --- a/Pdf4QtLibCore/sources/pdffont.h +++ b/Pdf4QtLibCore/sources/pdffont.h @@ -171,14 +171,14 @@ static constexpr PDFEncoding::Encoding getEncodingForStandardFont(StandardFontTy } } -struct PDF4QTLIBSHARED_EXPORT CIDSystemInfo +struct PDF4QTLIBCORESHARED_EXPORT CIDSystemInfo { QByteArray registry; QByteArray ordering; int supplement = 0; }; -struct PDF4QTLIBSHARED_EXPORT FontDescriptor +struct PDF4QTLIBCORESHARED_EXPORT FontDescriptor { bool isEmbedded() const { return !fontFile.isEmpty() || !fontFile2.isEmpty() || !fontFile3.isEmpty(); } @@ -245,7 +245,7 @@ using CharacterInfos = std::vector; /// Font, which has fixed pixel size. It is programmed as PIMPL, because we need /// to remove FreeType types from the interface (so we do not include FreeType in the interface). -class PDF4QTLIBSHARED_EXPORT PDFRealizedFont +class PDF4QTLIBCORESHARED_EXPORT PDFRealizedFont { public: ~PDFRealizedFont(); @@ -281,7 +281,7 @@ private: }; /// Base class representing font in the PDF file -class PDF4QTLIBSHARED_EXPORT PDFFont +class PDF4QTLIBCORESHARED_EXPORT PDFFont { public: explicit PDFFont(CIDSystemInfo CIDSystemInfo, FontDescriptor fontDescriptor); @@ -404,7 +404,7 @@ public: /// Font cache which caches both fonts, and realized fonts. Cache has individual limit /// for fonts, and realized fonts. -class PDF4QTLIBSHARED_EXPORT PDFFontCache +class PDF4QTLIBCORESHARED_EXPORT PDFFontCache { public: inline explicit PDFFontCache(size_t fontCacheLimit, size_t realizedFontCacheLimit) : @@ -511,7 +511,7 @@ private: }; /// Represents a font CMAP (mapping of CIDs) -class PDF4QTLIBSHARED_EXPORT PDFFontCMap +class PDF4QTLIBCORESHARED_EXPORT PDFFontCMap { public: explicit PDFFontCMap() = default; @@ -663,7 +663,7 @@ private: }; /// Repository with predefined CMaps -class PDF4QTLIBSHARED_EXPORT PDFFontCMapRepository +class PDF4QTLIBCORESHARED_EXPORT PDFFontCMapRepository { public: /// Returns instance of CMAP repository diff --git a/Pdf4QtLibCore/sources/pdfform.h b/Pdf4QtLibCore/sources/pdfform.h index ee8e023..0c7865a 100644 --- a/Pdf4QtLibCore/sources/pdfform.h +++ b/Pdf4QtLibCore/sources/pdfform.h @@ -413,7 +413,7 @@ private: /// Fields forms tree-like structure, where leafs are usually widgets. Fields include /// ordinary widgets, such as buttons, check boxes, combo boxes and text fields, and one /// special - signature field, which represents digital signature. -class PDF4QTLIBSHARED_EXPORT PDFForm +class PDF4QTLIBCORESHARED_EXPORT PDFForm { public: explicit inline PDFForm() = default; @@ -534,7 +534,7 @@ protected: /// Form manager. Manages all form widgets functionality - triggers actions, /// edits fields, updates annotation appearances, etc. Valid pointer to annotation /// manager is requirement. -class PDF4QTLIBSHARED_EXPORT PDFFormManager : public QObject, public IDrawWidgetInputInterface +class PDF4QTLIBCORESHARED_EXPORT PDFFormManager : public QObject, public IDrawWidgetInputInterface { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdffunction.h b/Pdf4QtLibCore/sources/pdffunction.h index b3a683a..659bed3 100644 --- a/Pdf4QtLibCore/sources/pdffunction.h +++ b/Pdf4QtLibCore/sources/pdffunction.h @@ -46,7 +46,7 @@ using PDFFunctionPtr = std::shared_ptr; /// Function has domain and range, values outside of domain and range are clamped /// to the nearest values. This class is fully thread safe (if constant functions /// are called). -class PDF4QTLIBSHARED_EXPORT PDFFunction +class PDF4QTLIBCORESHARED_EXPORT PDFFunction { public: @@ -131,7 +131,7 @@ protected: }; /// Identity function -class PDF4QTLIBSHARED_EXPORT PDFIdentityFunction : public PDFFunction +class PDF4QTLIBCORESHARED_EXPORT PDFIdentityFunction : public PDFFunction { public: explicit PDFIdentityFunction(); @@ -148,7 +148,7 @@ public: /// Sampled function (Type 0 function). /// \note Order is ignored, linear interpolation is always performed. No cubic spline /// interpolation occurs. -class PDF4QTLIBSHARED_EXPORT PDFSampledFunction : public PDFFunction +class PDF4QTLIBCORESHARED_EXPORT PDFSampledFunction : public PDFFunction { public: @@ -217,7 +217,7 @@ private: /// is defined as f(x) = c0 + x^exponent * (c1 - c0). If exponent is 1.0, then linear interpolation /// is performed as f(x) = c0 * (1 - x) + x * c1. To be more precise, if exponent is nearly 1.0, /// then linear interpolation is used instead. -class PDF4QTLIBSHARED_EXPORT PDFExponentialFunction : public PDFFunction +class PDF4QTLIBCORESHARED_EXPORT PDFExponentialFunction : public PDFFunction { public: /// Construct new exponential function. @@ -254,7 +254,7 @@ private: /// Stitching function (Type 3 function) /// This type of function has always exactly one input. Transformation of this function /// is defined via k subfunctions which are used in defined intervals of the input value. -class PDF4QTLIBSHARED_EXPORT PDFStitchingFunction : public PDFFunction +class PDF4QTLIBCORESHARED_EXPORT PDFStitchingFunction : public PDFFunction { public: struct PartialFunction @@ -313,7 +313,7 @@ private: /// Postscript function (Type 4 function) /// Implements subset of postscript language -class PDF4QTLIBSHARED_EXPORT PDFPostScriptFunction : public PDFFunction +class PDF4QTLIBCORESHARED_EXPORT PDFPostScriptFunction : public PDFFunction { public: diff --git a/Pdf4QtLibCore/sources/pdfglobal.h b/Pdf4QtLibCore/sources/pdfglobal.h index 5675583..8645633 100644 --- a/Pdf4QtLibCore/sources/pdfglobal.h +++ b/Pdf4QtLibCore/sources/pdfglobal.h @@ -25,13 +25,13 @@ #include #include -#include +#include -#if !defined(PDF4QTLIBSHARED_EXPORT) -#if defined(PDF4QTLIB_LIBRARY) -# define PDF4QTLIBSHARED_EXPORT Q_DECL_EXPORT +#if !defined(PDF4QTLIBCORESHARED_EXPORT) +#if defined(PDF4QTLIBCORE_LIBRARY) +# define PDF4QTLIBCORESHARED_EXPORT Q_DECL_EXPORT #else -# define PDF4QTLIBSHARED_EXPORT Q_DECL_IMPORT +# define PDF4QTLIBCORESHARED_EXPORT Q_DECL_IMPORT #endif #endif diff --git a/Pdf4QtLibCore/sources/pdficontheme.h b/Pdf4QtLibCore/sources/pdficontheme.h index 120919e..57a584d 100644 --- a/Pdf4QtLibCore/sources/pdficontheme.h +++ b/Pdf4QtLibCore/sources/pdficontheme.h @@ -27,7 +27,7 @@ namespace pdf /// Theme icon provider. Can provide icons from custom directory, /// so user can use their own icon theme. -class PDF4QTLIBSHARED_EXPORT PDFIconTheme +class PDF4QTLIBCORESHARED_EXPORT PDFIconTheme { public: explicit PDFIconTheme() = default; diff --git a/Pdf4QtLibCore/sources/pdfimage.h b/Pdf4QtLibCore/sources/pdfimage.h index b19e6e4..7ac06a7 100644 --- a/Pdf4QtLibCore/sources/pdfimage.h +++ b/Pdf4QtLibCore/sources/pdfimage.h @@ -55,7 +55,7 @@ private: bool m_defaultForPrinting = false; }; -class PDF4QTLIBSHARED_EXPORT PDFImage +class PDF4QTLIBCORESHARED_EXPORT PDFImage { public: PDFImage() = default; diff --git a/Pdf4QtLibCore/sources/pdfimageconversion.h b/Pdf4QtLibCore/sources/pdfimageconversion.h index fc9f621..6874f75 100644 --- a/Pdf4QtLibCore/sources/pdfimageconversion.h +++ b/Pdf4QtLibCore/sources/pdfimageconversion.h @@ -27,7 +27,7 @@ namespace pdf /// This class facilitates various image conversions, /// including transforming colored images into monochromatic (or bitonal) formats. -class PDF4QTLIBSHARED_EXPORT PDFImageConversion +class PDF4QTLIBCORESHARED_EXPORT PDFImageConversion { public: PDFImageConversion(); diff --git a/Pdf4QtLibCore/sources/pdfjavascriptscanner.h b/Pdf4QtLibCore/sources/pdfjavascriptscanner.h index 94a5daf..4a06b83 100644 --- a/Pdf4QtLibCore/sources/pdfjavascriptscanner.h +++ b/Pdf4QtLibCore/sources/pdfjavascriptscanner.h @@ -57,7 +57,7 @@ struct PDFJavaScriptEntry /// Scans document for all javascript presence (in actions). Several option /// can be set, for example, scan only document actions, or stop scanning, /// when first javascript is found. -class PDF4QTLIBSHARED_EXPORT PDFJavaScriptScanner +class PDF4QTLIBCORESHARED_EXPORT PDFJavaScriptScanner { public: explicit PDFJavaScriptScanner(const PDFDocument* document); diff --git a/Pdf4QtLibCore/sources/pdfjbig2decoder.h b/Pdf4QtLibCore/sources/pdfjbig2decoder.h index 2346769..3c3cd4e 100644 --- a/Pdf4QtLibCore/sources/pdfjbig2decoder.h +++ b/Pdf4QtLibCore/sources/pdfjbig2decoder.h @@ -73,7 +73,7 @@ struct PDFJBIG2HuffmanTableEntry /// state is stored as 8-bit value, where only 7 bits are used. 6 bits are used /// to store Qe value index (current row in the table, number 0-46), and lowest 1 bit /// is used to store current MPS value (most probable symbol - 0/1). -class PDF4QTLIBSHARED_EXPORT PDFJBIG2ArithmeticDecoderState +class PDF4QTLIBCORESHARED_EXPORT PDFJBIG2ArithmeticDecoderState { public: explicit inline PDFJBIG2ArithmeticDecoderState() = default; @@ -139,7 +139,7 @@ private: /// of decoder described in document ISO/IEC 14492:2001, T.88, annex G (arithmetic decoding /// procedure). It uses 32-bit fixed point arithmetic instead of 16-bit fixed point /// arithmetic described in the specification (it is much faster). -class PDF4QTLIBSHARED_EXPORT PDFJBIG2ArithmeticDecoder +class PDF4QTLIBCORESHARED_EXPORT PDFJBIG2ArithmeticDecoder { public: explicit inline PDFJBIG2ArithmeticDecoder(PDFBitReader* reader) : @@ -323,7 +323,7 @@ private: std::vector m_entries; }; -class PDF4QTLIBSHARED_EXPORT PDFJBIG2Bitmap : public PDFJBIG2Segment +class PDF4QTLIBCORESHARED_EXPORT PDFJBIG2Bitmap : public PDFJBIG2Segment { public: explicit PDFJBIG2Bitmap(); @@ -427,7 +427,7 @@ using PDFJBIG2ATPositions = std::array; /// Decoder of JBIG2 data streams. Decodes the black/white monochrome image. /// Handles also global segments. Decoder decodes data using the specification /// ISO/IEC 14492:2001, T.88. -class PDF4QTLIBSHARED_EXPORT PDFJBIG2Decoder +class PDF4QTLIBCORESHARED_EXPORT PDFJBIG2Decoder { public: explicit inline PDFJBIG2Decoder(QByteArray data, QByteArray globalData, PDFRenderErrorReporter* errorReporter) : diff --git a/Pdf4QtLibCore/sources/pdfnametounicode.h b/Pdf4QtLibCore/sources/pdfnametounicode.h index dcfceef..73a9fce 100644 --- a/Pdf4QtLibCore/sources/pdfnametounicode.h +++ b/Pdf4QtLibCore/sources/pdfnametounicode.h @@ -27,7 +27,7 @@ namespace pdf { -class PDF4QTLIBSHARED_EXPORT PDFNameToUnicode +class PDF4QTLIBCORESHARED_EXPORT PDFNameToUnicode { public: explicit PDFNameToUnicode() = delete; diff --git a/Pdf4QtLibCore/sources/pdfobject.h b/Pdf4QtLibCore/sources/pdfobject.h index 4a90652..b6f3f01 100644 --- a/Pdf4QtLibCore/sources/pdfobject.h +++ b/Pdf4QtLibCore/sources/pdfobject.h @@ -112,7 +112,7 @@ struct PDFInplaceString }; /// Reference to the string implementations -struct PDF4QTLIBSHARED_EXPORT PDFStringRef +struct PDF4QTLIBCORESHARED_EXPORT PDFStringRef { const PDFInplaceString* inplaceString = nullptr; const PDFString* memoryString = nullptr; @@ -122,7 +122,7 @@ struct PDF4QTLIBSHARED_EXPORT PDFStringRef /// This class represents string, which can be inplace string (no memory allocation), /// or classic byte array string, if not enough space for embedded string. -class PDF4QTLIBSHARED_EXPORT PDFInplaceOrMemoryString +class PDF4QTLIBCORESHARED_EXPORT PDFInplaceOrMemoryString { public: constexpr PDFInplaceOrMemoryString() = default; @@ -158,7 +158,7 @@ private: std::variant m_value; }; -class PDF4QTLIBSHARED_EXPORT PDFObject +class PDF4QTLIBCORESHARED_EXPORT PDFObject { public: enum class Type : uint8_t @@ -311,7 +311,7 @@ private: }; /// Represents an array of objects in the PDF file. -class PDF4QTLIBSHARED_EXPORT PDFArray : public PDFObjectContent +class PDF4QTLIBCORESHARED_EXPORT PDFArray : public PDFObjectContent { public: inline PDFArray() = default; @@ -353,7 +353,7 @@ private: /// an array of pairs key-value, where key is name object and value is any /// PDF object. For this reason, we use QByteArray for key. We do not use /// map, because dictionaries are usually small. -class PDF4QTLIBSHARED_EXPORT PDFDictionary : public PDFObjectContent +class PDF4QTLIBCORESHARED_EXPORT PDFDictionary : public PDFObjectContent { public: using DictionaryEntry = std::pair; @@ -464,7 +464,7 @@ private: /// Represents a stream object in the PDF file. Stream consists of dictionary /// and stream content - byte array. -class PDF4QTLIBSHARED_EXPORT PDFStream : public PDFObjectContent +class PDF4QTLIBCORESHARED_EXPORT PDFStream : public PDFObjectContent { public: inline explicit PDFStream() = default; @@ -493,7 +493,7 @@ private: QByteArray m_content; }; -class PDF4QTLIBSHARED_EXPORT PDFObjectManipulator +class PDF4QTLIBCORESHARED_EXPORT PDFObjectManipulator { public: explicit PDFObjectManipulator() = delete; diff --git a/Pdf4QtLibCore/sources/pdfobjecteditormodel.h b/Pdf4QtLibCore/sources/pdfobjecteditormodel.h index bca67b8..43ef4f4 100644 --- a/Pdf4QtLibCore/sources/pdfobjecteditormodel.h +++ b/Pdf4QtLibCore/sources/pdfobjecteditormodel.h @@ -121,7 +121,7 @@ struct PDFObjectEditorModelAttribute bool selectorAttributeValue = false; }; -class PDF4QTLIBSHARED_EXPORT PDFObjectEditorAbstractModel : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFObjectEditorAbstractModel : public QObject { Q_OBJECT @@ -230,7 +230,7 @@ protected: std::map> m_similarAttributes; }; -class PDF4QTLIBSHARED_EXPORT PDFObjectEditorAnnotationsModel : public PDFObjectEditorAbstractModel +class PDF4QTLIBCORESHARED_EXPORT PDFObjectEditorAnnotationsModel : public PDFObjectEditorAbstractModel { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfobjectutils.h b/Pdf4QtLibCore/sources/pdfobjectutils.h index e22b4b8..52dba51 100644 --- a/Pdf4QtLibCore/sources/pdfobjectutils.h +++ b/Pdf4QtLibCore/sources/pdfobjectutils.h @@ -32,7 +32,7 @@ class PDFObjectStorage; class PDFDocument; /// Utilities for manipulation with objects -class PDF4QTLIBSHARED_EXPORT PDFObjectUtils +class PDF4QTLIBCORESHARED_EXPORT PDFObjectUtils { public: /// Returns a list of references referenced by \p objects. So, all references, which are present @@ -111,7 +111,7 @@ private: /// Classifies objects according to their type. Some heuristic is used /// when object type is missing or document is not well-formed. -class PDF4QTLIBSHARED_EXPORT PDFObjectClassifier +class PDF4QTLIBCORESHARED_EXPORT PDFObjectClassifier { public: diff --git a/Pdf4QtLibCore/sources/pdfoptimizer.h b/Pdf4QtLibCore/sources/pdfoptimizer.h index 1b6095b..5055084 100644 --- a/Pdf4QtLibCore/sources/pdfoptimizer.h +++ b/Pdf4QtLibCore/sources/pdfoptimizer.h @@ -29,7 +29,7 @@ namespace pdf /// and remove unused objects, merge same objects, or even recompress some streams /// to achieve better optimization ratio. Optimization is configurable, user can specify, /// which optimization steps should be done and which not. -class PDF4QTLIBSHARED_EXPORT PDFOptimizer : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFOptimizer : public QObject { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfoptionalcontent.h b/Pdf4QtLibCore/sources/pdfoptionalcontent.h index 9c2ab7e..3a1dd0a 100644 --- a/Pdf4QtLibCore/sources/pdfoptionalcontent.h +++ b/Pdf4QtLibCore/sources/pdfoptionalcontent.h @@ -155,7 +155,7 @@ private: }; /// Activeness of the optional content -class PDF4QTLIBSHARED_EXPORT PDFOptionalContentActivity : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFOptionalContentActivity : public QObject { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfoutline.h b/Pdf4QtLibCore/sources/pdfoutline.h index 783ebe5..0353e69 100644 --- a/Pdf4QtLibCore/sources/pdfoutline.h +++ b/Pdf4QtLibCore/sources/pdfoutline.h @@ -31,7 +31,7 @@ namespace pdf class PDFDocument; /// Outline item -class PDF4QTLIBSHARED_EXPORT PDFOutlineItem +class PDF4QTLIBCORESHARED_EXPORT PDFOutlineItem { public: explicit PDFOutlineItem() = default; diff --git a/Pdf4QtLibCore/sources/pdfpage.h b/Pdf4QtLibCore/sources/pdfpage.h index f15512c..001e766 100644 --- a/Pdf4QtLibCore/sources/pdfpage.h +++ b/Pdf4QtLibCore/sources/pdfpage.h @@ -139,7 +139,7 @@ private: /// Object representing page in PDF document. Contains different page properties, such as /// media box, crop box, rotation, etc. and also page content, resources. -class PDF4QTLIBSHARED_EXPORT PDFPage +class PDF4QTLIBCORESHARED_EXPORT PDFPage { public: explicit PDFPage() = default; diff --git a/Pdf4QtLibCore/sources/pdfpagecontentprocessor.h b/Pdf4QtLibCore/sources/pdfpagecontentprocessor.h index d27aaf8..559074e 100644 --- a/Pdf4QtLibCore/sources/pdfpagecontentprocessor.h +++ b/Pdf4QtLibCore/sources/pdfpagecontentprocessor.h @@ -80,7 +80,7 @@ private: }; /// Process the contents of the page. -class PDF4QTLIBSHARED_EXPORT PDFPageContentProcessor : public PDFRenderErrorReporter +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentProcessor : public PDFRenderErrorReporter { public: explicit PDFPageContentProcessor(const PDFPage* page, @@ -706,7 +706,7 @@ protected: /// Returns optional content activity const PDFOptionalContentActivity* getOptionalContentActivity() const { return m_optionalContentActivity; } - class PDF4QTLIBSHARED_EXPORT PDFTransparencyGroupGuard + class PDF4QTLIBCORESHARED_EXPORT PDFTransparencyGroupGuard { public: explicit PDFTransparencyGroupGuard(PDFPageContentProcessor* processor, PDFTransparencyGroup&& group); diff --git a/Pdf4QtLibCore/sources/pdfpagenavigation.h b/Pdf4QtLibCore/sources/pdfpagenavigation.h index f5ec0b3..0c49aac 100644 --- a/Pdf4QtLibCore/sources/pdfpagenavigation.h +++ b/Pdf4QtLibCore/sources/pdfpagenavigation.h @@ -60,7 +60,7 @@ private: /// Navigation object, which helps to navigate trough document. /// It also handles subpage navigation, if subpage navigation /// steps are present. -class PDF4QTLIBSHARED_EXPORT PDFPageNavigation : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFPageNavigation : public QObject { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfpainter.h b/Pdf4QtLibCore/sources/pdfpainter.h index 336211b..1662141 100644 --- a/Pdf4QtLibCore/sources/pdfpainter.h +++ b/Pdf4QtLibCore/sources/pdfpainter.h @@ -364,7 +364,7 @@ private: /// Processor, which processes PDF's page commands and writes them to the precompiled page. /// Precompiled page then can be used to execute these commands on QPainter. -class PDF4QTLIBSHARED_EXPORT PDFPrecompiledPageGenerator : public PDFPainterBase +class PDF4QTLIBCORESHARED_EXPORT PDFPrecompiledPageGenerator : public PDFPainterBase { using BaseClass = PDFPainterBase; diff --git a/Pdf4QtLibCore/sources/pdfpainterutils.h b/Pdf4QtLibCore/sources/pdfpainterutils.h index 552db47..ecef6e1 100644 --- a/Pdf4QtLibCore/sources/pdfpainterutils.h +++ b/Pdf4QtLibCore/sources/pdfpainterutils.h @@ -44,7 +44,7 @@ private: QPainter* m_painter; }; -class PDF4QTLIBSHARED_EXPORT PDFPainterHelper +class PDF4QTLIBCORESHARED_EXPORT PDFPainterHelper { public: /// Draws bubble using painter. Bubble is aligned to the point, colored with color diff --git a/Pdf4QtLibCore/sources/pdfparser.h b/Pdf4QtLibCore/sources/pdfparser.h index 8bcf8e6..41f5deb 100644 --- a/Pdf4QtLibCore/sources/pdfparser.h +++ b/Pdf4QtLibCore/sources/pdfparser.h @@ -78,7 +78,7 @@ constexpr const char* PDF_REFERENCE_COMMAND = "R"; constexpr const char* PDF_STREAM_START_COMMAND = "stream"; constexpr const char* PDF_STREAM_END_COMMAND = "endstream"; -class PDF4QTLIBSHARED_EXPORT PDFLexicalAnalyzer +class PDF4QTLIBCORESHARED_EXPORT PDFLexicalAnalyzer { Q_GADGET Q_DECLARE_TR_FUNCTIONS(pdf::PDFLexicalAnalyzer) @@ -283,7 +283,7 @@ private: /// Class for parsing objects. Checks cyclical references. If /// the object cannot be obtained from the stream, exception is thrown. -class PDF4QTLIBSHARED_EXPORT PDFParser +class PDF4QTLIBCORESHARED_EXPORT PDFParser { Q_DECLARE_TR_FUNCTIONS(pdf::PDFParser) diff --git a/Pdf4QtLibCore/sources/pdfplugin.h b/Pdf4QtLibCore/sources/pdfplugin.h index b6e32a6..857d95a 100644 --- a/Pdf4QtLibCore/sources/pdfplugin.h +++ b/Pdf4QtLibCore/sources/pdfplugin.h @@ -34,7 +34,7 @@ namespace pdf class PDFWidget; class PDFCMSManager; -struct PDF4QTLIBSHARED_EXPORT PDFPluginInfo +struct PDF4QTLIBCORESHARED_EXPORT PDFPluginInfo { QString name; QString author; @@ -69,7 +69,7 @@ public: virtual VoiceSettings getVoiceSettings() const = 0; }; -class PDF4QTLIBSHARED_EXPORT PDFPlugin : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFPlugin : public QObject { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfprogress.h b/Pdf4QtLibCore/sources/pdfprogress.h index ca80960..b5b38e3 100644 --- a/Pdf4QtLibCore/sources/pdfprogress.h +++ b/Pdf4QtLibCore/sources/pdfprogress.h @@ -33,7 +33,7 @@ struct ProgressStartupInfo QString text; }; -class PDF4QTLIBSHARED_EXPORT PDFProgress : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFProgress : public QObject { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfredact.h b/Pdf4QtLibCore/sources/pdfredact.h index 3dc6782..d6016d1 100644 --- a/Pdf4QtLibCore/sources/pdfredact.h +++ b/Pdf4QtLibCore/sources/pdfredact.h @@ -27,7 +27,7 @@ namespace pdf /// Create redacted document from the document, which have redact annotations. /// Redacted document has removed content marked by these annotations, and /// annotations themselfs are removed. -class PDF4QTLIBSHARED_EXPORT PDFRedact +class PDF4QTLIBCORESHARED_EXPORT PDFRedact { public: explicit PDFRedact(const PDFDocument* document, diff --git a/Pdf4QtLibCore/sources/pdfrenderer.h b/Pdf4QtLibCore/sources/pdfrenderer.h index 7c2c5ad..d4d2cdb 100644 --- a/Pdf4QtLibCore/sources/pdfrenderer.h +++ b/Pdf4QtLibCore/sources/pdfrenderer.h @@ -46,7 +46,7 @@ class PDFPrecompiledPage; class PDFAnnotationManager; class PDFOptionalContentActivity; -class PDF4QTLIBSHARED_EXPORT PDFRendererInfo +class PDF4QTLIBCORESHARED_EXPORT PDFRendererInfo { public: PDFRendererInfo() = delete; @@ -71,7 +71,7 @@ private: }; /// Renders the PDF page on the painter, or onto an image. -class PDF4QTLIBSHARED_EXPORT PDFRenderer +class PDF4QTLIBCORESHARED_EXPORT PDFRenderer { public: @@ -169,7 +169,7 @@ private: /// if it is enabled, if this is the case, offscreen rendering to framebuffer /// is used. /// \note Construct this object only in main GUI thread -class PDF4QTLIBSHARED_EXPORT PDFRasterizer : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFRasterizer : public QObject { Q_OBJECT @@ -246,7 +246,7 @@ struct PDFRenderedPageImage /// render page images asynchronously. You can use this object in two ways - /// first one is as standard object pool, second one is to directly render /// page images asynchronously. -class PDF4QTLIBSHARED_EXPORT PDFRasterizerPool : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFRasterizerPool : public QObject { Q_OBJECT @@ -328,7 +328,7 @@ private: }; /// Settings object for image writer -class PDF4QTLIBSHARED_EXPORT PDFImageWriterSettings +class PDF4QTLIBCORESHARED_EXPORT PDFImageWriterSettings { public: explicit PDFImageWriterSettings(); @@ -380,7 +380,7 @@ private: }; /// This class is for setup of page image exporter -class PDF4QTLIBSHARED_EXPORT PDFPageImageExportSettings +class PDF4QTLIBCORESHARED_EXPORT PDFPageImageExportSettings { public: explicit PDFPageImageExportSettings() : PDFPageImageExportSettings(nullptr) { } diff --git a/Pdf4QtLibCore/sources/pdfsecurityhandler.h b/Pdf4QtLibCore/sources/pdfsecurityhandler.h index 1c33150..32930a5 100644 --- a/Pdf4QtLibCore/sources/pdfsecurityhandler.h +++ b/Pdf4QtLibCore/sources/pdfsecurityhandler.h @@ -445,7 +445,7 @@ private: }; /// Factory, which creates security handler based on settings. -class PDF4QTLIBSHARED_EXPORT PDFSecurityHandlerFactory +class PDF4QTLIBCORESHARED_EXPORT PDFSecurityHandlerFactory { Q_DECLARE_TR_FUNCTIONS(pdf::PDFSecurityHandlerFactory) diff --git a/Pdf4QtLibCore/sources/pdfsignaturehandler.h b/Pdf4QtLibCore/sources/pdfsignaturehandler.h index d93044e..388e424 100644 --- a/Pdf4QtLibCore/sources/pdfsignaturehandler.h +++ b/Pdf4QtLibCore/sources/pdfsignaturehandler.h @@ -153,7 +153,7 @@ private: }; /// Info about certificate, various details etc. -class PDF4QTLIBSHARED_EXPORT PDFCertificateInfo +class PDF4QTLIBCORESHARED_EXPORT PDFCertificateInfo { public: explicit inline PDFCertificateInfo() = default; @@ -270,7 +270,7 @@ private: using PDFCertificateInfos = std::vector; -class PDF4QTLIBSHARED_EXPORT PDFSignatureVerificationResult +class PDF4QTLIBCORESHARED_EXPORT PDFSignatureVerificationResult { public: explicit PDFSignatureVerificationResult() = default; @@ -428,7 +428,7 @@ private: }; /// Signature handler. Can verify both certificate and signature validity. -class PDF4QTLIBSHARED_EXPORT PDFSignatureHandler +class PDF4QTLIBCORESHARED_EXPORT PDFSignatureHandler { public: explicit PDFSignatureHandler() = default; @@ -465,7 +465,7 @@ private: /// Trusted certificate store. Contains list of trusted certificates. Store /// can be persisted to the persistent storage trough serialization/deserialization. /// Persisting method is versioned. -class PDF4QTLIBSHARED_EXPORT PDFCertificateStore +class PDF4QTLIBCORESHARED_EXPORT PDFCertificateStore { public: explicit inline PDFCertificateStore() = default; diff --git a/Pdf4QtLibCore/sources/pdfsnapper.cpp b/Pdf4QtLibCore/sources/pdfsnapper.cpp index bbf5e50..217d56e 100644 --- a/Pdf4QtLibCore/sources/pdfsnapper.cpp +++ b/Pdf4QtLibCore/sources/pdfsnapper.cpp @@ -17,7 +17,6 @@ #include "pdfsnapper.h" #include "pdfcompiler.h" -#include "pdfwidgetutils.h" #include "pdfdrawspacecontroller.h" #include "pdfdbgheap.h" diff --git a/Pdf4QtLibCore/sources/pdfstreamfilters.h b/Pdf4QtLibCore/sources/pdfstreamfilters.h index e89c740..46f3e0a 100644 --- a/Pdf4QtLibCore/sources/pdfstreamfilters.h +++ b/Pdf4QtLibCore/sources/pdfstreamfilters.h @@ -137,7 +137,7 @@ private: int m_stride = 0; }; -class PDF4QTLIBSHARED_EXPORT PDFStreamFilter +class PDF4QTLIBCORESHARED_EXPORT PDFStreamFilter { public: explicit PDFStreamFilter() = default; @@ -164,7 +164,7 @@ public: virtual PDFInteger getStreamDataLength(const QByteArray& data, PDFInteger offset) const; }; -class PDF4QTLIBSHARED_EXPORT PDFAsciiHexDecodeFilter : public PDFStreamFilter +class PDF4QTLIBCORESHARED_EXPORT PDFAsciiHexDecodeFilter : public PDFStreamFilter { public: explicit PDFAsciiHexDecodeFilter() = default; @@ -176,7 +176,7 @@ public: const PDFSecurityHandler* securityHandler) const override; }; -class PDF4QTLIBSHARED_EXPORT PDFAscii85DecodeFilter : public PDFStreamFilter +class PDF4QTLIBCORESHARED_EXPORT PDFAscii85DecodeFilter : public PDFStreamFilter { public: explicit PDFAscii85DecodeFilter() = default; @@ -188,7 +188,7 @@ public: const PDFSecurityHandler* securityHandler) const override; }; -class PDF4QTLIBSHARED_EXPORT PDFLzwDecodeFilter : public PDFStreamFilter +class PDF4QTLIBCORESHARED_EXPORT PDFLzwDecodeFilter : public PDFStreamFilter { public: explicit PDFLzwDecodeFilter() = default; @@ -200,7 +200,7 @@ public: const PDFSecurityHandler* securityHandler) const override; }; -class PDF4QTLIBSHARED_EXPORT PDFFlateDecodeFilter : public PDFStreamFilter +class PDF4QTLIBCORESHARED_EXPORT PDFFlateDecodeFilter : public PDFStreamFilter { public: explicit PDFFlateDecodeFilter() = default; @@ -226,7 +226,7 @@ private: static QByteArray uncompress(const QByteArray& data); }; -class PDF4QTLIBSHARED_EXPORT PDFRunLengthDecodeFilter : public PDFStreamFilter +class PDF4QTLIBCORESHARED_EXPORT PDFRunLengthDecodeFilter : public PDFStreamFilter { public: explicit PDFRunLengthDecodeFilter() = default; @@ -238,7 +238,7 @@ public: const PDFSecurityHandler* securityHandler) const override; }; -class PDF4QTLIBSHARED_EXPORT PDFCryptFilter : public PDFStreamFilter +class PDF4QTLIBCORESHARED_EXPORT PDFCryptFilter : public PDFStreamFilter { public: explicit PDFCryptFilter() = default; diff --git a/Pdf4QtLibCore/sources/pdfstructuretree.h b/Pdf4QtLibCore/sources/pdfstructuretree.h index 84f3ecf..b857ced 100644 --- a/Pdf4QtLibCore/sources/pdfstructuretree.h +++ b/Pdf4QtLibCore/sources/pdfstructuretree.h @@ -35,7 +35,7 @@ class PDFStructureElement; class PDFStructureMarkedContentReference; class PDFStructureObjectReference; -class PDF4QTLIBSHARED_EXPORT PDFStructureTreeAbstractVisitor +class PDF4QTLIBCORESHARED_EXPORT PDFStructureTreeAbstractVisitor { public: inline PDFStructureTreeAbstractVisitor() = default; @@ -50,7 +50,7 @@ protected: void acceptChildren(const PDFStructureItem* item); }; -class PDF4QTLIBSHARED_EXPORT PDFStructureTreeAttribute +class PDF4QTLIBCORESHARED_EXPORT PDFStructureTreeAttribute { public: @@ -251,7 +251,7 @@ class PDFStructureMarkedContentReference; using PDFStructureItemPointer = QSharedPointer; /// Root class for all structure tree items -class PDF4QTLIBSHARED_EXPORT PDFStructureItem +class PDF4QTLIBCORESHARED_EXPORT PDFStructureItem { public: explicit inline PDFStructureItem(PDFStructureItem* parent, PDFStructureTree* root) : @@ -345,7 +345,7 @@ protected: }; /// Structure tree namespace -class PDF4QTLIBSHARED_EXPORT PDFStructureTreeNamespace +class PDF4QTLIBCORESHARED_EXPORT PDFStructureTreeNamespace { public: explicit inline PDFStructureTreeNamespace() = default; @@ -367,7 +367,7 @@ private: using PDFStructureTreeNamespaces = std::vector; /// Structure tree, contains structure element hierarchy -class PDF4QTLIBSHARED_EXPORT PDFStructureTree : public PDFStructureItem +class PDF4QTLIBCORESHARED_EXPORT PDFStructureTree : public PDFStructureItem { public: explicit inline PDFStructureTree() : PDFStructureItem(nullptr, this) { } @@ -447,7 +447,7 @@ private: }; /// Structure element -class PDF4QTLIBSHARED_EXPORT PDFStructureElement : public PDFStructureItem +class PDF4QTLIBCORESHARED_EXPORT PDFStructureElement : public PDFStructureItem { public: explicit inline PDFStructureElement(PDFStructureItem* parent, PDFStructureTree* root) : @@ -539,7 +539,7 @@ private: }; /// Structure marked content reference -class PDF4QTLIBSHARED_EXPORT PDFStructureMarkedContentReference : public PDFStructureItem +class PDF4QTLIBCORESHARED_EXPORT PDFStructureMarkedContentReference : public PDFStructureItem { public: explicit inline PDFStructureMarkedContentReference(PDFStructureItem* parent, PDFStructureTree* root) : @@ -577,7 +577,7 @@ private: }; /// Structure object reference -class PDF4QTLIBSHARED_EXPORT PDFStructureObjectReference : public PDFStructureItem +class PDF4QTLIBCORESHARED_EXPORT PDFStructureObjectReference : public PDFStructureItem { public: explicit inline PDFStructureObjectReference(PDFStructureItem* parent, PDFStructureTree* root) : diff --git a/Pdf4QtLibCore/sources/pdftexteditpseudowidget.cpp b/Pdf4QtLibCore/sources/pdftexteditpseudowidget.cpp index 1cb7e39..04f949b 100644 --- a/Pdf4QtLibCore/sources/pdftexteditpseudowidget.cpp +++ b/Pdf4QtLibCore/sources/pdftexteditpseudowidget.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include namespace pdf @@ -35,7 +35,7 @@ PDFTextEditPseudowidget::PDFTextEditPseudowidget(PDFFormField::FieldFlags flags) m_maxTextLength(0) { m_textLayout.setCacheEnabled(true); - m_passwordReplacementCharacter = QChar(QApplication::style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter)); + m_passwordReplacementCharacter = QChar(QCoreApplication::style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter)); } void PDFTextEditPseudowidget::shortcutOverrideEvent(QWidget* widget, QKeyEvent* event) diff --git a/Pdf4QtLibCore/sources/pdftextlayout.h b/Pdf4QtLibCore/sources/pdftextlayout.h index 6408745..aa0ab1f 100644 --- a/Pdf4QtLibCore/sources/pdftextlayout.h +++ b/Pdf4QtLibCore/sources/pdftextlayout.h @@ -226,7 +226,7 @@ using PDFTextSelectionColoredItems = std::vector; /// Text selection, can be used across multiple pages. Also defines color /// for each text selection. -class PDF4QTLIBSHARED_EXPORT PDFTextSelection +class PDF4QTLIBCORESHARED_EXPORT PDFTextSelection { public: explicit PDFTextSelection() = default; @@ -285,7 +285,7 @@ using PDFTextFlows = std::vector; /// This class represents a portion of continuous text on the page. It can /// consists of multiple blocks (which follow reading order). -class PDF4QTLIBSHARED_EXPORT PDFTextFlow +class PDF4QTLIBCORESHARED_EXPORT PDFTextFlow { public: @@ -351,7 +351,7 @@ private: /// Text layout of single page. Can handle various fonts, various angles of lines /// and vertically oriented text. It performs the "docstrum" algorithm. -class PDF4QTLIBSHARED_EXPORT PDFTextLayout +class PDF4QTLIBCORESHARED_EXPORT PDFTextLayout { public: explicit PDFTextLayout(); @@ -436,7 +436,7 @@ private: }; /// Cache for storing single text layout -class PDF4QTLIBSHARED_EXPORT PDFTextLayoutCache +class PDF4QTLIBCORESHARED_EXPORT PDFTextLayoutCache { public: explicit PDFTextLayoutCache(std::function textLayoutGetter); @@ -456,7 +456,7 @@ private: PDFTextLayout m_layout; }; -class PDF4QTLIBSHARED_EXPORT PDFTextLayoutGetter +class PDF4QTLIBCORESHARED_EXPORT PDFTextLayoutGetter { public: explicit inline PDFTextLayoutGetter(PDFTextLayoutCache* cache, PDFInteger pageIndex) : @@ -505,7 +505,7 @@ private: }; /// Paints text selection on various pages using page to device point matrix -class PDF4QTLIBSHARED_EXPORT PDFTextSelectionPainter +class PDF4QTLIBCORESHARED_EXPORT PDFTextSelectionPainter { public: explicit inline PDFTextSelectionPainter(const PDFTextSelection* selection) : @@ -540,7 +540,7 @@ private: /// For writing, mutex is used to synchronize asynchronous writes, for reading /// no mutex is used at all. For this reason, both reading/writing at the same time /// is prohibited, it is not thread safe. -class PDF4QTLIBSHARED_EXPORT PDFTextLayoutStorage +class PDF4QTLIBCORESHARED_EXPORT PDFTextLayoutStorage { public: explicit inline PDFTextLayoutStorage() = default; diff --git a/Pdf4QtLibCore/sources/pdftransparencyrenderer.h b/Pdf4QtLibCore/sources/pdftransparencyrenderer.h index 2c35c58..43e7122 100644 --- a/Pdf4QtLibCore/sources/pdftransparencyrenderer.h +++ b/Pdf4QtLibCore/sources/pdftransparencyrenderer.h @@ -137,7 +137,7 @@ private: /// Represents float bitmap with arbitrary color channel count. Bitmap can also /// have auxiliary channels, such as shape and opacity channels. -class PDF4QTLIBSHARED_EXPORT PDFFloatBitmap +class PDF4QTLIBCORESHARED_EXPORT PDFFloatBitmap { public: explicit PDFFloatBitmap(); @@ -319,7 +319,7 @@ private: }; /// Float bitmap with color space -class PDF4QTLIBSHARED_EXPORT PDFFloatBitmapWithColorSpace : public PDFFloatBitmap +class PDF4QTLIBCORESHARED_EXPORT PDFFloatBitmapWithColorSpace : public PDFFloatBitmap { public: explicit PDFFloatBitmapWithColorSpace(); @@ -365,7 +365,7 @@ struct PDFInkMapping }; /// Ink mapper for mapping device inks (device colors) and spot inks (spot colors). -class PDF4QTLIBSHARED_EXPORT PDFInkMapper +class PDF4QTLIBCORESHARED_EXPORT PDFInkMapper { public: explicit PDFInkMapper(const PDFCMSManager* manager, const PDFDocument* document); @@ -633,7 +633,7 @@ struct PDFTransparencyRendererSettings /// page blending space and device blending space. So, painted graphics is being /// blended to the page blending space, and then converted to the device blending /// space. -class PDF4QTLIBSHARED_EXPORT PDFTransparencyRenderer : public PDFPageContentProcessor +class PDF4QTLIBCORESHARED_EXPORT PDFTransparencyRenderer : public PDFPageContentProcessor { private: using BaseClass = PDFPageContentProcessor; @@ -927,7 +927,7 @@ private: /// Ink coverage calculator. Calculates ink coverage for a given /// page range. Calculates ink coverage of both cmyk colors and spot colors. -class PDF4QTLIBSHARED_EXPORT PDFInkCoverageCalculator +class PDF4QTLIBCORESHARED_EXPORT PDFInkCoverageCalculator { public: PDFInkCoverageCalculator(const PDFDocument* document, diff --git a/Pdf4QtLibCore/sources/pdfutils.h b/Pdf4QtLibCore/sources/pdfutils.h index 900b6b5..2458a02 100644 --- a/Pdf4QtLibCore/sources/pdfutils.h +++ b/Pdf4QtLibCore/sources/pdfutils.h @@ -109,7 +109,7 @@ private: /// Bit-reader, which can read n-bit unsigned integers from the stream. /// Number of bits can be set in the constructor and is constant. -class PDF4QTLIBSHARED_EXPORT PDFBitReader +class PDF4QTLIBCORESHARED_EXPORT PDFBitReader { public: using Value = uint64_t; @@ -190,7 +190,7 @@ private: }; /// Bit writer -class PDF4QTLIBSHARED_EXPORT PDFBitWriter +class PDF4QTLIBCORESHARED_EXPORT PDFBitWriter { public: using Value = uint64_t; @@ -386,7 +386,7 @@ inline constexpr uint8_t log2ceil(uint32_t value) return logarithm; } -struct PDF4QTLIBSHARED_EXPORT PDFDependentLibraryInfo +struct PDF4QTLIBCORESHARED_EXPORT PDFDependentLibraryInfo { Q_DECLARE_TR_FUNCTIONS(pdf::PDFDependentLibraryInfo) @@ -657,7 +657,7 @@ private: }; /// Get system information -class PDF4QTLIBSHARED_EXPORT PDFSysUtils +class PDF4QTLIBCORESHARED_EXPORT PDFSysUtils { public: @@ -665,7 +665,7 @@ public: }; /// Set of closed intervals -class PDF4QTLIBSHARED_EXPORT PDFClosedIntervalSet +class PDF4QTLIBCORESHARED_EXPORT PDFClosedIntervalSet { public: explicit inline PDFClosedIntervalSet() = default; @@ -827,7 +827,7 @@ QDataStream& operator<<(QDataStream& stream, const std::set& set) /// Color scale represents hot-to-cold color scale. It maps value /// to the color from blue trough green to red. -class PDF4QTLIBSHARED_EXPORT PDFColorScale +class PDF4QTLIBCORESHARED_EXPORT PDFColorScale { public: explicit PDFColorScale(); diff --git a/Pdf4QtLibCore/sources/pdfvisitor.h b/Pdf4QtLibCore/sources/pdfvisitor.h index 56ee23c..7abe0fe 100644 --- a/Pdf4QtLibCore/sources/pdfvisitor.h +++ b/Pdf4QtLibCore/sources/pdfvisitor.h @@ -32,7 +32,7 @@ namespace pdf { /// Abstract visitor, can iterate trough object tree -class PDF4QTLIBSHARED_EXPORT PDFAbstractVisitor +class PDF4QTLIBCORESHARED_EXPORT PDFAbstractVisitor { public: @@ -81,7 +81,7 @@ protected: /// Statistics visitor, collects statistics about PDF object, can be /// invoked from multiple threads. -class PDF4QTLIBSHARED_EXPORT PDFStatisticsCollector : public PDFAbstractVisitor +class PDF4QTLIBCORESHARED_EXPORT PDFStatisticsCollector : public PDFAbstractVisitor { public: explicit PDFStatisticsCollector(); diff --git a/Pdf4QtLibWidgets/CMakeLists.txt b/Pdf4QtLibWidgets/CMakeLists.txt index 8f3c782..56280fd 100644 --- a/Pdf4QtLibWidgets/CMakeLists.txt +++ b/Pdf4QtLibWidgets/CMakeLists.txt @@ -47,13 +47,19 @@ add_library(Pdf4QtLibWidgets SHARED sources/pdfselectpagesdialog.h sources/pdfselectpagesdialog.cpp sources/pdfselectpagesdialog.ui + sources/pdfwidgetannotation.h + sources/pdfwidgetannotation.cpp + sources/pdfpagecontentelements.cpp + sources/pdfpagecontentelements.h + sources/pdfitemmodels.cpp + sources/pdfitemmodels.h ) include(GenerateExportHeader) GENERATE_EXPORT_HEADER(Pdf4QtLibWidgets EXPORT_MACRO_NAME - PDF4QTLIBSHARED_EXPORT + PDF4QTLIBCORESHARED_EXPORT EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/pdf4qtlibwidgets_export.h") if(PDF4QT_ENABLE_OPENGL) diff --git a/Pdf4QtLibWidgets/sources/pdfadvancedtools.h b/Pdf4QtLibWidgets/sources/pdfadvancedtools.h index 5e60824..828dbd5 100644 --- a/Pdf4QtLibWidgets/sources/pdfadvancedtools.h +++ b/Pdf4QtLibWidgets/sources/pdfadvancedtools.h @@ -29,7 +29,7 @@ namespace pdf /// Tool that creates 'sticky note' annotations. Multiple types of sticky /// notes are available, user can select a type of sticky note. When /// user select a point, popup window appears and user can enter a text. -class PDF4QTLIBSHARED_EXPORT PDFCreateStickyNoteTool : public PDFWidgetTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreateStickyNoteTool : public PDFWidgetTool { Q_OBJECT @@ -52,7 +52,7 @@ private: TextAnnotationIcon m_icon; }; -class PDF4QTLIBSHARED_EXPORT PDFCreateAnnotationTool : public PDFWidgetTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreateAnnotationTool : public PDFWidgetTool { Q_OBJECT @@ -69,7 +69,7 @@ protected: /// Tool that creates url link annotation. Multiple types of link highlights /// are available, user can select a link highlight. When link annotation /// is clicked, url address is triggered. -class PDF4QTLIBSHARED_EXPORT PDFCreateHyperlinkTool : public PDFCreateAnnotationTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreateHyperlinkTool : public PDFCreateAnnotationTool { Q_OBJECT @@ -91,7 +91,7 @@ private: }; /// Tool that creates free text note without callout line. -class PDF4QTLIBSHARED_EXPORT PDFCreateFreeTextTool : public PDFCreateAnnotationTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreateFreeTextTool : public PDFCreateAnnotationTool { Q_OBJECT @@ -109,7 +109,7 @@ private: }; /// Tool that creates line/polyline/polygon annotations. -class PDF4QTLIBSHARED_EXPORT PDFCreateLineTypeTool : public PDFCreateAnnotationTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreateLineTypeTool : public PDFCreateAnnotationTool { Q_OBJECT @@ -160,7 +160,7 @@ private: }; /// Tool that creates ellipse annotation. -class PDF4QTLIBSHARED_EXPORT PDFCreateEllipseTool : public PDFCreateAnnotationTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreateEllipseTool : public PDFCreateAnnotationTool { Q_OBJECT @@ -196,7 +196,7 @@ private: QColor m_fillColor; }; -class PDF4QTLIBSHARED_EXPORT PDFCreateFreehandCurveTool : public PDFCreateAnnotationTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreateFreehandCurveTool : public PDFCreateAnnotationTool { Q_OBJECT @@ -234,7 +234,7 @@ private: /// Tool that creates 'stamp' annotations. Multiple types of stamps /// are available, user can select a type of stamp (text). -class PDF4QTLIBSHARED_EXPORT PDFCreateStampTool : public PDFWidgetTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreateStampTool : public PDFWidgetTool { Q_OBJECT @@ -267,7 +267,7 @@ private: }; /// Tool for highlighting of text in document -class PDF4QTLIBSHARED_EXPORT PDFCreateHighlightTextTool : public PDFWidgetTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreateHighlightTextTool : public PDFWidgetTool { Q_OBJECT @@ -319,7 +319,7 @@ private: /// Tool that creates redaction annotation from rectangle. Rectangle is not /// selected from the text, it is just any rectangle. -class PDF4QTLIBSHARED_EXPORT PDFCreateRedactRectangleTool : public PDFCreateAnnotationTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreateRedactRectangleTool : public PDFCreateAnnotationTool { Q_OBJECT @@ -337,7 +337,7 @@ private: }; /// Tool for redaction of text in document. Creates redaction annotation from text selection. -class PDF4QTLIBSHARED_EXPORT PDFCreateRedactTextTool : public PDFWidgetTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreateRedactTextTool : public PDFWidgetTool { Q_OBJECT diff --git a/Pdf4QtLibWidgets/sources/pdfcertificatemanagerdialog.h b/Pdf4QtLibWidgets/sources/pdfcertificatemanagerdialog.h index 22059c2..e26c31b 100644 --- a/Pdf4QtLibWidgets/sources/pdfcertificatemanagerdialog.h +++ b/Pdf4QtLibWidgets/sources/pdfcertificatemanagerdialog.h @@ -33,7 +33,7 @@ class PDFCertificateManagerDialog; namespace pdf { -class PDF4QTLIBSHARED_EXPORT PDFCertificateManagerDialog : public QDialog +class PDF4QTLIBCORESHARED_EXPORT PDFCertificateManagerDialog : public QDialog { Q_OBJECT diff --git a/Pdf4QtLibWidgets/sources/pdfcreatecertificatedialog.h b/Pdf4QtLibWidgets/sources/pdfcreatecertificatedialog.h index ea244ef..05e7877 100644 --- a/Pdf4QtLibWidgets/sources/pdfcreatecertificatedialog.h +++ b/Pdf4QtLibWidgets/sources/pdfcreatecertificatedialog.h @@ -30,7 +30,7 @@ class PDFCreateCertificateDialog; namespace pdf { -class PDF4QTLIBSHARED_EXPORT PDFCreateCertificateDialog : public QDialog +class PDF4QTLIBCORESHARED_EXPORT PDFCreateCertificateDialog : public QDialog { Q_OBJECT diff --git a/Pdf4QtLibWidgets/sources/pdfdrawwidget.h b/Pdf4QtLibWidgets/sources/pdfdrawwidget.h index b567a47..4633781 100644 --- a/Pdf4QtLibWidgets/sources/pdfdrawwidget.h +++ b/Pdf4QtLibWidgets/sources/pdfdrawwidget.h @@ -54,7 +54,7 @@ public: virtual bool doEvent(QEvent* event) = 0; }; -class PDF4QTLIBSHARED_EXPORT PDFWidget : public QWidget +class PDF4QTLIBCORESHARED_EXPORT PDFWidget : public QWidget { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfitemmodels.cpp b/Pdf4QtLibWidgets/sources/pdfitemmodels.cpp similarity index 100% rename from Pdf4QtLibCore/sources/pdfitemmodels.cpp rename to Pdf4QtLibWidgets/sources/pdfitemmodels.cpp diff --git a/Pdf4QtLibCore/sources/pdfitemmodels.h b/Pdf4QtLibWidgets/sources/pdfitemmodels.h similarity index 95% rename from Pdf4QtLibCore/sources/pdfitemmodels.h rename to Pdf4QtLibWidgets/sources/pdfitemmodels.h index 033a2b9..82c55bd 100644 --- a/Pdf4QtLibCore/sources/pdfitemmodels.h +++ b/Pdf4QtLibWidgets/sources/pdfitemmodels.h @@ -39,7 +39,7 @@ class PDFDrawWidgetProxy; class PDFDestination; /// Represents tree item in the GUI tree -class PDF4QTLIBSHARED_EXPORT PDFTreeItem +class PDF4QTLIBCORESHARED_EXPORT PDFTreeItem { public: inline explicit PDFTreeItem() = default; @@ -89,7 +89,7 @@ private: /// Root of all tree item models. Reimplementations of this model /// must handle "soft" document updates, such as only annotations changed etc. /// Model should be rebuilded only, if it is neccessary. -class PDF4QTLIBSHARED_EXPORT PDFTreeItemModel : public QAbstractItemModel +class PDF4QTLIBCORESHARED_EXPORT PDFTreeItemModel : public QAbstractItemModel { public: explicit PDFTreeItemModel(QObject* parent); @@ -132,7 +132,7 @@ private: bool m_locked; ///< Node is locked (user can't change it) }; -class PDF4QTLIBSHARED_EXPORT PDFOptionalContentTreeItemModel : public PDFTreeItemModel +class PDF4QTLIBCORESHARED_EXPORT PDFOptionalContentTreeItemModel : public PDFTreeItemModel { Q_OBJECT public: @@ -167,7 +167,7 @@ private: QSharedPointer m_outlineItem; }; -class PDF4QTLIBSHARED_EXPORT PDFOutlineTreeItemModel : public PDFTreeItemModel +class PDF4QTLIBCORESHARED_EXPORT PDFOutlineTreeItemModel : public PDFTreeItemModel { Q_OBJECT public: @@ -221,7 +221,7 @@ private: mutable QSharedPointer m_dragDropItem; }; -class PDF4QTLIBSHARED_EXPORT PDFSelectableOutlineTreeItemModel : public PDFOutlineTreeItemModel +class PDF4QTLIBCORESHARED_EXPORT PDFSelectableOutlineTreeItemModel : public PDFOutlineTreeItemModel { Q_OBJECT @@ -264,7 +264,7 @@ private: std::unique_ptr m_fileSpecification; }; -class PDF4QTLIBSHARED_EXPORT PDFAttachmentsTreeItemModel : public PDFTreeItemModel +class PDF4QTLIBCORESHARED_EXPORT PDFAttachmentsTreeItemModel : public PDFTreeItemModel { Q_OBJECT public: @@ -289,7 +289,7 @@ public: const PDFFileSpecification* getFileSpecification(const QModelIndex& index) const; }; -class PDF4QTLIBSHARED_EXPORT PDFThumbnailsItemModel : public QAbstractItemModel +class PDF4QTLIBCORESHARED_EXPORT PDFThumbnailsItemModel : public QAbstractItemModel { Q_OBJECT diff --git a/Pdf4QtLibWidgets/sources/pdfpagecontenteditorstylesettings.h b/Pdf4QtLibWidgets/sources/pdfpagecontenteditorstylesettings.h index 04b0a61..a031e50 100644 --- a/Pdf4QtLibWidgets/sources/pdfpagecontenteditorstylesettings.h +++ b/Pdf4QtLibWidgets/sources/pdfpagecontenteditorstylesettings.h @@ -38,7 +38,7 @@ namespace pdf { class PDFPageContentElement; -class PDF4QTLIBSHARED_EXPORT PDFPageContentEditorStyleSettings : public QWidget +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentEditorStyleSettings : public QWidget { Q_OBJECT diff --git a/Pdf4QtLibWidgets/sources/pdfpagecontenteditortools.h b/Pdf4QtLibWidgets/sources/pdfpagecontenteditortools.h index e757d5f..2189c49 100644 --- a/Pdf4QtLibWidgets/sources/pdfpagecontenteditortools.h +++ b/Pdf4QtLibWidgets/sources/pdfpagecontenteditortools.h @@ -33,7 +33,7 @@ class PDFPageContentElementRectangle; class PDFPageContentElementFreehandCurve; class PDFTextEditPseudowidget; -class PDF4QTLIBSHARED_EXPORT PDFCreatePCElementTool : public PDFWidgetTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreatePCElementTool : public PDFWidgetTool { Q_OBJECT public: @@ -58,7 +58,7 @@ protected: }; /// Tool that creates rectangle element. -class PDF4QTLIBSHARED_EXPORT PDFCreatePCElementRectangleTool : public PDFCreatePCElementTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreatePCElementRectangleTool : public PDFCreatePCElementTool { Q_OBJECT @@ -91,7 +91,7 @@ private: }; /// Tool that displays SVG image (or raster image) -class PDF4QTLIBSHARED_EXPORT PDFCreatePCElementImageTool : public PDFCreatePCElementTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreatePCElementImageTool : public PDFCreatePCElementTool { Q_OBJECT @@ -131,7 +131,7 @@ private: }; /// Tool that creates line element. -class PDF4QTLIBSHARED_EXPORT PDFCreatePCElementLineTool : public PDFCreatePCElementTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreatePCElementLineTool : public PDFCreatePCElementTool { Q_OBJECT @@ -167,7 +167,7 @@ private: }; /// Tool that creates dot element. -class PDF4QTLIBSHARED_EXPORT PDFCreatePCElementDotTool : public PDFCreatePCElementTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreatePCElementDotTool : public PDFCreatePCElementTool { Q_OBJECT @@ -199,7 +199,7 @@ private: }; /// Tool that creates freehand curve element. -class PDF4QTLIBSHARED_EXPORT PDFCreatePCElementFreehandCurveTool : public PDFCreatePCElementTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreatePCElementFreehandCurveTool : public PDFCreatePCElementTool { Q_OBJECT @@ -237,7 +237,7 @@ private: }; /// Tool that displays SVG image -class PDF4QTLIBSHARED_EXPORT PDFCreatePCElementTextTool : public PDFCreatePCElementTool +class PDF4QTLIBCORESHARED_EXPORT PDFCreatePCElementTextTool : public PDFCreatePCElementTool { Q_OBJECT diff --git a/Pdf4QtLibWidgets/sources/pdfpagecontenteditorwidget.h b/Pdf4QtLibWidgets/sources/pdfpagecontenteditorwidget.h index 7c9d9cd..b3ad7ae 100644 --- a/Pdf4QtLibWidgets/sources/pdfpagecontenteditorwidget.h +++ b/Pdf4QtLibWidgets/sources/pdfpagecontenteditorwidget.h @@ -38,7 +38,7 @@ class PDFPageContentScene; class PDFPageContentElement; class PDFPageContentEditorStyleSettings; -class PDF4QTLIBSHARED_EXPORT PDFPageContentEditorWidget : public QDockWidget +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentEditorWidget : public QDockWidget { Q_OBJECT diff --git a/Pdf4QtLibCore/sources/pdfpagecontentelements.cpp b/Pdf4QtLibWidgets/sources/pdfpagecontentelements.cpp similarity index 100% rename from Pdf4QtLibCore/sources/pdfpagecontentelements.cpp rename to Pdf4QtLibWidgets/sources/pdfpagecontentelements.cpp diff --git a/Pdf4QtLibCore/sources/pdfpagecontentelements.h b/Pdf4QtLibWidgets/sources/pdfpagecontentelements.h similarity index 96% rename from Pdf4QtLibCore/sources/pdfpagecontentelements.h rename to Pdf4QtLibWidgets/sources/pdfpagecontentelements.h index e39867a..b4d0dc9 100644 --- a/Pdf4QtLibCore/sources/pdfpagecontentelements.h +++ b/Pdf4QtLibWidgets/sources/pdfpagecontentelements.h @@ -36,7 +36,7 @@ class PDFWidget; class PDFDocument; class PDFPageContentScene; -class PDF4QTLIBSHARED_EXPORT PDFPageContentElement +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentElement { public: explicit PDFPageContentElement() = default; @@ -117,7 +117,7 @@ protected: PDFInteger m_pageIndex = -1; }; -class PDF4QTLIBSHARED_EXPORT PDFPageContentStyledElement : public PDFPageContentElement +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentStyledElement : public PDFPageContentElement { public: explicit PDFPageContentStyledElement() = default; @@ -134,7 +134,7 @@ protected: QBrush m_brush; }; -class PDF4QTLIBSHARED_EXPORT PDFPageContentElementRectangle : public PDFPageContentStyledElement +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentElementRectangle : public PDFPageContentStyledElement { public: virtual ~PDFPageContentElementRectangle() = default; @@ -167,7 +167,7 @@ private: QRectF m_rectangle; }; -class PDF4QTLIBSHARED_EXPORT PDFPageContentElementLine : public PDFPageContentStyledElement +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentElementLine : public PDFPageContentStyledElement { public: virtual ~PDFPageContentElementLine() = default; @@ -207,7 +207,7 @@ private: QLineF m_line; }; -class PDF4QTLIBSHARED_EXPORT PDFPageContentElementDot : public PDFPageContentStyledElement +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentElementDot : public PDFPageContentStyledElement { public: virtual ~PDFPageContentElementDot() = default; @@ -236,7 +236,7 @@ private: QPointF m_point; }; -class PDF4QTLIBSHARED_EXPORT PDFPageContentElementFreehandCurve : public PDFPageContentStyledElement +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentElementFreehandCurve : public PDFPageContentStyledElement { public: virtual ~PDFPageContentElementFreehandCurve() = default; @@ -270,7 +270,7 @@ private: QPainterPath m_curve; }; -class PDF4QTLIBSHARED_EXPORT PDFPageContentImageElement : public PDFPageContentElement +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentImageElement : public PDFPageContentElement { public: PDFPageContentImageElement(); @@ -306,7 +306,7 @@ private: std::unique_ptr m_renderer; }; -class PDF4QTLIBSHARED_EXPORT PDFPageContentElementTextBox : public PDFPageContentStyledElement +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentElementTextBox : public PDFPageContentStyledElement { public: virtual ~PDFPageContentElementTextBox() = default; @@ -351,7 +351,7 @@ private: Qt::Alignment m_alignment = Qt::AlignCenter; }; -class PDF4QTLIBSHARED_EXPORT PDFPageContentElementManipulator : public QObject +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentElementManipulator : public QObject { Q_OBJECT @@ -463,7 +463,7 @@ private: QPointF m_lastUpdatedPoint; }; -class PDF4QTLIBSHARED_EXPORT PDFPageContentScene : public QObject, +class PDF4QTLIBCORESHARED_EXPORT PDFPageContentScene : public QObject, public IDocumentDrawInterface, public IDrawWidgetInputInterface { diff --git a/Pdf4QtLibWidgets/sources/pdfrenderingerrorswidget.h b/Pdf4QtLibWidgets/sources/pdfrenderingerrorswidget.h index 5df5b78..20053d7 100644 --- a/Pdf4QtLibWidgets/sources/pdfrenderingerrorswidget.h +++ b/Pdf4QtLibWidgets/sources/pdfrenderingerrorswidget.h @@ -31,7 +31,7 @@ namespace pdf { class PDFWidget; -class PDF4QTLIBSHARED_EXPORT PDFRenderingErrorsWidget : public QDialog +class PDF4QTLIBWIDGETSSHARED_EXPORT PDFRenderingErrorsWidget : public QDialog { Q_OBJECT diff --git a/Pdf4QtLibWidgets/sources/pdfselectpagesdialog.h b/Pdf4QtLibWidgets/sources/pdfselectpagesdialog.h index 2cb0490..6218a93 100644 --- a/Pdf4QtLibWidgets/sources/pdfselectpagesdialog.h +++ b/Pdf4QtLibWidgets/sources/pdfselectpagesdialog.h @@ -30,7 +30,7 @@ class PDFSelectPagesDialog; namespace pdf { -class PDF4QTLIBSHARED_EXPORT PDFSelectPagesDialog : public QDialog +class PDF4QTLIBWIDGETSSHARED_EXPORT PDFSelectPagesDialog : public QDialog { Q_OBJECT diff --git a/Pdf4QtLibWidgets/sources/pdfwidgetannotation.cpp b/Pdf4QtLibWidgets/sources/pdfwidgetannotation.cpp new file mode 100644 index 0000000..0792b5c --- /dev/null +++ b/Pdf4QtLibWidgets/sources/pdfwidgetannotation.cpp @@ -0,0 +1,513 @@ +// Copyright (C) 2023 Jakub Melka +// +// This file is part of PDF4QT. +// +// PDF4QT is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// with the written consent of the copyright owner, any later version. +// +// PDF4QT is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with PDF4QT. If not, see . + +#include "pdfdrawwidget.h" +#include "pdfwidgetutils.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace pdf +{ + +PDFWidgetAnnotationManager::PDFWidgetAnnotationManager(PDFDrawWidgetProxy* proxy, QObject* parent) : + BaseClass(proxy->getFontCache(), proxy->getCMSManager(), proxy->getOptionalContentActivity(), proxy->getMeshQualitySettings(), proxy->getFeatures(), Target::View, parent), + m_proxy(proxy) +{ + Q_ASSERT(proxy); + m_proxy->registerDrawInterface(this); +} + +PDFWidgetAnnotationManager::~PDFWidgetAnnotationManager() +{ + m_proxy->unregisterDrawInterface(this); +} + +void PDFWidgetAnnotationManager::setDocument(const PDFModifiedDocument& document) +{ + BaseClass::setDocument(document); + + if (document.hasReset() || document.getFlags().testFlag(PDFModifiedDocument::Annotation)) + { + m_editableAnnotation = PDFObjectReference(); + m_editableAnnotationPage = PDFObjectReference(); + } +} + +void PDFWidgetAnnotationManager::shortcutOverrideEvent(QWidget* widget, QKeyEvent* event) +{ + Q_UNUSED(widget); + Q_UNUSED(event); +} + +void PDFWidgetAnnotationManager::keyPressEvent(QWidget* widget, QKeyEvent* event) +{ + Q_UNUSED(widget); + Q_UNUSED(event); +} + +void PDFWidgetAnnotationManager::keyReleaseEvent(QWidget* widget, QKeyEvent* event) +{ + Q_UNUSED(widget); + Q_UNUSED(event); +} + +void PDFWidgetAnnotationManager::mousePressEvent(QWidget* widget, QMouseEvent* event) +{ + Q_UNUSED(widget); + + updateFromMouseEvent(event); + + // Show context menu? + if (event->button() == Qt::RightButton) + { + PDFWidget* pdfWidget = m_proxy->getWidget(); + std::vector currentPages = pdfWidget->getDrawWidget()->getCurrentPages(); + + if (!hasAnyPageAnnotation(currentPages)) + { + // All pages doesn't have annotation + return; + } + + m_editableAnnotation = PDFObjectReference(); + m_editableAnnotationPage = PDFObjectReference(); + for (PDFInteger pageIndex : currentPages) + { + PageAnnotations& pageAnnotations = getPageAnnotations(pageIndex); + for (PageAnnotation& pageAnnotation : pageAnnotations.annotations) + { + if (!pageAnnotation.isHovered) + { + continue; + } + + if (!PDFAnnotation::isTypeEditable(pageAnnotation.annotation->getType())) + { + continue; + } + + m_editableAnnotation = pageAnnotation.annotation->getSelfReference(); + m_editableAnnotationPage = pageAnnotation.annotation->getPageReference(); + + if (!m_editableAnnotationPage.isValid()) + { + m_editableAnnotationPage = m_document->getCatalog()->getPage(pageIndex)->getPageReference(); + } + break; + } + } + + if (m_editableAnnotation.isValid()) + { + QMenu menu(tr("Annotation"), pdfWidget); + QAction* showPopupAction = menu.addAction(tr("Show Popup Window")); + QAction* copyAction = menu.addAction(tr("Copy to Multiple Pages")); + QAction* editAction = menu.addAction(tr("Edit")); + QAction* deleteAction = menu.addAction(tr("Delete")); + connect(showPopupAction, &QAction::triggered, this, &PDFWidgetAnnotationManager::onShowPopupAnnotation); + connect(copyAction, &QAction::triggered, this, &PDFWidgetAnnotationManager::onCopyAnnotation); + connect(editAction, &QAction::triggered, this, &PDFWidgetAnnotationManager::onEditAnnotation); + connect(deleteAction, &QAction::triggered, this, &PDFWidgetAnnotationManager::onDeleteAnnotation); + + m_editableAnnotationGlobalPosition = pdfWidget->mapToGlobal(event->pos()); + menu.exec(m_editableAnnotationGlobalPosition); + } + } +} + +void PDFWidgetAnnotationManager::mouseDoubleClickEvent(QWidget* widget, QMouseEvent* event) +{ + Q_UNUSED(widget); + Q_UNUSED(event); +} + +void PDFWidgetAnnotationManager::mouseReleaseEvent(QWidget* widget, QMouseEvent* event) +{ + Q_UNUSED(widget); + + updateFromMouseEvent(event); +} + +void PDFWidgetAnnotationManager::mouseMoveEvent(QWidget* widget, QMouseEvent* event) +{ + Q_UNUSED(widget); + + updateFromMouseEvent(event); +} + +void PDFWidgetAnnotationManager::wheelEvent(QWidget* widget, QWheelEvent* event) +{ + Q_UNUSED(widget); + Q_UNUSED(event); +} + +void PDFWidgetAnnotationManager::updateFromMouseEvent(QMouseEvent* event) +{ + PDFWidget* widget = m_proxy->getWidget(); + std::vector currentPages = widget->getDrawWidget()->getCurrentPages(); + + if (!hasAnyPageAnnotation(currentPages)) + { + // All pages doesn't have annotation + return; + } + + m_tooltip = QString(); + m_cursor = std::nullopt; + bool appearanceChanged = false; + + // We must update appearance states, and update tooltip + PDFWidgetSnapshot snapshot = m_proxy->getSnapshot(); + const bool isDown = event->buttons().testFlag(Qt::LeftButton); + const PDFAppeareanceStreams::Appearance hoverAppearance = isDown ? PDFAppeareanceStreams::Appearance::Down : PDFAppeareanceStreams::Appearance::Rollover; + + for (const PDFWidgetSnapshot::SnapshotItem& snapshotItem : snapshot.items) + { + PageAnnotations& pageAnnotations = getPageAnnotations(snapshotItem.pageIndex); + for (PageAnnotation& pageAnnotation : pageAnnotations.annotations) + { + if (pageAnnotation.annotation->isReplyTo()) + { + // Annotation is reply to another annotation, do not interact with it + continue; + } + + const PDFAppeareanceStreams::Appearance oldAppearance = pageAnnotation.appearance; + QRectF annotationRect = pageAnnotation.annotation->getRectangle(); + QTransform matrix = prepareTransformations(snapshotItem.pageToDeviceMatrix, widget, pageAnnotation.annotation->getEffectiveFlags(), m_document->getCatalog()->getPage(snapshotItem.pageIndex), annotationRect); + QPainterPath path; + path.addRect(annotationRect); + path = matrix.map(path); + + if (path.contains(event->pos())) + { + pageAnnotation.appearance = hoverAppearance; + pageAnnotation.isHovered = true; + + // Generate tooltip + if (m_tooltip.isEmpty()) + { + const PDFMarkupAnnotation* markupAnnotation = pageAnnotation.annotation->asMarkupAnnotation(); + if (markupAnnotation) + { + QString title = markupAnnotation->getWindowTitle(); + if (title.isEmpty()) + { + title = markupAnnotation->getSubject(); + } + if (title.isEmpty()) + { + title = PDFTranslationContext::tr("Info"); + } + + const size_t repliesCount = pageAnnotations.getReplies(pageAnnotation).size(); + if (repliesCount > 0) + { + title = PDFTranslationContext::tr("%1 (%2 replies)").arg(title).arg(repliesCount); + } + + m_tooltip = QString("

%1

%2

").arg(title, markupAnnotation->getContents()); + } + } + + const PDFAction* linkAction = nullptr; + const AnnotationType annotationType = pageAnnotation.annotation->getType(); + if (annotationType == AnnotationType::Link) + { + const PDFLinkAnnotation* linkAnnotation = dynamic_cast(pageAnnotation.annotation.data()); + Q_ASSERT(linkAnnotation); + + // We must check, if user clicked to the link area + QPainterPath activationPath = linkAnnotation->getActivationRegion().getPath(); + activationPath = snapshotItem.pageToDeviceMatrix.map(activationPath); + if (activationPath.contains(event->pos()) && linkAnnotation->getAction()) + { + m_cursor = QCursor(Qt::PointingHandCursor); + linkAction = linkAnnotation->getAction(); + } + } + if (annotationType == AnnotationType::Widget) + { + if (m_formManager && m_formManager->hasFormFieldWidgetText(pageAnnotation.annotation->getSelfReference())) + { + m_cursor = QCursor(Qt::IBeamCursor); + } + else + { + m_cursor = QCursor(Qt::ArrowCursor); + } + } + + // Generate popup window + if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::LeftButton) + { + const PDFMarkupAnnotation* markupAnnotation = pageAnnotation.annotation->asMarkupAnnotation(); + if (markupAnnotation) + { + QDialog* dialog = createDialogForMarkupAnnotations(widget, pageAnnotation, pageAnnotations); + + // Set proper dialog position - according to the popup annotation. If we + // do not have popup annotation, then try to use annotations rectangle. + if (const PageAnnotation* popupAnnotation = pageAnnotations.getPopupAnnotation(pageAnnotation)) + { + QPoint popupPoint = snapshotItem.pageToDeviceMatrix.map(popupAnnotation->annotation->getRectangle().bottomLeft()).toPoint(); + popupPoint = widget->mapToGlobal(popupPoint); + dialog->move(popupPoint); + } + else if (markupAnnotation->getRectangle().isValid()) + { + QPoint popupPoint = snapshotItem.pageToDeviceMatrix.map(markupAnnotation->getRectangle().bottomRight()).toPoint(); + popupPoint = widget->mapToGlobal(popupPoint); + dialog->move(popupPoint); + } + + dialog->exec(); + } + + if (linkAction) + { + Q_EMIT actionTriggered(linkAction); + } + } + } + else + { + pageAnnotation.appearance = PDFAppeareanceStreams::Appearance::Normal; + pageAnnotation.isHovered = false; + } + + const bool currentAppearanceChanged = oldAppearance != pageAnnotation.appearance; + if (currentAppearanceChanged) + { + // We have changed appearance - we must mark stream as dirty + pageAnnotation.appearanceStream.dirty(); + appearanceChanged = true; + } + } + } + + // If appearance has changed, then we must redraw the page + if (appearanceChanged) + { + Q_EMIT widget->getDrawWidgetProxy()->repaintNeeded(); + } +} + +void PDFWidgetAnnotationManager::onShowPopupAnnotation() +{ + PDFWidgetSnapshot snapshot = m_proxy->getSnapshot(); + for (const PDFWidgetSnapshot::SnapshotItem& snapshotItem : snapshot.items) + { + PageAnnotations& pageAnnotations = getPageAnnotations(snapshotItem.pageIndex); + for (PageAnnotation& pageAnnotation : pageAnnotations.annotations) + { + if (pageAnnotation.annotation->isReplyTo()) + { + // Annotation is reply to another annotation, do not interact with it + continue; + } + + if (pageAnnotation.annotation->getSelfReference() == m_editableAnnotation) + { + QDialog* dialog = createDialogForMarkupAnnotations(m_proxy->getWidget(), pageAnnotation, pageAnnotations); + dialog->move(m_editableAnnotationGlobalPosition); + dialog->exec(); + return; + } + } + } +} + +void PDFWidgetAnnotationManager::onCopyAnnotation() +{ + pdf::PDFSelectPagesDialog dialog(tr("Copy Annotation"), tr("Copy Annotation onto Multiple Pages"), + m_document->getCatalog()->getPageCount(), m_proxy->getWidget()->getDrawWidget()->getCurrentPages(), m_proxy->getWidget()); + if (dialog.exec() == QDialog::Accepted) + { + std::vector pages = dialog.getSelectedPages(); + const PDFInteger currentPageIndex = m_document->getCatalog()->getPageIndexFromPageReference(m_editableAnnotationPage); + + for (PDFInteger& pageIndex : pages) + { + --pageIndex; + } + + auto it = std::find(pages.begin(), pages.end(), currentPageIndex); + if (it != pages.end()) + { + pages.erase(it); + } + + if (pages.empty()) + { + return; + } + + PDFDocumentModifier modifier(m_document); + modifier.markAnnotationsChanged(); + + for (const PDFInteger pageIndex : pages) + { + modifier.getBuilder()->copyAnnotation(m_document->getCatalog()->getPage(pageIndex)->getPageReference(), m_editableAnnotation); + } + + if (modifier.finalize()) + { + Q_EMIT documentModified(PDFModifiedDocument(modifier.getDocument(), nullptr, modifier.getFlags())); + } + } +} + +void PDFWidgetAnnotationManager::onEditAnnotation() +{ + PDFEditObjectDialog dialog(EditObjectType::Annotation, m_proxy->getWidget()); + + PDFObject originalObject = m_document->getObjectByReference(m_editableAnnotation); + dialog.setObject(originalObject); + + if (dialog.exec() == PDFEditObjectDialog::Accepted) + { + PDFObject object = dialog.getObject(); + if (object != originalObject) + { + PDFDocumentModifier modifier(m_document); + modifier.markAnnotationsChanged(); + modifier.getBuilder()->setObject(m_editableAnnotation, object); + modifier.getBuilder()->updateAnnotationAppearanceStreams(m_editableAnnotation); + + if (modifier.finalize()) + { + Q_EMIT documentModified(PDFModifiedDocument(modifier.getDocument(), nullptr, modifier.getFlags())); + } + } + } +} + +void PDFWidgetAnnotationManager::onDeleteAnnotation() +{ + if (m_editableAnnotation.isValid()) + { + PDFDocumentModifier modifier(m_document); + modifier.markAnnotationsChanged(); + modifier.getBuilder()->removeAnnotation(m_editableAnnotationPage, m_editableAnnotation); + + if (modifier.finalize()) + { + Q_EMIT documentModified(PDFModifiedDocument(modifier.getDocument(), nullptr, modifier.getFlags())); + } + } +} + +QDialog* PDFWidgetAnnotationManager::createDialogForMarkupAnnotations(PDFWidget* widget, + const PageAnnotation& pageAnnotation, + const PageAnnotations& pageAnnotations) +{ + QDialog* dialog = new QDialog(widget->getDrawWidget()->getWidget(), Qt::Popup); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + createWidgetsForMarkupAnnotations(dialog, pageAnnotation, pageAnnotations); + return dialog; +} + +void PDFWidgetAnnotationManager::createWidgetsForMarkupAnnotations(QWidget* parentWidget, + const PageAnnotation& pageAnnotation, + const PageAnnotations& pageAnnotations) +{ + std::vector replies = pageAnnotations.getReplies(pageAnnotation); + replies.insert(replies.begin(), &pageAnnotation); + + QScrollArea* scrollArea = new QScrollArea(parentWidget); + scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + + QVBoxLayout* layout = new QVBoxLayout(parentWidget); + layout->addWidget(scrollArea); + layout->setContentsMargins(QMargins()); + + QWidget* frameWidget = new QWidget(scrollArea); + QVBoxLayout* frameLayout = new QVBoxLayout(frameWidget); + frameLayout->setSpacing(0); + scrollArea->setWidget(frameWidget); + + const PDFMarkupAnnotation* markupMainAnnotation = pageAnnotation.annotation->asMarkupAnnotation(); + QColor color = markupMainAnnotation->getDrawColorFromAnnotationColor(markupMainAnnotation->getColor(), 1.0); + QColor titleColor = QColor::fromHslF(color.hueF(), color.saturationF(), 0.2f, 1.0f); + QColor backgroundColor = QColor::fromHslF(color.hueF(), color.saturationF(), 0.9f, 1.0f); + + QString style = "QGroupBox { " + "border: 2px solid black; " + "border-color: rgb(%4, %5, %6); " + "margin-top: 3ex; " + "background-color: rgb(%1, %2, %3); " + "}" + "QGroupBox::title { " + "subcontrol-origin: margin; " + "subcontrol-position: top center; " + "padding: 0px 8192px; " + "background-color: rgb(%4, %5, %6); " + "color: #FFFFFF;" + "}"; + style = style.arg(backgroundColor.red()).arg(backgroundColor.green()).arg(backgroundColor.blue()).arg(titleColor.red()).arg(titleColor.green()).arg(titleColor.blue()); + + for (const PageAnnotation* annotation : replies) + { + const PDFMarkupAnnotation* markupAnnotation = annotation->annotation->asMarkupAnnotation(); + + if (!markupAnnotation) + { + // This should not happen... + continue; + } + + QGroupBox* groupBox = new QGroupBox(scrollArea); + frameLayout->addWidget(groupBox); + + QString title = markupAnnotation->getWindowTitle(); + if (title.isEmpty()) + { + title = markupAnnotation->getSubject(); + } + + QString dateTimeString = QLocale::system().toString(markupAnnotation->getCreationDate().toLocalTime(), QLocale::LongFormat); + title = QString("%1 (%2)").arg(title, dateTimeString).trimmed(); + + groupBox->setStyleSheet(style); + groupBox->setTitle(title); + QVBoxLayout* groupBoxLayout = new QVBoxLayout(groupBox); + + QLabel* label = new QLabel(groupBox); + label->setTextInteractionFlags(Qt::TextBrowserInteraction); + label->setWordWrap(true); + label->setText(markupAnnotation->getContents()); + label->setFixedWidth(PDFWidgetUtils::scaleDPI_x(label, 250)); + label->setMinimumHeight(label->sizeHint().height()); + groupBoxLayout->addWidget(label); + } + + frameWidget->setFixedSize(frameWidget->minimumSizeHint()); + parentWidget->setFixedSize(scrollArea->sizeHint()); +} + +} // namespace pdf diff --git a/Pdf4QtLibWidgets/sources/pdfwidgetannotation.h b/Pdf4QtLibWidgets/sources/pdfwidgetannotation.h new file mode 100644 index 0000000..af971e17 --- /dev/null +++ b/Pdf4QtLibWidgets/sources/pdfwidgetannotation.h @@ -0,0 +1,95 @@ +// Copyright (C) 2023 Jakub Melka +// +// This file is part of PDF4QT. +// +// PDF4QT is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// with the written consent of the copyright owner, any later version. +// +// PDF4QT is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with PDF4QT. If not, see . + +#include "pdfannotation.h" + +namespace pdf +{ + +class PDFDrawWidgetProxy; + +/// Annotation manager for GUI rendering, it also manages annotations widgets +/// for parent widget. +class PDF4QTLIBWIDGETSSHARED_EXPORT PDFWidgetAnnotationManager : public PDFAnnotationManager, public IDrawWidgetInputInterface +{ + Q_OBJECT + +private: + using BaseClass = PDFAnnotationManager; + +public: + explicit PDFWidgetAnnotationManager(PDFDrawWidgetProxy* proxy, QObject* parent); + virtual ~PDFWidgetAnnotationManager() override; + + virtual void setDocument(const PDFModifiedDocument& document) override; + + virtual void shortcutOverrideEvent(QWidget* widget, QKeyEvent* event) override; + virtual void keyPressEvent(QWidget* widget, QKeyEvent* event) override; + virtual void keyReleaseEvent(QWidget* widget, QKeyEvent* event) override; + virtual void mousePressEvent(QWidget* widget, QMouseEvent* event) override; + virtual void mouseDoubleClickEvent(QWidget* widget, QMouseEvent* event) override; + virtual void mouseReleaseEvent(QWidget* widget, QMouseEvent* event) override; + virtual void mouseMoveEvent(QWidget* widget, QMouseEvent* event) override; + virtual void wheelEvent(QWidget* widget, QWheelEvent* event) override; + + /// Returns tooltip generated from annotation + virtual QString getTooltip() const override { return m_tooltip; } + + /// Returns current cursor + virtual const std::optional& getCursor() const override { return m_cursor; } + + virtual int getInputPriority() const override { return AnnotationPriority; } + +signals: + void actionTriggered(const PDFAction* action); + void documentModified(PDFModifiedDocument document); + +private: + void updateFromMouseEvent(QMouseEvent* event); + + void onShowPopupAnnotation(); + void onCopyAnnotation(); + void onEditAnnotation(); + void onDeleteAnnotation(); + + /// Creates dialog for markup annotations. This function is used only for markup annotations, + /// do not use them for other annotations (function can crash). + /// \param widget Dialog's parent widget + /// \param pageAnnotation Markup annotation + /// \param pageAnnotations Page annotations + QDialog* createDialogForMarkupAnnotations(PDFWidget* widget, + const PageAnnotation& pageAnnotation, + const PageAnnotations& pageAnnotations); + + /// Creates widgets for markup annotation main popup widget. Also sets + /// default size of parent widget. + /// \param parentWidget Parent widget, where widgets are created + /// \param pageAnnotation Markup annotation + /// \param pageAnnotations Page annotations + void createWidgetsForMarkupAnnotations(QWidget* parentWidget, + const PageAnnotation& pageAnnotation, + const PageAnnotations& pageAnnotations); + + PDFDrawWidgetProxy* m_proxy; + QString m_tooltip; + std::optional m_cursor; + QPoint m_editableAnnotationGlobalPosition; ///< Position, where action on annotation was executed + PDFObjectReference m_editableAnnotation; ///< Annotation to be edited or deleted + PDFObjectReference m_editableAnnotationPage; ///< Page of annotation above +}; + +} // namespace pdf diff --git a/Pdf4QtLibWidgets/sources/pdfwidgettool.h b/Pdf4QtLibWidgets/sources/pdfwidgettool.h index bcc4d1d..e8226f3 100644 --- a/Pdf4QtLibWidgets/sources/pdfwidgettool.h +++ b/Pdf4QtLibWidgets/sources/pdfwidgettool.h @@ -34,7 +34,7 @@ namespace pdf /// Base class for various widget tools (for example, searching, text selection, /// screenshots, zoom tool etc.). Each tool can have subtools (for example, /// screenshot tool is picking screenshot rectangle). -class PDF4QTLIBSHARED_EXPORT PDFWidgetTool : public QObject, public IDocumentDrawInterface +class PDF4QTLIBWIDGETSSHARED_EXPORT PDFWidgetTool : public QObject, public IDocumentDrawInterface { Q_OBJECT @@ -273,7 +273,7 @@ private: }; /// Tool to magnify specific area in the drawing widget -class PDF4QTLIBSHARED_EXPORT PDFMagnifierTool : public PDFWidgetTool +class PDF4QTLIBWIDGETSSHARED_EXPORT PDFMagnifierTool : public PDFWidgetTool { Q_OBJECT @@ -308,7 +308,7 @@ private: }; /// Tools for picking various items on page - points, rectangles, images etc. -class PDF4QTLIBSHARED_EXPORT PDFPickTool : public PDFWidgetTool +class PDF4QTLIBWIDGETSSHARED_EXPORT PDFPickTool : public PDFWidgetTool { Q_OBJECT @@ -433,7 +433,7 @@ private: /// Tool that makes screenshot of page area and copies it to the clipboard, /// using current client area to determine image size. -class PDF4QTLIBSHARED_EXPORT PDFScreenshotTool : public PDFWidgetTool +class PDF4QTLIBWIDGETSSHARED_EXPORT PDFScreenshotTool : public PDFWidgetTool { Q_OBJECT @@ -455,7 +455,7 @@ private: /// Tool that extracts image from page and copies it to the clipboard, /// using image original size (not zoomed size from widget area) -class PDF4QTLIBSHARED_EXPORT PDFExtractImageTool : public PDFWidgetTool +class PDF4QTLIBWIDGETSSHARED_EXPORT PDFExtractImageTool : public PDFWidgetTool { Q_OBJECT @@ -481,7 +481,7 @@ private: /// Manager used for managing tools, their activity, availability /// and other settings. It also defines a predefined set of tools, /// available for various purposes (text searching, magnifier tool etc.) -class PDF4QTLIBSHARED_EXPORT PDFToolManager : public QObject, public IDrawWidgetInputInterface +class PDF4QTLIBWIDGETSSHARED_EXPORT PDFToolManager : public QObject, public IDrawWidgetInputInterface { Q_OBJECT diff --git a/Pdf4QtLibWidgets/sources/pdfwidgetutils.h b/Pdf4QtLibWidgets/sources/pdfwidgetutils.h index 56d6a74..54e069c 100644 --- a/Pdf4QtLibWidgets/sources/pdfwidgetutils.h +++ b/Pdf4QtLibWidgets/sources/pdfwidgetutils.h @@ -26,7 +26,7 @@ namespace pdf { -class PDF4QTLIBSHARED_EXPORT PDFWidgetUtils +class PDF4QTLIBWIDGETSSHARED_EXPORT PDFWidgetUtils { public: PDFWidgetUtils() = delete;