STOFFList.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
44 struct STOFFListLevel {
46 enum Type { DEFAULT, NONE, BULLET, DECIMAL, LOWER_ALPHA, UPPER_ALPHA,
47 LOWER_ROMAN, UPPER_ROMAN, LABEL
48 };
50 enum Alignment { LEFT, RIGHT, CENTER };
51
53 STOFFListLevel() : m_type(NONE), m_labelBeforeSpace(0.0), m_labelWidth(0.1), m_labelAfterSpace(0.0), m_numBeforeLabels(0), m_alignment(LEFT), m_startValue(0),
54 m_label(""), m_prefix(""), m_suffix(""), m_bullet(""), m_extra("")
55 {
56 }
58 ~STOFFListLevel() {}
59
61 bool isDefault() const
62 {
63 return m_type ==DEFAULT;
64 }
66 bool isNumeric() const
67 {
68 return m_type !=DEFAULT && m_type !=NONE && m_type != BULLET;
69 }
71 bool operator==(STOFFListLevel const &levl) const
72 {
73 return cmp(levl)==0;
74 }
76 bool operator!=(STOFFListLevel const &levl) const
77 {
78 return !operator==(levl);
79 }
81 void addTo(librevenge::RVNGPropertyList &propList) const;
82
84 int getStartValue() const
85 {
86 return m_startValue <= 0 ? 1 : m_startValue;
87 }
88
90 int cmp(STOFFListLevel const &levl) const;
91
93 friend std::ostream &operator<<(std::ostream &o, STOFFListLevel const &ft);
94
96 Type m_type;
97 double m_labelBeforeSpace ;
98 double m_labelWidth ;
99 double m_labelAfterSpace ;
101 int m_numBeforeLabels;
103 Alignment m_alignment;
105 int m_startValue;
106 librevenge::RVNGString m_label ,
107 m_prefix ,
108 m_suffix,
109 m_bullet ;
111 std::string m_extra;
112 };
113
115 class STOFFList
116 {
117 public:
119 STOFFList() : m_levels(), m_actLevel(-1), m_actualIndices(), m_nextIndices(), 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
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() : m_listList(), m_sendIdMarkerList() { }
211 ~STOFFListManager() { }
213 bool needToSend(int index, std::vector<int> &idMarkerList) const;
215 shared_ptr<STOFFList> getList(int index) const;
217 shared_ptr<STOFFList> getNewList(shared_ptr<STOFFList> actList, int levl, STOFFListLevel const &level);
218 protected:
220 std::vector<STOFFList> m_listList;
222 mutable std::vector<int> m_sendIdMarkerList;
223 };
224 #endif
225 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFListLevel::Type
Type
the type of the level
Definition: STOFFList.hxx:46
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
STOFFList::swapId
void swapId() const
swap the list id
Definition: STOFFList.hxx:148
STOFFListLevel::m_labelAfterSpace
double m_labelAfterSpace
the minimum distance between the label and the text
Definition: STOFFList.hxx:99
STOFFList::getLevel
STOFFListLevel getLevel(int levl) const
returns a level if it exists
Definition: STOFFList.hxx:159
STOFFListLevel::m_prefix
librevenge::RVNGString m_prefix
string which preceedes the number if we have an ordered level
Definition: STOFFList.hxx:106
STOFFListLevel::isDefault
bool isDefault() const
returns true if the level type was not set
Definition: STOFFList.hxx:61
STOFFList::m_actLevel
int m_actLevel
the actual levels
Definition: STOFFList.hxx:196
STOFFListLevel::m_suffix
librevenge::RVNGString m_suffix
string which follows the number if we have an ordered level
Definition: STOFFList.hxx:106
STOFFListLevel::Alignment
Alignment
the item alignment
Definition: STOFFList.hxx:50
STOFFListLevel::UPPER_ROMAN
Definition: STOFFList.hxx:47
STOFFListLevel::m_numBeforeLabels
int m_numBeforeLabels
the number of label to show before this
Definition: STOFFList.hxx:101
STOFFListManager::m_listList
std::vector< STOFFList > m_listList
the list of created list
Definition: STOFFList.hxx:220
STOFFListLevel::operator!=
bool operator!=(STOFFListLevel const &levl) const
operator!=
Definition: STOFFList.hxx:76
STOFFListLevel::operator==
bool operator==(STOFFListLevel const &levl) const
operator==
Definition: STOFFList.hxx:71
STOFFListLevel::LOWER_ROMAN
Definition: STOFFList.hxx:47
STOFFListLevel::m_labelWidth
double m_labelWidth
the minimum label width
Definition: STOFFList.hxx:98
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:127
STOFFListManager::m_sendIdMarkerList
std::vector< int > m_sendIdMarkerList
the list of send list to interface
Definition: STOFFList.hxx:222
STOFFListLevel::RIGHT
Definition: STOFFList.hxx:50
STOFFListLevel::m_extra
std::string m_extra
extra data
Definition: STOFFList.hxx:111
STOFFListLevel::UPPER_ALPHA
Definition: STOFFList.hxx:46
STOFFListManager::STOFFListManager
STOFFListManager()
the constructor
Definition: STOFFList.hxx:209
STOFFListLevel::DECIMAL
Definition: STOFFList.hxx:46
STOFFListLevel
small structure to keep information about a list level
Definition: STOFFList.hxx:44
STOFFListLevel::LEFT
Definition: STOFFList.hxx:50
STOFFListLevel::getStartValue
int getStartValue() const
returns the start value (if set) or 1
Definition: STOFFList.hxx:84
STOFFList::numLevels
int numLevels() const
returns the number of level
Definition: STOFFList.hxx:167
STOFFListLevel::m_type
Type m_type
the type of the level
Definition: STOFFList.hxx:96
STOFFListLevel::LOWER_ALPHA
Definition: STOFFList.hxx:46
STOFFListLevel::addTo
void addTo(librevenge::RVNGPropertyList &propList) const
add the information of this level in the propList
Definition: STOFFList.cxx:46
STOFFListManager::~STOFFListManager
~STOFFListManager()
the destructor
Definition: STOFFList.hxx:211
STOFFListLevel::operator<<
friend std::ostream & operator<<(std::ostream &o, STOFFListLevel const &ft)
operator<<
Definition: STOFFList.cxx:134
STOFFList
a small structure used to store the informations about a list
Definition: STOFFList.hxx:115
STOFFListLevel::m_bullet
librevenge::RVNGString m_bullet
the bullet if we have an bullet level
Definition: STOFFList.hxx:106
STOFFListLevel::LABEL
Definition: STOFFList.hxx:47
STOFFListLevel::NONE
Definition: STOFFList.hxx:46
STOFFListLevel::cmp
int cmp(STOFFListLevel const &levl) const
comparison function ( compare all values excepted m_startValues
Definition: STOFFList.cxx:106
STOFFList::getMarker
int getMarker() const
returns the actual modify marker
Definition: STOFFList.hxx:131
STOFFList::STOFFList
STOFFList()
default constructor
Definition: STOFFList.hxx:119
STOFFListLevel::m_labelBeforeSpace
double m_labelBeforeSpace
the extra space between inserting a label
Definition: STOFFList.hxx:97
STOFFList::getId
int getId() const
returns the list id
Definition: STOFFList.hxx:125
STOFFListLevel::CENTER
Definition: STOFFList.hxx:50
STOFFListLevel::m_label
librevenge::RVNGString m_label
the text label
Definition: STOFFList.hxx:106
STOFFListLevel::m_startValue
int m_startValue
the actual value (if this is an ordered level )
Definition: STOFFList.hxx:105
STOFFListLevel::~STOFFListLevel
~STOFFListLevel()
destructor
Definition: STOFFList.hxx:58
STOFFListLevel::STOFFListLevel
STOFFListLevel()
basic constructor
Definition: STOFFList.hxx:53
STOFFList::closeElement
void closeElement() const
close the list element
Definition: STOFFList.hxx:179
STOFFListLevel::isNumeric
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition: STOFFList.hxx:66
STOFFListLevel::m_alignment
Alignment m_alignment
the alignment ( left, center, ...)
Definition: STOFFList.hxx:103
STOFFListLevel::BULLET
Definition: STOFFList.hxx:46
STOFFListLevel::DEFAULT
Definition: STOFFList.hxx:46
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