WPSList.h Source File documentation

WPSList.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/* libwps
3 * Version: MPL 2.0 / LGPLv2.1+
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * Major Contributor(s):
10 * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
11 * Copyright (C) 2006, 2007 Andrew Ziem
12 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
13 * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
14 * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
15 *
16 * For minor contributions see the git repository.
17 *
18 * Alternatively, the contents of this file may be used under the terms
19 * of the GNU Lesser General Public License Version 2.1 or later
20 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
21 * applicable instead of those above.
22 *
23 * For further information visit http://libwps.sourceforge.net
24 */
25
26#ifndef WPS_LIST_H
27# define WPS_LIST_H
28
29#include <iostream>
30#include <vector>
31
32#include <librevenge/librevenge.h>
33#include "libwps_internal.h"
34
36 class WPSList
37{
38public:
40 struct Level
41 {
42
44 Level() : m_labelIndent(0.0), m_labelWidth(0.0), m_startValue(-1), m_type(libwps::NONE),
45 m_prefix(""), m_suffix(""), m_bullet(""), m_sendToInterface(false) { }
46
48 bool isDefault() const
49 {
50 return m_type ==libwps::NONE;
51 }
52
53 bool isNumeric() const
54 {
55 return m_type !=libwps::NONE && m_type != libwps::BULLET;
56 }
57
58 void addTo(librevenge::RVNGPropertyList &propList, int startVal) const;
59
61 bool isSendToInterface() const
62 {
63 return m_sendToInterface;
64 }
65
66 void resetSendToInterface() const
67 {
68 m_sendToInterface = false;
69 }
70
72 int getStartValue() const
73 {
74 return m_startValue <= -1 ? 1 : m_startValue;
75 }
76
78 int cmp(Level const &levl) const;
79
81 int cmpType(Level const &levl) const;
82
84 friend std::ostream &operator<<(std::ostream &o, Level const &ft);
85
86 double m_labelIndent ;
87 double m_labelWidth ;
89 int m_startValue;
91 libwps::NumberingType m_type;
92 librevenge::RVNGString m_prefix ,
93 m_suffix,
94 m_bullet ;
95
96 protected:
98 mutable bool m_sendToInterface;
99 };
100
102 WPSList() : m_levels(), m_actLevel(-1), m_actualIndices(), m_nextIndices(),
103 m_id(-1), m_previousId(-1) {}
104
106 int getId() const
107 {
108 return m_id;
109 }
110
115 int getPreviousId() const
116 {
117 return m_previousId;
118 }
119
121 void setId(int newId);
122
124 int numLevels() const
125 {
126 return int(m_levels.size());
127 }
128
129 void set(int levl, Level const &level);
130
132 void setLevel(int levl) const;
134 void openElement() const;
136 void closeElement() const {}
137
139 bool isNumeric(int levl) const;
140
142 bool mustSendLevel(int level) const;
143
145 void addLevelTo(int level, librevenge::RVNGPropertyList &propList) const;
146
147protected:
148 std::vector<Level> m_levels;
149
150 mutable int m_actLevel;
151 mutable std::vector<int> m_actualIndices, m_nextIndices;
152 mutable int m_id, m_previousId;
153};
154
155#endif
156/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPSList::m_actualIndices
std::vector< int > m_actualIndices
Definition WPSList.h:151
WPSList::m_levels
std::vector< Level > m_levels
Definition WPSList.h:148
WPSList::numLevels
int numLevels() const
returns the number of level
Definition WPSList.h:124
WPSList::m_previousId
int m_previousId
Definition WPSList.h:152
WPSList::m_nextIndices
std::vector< int > m_nextIndices
Definition WPSList.h:151
WPSList::m_actLevel
int m_actLevel
Definition WPSList.h:150
WPSList::WPSList
WPSList()
default constructor
Definition WPSList.h:102
WPSList::closeElement
void closeElement() const
close the list element
Definition WPSList.h:136
WPSList::addLevelTo
void addLevelTo(int level, librevenge::RVNGPropertyList &propList) const
add level definition to propList
Definition WPSList.cpp:156
WPSList::isNumeric
bool isNumeric(int levl) const
returns true is a level is numeric
Definition WPSList.cpp:224
WPSList::m_id
int m_id
Definition WPSList.h:152
WPSList::setLevel
void setLevel(int levl) const
set the list level
Definition WPSList.cpp:198
WPSList::set
void set(int levl, Level const &level)
sets a level
Definition WPSList.cpp:176
WPSList::openElement
void openElement() const
open the list element
Definition WPSList.cpp:213
WPSList::mustSendLevel
bool mustSendLevel(int level) const
returns true of the level must be send to the document interface
Definition WPSList.cpp:143
WPSList::getPreviousId
int getPreviousId() const
returns the previous list id
Definition WPSList.h:115
WPSList::setId
void setId(int newId)
set the list id
Definition WPSList.cpp:134
WPSList::getId
int getId() const
returns the list id
Definition WPSList.h:106
libwps_internal.h
libwps
Definition libwps_internal.cpp:39
libwps::NumberingType
NumberingType
Definition libwps_internal.h:244
libwps::BULLET
@ BULLET
Definition libwps_internal.h:244
libwps::NONE
@ NONE
Definition libwps_internal.h:244
WPSList::Level
small structure to keep information about a level
Definition WPSList.h:41
WPSList::Level::resetSendToInterface
void resetSendToInterface() const
reset the sendToInterface flag
Definition WPSList.h:66
WPSList::Level::m_startValue
int m_startValue
the actual value (if this is an ordered level )
Definition WPSList.h:89
WPSList::Level::cmpType
int cmpType(Level const &levl) const
type comparison function
Definition WPSList.cpp:67
WPSList::Level::operator<<
friend std::ostream & operator<<(std::ostream &o, Level const &ft)
operator<<
Definition WPSList.cpp:95
WPSList::Level::m_type
libwps::NumberingType m_type
the type of the level
Definition WPSList.h:91
WPSList::Level::isDefault
bool isDefault() const
returns true if the level type was not set
Definition WPSList.h:48
WPSList::Level::m_suffix
librevenge::RVNGString m_suffix
string which follows the number if we have an ordered level
Definition WPSList.h:93
WPSList::Level::cmp
int cmp(Level const &levl) const
full comparison function
Definition WPSList.cpp:80
WPSList::Level::getStartValue
int getStartValue() const
returns the start value (if set) or 1
Definition WPSList.h:72
WPSList::Level::m_labelIndent
double m_labelIndent
the list indent
Definition WPSList.h:86
WPSList::Level::m_bullet
librevenge::RVNGString m_bullet
the bullet if we have an bullet level
Definition WPSList.h:94
WPSList::Level::addTo
void addTo(librevenge::RVNGPropertyList &propList, int startVal) const
add the information of this level in the propList
Definition WPSList.cpp:33
WPSList::Level::m_prefix
librevenge::RVNGString m_prefix
string which preceedes the number if we have an ordered level
Definition WPSList.h:92
WPSList::Level::isSendToInterface
bool isSendToInterface() const
returns true, if addTo has been called
Definition WPSList.h:61
WPSList::Level::Level
Level()
basic constructor
Definition WPSList.h:44
WPSList::Level::isNumeric
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition WPSList.h:53
WPSList::Level::m_labelWidth
double m_labelWidth
the list width
Definition WPSList.h:87
WPSList::Level::m_sendToInterface
bool m_sendToInterface
true if it is already send to librevenge::RVNGTextInterface
Definition WPSList.h:98