Warning, file /office/calligra/libs/odf/KoOdfStylesReader.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 Copyright (C) 2004-2006 David Faure <faure@kde.org> 0003 Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net> 0004 Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org> 0005 0006 This library is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU Library General Public 0008 License version 2 as published by the Free Software Foundation. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef KOODFSTYLESREADER_H 0022 #define KOODFSTYLESREADER_H 0023 0024 #include <QHash> 0025 #include <QList> 0026 0027 #include <KoXmlReader.h> 0028 0029 #include "koodf_export.h" 0030 #include "KoOdfNumberStyles.h" 0031 #include "KoOdfNotesConfiguration.h" 0032 0033 class KoOdfLineNumberingConfiguration; 0034 class KoOdfBibliographyConfiguration; 0035 0036 /** 0037 * Repository of styles used during loading of OASIS/OOo file 0038 */ 0039 class KOODF_EXPORT KoOdfStylesReader 0040 { 0041 public: 0042 /// constructor 0043 KoOdfStylesReader(); 0044 /// destructor 0045 ~KoOdfStylesReader(); 0046 0047 /// Look into @p doc for styles and remember them 0048 /// @param doc document to look into 0049 /// @param stylesDotXml true when loading styles.xml, false otherwise 0050 void createStyleMap(const KoXmlDocument &doc, bool stylesDotXml); 0051 0052 /** 0053 * Look up a style by name. 0054 * This method can find styles defined by the tags "style:page-layout", 0055 * "style:presentation-page-layout", or "style:font-face". 0056 * Do NOT use this method for style:style styles. 0057 * 0058 * @param name the style name 0059 * @return the dom element representing the style, or an empty QString if it wasn't found. 0060 */ 0061 const KoXmlElement* findStyle(const QString &name) const; 0062 0063 /** 0064 * Looks up a style:style by name. 0065 * Searches in the list of custom styles first and then in the lists of automatic styles. 0066 * @param name the style name 0067 * @param family the style family (for a style:style, use 0 otherwise) 0068 * @return the dom element representing the style, or an empty QString if it wasn't found. 0069 */ 0070 const KoXmlElement* findStyle(const QString &name, const QString &family) const; 0071 0072 /** 0073 * Looks up a style:style by name. 0074 * 0075 * Searches in the list of custom styles first and then in the lists of automatic styles. 0076 * 0077 * @param name the style name 0078 * @param family the style family (for a style:style, use 0 otherwise) 0079 * @param stylesDotXml if true search the styles.xml auto-styles otherwise the content.xml ones 0080 * 0081 * @return the dom element representing the style, or an empty QString if it wasn't found. 0082 */ 0083 const KoXmlElement* findStyle(const QString &name, const QString &family, bool stylesDotXml) const; 0084 0085 /// Similar to findStyle but for custom styles only. 0086 const KoXmlElement *findStyleCustomStyle(const QString &name, const QString &family) const; 0087 0088 /** 0089 * Similar to findStyle but for auto-styles only. 0090 * \note Searches in styles.xml only! 0091 * \see findStyle() 0092 */ 0093 const KoXmlElement *findAutoStyleStyle(const QString &name, const QString &family) const; 0094 0095 /** 0096 * Similar to findStyle but for auto-styles only. 0097 * \note Searches in content.xml only! 0098 * \see findStyle() 0099 */ 0100 const KoXmlElement *findContentAutoStyle(const QString &name, const QString &family) const; 0101 0102 /// @return the default style for a given family ("graphic","paragraph","table" etc.) 0103 /// Returns 0 if no default style for this family is available 0104 KoXmlElement *defaultStyle(const QString &family) const; 0105 0106 /// @return the office:style element 0107 KoXmlElement officeStyle() const; 0108 0109 /// @return the draw:layer-set element 0110 KoXmlElement layerSet() const; 0111 0112 /// @return master pages ("style:master-page" elements), hashed by name 0113 QHash<QString, KoXmlElement*> masterPages() const; 0114 0115 /// @return all presentation page layouts ("presentation-page-layout" elements), hashed by name 0116 QHash<QString, KoXmlElement*> presentationPageLayouts() const; 0117 0118 /// @return all table templates("table-template" elements), template names may be duplicated 0119 QList<KoXmlElement *> tableTemplates() const; 0120 0121 /** 0122 * Get the draw styles for a specified type. 0123 * 0124 * @param drawType The type of the wanted drawStyles 0125 * Available types: gradient(returns gradient, linearGradient, radialGradient and conicalGradient styles), 0126 * hatch, fill-image, marker, stroke-dash, opacity 0127 * @return draw styles of the specified type, hashed by name 0128 */ 0129 QHash<QString, KoXmlElement*> drawStyles(const QString &drawType) const; 0130 0131 /// @return all custom styles ("style:style" elements) for a given family, hashed by name 0132 QHash<QString, KoXmlElement*> customStyles(const QString& family) const; 0133 0134 /** 0135 * Returns all auto-styles defined in styles.xml, if \p stylesDotXml is \c true , 0136 * or all in content.xml, if \p stylesDotXml is \c false . 0137 * \return all auto-styles ("style:style" elements) for a given family, hashed by name 0138 */ 0139 QHash<QString, KoXmlElement*> autoStyles(const QString& family, bool stylesDotXml = false) const; 0140 0141 typedef QHash<QString, QPair<KoOdfNumberStyles::NumericStyleFormat, KoXmlElement*> > DataFormatsMap; 0142 /// Value (date/time/number...) formats found while parsing styles. Used e.g. for fields. 0143 /// Key: format name. Value: 0144 DataFormatsMap dataFormats() const; 0145 0146 /** 0147 * Return the notes configuration for the given note class (footnote or endnote). 0148 * 0149 * Note that ODF supports different notes configurations for sections, but we don't 0150 * support that yet. 0151 */ 0152 KoOdfNotesConfiguration globalNotesConfiguration(KoOdfNotesConfiguration::NoteClass noteClass) const; 0153 0154 /** 0155 * return the line numbering configuration for this document. 0156 */ 0157 KoOdfLineNumberingConfiguration lineNumberingConfiguration() const; 0158 0159 /** 0160 * return the bibliography configuration for this document. 0161 */ 0162 KoOdfBibliographyConfiguration globalBibliographyConfiguration() const; 0163 0164 private: 0165 enum TypeAndLocation { 0166 CustomInStyles, ///< custom style located in styles.xml 0167 AutomaticInContent, ///< auto-style located in content.xml 0168 AutomaticInStyles ///< auto-style located in styles.xml 0169 }; 0170 /// Add styles to styles map 0171 void insertStyles(const KoXmlElement &styles, TypeAndLocation typeAndLocation = CustomInStyles); 0172 0173 void insertOfficeStyles(const KoXmlElement &styles); 0174 void insertStyle(const KoXmlElement &style, TypeAndLocation typeAndLocation); 0175 0176 KoOdfStylesReader(const KoOdfStylesReader &); // forbidden 0177 KoOdfStylesReader& operator=(const KoOdfStylesReader &); // forbidden 0178 0179 class Private; 0180 Private * const d; 0181 }; 0182 0183 #endif /* KOODFSTYLESREADER_H */