LCOV - code coverage report
Current view: top level - svx/source/sdr/properties - itemsettools.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 13 39 33.3 %
Date: 2014-11-03 Functions: 5 6 83.3 %
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 <sdr/properties/itemsettools.hxx>
      21             : #include <tools/debug.hxx>
      22             : #include <svl/itemset.hxx>
      23             : #include <svl/whiter.hxx>
      24             : #include <svx/svdogrp.hxx>
      25             : #include <svx/svditer.hxx>
      26             : #include <vcl/region.hxx>
      27             : #include <boost/scoped_ptr.hpp>
      28             : 
      29             : // class to remember broadcast start positions
      30             : 
      31             : namespace sdr
      32             : {
      33             :     namespace properties
      34             :     {
      35       96727 :         ItemChangeBroadcaster::ItemChangeBroadcaster(const SdrObject& rObj)
      36             :         {
      37       96727 :             if(rObj.ISA(SdrObjGroup))
      38             :             {
      39           0 :                 SdrObjListIter aIter(static_cast<const SdrObjGroup&>(rObj), IM_DEEPNOGROUPS);
      40           0 :                 mpData = new RectangleVector;
      41             :                 DBG_ASSERT(mpData, "ItemChangeBroadcaster: No memory (!)");
      42           0 :                 ((RectangleVector*)mpData)->reserve(aIter.Count());
      43             : 
      44           0 :                 while(aIter.IsMore())
      45             :                 {
      46           0 :                     SdrObject* pObj = aIter.Next();
      47             : 
      48           0 :                     if(pObj)
      49             :                     {
      50           0 :                         ((RectangleVector*)mpData)->push_back(pObj->GetLastBoundRect());
      51             :                     }
      52             :                 }
      53             : 
      54           0 :                 mnCount = ((RectangleVector*)mpData)->size();
      55             :             }
      56             :             else
      57             :             {
      58       96727 :                 mpData = new Rectangle(rObj.GetLastBoundRect());
      59       96727 :                 mnCount = 1L;
      60             :             }
      61       96727 :         }
      62             : 
      63       96727 :         ItemChangeBroadcaster::~ItemChangeBroadcaster()
      64             :         {
      65       96727 :             if(mnCount > 1)
      66             :             {
      67           0 :                 delete ((RectangleVector*)mpData);
      68             :             }
      69             :             else
      70             :             {
      71       96727 :                 delete ((Rectangle*)mpData);
      72             :             }
      73       96727 :         }
      74             : 
      75             : 
      76       96727 :         const Rectangle& ItemChangeBroadcaster::GetRectangle(sal_uInt32 nIndex) const
      77             :         {
      78       96727 :             if(mnCount > 1)
      79             :             {
      80           0 :                 return (*((RectangleVector*)mpData))[nIndex];
      81             :             }
      82             :             else
      83             :             {
      84       96727 :                 return *((Rectangle*)mpData);
      85             :             }
      86             :         }
      87             :     } // end of namespace properties
      88             : } // end of namespace sdr
      89             : 
      90             : 
      91             : 
      92             : namespace sdr
      93             : {
      94             :     namespace properties
      95             :     {
      96           0 :         void ScaleItemSet(SfxItemSet& rSet, const Fraction& rScale)
      97             :         {
      98           0 :             sal_Int32 nMul(rScale.GetNumerator());
      99           0 :             sal_Int32 nDiv(rScale.GetDenominator());
     100             : 
     101           0 :             if(!rScale.IsValid() || !nDiv)
     102             :             {
     103           0 :                 return;
     104             :             }
     105             : 
     106           0 :             SfxWhichIter aIter(rSet);
     107           0 :             sal_uInt16 nWhich(aIter.FirstWhich());
     108           0 :             const SfxPoolItem *pItem = NULL;
     109             : 
     110           0 :             while(nWhich)
     111             :             {
     112           0 :                 if(SfxItemState::SET == rSet.GetItemState(nWhich, false, &pItem))
     113             :                 {
     114           0 :                     if(pItem->HasMetrics())
     115             :                     {
     116           0 :                         boost::scoped_ptr<SfxPoolItem> pNewItem(pItem->Clone());
     117           0 :                         pNewItem->ScaleMetrics(nMul, nDiv);
     118           0 :                         rSet.Put(*pNewItem);
     119             :                     }
     120             :                 }
     121           0 :                 nWhich = aIter.NextWhich();
     122           0 :             }
     123             :         }
     124             :     } // end of namespace properties
     125         651 : } // end of namespace sdr
     126             : 
     127             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10