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
45class STOFFFont;
46
51
54 : m_type(NONE)
56 , m_font()
57 , m_startValue(0)
58 {
59 }
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;
97 librevenge::RVNGPropertyList m_propertyList;
99 std::shared_ptr<STOFFFont> m_font;
102};
103
106{
107public:
109 explicit STOFFList(bool outline)
110 : m_outline(outline)
111 , m_name(""), m_levels()
112 , m_actLevel(-1)
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
190 librevenge::RVNGString m_name;
191protected:
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
206{
207public:
210 : m_listList()
211 , m_sendIdMarkerList() { }
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);
222protected:
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:
Class to store font.
Definition: STOFFFont.hxx:44
a manager which manages the lists, keeps the different kind of lists, to assure the unicity of each l...
Definition: STOFFList.hxx:206
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
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
std::shared_ptr< STOFFList > addList(std::shared_ptr< STOFFList > actList)
add a new list
Definition: STOFFList.cxx:274
~STOFFListManager()
the destructor
Definition: STOFFList.hxx:213
std::shared_ptr< STOFFList > getList(int index) const
returns a list with given index ( if found )
Definition: STOFFList.cxx:261
std::vector< int > m_sendIdMarkerList
the list of send list to interface
Definition: STOFFList.hxx:226
std::vector< STOFFList > m_listList
the list of created list
Definition: STOFFList.hxx:224
STOFFListManager()
the constructor
Definition: STOFFList.hxx:209
a small structure used to store the informations about a list
Definition: STOFFList.hxx:106
STOFFList(bool outline)
default constructor
Definition: STOFFList.hxx:109
int getStartValueForNextElement() const
returns the startvalue corresponding to the actual level ( or -1 for an unknown/unordered list)
Definition: STOFFList.cxx:209
int m_id[2]
the identificator ( actual and auxilliar )
Definition: STOFFList.hxx:199
void openElement() const
open the list element
Definition: STOFFList.cxx:220
void updateIndicesFrom(STOFFList const &list)
update the indices, the actual level from newList
Definition: STOFFList.cxx:102
void setLevel(int levl) const
set the list level
Definition: STOFFList.cxx:183
int getId() const
returns the list id
Definition: STOFFList.hxx:121
void set(int levl, STOFFListLevel const &level)
sets a level
Definition: STOFFList.cxx:164
librevenge::RVNGString m_name
the list name
Definition: STOFFList.hxx:190
void closeElement() const
close the list element
Definition: STOFFList.hxx:175
bool isNumeric(int levl) const
returns true is a level is numeric
Definition: STOFFList.cxx:230
void swapId() const
swap the list id
Definition: STOFFList.hxx:144
int numLevels() const
returns the number of level
Definition: STOFFList.hxx:163
void resize(int levl)
resize the number of level of the list (keeping only n level)
Definition: STOFFList.cxx:86
STOFFListLevel getLevel(int levl) const
returns a level if it exists
Definition: STOFFList.hxx:155
int getMarker() const
returns the actual modify marker
Definition: STOFFList.hxx:127
bool addTo(int level, librevenge::RVNGPropertyList &pList) const
retrieve the list level property
Definition: STOFFList.cxx:143
int m_actLevel
the actual levels
Definition: STOFFList.hxx:196
int m_modifyMarker
a modification marker ( can be used to check if a list has been send to a interface )
Definition: STOFFList.hxx:201
std::vector< int > m_actualIndices
Definition: STOFFList.hxx:197
std::vector< STOFFListLevel > m_levels
the different levels
Definition: STOFFList.hxx:193
std::vector< int > m_nextIndices
Definition: STOFFList.hxx:197
void setStartValueForNextElement(int value)
set the startvalue corresponding to the actual level
Definition: STOFFList.cxx:197
void setId(int newId) const
set the list id
Definition: STOFFList.cxx:137
bool m_outline
flag to know if the list is a outline list
Definition: STOFFList.hxx:188
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
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:129
small structure to keep information about a list level
Definition: STOFFList.hxx:48
void addTo(librevenge::RVNGPropertyList &propList) const
add the information of this level in the propList
Definition: STOFFList.cxx:52
bool isDefault() const
returns true if the level type was not set
Definition: STOFFList.hxx:64
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition: STOFFList.hxx:69
int m_startValue
the actual value (if this is an ordered level )
Definition: STOFFList.hxx:101
STOFFListLevel()
basic constructor
Definition: STOFFList.hxx:53
librevenge::RVNGPropertyList m_propertyList
the propertyList
Definition: STOFFList.hxx:97
~STOFFListLevel()
destructor
Definition: STOFFList.cxx:48
bool operator==(STOFFListLevel const &levl) const
operator==
Definition: STOFFList.hxx:74
Type m_type
the type of the level
Definition: STOFFList.hxx:95
int cmp(STOFFListLevel const &levl) const
comparison function ( compare all values excepted m_startValues
Definition: STOFFList.cxx:67
std::shared_ptr< STOFFFont > m_font
the font
Definition: STOFFList.hxx:99
Type
the type of the level
Definition: STOFFList.hxx:50
@ DEFAULT
Definition: STOFFList.hxx:50
@ BULLET
Definition: STOFFList.hxx:50
@ NUMBER
Definition: STOFFList.hxx:50
@ NONE
Definition: STOFFList.hxx:50
bool operator!=(STOFFListLevel const &levl) const
operator!=
Definition: STOFFList.hxx:79
int getStartValue() const
returns the start value (if set) or 1
Definition: STOFFList.hxx:87

Generated on Fri Sep 2 2022 03:06:15 for libstaroffice by doxygen 1.9.2