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 <memory>
27
28// class to remember broadcast start positions
29
30namespace sdr::properties
31{
33 {
35 {
36 const SdrObjGroup* pGroupObj = static_cast<const SdrObjGroup*>(&rObj);
38 maRectangles.reserve(aIter.Count());
39
40 while(aIter.IsMore())
41 {
42 SdrObject* pObj = aIter.Next();
43
44 if(pObj)
45 {
46 maRectangles.push_back(pObj->GetLastBoundRect());
47 }
48 }
49 }
50 else
51 {
52 maRectangles.push_back(rObj.GetLastBoundRect());
53 }
54 }
55
56
57 void ScaleItemSet(SfxItemSet& rSet, const Fraction& rScale)
58 {
59 sal_Int32 nMul(rScale.GetNumerator());
60 sal_Int32 nDiv(rScale.GetDenominator());
61
62 if(!rScale.IsValid() || !nDiv)
63 {
64 return;
65 }
66
67 SfxWhichIter aIter(rSet);
68 sal_uInt16 nWhich(aIter.FirstWhich());
69 const SfxPoolItem *pItem = nullptr;
70
71 while(nWhich)
72 {
73 if(SfxItemState::SET == aIter.GetItemState(false, &pItem))
74 {
75 if(pItem->HasMetrics())
76 {
77 std::unique_ptr<SfxPoolItem> pNewItem(pItem->Clone());
78 pNewItem->ScaleMetrics(nMul, nDiv);
79 rSet.Put(std::move(pNewItem));
80 }
81 }
82 nWhich = aIter.NextWhich();
83 }
84 }
85} // end of namespace
86
87/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 GetNumerator() const
sal_Int32 GetDenominator() const
bool IsValid() const
virtual SdrObjList * GetSubList() const override
Definition: svdogrp.cxx:208
size_t Count() const
Definition: svditer.hxx:69
SdrObject * Next()
Definition: svditer.hxx:63
bool IsMore() const
Definition: svditer.hxx:62
Abstract DrawObject.
Definition: svdobj.hxx:260
virtual SdrObjKind GetObjIdentifier() const
Definition: svdobj.cxx:626
virtual const tools::Rectangle & GetLastBoundRect() const
Definition: svdobj.cxx:977
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
virtual bool HasMetrics() const
sal_uInt16 FirstWhich()
SfxItemState GetItemState(bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
sal_uInt16 NextWhich()
ItemChangeBroadcaster(const SdrObject &rObj)
std::vector< tools::Rectangle > maRectangles
void ScaleItemSet(SfxItemSet &rSet, const Fraction &rScale)
static SfxItemSet & rSet
@ Group
abstract object (SdrObject)