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-2003 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 /* "This product is not manufactured, approved, or supported by
24  * Corel Corporation or Corel Corporation Limited."
25  */
26 
27 #ifndef _NUMBERINGSTYLE_HXX_
28 #define _NUMBERINGSTYLE_HXX_
29 #include <librevenge/librevenge.h>
30 #include <map>
31 #include <string>
32 #include <vector>
33 
34 #include "FilterInternal.hxx"
35 
36 #include "Style.hxx"
37 
38 class OdfDocumentHandler;
39 class NumberingManager;
40 
41 class NumberingStyle : public Style
42 {
43 public:
44 	//! constructor
45 	NumberingStyle(const librevenge::RVNGPropertyList &xPropList, const librevenge::RVNGString &psName);
46 	//! destructor
~NumberingStyle()47 	~NumberingStyle() override {};
48 	//! write a style
49 	void writeStyle(OdfDocumentHandler *pHandler, NumberingManager const &manager) const;
50 
51 	//! returns the hash name corresponding to a style
52 	static librevenge::RVNGString getHashName(const librevenge::RVNGPropertyList &xPropList);
53 
54 private:
55 	static void writeCondition(librevenge::RVNGPropertyList const &propList, OdfDocumentHandler *pHandler, NumberingManager const &manager);
56 
57 	librevenge::RVNGPropertyList mPropList;
58 };
59 
60 /** main class to create/store/write the numbering styles */
61 class NumberingManager
62 {
63 public:
64 	//! constructor
65 	NumberingManager();
66 	//! destructor
67 	virtual ~NumberingManager();
68 	//! clean all data
69 	void clean();
70 	//! write all
write(OdfDocumentHandler * pHandler) const71 	virtual void write(OdfDocumentHandler *pHandler) const
72 	{
73 		write(pHandler, Style::Z_ContentAutomatic);
74 	}
75 	//! write automatic/named/... style
76 	void write(OdfDocumentHandler *pHandler, Style::Zone zone) const;
77 	//! create a new numbering style
78 	void addStyle(const librevenge::RVNGPropertyList &xPropList);
79 	/* create a new style if it does not exists. In all case, returns the name of the style
80 
81 	Note: using Numbering_num%i as new name*/
82 	librevenge::RVNGString findOrAdd(const librevenge::RVNGPropertyList &xPropList);
83 	//! return the style name corresponding to a local name
84 	librevenge::RVNGString getStyleName(librevenge::RVNGString const &localName) const;
85 
86 private:
87 	//! hash key -> name
88 	std::map<librevenge::RVNGString, librevenge::RVNGString> mHashNameMap;
89 	//! style name -> NumberingStyle
90 	std::map<librevenge::RVNGString, std::shared_ptr<NumberingStyle> > mNumberingHash;
91 };
92 #endif
93 
94 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
95