libs/flake

KoShapeSavingContext.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2004-2006 David Faure <faure@kde.org>
00003    Copyright (C) 2007-2008 Thorsten Zachmann <zachmann@kde.org>
00004    Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KOSHAPESAVINGCONTEXT_H
00023 #define KOSHAPESAVINGCONTEXT_H
00024 
00025 #include "flake_export.h"
00026 
00027 #include <QImage>
00028 #include <QMatrix>
00029 
00030 class KoShape;
00031 class KoXmlWriter;
00032 class KoGenStyles;
00033 class KoDataCenterBase;
00034 class KoEmbeddedDocumentSaver;
00035 class KoImageData;
00036 class KoShapeLayer;
00037 class KoStore;
00038 class KoSharedSavingData;
00039 class KoShapeSavingContextPrivate;
00040 
00044 class FLAKE_EXPORT KoShapeSavingContext
00045 {
00046 public:
00048     enum ShapeSavingOption {
00054         PresentationShape = 1,
00059         DrawId = 2,
00063         AutoStyleInStyleXml = 4,
00067         UniqueMasterPages = 8
00068     };
00069     Q_DECLARE_FLAGS(ShapeSavingOptions, ShapeSavingOption)
00070 
00071     
00077     KoShapeSavingContext(KoXmlWriter &xmlWriter, KoGenStyles &mainStyles,
00078                          KoEmbeddedDocumentSaver &embeddedSaver);
00079     virtual ~KoShapeSavingContext();
00080 
00086     KoXmlWriter &xmlWriter();
00087 
00096     void setXmlWriter(KoXmlWriter &xmlWriter);
00097 
00103     KoGenStyles &mainStyles();
00104 
00110     KoEmbeddedDocumentSaver &embeddedSaver();
00111 
00117     bool isSet(ShapeSavingOption option) const;
00118 
00124     void setOptions(ShapeSavingOptions options);
00125 
00127     void addOption(ShapeSavingOption option);
00128 
00130     void removeOption(ShapeSavingOption option);
00131 
00137     ShapeSavingOptions options() const;
00138 
00149     QString drawId(const KoShape *shape, bool insert = true);
00150 
00159     void clearDrawIds();
00160 
00165     void addLayerForSaving(const KoShapeLayer *layer);
00166 
00170     void saveLayerSet(KoXmlWriter &xmlWriter) const;
00171 
00177     void clearLayers();
00178 
00182     QString imageHref(KoImageData *image);
00183 
00190     QString imageHref(QImage &image);
00191 
00195     QMap<qint64, QString> imagesToSave();
00196 
00200     void addDataCenter(KoDataCenterBase *dataCenter);
00201 
00208     bool saveDataCenter(KoStore *store, KoXmlWriter *manifestWriter);
00209 
00227     void addSharedData(const QString &id, KoSharedSavingData *data);
00228 
00237     KoSharedSavingData *sharedData(const QString &id) const;
00238 
00239     /*
00240      * Add an offset that will be applied to the shape position when saved
00241      *
00242      * This is needed e.g. for shapes anchored to a text shape as the position is
00243      * saved as offset to the anchor.
00244      *
00245      * @param shape The shape for which the offset should be added.
00246      * @param matrix The offset which should be applied on saving the position.
00247      */
00248     void addShapeOffset(const KoShape *shape, const QMatrix &matrix);
00249 
00255     void removeShapeOffset(const KoShape *shape);
00256 
00263     QMatrix shapeOffset(const KoShape *shape) const;
00264 
00265 private:
00266     KoShapeSavingContextPrivate *d;
00267 };
00268 
00269 Q_DECLARE_OPERATORS_FOR_FLAGS(KoShapeSavingContext::ShapeSavingOptions)
00270 
00271 #endif // KOSHAPESAVINGCONTEXT_H