Coverage Report

Created: 2026-06-13 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwps/src/lib/WPSPageSpan.h
Line
Count
Source
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) 2002 William Lachance (william.lachance@sympatico.ca)
11
 * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
12
 * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
13
 *
14
 * For minor contributions see the git repository.
15
 *
16
 * Alternatively, the contents of this file may be used under the terms
17
 * of the GNU Lesser General Public License Version 2.1 or later
18
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
19
 * applicable instead of those above.
20
 *
21
 * For further information visit http://libwps.sourceforge.net
22
 */
23
24
#ifndef WPSPAGESPAN_H
25
#define WPSPAGESPAN_H
26
#include <vector>
27
#include "libwps_internal.h"
28
29
class WKSContentListener;
30
class WPSContentListener;
31
32
namespace WPSPageSpanInternal
33
{
34
class HeaderFooter;
35
typedef std::shared_ptr<HeaderFooter> HeaderFooterPtr;
36
}
37
38
class WPSPageSpan
39
{
40
public:
41
  enum FormOrientation { PORTRAIT, LANDSCAPE };
42
43
  enum HeaderFooterType { HEADER, FOOTER };
44
  enum HeaderFooterOccurrence { ODD, EVEN, ALL, FIRST, NEVER };
45
46
  enum PageNumberPosition { None = 0, TopLeft, TopCenter, TopRight, TopLeftAndRight, TopInsideLeftAndRight,
47
                            BottomLeft, BottomCenter, BottomRight, BottomLeftAndRight, BottomInsideLeftAndRight
48
                          };
49
public:
50
  //! constructor
51
  WPSPageSpan();
52
6.58M
  WPSPageSpan(WPSPageSpan const &)=default;
53
  WPSPageSpan(WPSPageSpan &&)=default;
54
305k
  WPSPageSpan &operator=(WPSPageSpan const &)=default;
55
546k
  WPSPageSpan &operator=(WPSPageSpan &&)=default;
56
  //! destructor
57
  ~WPSPageSpan();
58
59
  double getFormLength() const
60
779k
  {
61
779k
    return m_formLength;
62
779k
  }
63
  double getFormWidth() const
64
863k
  {
65
863k
    return m_formWidth;
66
863k
  }
67
  FormOrientation getFormOrientation() const
68
753k
  {
69
753k
    return m_formOrientation;
70
753k
  }
71
  double getMarginLeft() const
72
806k
  {
73
806k
    return m_marginLeft;
74
806k
  }
75
  double getMarginRight() const
76
758k
  {
77
758k
    return m_marginRight;
78
758k
  }
79
  double getMarginTop() const
80
802k
  {
81
802k
    return m_marginTop;
82
802k
  }
83
  double getMarginBottom() const
84
753k
  {
85
753k
    return m_marginBottom;
86
753k
  }
87
  PageNumberPosition getPageNumberPosition() const
88
0
  {
89
0
    return m_pageNumberPosition;
90
0
  }
91
  int getPageNumber() const
92
324k
  {
93
324k
    return m_pageNumber;
94
324k
  }
95
  libwps::NumberingType getPageNumberingType() const
96
0
  {
97
0
    return m_pageNumberingType;
98
0
  }
99
  double getPageNumberingFontSize() const
100
0
  {
101
0
    return m_pageNumberingFontSize;
102
0
  }
103
  librevenge::RVNGString getPageNumberingFontName() const
104
0
  {
105
0
    return m_pageNumberingFontName;
106
0
  }
107
  int getPageSpan() const
108
479M
  {
109
479M
    return m_pageSpan;
110
479M
  }
111
  const std::vector<WPSPageSpanInternal::HeaderFooterPtr> &getHeaderFooterList() const
112
0
  {
113
0
    return m_headerFooterList;
114
0
  }
115
116
  void setHeaderFooter(const HeaderFooterType type, const HeaderFooterOccurrence occurrence,
117
                       WPSSubDocumentPtr &subDocument);
118
  void setFormLength(const double formLength)
119
51.4k
  {
120
51.4k
    m_formLength = formLength;
121
51.4k
  }
122
  void setFormWidth(const double formWidth)
123
44.1k
  {
124
44.1k
    m_formWidth = formWidth;
125
44.1k
  }
126
  void setFormOrientation(const FormOrientation formOrientation)
127
179k
  {
128
179k
    m_formOrientation = formOrientation;
129
179k
  }
130
  void setMarginLeft(const double marginLeft)
131
65.9k
  {
132
65.9k
    m_marginLeft = marginLeft;
133
65.9k
  }
134
  void setMarginRight(const double marginRight)
135
58.0k
  {
136
58.0k
    m_marginRight = marginRight;
137
58.0k
  }
138
  void setMarginTop(const double marginTop)
139
39.4k
  {
140
39.4k
    m_marginTop = marginTop;
141
39.4k
  }
142
  void setMarginBottom(const double marginBottom)
143
28.1k
  {
144
28.1k
    m_marginBottom = marginBottom;
145
28.1k
  }
146
  void setPageNumberPosition(const PageNumberPosition pageNumberPosition)
147
0
  {
148
0
    m_pageNumberPosition = pageNumberPosition;
149
0
  }
150
  void setPageNumber(const int pageNumber)
151
24.0k
  {
152
24.0k
    m_pageNumber = pageNumber;
153
24.0k
  }
154
  void setPageNumberingType(const libwps::NumberingType pageNumberingType)
155
0
  {
156
0
    m_pageNumberingType = pageNumberingType;
157
0
  }
158
  void setPageNumberingFontSize(const double pageNumberingFontSize)
159
0
  {
160
0
    m_pageNumberingFontSize = pageNumberingFontSize;
161
0
  }
162
  void setPageNumberingFontName(const librevenge::RVNGString &pageNumberingFontName)
163
0
  {
164
0
    m_pageNumberingFontName = pageNumberingFontName;
165
0
  }
166
  void setPageSpan(const int pageSpan)
167
63.0k
  {
168
63.0k
    m_pageSpan = pageSpan;
169
63.0k
  }
170
171
  bool operator==(std::shared_ptr<WPSPageSpan> const &pageSpan) const;
172
  bool operator!=(std::shared_ptr<WPSPageSpan> const &pageSpan) const
173
0
  {
174
0
    return !operator==(pageSpan);
175
0
  }
176
177
  // interface with the listeners
178
  void getPageProperty(librevenge::RVNGPropertyList &pList) const;
179
  void sendHeaderFooters(WPSContentListener *listener, librevenge::RVNGTextInterface *documentInterface);
180
  void sendHeaderFooters(WKSContentListener *listener, librevenge::RVNGSpreadsheetInterface *documentInterface);
181
182
protected:
183
184
  int _getHeaderFooterPosition(HeaderFooterType type, HeaderFooterOccurrence occurrence);
185
  void _setHeaderFooter(HeaderFooterType type, HeaderFooterOccurrence occurrence, WPSSubDocumentPtr &doc);
186
  void _removeHeaderFooter(HeaderFooterType type, HeaderFooterOccurrence occurrence);
187
  bool _containsHeaderFooter(HeaderFooterType type, HeaderFooterOccurrence occurrence);
188
189
  void _insertPageNumberParagraph(librevenge::RVNGTextInterface *documentInterface);
190
private:
191
  double m_formLength, m_formWidth;
192
  FormOrientation m_formOrientation;
193
  double m_marginLeft, m_marginRight;
194
  double m_marginTop, m_marginBottom;
195
  PageNumberPosition m_pageNumberPosition;
196
  int m_pageNumber;
197
  libwps::NumberingType m_pageNumberingType;
198
  librevenge::RVNGString m_pageNumberingFontName;
199
  double m_pageNumberingFontSize;
200
  std::vector<WPSPageSpanInternal::HeaderFooterPtr> m_headerFooterList;
201
202
  int m_pageSpan;
203
};
204
205
#endif
206
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */