File indexing completed on 2024-05-12 16:37:11

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2005 David Faure <faure@kde.org>
0003  * Copyright (C) 2007 Thomas Zander <zander@kde.org>
0004  * Copyright (C) 2007-2008 Sebastian Sauer <mail@dipe.org>
0005  * Copyright (C) 2007-2008 Pierre Ducroquet <pinaraf@gmail.com>
0006  * Copyright (C) 2007-2008 Thorsten Zachmann <zachmann@kde.org>
0007  *
0008  * This library is free software; you can redistribute it and/or
0009  * modify it under the terms of the GNU Library General Public
0010  * License as published by the Free Software Foundation; either
0011  * version 2 of the License, or (at your option) any later version.
0012  *
0013  * This library is distributed in the hope that it will be useful,
0014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016  * Library General Public License for more details.
0017  *
0018  * You should have received a copy of the GNU Library General Public License
0019  * along with this library; see the file COPYING.LIB.  If not, write to
0020  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0021  * Boston, MA 02110-1301, USA.
0022  */
0023 
0024 #ifndef KWODFWRITER_H
0025 #define KWODFWRITER_H
0026 
0027 #include "KWPageStyle.h"
0028 
0029 #include <KoRTree.h>
0030 
0031 class KWDocument;
0032 class KoOdfWriteStore;
0033 class KoShapeSavingContext;
0034 class KoEmbeddedDocumentSaver;
0035 class KWTextFrameSet;
0036 class KWPage;
0037 
0038 class KoStore;
0039 
0040 /**
0041  * Class that has a lot of the OpenDocument (ODF) saving code for Words.
0042  */
0043 class KWOdfWriter : public QObject
0044 {
0045     Q_OBJECT
0046 public:
0047 
0048     /**
0049      * Constructor
0050      * @param document the document this writer will work for.
0051      */
0052     explicit KWOdfWriter(KWDocument *document);
0053 
0054     /**
0055      * Destructor
0056      */
0057     ~KWOdfWriter() override;
0058 
0059     /**
0060      *  @brief Writes an OASIS OpenDocument to a store.
0061      *  This implements the KoDocument::saveOdf method.
0062      */
0063     bool save(KoOdfWriteStore &odfStore, KoEmbeddedDocumentSaver &embeddedSaver);
0064 
0065 private:
0066     void saveHeaderFooter(KoShapeSavingContext &context);
0067     QByteArray serializeHeaderFooter(KoShapeSavingContext &context, KWTextFrameSet* fs);
0068 
0069     void calculateZindexOffsets();
0070     void addShapeToTree(KoShape *shape);
0071 
0072     bool saveOdfSettings(KoStore *store);
0073 
0074     /// The Words document.
0075     KWDocument *m_document;
0076     QHash<KWPageStyle, QString> m_masterPages;
0077     /// Since ODF requires zindexes >= 0 and we can have negative ones we will calculate an offset per
0078     /// page and store that here.
0079     QHash<KWPage, int> m_zIndexOffsets;
0080     KoRTree<KoShape *> m_shapeTree;
0081 };
0082 
0083 #endif