STOFFList.hxx Source File documentation

STOFFList.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3 /* libstaroffice
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33
34 #ifndef STOFF_LIST_H
35 # define STOFF_LIST_H
36
37 #include <iostream>
38
39 #include <vector>
40
41 #include <librevenge/librevenge.h>
42
43 #include "libstaroffice_internal.hxx"
44
45 class STOFFFont;
46
48 struct STOFFListLevel {
50 enum Type { DEFAULT, NONE, BULLET, NUMBER };
51
53 STOFFListLevel()
54 : m_type(NONE)
55 , m_propertyList()
56 , m_font()
57 , m_startValue(0)
58 {
59 }
60 STOFFListLevel(STOFFListLevel const &)=default;
61 STOFFListLevel(STOFFListLevel &&)=default;
62 STOFFListLevel &operator=(STOFFListLevel const &)=default;
63 STOFFListLevel &operator=(STOFFListLevel &&)=default;
65 ~STOFFListLevel();
66
68 bool isDefault() const
69 {
70 return m_type==DEFAULT;
71 }
73 bool isNumeric() const
74 {
75 return m_type==NUMBER;
76 }
78 bool operator==(STOFFListLevel const &levl) const
79 {
80 return cmp(levl)==0;
81 }
83 bool operator!=(STOFFListLevel const &levl) const
84 {
85 return !operator==(levl);
86 }
88 void addTo(librevenge::RVNGPropertyList &propList) const;
89
91 int getStartValue() const
92 {
93 return m_startValue <= 0 ? 1 : m_startValue;
94 }
95
97 int cmp(STOFFListLevel const &levl) const;
99 Type m_type;
101 librevenge::RVNGPropertyList m_propertyList;
103 std::shared_ptr<STOFFFont> m_font;
105 int m_startValue;
106 };
107
109 class STOFFList
110 {
111 public:
113 explicit STOFFList(bool outline)
114 : m_outline(outline)
115 , m_name(""), m_levels()
116 , m_actLevel(-1)
117 , m_actualIndices()
118 , m_nextIndices()
119 , m_modifyMarker(1)
120 {
121 m_id[0] = m_id[1] = -1;
122 }
123
125 int getId() const
126 {
127 return m_id[0];
128 }
129
131 int getMarker() const
132 {
133 return m_modifyMarker;
134 }
136 void resize(int levl);
138 bool isCompatibleWith(int levl, STOFFListLevel const &level) const;
140 bool isCompatibleWith(STOFFList const &newList) const;
142 void updateIndicesFrom(STOFFList const &list);
143
148 void swapId() const
149 {
150 int tmp = m_id[0];
151 m_id[0] = m_id[1];
152 m_id[1] = tmp;
153 }
154
156 void setId(int newId) const;
157
159 STOFFListLevel getLevel(int levl) const
160 {
161 if (levl >= 0 && levl < int(m_levels.size()))
162 return m_levels[size_t(levl)];
163 STOFF_DEBUG_MSG(("STOFFList::getLevel: can not find level %d\n", levl));
164 return STOFFListLevel();
165 }
167 int numLevels() const
168 {
169 return int(m_levels.size());
170 }
172 void set(int levl, STOFFListLevel const &level);
173
175 void setLevel(int levl) const;
177 void openElement() const;
179 void closeElement() const {}
181 int getStartValueForNextElement() const;
183 void setStartValueForNextElement(int value);
184
186 bool isNumeric(int levl) const;
187
189 bool addTo(int level, librevenge::RVNGPropertyList &pList) const;
190
192 bool m_outline;
194 librevenge::RVNGString m_name;
195 protected:
197 std::vector<STOFFListLevel> m_levels;
198
200 mutable int m_actLevel;
201 mutable std::vector<int> m_actualIndices, m_nextIndices;
203 mutable int m_id[2];
205 mutable int m_modifyMarker;
206 };
207
209 class STOFFListManager
210 {
211 public:
213 STOFFListManager()
214 : m_listList()
215 , m_sendIdMarkerList() { }
217 ~STOFFListManager() { }
219 bool needToSend(int index, std::vector<int> &idMarkerList) const;
221 std::shared_ptr<STOFFList> getList(int index) const;
223 std::shared_ptr<STOFFList> getNewList(std::shared_ptr<STOFFList> actList, int levl, STOFFListLevel const &level);
225 std::shared_ptr<STOFFList> addList(std::shared_ptr<STOFFList> actList);
226 protected:
228 std::vector<STOFFList> m_listList;
230 mutable std::vector<int> m_sendIdMarkerList;
231 };
232 #endif
233 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFList::m_actualIndices
std::vector< int > m_actualIndices
Definition: STOFFList.hxx:201
STOFFListManager::m_listList
std::vector< STOFFList > m_listList
the list of created list
Definition: STOFFList.hxx:228
STOFFList::STOFFList
STOFFList(bool outline)
default constructor
Definition: STOFFList.hxx:113
STOFFListManager::needToSend
bool needToSend(int index, std::vector< int > &idMarkerList) const
check if a list need to be send/resend to the interface
Definition: STOFFList.cxx:243
STOFFList::swapId
void swapId() const
swap the list id
Definition: STOFFList.hxx:148
STOFFList::getId
int getId() const
returns the list id
Definition: STOFFList.hxx:125
STOFFListLevel::m_propertyList
librevenge::RVNGPropertyList m_propertyList
the propertyList
Definition: STOFFList.hxx:101
STOFFList::closeElement
void closeElement() const
close the list element
Definition: STOFFList.hxx:179
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:129
STOFFListLevel::DEFAULT
@ DEFAULT
Definition: STOFFList.hxx:50
STOFFList::getLevel
STOFFListLevel getLevel(int levl) const
returns a level if it exists
Definition: STOFFList.hxx:159
STOFFList::m_modifyMarker
int m_modifyMarker
a modification marker ( can be used to check if a list has been send to a interface )
Definition: STOFFList.hxx:205
STOFFList::m_nextIndices
std::vector< int > m_nextIndices
Definition: STOFFList.hxx:201
STOFFListLevel::operator!=
bool operator!=(STOFFListLevel const &levl) const
operator!=
Definition: STOFFList.hxx:83
STOFFListManager::m_sendIdMarkerList
std::vector< int > m_sendIdMarkerList
the list of send list to interface
Definition: STOFFList.hxx:230
STOFFListManager::STOFFListManager
STOFFListManager()
the constructor
Definition: STOFFList.hxx:213
STOFFList::m_id
int m_id[2]
the identificator ( actual and auxilliar )
Definition: STOFFList.hxx:203
STOFFListManager::addList
std::shared_ptr< STOFFList > addList(std::shared_ptr< STOFFList > actList)
add a new list
Definition: STOFFList.cxx:274
STOFFListLevel::operator=
STOFFListLevel & operator=(STOFFListLevel const &)=default
STOFFListLevel::cmp
int cmp(STOFFListLevel const &levl) const
comparison function ( compare all values excepted m_startValues
Definition: STOFFList.cxx:67
STOFFListLevel
small structure to keep information about a list level
Definition: STOFFList.hxx:48
libstaroffice_internal.hxx
STOFFListLevel::m_font
std::shared_ptr< STOFFFont > m_font
the font
Definition: STOFFList.hxx:103
STOFFList::resize
void resize(int levl)
resize the number of level of the list (keeping only n level)
Definition: STOFFList.cxx:86
STOFFList::setId
void setId(int newId) const
set the list id
Definition: STOFFList.cxx:137
STOFFList::setLevel
void setLevel(int levl) const
set the list level
Definition: STOFFList.cxx:183
STOFFList::numLevels
int numLevels() const
returns the number of level
Definition: STOFFList.hxx:167
STOFFListLevel::NUMBER
@ NUMBER
Definition: STOFFList.hxx:50
STOFFListLevel::m_type
Type m_type
the type of the level
Definition: STOFFList.hxx:99
STOFFListener.hxx
STOFFListManager
a manager which manages the lists, keeps the different kind of lists, to assure the unicity of each l...
Definition: STOFFList.hxx:209
STOFFList.hxx
STOFFList::m_actLevel
int m_actLevel
the actual levels
Definition: STOFFList.hxx:200
STOFFListLevel::getStartValue
int getStartValue() const
returns the start value (if set) or 1
Definition: STOFFList.hxx:91
STOFFListLevel::m_startValue
int m_startValue
the actual value (if this is an ordered level )
Definition: STOFFList.hxx:105
STOFFListLevel::Type
Type
the type of the level
Definition: STOFFList.hxx:50
STOFFListLevel::isDefault
bool isDefault() const
returns true if the level type was not set
Definition: STOFFList.hxx:68
STOFFList::m_name
librevenge::RVNGString m_name
the list name
Definition: STOFFList.hxx:194
STOFFListLevel::BULLET
@ BULLET
Definition: STOFFList.hxx:50
STOFFListManager::getList
std::shared_ptr< STOFFList > getList(int index) const
returns a list with given index ( if found )
Definition: STOFFList.cxx:261
STOFFListLevel::~STOFFListLevel
~STOFFListLevel()
destructor
Definition: STOFFList.cxx:48
STOFFListLevel::STOFFListLevel
STOFFListLevel()
basic constructor
Definition: STOFFList.hxx:53
STOFFList::m_outline
bool m_outline
flag to know if the list is a outline list
Definition: STOFFList.hxx:192
STOFFListLevel::NONE
@ NONE
Definition: STOFFList.hxx:50
STOFFFont
Class to store font.
Definition: STOFFFont.hxx:43
STOFFList::setStartValueForNextElement
void setStartValueForNextElement(int value)
set the startvalue corresponding to the actual level
Definition: STOFFList.cxx:197
STOFFList::isCompatibleWith
bool isCompatibleWith(int levl, STOFFListLevel const &level) const
returns true if we can add a new level in the list without changing is meaning
Definition: STOFFList.cxx:114
STOFFList::updateIndicesFrom
void updateIndicesFrom(STOFFList const &list)
update the indices, the actual level from newList
Definition: STOFFList.cxx:102
STOFFListManager::getNewList
std::shared_ptr< STOFFList > getNewList(std::shared_ptr< STOFFList > actList, int levl, STOFFListLevel const &level)
returns a new list corresponding to a list where we have a new level
Definition: STOFFList.cxx:291
STOFFListLevel::isNumeric
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition: STOFFList.hxx:73
STOFFListManager::~STOFFListManager
~STOFFListManager()
the destructor
Definition: STOFFList.hxx:217
STOFFList::getStartValueForNextElement
int getStartValueForNextElement() const
returns the startvalue corresponding to the actual level ( or -1 for an unknown/unordered list)
Definition: STOFFList.cxx:209
STOFFList::getMarker
int getMarker() const
returns the actual modify marker
Definition: STOFFList.hxx:131
STOFFList::isNumeric
bool isNumeric(int levl) const
returns true is a level is numeric
Definition: STOFFList.cxx:230
STOFFList
a small structure used to store the informations about a list
Definition: STOFFList.hxx:109
STOFFListLevel::addTo
void addTo(librevenge::RVNGPropertyList &propList) const
add the information of this level in the propList
Definition: STOFFList.cxx:52
STOFFListLevel::operator==
bool operator==(STOFFListLevel const &levl) const
operator==
Definition: STOFFList.hxx:78
STOFFList::m_levels
std::vector< STOFFListLevel > m_levels
the different levels
Definition: STOFFList.hxx:197
STOFFList::openElement
void openElement() const
open the list element
Definition: STOFFList.cxx:220
STOFFFont.hxx
STOFFList::set
void set(int levl, STOFFListLevel const &level)
sets a level
Definition: STOFFList.cxx:164
STOFFList::addTo
bool addTo(int level, librevenge::RVNGPropertyList &pList) const
retrieve the list level property
Definition: STOFFList.cxx:143