LCOV - code coverage report
Current view: top level - svx/source/sdr/properties - properties.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 48 66 72.7 %
Date: 2012-08-25 Functions: 11 17 64.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 36 56 64.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <svx/sdr/properties/properties.hxx>
      30                 :            : #include <svx/sdr/properties/itemsettools.hxx>
      31                 :            : #include <svl/itemset.hxx>
      32                 :            : #include <svx/svdogrp.hxx>
      33                 :            : #include <svx/svditer.hxx>
      34                 :            : #include <svx/xfillit0.hxx>
      35                 :            : 
      36                 :            : //////////////////////////////////////////////////////////////////////////////
      37                 :            : 
      38                 :            : namespace sdr
      39                 :            : {
      40                 :            :     namespace properties
      41                 :            :     {
      42                 :      95028 :         BaseProperties::BaseProperties(SdrObject& rObj)
      43                 :      95028 :         :   mrObject(rObj)
      44                 :            :         {
      45                 :      95028 :         }
      46                 :            : 
      47                 :          0 :         BaseProperties::BaseProperties(const BaseProperties& /*rProps*/, SdrObject& rObj)
      48                 :          0 :         :   mrObject(rObj)
      49                 :            :         {
      50                 :          0 :         }
      51                 :            : 
      52                 :      94928 :         BaseProperties::~BaseProperties()
      53                 :            :         {
      54         [ -  + ]:      94928 :         }
      55                 :            : 
      56                 :    1297361 :         const SfxItemSet& BaseProperties::GetMergedItemSet() const
      57                 :            :         {
      58                 :            :             // default implementation falls back to GetObjectItemSet()
      59                 :    1297361 :             return GetObjectItemSet();
      60                 :            :         }
      61                 :            : 
      62                 :      98363 :         void BaseProperties::SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems)
      63                 :            :         {
      64                 :            :             // clear items if requested
      65         [ -  + ]:      98363 :             if(bClearAllItems)
      66                 :            :             {
      67                 :          0 :                 ClearObjectItem();
      68                 :            :             }
      69                 :            : 
      70                 :            :             // default implementation falls back to SetObjectItemSet()
      71                 :      98363 :             SetObjectItemSet(rSet);
      72                 :      98363 :         }
      73                 :            : 
      74                 :      52243 :         void BaseProperties::SetMergedItem(const SfxPoolItem& rItem)
      75                 :            :         {
      76                 :            :             // default implementation falls back to SetObjectItem()
      77                 :      52243 :             SetObjectItem(rItem);
      78                 :      52243 :         }
      79                 :            : 
      80                 :        554 :         void BaseProperties::ClearMergedItem(const sal_uInt16 nWhich)
      81                 :            :         {
      82                 :            :             // default implementation falls back to ClearObjectItem()
      83                 :        554 :             ClearObjectItem(nWhich);
      84                 :        554 :         }
      85                 :            : 
      86                 :          0 :         void BaseProperties::Scale(const Fraction& /*rScale*/)
      87                 :            :         {
      88                 :            :             // default implementation does nothing; overload where
      89                 :            :             // an ItemSet is implemented.
      90                 :          0 :         }
      91                 :            : 
      92                 :          0 :         void BaseProperties::MoveToItemPool(SfxItemPool* /*pSrcPool*/, SfxItemPool* /*pDestPool*/, SdrModel* /*pNewModel*/)
      93                 :            :         {
      94                 :            :             // Move properties to a new ItemPool. Default implementation does nothing.
      95                 :            :             // Overload where an ItemSet is implemented.
      96                 :          0 :         }
      97                 :            : 
      98                 :      34814 :         void BaseProperties::SetModel(SdrModel* /*pOldModel*/, SdrModel* /*pNewModel*/)
      99                 :            :         {
     100                 :            :             // Set new model. Default implementation does nothing.
     101                 :            :             // Overload where an ItemSet is implemented.
     102                 :      34814 :         }
     103                 :            : 
     104                 :          0 :         void BaseProperties::ForceStyleToHardAttributes()
     105                 :            :         {
     106                 :            :             // force all attributes which come from styles to hard attributes
     107                 :            :             // to be able to live without the style. Default implementation does nothing.
     108                 :            :             // Overload where an ItemSet is implemented.
     109                 :          0 :         }
     110                 :            : 
     111                 :      95290 :         void BaseProperties::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems)
     112                 :            :         {
     113         [ +  - ]:      95290 :             ItemChangeBroadcaster aC(GetSdrObject());
     114                 :            : 
     115         [ -  + ]:      95290 :             if(bClearAllItems)
     116                 :            :             {
     117         [ #  # ]:          0 :                 ClearObjectItem();
     118                 :            :             }
     119                 :            : 
     120         [ +  - ]:      95290 :             SetMergedItemSet(rSet);
     121 [ +  - ][ +  - ]:      95290 :             BroadcastItemChange(aC);
     122                 :      95290 :         }
     123                 :            : 
     124                 :      66704 :         const SfxPoolItem& BaseProperties::GetItem(const sal_uInt16 nWhich) const
     125                 :            :         {
     126                 :      66704 :             return GetObjectItemSet().Get(nWhich);
     127                 :            :         }
     128                 :            : 
     129                 :      95330 :         void BaseProperties::BroadcastItemChange(const ItemChangeBroadcaster& rChange)
     130                 :            :         {
     131                 :      95330 :             const sal_uInt32 nCount(rChange.GetRectangleCount());
     132                 :            : 
     133                 :            :             // #110094#-14 Reduce to do only second change
     134                 :            :             //// invalidate all remembered rectangles
     135                 :            :             //for(sal_uInt32 a(0); a < nCount; a++)
     136                 :            :             //{
     137                 :            :             //  GetSdrObject().BroadcastObjectChange(rChange.GetRectangle(a));
     138                 :            :             //}
     139                 :            : 
     140                 :            :             // invalidate all new rectangles
     141         [ -  + ]:      95330 :             if(GetSdrObject().ISA(SdrObjGroup))
     142                 :            :             {
     143         [ #  # ]:          0 :                 SdrObjListIter aIter((SdrObjGroup&)GetSdrObject(), IM_DEEPNOGROUPS);
     144                 :            : 
     145         [ #  # ]:          0 :                 while(aIter.IsMore())
     146                 :            :                 {
     147         [ #  # ]:          0 :                     SdrObject* pObj = aIter.Next();
     148                 :            :                     // This is done with ItemSetChanged
     149                 :            :                     // pObj->SetChanged();
     150         [ #  # ]:          0 :                     pObj->BroadcastObjectChange();
     151                 :          0 :                 }
     152                 :            :             }
     153                 :            :             else
     154                 :            :             {
     155                 :            :                 // This is done with ItemSetChanged
     156                 :            :                 // GetSdrObject().SetChanged();
     157                 :      95330 :                 GetSdrObject().BroadcastObjectChange();
     158                 :            :             }
     159                 :            : 
     160                 :            :             // also send the user calls
     161         [ +  + ]:     190660 :             for(sal_uInt32 a(0L); a < nCount; a++)
     162                 :            :             {
     163                 :      95330 :                 GetSdrObject().SendUserCall(SDRUSERCALL_CHGATTR, rChange.GetRectangle(a));
     164                 :            :             }
     165                 :      95330 :         }
     166                 :            : 
     167                 :          0 :         sal_uInt32 BaseProperties::getVersion() const
     168                 :            :         {
     169                 :          0 :             return 0;
     170                 :            :         }
     171                 :            : 
     172                 :      48810 :         void CleanupFillProperties( SfxItemSet& rItemSet )
     173                 :            :         {
     174                 :      48810 :             const bool bFillBitmap = rItemSet.GetItemState(XATTR_FILLBITMAP, sal_False) == SFX_ITEM_SET;
     175                 :      48810 :             const bool bFillGradient = rItemSet.GetItemState(XATTR_FILLGRADIENT, sal_False) == SFX_ITEM_SET;
     176                 :      48810 :             const bool bFillHatch = rItemSet.GetItemState(XATTR_FILLHATCH, sal_False) == SFX_ITEM_SET;
     177 [ +  + ][ +  + ]:      48810 :             if( bFillBitmap || bFillGradient || bFillHatch )
                 [ +  + ]
     178                 :            :             {
     179         [ -  + ]:       6944 :                 const XFillStyleItem* pFillStyleItem = dynamic_cast< const XFillStyleItem* >( rItemSet.GetItem(XATTR_FILLSTYLE) );
     180         [ +  - ]:       6944 :                 if( pFillStyleItem )
     181                 :            :                 {
     182 [ +  + ][ +  + ]:       6944 :                     if( bFillBitmap && (pFillStyleItem->GetValue() != XFILL_BITMAP) )
                 [ +  + ]
     183                 :            :                     {
     184                 :       1721 :                         rItemSet.ClearItem( XATTR_FILLBITMAP );
     185                 :            :                     }
     186                 :            : 
     187 [ +  + ][ +  + ]:       6944 :                     if( bFillGradient && (pFillStyleItem->GetValue() != XFILL_GRADIENT) )
                 [ +  + ]
     188                 :            :                     {
     189                 :        996 :                         rItemSet.ClearItem( XATTR_FILLGRADIENT );
     190                 :            :                     }
     191                 :            : 
     192 [ +  + ][ +  + ]:       6944 :                     if( bFillHatch && (pFillStyleItem->GetValue() != XFILL_HATCH) )
                 [ +  + ]
     193                 :            :                     {
     194                 :       1721 :                         rItemSet.ClearItem( XATTR_FILLHATCH );
     195                 :            :                     }
     196                 :            :                 }
     197                 :            :             }
     198                 :      48810 :         }
     199                 :            : 
     200                 :            :     } // end of namespace properties
     201                 :            : } // end of namespace sdr
     202                 :            : 
     203                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10