xref: /trunk/main/tools/source/generic/svborder.cxx (revision 89b56da7)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_tools.hxx"
26 
27 #include <tools/svborder.hxx>
28 #include <osl/diagnose.h>
29 
SvBorder(const Rectangle & rOuter,const Rectangle & rInner)30 SvBorder::SvBorder( const Rectangle & rOuter, const Rectangle & rInner )
31 {
32 	Rectangle aOuter( rOuter );
33 	aOuter.Justify();
34 	Rectangle aInner( rInner );
35 	if( aInner.IsEmpty() )
36 		aInner = Rectangle( aOuter.Center(), aOuter.Center() );
37 	else
38 		aInner.Justify();
39 
40 	OSL_ENSURE( aOuter.IsInside( aInner ),
41 				"SvBorder::SvBorder: sal_False == aOuter.IsInside( aInner )" );
42 	nTop	= aInner.Top()	  - aOuter.Top();
43 	nRight	= aOuter.Right()  - aInner.Right();
44 	nBottom = aOuter.Bottom() - aInner.Bottom();
45 	nLeft	= aInner.Left()   - aOuter.Left();
46 }
47 
operator +=(Rectangle & rRect,const SvBorder & rBorder)48 Rectangle & operator += ( Rectangle & rRect, const SvBorder & rBorder )
49 {
50 	// wegen Empty-Rect, GetSize muss als erstes gerufen werden
51 	Size aS( rRect.GetSize() );
52 	aS.Width()	+= rBorder.Left() + rBorder.Right();
53 	aS.Height() += rBorder.Top() + rBorder.Bottom();
54 
55 	rRect.Left()   -= rBorder.Left();
56 	rRect.Top()    -= rBorder.Top();
57 	rRect.SetSize( aS );
58 	return rRect;
59 }
60 
operator -=(Rectangle & rRect,const SvBorder & rBorder)61 Rectangle & operator -= ( Rectangle & rRect, const SvBorder & rBorder )
62 {
63 	// wegen Empty-Rect, GetSize muss als erstes gerufen werden
64 	Size aS( rRect.GetSize() );
65 	aS.Width()	-= rBorder.Left() + rBorder.Right();
66 	aS.Height() -= rBorder.Top() + rBorder.Bottom();
67 
68 	rRect.Left()   += rBorder.Left();
69 	rRect.Top()    += rBorder.Top();
70 	rRect.SetSize( aS );
71 	return rRect;
72 }
73 
74