1 /* AbiSource Program Utilities
2  *
3  * Copyright (C) 2005 Daniel d'Andrada T. de Carvalho
4  * <daniel.carvalho@indt.org.br>
5  * Copyright (C) 2009 Hubert Figuiere
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  * 02110-1301 USA.
21  */
22 
23 #ifndef _ODI_STYLE_LIST_H_
24 #define _ODI_STYLE_LIST_H_
25 
26 #include <string>
27 #include <vector>
28 
29 // Internal includes
30 #include "ODi_ListenerState.h"
31 
32 // Internal classes
33 class ODi_ListLevelStyle;
34 
35 // AbiWord classes
36 class PD_Document;
37 
38 
39 /**
40  * Represents a <text:list-style> element.
41  */
42 class ODi_Style_List
43     : public ODi_ListenerState {
44 
45 public:
46 
ODi_Style_List(ODi_ElementStack & rElementStack)47     ODi_Style_List(ODi_ElementStack& rElementStack) :
48 	    ODi_ListenerState("StyleList", rElementStack),
49         m_bListStyle(false)
50     {
51     }
52 
53     virtual ~ODi_Style_List();
54 
55     void startElement (const gchar* pName, const gchar** ppAtts,
56                                ODi_ListenerStateAction& rAction);
57 
58     void endElement (const gchar* pName,
59                              ODi_ListenerStateAction& rAction);
60 
charData(const gchar *,int)61     void charData (const gchar* /*pBuffer*/, int /*length*/) { };
62 
63     void defineAbiList(PD_Document* pDocument);
64     void redefine(PD_Document* pDocument, UT_uint32 iLevel);
65 
getLevelStyle(UT_uint32 level)66     ODi_ListLevelStyle* getLevelStyle(UT_uint32 level) const
67         {
68             UT_return_val_if_fail(level > 0, NULL);
69             UT_return_val_if_fail(!m_levelStyles.empty(), NULL);
70             UT_return_val_if_fail(level <= m_levelStyles.size(), NULL);
71 
72             // Levels starts from 1, but our vector starts from 0 (zero).
73             return m_levelStyles[level-1];
74         }
75 
getLevelCount()76     UT_sint32 getLevelCount() const
77         {
78             return m_levelStyles.size();
79         }
80 
81     void buildAbiPropertiesString() const;
82 
83 private:
84     // style:name attribute
85     std::string m_name;
86 
87     // style:display-name attribute
88     std::string m_displayName;
89 
90     // text:consecutive-numbering attribute
91     bool m_bConsecutiveNumbering;
92 
93     std::vector<ODi_ListLevelStyle*> m_levelStyles;
94     bool m_bListStyle;
95 };
96 
97 #endif //_ODI_STYLE_LIST_H_
98