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 <libwpd/libwpd.h>
42 
43 class WPXPropertyList;
44 class WPXDocumentInterface;
45 
47 struct MWAWListLevel {
51  };
53  enum Alignment { LEFT, RIGHT, CENTER };
54 
57  m_label(""), m_prefix(""), m_suffix(""), m_bullet(""), m_extra("") {
58  }
61 
63  bool isDefault() const {
64  return m_type ==DEFAULT;
65  }
67  bool isNumeric() const {
68  return m_type !=DEFAULT && m_type !=NONE && m_type != BULLET;
69  }
71  void addTo(WPXPropertyList &propList) const;
72 
74  int getStartValue() const {
75  return m_startValue <= 0 ? 1 : m_startValue;
76  }
77 
79  int cmp(MWAWListLevel const &levl) const;
80 
82  friend std::ostream &operator<<(std::ostream &o, MWAWListLevel const &ft);
83 
87  double m_labelWidth ;
95  WPXString m_label ,
96  m_prefix ,
97  m_suffix,
98  m_bullet ;
100  std::string m_extra;
101 };
102 
104 class MWAWList
105 {
106 public:
109  m_id[0] = m_id[1] = -1;
110  }
111 
113  int getId() const {
114  return m_id[0];
115  }
116 
118  void resize(int levl);
120  bool isCompatibleWith(int levl, MWAWListLevel const &level) const;
122  bool isCompatibleWith(MWAWList const &newList) const;
124  void updateIndicesFrom(MWAWList const &list);
125 
130  void swapId() const {
131  int tmp = m_id[0];
132  m_id[0] = m_id[1];
133  m_id[1] = tmp;
134  }
135 
137  void setId(int newId) const;
138 
140  MWAWListLevel getLevel(int levl) const {
141  if (levl >= 0 && levl < int(m_levels.size()))
142  return m_levels[size_t(levl)];
143  MWAW_DEBUG_MSG(("MWAWList::getLevel: can not find level %d\n", levl));
144  return MWAWListLevel();
145  }
147  int numLevels() const {
148  return int(m_levels.size());
149  }
151  void set(int levl, MWAWListLevel const &level);
152 
154  void setLevel(int levl) const;
156  void openElement() const;
158  void closeElement() const {}
160  int getStartValueForNextElement() const;
162  void setStartValueForNextElement(int value);
163 
165  bool isNumeric(int levl) const;
166 
168  void sendTo(WPXDocumentInterface &docInterface, int level) const;
169 
170 protected:
172  std::vector<MWAWListLevel> m_levels;
173 
175  mutable int m_actLevel;
176  mutable std::vector<int> m_actualIndices, m_nextIndices;
178  mutable int m_id[2];
179 };
180 
183 {
184 public:
190  bool send(int index, WPXDocumentInterface &docInterface) const;
192  shared_ptr<MWAWList> getList(int index) const;
194  shared_ptr<MWAWList> getNewList(shared_ptr<MWAWList> actList, int levl, MWAWListLevel const &level);
195 protected:
197  void resetSend(size_t id) const;
199  std::vector<MWAWList> m_listList;
201  mutable std::vector<bool> m_sendIdList;
202 };
203 #endif
204 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWList()
default constructor
Definition: MWAWList.hxx:108
Definition: MWAWList.hxx:53
void setId(int newId) const
set the list id
Definition: MWAWList.cxx:239
bool isDefault() const
returns true if the level type was not set
Definition: MWAWList.hxx:63
Alignment
the item alignement
Definition: MWAWList.hxx:53
~MWAWListLevel()
destructor
Definition: MWAWList.hxx:60
shared_ptr< MWAWList > getNewList(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:385
Definition: MWAWList.hxx:49
double m_labelBeforeSpace
the extra space between inserting a label
Definition: MWAWList.hxx:86
void openElement() const
open the list element
Definition: MWAWList.cxx:318
MWAWListLevel()
basic constructor
Definition: MWAWList.hxx:56
int cmp(MWAWListLevel const &levl) const
comparison function ( compare all values excepted m_startValues
Definition: MWAWList.cxx:103
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition: MWAWList.hxx:67
Definition: MWAWList.hxx:49
void updateIndicesFrom(MWAWList const &list)
update the indices, the actual level from newList
Definition: MWAWList.cxx:205
Definition: MWAWList.hxx:49
MWAWListLevel getLevel(int levl) const
returns a level if it exists
Definition: MWAWList.hxx:140
small structure to keep information about a list level
Definition: MWAWList.hxx:47
int m_numBeforeLabels
the number of label to show before this
Definition: MWAWList.hxx:90
std::vector< int > m_nextIndices
Definition: MWAWList.hxx:176
int getStartValueForNextElement() const
returns the startvalue corresponding to the actual level ( or -1 for an unknown/unordered list) ...
Definition: MWAWList.cxx:307
Definition: MWAWList.hxx:50
int m_id[2]
the identificator ( actual and auxilliar )
Definition: MWAWList.hxx:178
double m_labelAfterSpace
the minimum distance between the label and the text
Definition: MWAWList.hxx:88
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:111
void setStartValueForNextElement(int value)
set the startvalue corresponding to the actual level
Definition: MWAWList.cxx:298
std::vector< MWAWListLevel > m_levels
the different levels
Definition: MWAWList.hxx:172
Definition: MWAWList.hxx:53
void setLevel(int levl) const
set the list level
Definition: MWAWList.cxx:284
WPXString m_suffix
string which follows the number if we have an ordered level
Definition: MWAWList.hxx:95
WPXString m_prefix
string which preceedes the number if we have an ordered level
Definition: MWAWList.hxx:95
int getId() const
returns the list id
Definition: MWAWList.hxx:113
Definition: MWAWList.hxx:49
void sendTo(WPXDocumentInterface &docInterface, int level) const
send the list level information to the document interface.
Definition: MWAWList.cxx:245
Definition: MWAWList.hxx:53
Definition: MWAWList.hxx:50
void resize(int levl)
resize the number of level of the list (keeping only n level)
Definition: MWAWList.cxx:190
void closeElement() const
close the list element
Definition: MWAWList.hxx:158
void resetSend(size_t id) const
reset the list id corresponding to a list
Definition: MWAWList.cxx:362
shared_ptr< MWAWList > getList(int index) const
returns a list with given index ( if found )
Definition: MWAWList.cxx:372
a manager which manages the lists, keeps the different kind of lists, to assure the unicity of each l...
Definition: MWAWList.hxx:182
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:216
Definition: MWAWList.hxx:49
~MWAWListManager()
the destructor
Definition: MWAWList.hxx:188
Type m_type
the type of the level
Definition: MWAWList.hxx:85
int getStartValue() const
returns the start value (if set) or 1
Definition: MWAWList.hxx:74
Definition: MWAWList.hxx:50
friend std::ostream & operator<<(std::ostream &o, MWAWListLevel const &ft)
operator&lt;&lt;
Definition: MWAWList.cxx:131
std::vector< int > m_actualIndices
Definition: MWAWList.hxx:176
std::vector< bool > m_sendIdList
the list of send list to interface
Definition: MWAWList.hxx:201
std::string m_extra
extra data
Definition: MWAWList.hxx:100
bool isNumeric(int levl) const
returns true is a level is numeric
Definition: MWAWList.cxx:328
Definition: MWAWList.hxx:49
WPXString m_bullet
the bullet if we have an bullet level
Definition: MWAWList.hxx:95
Alignment m_alignment
the alignement ( left, center, ...)
Definition: MWAWList.hxx:92
WPXString m_label
the text label
Definition: MWAWList.hxx:95
int numLevels() const
returns the number of level
Definition: MWAWList.hxx:147
void swapId() const
swap the list id
Definition: MWAWList.hxx:130
double m_labelWidth
the minimum label width
Definition: MWAWList.hxx:87
a small structure used to store the informations about a list
Definition: MWAWList.hxx:104
Type
the type of the level
Definition: MWAWList.hxx:49
int m_startValue
the actual value (if this is an ordered level )
Definition: MWAWList.hxx:94
MWAWListManager()
the constructor
Definition: MWAWList.hxx:186
int m_actLevel
the actual levels
Definition: MWAWList.hxx:175
void set(int levl, MWAWListLevel const &level)
sets a level
Definition: MWAWList.cxx:269
std::vector< MWAWList > m_listList
the list of created list
Definition: MWAWList.hxx:199
bool send(int index, WPXDocumentInterface &docInterface) const
send the list to the document interface.
Definition: MWAWList.cxx:341
void addTo(WPXPropertyList &propList) const
add the information of this level in the propList
Definition: MWAWList.cxx:46

Generated on Tue Jun 24 2014 16:46:26 for libmwaw by doxygen 1.8.5