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 <osl/diagnose.h>
22 #include <tools/debug.hxx>
23 #include <tools/stream.hxx>
24 #include <tools/vcompat.hxx>
26 #include <svl/cntwall.hxx>
27 #include <stringio.hxx>
29 #define CNTWALLPAPERITEM_STREAM_MAGIC ( (sal_uInt32)0xfefefefe )
30 #define CNTWALLPAPERITEM_STREAM_SEEKREL (-( (long)( sizeof( sal_uInt32 ) ) ) )
32 TYPEINIT1( CntWallpaperItem
, SfxPoolItem
);
35 CntWallpaperItem::CntWallpaperItem( sal_uInt16 which
)
36 : SfxPoolItem( which
), _nColor( COL_TRANSPARENT
), _nStyle( 0 )
41 CntWallpaperItem::CntWallpaperItem( sal_uInt16 which
, SvStream
& rStream
, sal_uInt16 nVersion
)
42 : SfxPoolItem( which
), _nColor( COL_TRANSPARENT
), _nStyle( 0 )
44 sal_uInt32 nMagic
= 0;
45 rStream
.ReadUInt32( nMagic
);
46 if ( nMagic
== CNTWALLPAPERITEM_STREAM_MAGIC
)
48 // Okay, data were stored by CntWallpaperItem.
50 _aURL
= readUnicodeString(rStream
, nVersion
>= 1);
51 // !!! Color stream operators do not work - they discard any
52 // transparency info !!!
53 _nColor
.Read( rStream
, true );
54 rStream
.ReadUInt16( _nStyle
);
58 rStream
.SeekRel( CNTWALLPAPERITEM_STREAM_SEEKREL
);
60 // Data were stored by SfxWallpaperItem ( SO < 6.0 ). The only
61 // thing we can do here is to get the URL and to position the stream.
64 // "Read" Wallpaper member - The version compat object positions
65 // the stream after the wallpaper data in its dtor. We must use
66 // this trick here as no VCL must be used here ( No Wallpaper
68 VersionCompat
aCompat( rStream
, StreamMode::READ
);
71 // Read SfxWallpaperItem's string member _aURL.
72 _aURL
= readUnicodeString(rStream
, false);
74 // "Read" SfxWallpaperItem's string member _aFilter.
75 read_uInt16_lenPrefixed_uInt8s_ToOString(rStream
);
80 CntWallpaperItem::CntWallpaperItem( const CntWallpaperItem
& rItem
) :
83 _nColor( rItem
._nColor
),
84 _nStyle( rItem
._nStyle
)
89 CntWallpaperItem::~CntWallpaperItem()
94 bool CntWallpaperItem::operator==( const SfxPoolItem
& rItem
) const
96 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
98 const CntWallpaperItem
& rWallItem
= static_cast<const CntWallpaperItem
&>(rItem
);
100 return ( rWallItem
._nStyle
== _nStyle
) &&
101 ( rWallItem
._nColor
== _nColor
) &&
102 ( rWallItem
._aURL
== _aURL
);
106 sal_uInt16
CntWallpaperItem::GetVersion(sal_uInt16
) const
108 return 1; // because it uses SfxPoolItem::read/writeUnicodeString()
112 SfxPoolItem
* CntWallpaperItem::Create( SvStream
& rStream
, sal_uInt16 nVersion
) const
114 return new CntWallpaperItem( Which(), rStream
, nVersion
);
118 SvStream
& CntWallpaperItem::Store( SvStream
& rStream
, sal_uInt16
) const
120 rStream
.WriteUInt32( CNTWALLPAPERITEM_STREAM_MAGIC
);
121 writeUnicodeString(rStream
, _aURL
);
122 // !!! Color stream operators do not work - they discard any
123 // transparency info !!!
124 // ??? Why the hell Color::Write(...) isn't const ???
125 (const_cast< CntWallpaperItem
* >(this))->_nColor
.Write( rStream
, true );
126 rStream
.WriteUInt16( _nStyle
);
132 SfxPoolItem
* CntWallpaperItem::Clone( SfxItemPool
* ) const
134 return new CntWallpaperItem( *this );
138 bool CntWallpaperItem::QueryValue( com::sun::star::uno::Any
&, sal_uInt8
) const
140 OSL_FAIL("Not implemented!");
145 bool CntWallpaperItem::PutValue( const com::sun::star::uno::Any
&, sal_uInt8
)
147 OSL_FAIL("Not implemented!");
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */