fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svx / source / xoutdev / xexch.cxx
bloba0c1783c50da80d3b9f4dee25cf54ec7c5b3fca5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sot/formats.hxx>
21 #include <tools/vcompat.hxx>
22 #include <svx/xflasit.hxx>
23 #include <svx/xfillit0.hxx>
24 #include <svl/itempool.hxx>
25 #include <svl/whiter.hxx>
26 #include <svl/itemset.hxx>
27 #include <svx/xdef.hxx>
28 #include "svx/xexch.hxx"
31 TYPEINIT1_AUTOFACTORY( XFillExchangeData, SvDataCopyStream );
34 /*************************************************************************
36 |* Default-Ctor (Fuer Assign())
38 *************************************************************************/
39 XFillExchangeData::XFillExchangeData() :
40 pXFillAttrSetItem( NULL ),
41 pPool( NULL )
46 /*************************************************************************
48 |* Ctor
50 *************************************************************************/
51 XFillExchangeData::XFillExchangeData( const XFillAttrSetItem rXFillAttrSetItem ) :
52 pXFillAttrSetItem( (XFillAttrSetItem*) rXFillAttrSetItem.Clone( rXFillAttrSetItem.GetItemSet().GetPool() ) ),
53 pPool( rXFillAttrSetItem.GetItemSet().GetPool() )
58 /*************************************************************************
60 |* Dtor
62 *************************************************************************/
63 XFillExchangeData::~XFillExchangeData()
65 delete pXFillAttrSetItem;
68 /******************************************************************************
70 |* Binaer-Export (z.Z. ohne Versionsverwaltung, da nicht persistent!)
72 \******************************************************************************/
74 SvStream& operator<<( SvStream& rOStm, const XFillExchangeData& rData )
76 if( rData.pXFillAttrSetItem )
78 SfxWhichIter aIter( rData.pXFillAttrSetItem->GetItemSet() );
79 sal_uInt16 nWhich = aIter.FirstWhich();
80 const SfxPoolItem* pItem;
81 sal_uInt32 nItemCount = 0;
82 sal_Size nFirstPos = rOStm.Tell();
84 rOStm << nItemCount;
86 while( nWhich )
88 if( SFX_ITEM_SET == rData.pXFillAttrSetItem->GetItemSet().GetItemState( nWhich, sal_False, &pItem ) )
90 VersionCompat aCompat( rOStm, STREAM_WRITE );
91 const sal_uInt16 nItemVersion2 = pItem->GetVersion( (sal_uInt16) rOStm.GetVersion() );
93 rOStm << nWhich << nItemVersion2;
94 pItem->Store( rOStm, nItemVersion2 );
96 nItemCount++;
99 nWhich = aIter.NextWhich();
102 const sal_uIntPtr nLastPos = rOStm.Tell();
103 rOStm.Seek( nFirstPos );
104 rOStm << nItemCount;
105 rOStm.Seek( nLastPos );
108 return rOStm;
112 /******************************************************************************
114 |* Binaer-Import (z.Z. ohne Versionsverwaltung, da nicht persistent!)
116 \******************************************************************************/
118 SvStream& operator>>( SvStream& rIStm, XFillExchangeData& rData )
120 DBG_ASSERT( rData.pPool, "XFillExchangeData has no pool" );
122 SfxItemSet* pSet = new SfxItemSet ( *rData.pPool, XATTR_FILL_FIRST, XATTR_FILL_LAST );
123 SfxPoolItem* pNewItem;
124 sal_uInt32 nItemCount = 0;
125 sal_uInt16 nWhich, nItemVersion;
127 rIStm >> nItemCount;
129 if( nItemCount > ( XATTR_FILL_LAST - XATTR_FILL_FIRST + 1 ) )
130 nItemCount = ( XATTR_FILL_LAST - XATTR_FILL_FIRST + 1 );
132 for( sal_uInt32 i = 0; i < nItemCount; i++ )
134 VersionCompat aCompat( rIStm, STREAM_READ );
136 rIStm >> nWhich >> nItemVersion;
138 if( nWhich )
140 pNewItem = rData.pPool->GetDefaultItem( nWhich ).Create( rIStm, nItemVersion );
142 if( pNewItem )
144 pSet->Put( *pNewItem );
145 delete pNewItem;
150 delete rData.pXFillAttrSetItem;
151 rData.pXFillAttrSetItem = new XFillAttrSetItem( pSet );
152 rData.pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool();
154 return rIStm;
157 /*************************************************************************
159 |* XBitmap& XBitmap::operator=( const XBitmap& rXBmp )
161 *************************************************************************/
163 XFillExchangeData& XFillExchangeData::operator=( const XFillExchangeData& rData )
165 delete pXFillAttrSetItem;
167 if( rData.pXFillAttrSetItem )
168 pXFillAttrSetItem = (XFillAttrSetItem*) rData.pXFillAttrSetItem->Clone( pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool() );
169 else
171 pPool = NULL;
172 pXFillAttrSetItem = NULL;
175 return( *this );
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */