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