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_label(""), m_prefix(""), m_suffix(""), m_bullet(""), m_spanId(-1), 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  void addTo(librevenge::RVNGPropertyList &propList, MWAWFontManagerPtr fontManager) const;
72 
74  int getStartValue() const
75  {
76  return m_startValue <= 0 ? 1 : m_startValue;
77  }
78 
80  int cmp(MWAWListLevel const &levl) const;
81 
83  friend std::ostream &operator<<(std::ostream &o, MWAWListLevel const &ft);
84 
90  double m_labelWidth ;
96  librevenge::RVNGString m_label ,
97  m_prefix ,
98  m_suffix,
99  m_bullet ;
101  int m_spanId;
103  std::string m_extra;
104 };
105 
107 class MWAWList
108 {
109 public:
111  MWAWList() : m_levels(), m_actualIndices(), m_nextIndices(), m_actLevel(-1), m_modifyMarker(1)
112  {
113  m_id[0] = m_id[1] = -1;
114  }
115 
117  int getId() const
118  {
119  return m_id[0];
120  }
121 
123  int getMarker() const
124  {
125  return m_modifyMarker;
126  }
128  void resize(int levl);
130  bool isCompatibleWith(int levl, MWAWListLevel const &level) const;
132  bool isCompatibleWith(MWAWList const &newList) const;
134  void updateIndicesFrom(MWAWList const &list);
135 
140  void swapId() const
141  {
142  int tmp = m_id[0];
143  m_id[0] = m_id[1];
144  m_id[1] = tmp;
145  }
146 
148  void setId(int newId) const;
149 
151  MWAWListLevel getLevel(int levl) const
152  {
153  if (levl >= 0 && levl < int(m_levels.size()))
154  return m_levels[size_t(levl)];
155  MWAW_DEBUG_MSG(("MWAWList::getLevel: can not find level %d\n", levl));
156  return MWAWListLevel();
157  }
159  int numLevels() const
160  {
161  return int(m_levels.size());
162  }
164  void set(int levl, MWAWListLevel const &level);
165 
167  void setLevel(int levl) const;
169  void openElement() const;
171  void closeElement() const {}
173  int getStartValueForNextElement() const;
175  void setStartValueForNextElement(int value);
176 
178  bool isNumeric(int levl) const;
179 
181  bool addTo(int level, librevenge::RVNGPropertyList &pList, MWAWFontManagerPtr fontManager) const;
182 
183 protected:
185  std::vector<MWAWListLevel> m_levels;
186 
187  mutable std::vector<int> m_actualIndices, m_nextIndices;
189  mutable int m_actLevel;
191  mutable int m_id[2];
193  mutable int m_modifyMarker;
194 };
195 
198 {
199 public:
201  explicit MWAWListManager(MWAWFontManagerPtr fontManager);
203  ~MWAWListManager();
205  bool needToSend(int index, std::vector<int> &idMarkerList) const;
207  shared_ptr<MWAWList> getList(int index) const;
209  shared_ptr<MWAWList> getNewList(shared_ptr<MWAWList> actList, int levl, MWAWListLevel const &level);
210 protected:
214  std::vector<MWAWList> m_listList;
216  mutable std::vector<int> m_sendIdMarkerList;
217 };
218 #endif
219 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
int getId() const
returns the list id
Definition: MWAWList.hxx:117
MWAWList()
default constructor
Definition: MWAWList.hxx:111
librevenge::RVNGString m_label
the text label
Definition: MWAWList.hxx:96
Definition: MWAWList.hxx:50
shared_ptr< MWAWFontManager > MWAWFontManagerPtr
a smart pointer of MWAWFontManager
Definition: libmwaw_internal.hxx:499
int m_modifyMarker
a modification marker ( can be used to check if a list has been send to a interface ) ...
Definition: MWAWList.hxx:193
librevenge::RVNGString m_prefix
string which preceedes the number if we have an ordered level
Definition: MWAWList.hxx:96
Alignment
the item alignment
Definition: MWAWList.hxx:50
~MWAWListLevel()
destructor
Definition: MWAWList.hxx:58
Definition: MWAWList.hxx:46
double m_labelBeforeSpace
the extra space between inserting a label
Definition: MWAWList.hxx:89
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:96
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:88
int m_spanId
the style span id
Definition: MWAWList.hxx:101
std::vector< int > m_nextIndices
Definition: MWAWList.hxx:187
Definition: MWAWList.hxx:47
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition: MWAWList.hxx:66
int cmp(MWAWListLevel const &levl) const
comparison function ( compare all values excepted m_startValues
Definition: MWAWList.cxx:116
double m_labelAfterSpace
the minimum distance between the label and the text
Definition: MWAWList.hxx:91
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:127
std::vector< MWAWListLevel > m_levels
the different levels
Definition: MWAWList.hxx:185
void addTo(librevenge::RVNGPropertyList &propList, MWAWFontManagerPtr fontManager) const
add the information of this level in the propList
Definition: MWAWList.cxx:47
Definition: MWAWList.hxx:50
void swapId() const
swap the list id
Definition: MWAWList.hxx:140
std::vector< int > m_sendIdMarkerList
the list of send list to interface
Definition: MWAWList.hxx:216
Definition: MWAWList.hxx:46
Definition: MWAWList.hxx:50
Definition: MWAWList.hxx:47
bool isDefault() const
returns true if the level type was not set
Definition: MWAWList.hxx:61
a manager which manages the lists, keeps the different kind of lists, to assure the unicity of each l...
Definition: MWAWList.hxx:197
librevenge::RVNGString m_suffix
string which follows the number if we have an ordered level
Definition: MWAWList.hxx:96
Definition: MWAWList.hxx:46
void closeElement() const
close the list element
Definition: MWAWList.hxx:171
int getStartValue() const
returns the start value (if set) or 1
Definition: MWAWList.hxx:74
Type m_type
the type of the level
Definition: MWAWList.hxx:86
int numLevels() const
returns the number of level
Definition: MWAWList.hxx:159
Definition: MWAWList.hxx:47
friend std::ostream & operator<<(std::ostream &o, MWAWListLevel const &ft)
operator<<
Definition: MWAWList.cxx:146
MWAWFontManagerPtr m_fontManager
the font manager
Definition: MWAWList.hxx:212
std::string m_extra
extra data
Definition: MWAWList.hxx:103
Definition: MWAWList.hxx:46
Alignment m_alignment
the alignment ( left, center, ...)
Definition: MWAWList.hxx:93
int getMarker() const
returns the actual modify marker
Definition: MWAWList.hxx:123
double m_labelWidth
the minimum label width
Definition: MWAWList.hxx:90
a small structure used to store the informations about a list
Definition: MWAWList.hxx:107
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:95
int m_actLevel
the actual levels
Definition: MWAWList.hxx:189
std::vector< MWAWList > m_listList
the list of created list
Definition: MWAWList.hxx:214
MWAWListLevel getLevel(int levl) const
returns a level if it exists
Definition: MWAWList.hxx:151

Generated on Wed Jun 7 2017 19:47:49 for libmwaw by doxygen 1.8.12