MWAWList.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 /* libmwaw
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 MWAW_LIST_H
35 # define MWAW_LIST_H
36 
37 #include <iostream>
38 
39 #include <vector>
40 
41 #include <librevenge/librevenge.h>
42 
44 struct MWAWListLevel {
48  };
50  enum Alignment { LEFT, RIGHT, CENTER };
51 
54  : m_type(NONE)
56  , m_labelBeforeSpace(0.0)
57  , m_labelWidth(0.1)
58  , m_labelAfterSpace(0.0)
59  , m_alignment(LEFT)
60  , m_startValue(0)
61  , m_label("")
62  , m_prefix("")
63  , m_suffix("")
64  , m_bullet("")
65  , m_spanId(-1)
66  , m_extra("")
67  {
68  }
69  MWAWListLevel(MWAWListLevel const &)=default;
70  MWAWListLevel &operator=(MWAWListLevel const &)=default;
74 
76  bool isDefault() const
77  {
78  return m_type ==DEFAULT;
79  }
81  bool isNumeric() const
82  {
83  return m_type !=DEFAULT && m_type !=NONE && m_type != BULLET;
84  }
86  void addTo(librevenge::RVNGPropertyList &propList, MWAWFontManagerPtr fontManager) const;
87 
89  int getStartValue() const
90  {
91  return m_startValue <= 0 ? 1 : m_startValue;
92  }
93 
95  int cmp(MWAWListLevel const &levl) const;
96 
98  friend std::ostream &operator<<(std::ostream &o, MWAWListLevel const &ft);
99 
105  double m_labelWidth ;
111  librevenge::RVNGString m_label ,
112  m_prefix ,
113  m_suffix,
114  m_bullet ;
116  int m_spanId;
118  std::string m_extra;
119 };
120 
122 class MWAWList
123 {
124 public:
127  : m_levels()
128  , m_actualIndices()
129  , m_nextIndices()
130  , m_actLevel(-1)
131  , m_modifyMarker(1)
132  {
133  for (auto &id : m_id) id = -1;
134  }
135 
137  int getId() const
138  {
139  return m_id[0];
140  }
141 
143  int getMarker() const
144  {
145  return m_modifyMarker;
146  }
148  void resize(int levl);
150  bool isCompatibleWith(int levl, MWAWListLevel const &level) const;
152  bool isCompatibleWith(MWAWList const &newList) const;
154  void updateIndicesFrom(MWAWList const &list);
155 
160  void swapId() const
161  {
162  std::swap(m_id[0], m_id[1]);
163  }
164 
166  void setId(int newId) const;
167 
169  MWAWListLevel getLevel(int levl) const
170  {
171  if (levl >= 0 && levl < int(m_levels.size()))
172  return m_levels[size_t(levl)];
173  MWAW_DEBUG_MSG(("MWAWList::getLevel: can not find level %d\n", levl));
174  return MWAWListLevel();
175  }
177  int numLevels() const
178  {
179  return int(m_levels.size());
180  }
182  void set(int levl, MWAWListLevel const &level);
183 
185  void setLevel(int levl) const;
187  void openElement() const;
189  void closeElement() const {}
191  int getStartValueForNextElement() const;
193  void setStartValueForNextElement(int value);
194 
196  bool isNumeric(int levl) const;
197 
199  bool addTo(int level, librevenge::RVNGPropertyList &pList, MWAWFontManagerPtr fontManager) const;
200 
201 protected:
203  std::vector<MWAWListLevel> m_levels;
204 
205  mutable std::vector<int> m_actualIndices, m_nextIndices;
207  mutable int m_actLevel;
209  mutable int m_id[2];
211  mutable int m_modifyMarker;
212 };
213 
216 {
217 public:
219  explicit MWAWListManager(MWAWFontManagerPtr const &fontManager);
223  bool needToSend(int index, std::vector<int> &idMarkerList) const;
225  std::shared_ptr<MWAWList> getList(int index) const;
227  std::shared_ptr<MWAWList> getNewList(std::shared_ptr<MWAWList> actList, int levl, MWAWListLevel const &level);
228 protected:
232  std::vector<MWAWList> m_listList;
234  mutable std::vector<int> m_sendIdMarkerList;
235 };
236 #endif
237 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
int getId() const
returns the list id
Definition: MWAWList.hxx:137
MWAWList()
default constructor
Definition: MWAWList.hxx:126
librevenge::RVNGString m_label
the text label
Definition: MWAWList.hxx:111
Definition: MWAWList.hxx:50
int m_modifyMarker
a modification marker ( can be used to check if a list has been send to a interface ) ...
Definition: MWAWList.hxx:211
librevenge::RVNGString m_prefix
string which preceedes the number if we have an ordered level
Definition: MWAWList.hxx:111
MWAWListLevel & operator=(MWAWListLevel const &)=default
Alignment
the item alignment
Definition: MWAWList.hxx:50
~MWAWListLevel()
destructor
Definition: MWAWList.hxx:73
Definition: MWAWList.hxx:46
double m_labelBeforeSpace
the extra space between inserting a label
Definition: MWAWList.hxx:104
MWAWListLevel()
basic constructor
Definition: MWAWList.hxx:53
Definition: MWAWList.hxx:46
librevenge::RVNGString m_bullet
the bullet if we have an bullet level
Definition: MWAWList.hxx:111
void updateIndicesFrom(MWAWList const &list)
update the indices, the actual level from newList
Definition: MWAWList.cxx:226
Definition: MWAWList.hxx:46
small structure to keep information about a list level
Definition: MWAWList.hxx:44
int m_numBeforeLabels
the number of label to show before this
Definition: MWAWList.hxx:103
int m_spanId
the style span id
Definition: MWAWList.hxx:116
std::vector< int > m_nextIndices
Definition: MWAWList.hxx:205
Definition: MWAWList.hxx:47
int m_id[2]
the identificator ( actual and auxilliar )
Definition: MWAWList.hxx:209
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition: MWAWList.hxx:81
int cmp(MWAWListLevel const &levl) const
comparison function ( compare all values excepted m_startValues
Definition: MWAWList.cxx:116
bool addTo(int level, librevenge::RVNGPropertyList &pList, MWAWFontManagerPtr fontManager) const
retrieve the list level property
Definition: MWAWList.cxx:267
double m_labelAfterSpace
the minimum distance between the label and the text
Definition: MWAWList.hxx:106
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
void setStartValueForNextElement(int value)
set the startvalue corresponding to the actual level
Definition: MWAWList.cxx:319
std::vector< MWAWListLevel > m_levels
the different levels
Definition: MWAWList.hxx:203
void addTo(librevenge::RVNGPropertyList &propList, MWAWFontManagerPtr fontManager) const
add the information of this level in the propList
Definition: MWAWList.cxx:47
void openElement() const
open the list element
Definition: MWAWList.cxx:342
Definition: MWAWList.hxx:50
std::shared_ptr< MWAWFontManager > MWAWFontManagerPtr
a smart pointer of MWAWFontManager
Definition: libmwaw_internal.hxx:547
bool isCompatibleWith(int levl, MWAWListLevel const &level) const
returns true if we can add a new level in the list without changing is meaning
Definition: MWAWList.cxx:238
void swapId() const
swap the list id
Definition: MWAWList.hxx:160
std::vector< int > m_sendIdMarkerList
the list of send list to interface
Definition: MWAWList.hxx:234
Definition: MWAWList.hxx:46
Definition: MWAWList.hxx:50
Definition: MWAWList.hxx:47
void resize(int levl)
resize the number of level of the list (keeping only n level)
Definition: MWAWList.cxx:210
bool isDefault() const
returns true if the level type was not set
Definition: MWAWList.hxx:76
a manager which manages the lists, keeps the different kind of lists, to assure the unicity of each l...
Definition: MWAWList.hxx:215
librevenge::RVNGString m_suffix
string which follows the number if we have an ordered level
Definition: MWAWList.hxx:111
Definition: MWAWList.hxx:46
MWAWListManager(MWAWFontManagerPtr const &fontManager)
the constructor
Definition: MWAWList.cxx:365
void closeElement() const
close the list element
Definition: MWAWList.hxx:189
int getStartValue() const
returns the start value (if set) or 1
Definition: MWAWList.hxx:89
~MWAWListManager()
the destructor
Definition: MWAWList.cxx:369
Type m_type
the type of the level
Definition: MWAWList.hxx:101
int numLevels() const
returns the number of level
Definition: MWAWList.hxx:177
std::shared_ptr< MWAWList > getNewList(std::shared_ptr< MWAWList > actList, int levl, MWAWListLevel const &level)
returns a new list corresponding to a list where we have a new level
Definition: MWAWList.cxx:404
std::shared_ptr< MWAWList > getList(int index) const
returns a list with given index ( if found )
Definition: MWAWList.cxx:391
Definition: MWAWList.hxx:47
friend std::ostream & operator<<(std::ostream &o, MWAWListLevel const &ft)
operator<<
Definition: MWAWList.cxx:146
std::vector< int > m_actualIndices
Definition: MWAWList.hxx:205
MWAWFontManagerPtr m_fontManager
the font manager
Definition: MWAWList.hxx:230
bool isNumeric(int levl) const
returns true is a level is numeric
Definition: MWAWList.cxx:352
std::string m_extra
extra data
Definition: MWAWList.hxx:118
void setLevel(int levl) const
set the list level
Definition: MWAWList.cxx:305
bool needToSend(int index, std::vector< int > &idMarkerList) const
check if a list need to be send/resend to the interface
Definition: MWAWList.cxx:373
Definition: MWAWList.hxx:46
Alignment m_alignment
the alignment ( left, center, ...)
Definition: MWAWList.hxx:108
int getMarker() const
returns the actual modify marker
Definition: MWAWList.hxx:143
void setId(int newId) const
set the list id
Definition: MWAWList.cxx:261
int getStartValueForNextElement() const
returns the startvalue corresponding to the actual level ( or -1 for an unknown/unordered list) ...
Definition: MWAWList.cxx:331
double m_labelWidth
the minimum label width
Definition: MWAWList.hxx:105
a small structure used to store the informations about a list
Definition: MWAWList.hxx:122
Type
the type of the level
Definition: MWAWList.hxx:46
int m_startValue
the actual value (if this is an ordered level )
Definition: MWAWList.hxx:110
int m_actLevel
the actual levels
Definition: MWAWList.hxx:207
std::vector< MWAWList > m_listList
the list of created list
Definition: MWAWList.hxx:232
MWAWListLevel getLevel(int levl) const
returns a level if it exists
Definition: MWAWList.hxx:169

Generated for libmwaw by doxygen 1.8.14