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;
73 
75  bool isDefault() const
76  {
77  return m_type ==DEFAULT;
78  }
80  bool isNumeric() const
81  {
82  return m_type !=DEFAULT && m_type !=NONE && m_type != BULLET;
83  }
85  void addTo(librevenge::RVNGPropertyList &propList, MWAWFontManagerPtr fontManager) const;
86 
88  int getStartValue() const
89  {
90  return m_startValue <= 0 ? 1 : m_startValue;
91  }
92 
94  int cmp(MWAWListLevel const &levl) const;
95 
97  friend std::ostream &operator<<(std::ostream &o, MWAWListLevel const &ft);
98 
104  double m_labelWidth ;
110  librevenge::RVNGString m_label ,
111  m_prefix ,
112  m_suffix,
113  m_bullet ;
115  int m_spanId;
117  std::string m_extra;
118 };
119 
121 class MWAWList
122 {
123 public:
126  : m_levels()
127  , m_actualIndices()
128  , m_nextIndices()
129  , m_actLevel(-1)
130  , m_modifyMarker(1)
131  {
132  for (auto &id : m_id) id = -1;
133  }
134 
136  int getId() const
137  {
138  return m_id[0];
139  }
140 
142  int getMarker() const
143  {
144  return m_modifyMarker;
145  }
147  void resize(int levl);
149  bool isCompatibleWith(int levl, MWAWListLevel const &level) const;
151  bool isCompatibleWith(MWAWList const &newList) const;
153  void updateIndicesFrom(MWAWList const &list);
154 
159  void swapId() const
160  {
161  std::swap(m_id[0], m_id[1]);
162  }
163 
165  void setId(int newId) const;
166 
168  MWAWListLevel getLevel(int levl) const
169  {
170  if (levl >= 0 && levl < int(m_levels.size()))
171  return m_levels[size_t(levl)];
172  MWAW_DEBUG_MSG(("MWAWList::getLevel: can not find level %d\n", levl));
173  return MWAWListLevel();
174  }
176  int numLevels() const
177  {
178  return int(m_levels.size());
179  }
181  void set(int levl, MWAWListLevel const &level);
182 
184  void setLevel(int levl) const;
186  void openElement() const;
188  void closeElement() const {}
190  int getStartValueForNextElement() const;
192  void setStartValueForNextElement(int value);
193 
195  bool isNumeric(int levl) const;
196 
198  bool addTo(int level, librevenge::RVNGPropertyList &pList, MWAWFontManagerPtr fontManager) const;
199 
200 protected:
202  std::vector<MWAWListLevel> m_levels;
203 
204  mutable std::vector<int> m_actualIndices, m_nextIndices;
206  mutable int m_actLevel;
208  mutable int m_id[2];
210  mutable int m_modifyMarker;
211 };
212 
215 {
216 public:
218  explicit MWAWListManager(MWAWFontManagerPtr const &fontManager);
222  bool needToSend(int index, std::vector<int> &idMarkerList) const;
224  std::shared_ptr<MWAWList> getList(int index) const;
226  std::shared_ptr<MWAWList> getNewList(std::shared_ptr<MWAWList> actList, int levl, MWAWListLevel const &level);
227 protected:
231  std::vector<MWAWList> m_listList;
233  mutable std::vector<int> m_sendIdMarkerList;
234 };
235 #endif
236 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWListLevel::Alignment
Alignment
the item alignment
Definition: MWAWList.hxx:50
MWAWList::setId
void setId(int newId) const
set the list id
Definition: MWAWList.cxx:261
MWAWListLevel::Type
Type
the type of the level
Definition: MWAWList.hxx:46
MWAWList::isCompatibleWith
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
MWAWFontManagerPtr
std::shared_ptr< MWAWFontManager > MWAWFontManagerPtr
a smart pointer of MWAWFontManager
Definition: libmwaw_internal.hxx:545
MWAWListManager::m_sendIdMarkerList
std::vector< int > m_sendIdMarkerList
the list of send list to interface
Definition: MWAWList.hxx:233
MWAWList::numLevels
int numLevels() const
returns the number of level
Definition: MWAWList.hxx:176
MWAWListLevel::m_spanId
int m_spanId
the style span id
Definition: MWAWList.hxx:115
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
MWAWListLevel::m_suffix
librevenge::RVNGString m_suffix
string which follows the number if we have an ordered level
Definition: MWAWList.hxx:110
MWAWList::closeElement
void closeElement() const
close the list element
Definition: MWAWList.hxx:188
MWAWListLevel::NONE
Definition: MWAWList.hxx:46
MWAWListLevel::LOWER_ALPHA
Definition: MWAWList.hxx:46
MWAWListLevel::m_startValue
int m_startValue
the actual value (if this is an ordered level )
Definition: MWAWList.hxx:109
MWAWList::set
void set(int levl, MWAWListLevel const &level)
sets a level
Definition: MWAWList.cxx:286
operator<<
std::ostream & operator<<(std::ostream &o, MWAWListLevel const &level)
Definition: MWAWList.cxx:146
MWAWList::isNumeric
bool isNumeric(int levl) const
returns true is a level is numeric
Definition: MWAWList.cxx:352
MWAWList::m_nextIndices
std::vector< int > m_nextIndices
Definition: MWAWList.hxx:204
MWAWListManager::getNewList
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
MWAWListLevel::getStartValue
int getStartValue() const
returns the start value (if set) or 1
Definition: MWAWList.hxx:88
MWAWListLevel::UPPER_ALPHA
Definition: MWAWList.hxx:46
MWAWListManager::needToSend
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
MWAWList::getStartValueForNextElement
int getStartValueForNextElement() const
returns the startvalue corresponding to the actual level ( or -1 for an unknown/unordered list)
Definition: MWAWList.cxx:331
MWAWList::getLevel
MWAWListLevel getLevel(int levl) const
returns a level if it exists
Definition: MWAWList.hxx:168
MWAWListLevel::m_labelBeforeSpace
double m_labelBeforeSpace
the extra space between inserting a label
Definition: MWAWList.hxx:103
MWAWList::m_actLevel
int m_actLevel
the actual levels
Definition: MWAWList.hxx:206
MWAWListLevel::isNumeric
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition: MWAWList.hxx:80
MWAWList::getId
int getId() const
returns the list id
Definition: MWAWList.hxx:136
MWAWList
a small structure used to store the informations about a list
Definition: MWAWList.hxx:121
MWAWListLevel::UPPER_ROMAN
Definition: MWAWList.hxx:47
libmwaw_internal.hxx
MWAWListLevel::isDefault
bool isDefault() const
returns true if the level type was not set
Definition: MWAWList.hxx:75
MWAWListLevel::MWAWListLevel
MWAWListLevel()
basic constructor
Definition: MWAWList.hxx:53
MWAWList::setStartValueForNextElement
void setStartValueForNextElement(int value)
set the startvalue corresponding to the actual level
Definition: MWAWList.cxx:319
MWAWListLevel::operator=
MWAWListLevel & operator=(MWAWListLevel const &)=default
MWAWListLevel::LOWER_ROMAN
Definition: MWAWList.hxx:47
MWAWList::updateIndicesFrom
void updateIndicesFrom(MWAWList const &list)
update the indices, the actual level from newList
Definition: MWAWList.cxx:226
MWAWListLevel::RIGHT
Definition: MWAWList.hxx:50
MWAWList::m_levels
std::vector< MWAWListLevel > m_levels
the different levels
Definition: MWAWList.hxx:202
MWAWList::setLevel
void setLevel(int levl) const
set the list level
Definition: MWAWList.cxx:305
MWAWList::MWAWList
MWAWList()
default constructor
Definition: MWAWList.hxx:125
MWAWListLevel::LABEL
Definition: MWAWList.hxx:47
MWAWListLevel::DEFAULT
Definition: MWAWList.hxx:46
MWAWListLevel::m_bullet
librevenge::RVNGString m_bullet
the bullet if we have an bullet level
Definition: MWAWList.hxx:110
MWAWListManager::MWAWListManager
MWAWListManager(MWAWFontManagerPtr const &fontManager)
the constructor
Definition: MWAWList.cxx:365
MWAWListManager::m_fontManager
MWAWFontManagerPtr m_fontManager
the font manager
Definition: MWAWList.hxx:229
MWAWList.hxx
MWAWList::m_modifyMarker
int m_modifyMarker
a modification marker ( can be used to check if a list has been send to a interface )
Definition: MWAWList.hxx:210
MWAWListLevel::DECIMAL
Definition: MWAWList.hxx:46
MWAWListLevel::LEFT
Definition: MWAWList.hxx:50
MWAWListLevel::~MWAWListLevel
~MWAWListLevel()
destructor
Definition: MWAWList.hxx:72
MWAWList::addTo
bool addTo(int level, librevenge::RVNGPropertyList &pList, MWAWFontManagerPtr fontManager) const
retrieve the list level property
Definition: MWAWList.cxx:267
MWAWList::swapId
void swapId() const
swap the list id
Definition: MWAWList.hxx:159
MWAWListLevel::operator<<
friend std::ostream & operator<<(std::ostream &o, MWAWListLevel const &ft)
operator<<
Definition: MWAWList.cxx:146
MWAWListLevel::BULLET
Definition: MWAWList.hxx:46
MWAWListManager::~MWAWListManager
~MWAWListManager()
the destructor
Definition: MWAWList.cxx:369
MWAWListLevel::m_label
librevenge::RVNGString m_label
the text label
Definition: MWAWList.hxx:110
MWAWListLevel::m_labelWidth
double m_labelWidth
the minimum label width
Definition: MWAWList.hxx:104
MWAWList::m_id
int m_id[2]
the identificator ( actual and auxilliar )
Definition: MWAWList.hxx:208
MWAWListLevel
small structure to keep information about a list level
Definition: MWAWList.hxx:44
MWAWListLevel::m_type
Type m_type
the type of the level
Definition: MWAWList.hxx:100
MWAWFont::addToListLevel
void addToListLevel(librevenge::RVNGPropertyList &propList, std::shared_ptr< MWAWFontConverter > fontConverter) const
add to the propList to a list level
Definition: MWAWFont.cxx:360
MWAWListLevel::m_extra
std::string m_extra
extra data
Definition: MWAWList.hxx:117
MWAWList::openElement
void openElement() const
open the list element
Definition: MWAWList.cxx:342
MWAWListManager::m_listList
std::vector< MWAWList > m_listList
the list of created list
Definition: MWAWList.hxx:231
MWAWListLevel::m_numBeforeLabels
int m_numBeforeLabels
the number of label to show before this
Definition: MWAWList.hxx:102
MWAWListLevel::CENTER
Definition: MWAWList.hxx:50
MWAWListLevel::m_labelAfterSpace
double m_labelAfterSpace
the minimum distance between the label and the text
Definition: MWAWList.hxx:105
MWAWListLevel::cmp
int cmp(MWAWListLevel const &levl) const
comparison function ( compare all values excepted m_startValues
Definition: MWAWList.cxx:116
MWAWListManager
a manager which manages the lists, keeps the different kind of lists, to assure the unicity of each l...
Definition: MWAWList.hxx:214
MWAWList::resize
void resize(int levl)
resize the number of level of the list (keeping only n level)
Definition: MWAWList.cxx:210
MWAWFont.hxx
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
MWAWList::m_actualIndices
std::vector< int > m_actualIndices
Definition: MWAWList.hxx:204
MWAWListLevel::m_prefix
librevenge::RVNGString m_prefix
string which preceedes the number if we have an ordered level
Definition: MWAWList.hxx:110
MWAWListLevel::addTo
void addTo(librevenge::RVNGPropertyList &propList, MWAWFontManagerPtr fontManager) const
add the information of this level in the propList
Definition: MWAWList.cxx:47
MWAWListLevel::m_alignment
Alignment m_alignment
the alignment ( left, center, ...)
Definition: MWAWList.hxx:107
MWAWListManager::getList
std::shared_ptr< MWAWList > getList(int index) const
returns a list with given index ( if found )
Definition: MWAWList.cxx:391
MWAWList::getMarker
int getMarker() const
returns the actual modify marker
Definition: MWAWList.hxx:142

Generated on Sat Jan 25 2020 05:50:07 for libmwaw by doxygen 1.8.16