File indexing completed on 2024-05-12 16:29:03

0001 /*
0002  * This file is part of Office 2007 Filters for Calligra
0003  *
0004  * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
0005  *
0006  * Contact: Suresh Chande suresh.chande@nokia.com
0007  *
0008  * This library is free software; you can redistribute it and/or
0009  * modify it under the terms of the GNU Lesser General Public License
0010  * version 2.1 as published by the Free Software Foundation.
0011  *
0012  * This library is distributed in the hope that it will be useful, but
0013  * WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0015  * Lesser General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General Public
0018  * License along with this library; if not, write to the Free Software
0019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
0020  * 02110-1301 USA
0021  *
0022  */
0023 
0024 #ifndef MSOOXMLCOMMONREADER_H
0025 #define MSOOXMLCOMMONREADER_H
0026 
0027 #include <KoGenStyle.h>
0028 #include <styles/KoCharacterStyle.h>
0029 #include <styles/KoListLevelProperties.h>
0030 
0031 #include "MsooXmlReader.h"
0032 #include "MsooXmlUtils.h"
0033 
0034 namespace MSOOXML
0035 {
0036 
0037 //! A class reading generic parts of MSOOXML main document's markup.
0038 class KOMSOOXML_EXPORT MsooXmlCommonReader : public MsooXmlReader
0039 {
0040 protected:
0041     explicit MsooXmlCommonReader(KoOdfWriters *writers);
0042 
0043     MsooXmlCommonReader(QIODevice* io, KoOdfWriters *writers);
0044 
0045     ~MsooXmlCommonReader() override;
0046 
0047     // -- for read_p()
0048     enum read_p_arg {
0049         read_p_Skip
0050     };
0051     Q_DECLARE_FLAGS(read_p_args, read_p_arg)
0052     read_p_args m_read_p_args;
0053 
0054     KoGenStyle* m_currentDrawStyle; //! used by all classes that need a graphics style.
0055     QList<KoGenStyle*>  m_drawStyleStack;
0056     KoGenStyle m_currentGradientStyle;
0057     void pushCurrentDrawStyle(KoGenStyle *newStyle);
0058     void popCurrentDrawStyle();
0059 
0060     //! Used for creating style in w:pPr (style:style/\@style:name attr)
0061     KoGenStyle m_currentParagraphStyle;
0062 
0063     void setupParagraphStyle();
0064 
0065     KoGenStyle m_currentTextStyle;
0066     KoCharacterStyle* m_currentTextStyleProperties;
0067 
0068     KoGenStyle m_currentListStyle;
0069     MSOOXML::Utils::ParagraphBulletProperties m_currentBulletProperties;
0070     // Properties for potentially all 9 lvls which are possible
0071     QMap<int, MSOOXML::Utils::ParagraphBulletProperties> m_currentCombinedBulletProperties;
0072     QMap<int, KoGenStyle> m_currentCombinedParagraphStyles;
0073     QMap<int, KoGenStyle> m_currentCombinedTextStyles;
0074 
0075     //! Style (from styles.xml) to apply to the current paragraph or similar element, set by read_pStyle()
0076     QString m_currentStyleName;
0077 
0078     bool isDefaultTocStyle(const QString& name) const;
0079 
0080     //! Adds reference to a file in the ODF document to manifest.xml
0081     //! The media-type attribute is based on the extension of @p path.
0082     void addManifestEntryForFile(const QString& path);
0083 
0084     //! Adds manifest entry for "Pictures/"
0085     void addManifestEntryForPicturesDir();
0086 
0087     //! value of recent pPr_lvl attribute; set by read_pPr()
0088     uint m_pPr_lvl;
0089 
0090     bool m_paragraphStyleNameWritten; //!< set by setupParagraphStyle()
0091 
0092     bool m_addManifestEntryForPicturesDirExecuted;
0093 
0094     bool m_moveToStylesXml;
0095 
0096     QSize m_imageSize;
0097 
0098     QSet<QString> m_copiedFiles; //!< collects source names to avoid multiple copying of media files
0099 
0100 //    //! Used for creating style names (style:style/@style:name attr)
0101 //    //! To achieve this, in XSLT it generate-id(.) for w:p is used.
0102 //    ////! Starts with 1. Updated in read_p();
0103 //    uint m_currentParagraphStyleNumber;
0104 //    QString currentParagraphStyleName() const;
0105 private:
0106     Q_DISABLE_COPY(MsooXmlCommonReader)
0107 
0108     void init();
0109 };
0110 
0111 }
0112 
0113 #endif