xref: /trunk/main/tools/inc/tools/svborder.hxx (revision 8b851043)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVBORDER_HXX
25 #define _SVBORDER_HXX
26 
27 #include "tools/toolsdllapi.h"
28 #include <tools/gen.hxx>
29 
30 class TOOLS_DLLPUBLIC SvBorder
31 {
32 	long nTop, nRight, nBottom, nLeft;
33 public:
SvBorder()34 	SvBorder()
35 	{ nTop = nRight = nBottom = nLeft = 0; }
SvBorder(const Size & rSz)36 	SvBorder( const Size & rSz )
37 	{ nTop = nBottom = rSz.Height(); nRight = nLeft = rSz.Width(); }
38 	SvBorder( const Rectangle & rOuter, const Rectangle & rInner );
SvBorder(long nLeftP,long nTopP,long nRightP,long nBottomP)39 	SvBorder( long nLeftP, long nTopP, long nRightP, long nBottomP )
40 	{ nLeft = nLeftP; nTop = nTopP; nRight = nRightP; nBottom = nBottomP; }
operator ==(const SvBorder & rObj) const41 	sal_Bool    operator == ( const SvBorder & rObj ) const
42 			{
43 				return nTop == rObj.nTop && nRight == rObj.nRight &&
44 					   nBottom == rObj.nBottom && nLeft == rObj.nLeft;
45 			}
operator !=(const SvBorder & rObj) const46 	sal_Bool    operator != ( const SvBorder & rObj ) const
47 			{ return !(*this == rObj); }
operator =(const SvBorder & rBorder)48     SvBorder & operator = ( const SvBorder & rBorder )
49             {
50                 Left()   = rBorder.Left();
51                 Top()    = rBorder.Top();
52                 Right()  = rBorder.Right();
53                 Bottom() = rBorder.Bottom();
54                 return *this;
55 			}
operator +=(const SvBorder & rBorder)56 	SvBorder & operator += ( const SvBorder & rBorder )
57 			{
58 				Left()   += rBorder.Left();
59 				Top()    += rBorder.Top();
60 				Right()  += rBorder.Right();
61 				Bottom() += rBorder.Bottom();
62 				return *this;
63 			}
operator -=(const SvBorder & rBorder)64 	SvBorder & operator -= ( const SvBorder & rBorder )
65 			{
66 				Left()   -= rBorder.Left();
67 				Top()    -= rBorder.Top();
68 				Right()  -= rBorder.Right();
69 				Bottom() -= rBorder.Bottom();
70 				return *this;
71 			}
IsInside(const SvBorder & rInside)72 	sal_Bool    IsInside( const SvBorder & rInside )
73 			{
74 				return nTop >= rInside.nTop && nRight >= rInside.nRight &&
75 					   nBottom >= rInside.nBottom && nLeft >= rInside.nLeft;
76 			}
Top()77 	long &  Top()    { return nTop; }
Right()78 	long &  Right()  { return nRight; }
Bottom()79 	long &  Bottom() { return nBottom; }
Left()80 	long &  Left()   { return nLeft; }
Top() const81 	long    Top()    const { return nTop; }
Right() const82 	long    Right()  const { return nRight; }
Bottom() const83 	long    Bottom() const { return nBottom; }
Left() const84 	long    Left()   const { return nLeft; }
85 };
86 
87 TOOLS_DLLPUBLIC Rectangle & operator += ( Rectangle & rRect, const SvBorder & rBorder );
88 TOOLS_DLLPUBLIC Rectangle & operator -= ( Rectangle & rRect, const SvBorder & rBorder );
89 
90 //=========================================================================
91 
92 #endif
93 
94