KD Reports API Documentation  2.1
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 #include <QTextDocument>
24 
25 //
26 // W A R N I N G
27 // -------------
28 //
29 // This file is not part of the KD Reports API. It exists purely as an
30 // implementation detail. This header file may change from version to
31 // version without notice, or even be removed.
32 //
33 // We mean it.
34 //
35 //
36 
37 namespace KDReports {
38 
44 {
45 public:
46  explicit TextDocumentData();
48 
51 
52  QTextDocument &document() { return m_document; }
53  const QTextDocument &document() const { return m_document; }
54 
55  void setUsesTabPositions(bool usesTabs);
56  void saveResourcesToFiles();
57  enum ModificationMode { Append,
58  Modify };
59  void aboutToModifyContents(ModificationMode mode);
60  void updateTextValue(const QString &id, const QString &newValue);
61  void layoutWithTextWidth(qreal w);
62  void setPageSize(QSizeF size);
63  void scaleFontsBy(qreal factor); // TODO remove?
64  void updatePercentSizes(QSizeF size);
65  void setTextValueMarker(int pos, const QString &id, int valueLength, bool html);
68  // int breakTables( const QSizeF& textDocPageSize, int numHorizontalPages, KDReports::Report::TableBreakingPageOrder pageOrder );
69  // We need to know about all tables in order to implement table-breaking
70  void registerTable(QTextTable *table);
71  QString asHtml() const;
74  void registerAutoTable(QTextTable *table, const KDReports::AutoTableElement *element);
78  void addResourceName(const QString &resourceName);
79  void setHasResizableImages();
80 
81  static void updatePercentSize(QTextImageFormat &format, QSizeF size);
82 
83 private:
84  void resolveCursorPositions(ModificationMode mode);
85  void setFontSizeHelper(QTextCursor &lastCursor, int endPosition, qreal pointSize, qreal factor);
86  void regenerateOneTable(const KDReports::AutoTableElement &tableElement, QTextTable *table);
87  void dumpTextValueCursors() const;
88 
89  QTextDocument m_document;
90  enum ElementType { ElementTypeText,
91  ElementTypeHtml };
92  struct TextValueData
93  {
94  int valueLength;
95  ElementType elementType;
96  QTextCursor cursor;
97  int initialPosition;
98  };
99  QMultiMap<QString, TextValueData> m_textValueCursors;
100 
101  QList<QTextTable *> m_tables;
102 
104  AutoTablesMaps m_autoTables;
105  QList<QString> m_resourceNames;
106  bool m_usesTabPositions;
107  bool m_hasResizableImages = false;
108 };
109 
110 }
111 
112 #endif /* KDREPORTSTEXTDOCUMENTDATA_P_H */
QTextDocument
QMultiMap< QString, TextValueData >
KDReports::TextDocumentData::asHtml
QString asHtml() const
KDReports::TextDocumentData
Definition: KDReportsTextDocumentData_p.h:44
KDReports::TextDocumentData::operator=
TextDocumentData & operator=(const TextDocumentData &)=delete
KDReports::TextDocumentData::autoTableElements
QList< KDReports::AutoTableElement * > autoTableElements()
QTextTable
QList
KDReports::TextDocumentData::regenerateAutoTables
void regenerateAutoTables()
KDReports::AutoTableElement
Definition: KDReportsAutoTableElement.h:41
KDReports::TextDocumentData::ModificationMode
ModificationMode
Definition: KDReportsTextDocumentData_p.h:57
KDReports::TextDocumentData::document
QTextDocument & document()
Definition: KDReportsTextDocumentData_p.h:52
QString
KDReportsReport.h
KDReports::TextDocumentData::regenerateAutoTableForModel
void regenerateAutoTableForModel(QAbstractItemModel *model)
KDReportsAutoTableElement.h
KDReports::TextDocumentData::document
const QTextDocument & document() const
Definition: KDReportsTextDocumentData_p.h:53
QSizeF
KDReports::TextDocumentData::TextDocumentData
TextDocumentData(const TextDocumentData &)=delete
KDREPORTS_EXPORT
#define KDREPORTS_EXPORT
Definition: KDReportsGlobal.h:29
QHash< QTextTable *, KDReports::AutoTableElement >
QTextImageFormat
QTextCursor
QAbstractItemModel
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 Fri Jul 15 2022 13:09:07 for KD Reports API Documentation by doxygen 1.8.20