bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / sidebar / PageMarginUtils.hxx
blob7061a11f9a6a90e097da5db44c8d3c384f7f035d
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 #define SDPAGE_NO_MARGIN 0
21 #define SDPAGE_NARROW_VALUE 635
22 #define SDPAGE_MODERATE_LR 955
23 #define SDPAGE_NORMAL_VALUE 1000
24 #define SDPAGE_WIDE_VALUE1 1270
25 #define SDPAGE_WIDE_VALUE2 2540
26 #define SDPAGE_WIDE_VALUE3 1590
27 #define SDPAGE_UNIT_THRESHOLD 5
29 namespace sd { namespace sidebar{
31 bool IsNone( const long nPageLeftMargin, const long nPageRightMargin,
32 const long nPageTopMargin, const long nPageBottomMargin )
34 return( std::abs(nPageLeftMargin - SDPAGE_NO_MARGIN) <= SDPAGE_UNIT_THRESHOLD &&
35 std::abs(nPageRightMargin - SDPAGE_NO_MARGIN ) <= SDPAGE_UNIT_THRESHOLD &&
36 std::abs(nPageTopMargin - SDPAGE_NO_MARGIN) <= SDPAGE_UNIT_THRESHOLD &&
37 std::abs(nPageBottomMargin - SDPAGE_NO_MARGIN) <= SDPAGE_UNIT_THRESHOLD );
40 void SetNone( long& nPageLeftMargin, long& nPageRightMargin,
41 long& nPageTopMargin, long& nPageBottomMargin )
43 nPageLeftMargin = SDPAGE_NO_MARGIN;
44 nPageRightMargin = SDPAGE_NO_MARGIN;
45 nPageTopMargin = SDPAGE_NO_MARGIN;
46 nPageBottomMargin = SDPAGE_NO_MARGIN;
49 bool IsNarrow( const long nPageLeftMargin, const long nPageRightMargin,
50 const long nPageTopMargin, const long nPageBottomMargin )
52 return( std::abs(nPageLeftMargin - SDPAGE_NARROW_VALUE) <= SDPAGE_UNIT_THRESHOLD &&
53 std::abs(nPageRightMargin - SDPAGE_NARROW_VALUE) <= SDPAGE_UNIT_THRESHOLD &&
54 std::abs(nPageTopMargin - SDPAGE_NARROW_VALUE) <= SDPAGE_UNIT_THRESHOLD &&
55 std::abs(nPageBottomMargin - SDPAGE_NARROW_VALUE) <= SDPAGE_UNIT_THRESHOLD );
58 void SetNarrow( long& nPageLeftMargin, long& nPageRightMargin,
59 long& nPageTopMargin, long& nPageBottomMargin )
61 nPageLeftMargin = SDPAGE_NARROW_VALUE;
62 nPageRightMargin = SDPAGE_NARROW_VALUE;
63 nPageTopMargin = SDPAGE_NARROW_VALUE;
64 nPageBottomMargin = SDPAGE_NARROW_VALUE;
67 bool IsModerate( const long nPageLeftMargin, const long nPageRightMargin,
68 const long nPageTopMargin, const long nPageBottomMargin )
70 return( std::abs(nPageLeftMargin - SDPAGE_MODERATE_LR) <= SDPAGE_UNIT_THRESHOLD &&
71 std::abs(nPageRightMargin - SDPAGE_MODERATE_LR) <= SDPAGE_UNIT_THRESHOLD &&
72 std::abs(nPageTopMargin - SDPAGE_WIDE_VALUE1) <= SDPAGE_UNIT_THRESHOLD &&
73 std::abs(nPageBottomMargin - SDPAGE_WIDE_VALUE1) <= SDPAGE_UNIT_THRESHOLD );
76 void SetModerate( long& nPageLeftMargin, long& nPageRightMargin,
77 long& nPageTopMargin, long& nPageBottomMargin )
79 nPageLeftMargin = SDPAGE_MODERATE_LR;
80 nPageRightMargin = SDPAGE_MODERATE_LR;
81 nPageTopMargin = SDPAGE_WIDE_VALUE1;
82 nPageBottomMargin = SDPAGE_WIDE_VALUE1;
85 bool IsNormal075( const long nPageLeftMargin, const long nPageRightMargin,
86 const long nPageTopMargin, const long nPageBottomMargin )
88 return( std::abs(nPageLeftMargin - SDPAGE_NORMAL_VALUE) <= SDPAGE_UNIT_THRESHOLD &&
89 std::abs(nPageRightMargin - SDPAGE_NORMAL_VALUE) <= SDPAGE_UNIT_THRESHOLD &&
90 std::abs(nPageTopMargin - SDPAGE_NORMAL_VALUE) <= SDPAGE_UNIT_THRESHOLD &&
91 std::abs(nPageBottomMargin - SDPAGE_NORMAL_VALUE) <= SDPAGE_UNIT_THRESHOLD );
94 void SetNormal075( long& nPageLeftMargin, long& nPageRightMargin,
95 long& nPageTopMargin, long& nPageBottomMargin )
97 nPageLeftMargin = SDPAGE_NORMAL_VALUE;
98 nPageRightMargin = SDPAGE_NORMAL_VALUE;
99 nPageTopMargin = SDPAGE_NORMAL_VALUE;
100 nPageBottomMargin = SDPAGE_NORMAL_VALUE;
103 bool IsNormal100( const long nPageLeftMargin, const long nPageRightMargin,
104 const long nPageTopMargin, const long nPageBottomMargin )
106 return( std::abs(nPageLeftMargin - SDPAGE_WIDE_VALUE1) <= SDPAGE_UNIT_THRESHOLD &&
107 std::abs(nPageRightMargin - SDPAGE_WIDE_VALUE1) <= SDPAGE_UNIT_THRESHOLD &&
108 std::abs(nPageTopMargin - SDPAGE_WIDE_VALUE1) <= SDPAGE_UNIT_THRESHOLD &&
109 std::abs(nPageBottomMargin - SDPAGE_WIDE_VALUE1) <= SDPAGE_UNIT_THRESHOLD );
112 void SetNormal100( long& nPageLeftMargin, long& nPageRightMargin,
113 long& nPageTopMargin, long& nPageBottomMargin )
115 nPageLeftMargin = SDPAGE_WIDE_VALUE1;
116 nPageRightMargin = SDPAGE_WIDE_VALUE1;
117 nPageTopMargin = SDPAGE_WIDE_VALUE1;
118 nPageBottomMargin = SDPAGE_WIDE_VALUE1;
121 bool IsNormal125( const long nPageLeftMargin, const long nPageRightMargin,
122 const long nPageTopMargin, const long nPageBottomMargin )
124 return( std::abs(nPageLeftMargin - SDPAGE_WIDE_VALUE3) <= SDPAGE_UNIT_THRESHOLD &&
125 std::abs(nPageRightMargin - SDPAGE_WIDE_VALUE3) <= SDPAGE_UNIT_THRESHOLD &&
126 std::abs(nPageTopMargin - SDPAGE_WIDE_VALUE1) <= SDPAGE_UNIT_THRESHOLD &&
127 std::abs(nPageBottomMargin - SDPAGE_WIDE_VALUE1) <= SDPAGE_UNIT_THRESHOLD );
130 void SetNormal125( long& nPageLeftMargin, long& nPageRightMargin,
131 long& nPageTopMargin, long& nPageBottomMargin )
133 nPageLeftMargin = SDPAGE_WIDE_VALUE3;
134 nPageRightMargin = SDPAGE_WIDE_VALUE3;
135 nPageTopMargin = SDPAGE_WIDE_VALUE1;
136 nPageBottomMargin = SDPAGE_WIDE_VALUE1;
139 bool IsWide( const long nPageLeftMargin, const long nPageRightMargin,
140 const long nPageTopMargin, const long nPageBottomMargin )
142 return( std::abs(nPageLeftMargin - SDPAGE_WIDE_VALUE2) <= SDPAGE_UNIT_THRESHOLD &&
143 std::abs(nPageRightMargin - SDPAGE_WIDE_VALUE2) <= SDPAGE_UNIT_THRESHOLD &&
144 std::abs(nPageTopMargin - SDPAGE_WIDE_VALUE1) <= SDPAGE_UNIT_THRESHOLD &&
145 std::abs(nPageBottomMargin - SDPAGE_WIDE_VALUE1) <= SDPAGE_UNIT_THRESHOLD );
148 void SetWide( long& nPageLeftMargin, long& nPageRightMargin,
149 long& nPageTopMargin, long& nPageBottomMargin )
151 nPageLeftMargin = SDPAGE_WIDE_VALUE2;
152 nPageRightMargin = SDPAGE_WIDE_VALUE2;
153 nPageTopMargin = SDPAGE_WIDE_VALUE1;
154 nPageBottomMargin = SDPAGE_WIDE_VALUE1;
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */