Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <sot/formats.hxx>
30 : : #include <tools/vcompat.hxx>
31 : : #include <svx/xflasit.hxx>
32 : : #include <svx/xfillit0.hxx>
33 : : #include <svl/itempool.hxx>
34 : : #include <svl/whiter.hxx>
35 : : #include <svl/itemset.hxx>
36 : : #include <svx/xdef.hxx>
37 : : #include "svx/xexch.hxx"
38 : :
39 : :
40 [ # # ][ # # ]: 0 : TYPEINIT1_AUTOFACTORY( XFillExchangeData, SvDataCopyStream );
[ # # ]
41 : :
42 : :
43 : : /*************************************************************************
44 : : |*
45 : : |* Default-Ctor (Fuer Assign())
46 : : |*
47 : : *************************************************************************/
48 : 0 : XFillExchangeData::XFillExchangeData() :
49 : : pXFillAttrSetItem( NULL ),
50 : 0 : pPool( NULL )
51 : : {
52 : 0 : }
53 : :
54 : :
55 : : /*************************************************************************
56 : : |*
57 : : |* Ctor
58 : : |*
59 : : *************************************************************************/
60 : 0 : XFillExchangeData::XFillExchangeData( const XFillAttrSetItem rXFillAttrSetItem ) :
61 : 0 : pXFillAttrSetItem( (XFillAttrSetItem*) rXFillAttrSetItem.Clone( rXFillAttrSetItem.GetItemSet().GetPool() ) ),
62 : 0 : pPool( rXFillAttrSetItem.GetItemSet().GetPool() )
63 : : {
64 : 0 : }
65 : :
66 : :
67 : : /*************************************************************************
68 : : |*
69 : : |* Dtor
70 : : |*
71 : : *************************************************************************/
72 : 0 : XFillExchangeData::~XFillExchangeData()
73 : : {
74 [ # # ]: 0 : delete pXFillAttrSetItem;
75 [ # # ]: 0 : }
76 : :
77 : : /******************************************************************************
78 : : |*
79 : : |* Binaer-Export (z.Z. ohne Versionsverwaltung, da nicht persistent!)
80 : : |*
81 : : \******************************************************************************/
82 : :
83 : 0 : SvStream& operator<<( SvStream& rOStm, const XFillExchangeData& rData )
84 : : {
85 [ # # ]: 0 : if( rData.pXFillAttrSetItem )
86 : : {
87 [ # # ]: 0 : SfxWhichIter aIter( rData.pXFillAttrSetItem->GetItemSet() );
88 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
89 : : const SfxPoolItem* pItem;
90 : 0 : sal_uInt32 nItemCount = 0;
91 : 0 : sal_Size nFirstPos = rOStm.Tell();
92 : :
93 [ # # ]: 0 : rOStm << nItemCount;
94 : :
95 [ # # ]: 0 : while( nWhich )
96 : : {
97 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET == rData.pXFillAttrSetItem->GetItemSet().GetItemState( nWhich, sal_False, &pItem ) )
98 : : {
99 [ # # ]: 0 : VersionCompat aCompat( rOStm, STREAM_WRITE );
100 [ # # ]: 0 : const sal_uInt16 nItemVersion2 = pItem->GetVersion( (sal_uInt16) rOStm.GetVersion() );
101 : :
102 [ # # ][ # # ]: 0 : rOStm << nWhich << nItemVersion2;
103 [ # # ]: 0 : pItem->Store( rOStm, nItemVersion2 );
104 : :
105 [ # # ]: 0 : nItemCount++;
106 : : }
107 : :
108 [ # # ]: 0 : nWhich = aIter.NextWhich();
109 : : }
110 : :
111 : 0 : const sal_uIntPtr nLastPos = rOStm.Tell();
112 [ # # ]: 0 : rOStm.Seek( nFirstPos );
113 [ # # ]: 0 : rOStm << nItemCount;
114 [ # # ][ # # ]: 0 : rOStm.Seek( nLastPos );
115 : : }
116 : :
117 : 0 : return rOStm;
118 : : }
119 : :
120 : :
121 : : /******************************************************************************
122 : : |*
123 : : |* Binaer-Import (z.Z. ohne Versionsverwaltung, da nicht persistent!)
124 : : |*
125 : : \******************************************************************************/
126 : :
127 : 0 : SvStream& operator>>( SvStream& rIStm, XFillExchangeData& rData )
128 : : {
129 : : DBG_ASSERT( rData.pPool, "XFillExchangeData has no pool" );
130 : :
131 [ # # ][ # # ]: 0 : SfxItemSet* pSet = new SfxItemSet ( *rData.pPool, XATTR_FILL_FIRST, XATTR_FILL_LAST );
132 : : SfxPoolItem* pNewItem;
133 : 0 : sal_uInt32 nItemCount = 0;
134 : : sal_uInt16 nWhich, nItemVersion;
135 : :
136 [ # # ]: 0 : rIStm >> nItemCount;
137 : :
138 [ # # ]: 0 : if( nItemCount > ( XATTR_FILL_LAST - XATTR_FILL_FIRST + 1 ) )
139 : 0 : nItemCount = ( XATTR_FILL_LAST - XATTR_FILL_FIRST + 1 );
140 : :
141 [ # # ]: 0 : for( sal_uInt32 i = 0; i < nItemCount; i++ )
142 : : {
143 [ # # ]: 0 : VersionCompat aCompat( rIStm, STREAM_READ );
144 : :
145 [ # # ][ # # ]: 0 : rIStm >> nWhich >> nItemVersion;
146 : :
147 [ # # ]: 0 : if( nWhich )
148 : : {
149 [ # # ][ # # ]: 0 : pNewItem = rData.pPool->GetDefaultItem( nWhich ).Create( rIStm, nItemVersion );
150 : :
151 [ # # ]: 0 : if( pNewItem )
152 : : {
153 [ # # ]: 0 : pSet->Put( *pNewItem );
154 [ # # ][ # # ]: 0 : delete pNewItem;
155 : : }
156 : : }
157 [ # # ]: 0 : }
158 : :
159 [ # # ][ # # ]: 0 : delete rData.pXFillAttrSetItem;
160 [ # # ][ # # ]: 0 : rData.pXFillAttrSetItem = new XFillAttrSetItem( pSet );
161 : 0 : rData.pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool();
162 : :
163 : 0 : return rIStm;
164 : : }
165 : :
166 : : /*************************************************************************
167 : : |*
168 : : |* XBitmap& XBitmap::operator=( const XBitmap& rXBmp )
169 : : |*
170 : : *************************************************************************/
171 : :
172 : 0 : XFillExchangeData& XFillExchangeData::operator=( const XFillExchangeData& rData )
173 : : {
174 [ # # ]: 0 : delete pXFillAttrSetItem;
175 : :
176 [ # # ]: 0 : if( rData.pXFillAttrSetItem )
177 : 0 : pXFillAttrSetItem = (XFillAttrSetItem*) rData.pXFillAttrSetItem->Clone( pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool() );
178 : : else
179 : : {
180 : 0 : pPool = NULL;
181 : 0 : pXFillAttrSetItem = NULL;
182 : : }
183 : :
184 : 0 : return( *this );
185 : : }
186 : :
187 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|