Mark some visible strings in ui files as translatable
[LibreOffice.git] / sw / source / uibase / sidebar / PageMarginUtils.hxx
blobce7d5f65ee70692406ad8f204f876e3174e19266
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #include <cmath>
20 #include <tools/long.hxx>
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
31 namespace sw::sidebar{
33 bool IsNone( const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin,
34 const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
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 );
43 void SetNone( tools::Long& nPageLeftMargin, tools::Long& nPageRightMargin,
44 tools::Long& nPageTopMargin, tools::Long& nPageBottomMargin, bool& bMirrored)
46 nPageLeftMargin = SWPAGE_NO_MARGIN;
47 nPageRightMargin = SWPAGE_NO_MARGIN;
48 nPageTopMargin = SWPAGE_NO_MARGIN;
49 nPageBottomMargin = SWPAGE_NO_MARGIN;
50 bMirrored = false;
53 bool IsNarrow( const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin,
54 const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
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 );
63 void SetNarrow( tools::Long& nPageLeftMargin, tools::Long& nPageRightMargin,
64 tools::Long& nPageTopMargin, tools::Long& nPageBottomMargin, bool& bMirrored)
66 nPageLeftMargin = SWPAGE_NARROW_VALUE;
67 nPageRightMargin = SWPAGE_NARROW_VALUE;
68 nPageTopMargin = SWPAGE_NARROW_VALUE;
69 nPageBottomMargin = SWPAGE_NARROW_VALUE;
70 bMirrored = false;
73 bool IsModerate( const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin,
74 const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
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 );
83 void SetModerate( tools::Long& nPageLeftMargin, tools::Long& nPageRightMargin,
84 tools::Long& nPageTopMargin, tools::Long& nPageBottomMargin, bool& bMirrored)
86 nPageLeftMargin = SWPAGE_MODERATE_LR;
87 nPageRightMargin = SWPAGE_MODERATE_LR;
88 nPageTopMargin = SWPAGE_WIDE_VALUE1;
89 nPageBottomMargin = SWPAGE_WIDE_VALUE1;
90 bMirrored = false;
93 bool IsNormal075( const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin,
94 const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
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 );
103 void SetNormal075( tools::Long& nPageLeftMargin, tools::Long& nPageRightMargin,
104 tools::Long& nPageTopMargin, tools::Long& nPageBottomMargin, bool& bMirrored)
106 nPageLeftMargin = SWPAGE_NORMAL_VALUE;
107 nPageRightMargin = SWPAGE_NORMAL_VALUE;
108 nPageTopMargin = SWPAGE_NORMAL_VALUE;
109 nPageBottomMargin = SWPAGE_NORMAL_VALUE;
110 bMirrored = false;
113 bool IsNormal100( const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin,
114 const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
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 );
123 void SetNormal100( tools::Long& nPageLeftMargin, tools::Long& nPageRightMargin,
124 tools::Long& nPageTopMargin, tools::Long& nPageBottomMargin, bool& bMirrored)
126 nPageLeftMargin = SWPAGE_WIDE_VALUE1;
127 nPageRightMargin = SWPAGE_WIDE_VALUE1;
128 nPageTopMargin = SWPAGE_WIDE_VALUE1;
129 nPageBottomMargin = SWPAGE_WIDE_VALUE1;
130 bMirrored = false;
133 bool IsNormal125( const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin,
134 const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
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 );
143 void SetNormal125( tools::Long& nPageLeftMargin, tools::Long& nPageRightMargin,
144 tools::Long& nPageTopMargin, tools::Long& nPageBottomMargin, bool& bMirrored)
146 nPageLeftMargin = SWPAGE_WIDE_VALUE3;
147 nPageRightMargin = SWPAGE_WIDE_VALUE3;
148 nPageTopMargin = SWPAGE_WIDE_VALUE1;
149 nPageBottomMargin = SWPAGE_WIDE_VALUE1;
150 bMirrored = false;
153 bool IsWide( const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin,
154 const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
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 );
163 void SetWide( tools::Long& nPageLeftMargin, tools::Long& nPageRightMargin,
164 tools::Long& nPageTopMargin, tools::Long& nPageBottomMargin, bool& bMirrored)
166 nPageLeftMargin = SWPAGE_WIDE_VALUE2;
167 nPageRightMargin = SWPAGE_WIDE_VALUE2;
168 nPageTopMargin = SWPAGE_WIDE_VALUE1;
169 nPageBottomMargin = SWPAGE_WIDE_VALUE1;
170 bMirrored = false;
173 bool IsMirrored( const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin,
174 const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
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 );
183 void SetMirrored( tools::Long& nPageLeftMargin, tools::Long& nPageRightMargin,
184 tools::Long& nPageTopMargin, tools::Long& nPageBottomMargin, bool& bMirrored)
186 nPageLeftMargin = SWPAGE_WIDE_VALUE3;
187 nPageRightMargin = SWPAGE_WIDE_VALUE1;
188 nPageTopMargin = SWPAGE_WIDE_VALUE1;
189 nPageBottomMargin = SWPAGE_WIDE_VALUE1;
190 bMirrored = true;
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */