LCOV - code coverage report
Current view: top level - svx/source/sdr/properties - defaultproperties.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 73 91 80.2 %
Date: 2014-04-11 Functions: 12 20 60.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 <svx/sdr/properties/defaultproperties.hxx>
      21             : #include <svx/sdr/properties/itemsettools.hxx>
      22             : #include <svl/itemset.hxx>
      23             : #include <svl/whiter.hxx>
      24             : 
      25             : #include <vector>
      26             : #include <svx/svdobj.hxx>
      27             : #include <svx/svddef.hxx>
      28             : #include <svx/svdpool.hxx>
      29             : #include <editeng/eeitem.hxx>
      30             : 
      31             : 
      32             : 
      33             : namespace sdr
      34             : {
      35             :     namespace properties
      36             :     {
      37           0 :         SfxItemSet& DefaultProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
      38             :         {
      39             :             // Basic implementation; Basic object has NO attributes
      40           0 :             return *(new SfxItemSet(rPool));
      41             :         }
      42             : 
      43       64274 :         DefaultProperties::DefaultProperties(SdrObject& rObj)
      44             :         :   BaseProperties(rObj),
      45       64274 :             mpItemSet(0L)
      46             :         {
      47       64274 :         }
      48             : 
      49          56 :         DefaultProperties::DefaultProperties(const DefaultProperties& rProps, SdrObject& rObj)
      50             :         :   BaseProperties(rObj),
      51          56 :             mpItemSet(0L)
      52             :         {
      53          56 :             if(rProps.mpItemSet)
      54             :             {
      55          56 :                 mpItemSet = rProps.mpItemSet->Clone(true);
      56             : 
      57             :                 // do not keep parent info, this may be changed by later construrtors.
      58             :                 // This class just copies the ItemSet, ignore parent.
      59          56 :                 if(mpItemSet && mpItemSet->GetParent())
      60             :                 {
      61           2 :                     mpItemSet->SetParent(0L);
      62             :                 }
      63             :             }
      64          56 :         }
      65             : 
      66           0 :         BaseProperties& DefaultProperties::Clone(SdrObject& rObj) const
      67             :         {
      68           0 :             return *(new DefaultProperties(*this, rObj));
      69             :         }
      70             : 
      71      112214 :         DefaultProperties::~DefaultProperties()
      72             :         {
      73       56107 :             if(mpItemSet)
      74             :             {
      75       37345 :                 delete mpItemSet;
      76       37345 :                 mpItemSet = 0L;
      77             :             }
      78       56107 :         }
      79             : 
      80     6056983 :         const SfxItemSet& DefaultProperties::GetObjectItemSet() const
      81             :         {
      82     6056983 :             if(!mpItemSet)
      83             :             {
      84       42602 :                 ((DefaultProperties*)this)->mpItemSet = &(((DefaultProperties*)this)->CreateObjectSpecificItemSet(*GetSdrObject().GetObjectItemPool()));
      85       42602 :                 ((DefaultProperties*)this)->ForceDefaultAttributes();
      86             :             }
      87             : 
      88             :             DBG_ASSERT(mpItemSet, "Could not create an SfxItemSet(!)");
      89             : 
      90     6056983 :             return *mpItemSet;
      91             :         }
      92             : 
      93       36116 :         void DefaultProperties::SetObjectItem(const SfxPoolItem& rItem)
      94             :         {
      95       36116 :             const sal_uInt16 nWhichID(rItem.Which());
      96             : 
      97       36116 :             if(AllowItemChange(nWhichID, &rItem))
      98             :             {
      99       36116 :                 ItemChange(nWhichID, &rItem);
     100       36116 :                 PostItemChange(nWhichID);
     101             : 
     102       36116 :                 SfxItemSet aSet(*GetSdrObject().GetObjectItemPool(), nWhichID, nWhichID);
     103       36116 :                 aSet.Put(rItem);
     104       36116 :                 ItemSetChanged(aSet);
     105             :             }
     106       36116 :         }
     107             : 
     108       76327 :         void DefaultProperties::SetObjectItemDirect(const SfxPoolItem& rItem)
     109             :         {
     110       76327 :             const sal_uInt16 nWhichID(rItem.Which());
     111             : 
     112       76327 :             if(AllowItemChange(nWhichID, &rItem))
     113             :             {
     114       76327 :                 ItemChange(nWhichID, &rItem);
     115             :             }
     116       76327 :         }
     117             : 
     118         429 :         void DefaultProperties::ClearObjectItem(const sal_uInt16 nWhich)
     119             :         {
     120         429 :             if(AllowItemChange(nWhich))
     121             :             {
     122         429 :                 ItemChange(nWhich);
     123         429 :                 PostItemChange(nWhich);
     124             : 
     125         429 :                 if(nWhich)
     126             :                 {
     127           0 :                     SfxItemSet aSet(*GetSdrObject().GetObjectItemPool(), nWhich, nWhich, 0, 0);
     128           0 :                     ItemSetChanged(aSet);
     129             :                 }
     130             :             }
     131         429 :         }
     132             : 
     133       14214 :         void DefaultProperties::ClearObjectItemDirect(const sal_uInt16 nWhich)
     134             :         {
     135       14214 :             if(AllowItemChange(nWhich))
     136             :             {
     137       13938 :                 ItemChange(nWhich);
     138             :             }
     139       14214 :         }
     140             : 
     141      131294 :         void DefaultProperties::SetObjectItemSet(const SfxItemSet& rSet)
     142             :         {
     143      131294 :             SfxWhichIter aWhichIter(rSet);
     144      131294 :             sal_uInt16 nWhich(aWhichIter.FirstWhich());
     145             :             const SfxPoolItem *pPoolItem;
     146      262588 :             std::vector< sal_uInt16 > aPostItemChangeList;
     147      131294 :             sal_Bool bDidChange(sal_False);
     148      262588 :             SfxItemSet aSet(*GetSdrObject().GetObjectItemPool(), SDRATTR_START, EE_ITEMS_END);
     149             : 
     150             :             // give a hint to STL_Vector
     151      131294 :             aPostItemChangeList.reserve(rSet.Count());
     152             : 
     153     6481478 :             while(nWhich)
     154             :             {
     155     6218890 :                 if(SFX_ITEM_SET == rSet.GetItemState(nWhich, false, &pPoolItem))
     156             :                 {
     157      982839 :                     if(AllowItemChange(nWhich, pPoolItem))
     158             :                     {
     159      982839 :                         bDidChange = sal_True;
     160      982839 :                         ItemChange(nWhich, pPoolItem);
     161      982839 :                         aPostItemChangeList.push_back( nWhich );
     162      982839 :                         aSet.Put(*pPoolItem);
     163             :                     }
     164             :                 }
     165             : 
     166     6218890 :                 nWhich = aWhichIter.NextWhich();
     167             :             }
     168             : 
     169      131294 :             if(bDidChange)
     170             :             {
     171     1114119 :                 for (std::vector< sal_uInt16 >::const_iterator aIter(aPostItemChangeList.begin()), aEnd(aPostItemChangeList.end()); aIter != aEnd; ++aIter)
     172             :                 {
     173      982839 :                     PostItemChange(*aIter);
     174             :                 }
     175             : 
     176      131280 :                 ItemSetChanged(aSet);
     177      131294 :             }
     178      131294 :         }
     179             : 
     180           0 :         void DefaultProperties::ItemSetChanged(const SfxItemSet& /*rSet*/)
     181             :         {
     182           0 :         }
     183             : 
     184     1109649 :         bool DefaultProperties::AllowItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/) const
     185             :         {
     186     1109649 :             return true;
     187             :         }
     188             : 
     189           0 :         void DefaultProperties::ItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/)
     190             :         {
     191           0 :         }
     192             : 
     193     1019384 :         void DefaultProperties::PostItemChange(const sal_uInt16 nWhich )
     194             :         {
     195     1019384 :             if( (nWhich == XATTR_FILLSTYLE) && (mpItemSet != NULL) )
     196       36049 :                 CleanupFillProperties(*mpItemSet);
     197     1019384 :         }
     198             : 
     199           0 :         void DefaultProperties::SetStyleSheet(SfxStyleSheet* /*pNewStyleSheet*/, bool /*bDontRemoveHardAttr*/)
     200             :         {
     201             :             // no StyleSheet in DefaultProperties
     202           0 :         }
     203             : 
     204           0 :         SfxStyleSheet* DefaultProperties::GetStyleSheet() const
     205             :         {
     206             :             // no StyleSheet in DefaultProperties
     207           0 :             return 0L;
     208             :         }
     209             : 
     210        1479 :         void DefaultProperties::ForceDefaultAttributes()
     211             :         {
     212        1479 :         }
     213             : 
     214           0 :         void DefaultProperties::Scale(const Fraction& rScale)
     215             :         {
     216           0 :             if(mpItemSet)
     217             :             {
     218           0 :                 ScaleItemSet(*mpItemSet, rScale);
     219             :             }
     220           0 :         }
     221             :     } // end of namespace properties
     222             : } // end of namespace sdr
     223             : 
     224             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10