Line data Source code
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 :
20 : #ifndef INCLUDED_TOOLS_SVBORDER_HXX
21 : #define INCLUDED_TOOLS_SVBORDER_HXX
22 :
23 : #include <tools/toolsdllapi.h>
24 : #include <tools/gen.hxx>
25 :
26 : class TOOLS_DLLPUBLIC SvBorder
27 : {
28 : long nTop, nRight, nBottom, nLeft;
29 :
30 : public:
31 0 : SvBorder()
32 : {
33 0 : nTop = nRight = nBottom = nLeft = 0;
34 0 : }
35 : SvBorder( const Size & rSz )
36 : {
37 : nTop = nBottom = rSz.Height();
38 : nRight = nLeft = rSz.Width();
39 : }
40 0 : SvBorder( long nLeftP, long nTopP, long nRightP, long nBottomP )
41 : {
42 0 : nLeft = nLeftP;
43 0 : nTop = nTopP;
44 0 : nRight = nRightP;
45 0 : nBottom = nBottomP;
46 0 : }
47 0 : bool operator == ( const SvBorder & rObj ) const
48 : {
49 0 : return nTop == rObj.nTop && nRight == rObj.nRight &&
50 0 : nBottom == rObj.nBottom && nLeft == rObj.nLeft;
51 : }
52 0 : bool operator != ( const SvBorder & rObj ) const
53 0 : { return !(*this == rObj); }
54 0 : SvBorder & operator = ( const SvBorder & rBorder )
55 : {
56 0 : Left() = rBorder.Left();
57 0 : Top() = rBorder.Top();
58 0 : Right() = rBorder.Right();
59 0 : Bottom() = rBorder.Bottom();
60 0 : return *this;
61 : }
62 0 : SvBorder & operator += ( const SvBorder & rBorder )
63 : {
64 0 : Left() += rBorder.Left();
65 0 : Top() += rBorder.Top();
66 0 : Right() += rBorder.Right();
67 0 : Bottom() += rBorder.Bottom();
68 0 : return *this;
69 : }
70 : SvBorder & operator -= ( const SvBorder & rBorder )
71 : {
72 : Left() -= rBorder.Left();
73 : Top() -= rBorder.Top();
74 : Right() -= rBorder.Right();
75 : Bottom() -= rBorder.Bottom();
76 : return *this;
77 : }
78 : bool IsInside( const SvBorder & rInside )
79 : {
80 : return nTop >= rInside.nTop && nRight >= rInside.nRight &&
81 : nBottom >= rInside.nBottom && nLeft >= rInside.nLeft;
82 : }
83 0 : long & Top() { return nTop; }
84 0 : long & Right() { return nRight; }
85 0 : long & Bottom() { return nBottom; }
86 0 : long & Left() { return nLeft; }
87 0 : long Top() const { return nTop; }
88 0 : long Right() const { return nRight; }
89 0 : long Bottom() const { return nBottom; }
90 0 : long Left() const { return nLeft; }
91 : };
92 :
93 : TOOLS_DLLPUBLIC Rectangle & operator += ( Rectangle & rRect, const SvBorder & rBorder );
94 : TOOLS_DLLPUBLIC Rectangle & operator -= ( Rectangle & rRect, const SvBorder & rBorder );
95 :
96 : #endif
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|