LCOV - code coverage report
Current view: top level - svx/source/sdr/properties - properties.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 48 66 72.7 %
Date: 2014-04-11 Functions: 11 17 64.7 %
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 <svx/sdr/properties/properties.hxx>
      21             : #include <svx/sdr/properties/itemsettools.hxx>
      22             : #include <svl/itemset.hxx>
      23             : #include <svx/svdogrp.hxx>
      24             : #include <svx/svditer.hxx>
      25             : #include <svx/xfillit0.hxx>
      26             : 
      27             : 
      28             : 
      29             : namespace sdr
      30             : {
      31             :     namespace properties
      32             :     {
      33       64351 :         BaseProperties::BaseProperties(SdrObject& rObj)
      34       64351 :         :   mrObject(rObj)
      35             :         {
      36       64351 :         }
      37             : 
      38           0 :         BaseProperties::BaseProperties(const BaseProperties& /*rProps*/, SdrObject& rObj)
      39           0 :         :   mrObject(rObj)
      40             :         {
      41           0 :         }
      42             : 
      43       56128 :         BaseProperties::~BaseProperties()
      44             :         {
      45       56128 :         }
      46             : 
      47      979291 :         const SfxItemSet& BaseProperties::GetMergedItemSet() const
      48             :         {
      49             :             // default implementation falls back to GetObjectItemSet()
      50      979291 :             return GetObjectItemSet();
      51             :         }
      52             : 
      53       75535 :         void BaseProperties::SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems)
      54             :         {
      55             :             // clear items if requested
      56       75535 :             if(bClearAllItems)
      57             :             {
      58           0 :                 ClearObjectItem();
      59             :             }
      60             : 
      61             :             // default implementation falls back to SetObjectItemSet()
      62       75535 :             SetObjectItemSet(rSet);
      63       75535 :         }
      64             : 
      65       36084 :         void BaseProperties::SetMergedItem(const SfxPoolItem& rItem)
      66             :         {
      67             :             // default implementation falls back to SetObjectItem()
      68       36084 :             SetObjectItem(rItem);
      69       36084 :         }
      70             : 
      71         498 :         void BaseProperties::ClearMergedItem(const sal_uInt16 nWhich)
      72             :         {
      73             :             // default implementation falls back to ClearObjectItem()
      74         498 :             ClearObjectItem(nWhich);
      75         498 :         }
      76             : 
      77           0 :         void BaseProperties::Scale(const Fraction& /*rScale*/)
      78             :         {
      79             :             // default implementation does nothing; overload where
      80             :             // an ItemSet is implemented.
      81           0 :         }
      82             : 
      83           0 :         void BaseProperties::MoveToItemPool(SfxItemPool* /*pSrcPool*/, SfxItemPool* /*pDestPool*/, SdrModel* /*pNewModel*/)
      84             :         {
      85             :             // Move properties to a new ItemPool. Default implementation does nothing.
      86             :             // Overload where an ItemSet is implemented.
      87           0 :         }
      88             : 
      89       21029 :         void BaseProperties::SetModel(SdrModel* /*pOldModel*/, SdrModel* /*pNewModel*/)
      90             :         {
      91             :             // Set new model. Default implementation does nothing.
      92             :             // Overload where an ItemSet is implemented.
      93       21029 :         }
      94             : 
      95           0 :         void BaseProperties::ForceStyleToHardAttributes()
      96             :         {
      97             :             // force all attributes which come from styles to hard attributes
      98             :             // to be able to live without the style. Default implementation does nothing.
      99             :             // Overload where an ItemSet is implemented.
     100           0 :         }
     101             : 
     102       68482 :         void BaseProperties::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems)
     103             :         {
     104       68482 :             ItemChangeBroadcaster aC(GetSdrObject());
     105             : 
     106       68482 :             if(bClearAllItems)
     107             :             {
     108           0 :                 ClearObjectItem();
     109             :             }
     110             : 
     111       68482 :             SetMergedItemSet(rSet);
     112       68482 :             BroadcastItemChange(aC);
     113       68482 :         }
     114             : 
     115       59754 :         const SfxPoolItem& BaseProperties::GetItem(const sal_uInt16 nWhich) const
     116             :         {
     117       59754 :             return GetObjectItemSet().Get(nWhich);
     118             :         }
     119             : 
     120       68502 :         void BaseProperties::BroadcastItemChange(const ItemChangeBroadcaster& rChange)
     121             :         {
     122       68502 :             const sal_uInt32 nCount(rChange.GetRectangleCount());
     123             : 
     124             :             // #110094#-14 Reduce to do only second change
     125             :             //// invalidate all remembered rectangles
     126             :             //for(sal_uInt32 a(0); a < nCount; a++)
     127             :             //{
     128             :             //  GetSdrObject().BroadcastObjectChange(rChange.GetRectangle(a));
     129             :             //}
     130             : 
     131             :             // invalidate all new rectangles
     132       68502 :             if(GetSdrObject().ISA(SdrObjGroup))
     133             :             {
     134           0 :                 SdrObjListIter aIter((SdrObjGroup&)GetSdrObject(), IM_DEEPNOGROUPS);
     135             : 
     136           0 :                 while(aIter.IsMore())
     137             :                 {
     138           0 :                     SdrObject* pObj = aIter.Next();
     139             :                     // This is done with ItemSetChanged
     140             :                     // pObj->SetChanged();
     141           0 :                     pObj->BroadcastObjectChange();
     142           0 :                 }
     143             :             }
     144             :             else
     145             :             {
     146             :                 // This is done with ItemSetChanged
     147             :                 // GetSdrObject().SetChanged();
     148       68502 :                 GetSdrObject().BroadcastObjectChange();
     149             :             }
     150             : 
     151             :             // also send the user calls
     152      137004 :             for(sal_uInt32 a(0L); a < nCount; a++)
     153             :             {
     154       68502 :                 GetSdrObject().SendUserCall(SDRUSERCALL_CHGATTR, rChange.GetRectangle(a));
     155             :             }
     156       68502 :         }
     157             : 
     158           0 :         sal_uInt32 BaseProperties::getVersion() const
     159             :         {
     160           0 :             return 0;
     161             :         }
     162             : 
     163       36049 :         void CleanupFillProperties( SfxItemSet& rItemSet )
     164             :         {
     165       36049 :             const bool bFillBitmap = rItemSet.GetItemState(XATTR_FILLBITMAP, false) == SFX_ITEM_SET;
     166       36049 :             const bool bFillGradient = rItemSet.GetItemState(XATTR_FILLGRADIENT, false) == SFX_ITEM_SET;
     167       36049 :             const bool bFillHatch = rItemSet.GetItemState(XATTR_FILLHATCH, false) == SFX_ITEM_SET;
     168       36049 :             if( bFillBitmap || bFillGradient || bFillHatch )
     169             :             {
     170        3934 :                 const XFillStyleItem* pFillStyleItem = dynamic_cast< const XFillStyleItem* >( rItemSet.GetItem(XATTR_FILLSTYLE) );
     171        3934 :                 if( pFillStyleItem )
     172             :                 {
     173        3934 :                     if( bFillBitmap && (pFillStyleItem->GetValue() != XFILL_BITMAP) )
     174             :                     {
     175         906 :                         rItemSet.ClearItem( XATTR_FILLBITMAP );
     176             :                     }
     177             : 
     178        3934 :                     if( bFillGradient && (pFillStyleItem->GetValue() != XFILL_GRADIENT) )
     179             :                     {
     180         521 :                         rItemSet.ClearItem( XATTR_FILLGRADIENT );
     181             :                     }
     182             : 
     183        3934 :                     if( bFillHatch && (pFillStyleItem->GetValue() != XFILL_HATCH) )
     184             :                     {
     185         941 :                         rItemSet.ClearItem( XATTR_FILLHATCH );
     186             :                     }
     187             :                 }
     188             :             }
     189       36049 :         }
     190             : 
     191             :     } // end of namespace properties
     192             : } // end of namespace sdr
     193             : 
     194             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10