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

Generated by: LCOV version 1.11