1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cntwall.cxx,v $
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 )
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
);
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
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.
88 rStream
.ReadByteString(aDummy
);
92 // -----------------------------------------------------------------------
93 CntWallpaperItem::CntWallpaperItem( const CntWallpaperItem
& rItem
) :
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
) )
121 //============================================================================
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
);
148 // -----------------------------------------------------------------------
149 SfxPoolItem
* CntWallpaperItem::Clone( SfxItemPool
* ) const
151 return new CntWallpaperItem( *this );
154 //----------------------------------------------------------------------------
156 BOOL
CntWallpaperItem::QueryValue( com::sun::star::uno::Any
&,BYTE
) const
158 DBG_ERROR("Not implemented!");
162 //----------------------------------------------------------------------------
164 BOOL
CntWallpaperItem::PutValue( const com::sun::star::uno::Any
&,BYTE
)
166 DBG_ERROR("Not implemented!");