Skip to content
Permalink
Browse files

[layout] Import HTML and atlas from 2.x composition

  • Loading branch information
elpaso committed Jan 8, 2018
1 parent b40a598 commit 2b2dae828f8a4d4ceedccbf43ef0f212947fc63a
@@ -1051,12 +1051,9 @@ SET(QGIS_CORE_HDRS
layout/qgslayoutsnapper.h
layout/qgslayoutundocommand.h
layout/qgslayoututils.h
<<<<<<< 2b8143a20674b8598fad5ee489def7ebd539cb5b
layout/qgsreportsectionfieldgroup.h
layout/qgsreportsectionlayout.h
=======
layout/qgscompositionconverter.h
>>>>>>> [layout] Converter: initial implementation

metadata/qgslayermetadata.h
metadata/qgslayermetadatavalidator.h

Large diffs are not rendered by default.

@@ -27,8 +27,9 @@

#include "qgspropertycollection.h"

class QgsLayout;
class QgsPrintLayout;
class QgsLayoutItem;
class QgsLayoutObject;
class QgsReadWriteContext;
class QgsProperty;
class QgsPropertyCollection;
@@ -41,6 +42,7 @@ class QgsLayoutItemPolyline;
class QgsLayoutItemMap;
class QgsLayoutItemScaleBar;
class QgsLayoutItemLegend;
class QgsLayoutItemHtml;


/**
@@ -119,28 +121,24 @@ class CORE_EXPORT QgsCompositionConverter


/**
* \brief createLayoutFromCompositionXml is a factory that creates layout instances from a
* QGIS 2.x XML composition \a document
* \param parentElement is the Composition element
* \param project the QGIS project
* \return a QgsLayout instance
* createLayoutFromCompositionXml is a factory that creates layout instances from a
* QGIS 2.x XML composition \a parentElement and a QGIS \a project
* \return a QgsPrintLayout instance
* \since QGIS 3.0
*/
static std::unique_ptr< QgsLayout > createLayoutFromCompositionXml( const QDomElement &parentElement,
static std::unique_ptr<QgsPrintLayout> createLayoutFromCompositionXml( const QDomElement &composerElement,
QgsProject *project );


/**
* addItemsFromCompositionXml parse a QGIS 2.x composition XML in the \a parentElement,
* converts the 2.x items to the new layout elements and add them to the \a layout
* \param layout the lay
* \param parentElement
* \param position for pasting
* \param pasteInPlace if true element position is translated to \a position
* \return a list of layout items
* \return list of layout object items that have been added to the layout
* \since QGIS 3.0
*/
static QList<QgsLayoutItem *> addItemsFromCompositionXml( QgsLayout *layout,
static QList<QgsLayoutObject *> addItemsFromCompositionXml( QgsPrintLayout *layout,
const QDomElement &parentElement,
QPointF *position = nullptr,
bool pasteInPlace = false );
@@ -189,8 +187,15 @@ class CORE_EXPORT QgsCompositionConverter
const QgsProject *project,
const QgsStringMap &mapId2Uuid );

static bool readAtlasXml( QgsLayoutAtlas *atlasItem,
const QDomElement &itemElem,
const QgsProject *project );

static bool readHtmlXml( QgsLayoutItemHtml *layoutItem,
const QDomElement &itemElem,
const QgsProject *project );

static bool readOldComposerObjectXml( QgsLayoutItem *layoutItem, const QDomElement &itemElem );
static bool readOldComposerObjectXml( QgsLayoutObject *layoutItem, const QDomElement &itemElem );

static void readOldDataDefinedPropertyMap( const QDomElement &itemElem,
QgsPropertyCollection &dataDefinedProperties );
@@ -205,7 +210,7 @@ class CORE_EXPORT QgsCompositionConverter
static bool readXml( QgsLayoutItem *layoutItem, const QDomElement &itemElem );

//! Make some common import adjustments
static void adjustPos( QgsLayout *layout, QgsLayoutItem *layoutItem, QDomNode &itemNode, QPointF *position, bool &pasteInPlace, int zOrderOffset, QPointF &pasteShiftPos, int &pageNumber );
static void adjustPos( QgsPrintLayout *layout, QgsLayoutItem *layoutItem, QPointF *position, bool &pasteInPlace, int zOrderOffset, QPointF &pasteShiftPos, int &pageNumber );

//! Restore general composer item properties
static void restoreGeneralComposeItemProperties( QgsLayoutItem *layoutItem, const QDomElement &itemElem );
@@ -195,7 +195,7 @@ bool QgsLayoutManager::readXml( const QDomElement &element, const QDomDocument &
QDomNodeList compositionNodes = composerNodes.at( i ).toElement().elementsByTagName( QStringLiteral( "Composition" ) );
for ( int j = 0; j < compositionNodes.size(); ++j )
{
std::unique_ptr< QgsLayout > l( QgsCompositionConverter::createLayoutFromCompositionXml( compositionNodes.at( j ).toElement(), mProject ) );
std::unique_ptr< QgsPrintLayout > l( QgsCompositionConverter::createLayoutFromCompositionXml( compositionNodes.at( j ).toElement(), mProject ) );
if ( l )
{
if ( l->name().isEmpty() )
@@ -244,6 +244,7 @@ class CORE_EXPORT QgsLayoutObject: public QObject, public QgsExpressionContextGe
static void initPropertyDefinitions();

friend class TestQgsLayoutObject;
friend class QgsCompositionConverter;
};

#endif //QGSLAYOUTOBJECT_H

0 comments on commit 2b2dae8

Please sign in to comment.
You can’t perform that action at this time.