LibreOffice Module svx (master)  1
itemsettools.cxx
Go to the documentation of this file.
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 
21 #include <tools/fract.hxx>
22 #include <svl/itemset.hxx>
23 #include <svl/whiter.hxx>
24 #include <svx/svdogrp.hxx>
25 #include <svx/svditer.hxx>
26 #include <vcl/outdev.hxx>
27 #include <memory>
28 
29 // class to remember broadcast start positions
30 
31 namespace sdr
32 {
33  namespace properties
34  {
36  {
37  if (const SdrObjGroup* pGroupObj = dynamic_cast<const SdrObjGroup*>(&rObj))
38  {
39  SdrObjListIter aIter(pGroupObj->GetSubList(), SdrIterMode::DeepNoGroups);
40  maRectangles.reserve(aIter.Count());
41 
42  while(aIter.IsMore())
43  {
44  SdrObject* pObj = aIter.Next();
45 
46  if(pObj)
47  {
48  maRectangles.push_back(pObj->GetLastBoundRect());
49  }
50  }
51  }
52  else
53  {
54  maRectangles.push_back(rObj.GetLastBoundRect());
55  }
56  }
57  } // end of namespace properties
58 } // end of namespace sdr
59 
60 
61 namespace sdr
62 {
63  namespace properties
64  {
65  void ScaleItemSet(SfxItemSet& rSet, const Fraction& rScale)
66  {
67  sal_Int32 nMul(rScale.GetNumerator());
68  sal_Int32 nDiv(rScale.GetDenominator());
69 
70  if(!rScale.IsValid() || !nDiv)
71  {
72  return;
73  }
74 
75  SfxWhichIter aIter(rSet);
76  sal_uInt16 nWhich(aIter.FirstWhich());
77  const SfxPoolItem *pItem = nullptr;
78 
79  while(nWhich)
80  {
81  if(SfxItemState::SET == rSet.GetItemState(nWhich, false, &pItem))
82  {
83  if(pItem->HasMetrics())
84  {
85  std::unique_ptr<SfxPoolItem> pNewItem(pItem->Clone());
86  pNewItem->ScaleMetrics(nMul, nDiv);
87  rSet.Put(std::move(pNewItem));
88  }
89  }
90  nWhich = aIter.NextWhich();
91  }
92  }
93  } // end of namespace properties
94 } // end of namespace sdr
95 
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
void ScaleItemSet(SfxItemSet &rSet, const Fraction &rScale)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Abstract DrawObject.
Definition: svdobj.hxx:312
ItemChangeBroadcaster(const SdrObject &rObj)
std::vector< tools::Rectangle > maRectangles
virtual const tools::Rectangle & GetLastBoundRect() const
Definition: svdobj.cxx:895
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_Int32 GetDenominator() const
sal_Int32 GetNumerator() const
virtual void ScaleMetrics(long lMult, long lDiv)
bool IsValid() const