1 /* 2 * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> 3 * Copyright (c) 2005 C. Boemann <cbo@boemann.dk> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 #ifndef KIS_KRA_SAVEXML_VISITOR_H_ 20 #define KIS_KRA_SAVEXML_VISITOR_H_ 21 22 #include <QDomDocument> 23 #include <QDomElement> 24 #include <QStringList> 25 26 #include "kis_node_visitor.h" 27 #include "kis_types.h" 28 #include "kritalibkra_export.h" 29 30 class KRITALIBKRA_EXPORT KisSaveXmlVisitor : public KisNodeVisitor 31 { 32 public: 33 KisSaveXmlVisitor(QDomDocument doc, const QDomElement & element, quint32 &count, const QString &url, bool root); 34 35 void setSelectedNodes(vKisNodeSP selectedNodes); 36 37 using KisNodeVisitor::visit; 38 39 QStringList errorMessages() const; 40 41 public: 42 visit(KisNode *)43 bool visit(KisNode*) override { 44 return true; 45 } 46 bool visit(KisExternalLayer *) override; 47 bool visit(KisPaintLayer *layer) override; 48 bool visit(KisGroupLayer *layer) override; 49 bool visit(KisAdjustmentLayer* layer) override; 50 bool visit(KisGeneratorLayer *layer) override; 51 bool visit(KisCloneLayer *layer) override; 52 bool visit(KisFilterMask *mask) override; 53 bool visit(KisTransformMask *mask) override; 54 bool visit(KisTransparencyMask *mask) override; 55 bool visit(KisSelectionMask *mask) override; 56 bool visit(KisColorizeMask *mask) override; 57 nodeFileNames()58 QMap<const KisNode*, QString> nodeFileNames() { 59 return m_nodeFileNames; 60 } 61 keyframeFileNames()62 QMap<const KisNode*, QString> keyframeFileNames() { 63 return m_keyframeFileNames; 64 } 65 66 public: 67 QDomElement savePaintLayerAttributes(KisPaintLayer *layer, QDomDocument &doc); 68 69 // used by EXR to save properties of Krita layers inside .exr 70 static void loadPaintLayerAttributes(const QDomElement &el, KisPaintLayer *layer); 71 72 private: 73 static void loadLayerAttributes(const QDomElement &el, KisLayer *layer); 74 75 private: 76 77 void saveLayer(QDomElement & el, const QString & layerType, const KisLayer * layer); 78 void saveMask(QDomElement & el, const QString & maskType, const KisMaskSP mask); 79 bool saveMasks(KisNode * node, QDomElement & layerElement); 80 void saveNodeKeyframes(const KisNode *node, QString filename, QDomElement& el); 81 82 friend class KisKraSaveXmlVisitorTest; 83 84 vKisNodeSP m_selectedNodes; 85 QMap<const KisNode*, QString> m_nodeFileNames; 86 QMap<const KisNode*, QString> m_keyframeFileNames; 87 QDomDocument m_doc; 88 QDomElement m_elem; 89 quint32 &m_count; 90 QString m_url; 91 bool m_root; 92 QStringList m_errorMessages; 93 94 bool saveReferenceImagesLayer(KisExternalLayer *layer); 95 }; 96 97 #endif 98 99