Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <osl/diagnose.h>
22 : #include <tools/debug.hxx>
23 : #include <tools/stream.hxx>
24 : #include <tools/vcompat.hxx>
25 :
26 : #include <svl/cntwall.hxx>
27 : #include <stringio.hxx>
28 :
29 : #define CNTWALLPAPERITEM_STREAM_MAGIC ( (sal_uInt32)0xfefefefe )
30 : #define CNTWALLPAPERITEM_STREAM_SEEKREL (-( (long)( sizeof( sal_uInt32 ) ) ) )
31 :
32 0 : TYPEINIT1( CntWallpaperItem, SfxPoolItem );
33 :
34 :
35 0 : CntWallpaperItem::CntWallpaperItem( sal_uInt16 which )
36 0 : : SfxPoolItem( which ), _nColor( COL_TRANSPARENT ), _nStyle( 0 )
37 : {
38 0 : }
39 :
40 :
41 0 : CntWallpaperItem::CntWallpaperItem( sal_uInt16 which, SvStream& rStream, sal_uInt16 nVersion )
42 0 : : SfxPoolItem( which ), _nColor( COL_TRANSPARENT ), _nStyle( 0 )
43 : {
44 0 : sal_uInt32 nMagic = 0;
45 0 : rStream.ReadUInt32( nMagic );
46 0 : if ( nMagic == CNTWALLPAPERITEM_STREAM_MAGIC )
47 : {
48 : // Okay, data were stored by CntWallpaperItem.
49 :
50 0 : _aURL = readUnicodeString(rStream, nVersion >= 1);
51 : // !!! Color stream operators do not work - they discard any
52 : // transparency info !!!
53 0 : _nColor.Read( rStream, true );
54 0 : rStream.ReadUInt16( _nStyle );
55 : }
56 : else
57 : {
58 0 : rStream.SeekRel( CNTWALLPAPERITEM_STREAM_SEEKREL );
59 :
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.
62 :
63 : {
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
67 : // object allowed ).
68 0 : VersionCompat aCompat( rStream, StreamMode::READ );
69 : }
70 :
71 : // Read SfxWallpaperItem's string member _aURL.
72 0 : _aURL = readUnicodeString(rStream, false);
73 :
74 : // "Read" SfxWallpaperItem's string member _aFilter.
75 0 : read_uInt16_lenPrefixed_uInt8s_ToOString(rStream);
76 : }
77 0 : }
78 :
79 :
80 0 : CntWallpaperItem::CntWallpaperItem( const CntWallpaperItem& rItem ) :
81 : SfxPoolItem( rItem ),
82 : _aURL( rItem._aURL ),
83 : _nColor( rItem._nColor ),
84 0 : _nStyle( rItem._nStyle )
85 : {
86 0 : }
87 :
88 :
89 0 : CntWallpaperItem::~CntWallpaperItem()
90 : {
91 0 : }
92 :
93 :
94 0 : bool CntWallpaperItem::operator==( const SfxPoolItem& rItem ) const
95 : {
96 : DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
97 :
98 0 : const CntWallpaperItem& rWallItem = static_cast<const CntWallpaperItem&>(rItem);
99 :
100 0 : return ( rWallItem._nStyle == _nStyle ) &&
101 0 : ( rWallItem._nColor == _nColor ) &&
102 0 : ( rWallItem._aURL == _aURL );
103 : }
104 :
105 : // virtual
106 0 : sal_uInt16 CntWallpaperItem::GetVersion(sal_uInt16) const
107 : {
108 0 : return 1; // because it uses SfxPoolItem::read/writeUnicodeString()
109 : }
110 :
111 :
112 0 : SfxPoolItem* CntWallpaperItem::Create( SvStream& rStream, sal_uInt16 nVersion) const
113 : {
114 0 : return new CntWallpaperItem( Which(), rStream, nVersion );
115 : }
116 :
117 :
118 0 : SvStream& CntWallpaperItem::Store( SvStream& rStream, sal_uInt16 ) const
119 : {
120 0 : rStream.WriteUInt32( CNTWALLPAPERITEM_STREAM_MAGIC );
121 0 : 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 0 : (const_cast< CntWallpaperItem* >(this))->_nColor.Write( rStream, true );
126 0 : rStream.WriteUInt16( _nStyle );
127 :
128 0 : return rStream;
129 : }
130 :
131 :
132 0 : SfxPoolItem* CntWallpaperItem::Clone( SfxItemPool* ) const
133 : {
134 0 : return new CntWallpaperItem( *this );
135 : }
136 :
137 : // virtual
138 0 : bool CntWallpaperItem::QueryValue( com::sun::star::uno::Any&, sal_uInt8) const
139 : {
140 : OSL_FAIL("Not implemented!");
141 0 : return false;
142 : }
143 :
144 : // virtual
145 0 : bool CntWallpaperItem::PutValue( const com::sun::star::uno::Any&, sal_uInt8)
146 : {
147 : OSL_FAIL("Not implemented!");
148 0 : return false;
149 : }
150 :
151 :
152 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|