1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ 2 /* libodfgen 3 * Version: MPL 2.0 / LGPLv2.1+ 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * Major Contributor(s): 10 * Copyright (C) 2002-2004 William Lachance (wrlach@gmail.com) 11 * Copyright (C) 2004 Fridrich Strba (fridrich.strba@bluewin.ch) 12 * 13 * For minor contributions see the git repository. 14 * 15 * Alternatively, the contents of this file may be used under the terms 16 * of the GNU Lesser General Public License Version 2.1 or later 17 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are 18 * applicable instead of those above. 19 * 20 * For further information visit http://libwpd.sourceforge.net 21 */ 22 23 #ifndef _GRAPHICSTYLE_HXX_ 24 #define _GRAPHICSTYLE_HXX_ 25 26 #include <map> 27 #include <vector> 28 29 #include <librevenge/librevenge.h> 30 31 #include "FilterInternal.hxx" 32 33 #include "Style.hxx" 34 35 class FillManager; 36 class OdfDocumentHandler; 37 38 //! graphic style class 39 class GraphicStyle : public Style 40 { 41 public: 42 //! constructor 43 GraphicStyle(const librevenge::RVNGPropertyList &xPropList, const char *psName, Style::Zone zone); 44 //! destructor 45 ~GraphicStyle() override; 46 //! write content to the document handler 47 void write(OdfDocumentHandler *pHandler) const override; 48 49 private: 50 librevenge::RVNGPropertyList mPropList; 51 }; 52 53 54 class GraphicStyleManager : public StyleManager 55 { 56 public: GraphicStyleManager(FillManager & fillManager)57 explicit GraphicStyleManager(FillManager &fillManager) 58 : mFillManager(fillManager) 59 , mMarkerStyles(), mStrokeDashStyles(), mStyles() 60 , mMarkerNameMap(), mStrokeDashNameMap(), mDisplayStrokeDashNameMap(), mStyleNameMap() 61 , mDisplayNameMap() {} ~GraphicStyleManager()62 ~GraphicStyleManager() override 63 { 64 clean(); 65 } 66 void clean() override; 67 //! write all write(OdfDocumentHandler * pHandler) const68 void write(OdfDocumentHandler *pHandler) const override 69 { 70 write(pHandler, Style::Z_Style); 71 write(pHandler, Style::Z_StyleAutomatic); 72 write(pHandler, Style::Z_ContentAutomatic); 73 } 74 // write automatic/name/... style 75 void write(OdfDocumentHandler *pHandler, Style::Zone zone) const; 76 77 /** find a style ( or add it to the stored styles) and returns the style name */ 78 librevenge::RVNGString findOrAdd(librevenge::RVNGPropertyList const &propList, Style::Zone zone=Style::Z_Unknown); 79 //! return the file name corresponding to a display name 80 librevenge::RVNGString getFinalDisplayName(const librevenge::RVNGString &displayName); 81 82 /** append the graphic in the element, ie. the stroke, pattern, bitmap, marker properties */ 83 void addGraphicProperties(librevenge::RVNGPropertyList const &style, librevenge::RVNGPropertyList &element); 84 /** append the frame, ... properties in the element, ie. all properties excepted the graphic properties */ 85 static void addFrameProperties(librevenge::RVNGPropertyList const &propList, librevenge::RVNGPropertyList &element); 86 87 protected: 88 FillManager &mFillManager; 89 90 librevenge::RVNGString getStyleNameForMarker(librevenge::RVNGPropertyList const &style, bool startMarker); 91 librevenge::RVNGString getStyleNameForStrokeDash(librevenge::RVNGPropertyList const &style); 92 // graphics styles 93 libodfgen::DocumentElementVector mMarkerStyles; 94 libodfgen::DocumentElementVector mStrokeDashStyles; 95 std::vector<std::shared_ptr<GraphicStyle> > mStyles; 96 97 // marker hash -> style name 98 std::map<librevenge::RVNGString, librevenge::RVNGString> mMarkerNameMap; 99 // stroke dash hash -> style name 100 std::map<librevenge::RVNGString, librevenge::RVNGString> mStrokeDashNameMap; 101 // display style name -> stroke dash style name 102 std::map<librevenge::RVNGString, librevenge::RVNGString> mDisplayStrokeDashNameMap; 103 // style hash -> style name 104 std::map<librevenge::RVNGString, librevenge::RVNGString> mStyleNameMap; 105 // display name -> style name 106 std::map<librevenge::RVNGString, librevenge::RVNGString> mDisplayNameMap; 107 }; 108 109 110 111 #endif 112 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ 113