1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <tools/debug.hxx>
22 #include <tools/stream.hxx>
23 #include <tools/vcompat.hxx>
25 #include <svl/cntwall.hxx>
27 #define CNTWALLPAPERITEM_STREAM_MAGIC ( (sal_uInt32)0xfefefefe )
28 #define CNTWALLPAPERITEM_STREAM_SEEKREL (-( (long)( sizeof( sal_uInt32 ) ) ) )
30 TYPEINIT1( CntWallpaperItem
, SfxPoolItem
);
32 // -----------------------------------------------------------------------
33 CntWallpaperItem::CntWallpaperItem( sal_uInt16 which
)
34 : SfxPoolItem( which
), _nColor( COL_TRANSPARENT
), _nStyle( 0 )
38 // -----------------------------------------------------------------------
39 CntWallpaperItem::CntWallpaperItem( sal_uInt16 which
, SvStream
& rStream
, sal_uInt16 nVersion
)
40 : SfxPoolItem( which
), _nColor( COL_TRANSPARENT
), _nStyle( 0 )
42 sal_uInt32 nMagic
= 0;
44 if ( nMagic
== CNTWALLPAPERITEM_STREAM_MAGIC
)
46 // Okay, data were stored by CntWallpaperItem.
48 _aURL
= readUnicodeString(rStream
, nVersion
>= 1);
49 // !!! Color stream operators do not work - they discard any
50 // transparency info !!!
51 _nColor
.Read( rStream
, sal_True
);
56 rStream
.SeekRel( CNTWALLPAPERITEM_STREAM_SEEKREL
);
58 // Data were stored by SfxWallpaperItem ( SO < 6.0 ). The only
59 // thing we can do here is to get the URL and to position the stream.
62 // "Read" Wallpaper member - The version compat object positions
63 // the stream after the wallpaper data in its dtor. We must use
64 // this trick here as no VCL must be used here ( No Wallpaper
66 VersionCompat
aCompat( rStream
, STREAM_READ
);
69 // Read SfxWallpaperItem's string member _aURL.
70 _aURL
= readUnicodeString(rStream
, false);
72 // "Read" SfxWallpaperItem's string member _aFilter.
73 read_lenPrefixed_uInt8s_ToOString
<sal_uInt16
>(rStream
);
77 // -----------------------------------------------------------------------
78 CntWallpaperItem::CntWallpaperItem( const CntWallpaperItem
& rItem
) :
81 _nColor( rItem
._nColor
),
82 _nStyle( rItem
._nStyle
)
86 // -----------------------------------------------------------------------
87 CntWallpaperItem::~CntWallpaperItem()
91 // -----------------------------------------------------------------------
92 int CntWallpaperItem::operator==( const SfxPoolItem
& rItem
) const
94 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
96 const CntWallpaperItem
& rWallItem
= (const CntWallpaperItem
&)rItem
;
98 if( ( rWallItem
._nStyle
== _nStyle
) &&
99 ( rWallItem
._nColor
== _nColor
) &&
100 ( rWallItem
._aURL
== _aURL
) )
106 //============================================================================
108 sal_uInt16
CntWallpaperItem::GetVersion(sal_uInt16
) const
110 return 1; // because it uses SfxPoolItem::read/writeUnicodeString()
113 // -----------------------------------------------------------------------
114 SfxPoolItem
* CntWallpaperItem::Create( SvStream
& rStream
, sal_uInt16 nVersion
) const
116 return new CntWallpaperItem( Which(), rStream
, nVersion
);
119 // -----------------------------------------------------------------------
120 SvStream
& CntWallpaperItem::Store( SvStream
& rStream
, sal_uInt16
) const
122 rStream
<< CNTWALLPAPERITEM_STREAM_MAGIC
;
123 writeUnicodeString(rStream
, _aURL
);
124 // !!! Color stream operators do not work - they discard any
125 // transparency info !!!
126 // ??? Why the hell Color::Write(...) isn't const ???
127 (const_cast< CntWallpaperItem
* >(this))->_nColor
.Write( rStream
, sal_True
);
133 // -----------------------------------------------------------------------
134 SfxPoolItem
* CntWallpaperItem::Clone( SfxItemPool
* ) const
136 return new CntWallpaperItem( *this );
139 //----------------------------------------------------------------------------
141 bool CntWallpaperItem::QueryValue( com::sun::star::uno::Any
&, sal_uInt8
) const
143 OSL_FAIL("Not implemented!");
147 //----------------------------------------------------------------------------
149 bool CntWallpaperItem::PutValue( const com::sun::star::uno::Any
&, sal_uInt8
)
151 OSL_FAIL("Not implemented!");
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */