1 /* 2 * This file is part of Office 2007 Filters for Calligra 3 * 4 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 5 * 6 * Contact: Suresh Chande suresh.chande@nokia.com 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public License 10 * version 2.1 as published by the Free Software Foundation. 11 * 12 * This library is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 20 * 02110-1301 USA 21 * 22 */ 23 24 #ifndef MSOOXMLTHEME_H 25 #define MSOOXMLTHEME_H 26 27 #include <QHash> 28 #include <QVector> 29 #include <QColor> 30 #include <QMap> 31 32 #include <KoGenStyles.h> 33 34 #include "komsooxml_export.h" 35 36 37 namespace MSOOXML 38 { 39 40 class DrawingMLColorSchemeItem; 41 class DrawingMLColorSchemeSystemItem; 42 43 //! @todo add other classes inheriting DrawingMLColorSchemeItemBase 44 class KOMSOOXML_EXPORT DrawingMLColorSchemeItemBase 45 { 46 public: 47 DrawingMLColorSchemeItemBase(); 48 virtual ~DrawingMLColorSchemeItemBase(); 49 DrawingMLColorSchemeItem* toColorItem(); 50 DrawingMLColorSchemeSystemItem* toSystemItem(); 51 virtual QColor value() const = 0; 52 virtual DrawingMLColorSchemeItemBase* clone() const = 0; 53 }; 54 55 class KOMSOOXML_EXPORT DrawingMLColorSchemeItem : public DrawingMLColorSchemeItemBase 56 { 57 public: 58 DrawingMLColorSchemeItem(); value()59 QColor value() const override { return color; } 60 QColor color; clone()61 DrawingMLColorSchemeItem* clone() const override { return new DrawingMLColorSchemeItem(*this); } 62 }; 63 64 class KOMSOOXML_EXPORT DrawingMLColorSchemeSystemItem : public DrawingMLColorSchemeItemBase 65 { 66 public: 67 DrawingMLColorSchemeSystemItem(); 68 QColor value() const override; 69 70 QColor lastColor; 71 QString systemColor; //!< ST_SystemColorVal (§20.1.10.58).; clone()72 DrawingMLColorSchemeSystemItem* clone() const override { return new DrawingMLColorSchemeSystemItem(*this); } 73 }; 74 75 typedef QHash<QString, DrawingMLColorSchemeItemBase*> DrawingMLColorSchemeItemHash; 76 77 //! Implements color scheme, based on hash. All items are owned by this object. 78 class KOMSOOXML_EXPORT DrawingMLColorScheme : public DrawingMLColorSchemeItemHash 79 { 80 public: 81 DrawingMLColorScheme(); 82 ~DrawingMLColorScheme(); 83 value(const QString & name)84 DrawingMLColorSchemeItemBase* value(const QString& name) const { 85 return DrawingMLColorSchemeItemHash::value(name); 86 } 87 88 /*! @return color value for index. Needed because while PPTX uses lookup by 89 name: value(QString&), XLSX uses lookup by index. When index is 90 invalid, 0 is returned. */ 91 DrawingMLColorSchemeItemBase* value(int index) const; 92 93 DrawingMLColorScheme(const DrawingMLColorScheme& scheme); 94 DrawingMLColorScheme& operator=(const DrawingMLColorScheme& scheme); 95 //! Name of the color scheme 96 QString name; 97 }; 98 99 //! Font set for majorFont and minorFont. 100 //! @todo add more support for latin, ea and cs: charser, panose, pitchfamily attributes (21.1.2.3.3) 101 class KOMSOOXML_EXPORT DrawingMLFontSet 102 { 103 public: 104 DrawingMLFontSet(); 105 //! A (script->typeface) hash with font definitions (20.1.4.1.16.) 106 QHash<QString, QString> typefacesForScripts; 107 108 //! Specifies that a Latin font be used for a specific run of text. 109 QString latinTypeface; 110 111 //! The possible values for this attribute are defined by the ST_TextTypeface simple type 112 //! (§20.1.10.81). 113 QString eaTypeface; 114 //! The possible values for this attribute are defined by the ST_TextTypeface simple type 115 //! (§20.1.10.81). 116 QString csTypeface; 117 }; 118 119 //! Defines the font scheme within the theme 120 //! The font scheme consists of a pair of major and minor fonts for which to use in a document.s 121 class KOMSOOXML_EXPORT DrawingMLFontScheme 122 { 123 public: 124 DrawingMLFontScheme(); 125 DrawingMLFontSet majorFonts; 126 DrawingMLFontSet minorFonts; 127 QString name; 128 }; 129 130 131 class KOMSOOXML_EXPORT DrawingMLFillBase 132 { 133 public: 134 virtual ~DrawingMLFillBase(); 135 // This function will create the fill style and fill the appropriate styles 136 // and filePath if needed. 137 // Number is used to index to correct style, color is the color which should be used when making the styles 138 virtual void writeStyles(KoGenStyles& styles, KoGenStyle *graphicStyle, const QColor &color) = 0; 139 140 virtual DrawingMLFillBase* clone() const = 0; 141 }; 142 143 class KOMSOOXML_EXPORT DrawingMLSolidFill : public DrawingMLFillBase 144 { 145 public: 146 void writeStyles(KoGenStyles& styles, KoGenStyle *graphicStyle, const QColor &color) override; 147 clone()148 DrawingMLSolidFill* clone() const override { return new DrawingMLSolidFill(*this); } 149 }; 150 151 class KOMSOOXML_EXPORT DrawingMLBlipFill : public DrawingMLFillBase 152 { 153 public: 154 explicit DrawingMLBlipFill(const QString &filePath); 155 void writeStyles(KoGenStyles& styles, KoGenStyle *graphicStyle, const QColor &color) override; 156 clone()157 DrawingMLBlipFill* clone() const override { return new DrawingMLBlipFill(*this); } 158 159 private: 160 QString m_filePath; 161 }; 162 163 class KOMSOOXML_EXPORT DrawingMLGradientFill : public DrawingMLFillBase 164 { 165 public: 166 // Simplified gradient constructor 167 DrawingMLGradientFill(const QVector<qreal> &shadeModifier, const QVector<qreal> &tintModifier, const QVector<qreal> &satModifier, 168 const QVector<int> &alphaModifier, const QVector<int> &gradPositions, const QString &gradAngle); 169 void writeStyles(KoGenStyles& styles, KoGenStyle *graphicStyle, const QColor &color) override; 170 clone()171 DrawingMLGradientFill* clone() const override { return new DrawingMLGradientFill(*this); } 172 173 private: 174 QVector<qreal> m_shadeModifier; 175 QVector<qreal> m_tintModifier; 176 QVector<qreal> m_satModifier; 177 QVector<int> m_alphaModifier; 178 QVector<int> m_gradPosition; 179 QString m_gradAngle; 180 }; 181 182 class KOMSOOXML_EXPORT DrawingMLFormatScheme 183 { 184 public: 185 186 DrawingMLFormatScheme(); 187 ~DrawingMLFormatScheme(); 188 QString name; 189 190 DrawingMLFormatScheme(const DrawingMLFormatScheme& format); 191 DrawingMLFormatScheme& operator=(const DrawingMLFormatScheme& format); 192 193 QMap<int, DrawingMLFillBase*> fillStyles; 194 195 //! Stores the three line styles for use within a theme. 196 QList<KoGenStyle> lnStyleLst; 197 }; 198 199 //! Defines a single DrawingML theme. 200 //! @todo support objectDefaults and extraClrSchemeLst 201 class KOMSOOXML_EXPORT DrawingMLTheme 202 { 203 public: 204 DrawingMLTheme(); 205 QString name; 206 DrawingMLColorScheme colorScheme; 207 DrawingMLFontScheme fontScheme; 208 DrawingMLFormatScheme formatScheme; 209 }; 210 211 212 } // namespace MSOOXML 213 214 #endif //MSOOXMLTHEME_H 215