Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <drawinglayer/attribute/fillbitmapattribute.hxx>
30 : : #include <vcl/bitmapex.hxx>
31 : :
32 : : //////////////////////////////////////////////////////////////////////////////
33 : :
34 : : namespace drawinglayer
35 : : {
36 : : namespace attribute
37 : : {
38 : 262 : class ImpFillBitmapAttribute
39 : : {
40 : : public:
41 : : // refcounter
42 : : sal_uInt32 mnRefCount;
43 : :
44 : : // data definitions
45 : : BitmapEx maBitmapEx;
46 : : basegfx::B2DPoint maTopLeft;
47 : : basegfx::B2DVector maSize;
48 : :
49 : : // bitfield
50 : : unsigned mbTiling : 1;
51 : :
52 : 264 : ImpFillBitmapAttribute(
53 : : const BitmapEx& rBitmapEx,
54 : : const basegfx::B2DPoint& rTopLeft,
55 : : const basegfx::B2DVector& rSize,
56 : : bool bTiling)
57 : : : mnRefCount(0),
58 : : maBitmapEx(rBitmapEx),
59 : : maTopLeft(rTopLeft),
60 : : maSize(rSize),
61 : 264 : mbTiling(bTiling)
62 : : {
63 : 264 : }
64 : :
65 : 0 : bool operator==(const ImpFillBitmapAttribute& rCandidate) const
66 : : {
67 : 0 : return (maBitmapEx == rCandidate.maBitmapEx
68 : 0 : && maTopLeft == rCandidate.maTopLeft
69 : 0 : && maSize == rCandidate.maSize
70 [ # # ][ # # : 0 : && mbTiling == rCandidate.mbTiling);
# # # # ]
71 : : }
72 : :
73 : : // data read access
74 : 626 : const BitmapEx& getBitmapEx() const { return maBitmapEx; }
75 : 626 : const basegfx::B2DPoint& getTopLeft() const { return maTopLeft; }
76 : 313 : const basegfx::B2DVector& getSize() const { return maSize; }
77 : 313 : bool getTiling() const { return mbTiling; }
78 : :
79 : 262 : static ImpFillBitmapAttribute* get_global_default()
80 : : {
81 : : static ImpFillBitmapAttribute* pDefault = 0;
82 : :
83 [ + + ]: 262 : if(!pDefault)
84 : : {
85 : : pDefault = new ImpFillBitmapAttribute(
86 : : BitmapEx(),
87 : : basegfx::B2DPoint(),
88 : : basegfx::B2DVector(),
89 [ + - ][ + - ]: 2 : false);
90 : :
91 : : // never delete; start with RefCount 1, not 0
92 : 2 : pDefault->mnRefCount++;
93 : : }
94 : :
95 : 262 : return pDefault;
96 : : }
97 : : };
98 : :
99 : 262 : FillBitmapAttribute::FillBitmapAttribute(
100 : : const BitmapEx& rBitmapEx,
101 : : const basegfx::B2DPoint& rTopLeft,
102 : : const basegfx::B2DVector& rSize,
103 : : bool bTiling)
104 : : : mpFillBitmapAttribute(new ImpFillBitmapAttribute(
105 [ + - ]: 262 : rBitmapEx, rTopLeft, rSize, bTiling))
106 : : {
107 : 262 : }
108 : :
109 : 524 : FillBitmapAttribute::FillBitmapAttribute(const FillBitmapAttribute& rCandidate)
110 : 524 : : mpFillBitmapAttribute(rCandidate.mpFillBitmapAttribute)
111 : : {
112 : 524 : mpFillBitmapAttribute->mnRefCount++;
113 : 524 : }
114 : :
115 : 786 : FillBitmapAttribute::~FillBitmapAttribute()
116 : : {
117 [ + + ]: 786 : if(mpFillBitmapAttribute->mnRefCount)
118 : : {
119 : 524 : mpFillBitmapAttribute->mnRefCount--;
120 : : }
121 : : else
122 : : {
123 [ + - ]: 262 : delete mpFillBitmapAttribute;
124 : : }
125 : 786 : }
126 : :
127 : 262 : bool FillBitmapAttribute::isDefault() const
128 : : {
129 : 262 : return mpFillBitmapAttribute == ImpFillBitmapAttribute::get_global_default();
130 : : }
131 : :
132 : 0 : FillBitmapAttribute& FillBitmapAttribute::operator=(const FillBitmapAttribute& rCandidate)
133 : : {
134 [ # # ]: 0 : if(rCandidate.mpFillBitmapAttribute != mpFillBitmapAttribute)
135 : : {
136 [ # # ]: 0 : if(mpFillBitmapAttribute->mnRefCount)
137 : : {
138 : 0 : mpFillBitmapAttribute->mnRefCount--;
139 : : }
140 : : else
141 : : {
142 [ # # ]: 0 : delete mpFillBitmapAttribute;
143 : : }
144 : :
145 : 0 : mpFillBitmapAttribute = rCandidate.mpFillBitmapAttribute;
146 : 0 : mpFillBitmapAttribute->mnRefCount++;
147 : : }
148 : :
149 : 0 : return *this;
150 : : }
151 : :
152 : 0 : bool FillBitmapAttribute::operator==(const FillBitmapAttribute& rCandidate) const
153 : : {
154 [ # # ]: 0 : if(rCandidate.mpFillBitmapAttribute == mpFillBitmapAttribute)
155 : : {
156 : 0 : return true;
157 : : }
158 : :
159 [ # # ]: 0 : if(rCandidate.isDefault() != isDefault())
160 : : {
161 : 0 : return false;
162 : : }
163 : :
164 : 0 : return (*rCandidate.mpFillBitmapAttribute == *mpFillBitmapAttribute);
165 : : }
166 : :
167 : 626 : const BitmapEx& FillBitmapAttribute::getBitmapEx() const
168 : : {
169 : 626 : return mpFillBitmapAttribute->getBitmapEx();
170 : : }
171 : :
172 : 626 : const basegfx::B2DPoint& FillBitmapAttribute::getTopLeft() const
173 : : {
174 : 626 : return mpFillBitmapAttribute->getTopLeft();
175 : : }
176 : :
177 : 313 : const basegfx::B2DVector& FillBitmapAttribute::getSize() const
178 : : {
179 : 313 : return mpFillBitmapAttribute->getSize();
180 : : }
181 : :
182 : 313 : bool FillBitmapAttribute::getTiling() const
183 : : {
184 : 313 : return mpFillBitmapAttribute->getTiling();
185 : : }
186 : :
187 : : } // end of namespace attribute
188 : : } // end of namespace drawinglayer
189 : :
190 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|