xref: /AOO41X/main/svl/source/items/cntwall.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svl.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <tools/debug.hxx>
32*cdf0e10cSrcweir #include <tools/string.hxx>
33*cdf0e10cSrcweir #include <tools/stream.hxx>
34*cdf0e10cSrcweir #include <tools/vcompat.hxx>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include <svl/cntwall.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #define CNTWALLPAPERITEM_STREAM_MAGIC   ( (sal_uInt32)0xfefefefe )
39*cdf0e10cSrcweir #define CNTWALLPAPERITEM_STREAM_SEEKREL (-( (long)( sizeof( sal_uInt32 ) ) ) )
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir TYPEINIT1( CntWallpaperItem, SfxPoolItem );
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir // -----------------------------------------------------------------------
44*cdf0e10cSrcweir CntWallpaperItem::CntWallpaperItem( sal_uInt16 which )
45*cdf0e10cSrcweir 	: SfxPoolItem( which ), _nColor( COL_TRANSPARENT ), _nStyle( 0 )
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir }
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir // -----------------------------------------------------------------------
50*cdf0e10cSrcweir CntWallpaperItem::CntWallpaperItem( sal_uInt16 which, SvStream& rStream, sal_uInt16 nVersion )
51*cdf0e10cSrcweir 	: SfxPoolItem( which ), _nColor( COL_TRANSPARENT ), _nStyle( 0 )
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir 	sal_uInt32 nMagic = 0;
54*cdf0e10cSrcweir 	rStream >> nMagic;
55*cdf0e10cSrcweir 	if ( nMagic == CNTWALLPAPERITEM_STREAM_MAGIC )
56*cdf0e10cSrcweir 	{
57*cdf0e10cSrcweir 		// Okay, data were stored by CntWallpaperItem.
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 		readUnicodeString(rStream, _aURL, nVersion >= 1);
60*cdf0e10cSrcweir 		// !!! Color stream operators do not work - they discard any
61*cdf0e10cSrcweir 		// transparency info !!!
62*cdf0e10cSrcweir 		_nColor.Read( rStream, sal_True );
63*cdf0e10cSrcweir 		rStream >> _nStyle;
64*cdf0e10cSrcweir 	}
65*cdf0e10cSrcweir 	else
66*cdf0e10cSrcweir 	{
67*cdf0e10cSrcweir 		rStream.SeekRel( CNTWALLPAPERITEM_STREAM_SEEKREL );
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 		// Data were stored by SfxWallpaperItem ( SO < 6.0 ). The only
70*cdf0e10cSrcweir 		// thing we can do here is to get the URL and to position the stream.
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir 		{
73*cdf0e10cSrcweir 			// "Read" Wallpaper member - The version compat object positions
74*cdf0e10cSrcweir 			// the stream after the wallpaper data in its dtor. We must use
75*cdf0e10cSrcweir 			// this trick here as no VCL must be used here ( No Wallpaper
76*cdf0e10cSrcweir 			// object allowed ).
77*cdf0e10cSrcweir 			VersionCompat aCompat( rStream, STREAM_READ );
78*cdf0e10cSrcweir 		}
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 		// Read SfxWallpaperItem's string member _aURL.
81*cdf0e10cSrcweir 		readUnicodeString(rStream, _aURL, false);
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 		// "Read" SfxWallpaperItem's string member _aFilter.
84*cdf0e10cSrcweir 		ByteString aDummy;
85*cdf0e10cSrcweir 		rStream.ReadByteString(aDummy);
86*cdf0e10cSrcweir 	}
87*cdf0e10cSrcweir }
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir // -----------------------------------------------------------------------
90*cdf0e10cSrcweir CntWallpaperItem::CntWallpaperItem( const CntWallpaperItem& rItem ) :
91*cdf0e10cSrcweir 	SfxPoolItem( rItem ),
92*cdf0e10cSrcweir 	_aURL( rItem._aURL ),
93*cdf0e10cSrcweir 	_nColor( rItem._nColor ),
94*cdf0e10cSrcweir 	_nStyle( rItem._nStyle )
95*cdf0e10cSrcweir {
96*cdf0e10cSrcweir }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir // -----------------------------------------------------------------------
99*cdf0e10cSrcweir CntWallpaperItem::~CntWallpaperItem()
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir }
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir // -----------------------------------------------------------------------
104*cdf0e10cSrcweir int CntWallpaperItem::operator==( const SfxPoolItem& rItem ) const
105*cdf0e10cSrcweir {
106*cdf0e10cSrcweir 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 	const CntWallpaperItem& rWallItem = (const CntWallpaperItem&)rItem;
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 	if( ( rWallItem._nStyle == _nStyle ) &&
111*cdf0e10cSrcweir 		( rWallItem._nColor == _nColor ) &&
112*cdf0e10cSrcweir 		( rWallItem._aURL == _aURL ) )
113*cdf0e10cSrcweir 		return sal_True;
114*cdf0e10cSrcweir 	else
115*cdf0e10cSrcweir 		return sal_False;
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir //============================================================================
119*cdf0e10cSrcweir // virtual
120*cdf0e10cSrcweir sal_uInt16 CntWallpaperItem::GetVersion(sal_uInt16) const
121*cdf0e10cSrcweir {
122*cdf0e10cSrcweir 	return 1; // because it uses SfxPoolItem::read/writeUnicodeString()
123*cdf0e10cSrcweir }
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir // -----------------------------------------------------------------------
126*cdf0e10cSrcweir SfxPoolItem* CntWallpaperItem::Create( SvStream& rStream, sal_uInt16 nVersion) const
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir 	return new CntWallpaperItem( Which(), rStream, nVersion );
129*cdf0e10cSrcweir }
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir // -----------------------------------------------------------------------
132*cdf0e10cSrcweir SvStream& CntWallpaperItem::Store( SvStream& rStream, sal_uInt16 ) const
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir 	rStream << CNTWALLPAPERITEM_STREAM_MAGIC;
135*cdf0e10cSrcweir 	writeUnicodeString(rStream, _aURL);
136*cdf0e10cSrcweir 	// !!! Color stream operators do not work - they discard any
137*cdf0e10cSrcweir 	// transparency info !!!
138*cdf0e10cSrcweir 	// ??? Why the hell Color::Write(...) isn't const ???
139*cdf0e10cSrcweir 	SAL_CONST_CAST( CntWallpaperItem*, this )->_nColor.Write( rStream, sal_True );
140*cdf0e10cSrcweir 	rStream << _nStyle;
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 	return rStream;
143*cdf0e10cSrcweir }
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir // -----------------------------------------------------------------------
146*cdf0e10cSrcweir SfxPoolItem* CntWallpaperItem::Clone( SfxItemPool* ) const
147*cdf0e10cSrcweir {
148*cdf0e10cSrcweir 	return new CntWallpaperItem( *this );
149*cdf0e10cSrcweir }
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir //----------------------------------------------------------------------------
152*cdf0e10cSrcweir // virtual
153*cdf0e10cSrcweir sal_Bool CntWallpaperItem::QueryValue( com::sun::star::uno::Any&,sal_uInt8 ) const
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir     DBG_ERROR("Not implemented!");
156*cdf0e10cSrcweir 	return sal_False;
157*cdf0e10cSrcweir }
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir //----------------------------------------------------------------------------
160*cdf0e10cSrcweir // virtual
161*cdf0e10cSrcweir sal_Bool CntWallpaperItem::PutValue( const com::sun::star::uno::Any&,sal_uInt8 )
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir     DBG_ERROR("Not implemented!");
164*cdf0e10cSrcweir 	return sal_False;
165*cdf0e10cSrcweir }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 
168