Update ooo320-m1
[ooovba.git] / svtools / source / items1 / cntwall.cxx
blob5a0a8412853c633e18cec6db4afcf899c1cdd47f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cntwall.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #include <tools/debug.hxx>
35 #include <tools/string.hxx>
36 #include <tools/stream.hxx>
37 #include <tools/vcompat.hxx>
39 #include <svtools/cntwall.hxx>
41 #define CNTWALLPAPERITEM_STREAM_MAGIC ( (UINT32)0xfefefefe )
42 #define CNTWALLPAPERITEM_STREAM_SEEKREL (-( (long)( sizeof( UINT32 ) ) ) )
44 TYPEINIT1( CntWallpaperItem, SfxPoolItem );
46 // -----------------------------------------------------------------------
47 CntWallpaperItem::CntWallpaperItem( USHORT which )
48 : SfxPoolItem( which ), _nColor( COL_TRANSPARENT ), _nStyle( 0 )
52 // -----------------------------------------------------------------------
53 CntWallpaperItem::CntWallpaperItem( USHORT which, SvStream& rStream, USHORT nVersion )
54 : SfxPoolItem( which ), _nColor( COL_TRANSPARENT ), _nStyle( 0 )
56 UINT32 nMagic = 0;
57 rStream >> nMagic;
58 if ( nMagic == CNTWALLPAPERITEM_STREAM_MAGIC )
60 // Okay, data were stored by CntWallpaperItem.
62 readUnicodeString(rStream, _aURL, nVersion >= 1);
63 // !!! Color stream operators do not work - they discard any
64 // transparency info !!!
65 _nColor.Read( rStream, TRUE );
66 rStream >> _nStyle;
68 else
70 rStream.SeekRel( CNTWALLPAPERITEM_STREAM_SEEKREL );
72 // Data were stored by SfxWallpaperItem ( SO < 6.0 ). The only
73 // thing we can do here is to get the URL and to position the stream.
76 // "Read" Wallpaper member - The version compat object positions
77 // the stream after the wallpaper data in its dtor. We must use
78 // this trick here as no VCL must be used here ( No Wallpaper
79 // object allowed ).
80 VersionCompat aCompat( rStream, STREAM_READ );
83 // Read SfxWallpaperItem's string member _aURL.
84 readUnicodeString(rStream, _aURL, false);
86 // "Read" SfxWallpaperItem's string member _aFilter.
87 ByteString aDummy;
88 rStream.ReadByteString(aDummy);
92 // -----------------------------------------------------------------------
93 CntWallpaperItem::CntWallpaperItem( const CntWallpaperItem& rItem ) :
94 SfxPoolItem( rItem ),
95 _aURL( rItem._aURL ),
96 _nColor( rItem._nColor ),
97 _nStyle( rItem._nStyle )
101 // -----------------------------------------------------------------------
102 CntWallpaperItem::~CntWallpaperItem()
106 // -----------------------------------------------------------------------
107 int CntWallpaperItem::operator==( const SfxPoolItem& rItem ) const
109 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
111 const CntWallpaperItem& rWallItem = (const CntWallpaperItem&)rItem;
113 if( ( rWallItem._nStyle == _nStyle ) &&
114 ( rWallItem._nColor == _nColor ) &&
115 ( rWallItem._aURL == _aURL ) )
116 return TRUE;
117 else
118 return FALSE;
121 //============================================================================
122 // virtual
123 USHORT CntWallpaperItem::GetVersion(USHORT) const
125 return 1; // because it uses SfxPoolItem::read/writeUnicodeString()
128 // -----------------------------------------------------------------------
129 SfxPoolItem* CntWallpaperItem::Create( SvStream& rStream, USHORT nVersion) const
131 return new CntWallpaperItem( Which(), rStream, nVersion );
134 // -----------------------------------------------------------------------
135 SvStream& CntWallpaperItem::Store( SvStream& rStream, USHORT ) const
137 rStream << CNTWALLPAPERITEM_STREAM_MAGIC;
138 writeUnicodeString(rStream, _aURL);
139 // !!! Color stream operators do not work - they discard any
140 // transparency info !!!
141 // ??? Why the hell Color::Write(...) isn't const ???
142 SAL_CONST_CAST( CntWallpaperItem*, this )->_nColor.Write( rStream, TRUE );
143 rStream << _nStyle;
145 return rStream;
148 // -----------------------------------------------------------------------
149 SfxPoolItem* CntWallpaperItem::Clone( SfxItemPool* ) const
151 return new CntWallpaperItem( *this );
154 //----------------------------------------------------------------------------
155 // virtual
156 BOOL CntWallpaperItem::QueryValue( com::sun::star::uno::Any&,BYTE ) const
158 DBG_ERROR("Not implemented!");
159 return FALSE;
162 //----------------------------------------------------------------------------
163 // virtual
164 BOOL CntWallpaperItem::PutValue( const com::sun::star::uno::Any&,BYTE )
166 DBG_ERROR("Not implemented!");
167 return FALSE;