QgsCompositionConverter class

QgsCompositionConverter class converts a QGIS 2.x composition to a QGIS 3.x layout.

Public types

enum DataDefinedProperty { NoProperty = 0, AllProperties, TestProperty, PresetPaperSize, PaperWidth, PaperHeight, NumPages, PaperOrientation, PageNumber, PositionX, PositionY, ItemWidth, ItemHeight, ItemRotation, Transparency, Opacity, BlendMode, ExcludeFromExports, FrameColor, BackgroundColor, MapRotation, MapScale, MapXMin, MapYMin, MapXMax, MapYMax, MapAtlasMargin, MapLayers, MapStylePreset, PictureSource, PictureSvgBackgroundColor, PictureSvgStrokeColor, PictureSvgStrokeWidth, SourceUrl, LegendTitle, LegendColumnCount, ScalebarFillColor, ScalebarFillColor2, ScalebarLineColor, ScalebarLineWidth }
Composition data defined properties for different item types.
enum MarkerMode { DefaultMarker, NoMarker, SVGMarker }
The MarkerMode enum is the old QGIS 2.x arrow marker mode.

Public static functions

static auto addItemsFromCompositionXml(QgsPrintLayout* layout, const QDomElement& parentElement, QPointF* position = nullptr, bool pasteInPlace = false) -> QList<QgsLayoutObject*>
addItemsFromCompositionXml parse a QGIS 2.x composition XML in the parentElement, converts the 2.x items to the new layout elements and add them to the layout
static auto convertCompositionTemplate(const QDomDocument& document, QgsProject* project) -> QDomDocument
Convert a composition template document to a layout template.
static auto createLayoutFromCompositionXml(const QDomElement& composerElement, QgsProject* project) -> std::unique_ptr<QgsPrintLayout>
createLayoutFromCompositionXml is a factory that creates layout instances from a QGIS 2.x XML composition parentElement and a QGIS project
static auto isCompositionTemplate(const QDomDocument& document) -> bool
Check if the given document is a composition template.

Enum documentation

enum QgsCompositionConverter::DataDefinedProperty

Composition data defined properties for different item types.

Enumerators
NoProperty

No property.

AllProperties

All properties for item.

TestProperty

Dummy property with no effect on item.

PresetPaperSize

Preset paper size for composition.

PaperWidth

Paper width.

PaperHeight

Paper height.

NumPages

Number of pages in composition.

PaperOrientation

Paper orientation.

PageNumber

Page number for item placement.

PositionX

X position on page.

PositionY

Y position on page.

ItemWidth

Width of item.

ItemHeight

Height of item.

ItemRotation

Rotation of item.

Transparency

Item transparency (deprecated)

Opacity

Item opacity.

BlendMode

Item blend mode.

ExcludeFromExports

Exclude item from exports.

FrameColor

Item frame color.

BackgroundColor

Item background color.

MapRotation

Map rotation.

MapScale

Map scale.

MapXMin

Map extent x minimum.

MapYMin

Map extent y minimum.

MapXMax

Map extent x maximum.

MapYMax

Map extent y maximum.

MapAtlasMargin

Map atlas margin.

MapLayers

Map layer set.

MapStylePreset

Layer and style map theme.

PictureSource

Picture source url.

PictureSvgBackgroundColor

SVG background color.

PictureSvgStrokeColor

SVG stroke color.

PictureSvgStrokeWidth

SVG stroke width.

SourceUrl

Html source url.

LegendTitle

Legend title.

LegendColumnCount

Legend column count.

ScalebarFillColor

Scalebar fill color.

ScalebarFillColor2

Scalebar secondary fill color.

ScalebarLineColor

Scalebar line color.

ScalebarLineWidth

Scalebar line width.

Function documentation

static QList<QgsLayoutObject*> QgsCompositionConverter::addItemsFromCompositionXml(QgsPrintLayout* layout, const QDomElement& parentElement, QPointF* position = nullptr, bool pasteInPlace = false)

addItemsFromCompositionXml parse a QGIS 2.x composition XML in the parentElement, converts the 2.x items to the new layout elements and add them to the layout

Parameters
layout where the items will be added
parentElement parent DOM element
position for pasting
pasteInPlace if true element position is translated to position
Returns list of layout object items that have been added to the layout

static QDomDocument QgsCompositionConverter::convertCompositionTemplate(const QDomDocument& document, QgsProject* project)

Convert a composition template document to a layout template.

Parameters
document containing a composition
project
Returns dom document with the converted template

static std::unique_ptr<QgsPrintLayout> QgsCompositionConverter::createLayoutFromCompositionXml(const QDomElement& composerElement, QgsProject* project)

createLayoutFromCompositionXml is a factory that creates layout instances from a QGIS 2.x XML composition parentElement and a QGIS project

Returns a QgsPrintLayout instance

static bool QgsCompositionConverter::isCompositionTemplate(const QDomDocument& document)

Check if the given document is a composition template.

Returns true if the document is a composition template