KD Reports API Documentation  2.0
KDReportsTextDocumentData_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** This file is part of the KD Reports library.
4 **
5 ** SPDX-FileCopyrightText: 2007-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6 **
7 ** SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDAB-KDReports OR LicenseRef-KDAB-KDReports-US
8 **
9 ** Licensees holding valid commercial KD Reports licenses may use this file in
10 ** accordance with the KD Reports Commercial License Agreement provided with
11 ** the Software.
12 **
13 ** Contact info@kdab.com if any conditions of this licensing are not clear to you.
14 **
15 ****************************************************************************/
16 
17 #ifndef KDREPORTSTEXTDOCUMENTDATA_P_H
18 #define KDREPORTSTEXTDOCUMENTDATA_P_H
20 #include "KDReportsReport.h"
21 #include <QMultiMap>
22 #include <QTextCursor>
23 
24 //
25 // W A R N I N G
26 // -------------
27 //
28 // This file is not part of the KD Reports API. It exists purely as an
29 // implementation detail. This header file may change from version to
30 // version without notice, or even be removed.
31 //
32 // We mean it.
33 //
34 //
35 
36 namespace KDReports {
37 
42 class KDREPORTS_EXPORT TextDocumentData
43 {
44 public:
45  explicit TextDocumentData();
46  ~TextDocumentData();
47 
48  TextDocumentData(const TextDocumentData &) = delete;
49  TextDocumentData &operator=(const TextDocumentData &) = delete;
50 
51  QTextDocument &document() { return *m_document; }
52  const QTextDocument &document() const { return *m_document; }
53 
54  void setUsesTabPositions(bool usesTabs);
55  void saveResourcesToFiles();
56  enum ModificationMode { Append,
57  Modify };
58  void aboutToModifyContents(ModificationMode mode);
59  void updateTextValue(const QString &id, const QString &newValue);
60  void layoutWithTextWidth(qreal w);
61  void setPageSize(QSizeF size);
62  void scaleFontsBy(qreal factor); // TODO remove?
63  void updatePercentSizes(QSizeF size);
64  void setTextValueMarker(int pos, const QString &id, int valueLength, bool html);
67  // int breakTables( const QSizeF& textDocPageSize, int numHorizontalPages, KDReports::Report::TableBreakingPageOrder pageOrder );
68  // We need to know about all tables in order to implement table-breaking
69  void registerTable(QTextTable *table);
70  QString asHtml() const;
73  void registerAutoTable(QTextTable *table, const KDReports::AutoTableElement *element);
74  QList<KDReports::AutoTableElement *> autoTableElements();
75  void regenerateAutoTables();
76  void regenerateAutoTableForModel(QAbstractItemModel *model);
77  void addResourceName(const QString &resourceName);
78  void setHasResizableImages();
79 
80  static void updatePercentSize(QTextImageFormat &format, QSizeF size);
81 
82 private:
83  void resolveCursorPositions(ModificationMode mode);
84  void setFontSizeHelper(QTextCursor &lastCursor, int endPosition, qreal pointSize, qreal factor);
85  void regenerateOneTable(const KDReports::AutoTableElement &tableElement, QTextTable *table);
86  void dumpTextValueCursors() const;
87 
88  QTextDocument *m_document; // a pointer because of the clone() API... TODO: cleanup
89  enum ElementType { ElementTypeText,
90  ElementTypeHtml };
91  struct TextValueData
92  {
93  int valueLength;
94  ElementType elementType;
95  QTextCursor cursor;
96  int initialPosition;
97  };
98  QMultiMap<QString, TextValueData> m_textValueCursors;
99 
100  QList<QTextTable *> m_tables;
101 
102  typedef QHash<QTextTable *, KDReports::AutoTableElement> AutoTablesMaps;
103  AutoTablesMaps m_autoTables;
104  QList<QString> m_resourceNames;
105  bool m_usesTabPositions;
106  bool m_hasResizableImages = false;
107 };
108 
109 }
110 
111 #endif /* KDREPORTSTEXTDOCUMENTDATA_P_H */
QList
Definition: KDReportsAbstractTableElement.h:25
KDReports::AutoTableElement
Definition: KDReportsAutoTableElement.h:40
KDReports::TextDocumentData::ModificationMode
ModificationMode
Definition: KDReportsTextDocumentData_p.h:84
KDReportsReport.h
KDReportsAutoTableElement.h
KDREPORTS_EXPORT
#define KDREPORTS_EXPORT
Definition: KDReportsGlobal.h:29
KDReports
Definition: KDReportsAbstractReportLayout_p.h:30

© 2007-2021 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-reports/
Generated on Sat Jan 8 2022 02:38:32 for KD Reports API Documentation by doxygen 1.8.17