File indexing completed on 2025-02-23 04:05:52

0001 /* This file is part of the KDE project
0002    SPDX-FileCopyrightText: 2002 Lars Siebold <khandha5@gmx.net>
0003    SPDX-FileCopyrightText: 2002 Werner Trobin <trobin@kde.org>
0004    SPDX-FileCopyrightText: 2002 Lennart Kudling <kudling@kde.org>
0005    SPDX-FileCopyrightText: 2002-2003, 2005 Rob Buis <buis@kde.org>
0006    SPDX-FileCopyrightText: 2005 Boudewijn Rempt <boud@valdyas.org>
0007    SPDX-FileCopyrightText: 2005 Raphael Langerhorst <raphael.langerhorst@kdemail.net>
0008    SPDX-FileCopyrightText: 2005 Thomas Zander <zander@kde.org>
0009    SPDX-FileCopyrightText: 2005, 2008 Jan Hambrecht <jaham@gmx.net>
0010    SPDX-FileCopyrightText: 2006 Inge Wallin <inge@lysator.liu.se>
0011    SPDX-FileCopyrightText: 2006 Laurent Montel <montel@kde.org>
0012 
0013    SPDX-License-Identifier: LGPL-2.0-or-later
0014 */
0015 
0016 #ifndef SVGWRITER_H
0017 #define SVGWRITER_H
0018 
0019 #include "kritaflake_export.h"
0020 #include <QList>
0021 #include <QSizeF>
0022 
0023 class SvgSavingContext;
0024 class KoShapeLayer;
0025 class KoShapeGroup;
0026 class KoShape;
0027 class KoPathShape;
0028 class QIODevice;
0029 class QString;
0030 
0031 /// Implements exporting shapes to SVG
0032 class KRITAFLAKE_EXPORT SvgWriter
0033 {
0034 public:
0035     /// Creates svg writer to export specified layers
0036     SvgWriter(const QList<KoShapeLayer*> &layers);
0037 
0038     /// Creates svg writer to export specified shapes
0039     SvgWriter(const QList<KoShape*> &toplevelShapes);
0040 
0041     /// Destroys the svg writer
0042     virtual ~SvgWriter();
0043 
0044     /// Writes svg to specified output device
0045     bool save(QIODevice &outputDevice, const QSizeF &pageSize);
0046 
0047     /// Writes svg to the specified file
0048     bool save(const QString &filename, const QSizeF &pageSize, bool writeInlineImages);
0049 
0050     bool saveDetached(QIODevice &outputDevice);
0051 
0052     bool saveDetached(SvgSavingContext &savingContext);
0053 
0054     void setDocumentTitle(QString title);
0055     void setDocumentDescription(QString description);
0056 
0057 private:
0058     void saveShapes(const QList<KoShape*> shapes, SvgSavingContext &savingContext);
0059 
0060     void saveLayer(KoShapeLayer *layer, SvgSavingContext &context);
0061     void saveGroup(KoShapeGroup *group, SvgSavingContext &context);
0062     void saveShape(KoShape *shape, SvgSavingContext &context);
0063     void savePath(KoPathShape *path, SvgSavingContext &context);
0064     void saveGeneric(KoShape *shape, SvgSavingContext &context);
0065 
0066     QList<KoShape*> m_toplevelShapes;
0067     bool m_writeInlineImages;
0068     QString m_documentTitle;
0069     QString m_documentDescription;
0070 };
0071 
0072 #endif // SVGWRITER_H