Branch data 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 _SVBORDER_HXX
21 : : #define _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 : 16620 : SvBorder()
32 : 16620 : { nTop = nRight = nBottom = nLeft = 0; }
33 : : SvBorder( const Size & rSz )
34 : : { nTop = nBottom = rSz.Height(); nRight = nLeft = rSz.Width(); }
35 : 714 : SvBorder( long nLeftP, long nTopP, long nRightP, long nBottomP )
36 : 714 : { nLeft = nLeftP; nTop = nTopP; nRight = nRightP; nBottom = nBottomP; }
37 : 558 : sal_Bool operator == ( const SvBorder & rObj ) const
38 : : {
39 : : return nTop == rObj.nTop && nRight == rObj.nRight &&
40 [ + + ][ + - ]: 558 : nBottom == rObj.nBottom && nLeft == rObj.nLeft;
[ + - ][ + - ]
41 : : }
42 : 558 : sal_Bool operator != ( const SvBorder & rObj ) const
43 : 558 : { return !(*this == rObj); }
44 : 14489 : SvBorder & operator = ( const SvBorder & rBorder )
45 : : {
46 : 14489 : Left() = rBorder.Left();
47 : 14489 : Top() = rBorder.Top();
48 : 14489 : Right() = rBorder.Right();
49 : 14489 : Bottom() = rBorder.Bottom();
50 : 14489 : return *this;
51 : : }
52 : 558 : SvBorder & operator += ( const SvBorder & rBorder )
53 : : {
54 : 558 : Left() += rBorder.Left();
55 : 558 : Top() += rBorder.Top();
56 : 558 : Right() += rBorder.Right();
57 : 558 : Bottom() += rBorder.Bottom();
58 : 558 : return *this;
59 : : }
60 : : SvBorder & operator -= ( const SvBorder & rBorder )
61 : : {
62 : : Left() -= rBorder.Left();
63 : : Top() -= rBorder.Top();
64 : : Right() -= rBorder.Right();
65 : : Bottom() -= rBorder.Bottom();
66 : : return *this;
67 : : }
68 : : sal_Bool IsInside( const SvBorder & rInside )
69 : : {
70 : : return nTop >= rInside.nTop && nRight >= rInside.nRight &&
71 : : nBottom >= rInside.nBottom && nLeft >= rInside.nLeft;
72 : : }
73 : 25548 : long & Top() { return nTop; }
74 : 24835 : long & Right() { return nRight; }
75 : 24485 : long & Bottom() { return nBottom; }
76 : 25371 : long & Left() { return nLeft; }
77 : 34573 : long Top() const { return nTop; }
78 : 26644 : long Right() const { return nRight; }
79 : 26518 : long Bottom() const { return nBottom; }
80 : 34699 : long Left() const { return nLeft; }
81 : : };
82 : :
83 : : TOOLS_DLLPUBLIC Rectangle & operator += ( Rectangle & rRect, const SvBorder & rBorder );
84 : : TOOLS_DLLPUBLIC Rectangle & operator -= ( Rectangle & rRect, const SvBorder & rBorder );
85 : :
86 : : #endif
87 : :
88 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|