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