LibreOffice Module sw (master)
1
sw
source
uibase
sidebar
PageMarginUtils.hxx
Go to the documentation of this file.
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
* This file is part of the LibreOffice project.
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
* This file incorporates work covered by the following license notice:
10
*
11
* Licensed to the Apache Software Foundation (ASF) under one or more
12
* contributor license agreements. See the NOTICE file distributed
13
* with this work for additional information regarding copyright
14
* ownership. The ASF licenses this file to you under the Apache
15
* License, Version 2.0 (the "License"); you may not use this file
16
* except in compliance with the License. You may obtain a copy of
17
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
*/
19
#include <cmath>
20
#include <
tools/long.hxx
>
21
22
#define SWPAGE_NO_MARGIN 0
23
#define SWPAGE_NARROW_VALUE 720
24
#define SWPAGE_MODERATE_LR 1080
25
#define SWPAGE_NORMAL_VALUE 1136
26
#define SWPAGE_WIDE_VALUE1 1440
27
#define SWPAGE_WIDE_VALUE2 2880
28
#define SWPAGE_WIDE_VALUE3 1800
29
#define SWPAGE_UNIT_THRESHOLD 5
30
31
namespace
sw::sidebar
{
32
33
bool
IsNone
(
const
tools::Long
nPageLeftMargin,
const
tools::Long
nPageRightMargin,
34
const
tools::Long
nPageTopMargin,
const
tools::Long
nPageBottomMargin,
bool
bMirrored)
35
{
36
return
(
std::abs
(nPageLeftMargin -
SWPAGE_NO_MARGIN
) <=
SWPAGE_UNIT_THRESHOLD
&&
37
std::abs
(nPageRightMargin -
SWPAGE_NO_MARGIN
) <=
SWPAGE_UNIT_THRESHOLD
&&
38
std::abs
(nPageTopMargin -
SWPAGE_NO_MARGIN
) <=
SWPAGE_UNIT_THRESHOLD
&&
39
std::abs
(nPageBottomMargin -
SWPAGE_NO_MARGIN
) <=
SWPAGE_UNIT_THRESHOLD
&&
40
!bMirrored );
41
}
42
43
void
SetNone
(
tools::Long
& nPageLeftMargin,
tools::Long
& nPageRightMargin,
44
tools::Long
& nPageTopMargin,
tools::Long
& nPageBottomMargin,
bool
& bMirrored)
45
{
46
nPageLeftMargin =
SWPAGE_NO_MARGIN
;
47
nPageRightMargin =
SWPAGE_NO_MARGIN
;
48
nPageTopMargin =
SWPAGE_NO_MARGIN
;
49
nPageBottomMargin =
SWPAGE_NO_MARGIN
;
50
bMirrored =
false
;
51
}
52
53
bool
IsNarrow
(
const
tools::Long
nPageLeftMargin,
const
tools::Long
nPageRightMargin,
54
const
tools::Long
nPageTopMargin,
const
tools::Long
nPageBottomMargin,
bool
bMirrored)
55
{
56
return
(
std::abs
(nPageLeftMargin -
SWPAGE_NARROW_VALUE
) <=
SWPAGE_UNIT_THRESHOLD
&&
57
std::abs
(nPageRightMargin -
SWPAGE_NARROW_VALUE
) <=
SWPAGE_UNIT_THRESHOLD
&&
58
std::abs
(nPageTopMargin -
SWPAGE_NARROW_VALUE
) <=
SWPAGE_UNIT_THRESHOLD
&&
59
std::abs
(nPageBottomMargin -
SWPAGE_NARROW_VALUE
) <=
SWPAGE_UNIT_THRESHOLD
&&
60
!bMirrored );
61
}
62
63
void
SetNarrow
(
tools::Long
& nPageLeftMargin,
tools::Long
& nPageRightMargin,
64
tools::Long
& nPageTopMargin,
tools::Long
& nPageBottomMargin,
bool
& bMirrored)
65
{
66
nPageLeftMargin =
SWPAGE_NARROW_VALUE
;
67
nPageRightMargin =
SWPAGE_NARROW_VALUE
;
68
nPageTopMargin =
SWPAGE_NARROW_VALUE
;
69
nPageBottomMargin =
SWPAGE_NARROW_VALUE
;
70
bMirrored =
false
;
71
}
72
73
bool
IsModerate
(
const
tools::Long
nPageLeftMargin,
const
tools::Long
nPageRightMargin,
74
const
tools::Long
nPageTopMargin,
const
tools::Long
nPageBottomMargin,
bool
bMirrored)
75
{
76
return
(
std::abs
(nPageLeftMargin -
SWPAGE_MODERATE_LR
) <=
SWPAGE_UNIT_THRESHOLD
&&
77
std::abs
(nPageRightMargin -
SWPAGE_MODERATE_LR
) <=
SWPAGE_UNIT_THRESHOLD
&&
78
std::abs
(nPageTopMargin -
SWPAGE_WIDE_VALUE1
) <=
SWPAGE_UNIT_THRESHOLD
&&
79
std::abs
(nPageBottomMargin -
SWPAGE_WIDE_VALUE1
) <=
SWPAGE_UNIT_THRESHOLD
&&
80
!bMirrored );
81
}
82
83
void
SetModerate
(
tools::Long
& nPageLeftMargin,
tools::Long
& nPageRightMargin,
84
tools::Long
& nPageTopMargin,
tools::Long
& nPageBottomMargin,
bool
& bMirrored)
85
{
86
nPageLeftMargin =
SWPAGE_MODERATE_LR
;
87
nPageRightMargin =
SWPAGE_MODERATE_LR
;
88
nPageTopMargin =
SWPAGE_WIDE_VALUE1
;
89
nPageBottomMargin =
SWPAGE_WIDE_VALUE1
;
90
bMirrored =
false
;
91
}
92
93
bool
IsNormal075
(
const
tools::Long
nPageLeftMargin,
const
tools::Long
nPageRightMargin,
94
const
tools::Long
nPageTopMargin,
const
tools::Long
nPageBottomMargin,
bool
bMirrored)
95
{
96
return
(
std::abs
(nPageLeftMargin -
SWPAGE_NORMAL_VALUE
) <=
SWPAGE_UNIT_THRESHOLD
&&
97
std::abs
(nPageRightMargin -
SWPAGE_NORMAL_VALUE
) <=
SWPAGE_UNIT_THRESHOLD
&&
98
std::abs
(nPageTopMargin -
SWPAGE_NORMAL_VALUE
) <=
SWPAGE_UNIT_THRESHOLD
&&
99
std::abs
(nPageBottomMargin -
SWPAGE_NORMAL_VALUE
) <=
SWPAGE_UNIT_THRESHOLD
&&
100
!bMirrored );
101
}
102
103
void
SetNormal075
(
tools::Long
& nPageLeftMargin,
tools::Long
& nPageRightMargin,
104
tools::Long
& nPageTopMargin,
tools::Long
& nPageBottomMargin,
bool
& bMirrored)
105
{
106
nPageLeftMargin =
SWPAGE_NORMAL_VALUE
;
107
nPageRightMargin =
SWPAGE_NORMAL_VALUE
;
108
nPageTopMargin =
SWPAGE_NORMAL_VALUE
;
109
nPageBottomMargin =
SWPAGE_NORMAL_VALUE
;
110
bMirrored =
false
;
111
}
112
113
bool
IsNormal100
(
const
tools::Long
nPageLeftMargin,
const
tools::Long
nPageRightMargin,
114
const
tools::Long
nPageTopMargin,
const
tools::Long
nPageBottomMargin,
bool
bMirrored)
115
{
116
return
(
std::abs
(nPageLeftMargin -
SWPAGE_WIDE_VALUE1
) <=
SWPAGE_UNIT_THRESHOLD
&&
117
std::abs
(nPageRightMargin -
SWPAGE_WIDE_VALUE1
) <=
SWPAGE_UNIT_THRESHOLD
&&
118
std::abs
(nPageTopMargin -
SWPAGE_WIDE_VALUE1
) <=
SWPAGE_UNIT_THRESHOLD
&&
119
std::abs
(nPageBottomMargin -
SWPAGE_WIDE_VALUE1
) <=
SWPAGE_UNIT_THRESHOLD
&&
120
!bMirrored );
121
}
122
123
void
SetNormal100
(
tools::Long
& nPageLeftMargin,
tools::Long
& nPageRightMargin,
124
tools::Long
& nPageTopMargin,
tools::Long
& nPageBottomMargin,
bool
& bMirrored)
125
{
126
nPageLeftMargin =
SWPAGE_WIDE_VALUE1
;
127
nPageRightMargin =
SWPAGE_WIDE_VALUE1
;
128
nPageTopMargin =
SWPAGE_WIDE_VALUE1
;
129
nPageBottomMargin =
SWPAGE_WIDE_VALUE1
;
130
bMirrored =
false
;
131
}
132
133
bool
IsNormal125
(
const
tools::Long
nPageLeftMargin,
const
tools::Long
nPageRightMargin,
134
const
tools::Long
nPageTopMargin,
const
tools::Long
nPageBottomMargin,
bool
bMirrored)
135
{
136
return
(
std::abs
(nPageLeftMargin -
SWPAGE_WIDE_VALUE3
) <=
SWPAGE_UNIT_THRESHOLD
&&
137
std::abs
(nPageRightMargin -
SWPAGE_WIDE_VALUE3
) <=
SWPAGE_UNIT_THRESHOLD
&&
138
std::abs
(nPageTopMargin -
SWPAGE_WIDE_VALUE1
) <=
SWPAGE_UNIT_THRESHOLD
&&
139
std::abs
(nPageBottomMargin -
SWPAGE_WIDE_VALUE1
) <=
SWPAGE_UNIT_THRESHOLD
&&
140
!bMirrored );
141
}
142
143
void
SetNormal125
(
tools::Long
& nPageLeftMargin,
tools::Long
& nPageRightMargin,
144
tools::Long
& nPageTopMargin,
tools::Long
& nPageBottomMargin,
bool
& bMirrored)
145
{
146
nPageLeftMargin =
SWPAGE_WIDE_VALUE3
;
147
nPageRightMargin =
SWPAGE_WIDE_VALUE3
;
148
nPageTopMargin =
SWPAGE_WIDE_VALUE1
;
149
nPageBottomMargin =
SWPAGE_WIDE_VALUE1
;
150
bMirrored =
false
;
151
}
152
153
bool
IsWide
(
const
tools::Long
nPageLeftMargin,
const
tools::Long
nPageRightMargin,
154
const
tools::Long
nPageTopMargin,
const
tools::Long
nPageBottomMargin,
bool
bMirrored)
155
{
156
return
(
std::abs
(nPageLeftMargin -
SWPAGE_WIDE_VALUE2
) <=
SWPAGE_UNIT_THRESHOLD
&&
157
std::abs
(nPageRightMargin -
SWPAGE_WIDE_VALUE2
) <=
SWPAGE_UNIT_THRESHOLD
&&
158
std::abs
(nPageTopMargin -
SWPAGE_WIDE_VALUE1
) <=
SWPAGE_UNIT_THRESHOLD
&&
159
std::abs
(nPageBottomMargin -
SWPAGE_WIDE_VALUE1
) <=
SWPAGE_UNIT_THRESHOLD
&&
160
!bMirrored );
161
}
162
163
void
SetWide
(
tools::Long
& nPageLeftMargin,
tools::Long
& nPageRightMargin,
164
tools::Long
& nPageTopMargin,
tools::Long
& nPageBottomMargin,
bool
& bMirrored)
165
{
166
nPageLeftMargin =
SWPAGE_WIDE_VALUE2
;
167
nPageRightMargin =
SWPAGE_WIDE_VALUE2
;
168
nPageTopMargin =
SWPAGE_WIDE_VALUE1
;
169
nPageBottomMargin =
SWPAGE_WIDE_VALUE1
;
170
bMirrored =
false
;
171
}
172
173
bool
IsMirrored
(
const
tools::Long
nPageLeftMargin,
const
tools::Long
nPageRightMargin,
174
const
tools::Long
nPageTopMargin,
const
tools::Long
nPageBottomMargin,
bool
bMirrored)
175
{
176
return
(
std::abs
(nPageLeftMargin -
SWPAGE_WIDE_VALUE3
) <=
SWPAGE_UNIT_THRESHOLD
&&
177
std::abs
(nPageRightMargin -
SWPAGE_WIDE_VALUE1
) <=
SWPAGE_UNIT_THRESHOLD
&&
178
std::abs
(nPageTopMargin -
SWPAGE_WIDE_VALUE1
) <=
SWPAGE_UNIT_THRESHOLD
&&
179
std::abs
(nPageBottomMargin -
SWPAGE_WIDE_VALUE1
) <=
SWPAGE_UNIT_THRESHOLD
&&
180
bMirrored );
181
}
182
183
void
SetMirrored
(
tools::Long
& nPageLeftMargin,
tools::Long
& nPageRightMargin,
184
tools::Long
& nPageTopMargin,
tools::Long
& nPageBottomMargin,
bool
& bMirrored)
185
{
186
nPageLeftMargin =
SWPAGE_WIDE_VALUE3
;
187
nPageRightMargin =
SWPAGE_WIDE_VALUE1
;
188
nPageTopMargin =
SWPAGE_WIDE_VALUE1
;
189
nPageBottomMargin =
SWPAGE_WIDE_VALUE1
;
190
bMirrored =
true
;
191
}
192
}
193
194
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SWPAGE_WIDE_VALUE3
#define SWPAGE_WIDE_VALUE3
Definition:
PageMarginUtils.hxx:28
SWPAGE_NARROW_VALUE
#define SWPAGE_NARROW_VALUE
Definition:
PageMarginUtils.hxx:23
SWPAGE_MODERATE_LR
#define SWPAGE_MODERATE_LR
Definition:
PageMarginUtils.hxx:24
SWPAGE_WIDE_VALUE2
#define SWPAGE_WIDE_VALUE2
Definition:
PageMarginUtils.hxx:27
SWPAGE_NORMAL_VALUE
#define SWPAGE_NORMAL_VALUE
Definition:
PageMarginUtils.hxx:25
SWPAGE_UNIT_THRESHOLD
#define SWPAGE_UNIT_THRESHOLD
Definition:
PageMarginUtils.hxx:29
SWPAGE_WIDE_VALUE1
#define SWPAGE_WIDE_VALUE1
Definition:
PageMarginUtils.hxx:26
SWPAGE_NO_MARGIN
#define SWPAGE_NO_MARGIN
Definition:
PageMarginUtils.hxx:22
long.hxx
sw::sidebar
Definition:
A11yCheckIssuesPanel.cxx:30
sw::sidebar::SetNone
void SetNone(tools::Long &nPageLeftMargin, tools::Long &nPageRightMargin, tools::Long &nPageTopMargin, tools::Long &nPageBottomMargin, bool &bMirrored)
Definition:
PageMarginUtils.hxx:43
sw::sidebar::IsNarrow
bool IsNarrow(const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin, const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
Definition:
PageMarginUtils.hxx:53
sw::sidebar::IsWide
bool IsWide(const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin, const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
Definition:
PageMarginUtils.hxx:153
sw::sidebar::IsMirrored
bool IsMirrored(const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin, const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
Definition:
PageMarginUtils.hxx:173
sw::sidebar::SetModerate
void SetModerate(tools::Long &nPageLeftMargin, tools::Long &nPageRightMargin, tools::Long &nPageTopMargin, tools::Long &nPageBottomMargin, bool &bMirrored)
Definition:
PageMarginUtils.hxx:83
sw::sidebar::IsModerate
bool IsModerate(const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin, const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
Definition:
PageMarginUtils.hxx:73
sw::sidebar::SetWide
void SetWide(tools::Long &nPageLeftMargin, tools::Long &nPageRightMargin, tools::Long &nPageTopMargin, tools::Long &nPageBottomMargin, bool &bMirrored)
Definition:
PageMarginUtils.hxx:163
sw::sidebar::SetNormal125
void SetNormal125(tools::Long &nPageLeftMargin, tools::Long &nPageRightMargin, tools::Long &nPageTopMargin, tools::Long &nPageBottomMargin, bool &bMirrored)
Definition:
PageMarginUtils.hxx:143
sw::sidebar::SetNarrow
void SetNarrow(tools::Long &nPageLeftMargin, tools::Long &nPageRightMargin, tools::Long &nPageTopMargin, tools::Long &nPageBottomMargin, bool &bMirrored)
Definition:
PageMarginUtils.hxx:63
sw::sidebar::IsNone
bool IsNone(const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin, const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
Definition:
PageMarginUtils.hxx:33
sw::sidebar::SetNormal100
void SetNormal100(tools::Long &nPageLeftMargin, tools::Long &nPageRightMargin, tools::Long &nPageTopMargin, tools::Long &nPageBottomMargin, bool &bMirrored)
Definition:
PageMarginUtils.hxx:123
sw::sidebar::IsNormal125
bool IsNormal125(const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin, const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
Definition:
PageMarginUtils.hxx:133
sw::sidebar::IsNormal100
bool IsNormal100(const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin, const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
Definition:
PageMarginUtils.hxx:113
sw::sidebar::SetNormal075
void SetNormal075(tools::Long &nPageLeftMargin, tools::Long &nPageRightMargin, tools::Long &nPageTopMargin, tools::Long &nPageBottomMargin, bool &bMirrored)
Definition:
PageMarginUtils.hxx:103
sw::sidebar::IsNormal075
bool IsNormal075(const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin, const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
Definition:
PageMarginUtils.hxx:93
sw::sidebar::SetMirrored
void SetMirrored(tools::Long &nPageLeftMargin, tools::Long &nPageRightMargin, tools::Long &nPageTopMargin, tools::Long &nPageBottomMargin, bool &bMirrored)
Definition:
PageMarginUtils.hxx:183
tools::Long
long Long
abs
SwNodeOffset abs(const SwNodeOffset &a)
Definition:
nodeoffset.hxx:34
Generated on Sun Jul 30 2023 04:30:03 for LibreOffice Module sw (master) by
1.9.3