1*40df464eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*40df464eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*40df464eSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*40df464eSAndrew Rist * distributed with this work for additional information
6*40df464eSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*40df464eSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*40df464eSAndrew Rist * "License"); you may not use this file except in compliance
9*40df464eSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*40df464eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*40df464eSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*40df464eSAndrew Rist * software distributed under the License is distributed on an
15*40df464eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*40df464eSAndrew Rist * KIND, either express or implied. See the License for the
17*40df464eSAndrew Rist * specific language governing permissions and limitations
18*40df464eSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*40df464eSAndrew Rist *************************************************************/
21*40df464eSAndrew Rist
22*40df464eSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <tools/debug.hxx>
28cdf0e10cSrcweir #include <tools/string.hxx>
29cdf0e10cSrcweir #include <tools/stream.hxx>
30cdf0e10cSrcweir #include <tools/vcompat.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <svl/cntwall.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir #define CNTWALLPAPERITEM_STREAM_MAGIC ( (sal_uInt32)0xfefefefe )
35cdf0e10cSrcweir #define CNTWALLPAPERITEM_STREAM_SEEKREL (-( (long)( sizeof( sal_uInt32 ) ) ) )
36cdf0e10cSrcweir
37cdf0e10cSrcweir TYPEINIT1( CntWallpaperItem, SfxPoolItem );
38cdf0e10cSrcweir
39cdf0e10cSrcweir // -----------------------------------------------------------------------
CntWallpaperItem(sal_uInt16 which)40cdf0e10cSrcweir CntWallpaperItem::CntWallpaperItem( sal_uInt16 which )
41cdf0e10cSrcweir : SfxPoolItem( which ), _nColor( COL_TRANSPARENT ), _nStyle( 0 )
42cdf0e10cSrcweir {
43cdf0e10cSrcweir }
44cdf0e10cSrcweir
45cdf0e10cSrcweir // -----------------------------------------------------------------------
CntWallpaperItem(sal_uInt16 which,SvStream & rStream,sal_uInt16 nVersion)46cdf0e10cSrcweir CntWallpaperItem::CntWallpaperItem( sal_uInt16 which, SvStream& rStream, sal_uInt16 nVersion )
47cdf0e10cSrcweir : SfxPoolItem( which ), _nColor( COL_TRANSPARENT ), _nStyle( 0 )
48cdf0e10cSrcweir {
49cdf0e10cSrcweir sal_uInt32 nMagic = 0;
50cdf0e10cSrcweir rStream >> nMagic;
51cdf0e10cSrcweir if ( nMagic == CNTWALLPAPERITEM_STREAM_MAGIC )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir // Okay, data were stored by CntWallpaperItem.
54cdf0e10cSrcweir
55cdf0e10cSrcweir readUnicodeString(rStream, _aURL, nVersion >= 1);
56cdf0e10cSrcweir // !!! Color stream operators do not work - they discard any
57cdf0e10cSrcweir // transparency info !!!
58cdf0e10cSrcweir _nColor.Read( rStream, sal_True );
59cdf0e10cSrcweir rStream >> _nStyle;
60cdf0e10cSrcweir }
61cdf0e10cSrcweir else
62cdf0e10cSrcweir {
63cdf0e10cSrcweir rStream.SeekRel( CNTWALLPAPERITEM_STREAM_SEEKREL );
64cdf0e10cSrcweir
65cdf0e10cSrcweir // Data were stored by SfxWallpaperItem ( SO < 6.0 ). The only
66cdf0e10cSrcweir // thing we can do here is to get the URL and to position the stream.
67cdf0e10cSrcweir
68cdf0e10cSrcweir {
69cdf0e10cSrcweir // "Read" Wallpaper member - The version compat object positions
70cdf0e10cSrcweir // the stream after the wallpaper data in its dtor. We must use
71cdf0e10cSrcweir // this trick here as no VCL must be used here ( No Wallpaper
72cdf0e10cSrcweir // object allowed ).
73cdf0e10cSrcweir VersionCompat aCompat( rStream, STREAM_READ );
74cdf0e10cSrcweir }
75cdf0e10cSrcweir
76cdf0e10cSrcweir // Read SfxWallpaperItem's string member _aURL.
77cdf0e10cSrcweir readUnicodeString(rStream, _aURL, false);
78cdf0e10cSrcweir
79cdf0e10cSrcweir // "Read" SfxWallpaperItem's string member _aFilter.
80cdf0e10cSrcweir ByteString aDummy;
81cdf0e10cSrcweir rStream.ReadByteString(aDummy);
82cdf0e10cSrcweir }
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
85cdf0e10cSrcweir // -----------------------------------------------------------------------
CntWallpaperItem(const CntWallpaperItem & rItem)86cdf0e10cSrcweir CntWallpaperItem::CntWallpaperItem( const CntWallpaperItem& rItem ) :
87cdf0e10cSrcweir SfxPoolItem( rItem ),
88cdf0e10cSrcweir _aURL( rItem._aURL ),
89cdf0e10cSrcweir _nColor( rItem._nColor ),
90cdf0e10cSrcweir _nStyle( rItem._nStyle )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
94cdf0e10cSrcweir // -----------------------------------------------------------------------
~CntWallpaperItem()95cdf0e10cSrcweir CntWallpaperItem::~CntWallpaperItem()
96cdf0e10cSrcweir {
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
99cdf0e10cSrcweir // -----------------------------------------------------------------------
operator ==(const SfxPoolItem & rItem) const100cdf0e10cSrcweir int CntWallpaperItem::operator==( const SfxPoolItem& rItem ) const
101cdf0e10cSrcweir {
102cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
103cdf0e10cSrcweir
104cdf0e10cSrcweir const CntWallpaperItem& rWallItem = (const CntWallpaperItem&)rItem;
105cdf0e10cSrcweir
106cdf0e10cSrcweir if( ( rWallItem._nStyle == _nStyle ) &&
107cdf0e10cSrcweir ( rWallItem._nColor == _nColor ) &&
108cdf0e10cSrcweir ( rWallItem._aURL == _aURL ) )
109cdf0e10cSrcweir return sal_True;
110cdf0e10cSrcweir else
111cdf0e10cSrcweir return sal_False;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
114cdf0e10cSrcweir //============================================================================
115cdf0e10cSrcweir // virtual
GetVersion(sal_uInt16) const116cdf0e10cSrcweir sal_uInt16 CntWallpaperItem::GetVersion(sal_uInt16) const
117cdf0e10cSrcweir {
118cdf0e10cSrcweir return 1; // because it uses SfxPoolItem::read/writeUnicodeString()
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
121cdf0e10cSrcweir // -----------------------------------------------------------------------
Create(SvStream & rStream,sal_uInt16 nVersion) const122cdf0e10cSrcweir SfxPoolItem* CntWallpaperItem::Create( SvStream& rStream, sal_uInt16 nVersion) const
123cdf0e10cSrcweir {
124cdf0e10cSrcweir return new CntWallpaperItem( Which(), rStream, nVersion );
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
127cdf0e10cSrcweir // -----------------------------------------------------------------------
Store(SvStream & rStream,sal_uInt16) const128cdf0e10cSrcweir SvStream& CntWallpaperItem::Store( SvStream& rStream, sal_uInt16 ) const
129cdf0e10cSrcweir {
130cdf0e10cSrcweir rStream << CNTWALLPAPERITEM_STREAM_MAGIC;
131cdf0e10cSrcweir writeUnicodeString(rStream, _aURL);
132cdf0e10cSrcweir // !!! Color stream operators do not work - they discard any
133cdf0e10cSrcweir // transparency info !!!
134cdf0e10cSrcweir // ??? Why the hell Color::Write(...) isn't const ???
135cdf0e10cSrcweir SAL_CONST_CAST( CntWallpaperItem*, this )->_nColor.Write( rStream, sal_True );
136cdf0e10cSrcweir rStream << _nStyle;
137cdf0e10cSrcweir
138cdf0e10cSrcweir return rStream;
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
141cdf0e10cSrcweir // -----------------------------------------------------------------------
Clone(SfxItemPool *) const142cdf0e10cSrcweir SfxPoolItem* CntWallpaperItem::Clone( SfxItemPool* ) const
143cdf0e10cSrcweir {
144cdf0e10cSrcweir return new CntWallpaperItem( *this );
145cdf0e10cSrcweir }
146cdf0e10cSrcweir
147cdf0e10cSrcweir //----------------------------------------------------------------------------
148cdf0e10cSrcweir // virtual
QueryValue(com::sun::star::uno::Any &,sal_uInt8) const149cdf0e10cSrcweir sal_Bool CntWallpaperItem::QueryValue( com::sun::star::uno::Any&,sal_uInt8 ) const
150cdf0e10cSrcweir {
151cdf0e10cSrcweir DBG_ERROR("Not implemented!");
152cdf0e10cSrcweir return sal_False;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir
155cdf0e10cSrcweir //----------------------------------------------------------------------------
156cdf0e10cSrcweir // virtual
PutValue(const com::sun::star::uno::Any &,sal_uInt8)157cdf0e10cSrcweir sal_Bool CntWallpaperItem::PutValue( const com::sun::star::uno::Any&,sal_uInt8 )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir DBG_ERROR("Not implemented!");
160cdf0e10cSrcweir return sal_False;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir
164