QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgscompositionconverter.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscompositionconverter.h - Convert a QGIS 2.x composition to a layout
3
4 ---------------------
5 begin : 13.12.2017
6 copyright : (C) 2017 by Alessandro Pasotti
7 email : elpaso at itopen dot it
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSCOMPOSITIONCONVERTER_H
17#define QGSCOMPOSITIONCONVERTER_H
18
19
20#include <QDomDocument>
21#include <QDomElement>
22
23#include "qgis_sip.h"
24
25#define SIP_NO_FILE
26
28
29class QgsPrintLayout;
30class QgsLayoutItem;
31class QgsLayoutObject;
33class QgsProperty;
35
47class QgsLayoutAtlas;
48class QgsProject;
49
55class CORE_EXPORT QgsCompositionConverter
56{
57 public:
58
63 {
64 NoProperty = 0,
65 AllProperties,
66 TestProperty,
67 //composer page properties
68 PresetPaperSize,
69 PaperWidth,
70 PaperHeight,
71 NumPages,
72 PaperOrientation,
73 //general composer item properties
74 PageNumber,
75 PositionX,
76 PositionY,
77 ItemWidth,
78 ItemHeight,
79 ItemRotation,
80 Transparency,
81 Opacity,
82 BlendMode,
83 ExcludeFromExports,
84 FrameColor,
85 BackgroundColor,
86 //composer map
87 MapRotation,
88 MapScale,
89 MapXMin,
90 MapYMin,
91 MapXMax,
92 MapYMax,
93 MapAtlasMargin,
94 MapLayers,
95 MapStylePreset,
96 //composer picture
97 PictureSource,
98 PictureSvgBackgroundColor,
99 PictureSvgStrokeColor,
100 PictureSvgStrokeWidth,
101 //html item
102 SourceUrl,
103 //legend item
104 LegendTitle,
105 LegendColumnCount,
106 //scalebar item
107 ScalebarFillColor,
108 ScalebarFillColor2,
109 ScalebarLineColor,
110 ScalebarLineWidth,
111 };
112
117 {
120 SVGMarker
121 };
122
123
129 static std::unique_ptr<QgsPrintLayout> createLayoutFromCompositionXml( const QDomElement &composerElement,
130 QgsProject *project );
131
132
142 static QList<QgsLayoutObject *> addItemsFromCompositionXml( QgsPrintLayout *layout,
143 const QDomElement &parentElement,
144 QPointF *position = nullptr,
145 bool pasteInPlace = false );
146
151 static bool isCompositionTemplate( const QDomDocument &document );
152
159 static QDomDocument convertCompositionTemplate( const QDomDocument
160 &document, QgsProject *project );
161
162
163 private:
164
165
167 static QgsPropertiesDefinition sPropertyDefinitions;
168
169
170 static bool readLabelXml( QgsLayoutItemLabel *layoutItem,
171 const QDomElement &itemElem,
172 const QgsProject *project );
173
174 static bool readShapeXml( QgsLayoutItemShape *layoutItem,
175 const QDomElement &itemElem,
176 const QgsProject *project );
177
178 static bool readPictureXml( QgsLayoutItemPicture *layoutItem,
179 const QDomElement &itemElem,
180 const QgsProject *project,
181 const QgsStringMap &mapId2Uuid );
182
184 template <class T, class T2> static bool readPolyXml( T *layoutItem,
185 const QDomElement &itemElem,
186 const QgsProject *project );
187
188 static bool readArrowXml( QgsLayoutItemPolyline *layoutItem,
189 const QDomElement &itemElem,
190 const QgsProject *project );
191
192 static bool readMapXml( QgsLayoutItemMap *layoutItem,
193 const QDomElement &itemElem,
194 const QgsProject *project,
195 QgsStringMap &mapId2Uuid );
196
197 static bool readScaleBarXml( QgsLayoutItemScaleBar *layoutItem,
198 const QDomElement &itemElem,
199 const QgsProject *project,
200 const QgsStringMap &mapId2Uuid );
201
202 static bool readLegendXml( QgsLayoutItemLegend *layoutItem,
203 const QDomElement &itemElem,
204 const QgsProject *project,
205 const QgsStringMap &mapId2Uuid );
206
207 static bool readAtlasXml( QgsLayoutAtlas *atlasItem,
208 const QDomElement &itemElem,
209 const QgsProject *project );
210
211 static bool readHtmlXml( QgsLayoutItemHtml *layoutItem,
212 const QDomElement &itemElem,
213 const QgsProject *project );
214
215 static bool readTableXml( QgsLayoutItemAttributeTable *layoutItem,
216 const QDomElement &itemElem,
217 const QgsProject *project );
218
219 static bool readGroupXml( QgsLayoutItemGroup *layoutItem,
220 const QDomElement &itemElem,
221 const QgsProject *project,
222 const QList<QgsLayoutObject *> &items );
223
224 static bool readOldComposerObjectXml( QgsLayoutObject *layoutItem, const QDomElement &itemElem );
225
226 static void readOldDataDefinedPropertyMap( const QDomElement &itemElem,
227 QgsPropertyCollection &dataDefinedProperties );
228
229 static QgsProperty readOldDataDefinedProperty( DataDefinedProperty property, const QDomElement &ddElem );
230
231 static void initPropertyDefinitions();
232
233 static QgsPropertiesDefinition propertyDefinitions();
234
236 static bool readXml( QgsLayoutItem *layoutItem, const QDomElement &itemElem );
237
239 static void adjustPos( QgsPrintLayout *layout, QgsLayoutItem *layoutItem, QPointF *position, bool &pasteInPlace, int zOrderOffset, QPointF &pasteShiftPos, int &pageNumber );
240
242 static void restoreGeneralComposeItemProperties( QgsLayoutItem *layoutItem, const QDomElement &itemElem );
243
245 static QRectF itemPosition( QgsLayoutItem *layoutItem, const QDomElement &itemElem );
246
248 static QPointF minPointFromXml( const QDomElement &elem );
249
250};
251
252#endif // QGSCOMPOSITIONCONVERTER_H
QgsCompositionConverter class converts a QGIS 2.x composition to a QGIS 3.x layout.
DataDefinedProperty
Composition data defined properties for different item types.
MarkerMode
The MarkerMode enum is the old QGIS 2.x arrow marker mode.
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
A layout table subclass that displays attributes from a vector layer.
A container for grouping several QgsLayoutItems.
A layout multiframe subclass for HTML content.
A layout item subclass for text labels.
A layout item subclass for map legends.
Layout graphical items for displaying a map.
A layout item subclass that displays SVG files or raster format images (jpg, png, ....
Layout item for node based polygon shapes.
Layout item for node based polyline shapes.
A layout item subclass for scale bars.
Layout item for basic filled shapes (e.g.
Base class for graphical items within a QgsLayout.
A base class for objects which belong to a layout.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
A store for object properties.
The class is used as a container of context for various read/write operations on other objects.
QMap< QString, QString > QgsStringMap
Definition qgis.h:6604
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.