1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svx.hxx" 26 #include <svx/sdr/properties/itemsettools.hxx> 27 #include <tools/debug.hxx> 28 #include <svl/itemset.hxx> 29 #include <svl/whiter.hxx> 30 #include <svx/svdogrp.hxx> 31 #include <svx/svditer.hxx> 32 #include <vcl/region.hxx> 33 34 ////////////////////////////////////////////////////////////////////////////// 35 // class to remember broadcast start positions 36 37 namespace sdr 38 { 39 namespace properties 40 { ItemChangeBroadcaster(const SdrObject & rObj)41 ItemChangeBroadcaster::ItemChangeBroadcaster(const SdrObject& rObj) 42 { 43 if(rObj.ISA(SdrObjGroup)) 44 { 45 SdrObjListIter aIter((const SdrObjGroup&)rObj, IM_DEEPNOGROUPS); 46 mpData = new RectangleVector; 47 DBG_ASSERT(mpData, "ItemChangeBroadcaster: No memory (!)"); 48 ((RectangleVector*)mpData)->reserve(aIter.Count()); 49 50 while(aIter.IsMore()) 51 { 52 SdrObject* pObj = aIter.Next(); 53 54 if(pObj) 55 { 56 ((RectangleVector*)mpData)->push_back(pObj->GetLastBoundRect()); 57 } 58 } 59 60 mnCount = ((RectangleVector*)mpData)->size(); 61 } 62 else 63 { 64 mpData = new Rectangle(rObj.GetLastBoundRect()); 65 mnCount = 1L; 66 } 67 } 68 ~ItemChangeBroadcaster()69 ItemChangeBroadcaster::~ItemChangeBroadcaster() 70 { 71 if(mnCount > 1) 72 { 73 delete ((RectangleVector*)mpData); 74 } 75 else 76 { 77 delete ((Rectangle*)mpData); 78 } 79 } 80 GetRectangleCount() const81 sal_uInt32 ItemChangeBroadcaster::GetRectangleCount() const 82 { 83 return mnCount; 84 } 85 GetRectangle(sal_uInt32 nIndex) const86 const Rectangle& ItemChangeBroadcaster::GetRectangle(sal_uInt32 nIndex) const 87 { 88 if(mnCount > 1) 89 { 90 return (*((RectangleVector*)mpData))[nIndex]; 91 } 92 else 93 { 94 return *((Rectangle*)mpData); 95 } 96 } 97 } // end of namespace properties 98 } // end of namespace sdr 99 100 ////////////////////////////////////////////////////////////////////////////// 101 102 namespace sdr 103 { 104 namespace properties 105 { ScaleItemSet(SfxItemSet & rSet,const Fraction & rScale)106 void ScaleItemSet(SfxItemSet& rSet, const Fraction& rScale) 107 { 108 sal_Int32 nMul(rScale.GetNumerator()); 109 sal_Int32 nDiv(rScale.GetDenominator()); 110 111 if(!rScale.IsValid() || !nDiv) 112 { 113 return; 114 } 115 116 SfxWhichIter aIter(rSet); 117 sal_uInt16 nWhich(aIter.FirstWhich()); 118 const SfxPoolItem *pItem = NULL; 119 120 while(nWhich) 121 { 122 if(SFX_ITEM_SET == rSet.GetItemState(nWhich, sal_False, &pItem)) 123 { 124 if(pItem->HasMetrics()) 125 { 126 SfxPoolItem* pNewItem = pItem->Clone(); 127 pNewItem->ScaleMetrics(nMul, nDiv); 128 rSet.Put(*pNewItem); 129 } 130 } 131 nWhich = aIter.NextWhich(); 132 } 133 } 134 } // end of namespace properties 135 } // end of namespace sdr 136 137 ////////////////////////////////////////////////////////////////////////////// 138 // eof 139