1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xexch.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
36 #include <sot/formats.hxx>
37 #include <tools/vcompat.hxx>
38 #include <svx/xflasit.hxx>
39 #include <svx/xfillit0.hxx>
41 #include <svtools/itempool.hxx>
43 #include <svtools/whiter.hxx>
45 #include <svtools/itempool.hxx>
47 #include <svtools/itemset.hxx>
48 #include <svx/xdef.hxx>
52 TYPEINIT1_AUTOFACTORY( XFillExchangeData
, SvDataCopyStream
);
55 /*************************************************************************
57 |* Default-Ctor (Fuer Assign())
59 *************************************************************************/
60 XFillExchangeData::XFillExchangeData() :
61 pXFillAttrSetItem( NULL
),
67 /*************************************************************************
71 *************************************************************************/
72 XFillExchangeData::XFillExchangeData( const XFillAttrSetItem rXFillAttrSetItem
) :
73 pXFillAttrSetItem( (XFillAttrSetItem
*) rXFillAttrSetItem
.Clone( rXFillAttrSetItem
.GetItemSet().GetPool() ) ),
74 pPool( rXFillAttrSetItem
.GetItemSet().GetPool() )
79 /*************************************************************************
83 *************************************************************************/
84 XFillExchangeData::~XFillExchangeData()
86 delete pXFillAttrSetItem
;
89 /*************************************************************************
93 *************************************************************************/
94 ULONG
XFillExchangeData::RegisterClipboardFormatName()
96 return( SOT_FORMATSTR_ID_XFA
);
99 /******************************************************************************
101 |* Binaer-Export (z.Z. ohne Versionsverwaltung, da nicht persistent!)
103 \******************************************************************************/
105 SvStream
& operator<<( SvStream
& rOStm
, const XFillExchangeData
& rData
)
107 if( rData
.pXFillAttrSetItem
)
109 SfxWhichIter
aIter( rData
.pXFillAttrSetItem
->GetItemSet() );
110 USHORT nWhich
= aIter
.FirstWhich();
111 const SfxPoolItem
* pItem
;
112 sal_uInt32 nItemCount
= 0;
113 sal_Size nFirstPos
= rOStm
.Tell();
119 if( SFX_ITEM_SET
== rData
.pXFillAttrSetItem
->GetItemSet().GetItemState( nWhich
, FALSE
, &pItem
) )
121 VersionCompat
aCompat( rOStm
, STREAM_WRITE
);
122 const USHORT nItemVersion2
= pItem
->GetVersion( (USHORT
) rOStm
.GetVersion() );
124 rOStm
<< nWhich
<< nItemVersion2
;
125 pItem
->Store( rOStm
, nItemVersion2
);
130 nWhich
= aIter
.NextWhich();
133 const ULONG nLastPos
= rOStm
.Tell();
134 rOStm
.Seek( nFirstPos
);
136 rOStm
.Seek( nLastPos
);
143 /******************************************************************************
145 |* Binaer-Import (z.Z. ohne Versionsverwaltung, da nicht persistent!)
147 \******************************************************************************/
149 SvStream
& operator>>( SvStream
& rIStm
, XFillExchangeData
& rData
)
151 DBG_ASSERT( rData
.pPool
, "XFillExchangeData has no pool" );
153 SfxItemSet
* pSet
= new SfxItemSet ( *rData
.pPool
, XATTR_FILL_FIRST
, XATTR_FILL_LAST
);
154 SfxPoolItem
* pNewItem
;
155 sal_uInt32 nItemCount
= 0;
156 USHORT nWhich
, nItemVersion
;
160 if( nItemCount
> ( XATTR_FILL_LAST
- XATTR_FILL_FIRST
+ 1 ) )
161 nItemCount
= ( XATTR_FILL_LAST
- XATTR_FILL_FIRST
+ 1 );
163 for( sal_uInt32 i
= 0; i
< nItemCount
; i
++ )
165 VersionCompat
aCompat( rIStm
, STREAM_READ
);
167 rIStm
>> nWhich
>> nItemVersion
;
171 pNewItem
= rData
.pPool
->GetDefaultItem( nWhich
).Create( rIStm
, nItemVersion
);
175 pSet
->Put( *pNewItem
);
181 delete rData
.pXFillAttrSetItem
;
182 rData
.pXFillAttrSetItem
= new XFillAttrSetItem( pSet
);
183 rData
.pPool
= rData
.pXFillAttrSetItem
->GetItemSet().GetPool();
188 /*************************************************************************
190 |* XBitmap& XBitmap::operator=( const XBitmap& rXBmp )
192 *************************************************************************/
194 XFillExchangeData
& XFillExchangeData::operator=( const XFillExchangeData
& rData
)
196 delete pXFillAttrSetItem
;
198 if( rData
.pXFillAttrSetItem
)
199 pXFillAttrSetItem
= (XFillAttrSetItem
*) rData
.pXFillAttrSetItem
->Clone( pPool
= rData
.pXFillAttrSetItem
->GetItemSet().GetPool() );
203 pXFillAttrSetItem
= NULL
;