File indexing completed on 2025-02-16 10:53:35
0001 /* 0002 * This file is part of Office 2007 Filters for Calligra 0003 * 0004 * SPDX-FileCopyrightText: 2009 Nokia Corporation and /or its subsidiary(-ies). 0005 * 0006 * Contact: Suresh Chande suresh.chande@nokia.com 0007 * 0008 * SPDX-License-Identifier: LGPL-2.1-only 0009 * 0010 */ 0011 0012 #ifndef MSOOXMLCOMMONREADER_H 0013 #define MSOOXMLCOMMONREADER_H 0014 0015 #include <KoGenStyle.h> 0016 #include <styles/KoCharacterStyle.h> 0017 #include <styles/KoListLevelProperties.h> 0018 0019 #include "MsooXmlReader.h" 0020 #include "MsooXmlUtils.h" 0021 0022 namespace MSOOXML 0023 { 0024 0025 //! A class reading generic parts of MSOOXML main document's markup. 0026 class KOMSOOXML_EXPORT MsooXmlCommonReader : public MsooXmlReader 0027 { 0028 protected: 0029 explicit MsooXmlCommonReader(KoOdfWriters *writers); 0030 0031 MsooXmlCommonReader(QIODevice* io, KoOdfWriters *writers); 0032 0033 ~MsooXmlCommonReader() override; 0034 0035 // -- for read_p() 0036 enum read_p_arg { 0037 read_p_Skip 0038 }; 0039 Q_DECLARE_FLAGS(read_p_args, read_p_arg) 0040 read_p_args m_read_p_args; 0041 0042 KoGenStyle* m_currentDrawStyle; //! used by all classes that need a graphics style. 0043 QList<KoGenStyle*> m_drawStyleStack; 0044 KoGenStyle m_currentGradientStyle; 0045 void pushCurrentDrawStyle(KoGenStyle *newStyle); 0046 void popCurrentDrawStyle(); 0047 0048 //! Used for creating style in w:pPr (style:style/\@style:name attr) 0049 KoGenStyle m_currentParagraphStyle; 0050 0051 void setupParagraphStyle(); 0052 0053 KoGenStyle m_currentTextStyle; 0054 KoCharacterStyle* m_currentTextStyleProperties; 0055 0056 KoGenStyle m_currentListStyle; 0057 MSOOXML::Utils::ParagraphBulletProperties m_currentBulletProperties; 0058 // Properties for potentially all 9 lvls which are possible 0059 QMap<int, MSOOXML::Utils::ParagraphBulletProperties> m_currentCombinedBulletProperties; 0060 QMap<int, KoGenStyle> m_currentCombinedParagraphStyles; 0061 QMap<int, KoGenStyle> m_currentCombinedTextStyles; 0062 0063 //! Style (from styles.xml) to apply to the current paragraph or similar element, set by read_pStyle() 0064 QString m_currentStyleName; 0065 0066 bool isDefaultTocStyle(const QString& name) const; 0067 0068 //! Adds reference to a file in the ODF document to manifest.xml 0069 //! The media-type attribute is based on the extension of @p path. 0070 void addManifestEntryForFile(const QString& path); 0071 0072 //! Adds manifest entry for "Pictures/" 0073 void addManifestEntryForPicturesDir(); 0074 0075 //! value of recent pPr_lvl attribute; set by read_pPr() 0076 uint m_pPr_lvl; 0077 0078 bool m_paragraphStyleNameWritten; //!< set by setupParagraphStyle() 0079 0080 bool m_addManifestEntryForPicturesDirExecuted; 0081 0082 bool m_moveToStylesXml; 0083 0084 QSize m_imageSize; 0085 0086 QSet<QString> m_copiedFiles; //!< collects source names to avoid multiple copying of media files 0087 0088 // //! Used for creating style names (style:style/@style:name attr) 0089 // //! To achieve this, in XSLT it generate-id(.) for w:p is used. 0090 // ////! Starts with 1. Updated in read_p(); 0091 // uint m_currentParagraphStyleNumber; 0092 // QString currentParagraphStyleName() const; 0093 private: 0094 Q_DISABLE_COPY(MsooXmlCommonReader) 0095 0096 void init(); 0097 }; 0098 0099 } 0100 0101 #endif