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 <tools/debug.hxx>
22 : #include <tools/stream.hxx>
23 : #include <tools/vcompat.hxx>
24 :
25 : #include <svl/cntwall.hxx>
26 :
27 : #define CNTWALLPAPERITEM_STREAM_MAGIC ( (sal_uInt32)0xfefefefe )
28 : #define CNTWALLPAPERITEM_STREAM_SEEKREL (-( (long)( sizeof( sal_uInt32 ) ) ) )
29 :
30 0 : TYPEINIT1( CntWallpaperItem, SfxPoolItem );
31 :
32 : // -----------------------------------------------------------------------
33 0 : CntWallpaperItem::CntWallpaperItem( sal_uInt16 which )
34 0 : : SfxPoolItem( which ), _nColor( COL_TRANSPARENT ), _nStyle( 0 )
35 : {
36 0 : }
37 :
38 : // -----------------------------------------------------------------------
39 0 : CntWallpaperItem::CntWallpaperItem( sal_uInt16 which, SvStream& rStream, sal_uInt16 nVersion )
40 0 : : SfxPoolItem( which ), _nColor( COL_TRANSPARENT ), _nStyle( 0 )
41 : {
42 0 : sal_uInt32 nMagic = 0;
43 0 : rStream >> nMagic;
44 0 : if ( nMagic == CNTWALLPAPERITEM_STREAM_MAGIC )
45 : {
46 : // Okay, data were stored by CntWallpaperItem.
47 :
48 0 : _aURL = readUnicodeString(rStream, nVersion >= 1);
49 : // !!! Color stream operators do not work - they discard any
50 : // transparency info !!!
51 0 : _nColor.Read( rStream, sal_True );
52 0 : rStream >> _nStyle;
53 : }
54 : else
55 : {
56 0 : rStream.SeekRel( CNTWALLPAPERITEM_STREAM_SEEKREL );
57 :
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.
60 :
61 : {
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
65 : // object allowed ).
66 0 : VersionCompat aCompat( rStream, STREAM_READ );
67 : }
68 :
69 : // Read SfxWallpaperItem's string member _aURL.
70 0 : _aURL = readUnicodeString(rStream, false);
71 :
72 : // "Read" SfxWallpaperItem's string member _aFilter.
73 0 : read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rStream);
74 : }
75 0 : }
76 :
77 : // -----------------------------------------------------------------------
78 0 : CntWallpaperItem::CntWallpaperItem( const CntWallpaperItem& rItem ) :
79 : SfxPoolItem( rItem ),
80 : _aURL( rItem._aURL ),
81 : _nColor( rItem._nColor ),
82 0 : _nStyle( rItem._nStyle )
83 : {
84 0 : }
85 :
86 : // -----------------------------------------------------------------------
87 0 : CntWallpaperItem::~CntWallpaperItem()
88 : {
89 0 : }
90 :
91 : // -----------------------------------------------------------------------
92 0 : int CntWallpaperItem::operator==( const SfxPoolItem& rItem ) const
93 : {
94 : DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
95 :
96 0 : const CntWallpaperItem& rWallItem = (const CntWallpaperItem&)rItem;
97 :
98 0 : if( ( rWallItem._nStyle == _nStyle ) &&
99 0 : ( rWallItem._nColor == _nColor ) &&
100 0 : ( rWallItem._aURL == _aURL ) )
101 0 : return sal_True;
102 : else
103 0 : return sal_False;
104 : }
105 :
106 : //============================================================================
107 : // virtual
108 0 : sal_uInt16 CntWallpaperItem::GetVersion(sal_uInt16) const
109 : {
110 0 : return 1; // because it uses SfxPoolItem::read/writeUnicodeString()
111 : }
112 :
113 : // -----------------------------------------------------------------------
114 0 : SfxPoolItem* CntWallpaperItem::Create( SvStream& rStream, sal_uInt16 nVersion) const
115 : {
116 0 : return new CntWallpaperItem( Which(), rStream, nVersion );
117 : }
118 :
119 : // -----------------------------------------------------------------------
120 0 : SvStream& CntWallpaperItem::Store( SvStream& rStream, sal_uInt16 ) const
121 : {
122 0 : rStream << CNTWALLPAPERITEM_STREAM_MAGIC;
123 0 : 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 0 : (const_cast< CntWallpaperItem* >(this))->_nColor.Write( rStream, sal_True );
128 0 : rStream << _nStyle;
129 :
130 0 : return rStream;
131 : }
132 :
133 : // -----------------------------------------------------------------------
134 0 : SfxPoolItem* CntWallpaperItem::Clone( SfxItemPool* ) const
135 : {
136 0 : return new CntWallpaperItem( *this );
137 : }
138 :
139 : //----------------------------------------------------------------------------
140 : // virtual
141 0 : bool CntWallpaperItem::QueryValue( com::sun::star::uno::Any&, sal_uInt8) const
142 : {
143 : OSL_FAIL("Not implemented!");
144 0 : return false;
145 : }
146 :
147 : //----------------------------------------------------------------------------
148 : // virtual
149 0 : bool CntWallpaperItem::PutValue( const com::sun::star::uno::Any&, sal_uInt8)
150 : {
151 : OSL_FAIL("Not implemented!");
152 0 : return false;
153 : }
154 :
155 :
156 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|