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 _FILLMANAGER_HXX_
24 #define _FILLMANAGER_HXX_
25 
26 #include <map>
27 #include <vector>
28 
29 #include <librevenge/librevenge.h>
30 
31 #include "FilterInternal.hxx"
32 
33 class OdfDocumentHandler;
34 
35 class FillManager
36 {
37 public:
FillManager()38 	FillManager() : mBitmapStyles(), mGradientStyles(), mHatchStyles(), mOpacityStyles(),
39 		mBitmapNameMap(), mGradientNameMap(), mDisplayGradientNameMap(),
40 		mHatchNameMap(), mDisplayHatchNameMap(), mOpacityNameMap(), mDisplayOpacityNameMap()
41 	{}
42 
43 	void clean();
44 
45 	// write fill definition to style
46 	void write(OdfDocumentHandler *pHandler) const;
47 
48 	/** append the fill into the element */
49 	void addProperties(librevenge::RVNGPropertyList const &style, librevenge::RVNGPropertyList &element);
50 
51 private:
52 	// return a bitmap
53 	librevenge::RVNGString getStyleNameForBitmap(librevenge::RVNGString const &bitmap);
54 	librevenge::RVNGString getStyleNameForGradient(librevenge::RVNGPropertyList const &style,
55 	                                               bool &needCreateOpacityStyle);
56 	librevenge::RVNGString getStyleNameForHatch(librevenge::RVNGPropertyList const &style);
57 	librevenge::RVNGString getStyleNameForOpacity(librevenge::RVNGPropertyList const &style);
58 
59 private:
60 	// graphics styles
61 	libodfgen::DocumentElementVector mBitmapStyles;
62 	libodfgen::DocumentElementVector mGradientStyles;
63 	libodfgen::DocumentElementVector mHatchStyles;
64 	libodfgen::DocumentElementVector mOpacityStyles;
65 
66 	// bitmap content -> style name
67 	std::map<librevenge::RVNGString, librevenge::RVNGString> mBitmapNameMap;
68 	// gradient hash -> style name
69 	std::map<librevenge::RVNGString, librevenge::RVNGString> mGradientNameMap;
70 	// display style name -> gradient style name
71 	std::map<librevenge::RVNGString, librevenge::RVNGString> mDisplayGradientNameMap;
72 	// hatch hash -> style name
73 	std::map<librevenge::RVNGString, librevenge::RVNGString> mHatchNameMap;
74 	// display style name -> hatch style name
75 	std::map<librevenge::RVNGString, librevenge::RVNGString> mDisplayHatchNameMap;
76 	// opacity hash -> style name
77 	std::map<librevenge::RVNGString, librevenge::RVNGString> mOpacityNameMap;
78 	// display style name -> opacity style name
79 	std::map<librevenge::RVNGString, librevenge::RVNGString> mDisplayOpacityNameMap;
80 };
81 
82 #endif
83 
84 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
85