1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
26 #include <svx/svdogrp.hxx>
27 #include <svx/svditer.hxx>
29 //////////////////////////////////////////////////////////////////////////////
30 // class to remember broadcast start positions
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());
50 SdrObject
* pObj
= aIter
.Next();
54 ((RectangleVector
*)mpData
)->push_back(pObj
->GetLastBoundRect());
58 mnCount
= ((RectangleVector
*)mpData
)->size();
62 mpData
= new Rectangle(rObj
.GetLastBoundRect());
67 ItemChangeBroadcaster::~ItemChangeBroadcaster()
71 delete ((RectangleVector
*)mpData
);
75 delete ((Rectangle
*)mpData
);
79 sal_uInt32
ItemChangeBroadcaster::GetRectangleCount() const
84 const Rectangle
& ItemChangeBroadcaster::GetRectangle(sal_uInt32 nIndex
) const
88 return (*((RectangleVector
*)mpData
))[nIndex
];
92 return *((Rectangle
*)mpData
);
95 } // end of namespace properties
96 } // end of namespace sdr
98 //////////////////////////////////////////////////////////////////////////////
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
)
114 SfxWhichIter
aIter(rSet
);
115 sal_uInt16
nWhich(aIter
.FirstWhich());
116 const SfxPoolItem
*pItem
= NULL
;
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
);
129 nWhich
= aIter
.NextWhich();
132 } // end of namespace properties
133 } // end of namespace sdr
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */