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 }
61 ~STOFFListLevel();
62
64 bool isDefault() const
65 {
66 return m_type==DEFAULT;
67 }
69 bool isNumeric() const
70 {
71 return m_type==NUMBER;
72 }
74 bool operator==(STOFFListLevel const &levl) const
75 {
76 return cmp(levl)==0;
77 }
79 bool operator!=(STOFFListLevel const &levl) const
80 {
81 return !operator==(levl);
82 }
84 void addTo(librevenge::RVNGPropertyList &propList) const;
85
87 int getStartValue() const
88 {
89 return m_startValue <= 0 ? 1 : m_startValue;
90 }
91
93 int cmp(STOFFListLevel const &levl) const;
95 Type m_type;
97 librevenge::RVNGPropertyList m_propertyList;
99 std::shared_ptr<STOFFFont> m_font;
101 int m_startValue;
102 };
103
105 class STOFFList
106 {
107 public:
109 explicit STOFFList(bool outline)
110 : m_outline(outline)
111 , m_name(""), m_levels()
112 , m_actLevel(-1)
113 , m_actualIndices()
114 , m_nextIndices()
115 , m_modifyMarker(1)
116 {
117 m_id[0] = m_id[1] = -1;
118 }
119
121 int getId() const
122 {
123 return m_id[0];
124 }
125
127 int getMarker() const
128 {
129 return m_modifyMarker;
130 }
132 void resize(int levl);
134 bool isCompatibleWith(int levl, STOFFListLevel const &level) const;
136 bool isCompatibleWith(STOFFList const &newList) const;
138 void updateIndicesFrom(STOFFList const &list);
139
144 void swapId() const
145 {
146 int tmp = m_id[0];
147 m_id[0] = m_id[1];
148 m_id[1] = tmp;
149 }
150
152 void setId(int newId) const;
153
155 STOFFListLevel getLevel(int levl) const
156 {
157 if (levl >= 0 && levl < int(m_levels.size()))
158 return m_levels[size_t(levl)];
159 STOFF_DEBUG_MSG(("STOFFList::getLevel: can not find level %d\n", levl));
160 return STOFFListLevel();
161 }
163 int numLevels() const
164 {
165 return int(m_levels.size());
166 }
168 void set(int levl, STOFFListLevel const &level);
169
171 void setLevel(int levl) const;
173 void openElement() const;
175 void closeElement() const {}
177 int getStartValueForNextElement() const;
179 void setStartValueForNextElement(int value);
180
182 bool isNumeric(int levl) const;
183
185 bool addTo(int level, librevenge::RVNGPropertyList &pList) const;
186
188 bool m_outline;
190 librevenge::RVNGString m_name;
191 protected:
193 std::vector<STOFFListLevel> m_levels;
194
196 mutable int m_actLevel;
197 mutable std::vector<int> m_actualIndices, m_nextIndices;
199 mutable int m_id[2];
201 mutable int m_modifyMarker;
202 };
203
205 class STOFFListManager
206 {
207 public:
209 STOFFListManager()
210 : m_listList()
211 , m_sendIdMarkerList() { }
213 ~STOFFListManager() { }
215 bool needToSend(int index, std::vector<int> &idMarkerList) const;
217 std::shared_ptr<STOFFList> getList(int index) const;
219 std::shared_ptr<STOFFList> getNewList(std::shared_ptr<STOFFList> actList, int levl, STOFFListLevel const &level);
221 std::shared_ptr<STOFFList> addList(std::shared_ptr<STOFFList> actList);
222 protected:
224 std::vector<STOFFList> m_listList;
226 mutable std::vector<int> m_sendIdMarkerList;
227 };
228 #endif
229 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFListLevel::Type
Type
the type of the level
Definition: STOFFList.hxx:50
STOFFList::resize
void resize(int levl)
resize the number of level of the list (keeping only n level)
Definition: STOFFList.cxx:86
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:201
STOFFList::m_levels
std::vector< STOFFListLevel > m_levels
the different levels
Definition: STOFFList.hxx:193
STOFFListLevel::getStartValue
int getStartValue() const
returns the start value (if set) or 1
Definition: STOFFList.hxx:87
STOFFList::STOFFList
STOFFList(bool outline)
default constructor
Definition: STOFFList.hxx:109
STOFFList::getId
int getId() const
returns the list id
Definition: STOFFList.hxx:121
STOFFList::m_id
int m_id[2]
the identificator ( actual and auxilliar )
Definition: STOFFList.hxx:199
STOFFListLevel::NUMBER
Definition: STOFFList.hxx:50
STOFFList::m_actLevel
int m_actLevel
the actual levels
Definition: STOFFList.hxx:196
STOFFListManager::m_listList
std::vector< STOFFList > m_listList
the list of created list
Definition: STOFFList.hxx:224
STOFFListLevel::cmp
int cmp(STOFFListLevel const &levl) const
comparison function ( compare all values excepted m_startValues
Definition: STOFFList.cxx:67
STOFFListLevel::isDefault
bool isDefault() const
returns true if the level type was not set
Definition: STOFFList.hxx:64
STOFFList::getLevel
STOFFListLevel getLevel(int levl) const
returns a level if it exists
Definition: STOFFList.hxx:155
STOFFListLevel::addTo
void addTo(librevenge::RVNGPropertyList &propList) const
add the information of this level in the propList
Definition: STOFFList.cxx:52
STOFFList::updateIndicesFrom
void updateIndicesFrom(STOFFList const &list)
update the indices, the actual level from newList
Definition: STOFFList.cxx:102
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:129
STOFFListManager::m_sendIdMarkerList
std::vector< int > m_sendIdMarkerList
the list of send list to interface
Definition: STOFFList.hxx:226
STOFFList::setStartValueForNextElement
void setStartValueForNextElement(int value)
set the startvalue corresponding to the actual level
Definition: STOFFList.cxx:197
STOFFListLevel::operator==
bool operator==(STOFFListLevel const &levl) const
operator==
Definition: STOFFList.hxx:74
STOFFList::closeElement
void closeElement() const
close the list element
Definition: STOFFList.hxx:175
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::m_outline
bool m_outline
flag to know if the list is a outline list
Definition: STOFFList.hxx:188
STOFFListLevel::operator!=
bool operator!=(STOFFListLevel const &levl) const
operator!=
Definition: STOFFList.hxx:79
STOFFListManager::STOFFListManager
STOFFListManager()
the constructor
Definition: STOFFList.hxx:209
STOFFListLevel
small structure to keep information about a list level
Definition: STOFFList.hxx:48
STOFFList::setLevel
void setLevel(int levl) const
set the list level
Definition: STOFFList.cxx:183
STOFFListLevel::m_type
Type m_type
the type of the level
Definition: STOFFList.hxx:95
STOFFList::isNumeric
bool isNumeric(int levl) const
returns true is a level is numeric
Definition: STOFFList.cxx:230
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
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::numLevels
int numLevels() const
returns the number of level
Definition: STOFFList.hxx:163
STOFFList::swapId
void swapId() const
swap the list id
Definition: STOFFList.hxx:144
STOFFListManager::~STOFFListManager
~STOFFListManager()
the destructor
Definition: STOFFList.hxx:213
STOFFList::getMarker
int getMarker() const
returns the actual modify marker
Definition: STOFFList.hxx:127
STOFFListManager::addList
std::shared_ptr< STOFFList > addList(std::shared_ptr< STOFFList > actList)
add a new list
Definition: STOFFList.cxx:274
STOFFList
a small structure used to store the informations about a list
Definition: STOFFList.hxx:105
STOFFListLevel::m_font
std::shared_ptr< STOFFFont > m_font
the font
Definition: STOFFList.hxx:99
STOFFListLevel::NONE
Definition: STOFFList.hxx:50
STOFFList::setId
void setId(int newId) const
set the list id
Definition: STOFFList.cxx:137
STOFFList::m_actualIndices
std::vector< int > m_actualIndices
Definition: STOFFList.hxx:197
libstaroffice_internal.hxx
STOFFListLevel::m_propertyList
librevenge::RVNGPropertyList m_propertyList
the propertyList
Definition: STOFFList.hxx:97
STOFFFont
Class to store font.
Definition: STOFFFont.hxx:43
STOFFList::addTo
bool addTo(int level, librevenge::RVNGPropertyList &pList) const
retrieve the list level property
Definition: STOFFList.cxx:143
STOFFList::m_name
librevenge::RVNGString m_name
the list name
Definition: STOFFList.hxx:190
STOFFListManager::getList
std::shared_ptr< STOFFList > getList(int index) const
returns a list with given index ( if found )
Definition: STOFFList.cxx:261
STOFFList::getStartValueForNextElement
int getStartValueForNextElement() const
returns the startvalue corresponding to the actual level ( or -1 for an unknown/unordered list) ...
Definition: STOFFList.cxx:209
STOFFListLevel::isNumeric
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition: STOFFList.hxx:69
STOFFListLevel::m_startValue
int m_startValue
the actual value (if this is an ordered level )
Definition: STOFFList.hxx:101
STOFFListLevel::~STOFFListLevel
~STOFFListLevel()
destructor
Definition: STOFFList.cxx:48
STOFFListLevel::STOFFListLevel
STOFFListLevel()
basic constructor
Definition: STOFFList.hxx:53
STOFFList::openElement
void openElement() const
open the list element
Definition: STOFFList.cxx:220
STOFFListLevel::BULLET
Definition: STOFFList.hxx:50
STOFFListLevel::DEFAULT
Definition: STOFFList.hxx:50
STOFFList::m_nextIndices
std::vector< int > m_nextIndices
Definition: STOFFList.hxx:197
STOFFListManager
a manager which manages the lists, keeps the different kind of lists, to assure the unicity of each l...
Definition: STOFFList.hxx:205