1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #define SWPAGE_NO_MARGIN 0
21 #define SWPAGE_NARROW_VALUE 720
22 #define SWPAGE_MODERATE_LR 1080
23 #define SWPAGE_NORMAL_VALUE 1136
24 #define SWPAGE_WIDE_VALUE1 1440
25 #define SWPAGE_WIDE_VALUE2 2880
26 #define SWPAGE_WIDE_VALUE3 1800
27 #define SWPAGE_UNIT_THRESHOLD 5
29 namespace sw::sidebar
{
31 bool IsNone( const tools::Long nPageLeftMargin
, const tools::Long nPageRightMargin
,
32 const tools::Long nPageTopMargin
, const tools::Long nPageBottomMargin
, bool bMirrored
)
34 return( std::abs(nPageLeftMargin
- SWPAGE_NO_MARGIN
) <= SWPAGE_UNIT_THRESHOLD
&&
35 std::abs(nPageRightMargin
- SWPAGE_NO_MARGIN
) <= SWPAGE_UNIT_THRESHOLD
&&
36 std::abs(nPageTopMargin
- SWPAGE_NO_MARGIN
) <= SWPAGE_UNIT_THRESHOLD
&&
37 std::abs(nPageBottomMargin
- SWPAGE_NO_MARGIN
) <= SWPAGE_UNIT_THRESHOLD
&&
41 void SetNone( tools::Long
& nPageLeftMargin
, tools::Long
& nPageRightMargin
,
42 tools::Long
& nPageTopMargin
, tools::Long
& nPageBottomMargin
, bool& bMirrored
)
44 nPageLeftMargin
= SWPAGE_NO_MARGIN
;
45 nPageRightMargin
= SWPAGE_NO_MARGIN
;
46 nPageTopMargin
= SWPAGE_NO_MARGIN
;
47 nPageBottomMargin
= SWPAGE_NO_MARGIN
;
51 bool IsNarrow( const tools::Long nPageLeftMargin
, const tools::Long nPageRightMargin
,
52 const tools::Long nPageTopMargin
, const tools::Long nPageBottomMargin
, bool bMirrored
)
54 return( std::abs(nPageLeftMargin
- SWPAGE_NARROW_VALUE
) <= SWPAGE_UNIT_THRESHOLD
&&
55 std::abs(nPageRightMargin
- SWPAGE_NARROW_VALUE
) <= SWPAGE_UNIT_THRESHOLD
&&
56 std::abs(nPageTopMargin
- SWPAGE_NARROW_VALUE
) <= SWPAGE_UNIT_THRESHOLD
&&
57 std::abs(nPageBottomMargin
- SWPAGE_NARROW_VALUE
) <= SWPAGE_UNIT_THRESHOLD
&&
61 void SetNarrow( tools::Long
& nPageLeftMargin
, tools::Long
& nPageRightMargin
,
62 tools::Long
& nPageTopMargin
, tools::Long
& nPageBottomMargin
, bool& bMirrored
)
64 nPageLeftMargin
= SWPAGE_NARROW_VALUE
;
65 nPageRightMargin
= SWPAGE_NARROW_VALUE
;
66 nPageTopMargin
= SWPAGE_NARROW_VALUE
;
67 nPageBottomMargin
= SWPAGE_NARROW_VALUE
;
71 bool IsModerate( const tools::Long nPageLeftMargin
, const tools::Long nPageRightMargin
,
72 const tools::Long nPageTopMargin
, const tools::Long nPageBottomMargin
, bool bMirrored
)
74 return( std::abs(nPageLeftMargin
- SWPAGE_MODERATE_LR
) <= SWPAGE_UNIT_THRESHOLD
&&
75 std::abs(nPageRightMargin
- SWPAGE_MODERATE_LR
) <= SWPAGE_UNIT_THRESHOLD
&&
76 std::abs(nPageTopMargin
- SWPAGE_WIDE_VALUE1
) <= SWPAGE_UNIT_THRESHOLD
&&
77 std::abs(nPageBottomMargin
- SWPAGE_WIDE_VALUE1
) <= SWPAGE_UNIT_THRESHOLD
&&
81 void SetModerate( tools::Long
& nPageLeftMargin
, tools::Long
& nPageRightMargin
,
82 tools::Long
& nPageTopMargin
, tools::Long
& nPageBottomMargin
, bool& bMirrored
)
84 nPageLeftMargin
= SWPAGE_MODERATE_LR
;
85 nPageRightMargin
= SWPAGE_MODERATE_LR
;
86 nPageTopMargin
= SWPAGE_WIDE_VALUE1
;
87 nPageBottomMargin
= SWPAGE_WIDE_VALUE1
;
91 bool IsNormal075( const tools::Long nPageLeftMargin
, const tools::Long nPageRightMargin
,
92 const tools::Long nPageTopMargin
, const tools::Long nPageBottomMargin
, bool bMirrored
)
94 return( std::abs(nPageLeftMargin
- SWPAGE_NORMAL_VALUE
) <= SWPAGE_UNIT_THRESHOLD
&&
95 std::abs(nPageRightMargin
- SWPAGE_NORMAL_VALUE
) <= SWPAGE_UNIT_THRESHOLD
&&
96 std::abs(nPageTopMargin
- SWPAGE_NORMAL_VALUE
) <= SWPAGE_UNIT_THRESHOLD
&&
97 std::abs(nPageBottomMargin
- SWPAGE_NORMAL_VALUE
) <= SWPAGE_UNIT_THRESHOLD
&&
101 void SetNormal075( tools::Long
& nPageLeftMargin
, tools::Long
& nPageRightMargin
,
102 tools::Long
& nPageTopMargin
, tools::Long
& nPageBottomMargin
, bool& bMirrored
)
104 nPageLeftMargin
= SWPAGE_NORMAL_VALUE
;
105 nPageRightMargin
= SWPAGE_NORMAL_VALUE
;
106 nPageTopMargin
= SWPAGE_NORMAL_VALUE
;
107 nPageBottomMargin
= SWPAGE_NORMAL_VALUE
;
111 bool IsNormal100( const tools::Long nPageLeftMargin
, const tools::Long nPageRightMargin
,
112 const tools::Long nPageTopMargin
, const tools::Long nPageBottomMargin
, bool bMirrored
)
114 return( std::abs(nPageLeftMargin
- SWPAGE_WIDE_VALUE1
) <= SWPAGE_UNIT_THRESHOLD
&&
115 std::abs(nPageRightMargin
- SWPAGE_WIDE_VALUE1
) <= SWPAGE_UNIT_THRESHOLD
&&
116 std::abs(nPageTopMargin
- SWPAGE_WIDE_VALUE1
) <= SWPAGE_UNIT_THRESHOLD
&&
117 std::abs(nPageBottomMargin
- SWPAGE_WIDE_VALUE1
) <= SWPAGE_UNIT_THRESHOLD
&&
121 void SetNormal100( tools::Long
& nPageLeftMargin
, tools::Long
& nPageRightMargin
,
122 tools::Long
& nPageTopMargin
, tools::Long
& nPageBottomMargin
, bool& bMirrored
)
124 nPageLeftMargin
= SWPAGE_WIDE_VALUE1
;
125 nPageRightMargin
= SWPAGE_WIDE_VALUE1
;
126 nPageTopMargin
= SWPAGE_WIDE_VALUE1
;
127 nPageBottomMargin
= SWPAGE_WIDE_VALUE1
;
131 bool IsNormal125( const tools::Long nPageLeftMargin
, const tools::Long nPageRightMargin
,
132 const tools::Long nPageTopMargin
, const tools::Long nPageBottomMargin
, bool bMirrored
)
134 return( std::abs(nPageLeftMargin
- SWPAGE_WIDE_VALUE3
) <= SWPAGE_UNIT_THRESHOLD
&&
135 std::abs(nPageRightMargin
- SWPAGE_WIDE_VALUE3
) <= SWPAGE_UNIT_THRESHOLD
&&
136 std::abs(nPageTopMargin
- SWPAGE_WIDE_VALUE1
) <= SWPAGE_UNIT_THRESHOLD
&&
137 std::abs(nPageBottomMargin
- SWPAGE_WIDE_VALUE1
) <= SWPAGE_UNIT_THRESHOLD
&&
141 void SetNormal125( tools::Long
& nPageLeftMargin
, tools::Long
& nPageRightMargin
,
142 tools::Long
& nPageTopMargin
, tools::Long
& nPageBottomMargin
, bool& bMirrored
)
144 nPageLeftMargin
= SWPAGE_WIDE_VALUE3
;
145 nPageRightMargin
= SWPAGE_WIDE_VALUE3
;
146 nPageTopMargin
= SWPAGE_WIDE_VALUE1
;
147 nPageBottomMargin
= SWPAGE_WIDE_VALUE1
;
151 bool IsWide( const tools::Long nPageLeftMargin
, const tools::Long nPageRightMargin
,
152 const tools::Long nPageTopMargin
, const tools::Long nPageBottomMargin
, bool bMirrored
)
154 return( std::abs(nPageLeftMargin
- SWPAGE_WIDE_VALUE2
) <= SWPAGE_UNIT_THRESHOLD
&&
155 std::abs(nPageRightMargin
- SWPAGE_WIDE_VALUE2
) <= SWPAGE_UNIT_THRESHOLD
&&
156 std::abs(nPageTopMargin
- SWPAGE_WIDE_VALUE1
) <= SWPAGE_UNIT_THRESHOLD
&&
157 std::abs(nPageBottomMargin
- SWPAGE_WIDE_VALUE1
) <= SWPAGE_UNIT_THRESHOLD
&&
161 void SetWide( tools::Long
& nPageLeftMargin
, tools::Long
& nPageRightMargin
,
162 tools::Long
& nPageTopMargin
, tools::Long
& nPageBottomMargin
, bool& bMirrored
)
164 nPageLeftMargin
= SWPAGE_WIDE_VALUE2
;
165 nPageRightMargin
= SWPAGE_WIDE_VALUE2
;
166 nPageTopMargin
= SWPAGE_WIDE_VALUE1
;
167 nPageBottomMargin
= SWPAGE_WIDE_VALUE1
;
171 bool IsMirrored( const tools::Long nPageLeftMargin
, const tools::Long nPageRightMargin
,
172 const tools::Long nPageTopMargin
, const tools::Long nPageBottomMargin
, bool bMirrored
)
174 return( std::abs(nPageLeftMargin
- SWPAGE_WIDE_VALUE3
) <= SWPAGE_UNIT_THRESHOLD
&&
175 std::abs(nPageRightMargin
- SWPAGE_WIDE_VALUE1
) <= SWPAGE_UNIT_THRESHOLD
&&
176 std::abs(nPageTopMargin
- SWPAGE_WIDE_VALUE1
) <= SWPAGE_UNIT_THRESHOLD
&&
177 std::abs(nPageBottomMargin
- SWPAGE_WIDE_VALUE1
) <= SWPAGE_UNIT_THRESHOLD
&&
181 void SetMirrored( tools::Long
& nPageLeftMargin
, tools::Long
& nPageRightMargin
,
182 tools::Long
& nPageTopMargin
, tools::Long
& nPageBottomMargin
, bool& bMirrored
)
184 nPageLeftMargin
= SWPAGE_WIDE_VALUE3
;
185 nPageRightMargin
= SWPAGE_WIDE_VALUE1
;
186 nPageTopMargin
= SWPAGE_WIDE_VALUE1
;
187 nPageBottomMargin
= SWPAGE_WIDE_VALUE1
;
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */