fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svx / source / sdr / properties / itemsettools.cxx
blobb5f763ab6245ae2c586b96bd4533c59ed9209941
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/sdr/properties/itemsettools.hxx>
21 #include <tools/debug.hxx>
22 #include <svl/itemset.hxx>
23 #include <svl/whiter.hxx>
25 #include <vector>
26 #include <svx/svdogrp.hxx>
27 #include <svx/svditer.hxx>
29 //////////////////////////////////////////////////////////////////////////////
30 // class to remember broadcast start positions
32 namespace sdr
34 namespace properties
36 // helper vector to remember rectangles
37 typedef ::std::vector< Rectangle > RectangleVector;
39 ItemChangeBroadcaster::ItemChangeBroadcaster(const SdrObject& rObj)
41 if(rObj.ISA(SdrObjGroup))
43 SdrObjListIter aIter((const SdrObjGroup&)rObj, IM_DEEPNOGROUPS);
44 mpData = new RectangleVector;
45 DBG_ASSERT(mpData, "ItemChangeBroadcaster: No memory (!)");
46 ((RectangleVector*)mpData)->reserve(aIter.Count());
48 while(aIter.IsMore())
50 SdrObject* pObj = aIter.Next();
52 if(pObj)
54 ((RectangleVector*)mpData)->push_back(pObj->GetLastBoundRect());
58 mnCount = ((RectangleVector*)mpData)->size();
60 else
62 mpData = new Rectangle(rObj.GetLastBoundRect());
63 mnCount = 1L;
67 ItemChangeBroadcaster::~ItemChangeBroadcaster()
69 if(mnCount > 1)
71 delete ((RectangleVector*)mpData);
73 else
75 delete ((Rectangle*)mpData);
79 sal_uInt32 ItemChangeBroadcaster::GetRectangleCount() const
81 return mnCount;
84 const Rectangle& ItemChangeBroadcaster::GetRectangle(sal_uInt32 nIndex) const
86 if(mnCount > 1)
88 return (*((RectangleVector*)mpData))[nIndex];
90 else
92 return *((Rectangle*)mpData);
95 } // end of namespace properties
96 } // end of namespace sdr
98 //////////////////////////////////////////////////////////////////////////////
100 namespace sdr
102 namespace properties
104 void ScaleItemSet(SfxItemSet& rSet, const Fraction& rScale)
106 sal_Int32 nMul(rScale.GetNumerator());
107 sal_Int32 nDiv(rScale.GetDenominator());
109 if(!rScale.IsValid() || !nDiv)
111 return;
114 SfxWhichIter aIter(rSet);
115 sal_uInt16 nWhich(aIter.FirstWhich());
116 const SfxPoolItem *pItem = NULL;
118 while(nWhich)
120 if(SFX_ITEM_SET == rSet.GetItemState(nWhich, sal_False, &pItem))
122 if(pItem->HasMetrics())
124 SfxPoolItem* pNewItem = pItem->Clone();
125 pNewItem->ScaleMetrics(nMul, nDiv);
126 rSet.Put(*pNewItem);
129 nWhich = aIter.NextWhich();
132 } // end of namespace properties
133 } // end of namespace sdr
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */