LCOV - code coverage report
Current view: top level - svx/source/xoutdev - xexch.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 57 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          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             : #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"
      29             : #include <boost/scoped_ptr.hpp>
      30             : 
      31             : 
      32           0 : TYPEINIT1_AUTOFACTORY( XFillExchangeData, SvDataCopyStream );
      33             : 
      34             : /// default CTOR, for Assign()
      35           0 : XFillExchangeData::XFillExchangeData() :
      36             :     pXFillAttrSetItem( NULL ),
      37           0 :     pPool( NULL )
      38             : {
      39           0 : }
      40             : 
      41           0 : XFillExchangeData::XFillExchangeData( const XFillAttrSetItem& rXFillAttrSetItem ) :
      42           0 :     pXFillAttrSetItem( static_cast<XFillAttrSetItem*>( rXFillAttrSetItem.Clone( rXFillAttrSetItem.GetItemSet().GetPool() ) ) ),
      43           0 :     pPool( rXFillAttrSetItem.GetItemSet().GetPool() )
      44             : {
      45           0 : }
      46             : 
      47           0 : XFillExchangeData::~XFillExchangeData()
      48             : {
      49           0 :     delete pXFillAttrSetItem;
      50           0 : }
      51             : 
      52             : /// binary export (currently w/o version control because it is not persistent)
      53           0 : SvStream& WriteXFillExchangeData( SvStream& rOStm, const XFillExchangeData& rData )
      54             : {
      55           0 :     if( rData.pXFillAttrSetItem )
      56             :     {
      57           0 :         SfxWhichIter        aIter( rData.pXFillAttrSetItem->GetItemSet() );
      58           0 :         sal_uInt16              nWhich = aIter.FirstWhich();
      59             :         const SfxPoolItem*  pItem;
      60           0 :         sal_uInt32          nItemCount = 0;
      61           0 :         sal_Size            nFirstPos = rOStm.Tell();
      62             : 
      63           0 :         rOStm.WriteUInt32( nItemCount );
      64             : 
      65           0 :         while( nWhich )
      66             :         {
      67           0 :             if( SfxItemState::SET == rData.pXFillAttrSetItem->GetItemSet().GetItemState( nWhich, false, &pItem ) )
      68             :             {
      69           0 :                 VersionCompat   aCompat( rOStm, StreamMode::WRITE );
      70           0 :                 const sal_uInt16    nItemVersion2 = pItem->GetVersion( (sal_uInt16) rOStm.GetVersion() );
      71             : 
      72           0 :                 rOStm.WriteUInt16( nWhich ).WriteUInt16( nItemVersion2 );
      73           0 :                 pItem->Store( rOStm, nItemVersion2 );
      74             : 
      75           0 :                 nItemCount++;
      76             :             }
      77             : 
      78           0 :             nWhich = aIter.NextWhich();
      79             :         }
      80             : 
      81           0 :         const sal_uIntPtr nLastPos = rOStm.Tell();
      82           0 :         rOStm.Seek( nFirstPos );
      83           0 :         rOStm.WriteUInt32( nItemCount );
      84           0 :         rOStm.Seek( nLastPos );
      85             :     }
      86             : 
      87           0 :     return rOStm;
      88             : }
      89             : 
      90             : /// binary export (currently w/o version control because it is not persistent)
      91           0 : SvStream& ReadXFillExchangeData( SvStream& rIStm, XFillExchangeData& rData )
      92             : {
      93             :     DBG_ASSERT( rData.pPool, "XFillExchangeData has no pool" );
      94             : 
      95           0 :     SfxItemSet*     pSet = new SfxItemSet ( *rData.pPool, XATTR_FILL_FIRST, XATTR_FILL_LAST );
      96           0 :     sal_uInt32      nItemCount = 0;
      97             :     sal_uInt16          nWhich, nItemVersion;
      98             : 
      99           0 :     rIStm.ReadUInt32( nItemCount );
     100             : 
     101           0 :     if( nItemCount > ( XATTR_FILL_LAST - XATTR_FILL_FIRST + 1 ) )
     102           0 :         nItemCount = ( XATTR_FILL_LAST - XATTR_FILL_FIRST + 1 );
     103             : 
     104           0 :     for( sal_uInt32 i = 0; i < nItemCount; i++ )
     105             :     {
     106           0 :         VersionCompat aCompat( rIStm, StreamMode::READ );
     107             : 
     108           0 :         rIStm.ReadUInt16( nWhich ).ReadUInt16( nItemVersion );
     109             : 
     110           0 :         if( nWhich )
     111             :         {
     112           0 :             boost::scoped_ptr<SfxPoolItem> pNewItem(rData.pPool->GetDefaultItem( nWhich ).Create( rIStm, nItemVersion ));
     113             : 
     114           0 :             if( pNewItem )
     115             :             {
     116           0 :                 pSet->Put( *pNewItem );
     117           0 :             }
     118             :         }
     119           0 :     }
     120             : 
     121           0 :     delete rData.pXFillAttrSetItem;
     122           0 :     rData.pXFillAttrSetItem = new XFillAttrSetItem( pSet );
     123           0 :     rData.pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool();
     124             : 
     125           0 :     return rIStm;
     126             : }
     127             : 
     128           0 : XFillExchangeData& XFillExchangeData::operator=( const XFillExchangeData& rData )
     129             : {
     130           0 :     delete pXFillAttrSetItem;
     131             : 
     132           0 :     if( rData.pXFillAttrSetItem )
     133           0 :         pXFillAttrSetItem = static_cast<XFillAttrSetItem*>( rData.pXFillAttrSetItem->Clone( pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool() ) );
     134             :     else
     135             :     {
     136           0 :         pPool = NULL;
     137           0 :         pXFillAttrSetItem = NULL;
     138             :     }
     139             : 
     140           0 :     return( *this );
     141             : }
     142             : 
     143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11