xref: /aoo41x/main/vcl/source/gdi/wall.cxx (revision 9f62ea84)
1*9f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9f62ea84SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9f62ea84SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9f62ea84SAndrew Rist  * distributed with this work for additional information
6*9f62ea84SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9f62ea84SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9f62ea84SAndrew Rist  * "License"); you may not use this file except in compliance
9*9f62ea84SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9f62ea84SAndrew Rist  *
11*9f62ea84SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9f62ea84SAndrew Rist  *
13*9f62ea84SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9f62ea84SAndrew Rist  * software distributed under the License is distributed on an
15*9f62ea84SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9f62ea84SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9f62ea84SAndrew Rist  * specific language governing permissions and limitations
18*9f62ea84SAndrew Rist  * under the License.
19*9f62ea84SAndrew Rist  *
20*9f62ea84SAndrew Rist  *************************************************************/
21*9f62ea84SAndrew Rist 
22*9f62ea84SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <tools/stream.hxx>
28cdf0e10cSrcweir #include <tools/vcompat.hxx>
29cdf0e10cSrcweir #include <tools/debug.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <vcl/bitmapex.hxx>
32cdf0e10cSrcweir #include <vcl/gradient.hxx>
33cdf0e10cSrcweir #include <vcl/wall.hxx>
34cdf0e10cSrcweir #include <vcl/svapp.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <wall2.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 
39cdf0e10cSrcweir DBG_NAME( Wallpaper )
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // -----------------------------------------------------------------------
42cdf0e10cSrcweir 
43cdf0e10cSrcweir ImplWallpaper::ImplWallpaper() :
44cdf0e10cSrcweir 	maColor( COL_TRANSPARENT )
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 	mnRefCount		= 1;
47cdf0e10cSrcweir 	mpBitmap		= NULL;
48cdf0e10cSrcweir 	mpCache			= NULL;
49cdf0e10cSrcweir 	mpGradient		= NULL;
50cdf0e10cSrcweir 	mpRect			= NULL;
51cdf0e10cSrcweir 	meStyle 		= WALLPAPER_NULL;
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir // -----------------------------------------------------------------------
55cdf0e10cSrcweir 
56cdf0e10cSrcweir ImplWallpaper::ImplWallpaper( const ImplWallpaper& rImplWallpaper ) :
57cdf0e10cSrcweir 	maColor( rImplWallpaper.maColor )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir 	mnRefCount = 1;
60cdf0e10cSrcweir 	meStyle = rImplWallpaper.meStyle;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 	if ( rImplWallpaper.mpBitmap )
63cdf0e10cSrcweir 		mpBitmap = new BitmapEx( *rImplWallpaper.mpBitmap );
64cdf0e10cSrcweir 	else
65cdf0e10cSrcweir 		mpBitmap = NULL;
66cdf0e10cSrcweir 	if( rImplWallpaper.mpCache )
67cdf0e10cSrcweir 		mpCache = new BitmapEx( *rImplWallpaper.mpCache );
68cdf0e10cSrcweir 	else
69cdf0e10cSrcweir 		mpCache = NULL;
70cdf0e10cSrcweir 	if ( rImplWallpaper.mpGradient )
71cdf0e10cSrcweir 		mpGradient = new Gradient( *rImplWallpaper.mpGradient );
72cdf0e10cSrcweir 	else
73cdf0e10cSrcweir 		mpGradient = NULL;
74cdf0e10cSrcweir 	if ( rImplWallpaper.mpRect )
75cdf0e10cSrcweir 		mpRect = new Rectangle( *rImplWallpaper.mpRect );
76cdf0e10cSrcweir 	else
77cdf0e10cSrcweir 		mpRect = NULL;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir // -----------------------------------------------------------------------
81cdf0e10cSrcweir 
82cdf0e10cSrcweir ImplWallpaper::~ImplWallpaper()
83cdf0e10cSrcweir {
84cdf0e10cSrcweir 	delete mpBitmap;
85cdf0e10cSrcweir 	delete mpCache;
86cdf0e10cSrcweir 	delete mpGradient;
87cdf0e10cSrcweir 	delete mpRect;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir // -----------------------------------------------------------------------
91cdf0e10cSrcweir 
92cdf0e10cSrcweir void ImplWallpaper::ImplSetCachedBitmap( BitmapEx& rBmp )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir 	if( !mpCache )
95cdf0e10cSrcweir 		mpCache = new BitmapEx( rBmp );
96cdf0e10cSrcweir 	else
97cdf0e10cSrcweir 		*mpCache = rBmp;
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir // -----------------------------------------------------------------------
101cdf0e10cSrcweir 
102cdf0e10cSrcweir void ImplWallpaper::ImplReleaseCachedBitmap()
103cdf0e10cSrcweir {
104cdf0e10cSrcweir 	delete mpCache;
105cdf0e10cSrcweir 	mpCache = NULL;
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir // -----------------------------------------------------------------------
109cdf0e10cSrcweir 
110cdf0e10cSrcweir SvStream& operator>>( SvStream& rIStm, ImplWallpaper& rImplWallpaper )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 	VersionCompat	aCompat( rIStm, STREAM_READ );
113cdf0e10cSrcweir 	sal_uInt16			nTmp16;
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	delete rImplWallpaper.mpRect;
116cdf0e10cSrcweir 	rImplWallpaper.mpRect = NULL;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	delete rImplWallpaper.mpGradient;
119cdf0e10cSrcweir 	rImplWallpaper.mpGradient = NULL;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	delete rImplWallpaper.mpBitmap;
122cdf0e10cSrcweir 	rImplWallpaper.mpBitmap = NULL;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	// version 1
125cdf0e10cSrcweir 	rIStm >> rImplWallpaper.maColor;
126cdf0e10cSrcweir 	rIStm >> nTmp16; rImplWallpaper.meStyle = (WallpaperStyle) nTmp16;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	// version 2
129cdf0e10cSrcweir 	if( aCompat.GetVersion() >= 2 )
130cdf0e10cSrcweir 	{
131cdf0e10cSrcweir 		sal_Bool bRect, bGrad, bBmp, bDummy;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 		rIStm >> bRect >> bGrad >> bBmp >> bDummy >> bDummy >> bDummy;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 		if( bRect )
136cdf0e10cSrcweir 		{
137cdf0e10cSrcweir 			rImplWallpaper.mpRect = new Rectangle;
138cdf0e10cSrcweir 			rIStm >> *rImplWallpaper.mpRect;
139cdf0e10cSrcweir 		}
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 		if( bGrad )
142cdf0e10cSrcweir 		{
143cdf0e10cSrcweir 			rImplWallpaper.mpGradient = new Gradient;
144cdf0e10cSrcweir 			rIStm >> *rImplWallpaper.mpGradient;
145cdf0e10cSrcweir 		}
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 		if( bBmp )
148cdf0e10cSrcweir 		{
149cdf0e10cSrcweir 			rImplWallpaper.mpBitmap = new BitmapEx;
150cdf0e10cSrcweir 			rIStm >> *rImplWallpaper.mpBitmap;
151cdf0e10cSrcweir 		}
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 		// version 3 (new color format)
154cdf0e10cSrcweir 		if( aCompat.GetVersion() >= 3 )
155cdf0e10cSrcweir 		{
156cdf0e10cSrcweir 			rImplWallpaper.maColor.Read( rIStm, sal_True );
157cdf0e10cSrcweir 		}
158cdf0e10cSrcweir 	}
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	return rIStm;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir // -----------------------------------------------------------------------
164cdf0e10cSrcweir 
165cdf0e10cSrcweir SvStream& operator<<( SvStream& rOStm, const ImplWallpaper& rImplWallpaper )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir 	VersionCompat	aCompat( rOStm, STREAM_WRITE, 3 );
168cdf0e10cSrcweir 	sal_Bool			bRect = ( rImplWallpaper.mpRect != NULL );
169cdf0e10cSrcweir 	sal_Bool			bGrad = ( rImplWallpaper.mpGradient != NULL );
170cdf0e10cSrcweir 	sal_Bool			bBmp = ( rImplWallpaper.mpBitmap != NULL );
171cdf0e10cSrcweir 	sal_Bool			bDummy = sal_False;
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	// version 1
174cdf0e10cSrcweir 	rOStm << rImplWallpaper.maColor << (sal_uInt16) rImplWallpaper.meStyle;
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 	// version 2
177cdf0e10cSrcweir 	rOStm << bRect << bGrad << bBmp << bDummy << bDummy << bDummy;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	if( bRect )
180cdf0e10cSrcweir 		rOStm << *rImplWallpaper.mpRect;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	if( bGrad )
183cdf0e10cSrcweir 		rOStm << *rImplWallpaper.mpGradient;
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	if( bBmp )
186cdf0e10cSrcweir 		rOStm << *rImplWallpaper.mpBitmap;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	// version 3 (new color format)
189cdf0e10cSrcweir 	( (Color&) rImplWallpaper.maColor ).Write( rOStm, sal_True );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	return rOStm;
192cdf0e10cSrcweir }
193cdf0e10cSrcweir 
194cdf0e10cSrcweir // -----------------------------------------------------------------------
195cdf0e10cSrcweir 
196cdf0e10cSrcweir inline void Wallpaper::ImplMakeUnique( sal_Bool bReleaseCache )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir 	// Falls noch andere Referenzen bestehen, dann kopieren
199cdf0e10cSrcweir 	if ( mpImplWallpaper->mnRefCount != 1 )
200cdf0e10cSrcweir 	{
201cdf0e10cSrcweir 		if ( mpImplWallpaper->mnRefCount )
202cdf0e10cSrcweir 			mpImplWallpaper->mnRefCount--;
203cdf0e10cSrcweir 		mpImplWallpaper = new ImplWallpaper( *(mpImplWallpaper) );
204cdf0e10cSrcweir 	}
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 	if( bReleaseCache )
207cdf0e10cSrcweir 		mpImplWallpaper->ImplReleaseCachedBitmap();
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir // -----------------------------------------------------------------------
211cdf0e10cSrcweir 
212cdf0e10cSrcweir Wallpaper::Wallpaper()
213cdf0e10cSrcweir {
214cdf0e10cSrcweir 	DBG_CTOR( Wallpaper, NULL );
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 	static ImplWallpaper aStaticImplWallpaper;
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 	aStaticImplWallpaper.mnRefCount = 0;
219cdf0e10cSrcweir 	mpImplWallpaper = &aStaticImplWallpaper;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir 
222cdf0e10cSrcweir // -----------------------------------------------------------------------
223cdf0e10cSrcweir 
224cdf0e10cSrcweir Wallpaper::Wallpaper( const Wallpaper& rWallpaper )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir 	DBG_CTOR( Wallpaper, NULL );
227cdf0e10cSrcweir 	DBG_CHKOBJ( &rWallpaper, Wallpaper, NULL );
228cdf0e10cSrcweir 	DBG_ASSERT( rWallpaper.mpImplWallpaper->mnRefCount < 0xFFFFFFFE, "Wallpaper: RefCount overflow" );
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 	// Instance Daten uebernehmen und Referenzcounter erhoehen
231cdf0e10cSrcweir 	mpImplWallpaper = rWallpaper.mpImplWallpaper;
232cdf0e10cSrcweir 	// RefCount == 0 fuer statische Objekte
233cdf0e10cSrcweir 	if ( mpImplWallpaper->mnRefCount )
234cdf0e10cSrcweir 		mpImplWallpaper->mnRefCount++;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir // -----------------------------------------------------------------------
238cdf0e10cSrcweir 
239cdf0e10cSrcweir Wallpaper::Wallpaper( const Color& rColor )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir 	DBG_CTOR( Wallpaper, NULL );
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 	mpImplWallpaper 			= new ImplWallpaper;
244cdf0e10cSrcweir 	mpImplWallpaper->maColor	= rColor;
245cdf0e10cSrcweir 	mpImplWallpaper->meStyle	= WALLPAPER_TILE;
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir // -----------------------------------------------------------------------
249cdf0e10cSrcweir 
250cdf0e10cSrcweir Wallpaper::Wallpaper( const BitmapEx& rBmpEx )
251cdf0e10cSrcweir {
252cdf0e10cSrcweir 	DBG_CTOR( Wallpaper, NULL );
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	mpImplWallpaper 			= new ImplWallpaper;
255cdf0e10cSrcweir 	mpImplWallpaper->mpBitmap	= new BitmapEx( rBmpEx );
256cdf0e10cSrcweir 	mpImplWallpaper->meStyle	= WALLPAPER_TILE;
257cdf0e10cSrcweir }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir // -----------------------------------------------------------------------
260cdf0e10cSrcweir 
261cdf0e10cSrcweir Wallpaper::Wallpaper( const Gradient& rGradient )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir 	DBG_CTOR( Wallpaper, NULL );
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 	mpImplWallpaper 			= new ImplWallpaper;
266cdf0e10cSrcweir 	mpImplWallpaper->mpGradient = new Gradient( rGradient );
267cdf0e10cSrcweir 	mpImplWallpaper->meStyle	= WALLPAPER_TILE;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
270cdf0e10cSrcweir // -----------------------------------------------------------------------
271cdf0e10cSrcweir 
272cdf0e10cSrcweir Wallpaper::~Wallpaper()
273cdf0e10cSrcweir {
274cdf0e10cSrcweir 	DBG_DTOR( Wallpaper, NULL );
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	// Wenn es keine statischen ImpDaten sind, dann loeschen, wenn es
277cdf0e10cSrcweir 	// die letzte Referenz ist, sonst Referenzcounter decrementieren
278cdf0e10cSrcweir 	if ( mpImplWallpaper->mnRefCount )
279cdf0e10cSrcweir 	{
280cdf0e10cSrcweir 		if ( mpImplWallpaper->mnRefCount == 1 )
281cdf0e10cSrcweir 			delete mpImplWallpaper;
282cdf0e10cSrcweir 		else
283cdf0e10cSrcweir 			mpImplWallpaper->mnRefCount--;
284cdf0e10cSrcweir 	}
285cdf0e10cSrcweir }
286cdf0e10cSrcweir 
287cdf0e10cSrcweir // -----------------------------------------------------------------------
288cdf0e10cSrcweir 
289cdf0e10cSrcweir void Wallpaper::SetColor( const Color& rColor )
290cdf0e10cSrcweir {
291cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 	ImplMakeUnique();
294cdf0e10cSrcweir 	mpImplWallpaper->maColor = rColor;
295cdf0e10cSrcweir 
296cdf0e10cSrcweir 	if( WALLPAPER_NULL == mpImplWallpaper->meStyle || WALLPAPER_APPLICATIONGRADIENT == mpImplWallpaper->meStyle )
297cdf0e10cSrcweir 		mpImplWallpaper->meStyle = WALLPAPER_TILE;
298cdf0e10cSrcweir }
299cdf0e10cSrcweir 
300cdf0e10cSrcweir // -----------------------------------------------------------------------
301cdf0e10cSrcweir 
302cdf0e10cSrcweir const Color& Wallpaper::GetColor() const
303cdf0e10cSrcweir {
304cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
305cdf0e10cSrcweir 
306cdf0e10cSrcweir     return mpImplWallpaper->maColor;
307cdf0e10cSrcweir }
308cdf0e10cSrcweir 
309cdf0e10cSrcweir // -----------------------------------------------------------------------
310cdf0e10cSrcweir 
311cdf0e10cSrcweir void Wallpaper::SetStyle( WallpaperStyle eStyle )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 	ImplMakeUnique( sal_False );
316cdf0e10cSrcweir 
317cdf0e10cSrcweir     if( eStyle == WALLPAPER_APPLICATIONGRADIENT )
318cdf0e10cSrcweir         // set a dummy gradient, the correct gradient
319cdf0e10cSrcweir         // will be created dynamically in GetGradient()
320cdf0e10cSrcweir         SetGradient( ImplGetApplicationGradient() );
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 	mpImplWallpaper->meStyle = eStyle;
323cdf0e10cSrcweir }
324cdf0e10cSrcweir 
325cdf0e10cSrcweir // -----------------------------------------------------------------------
326cdf0e10cSrcweir 
327cdf0e10cSrcweir WallpaperStyle Wallpaper::GetStyle() const
328cdf0e10cSrcweir {
329cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
330cdf0e10cSrcweir 
331cdf0e10cSrcweir     return mpImplWallpaper->meStyle;
332cdf0e10cSrcweir }
333cdf0e10cSrcweir 
334cdf0e10cSrcweir // -----------------------------------------------------------------------
335cdf0e10cSrcweir 
336cdf0e10cSrcweir void Wallpaper::SetBitmap( const BitmapEx& rBitmap )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 	if ( !rBitmap )
341cdf0e10cSrcweir 	{
342cdf0e10cSrcweir 		if ( mpImplWallpaper->mpBitmap )
343cdf0e10cSrcweir 		{
344cdf0e10cSrcweir 			ImplMakeUnique();
345cdf0e10cSrcweir 			delete mpImplWallpaper->mpBitmap;
346cdf0e10cSrcweir 			mpImplWallpaper->mpBitmap = NULL;
347cdf0e10cSrcweir 		}
348cdf0e10cSrcweir 	}
349cdf0e10cSrcweir 	else
350cdf0e10cSrcweir 	{
351cdf0e10cSrcweir 		ImplMakeUnique();
352cdf0e10cSrcweir 		if ( mpImplWallpaper->mpBitmap )
353cdf0e10cSrcweir 			*(mpImplWallpaper->mpBitmap) = rBitmap;
354cdf0e10cSrcweir 		else
355cdf0e10cSrcweir 			mpImplWallpaper->mpBitmap = new BitmapEx( rBitmap );
356cdf0e10cSrcweir 	}
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 	if( WALLPAPER_NULL == mpImplWallpaper->meStyle || WALLPAPER_APPLICATIONGRADIENT == mpImplWallpaper->meStyle)
359cdf0e10cSrcweir 		mpImplWallpaper->meStyle = WALLPAPER_TILE;
360cdf0e10cSrcweir }
361cdf0e10cSrcweir 
362cdf0e10cSrcweir // -----------------------------------------------------------------------
363cdf0e10cSrcweir 
364cdf0e10cSrcweir void Wallpaper::SetBitmap()
365cdf0e10cSrcweir {
366cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	if ( mpImplWallpaper->mpBitmap )
369cdf0e10cSrcweir 	{
370cdf0e10cSrcweir 		ImplMakeUnique();
371cdf0e10cSrcweir 		delete mpImplWallpaper->mpBitmap;
372cdf0e10cSrcweir 		mpImplWallpaper->mpBitmap = NULL;
373cdf0e10cSrcweir 	}
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
376cdf0e10cSrcweir // -----------------------------------------------------------------------
377cdf0e10cSrcweir 
378cdf0e10cSrcweir BitmapEx Wallpaper::GetBitmap() const
379cdf0e10cSrcweir {
380cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 	if ( mpImplWallpaper->mpBitmap )
383cdf0e10cSrcweir 		return *(mpImplWallpaper->mpBitmap);
384cdf0e10cSrcweir 	else
385cdf0e10cSrcweir 	{
386cdf0e10cSrcweir 		BitmapEx aBmp;
387cdf0e10cSrcweir 		return aBmp;
388cdf0e10cSrcweir 	}
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
391cdf0e10cSrcweir // -----------------------------------------------------------------------
392cdf0e10cSrcweir 
393cdf0e10cSrcweir sal_Bool Wallpaper::IsBitmap() const
394cdf0e10cSrcweir {
395cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
396cdf0e10cSrcweir 
397cdf0e10cSrcweir     return (mpImplWallpaper->mpBitmap != 0);
398cdf0e10cSrcweir }
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 
401cdf0e10cSrcweir // -----------------------------------------------------------------------
402cdf0e10cSrcweir 
403cdf0e10cSrcweir void Wallpaper::SetGradient( const Gradient& rGradient )
404cdf0e10cSrcweir {
405cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 	ImplMakeUnique();
408cdf0e10cSrcweir 
409cdf0e10cSrcweir 	if ( mpImplWallpaper->mpGradient )
410cdf0e10cSrcweir 		*(mpImplWallpaper->mpGradient) = rGradient;
411cdf0e10cSrcweir 	else
412cdf0e10cSrcweir 		mpImplWallpaper->mpGradient = new Gradient( rGradient );
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 	if( WALLPAPER_NULL == mpImplWallpaper->meStyle || WALLPAPER_APPLICATIONGRADIENT == mpImplWallpaper->meStyle )
415cdf0e10cSrcweir 		mpImplWallpaper->meStyle = WALLPAPER_TILE;
416cdf0e10cSrcweir }
417cdf0e10cSrcweir 
418cdf0e10cSrcweir // -----------------------------------------------------------------------
419cdf0e10cSrcweir 
420cdf0e10cSrcweir void Wallpaper::SetGradient()
421cdf0e10cSrcweir {
422cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 	if ( mpImplWallpaper->mpGradient )
425cdf0e10cSrcweir 	{
426cdf0e10cSrcweir 		ImplMakeUnique();
427cdf0e10cSrcweir 		delete mpImplWallpaper->mpGradient;
428cdf0e10cSrcweir 		mpImplWallpaper->mpGradient = NULL;
429cdf0e10cSrcweir 	}
430cdf0e10cSrcweir }
431cdf0e10cSrcweir 
432cdf0e10cSrcweir // -----------------------------------------------------------------------
433cdf0e10cSrcweir 
434cdf0e10cSrcweir Gradient Wallpaper::GetGradient() const
435cdf0e10cSrcweir {
436cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
437cdf0e10cSrcweir 
438cdf0e10cSrcweir     if( WALLPAPER_APPLICATIONGRADIENT == mpImplWallpaper->meStyle )
439cdf0e10cSrcweir         return ImplGetApplicationGradient();
440cdf0e10cSrcweir 	else if ( mpImplWallpaper->mpGradient )
441cdf0e10cSrcweir 		return *(mpImplWallpaper->mpGradient);
442cdf0e10cSrcweir 	else
443cdf0e10cSrcweir 	{
444cdf0e10cSrcweir 		Gradient aGradient;
445cdf0e10cSrcweir 		return aGradient;
446cdf0e10cSrcweir 	}
447cdf0e10cSrcweir }
448cdf0e10cSrcweir 
449cdf0e10cSrcweir // -----------------------------------------------------------------------
450cdf0e10cSrcweir 
451cdf0e10cSrcweir sal_Bool Wallpaper::IsGradient() const
452cdf0e10cSrcweir {
453cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
454cdf0e10cSrcweir 
455cdf0e10cSrcweir     return (mpImplWallpaper->mpGradient != 0);
456cdf0e10cSrcweir }
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 
459cdf0e10cSrcweir // -----------------------------------------------------------------------
460cdf0e10cSrcweir 
461cdf0e10cSrcweir Gradient Wallpaper::ImplGetApplicationGradient() const
462cdf0e10cSrcweir {
463cdf0e10cSrcweir     Gradient g;
464cdf0e10cSrcweir     g.SetAngle( 900 );
465cdf0e10cSrcweir     g.SetStyle( GRADIENT_LINEAR );
466cdf0e10cSrcweir     g.SetStartColor( Application::GetSettings().GetStyleSettings().GetFaceColor() );
467cdf0e10cSrcweir     // no 'extreme' gradient when high contrast
468cdf0e10cSrcweir 	if( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
469cdf0e10cSrcweir 		g.SetEndColor( Application::GetSettings().GetStyleSettings().GetFaceColor() );
470cdf0e10cSrcweir 	else
471cdf0e10cSrcweir 		g.SetEndColor( Application::GetSettings().GetStyleSettings().GetFaceGradientColor() );
472cdf0e10cSrcweir     return g;
473cdf0e10cSrcweir }
474cdf0e10cSrcweir 
475cdf0e10cSrcweir // -----------------------------------------------------------------------
476cdf0e10cSrcweir 
477cdf0e10cSrcweir void Wallpaper::SetRect( const Rectangle& rRect )
478cdf0e10cSrcweir {
479cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
480cdf0e10cSrcweir 
481cdf0e10cSrcweir 	ImplMakeUnique( sal_False );
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 	if ( rRect.IsEmpty() )
484cdf0e10cSrcweir 	{
485cdf0e10cSrcweir 		if ( mpImplWallpaper->mpRect )
486cdf0e10cSrcweir 		{
487cdf0e10cSrcweir 			delete mpImplWallpaper->mpRect;
488cdf0e10cSrcweir 			mpImplWallpaper->mpRect = NULL;
489cdf0e10cSrcweir 		}
490cdf0e10cSrcweir 	}
491cdf0e10cSrcweir 	else
492cdf0e10cSrcweir 	{
493cdf0e10cSrcweir 		if ( mpImplWallpaper->mpRect )
494cdf0e10cSrcweir 			*(mpImplWallpaper->mpRect) = rRect;
495cdf0e10cSrcweir 		else
496cdf0e10cSrcweir 			mpImplWallpaper->mpRect = new Rectangle( rRect );
497cdf0e10cSrcweir 	}
498cdf0e10cSrcweir }
499cdf0e10cSrcweir 
500cdf0e10cSrcweir // -----------------------------------------------------------------------
501cdf0e10cSrcweir 
502cdf0e10cSrcweir void Wallpaper::SetRect()
503cdf0e10cSrcweir {
504cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 	if ( mpImplWallpaper->mpRect )
507cdf0e10cSrcweir 	{
508cdf0e10cSrcweir 		ImplMakeUnique( sal_False );
509cdf0e10cSrcweir 		delete mpImplWallpaper->mpRect;
510cdf0e10cSrcweir 		mpImplWallpaper->mpRect = NULL;
511cdf0e10cSrcweir 	}
512cdf0e10cSrcweir }
513cdf0e10cSrcweir 
514cdf0e10cSrcweir // -----------------------------------------------------------------------
515cdf0e10cSrcweir 
516cdf0e10cSrcweir Rectangle Wallpaper::GetRect() const
517cdf0e10cSrcweir {
518cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
519cdf0e10cSrcweir 
520cdf0e10cSrcweir 	if ( mpImplWallpaper->mpRect )
521cdf0e10cSrcweir 		return *(mpImplWallpaper->mpRect);
522cdf0e10cSrcweir 	else
523cdf0e10cSrcweir 	{
524cdf0e10cSrcweir 		Rectangle aRect;
525cdf0e10cSrcweir 		return aRect;
526cdf0e10cSrcweir 	}
527cdf0e10cSrcweir }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir // -----------------------------------------------------------------------
530cdf0e10cSrcweir 
531cdf0e10cSrcweir sal_Bool Wallpaper::IsRect() const
532cdf0e10cSrcweir {
533cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
534cdf0e10cSrcweir 
535cdf0e10cSrcweir     return (mpImplWallpaper->mpRect != 0);
536cdf0e10cSrcweir }
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 
539cdf0e10cSrcweir // -----------------------------------------------------------------------
540cdf0e10cSrcweir 
541cdf0e10cSrcweir sal_Bool Wallpaper::IsFixed() const
542cdf0e10cSrcweir {
543cdf0e10cSrcweir 	if ( mpImplWallpaper->meStyle == WALLPAPER_NULL )
544cdf0e10cSrcweir 		return sal_False;
545cdf0e10cSrcweir 	else
546cdf0e10cSrcweir 		return (!mpImplWallpaper->mpBitmap && !mpImplWallpaper->mpGradient);
547cdf0e10cSrcweir }
548cdf0e10cSrcweir 
549cdf0e10cSrcweir // -----------------------------------------------------------------------
550cdf0e10cSrcweir 
551cdf0e10cSrcweir sal_Bool Wallpaper::IsScrollable() const
552cdf0e10cSrcweir {
553cdf0e10cSrcweir 	if ( mpImplWallpaper->meStyle == WALLPAPER_NULL )
554cdf0e10cSrcweir 		return sal_False;
555cdf0e10cSrcweir 	else if ( !mpImplWallpaper->mpBitmap && !mpImplWallpaper->mpGradient )
556cdf0e10cSrcweir 		return sal_True;
557cdf0e10cSrcweir 	else if ( mpImplWallpaper->mpBitmap )
558cdf0e10cSrcweir 		return (mpImplWallpaper->meStyle == WALLPAPER_TILE);
559cdf0e10cSrcweir 	else
560cdf0e10cSrcweir 		return sal_False;
561cdf0e10cSrcweir }
562cdf0e10cSrcweir 
563cdf0e10cSrcweir // -----------------------------------------------------------------------
564cdf0e10cSrcweir 
565cdf0e10cSrcweir Wallpaper& Wallpaper::operator=( const Wallpaper& rWallpaper )
566cdf0e10cSrcweir {
567cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
568cdf0e10cSrcweir 	DBG_CHKOBJ( &rWallpaper, Wallpaper, NULL );
569cdf0e10cSrcweir 	DBG_ASSERT( rWallpaper.mpImplWallpaper->mnRefCount < 0xFFFFFFFE, "Wallpaper: RefCount overflow" );
570cdf0e10cSrcweir 
571cdf0e10cSrcweir 	// Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
572cdf0e10cSrcweir 	if ( rWallpaper.mpImplWallpaper->mnRefCount )
573cdf0e10cSrcweir 		rWallpaper.mpImplWallpaper->mnRefCount++;
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 	// Wenn es keine statischen ImpDaten sind, dann loeschen, wenn es
576cdf0e10cSrcweir 	// die letzte Referenz ist, sonst Referenzcounter decrementieren
577cdf0e10cSrcweir 	if ( mpImplWallpaper->mnRefCount )
578cdf0e10cSrcweir 	{
579cdf0e10cSrcweir 		if ( mpImplWallpaper->mnRefCount == 1 )
580cdf0e10cSrcweir 			delete mpImplWallpaper;
581cdf0e10cSrcweir 		else
582cdf0e10cSrcweir 			mpImplWallpaper->mnRefCount--;
583cdf0e10cSrcweir 	}
584cdf0e10cSrcweir 
585cdf0e10cSrcweir 	mpImplWallpaper = rWallpaper.mpImplWallpaper;
586cdf0e10cSrcweir 
587cdf0e10cSrcweir 	return *this;
588cdf0e10cSrcweir }
589cdf0e10cSrcweir 
590cdf0e10cSrcweir // -----------------------------------------------------------------------
591cdf0e10cSrcweir 
592cdf0e10cSrcweir sal_Bool Wallpaper::operator==( const Wallpaper& rWallpaper ) const
593cdf0e10cSrcweir {
594cdf0e10cSrcweir 	DBG_CHKTHIS( Wallpaper, NULL );
595cdf0e10cSrcweir 	DBG_CHKOBJ( &rWallpaper, Wallpaper, NULL );
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 	if ( mpImplWallpaper == rWallpaper.mpImplWallpaper )
598cdf0e10cSrcweir 		return sal_True;
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 	if ( ( mpImplWallpaper->meStyle != rWallpaper.mpImplWallpaper->meStyle ) ||
601cdf0e10cSrcweir 	     ( mpImplWallpaper->maColor	!= rWallpaper.mpImplWallpaper->maColor ) )
602cdf0e10cSrcweir 		return sal_False;
603cdf0e10cSrcweir 
604cdf0e10cSrcweir 	if ( mpImplWallpaper->mpRect != rWallpaper.mpImplWallpaper->mpRect
605cdf0e10cSrcweir 	     && ( !mpImplWallpaper->mpRect
606cdf0e10cSrcweir 		      || !rWallpaper.mpImplWallpaper->mpRect
607cdf0e10cSrcweir 			  || *(mpImplWallpaper->mpRect) != *(rWallpaper.mpImplWallpaper->mpRect) ) )
608cdf0e10cSrcweir 		return sal_False;
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 	if ( mpImplWallpaper->mpBitmap != rWallpaper.mpImplWallpaper->mpBitmap
611cdf0e10cSrcweir 	     && ( !mpImplWallpaper->mpBitmap
612cdf0e10cSrcweir 		      || !rWallpaper.mpImplWallpaper->mpBitmap
613cdf0e10cSrcweir 			  || *(mpImplWallpaper->mpBitmap) != *(rWallpaper.mpImplWallpaper->mpBitmap) ) )
614cdf0e10cSrcweir 		return sal_False;
615cdf0e10cSrcweir 
616cdf0e10cSrcweir 	if ( mpImplWallpaper->mpGradient != rWallpaper.mpImplWallpaper->mpGradient
617cdf0e10cSrcweir 	     && ( !mpImplWallpaper->mpGradient
618cdf0e10cSrcweir 		      || !rWallpaper.mpImplWallpaper->mpGradient
619cdf0e10cSrcweir 			  || *(mpImplWallpaper->mpGradient) != *(rWallpaper.mpImplWallpaper->mpGradient) ) )
620cdf0e10cSrcweir 		return sal_False;
621cdf0e10cSrcweir 
622cdf0e10cSrcweir 	return sal_True;
623cdf0e10cSrcweir }
624cdf0e10cSrcweir 
625cdf0e10cSrcweir // -----------------------------------------------------------------------
626cdf0e10cSrcweir 
627cdf0e10cSrcweir SvStream& operator>>( SvStream& rIStm, Wallpaper& rWallpaper )
628cdf0e10cSrcweir {
629cdf0e10cSrcweir 	rWallpaper.ImplMakeUnique();
630cdf0e10cSrcweir 	return( rIStm >> *rWallpaper.mpImplWallpaper );
631cdf0e10cSrcweir }
632cdf0e10cSrcweir 
633cdf0e10cSrcweir // -----------------------------------------------------------------------
634cdf0e10cSrcweir 
635cdf0e10cSrcweir SvStream& operator<<( SvStream& rOStm, const Wallpaper& rWallpaper )
636cdf0e10cSrcweir {
637cdf0e10cSrcweir 	return( rOStm << *rWallpaper.mpImplWallpaper );
638cdf0e10cSrcweir }
639