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 
46 struct MWAWListLevel {
50  };
52  enum Alignment { LEFT, RIGHT, CENTER };
53 
56  m_label(""), m_prefix(""), m_suffix(""), m_bullet(""), m_extra("") {
57  }
60 
62  bool isDefault() const {
63  return m_type ==DEFAULT;
64  }
66  bool isNumeric() const {
67  return m_type !=DEFAULT && m_type !=NONE && m_type != BULLET;
68  }
70  void addTo(WPXPropertyList &propList) const;
71 
73  int getStartValue() const {
74  return m_startValue <= 0 ? 1 : m_startValue;
75  }
76 
78  int cmp(MWAWListLevel const &levl) const;
79 
81  friend std::ostream &operator<<(std::ostream &o, MWAWListLevel const &ft);
82 
86  double m_labelWidth ;
94  WPXString m_label ,
95  m_prefix ,
96  m_suffix,
97  m_bullet ;
99  std::string m_extra;
100 };
101 
103 class MWAWList
104 {
105 public:
108  m_id[0] = m_id[1] = -1;
109  }
110 
112  int getId() const {
113  return m_id[0];
114  }
115 
117  int getMarker() const {
118  return m_modifyMarker;
119  }
121  void resize(int levl);
123  bool isCompatibleWith(int levl, MWAWListLevel const &level) const;
125  bool isCompatibleWith(MWAWList const &newList) const;
127  void updateIndicesFrom(MWAWList const &list);
128 
133  void swapId() const {
134  int tmp = m_id[0];
135  m_id[0] = m_id[1];
136  m_id[1] = tmp;
137  }
138 
140  void setId(int newId) const;
141 
143  MWAWListLevel getLevel(int levl) const {
144  if (levl >= 0 && levl < int(m_levels.size()))
145  return m_levels[size_t(levl)];
146  MWAW_DEBUG_MSG(("MWAWList::getLevel: can not find level %d\n", levl));
147  return MWAWListLevel();
148  }
150  int numLevels() const {
151  return int(m_levels.size());
152  }
154  void set(int levl, MWAWListLevel const &level);
155 
157  void setLevel(int levl) const;
159  void openElement() const;
161  void closeElement() const {}
163  int getStartValueForNextElement() const;
165  void setStartValueForNextElement(int value);
166 
168  bool isNumeric(int levl) const;
169 
171  bool addTo(int level, WPXPropertyList &pList) const;
172 
173 protected:
175  std::vector<MWAWListLevel> m_levels;
176 
178  mutable int m_actLevel;
179  mutable std::vector<int> m_actualIndices, m_nextIndices;
181  mutable int m_id[2];
183  mutable int m_modifyMarker;
184 };
185 
188 {
189 public:
195  bool needToSend(int index, std::vector<int> &idMarkerList) const;
197  shared_ptr<MWAWList> getList(int index) const;
199  shared_ptr<MWAWList> getNewList(shared_ptr<MWAWList> actList, int levl, MWAWListLevel const &level);
200 protected:
202  std::vector<MWAWList> m_listList;
204  mutable std::vector<int> m_sendIdMarkerList;
205 };
206 #endif
207 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:

Generated on Tue May 6 2014 09:50:49 for libmwaw by doxygen 1.8.3.1