Main Page
Namespaces
Classes
Files
File List
File Members
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
{
49
enum
Type
{
DEFAULT
,
NONE
,
BULLET
,
DECIMAL
,
LOWER_ALPHA
,
UPPER_ALPHA
,
50
LOWER_ROMAN
,
UPPER_ROMAN
51
};
53
enum
Alignment
{
LEFT
,
RIGHT
,
CENTER
};
54
56
MWAWListLevel
() :
m_type
(
NONE
),
m_labelBeforeSpace
(0.0),
m_labelWidth
(0.1),
m_labelAfterSpace
(0.0),
m_numBeforeLabels
(0),
m_alignment
(
LEFT
),
m_startValue
(0),
57
m_prefix
(
""
),
m_suffix
(
""
),
m_bullet
(
""
) {
58
}
60
~MWAWListLevel
() {}
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
85
Type
m_type
;
86
double
m_labelBeforeSpace
;
87
double
m_labelWidth
;
88
double
m_labelAfterSpace
;
90
int
m_numBeforeLabels
;
92
Alignment
m_alignment
;
94
int
m_startValue
;
95
WPXString
m_prefix
,
96
m_suffix
,
97
m_bullet
;
98
};
99
101
class
MWAWList
102
{
103
public
:
105
MWAWList
() :
m_levels
(),
m_actLevel
(-1),
m_actualIndices
(),
m_nextIndices
() {
106
m_id
[0] =
m_id
[1] = -1;
107
}
108
110
int
getId
()
const
{
111
return
m_id
[0];
112
}
113
115
void
resize
(
int
levl);
117
bool
isCompatibleWith
(
int
levl,
MWAWListLevel
const
&level)
const
;
119
bool
isCompatibleWith
(
MWAWList
const
&newList)
const
;
121
void
updateIndicesFrom
(
MWAWList
const
&list);
122
127
void
swapId
()
const
{
128
int
tmp =
m_id
[0];
129
m_id
[0] =
m_id
[1];
130
m_id
[1] = tmp;
131
}
132
134
void
setId
(
int
newId)
const
;
135
137
MWAWListLevel
getLevel
(
int
levl)
const
{
138
if
(levl >= 0 && levl <
int
(
m_levels
.size()))
139
return
m_levels
[size_t(levl)];
140
MWAW_DEBUG_MSG
((
"MWAWList::getLevel: can not find level %d\n"
, levl));
141
return
MWAWListLevel
();
142
}
144
int
numLevels
()
const
{
145
return
int(
m_levels
.size());
146
}
148
void
set
(
int
levl,
MWAWListLevel
const
&level);
149
151
void
setLevel
(
int
levl)
const
;
153
void
openElement
()
const
;
155
void
closeElement
()
const
{}
157
int
getStartValueForNextElement
()
const
;
159
void
setStartValueForNextElement
(
int
value);
160
162
bool
isNumeric
(
int
levl)
const
;
163
165
void
sendTo
(WPXDocumentInterface &docInterface,
int
level)
const
;
166
167
protected
:
169
std::vector<MWAWListLevel>
m_levels
;
170
172
mutable
int
m_actLevel
;
173
mutable
std::vector<int>
m_actualIndices
,
m_nextIndices
;
175
mutable
int
m_id
[2];
176
};
177
179
class
MWAWListManager
180
{
181
public
:
183
MWAWListManager
() :
m_listList
(),
m_sendIdList
() { }
185
~MWAWListManager
() { }
187
bool
send
(
int
index, WPXDocumentInterface &docInterface)
const
;
189
shared_ptr<MWAWList>
getList
(
int
index)
const
;
191
shared_ptr<MWAWList>
getNewList
(shared_ptr<MWAWList> actList,
int
levl,
MWAWListLevel
const
&level);
192
protected
:
194
void
resetSend
(
size_t
id
)
const
;
196
std::vector<MWAWList>
m_listList
;
198
mutable
std::vector<bool>
m_sendIdList
;
199
};
200
#endif
201
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Generated on Tue Apr 30 2013 06:16:19 for libmwaw by
doxygen
1.8.3.1