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_startValue(0)
55  {
56  }
59 
61  bool isDefault() const
62  {
63  return m_type ==DEFAULT;
64  }
66  bool isNumeric() const
67  {
68  return m_type==NUMBER;
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;
94  librevenge::RVNGPropertyList m_propertyList;
96  shared_ptr<STOFFFont> m_font;
99 };
100 
103 {
104 public:
106  explicit STOFFList(bool outline) : m_outline(outline), m_name(""), m_levels(), m_actLevel(-1), m_actualIndices(), m_nextIndices(), m_modifyMarker(1)
107  {
108  m_id[0] = m_id[1] = -1;
109  }
110 
112  int getId() const
113  {
114  return m_id[0];
115  }
116 
118  int getMarker() const
119  {
120  return m_modifyMarker;
121  }
123  void resize(int levl);
125  bool isCompatibleWith(int levl, STOFFListLevel const &level) const;
127  bool isCompatibleWith(STOFFList const &newList) const;
129  void updateIndicesFrom(STOFFList const &list);
130 
135  void swapId() const
136  {
137  int tmp = m_id[0];
138  m_id[0] = m_id[1];
139  m_id[1] = tmp;
140  }
141 
143  void setId(int newId) const;
144 
146  STOFFListLevel getLevel(int levl) const
147  {
148  if (levl >= 0 && levl < int(m_levels.size()))
149  return m_levels[size_t(levl)];
150  STOFF_DEBUG_MSG(("STOFFList::getLevel: can not find level %d\n", levl));
151  return STOFFListLevel();
152  }
154  int numLevels() const
155  {
156  return int(m_levels.size());
157  }
159  void set(int levl, STOFFListLevel const &level);
160 
162  void setLevel(int levl) const;
164  void openElement() const;
166  void closeElement() const {}
168  int getStartValueForNextElement() const;
170  void setStartValueForNextElement(int value);
171 
173  bool isNumeric(int levl) const;
174 
176  bool addTo(int level, librevenge::RVNGPropertyList &pList) const;
177 
179  bool m_outline;
181  librevenge::RVNGString m_name;
182 protected:
184  std::vector<STOFFListLevel> m_levels;
185 
187  mutable int m_actLevel;
188  mutable std::vector<int> m_actualIndices, m_nextIndices;
190  mutable int m_id[2];
192  mutable int m_modifyMarker;
193 };
194 
197 {
198 public:
204  bool needToSend(int index, std::vector<int> &idMarkerList) const;
206  shared_ptr<STOFFList> getList(int index) const;
208  shared_ptr<STOFFList> getNewList(shared_ptr<STOFFList> actList, int levl, STOFFListLevel const &level);
210  shared_ptr<STOFFList> addList(shared_ptr<STOFFList> actList);
211 protected:
213  std::vector<STOFFList> m_listList;
215  mutable std::vector<int> m_sendIdMarkerList;
216 };
217 #endif
218 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Type
the type of the level
Definition: STOFFList.hxx:50
void resize(int levl)
resize the number of level of the list (keeping only n level)
Definition: STOFFList.cxx:86
int m_modifyMarker
a modification marker ( can be used to check if a list has been send to a interface ) ...
Definition: STOFFList.hxx:192
bool isNumeric(int levl) const
returns true is a level is numeric
Definition: STOFFList.cxx:230
std::vector< STOFFListLevel > m_levels
the different levels
Definition: STOFFList.hxx:184
shared_ptr< STOFFList > getList(int index) const
returns a list with given index ( if found )
Definition: STOFFList.cxx:261
shared_ptr< STOFFFont > m_font
the font
Definition: STOFFList.hxx:96
void setLevel(int levl) const
set the list level
Definition: STOFFList.cxx:183
void swapId() const
swap the list id
Definition: STOFFList.hxx:135
STOFFList(bool outline)
default constructor
Definition: STOFFList.hxx:106
STOFFListLevel getLevel(int levl) const
returns a level if it exists
Definition: STOFFList.hxx:146
bool isDefault() const
returns true if the level type was not set
Definition: STOFFList.hxx:61
int m_id[2]
the identificator ( actual and auxilliar )
Definition: STOFFList.hxx:190
Definition: STOFFList.hxx:50
int m_actLevel
the actual levels
Definition: STOFFList.hxx:187
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
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::vector< STOFFList > m_listList
the list of created list
Definition: STOFFList.hxx:213
bool operator!=(STOFFListLevel const &levl) const
operator!=
Definition: STOFFList.hxx:76
bool operator==(STOFFListLevel const &levl) const
operator==
Definition: STOFFList.hxx:71
void updateIndicesFrom(STOFFList const &list)
update the indices, the actual level from newList
Definition: STOFFList.cxx:102
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:141
std::vector< int > m_sendIdMarkerList
the list of send list to interface
Definition: STOFFList.hxx:215
void setStartValueForNextElement(int value)
set the startvalue corresponding to the actual level
Definition: STOFFList.cxx:197
bool m_outline
flag to know if the list is a outline list
Definition: STOFFList.hxx:179
STOFFListManager()
the constructor
Definition: STOFFList.hxx:200
small structure to keep information about a list level
Definition: STOFFList.hxx:48
int getStartValue() const
returns the start value (if set) or 1
Definition: STOFFList.hxx:84
int numLevels() const
returns the number of level
Definition: STOFFList.hxx:154
Type m_type
the type of the level
Definition: STOFFList.hxx:92
shared_ptr< STOFFList > addList(shared_ptr< STOFFList > actList)
add a new list
Definition: STOFFList.cxx:274
void openElement() const
open the list element
Definition: STOFFList.cxx:220
void addTo(librevenge::RVNGPropertyList &propList) const
add the information of this level in the propList
Definition: STOFFList.cxx:52
~STOFFListManager()
the destructor
Definition: STOFFList.hxx:202
void set(int levl, STOFFListLevel const &level)
sets a level
Definition: STOFFList.cxx:164
int getStartValueForNextElement() const
returns the startvalue corresponding to the actual level ( or -1 for an unknown/unordered list) ...
Definition: STOFFList.cxx:209
void setId(int newId) const
set the list id
Definition: STOFFList.cxx:137
a small structure used to store the informations about a list
Definition: STOFFList.hxx:102
Definition: STOFFList.hxx:50
int cmp(STOFFListLevel const &levl) const
comparison function ( compare all values excepted m_startValues
Definition: STOFFList.cxx:67
std::vector< int > m_actualIndices
Definition: STOFFList.hxx:188
librevenge::RVNGPropertyList m_propertyList
the propertyList
Definition: STOFFList.hxx:94
int getMarker() const
returns the actual modify marker
Definition: STOFFList.hxx:118
int getId() const
returns the list id
Definition: STOFFList.hxx:112
Class to store font.
Definition: STOFFFont.hxx:43
librevenge::RVNGString m_name
the list name
Definition: STOFFList.hxx:181
bool addTo(int level, librevenge::RVNGPropertyList &pList) const
retrieve the list level property
Definition: STOFFList.cxx:143
int m_startValue
the actual value (if this is an ordered level )
Definition: STOFFList.hxx:98
~STOFFListLevel()
destructor
Definition: STOFFList.cxx:48
STOFFListLevel()
basic constructor
Definition: STOFFList.hxx:53
void closeElement() const
close the list element
Definition: STOFFList.hxx:166
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition: STOFFList.hxx:66
Definition: STOFFList.hxx:50
Definition: STOFFList.hxx:50
shared_ptr< STOFFList > getNewList(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
std::vector< int > m_nextIndices
Definition: STOFFList.hxx:188
a manager which manages the lists, keeps the different kind of lists, to assure the unicity of each l...
Definition: STOFFList.hxx:196

Generated on Sat Jul 29 2017 14:32:44 for libstaroffice by doxygen 1.8.8