LCOV - code coverage report
Current view: top level - svx/source/xoutdev - xexch.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 57 0.0 %
Date: 2014-04-14 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             : 
      30             : 
      31           0 : TYPEINIT1_AUTOFACTORY( XFillExchangeData, SvDataCopyStream );
      32             : 
      33             : /// default CTOR, for Assign()
      34           0 : XFillExchangeData::XFillExchangeData() :
      35             :     pXFillAttrSetItem( NULL ),
      36           0 :     pPool( NULL )
      37             : {
      38           0 : }
      39             : 
      40           0 : XFillExchangeData::XFillExchangeData( const XFillAttrSetItem rXFillAttrSetItem ) :
      41           0 :     pXFillAttrSetItem( (XFillAttrSetItem*) rXFillAttrSetItem.Clone( rXFillAttrSetItem.GetItemSet().GetPool() ) ),
      42           0 :     pPool( rXFillAttrSetItem.GetItemSet().GetPool() )
      43             : {
      44           0 : }
      45             : 
      46           0 : XFillExchangeData::~XFillExchangeData()
      47             : {
      48           0 :     delete pXFillAttrSetItem;
      49           0 : }
      50             : 
      51             : /// binary export (currently w/o version control because it is not persistent)
      52           0 : SvStream& WriteXFillExchangeData( SvStream& rOStm, const XFillExchangeData& rData )
      53             : {
      54           0 :     if( rData.pXFillAttrSetItem )
      55             :     {
      56           0 :         SfxWhichIter        aIter( rData.pXFillAttrSetItem->GetItemSet() );
      57           0 :         sal_uInt16              nWhich = aIter.FirstWhich();
      58             :         const SfxPoolItem*  pItem;
      59           0 :         sal_uInt32          nItemCount = 0;
      60           0 :         sal_Size            nFirstPos = rOStm.Tell();
      61             : 
      62           0 :         rOStm.WriteUInt32( nItemCount );
      63             : 
      64           0 :         while( nWhich )
      65             :         {
      66           0 :             if( SFX_ITEM_SET == rData.pXFillAttrSetItem->GetItemSet().GetItemState( nWhich, false, &pItem ) )
      67             :             {
      68           0 :                 VersionCompat   aCompat( rOStm, STREAM_WRITE );
      69           0 :                 const sal_uInt16    nItemVersion2 = pItem->GetVersion( (sal_uInt16) rOStm.GetVersion() );
      70             : 
      71           0 :                 rOStm.WriteUInt16( nWhich ).WriteUInt16( nItemVersion2 );
      72           0 :                 pItem->Store( rOStm, nItemVersion2 );
      73             : 
      74           0 :                 nItemCount++;
      75             :             }
      76             : 
      77           0 :             nWhich = aIter.NextWhich();
      78             :         }
      79             : 
      80           0 :         const sal_uIntPtr nLastPos = rOStm.Tell();
      81           0 :         rOStm.Seek( nFirstPos );
      82           0 :         rOStm.WriteUInt32( nItemCount );
      83           0 :         rOStm.Seek( nLastPos );
      84             :     }
      85             : 
      86           0 :     return rOStm;
      87             : }
      88             : 
      89             : /// binary export (currently w/o version control because it is not persistent)
      90           0 : SvStream& ReadXFillExchangeData( SvStream& rIStm, XFillExchangeData& rData )
      91             : {
      92             :     DBG_ASSERT( rData.pPool, "XFillExchangeData has no pool" );
      93             : 
      94           0 :     SfxItemSet*     pSet = new SfxItemSet ( *rData.pPool, XATTR_FILL_FIRST, XATTR_FILL_LAST );
      95             :     SfxPoolItem*    pNewItem;
      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, STREAM_READ );
     107             : 
     108           0 :         rIStm.ReadUInt16( nWhich ).ReadUInt16( nItemVersion );
     109             : 
     110           0 :         if( nWhich )
     111             :         {
     112           0 :             pNewItem = rData.pPool->GetDefaultItem( nWhich ).Create( rIStm, nItemVersion );
     113             : 
     114           0 :             if( pNewItem )
     115             :             {
     116           0 :                 pSet->Put( *pNewItem );
     117           0 :                 delete pNewItem;
     118             :             }
     119             :         }
     120           0 :     }
     121             : 
     122           0 :     delete rData.pXFillAttrSetItem;
     123           0 :     rData.pXFillAttrSetItem = new XFillAttrSetItem( pSet );
     124           0 :     rData.pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool();
     125             : 
     126           0 :     return rIStm;
     127             : }
     128             : 
     129           0 : XFillExchangeData& XFillExchangeData::operator=( const XFillExchangeData& rData )
     130             : {
     131           0 :     delete pXFillAttrSetItem;
     132             : 
     133           0 :     if( rData.pXFillAttrSetItem )
     134           0 :         pXFillAttrSetItem = (XFillAttrSetItem*) rData.pXFillAttrSetItem->Clone( pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool() );
     135             :     else
     136             :     {
     137           0 :         pPool = NULL;
     138           0 :         pXFillAttrSetItem = NULL;
     139             :     }
     140             : 
     141           0 :     return( *this );
     142             : }
     143             : 
     144             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10