LCOV - code coverage report
Current view: top level - svx/source/sdr/properties - properties.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 52 70 74.3 %
Date: 2015-06-13 12:38:46 Functions: 13 19 68.4 %
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 <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             : using namespace com::sun::star;
      28             : 
      29             : namespace sdr
      30             : {
      31             :     namespace properties
      32             :     {
      33      109847 :         BaseProperties::BaseProperties(SdrObject& rObj)
      34      109847 :         :   mrObject(rObj)
      35             :         {
      36      109847 :         }
      37             : 
      38           0 :         BaseProperties::BaseProperties(const BaseProperties& /*rProps*/, SdrObject& rObj)
      39           0 :         :   mrObject(rObj)
      40             :         {
      41           0 :         }
      42             : 
      43      108694 :         BaseProperties::~BaseProperties()
      44             :         {
      45      108694 :         }
      46             : 
      47      542214 :         const SdrObject& BaseProperties::GetSdrObject() const
      48             :         {
      49      542214 :             return mrObject;
      50             :         }
      51             : 
      52     5863091 :         SdrObject& BaseProperties::GetSdrObject()
      53             :         {
      54     5863091 :             return mrObject;
      55             :         }
      56             : 
      57     1586058 :         const SfxItemSet& BaseProperties::GetMergedItemSet() const
      58             :         {
      59             :             // default implementation falls back to GetObjectItemSet()
      60     1586058 :             return GetObjectItemSet();
      61             :         }
      62             : 
      63      135005 :         void BaseProperties::SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems)
      64             :         {
      65             :             // clear items if requested
      66      135005 :             if(bClearAllItems)
      67             :             {
      68           0 :                 ClearObjectItem();
      69             :             }
      70             : 
      71             :             // default implementation falls back to SetObjectItemSet()
      72      135005 :             SetObjectItemSet(rSet);
      73      135005 :         }
      74             : 
      75       56150 :         void BaseProperties::SetMergedItem(const SfxPoolItem& rItem)
      76             :         {
      77             :             // default implementation falls back to SetObjectItem()
      78       56150 :             SetObjectItem(rItem);
      79       56150 :         }
      80             : 
      81        2241 :         void BaseProperties::ClearMergedItem(const sal_uInt16 nWhich)
      82             :         {
      83             :             // default implementation falls back to ClearObjectItem()
      84        2241 :             ClearObjectItem(nWhich);
      85        2241 :         }
      86             : 
      87           0 :         void BaseProperties::Scale(const Fraction& /*rScale*/)
      88             :         {
      89             :             // default implementation does nothing; override where
      90             :             // an ItemSet is implemented.
      91           0 :         }
      92             : 
      93           0 :         void BaseProperties::MoveToItemPool(SfxItemPool* /*pSrcPool*/, SfxItemPool* /*pDestPool*/, SdrModel* /*pNewModel*/)
      94             :         {
      95             :             // Move properties to a new ItemPool. Default implementation does nothing.
      96             :             // Override where an ItemSet is implemented.
      97           0 :         }
      98             : 
      99       34336 :         void BaseProperties::SetModel(SdrModel* /*pOldModel*/, SdrModel* /*pNewModel*/)
     100             :         {
     101             :             // Set new model. Default implementation does nothing.
     102             :             // Override where an ItemSet is implemented.
     103       34336 :         }
     104             : 
     105           0 :         void BaseProperties::ForceStyleToHardAttributes()
     106             :         {
     107             :             // force all attributes which come from styles to hard attributes
     108             :             // to be able to live without the style. Default implementation does nothing.
     109             :             // Override where an ItemSet is implemented.
     110           0 :         }
     111             : 
     112      120365 :         void BaseProperties::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems)
     113             :         {
     114      120365 :             ItemChangeBroadcaster aC(GetSdrObject());
     115             : 
     116      120365 :             if(bClearAllItems)
     117             :             {
     118           0 :                 ClearObjectItem();
     119             :             }
     120             : 
     121      120365 :             SetMergedItemSet(rSet);
     122      120365 :             BroadcastItemChange(aC);
     123      120365 :         }
     124             : 
     125      102578 :         const SfxPoolItem& BaseProperties::GetItem(const sal_uInt16 nWhich) const
     126             :         {
     127      102578 :             return GetObjectItemSet().Get(nWhich);
     128             :         }
     129             : 
     130      120385 :         void BaseProperties::BroadcastItemChange(const ItemChangeBroadcaster& rChange)
     131             :         {
     132      120385 :             const sal_uInt32 nCount(rChange.GetRectangleCount());
     133             : 
     134             :             // #110094#-14 Reduce to do only second change
     135             :             //// invalidate all remembered rectangles
     136             :             //for(sal_uInt32 a(0); a < nCount; a++)
     137             :             //{
     138             :             //  GetSdrObject().BroadcastObjectChange(rChange.GetRectangle(a));
     139             :             //}
     140             : 
     141             :             // invalidate all new rectangles
     142      120385 :             if(GetSdrObject().ISA(SdrObjGroup))
     143             :             {
     144           0 :                 SdrObjListIter aIter(static_cast<SdrObjGroup&>(GetSdrObject()), IM_DEEPNOGROUPS);
     145             : 
     146           0 :                 while(aIter.IsMore())
     147             :                 {
     148           0 :                     SdrObject* pObj = aIter.Next();
     149             :                     // This is done with ItemSetChanged
     150             :                     // pObj->SetChanged();
     151           0 :                     pObj->BroadcastObjectChange();
     152           0 :                 }
     153             :             }
     154             :             else
     155             :             {
     156             :                 // This is done with ItemSetChanged
     157             :                 // GetSdrObject().SetChanged();
     158      120385 :                 GetSdrObject().BroadcastObjectChange();
     159             :             }
     160             : 
     161             :             // also send the user calls
     162      240770 :             for(sal_uInt32 a(0L); a < nCount; a++)
     163             :             {
     164      120385 :                 GetSdrObject().SendUserCall(SDRUSERCALL_CHGATTR, rChange.GetRectangle(a));
     165             :             }
     166      120385 :         }
     167             : 
     168           0 :         sal_uInt32 BaseProperties::getVersion() const
     169             :         {
     170           0 :             return 0;
     171             :         }
     172             : 
     173       58591 :         void CleanupFillProperties( SfxItemSet& rItemSet )
     174             :         {
     175       58591 :             const bool bFillBitmap = rItemSet.GetItemState(XATTR_FILLBITMAP, false) == SfxItemState::SET;
     176       58591 :             const bool bFillGradient = rItemSet.GetItemState(XATTR_FILLGRADIENT, false) == SfxItemState::SET;
     177       58591 :             const bool bFillHatch = rItemSet.GetItemState(XATTR_FILLHATCH, false) == SfxItemState::SET;
     178       58591 :             if( bFillBitmap || bFillGradient || bFillHatch )
     179             :             {
     180        6621 :                 const XFillStyleItem* pFillStyleItem = dynamic_cast< const XFillStyleItem* >( rItemSet.GetItem(XATTR_FILLSTYLE) );
     181        6621 :                 if( pFillStyleItem )
     182             :                 {
     183        6621 :                     if( bFillBitmap && (pFillStyleItem->GetValue() != drawing::FillStyle_BITMAP) )
     184             :                     {
     185        1478 :                         rItemSet.ClearItem( XATTR_FILLBITMAP );
     186             :                     }
     187             : 
     188        6621 :                     if( bFillGradient && (pFillStyleItem->GetValue() != drawing::FillStyle_GRADIENT) )
     189             :                     {
     190         990 :                         rItemSet.ClearItem( XATTR_FILLGRADIENT );
     191             :                     }
     192             : 
     193        6621 :                     if( bFillHatch && (pFillStyleItem->GetValue() != drawing::FillStyle_HATCH) )
     194             :                     {
     195        1435 :                         rItemSet.ClearItem( XATTR_FILLHATCH );
     196             :                     }
     197             :                 }
     198             :             }
     199       58591 :         }
     200             : 
     201             :     } // end of namespace properties
     202             : } // end of namespace sdr
     203             : 
     204             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11