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 
48  };
50  enum Alignment { LEFT, RIGHT, CENTER };
51 
54  m_label(""), m_prefix(""), m_suffix(""), m_bullet(""), m_extra("")
55  {
56  }
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 
98  double m_labelWidth ;
106  librevenge::RVNGString m_label ,
107  m_prefix ,
108  m_suffix,
109  m_bullet ;
111  std::string m_extra;
112 };
113 
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 
206 {
207 public:
209  STOFFListManager() : m_listList(), m_sendIdMarkerList() { }
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:
Type
the type of the level
Definition: STOFFList.hxx:46
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< STOFFListLevel > m_levels
the different levels
Definition: STOFFList.hxx:193
void swapId() const
swap the list id
Definition: STOFFList.hxx:148
double m_labelAfterSpace
the minimum distance between the label and the text
Definition: STOFFList.hxx:99
STOFFListLevel getLevel(int levl) const
returns a level if it exists
Definition: STOFFList.hxx:159
librevenge::RVNGString m_prefix
string which preceedes the number if we have an ordered level
Definition: STOFFList.hxx:106
bool isDefault() const
returns true if the level type was not set
Definition: STOFFList.hxx:61
int m_actLevel
the actual levels
Definition: STOFFList.hxx:196
librevenge::RVNGString m_suffix
string which follows the number if we have an ordered level
Definition: STOFFList.hxx:106
Alignment
the item alignment
Definition: STOFFList.hxx:50
Definition: STOFFList.hxx:47
int m_numBeforeLabels
the number of label to show before this
Definition: STOFFList.hxx:101
std::vector< STOFFList > m_listList
the list of created list
Definition: STOFFList.hxx:220
bool operator!=(STOFFListLevel const &levl) const
operator!=
Definition: STOFFList.hxx:76
bool operator==(STOFFListLevel const &levl) const
operator==
Definition: STOFFList.hxx:71
Definition: STOFFList.hxx:47
double m_labelWidth
the minimum label width
Definition: STOFFList.hxx:98
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:127
std::vector< int > m_sendIdMarkerList
the list of send list to interface
Definition: STOFFList.hxx:222
Definition: STOFFList.hxx:50
std::string m_extra
extra data
Definition: STOFFList.hxx:111
Definition: STOFFList.hxx:46
STOFFListManager()
the constructor
Definition: STOFFList.hxx:209
Definition: STOFFList.hxx:46
small structure to keep information about a list level
Definition: STOFFList.hxx:44
Definition: STOFFList.hxx:50
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:167
Type m_type
the type of the level
Definition: STOFFList.hxx:96
Definition: STOFFList.hxx:46
void addTo(librevenge::RVNGPropertyList &propList) const
add the information of this level in the propList
Definition: STOFFList.cxx:46
~STOFFListManager()
the destructor
Definition: STOFFList.hxx:211
friend std::ostream & operator<<(std::ostream &o, STOFFListLevel const &ft)
operator<<
Definition: STOFFList.cxx:134
a small structure used to store the informations about a list
Definition: STOFFList.hxx:115
librevenge::RVNGString m_bullet
the bullet if we have an bullet level
Definition: STOFFList.hxx:106
Definition: STOFFList.hxx:47
Definition: STOFFList.hxx:46
int cmp(STOFFListLevel const &levl) const
comparison function ( compare all values excepted m_startValues
Definition: STOFFList.cxx:106
int getMarker() const
returns the actual modify marker
Definition: STOFFList.hxx:131
STOFFList()
default constructor
Definition: STOFFList.hxx:119
double m_labelBeforeSpace
the extra space between inserting a label
Definition: STOFFList.hxx:97
int getId() const
returns the list id
Definition: STOFFList.hxx:125
Definition: STOFFList.hxx:50
librevenge::RVNGString m_label
the text label
Definition: STOFFList.hxx:106
int m_startValue
the actual value (if this is an ordered level )
Definition: STOFFList.hxx:105
~STOFFListLevel()
destructor
Definition: STOFFList.hxx:58
STOFFListLevel()
basic constructor
Definition: STOFFList.hxx:53
void closeElement() const
close the list element
Definition: STOFFList.hxx:179
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition: STOFFList.hxx:66
Alignment m_alignment
the alignment ( left, center, ...)
Definition: STOFFList.hxx:103
Definition: STOFFList.hxx:46
Definition: STOFFList.hxx:46
std::vector< int > m_nextIndices
Definition: STOFFList.hxx:197
a manager which manages the lists, keeps the different kind of lists, to assure the unicity of each l...
Definition: STOFFList.hxx:205

Generated on Mon Jul 25 2016 14:48:13 for libstaroffice by doxygen 1.8.11