Issue #118: Fixing compilation errors

This commit is contained in:
Jakub Melka 2023-12-08 10:54:29 +01:00
parent cdbbe5e121
commit 642e6a9bb7
19 changed files with 123 additions and 56 deletions

View File

@ -426,7 +426,7 @@ private:
};
/// Annotation default appearance
class PDFAnnotationDefaultAppearance
class PDF4QTLIBCORESHARED_EXPORT PDFAnnotationDefaultAppearance
{
public:
explicit inline PDFAnnotationDefaultAppearance() = default;
@ -482,7 +482,7 @@ struct AnnotationDrawParameters
/// Annotations are various enhancements to pages graphical representation,
/// such as graphics, text, highlight or multimedia content, such as sounds,
/// videos and 3D annotations.
class PDFAnnotation
class PDF4QTLIBCORESHARED_EXPORT PDFAnnotation
{
public:
explicit PDFAnnotation();
@ -1497,7 +1497,7 @@ public:
mutable PDFCachedItem<PDFObject> appearanceStream;
};
struct PageAnnotations
struct PDF4QTLIBCORESHARED_EXPORT PageAnnotations
{
bool isEmpty() const { return annotations.empty(); }

View File

@ -623,7 +623,6 @@ void PDFFormFieldButton::resetValue(const ResetValueParameters& parameters)
PDFFormManager::PDFFormManager(QObject* parent) :
BaseClass(parent),
m_annotationManager(nullptr),
m_document(nullptr),
m_flags(getDefaultApperanceFlags()),
m_isCommitDisabled(false)
@ -636,16 +635,6 @@ PDFFormManager::~PDFFormManager()
}
PDFAnnotationManager* PDFFormManager::getAnnotationManager() const
{
return m_annotationManager;
}
void PDFFormManager::setAnnotationManager(PDFAnnotationManager* annotationManager)
{
m_annotationManager = annotationManager;
}
const PDFDocument* PDFFormManager::getDocument() const
{
return m_document;

View File

@ -72,7 +72,7 @@ using PDFFormWidgets = std::vector<PDFFormWidget>;
/// have children), fields represents various interactive widgets, such as
/// checks, radio buttons, text edits etc., which are editable and user
/// can interact with them.
class PDFFormField
class PDF4QTLIBCORESHARED_EXPORT PDFFormField
{
public:
explicit inline PDFFormField() = default;
@ -280,7 +280,7 @@ protected:
/// Represents pushbutton, checkbox and radio button (which is distinguished
/// by flags).
class PDFFormFieldButton : public PDFFormField
class PDF4QTLIBCORESHARED_EXPORT PDFFormFieldButton : public PDFFormField
{
public:
explicit inline PDFFormFieldButton() = default;
@ -325,7 +325,7 @@ private:
};
/// Represents single line, or multiline text field
class PDFFormFieldText : public PDFFormField
class PDF4QTLIBCORESHARED_EXPORT PDFFormFieldText : public PDFFormField
{
public:
explicit inline PDFFormFieldText() = default;
@ -359,7 +359,7 @@ private:
QString m_richTextValue;
};
class PDFFormFieldChoice : public PDFFormField
class PDF4QTLIBCORESHARED_EXPORT PDFFormFieldChoice : public PDFFormField
{
using BaseClass = PDFFormField;
@ -394,7 +394,7 @@ private:
PDFObject m_selection;
};
class PDFFormFieldSignature : public PDFFormField
class PDF4QTLIBCORESHARED_EXPORT PDFFormFieldSignature : public PDFFormField
{
public:
explicit inline PDFFormFieldSignature() = default;
@ -522,9 +522,6 @@ public:
/// \param widget Widget annotation
PDFFormField* getFormFieldForWidget(PDFObjectReference widget) { return m_form.getFormFieldForWidget(widget); }
PDFAnnotationManager* getAnnotationManager() const;
void setAnnotationManager(PDFAnnotationManager* annotationManager);
const PDFDocument* getDocument() const;
void setDocument(const PDFModifiedDocument& document);
@ -615,7 +612,6 @@ signals:
void documentModified(pdf::PDFModifiedDocument document);
private:
PDFAnnotationManager* m_annotationManager;
const PDFDocument* m_document;
FormAppearanceFlags m_flags;
PDFForm m_form;

View File

@ -147,7 +147,7 @@ private:
/// Precompiled page contains precompiled graphic instructions of a PDF page to draw it quickly
/// on the target painter. It enables very fast drawing, because instructions are not decoded
/// and interpreted from the PDF stream, but they are just "played" on the painter.
class PDFPrecompiledPage
class PDF4QTLIBCORESHARED_EXPORT PDFPrecompiledPage
{
public:
explicit inline PDFPrecompiledPage() = default;

View File

@ -106,7 +106,7 @@ private:
};
/// Snap engine, which handles snapping of points on the page.
class PDFSnapper
class PDF4QTLIBCORESHARED_EXPORT PDFSnapper
{
public:
PDFSnapper();

View File

@ -264,7 +264,7 @@ private:
PDFTextSelectionColoredItems m_items;
};
struct PDFFindResult
struct PDF4QTLIBCORESHARED_EXPORT PDFFindResult
{
bool operator<(const PDFFindResult& other) const;

View File

@ -20,7 +20,7 @@
namespace pdf
{
class PDFTextLayoutGenerator : public PDFPageContentProcessor
class PDF4QTLIBCORESHARED_EXPORT PDFTextLayoutGenerator : public PDFPageContentProcessor
{
using BaseClass = PDFPageContentProcessor;

View File

@ -25,7 +25,7 @@ namespace pdf
class PDFPrecompiledPage;
/// Snapshot for current widget viewable items.
struct PDFWidgetSnapshot
struct PDF4QTLIBCORESHARED_EXPORT PDFWidgetSnapshot
{
struct SnapshotItem
{

View File

@ -21,6 +21,7 @@
#include "pdfutils.h"
#include "pdfcompiler.h"
#include "pdfwidgetformmanager.h"
#include "pdfwidgetannotation.h"
#include "pdfdbgheap.h"
#include <QActionGroup>

View File

@ -23,6 +23,7 @@
#include "pdfcms.h"
#include "pdfannotation.h"
#include "pdfdrawwidget.h"
#include "pdfwidgetannotation.h"
#include "pdfdbgheap.h"
#include <QTimer>

View File

@ -18,7 +18,11 @@
#include "pdfwidgetannotation.h"
#include "pdfdrawwidget.h"
#include "pdfwidgetutils.h"
#include "pdfwidgetformmanager.h"
#include "pdfdrawspacecontroller.h"
#include "pdfselectpagesdialog.h"
#include "pdfobjecteditorwidget.h"
#include "pdfdocumentbuilder.h"
#include <QMenu>
#include <QDialog>

View File

@ -15,6 +15,9 @@
// You should have received a copy of the GNU Lesser General Public License
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
#ifndef PDFWIDGETANNOTATION_H
#define PDFWIDGETANNOTATION_H
#include "pdfwidgetsglobal.h"
#include "pdfannotation.h"
#include "pdfdocumentdrawinterface.h"
@ -101,3 +104,5 @@ private:
};
} // namespace pdf
#endif // PDFWIDGETANNOTATION_H

View File

@ -17,7 +17,12 @@
#include "pdfwidgetformmanager.h"
#include "pdfdrawwidget.h"
#include "pdftexteditpseudowidget.h"
#include "pdfdrawspacecontroller.h"
#include "pdfform.h"
#include "pdfpainterutils.h"
#include "pdfwidgetannotation.h"
#include "pdfdocumentbuilder.h"
#include <QKeyEvent>
#include <QMouseEvent>
@ -172,7 +177,7 @@ private:
using BaseClass = PDFFormFieldWidgetEditor;
public:
explicit PDFFormFieldAbstractButtonEditor(PDFFormManager* formManager, PDFFormWidget formWidget);
explicit PDFFormFieldAbstractButtonEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget);
virtual ~PDFFormFieldAbstractButtonEditor() = default;
virtual void shortcutOverrideEvent(QWidget* widget, QKeyEvent* event) override;
@ -191,7 +196,7 @@ private:
using BaseClass = PDFFormFieldAbstractButtonEditor;
public:
explicit PDFFormFieldPushButtonEditor(PDFFormManager* formManager, PDFFormWidget formWidget);
explicit PDFFormFieldPushButtonEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget);
virtual ~PDFFormFieldPushButtonEditor() = default;
protected:
@ -205,7 +210,7 @@ private:
using BaseClass = PDFFormFieldAbstractButtonEditor;
public:
explicit PDFFormFieldCheckableButtonEditor(PDFFormManager* formManager, PDFFormWidget formWidget);
explicit PDFFormFieldCheckableButtonEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget);
virtual ~PDFFormFieldCheckableButtonEditor() = default;
protected:
@ -219,7 +224,7 @@ private:
using BaseClass = PDFFormFieldWidgetEditor;
public:
explicit PDFFormFieldTextBoxEditor(PDFFormManager* formManager, PDFFormWidget formWidget);
explicit PDFFormFieldTextBoxEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget);
virtual ~PDFFormFieldTextBoxEditor() = default;
virtual void shortcutOverrideEvent(QWidget* widget, QKeyEvent* event) override;
@ -250,7 +255,7 @@ private:
using BaseClass = PDFFormFieldWidgetEditor;
public:
explicit PDFFormFieldComboBoxEditor(PDFFormManager* formManager, PDFFormWidget formWidget);
explicit PDFFormFieldComboBoxEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget);
virtual ~PDFFormFieldComboBoxEditor() = default;
virtual void shortcutOverrideEvent(QWidget* widget, QKeyEvent* event) override;
@ -300,7 +305,7 @@ private:
using BaseClass = PDFFormFieldWidgetEditor;
public:
explicit PDFFormFieldListBoxEditor(PDFFormManager* formManager, PDFFormWidget formWidget);
explicit PDFFormFieldListBoxEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget);
virtual ~PDFFormFieldListBoxEditor() = default;
virtual void shortcutOverrideEvent(QWidget* widget, QKeyEvent* event) override;
@ -337,12 +342,23 @@ private:
PDFWidgetFormManager::PDFWidgetFormManager(PDFDrawWidgetProxy* proxy, QObject* parent) :
BaseClass(parent),
m_annotationManager(nullptr),
m_proxy(proxy),
m_focusedEditor(nullptr)
{
Q_ASSERT(proxy);
}
PDFWidgetAnnotationManager* PDFWidgetFormManager::getAnnotationManager() const
{
return m_annotationManager;
}
void PDFWidgetFormManager::setAnnotationManager(PDFWidgetAnnotationManager* annotationManager)
{
m_annotationManager = annotationManager;
}
void PDFWidgetFormManager::shortcutOverrideEvent(QWidget* widget, QKeyEvent* event)
{
if (m_focusedEditor)
@ -522,7 +538,7 @@ void PDFWidgetFormManager::grabMouse(const MouseEventInfo& info, QMouseEvent* ev
}
}
PDFFormManager::MouseEventInfo PDFWidgetFormManager::getMouseEventInfo(QWidget* widget, QPoint point)
PDFWidgetFormManager::MouseEventInfo PDFWidgetFormManager::getMouseEventInfo(QWidget* widget, QPoint point)
{
MouseEventInfo result;
@ -567,7 +583,7 @@ PDFFormManager::MouseEventInfo PDFWidgetFormManager::getMouseEventInfo(QWidget*
{
annotationRect = pageAnnotation.annotation->getRectangle();
}
QTransform widgetToDevice = m_annotationManager->prepareTransformations(snapshotItem.pageToDeviceMatrix, widget, pageAnnotation.annotation->getEffectiveFlags(), m_document->getCatalog()->getPage(snapshotItem.pageIndex), annotationRect);
QTransform widgetToDevice = m_annotationManager->prepareTransformations(snapshotItem.pageToDeviceMatrix, widget, pageAnnotation.annotation->getEffectiveFlags(), getDocument()->getCatalog()->getPage(snapshotItem.pageIndex), annotationRect);
QPainterPath path;
path.addRect(annotationRect);
@ -796,7 +812,7 @@ void PDFWidgetFormManager::updateFieldValues()
{
BaseClass::updateFieldValues();
if (m_document)
if (getDocument())
{
for (PDFFormFieldWidgetEditor* editor : m_widgetEditors)
{
@ -818,7 +834,7 @@ PDFFormFieldWidgetEditor* PDFWidgetFormManager::getEditor(const PDFFormField* fo
return nullptr;
}
PDFFormFieldWidgetEditor::PDFFormFieldWidgetEditor(PDFFormManager* formManager, PDFFormWidget formWidget) :
PDFFormFieldWidgetEditor::PDFFormFieldWidgetEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget) :
m_formManager(formManager),
m_formWidget(formWidget),
m_hasFocus(false)
@ -959,13 +975,13 @@ void PDFFormFieldWidgetEditor::performKeypadNavigation(QWidget* widget, QKeyEven
m_formManager->focusNextPrevFormField(next);
}
PDFFormFieldPushButtonEditor::PDFFormFieldPushButtonEditor(PDFFormManager* formManager, PDFFormWidget formWidget) :
PDFFormFieldPushButtonEditor::PDFFormFieldPushButtonEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget) :
BaseClass(formManager, formWidget)
{
}
PDFFormFieldAbstractButtonEditor::PDFFormFieldAbstractButtonEditor(PDFFormManager* formManager, PDFFormWidget formWidget) :
PDFFormFieldAbstractButtonEditor::PDFFormFieldAbstractButtonEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget) :
BaseClass(formManager, formWidget)
{
@ -1062,7 +1078,7 @@ void PDFFormFieldPushButtonEditor::click()
}
}
PDFFormFieldCheckableButtonEditor::PDFFormFieldCheckableButtonEditor(PDFFormManager* formManager, PDFFormWidget formWidget) :
PDFFormFieldCheckableButtonEditor::PDFFormFieldCheckableButtonEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget) :
BaseClass(formManager, formWidget)
{
@ -1095,7 +1111,7 @@ void PDFFormFieldCheckableButtonEditor::click()
m_formManager->setFormFieldValue(parameters);
}
PDFFormFieldComboBoxEditor::PDFFormFieldComboBoxEditor(PDFFormManager* formManager, PDFFormWidget formWidget) :
PDFFormFieldComboBoxEditor::PDFFormFieldComboBoxEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget) :
BaseClass(formManager, formWidget),
m_textEdit(getTextEditFlags(formWidget.getParent()->getFlags())),
m_listBox(formWidget.getParent()->getFlags()),
@ -1460,7 +1476,7 @@ void PDFFormFieldTextBoxEditor::setFocusImpl(bool focused)
}
}
PDFFormFieldTextBoxEditor::PDFFormFieldTextBoxEditor(PDFFormManager* formManager, PDFFormWidget formWidget) :
PDFFormFieldTextBoxEditor::PDFFormFieldTextBoxEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget) :
BaseClass(formManager, formWidget),
m_textEdit(formWidget.getParent()->getFlags())
{
@ -1905,7 +1921,7 @@ int PDFListBoxPseudowidget::getIndexFromWidgetPosition(const QPointF& point) con
return m_topIndex + visualIndex;
}
PDFFormFieldListBoxEditor::PDFFormFieldListBoxEditor(PDFFormManager* formManager, PDFFormWidget formWidget) :
PDFFormFieldListBoxEditor::PDFFormFieldListBoxEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget) :
BaseClass(formManager, formWidget),
m_listBox(formWidget.getParent()->getFlags())
{
@ -2154,7 +2170,7 @@ void PDFFormFieldListBoxEditor::commit()
}
}
PDFWidgetFormManager::isEditorDrawEnabled(const PDFObjectReference& reference) const
bool PDFWidgetFormManager::isEditorDrawEnabled(const PDFObjectReference& reference) const
{
const PDFFormFieldWidgetEditor* editor = getEditor(getFormFieldForWidget(reference));
return editor && editor->isEditorDrawEnabled();

View File

@ -15,19 +15,25 @@
// You should have received a copy of the GNU Lesser General Public License
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
#ifndef PDFWIDGETFORMMANAGER_H
#define PDFWIDGETFORMMANAGER_H
#include "pdfwidgetsglobal.h"
#include "pdfform.h"
#include "pdfdocumentdrawinterface.h"
namespace pdf
{
class PDFDrawWidgetProxy;
class PDFWidgetAnnotationManager;
class PDFWidgetFormManager;
/// Base class for editors of form fields. It enables editation
/// of form fields, such as entering text, clicking on check box etc.
class PDFFormFieldWidgetEditor
class PDF4QTLIBWIDGETSSHARED_EXPORT PDFFormFieldWidgetEditor
{
public:
explicit PDFFormFieldWidgetEditor(PDFFormManager* formManager, PDFFormWidget formWidget);
explicit PDFFormFieldWidgetEditor(PDFWidgetFormManager* formManager, PDFFormWidget formWidget);
virtual ~PDFFormFieldWidgetEditor() = default;
virtual void shortcutOverrideEvent(QWidget* widget, QKeyEvent* event);
@ -63,12 +69,12 @@ protected:
void performKeypadNavigation(QWidget* widget, QKeyEvent* event);
PDFFormManager* m_formManager;
PDFWidgetFormManager* m_formManager;
PDFFormWidget m_formWidget;
bool m_hasFocus;
};
class PDFWidgetFormManager : public PDFFormManager, public IDrawWidgetInputInterface
class PDF4QTLIBWIDGETSSHARED_EXPORT PDFWidgetFormManager : public PDFFormManager, public IDrawWidgetInputInterface
{
Q_OBJECT
@ -135,6 +141,9 @@ public:
virtual bool isEditorDrawEnabled(const PDFFormField* formField) const override;
virtual void drawFormField(const PDFFormField* formField, AnnotationDrawParameters& parameters, bool edit) const override;
PDFWidgetAnnotationManager* getAnnotationManager() const;
void setAnnotationManager(PDFWidgetAnnotationManager* annotationManager);
protected:
virtual void updateFieldValues() override;
virtual void onDocumentReset() override;
@ -169,6 +178,7 @@ private:
/// \param event Mouse event
void ungrabMouse(const MouseEventInfo& info, QMouseEvent* event);
PDFWidgetAnnotationManager* m_annotationManager;
PDFDrawWidgetProxy* m_proxy;
MouseGrabInfo m_mouseGrabInfo;
std::optional<QCursor> m_mouseCursor;
@ -177,3 +187,5 @@ private:
};
} // namespace pdf
#endif // PDFWIDGETFORMMANAGER_H

View File

@ -30,11 +30,47 @@
#include <QPageSize>
#include <QtConcurrent/QtConcurrent>
#include <stack>
#include <execution>
namespace pdfviewer
{
class PDFTreeFactory : public pdf::ITreeFactory
{
public:
PDFTreeFactory(QTreeWidgetItem* root)
{
m_roots.push(root);
}
// ITreeFactory interface
virtual void pushItem(QStringList texts) override;
virtual void addItem(QStringList texts) override;
virtual void popItem() override;
private:
std::stack<QTreeWidgetItem*> m_roots;
};
void PDFTreeFactory::pushItem(QStringList texts)
{
Q_ASSERT(!m_roots.empty());
m_roots.push(new QTreeWidgetItem(m_roots.top(), texts));
}
void PDFTreeFactory::addItem(QStringList texts)
{
Q_ASSERT(!m_roots.empty());
new QTreeWidgetItem(m_roots.top(), texts);
}
void PDFTreeFactory::popItem()
{
Q_ASSERT(!m_roots.empty());
m_roots.pop();
}
PDFDocumentPropertiesDialog::PDFDocumentPropertiesDialog(const pdf::PDFDocument* document,
const PDFFileInfo* fileInfo,
QWidget* parent) :
@ -352,9 +388,14 @@ void PDFDocumentPropertiesDialog::initializeFonts(const pdf::PDFDocument* docume
{
new QTreeWidgetItem(fontRootItem, { tr("Font family"), fontDescriptor->fontFamily });
}
new QTreeWidgetItem(fontRootItem, { tr("Embedded subset"), fontDescriptor->getEmbeddedFontData() ? tr("Yes") : tr("No") });
font->dumpFontToTreeItem(fontRootItem);
realizedFont->dumpFontToTreeItem(fontRootItem);
PDFTreeFactory treeFactory1(fontRootItem);
font->dumpFontToTreeItem(&treeFactory1);
PDFTreeFactory treeFactory2(fontRootItem);
realizedFont->dumpFontToTreeItem(&treeFactory2);
// Separator item
new QTreeWidgetItem(fontRootItem, QStringList());

View File

@ -42,6 +42,8 @@
#include "pdfrecentfilemanager.h"
#include "pdftexttospeech.h"
#include "pdfencryptionsettingsdialog.h"
#include "pdfwidgetannotation.h"
#include "pdfwidgetformmanager.h"
#include <QMenu>
#include <QPrinter>
@ -385,7 +387,7 @@ void PDFProgramController::initializeAnnotationManager()
void PDFProgramController::initializeFormManager()
{
m_formManager = new pdf::PDFFormManager(m_pdfWidget->getDrawWidgetProxy(), this);
m_formManager = new pdf::PDFWidgetFormManager(m_pdfWidget->getDrawWidgetProxy(), this);
m_formManager->setAnnotationManager(m_annotationManager);
m_formManager->setAppearanceFlags(m_settings->getSettings().m_formAppearanceFlags);
m_annotationManager->setFormManager(m_formManager);

View File

@ -42,7 +42,7 @@ class PDFAction;
class PDFWidget;
class PDFCMSManager;
class PDFToolManager;
class PDFFormManager;
class PDFWidgetFormManager;
class PDFWidgetAnnotationManager;
}
@ -421,7 +421,7 @@ private:
pdf::PDFCMSManager* m_CMSManager;
pdf::PDFToolManager* m_toolManager;
pdf::PDFWidgetAnnotationManager* m_annotationManager;
pdf::PDFFormManager* m_formManager;
pdf::PDFWidgetFormManager* m_formManager;
PDFFileInfo m_fileInfo;
QFileSystemWatcher m_fileWatcher;

View File

@ -20,7 +20,7 @@ add_executable(Pdf4QtViewerLite
icon.rc
)
target_link_libraries(Pdf4QtViewerLite PRIVATE Pdf4QtLibCore Pdf4QtViewer Qt6::Core Qt6::Gui Qt6::Widgets)
target_link_libraries(Pdf4QtViewerLite PRIVATE Pdf4QtLibCore Pdf4QtLibWidgets Pdf4QtViewer Qt6::Core Qt6::Gui Qt6::Widgets)
set_target_properties(Pdf4QtViewerLite PROPERTIES
WIN32_EXECUTABLE ON

View File

@ -20,7 +20,7 @@ add_executable(Pdf4QtViewerProfi
icon.rc
)
target_link_libraries(Pdf4QtViewerProfi PRIVATE Pdf4QtLibCore Pdf4QtViewer Qt6::Core Qt6::Gui Qt6::Widgets)
target_link_libraries(Pdf4QtViewerProfi PRIVATE Pdf4QtLibCore Pdf4QtLibWidgets Pdf4QtViewer Qt6::Core Qt6::Gui Qt6::Widgets)
set_target_properties(Pdf4QtViewerProfi PROPERTIES
WIN32_EXECUTABLE ON