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 
45 class STOFFFont;
46 
50  enum Type { DEFAULT, NONE, BULLET, NUMBER };
51 
54  : m_type(NONE)
55  , m_propertyList()
56  , m_font()
57  , m_startValue(0)
58  {
59  }
60  STOFFListLevel(STOFFListLevel const &)=default;
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;
101  librevenge::RVNGPropertyList m_propertyList;
103  std::shared_ptr<STOFFFont> m_font;
106 };
107 
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 
210 {
211 public:
214  : m_listList()
215  , m_sendIdMarkerList() { }
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:
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:210
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:217
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:230
std::vector< STOFFList > m_listList
the list of created list
Definition: STOFFList.hxx:228
STOFFListManager()
the constructor
Definition: STOFFList.hxx:213
a small structure used to store the informations about a list
Definition: STOFFList.hxx:110
STOFFList(bool outline)
default constructor
Definition: STOFFList.hxx:113
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:203
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:125
void set(int levl, STOFFListLevel const &level)
sets a level
Definition: STOFFList.cxx:164
librevenge::RVNGString m_name
the list name
Definition: STOFFList.hxx:194
void closeElement() const
close the list element
Definition: STOFFList.hxx:179
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:148
int numLevels() const
returns the number of level
Definition: STOFFList.hxx:167
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:159
int getMarker() const
returns the actual modify marker
Definition: STOFFList.hxx:131
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:200
int m_modifyMarker
a modification marker ( can be used to check if a list has been send to a interface )
Definition: STOFFList.hxx:205
std::vector< int > m_actualIndices
Definition: STOFFList.hxx:201
std::vector< STOFFListLevel > m_levels
the different levels
Definition: STOFFList.hxx:197
std::vector< int > m_nextIndices
Definition: STOFFList.hxx:201
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:192
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
STOFFListLevel & operator=(STOFFListLevel &&)=default
bool isDefault() const
returns true if the level type was not set
Definition: STOFFList.hxx:68
STOFFListLevel & operator=(STOFFListLevel const &)=default
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition: STOFFList.hxx:73
int m_startValue
the actual value (if this is an ordered level )
Definition: STOFFList.hxx:105
STOFFListLevel()
basic constructor
Definition: STOFFList.hxx:53
librevenge::RVNGPropertyList m_propertyList
the propertyList
Definition: STOFFList.hxx:101
~STOFFListLevel()
destructor
Definition: STOFFList.cxx:48
bool operator==(STOFFListLevel const &levl) const
operator==
Definition: STOFFList.hxx:78
Type m_type
the type of the level
Definition: STOFFList.hxx:99
int cmp(STOFFListLevel const &levl) const
comparison function ( compare all values excepted m_startValues
Definition: STOFFList.cxx:67
STOFFListLevel(STOFFListLevel &&)=default
std::shared_ptr< STOFFFont > m_font
the font
Definition: STOFFList.hxx:103
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
STOFFListLevel(STOFFListLevel const &)=default
bool operator!=(STOFFListLevel const &levl) const
operator!=
Definition: STOFFList.hxx:83
int getStartValue() const
returns the start value (if set) or 1
Definition: STOFFList.hxx:91

Generated on Wed Mar 15 2023 00:00:00 for libstaroffice by doxygen 1.9.1