LibreOffice Module svx (master) 1
sdrobject.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
10#include <svx/uiobject.hxx>
11#include <svx/svdobj.hxx>
13#include <tools/fract.hxx>
14#include <vcl/window.hxx>
15#include <memory>
16
18
20{
23
24 if (!pObject)
25 return aMap;
26
27 aMap["Name"] = pObject->GetName();
28 aMap["Description"] = pObject->GetDescription();
29 aMap["Title"] = pObject->GetTitle();
30 aMap["Z-Order"] = OUString::number(pObject->GetOrdNum());
31 aMap["Layer"] = OUString::number(pObject->GetLayer().get());
32 aMap["IsGroupObject"] = OUString::boolean(pObject->IsGroupObject());
33 aMap["IsPolyObject"] = OUString::boolean(pObject->IsPolyObj());
34 aMap["PointCount"] = OUString::number(pObject->GetPointCount());
35 aMap["HasTextEdit"] = OUString::boolean(pObject->HasTextEdit());
36 aMap["HasMacro"] = OUString::boolean(pObject->HasMacro());
37 aMap["IsClosed"] = OUString::boolean(pObject->IsClosedObj());
38 aMap["IsEdgeObject"] = OUString::boolean(pObject->IsEdgeObj());
39 aMap["Is3DObject"] = OUString::boolean(pObject->Is3DObj());
40 aMap["IsUNOObject"] = OUString::boolean(pObject->IsUnoObj());
41 aMap["MoveProtected"] = OUString::boolean(pObject->IsMoveProtect());
42 aMap["ResizeProtected"] = OUString::boolean(pObject->IsResizeProtect());
43 aMap["Printable"] = OUString::boolean(pObject->IsPrintable());
44 aMap["Visible"] = OUString::boolean(pObject->IsVisible());
45 aMap["HasText"] = OUString::boolean(pObject->HasText());
46
47 return aMap;
48}
49
50void SdrUIObject::execute(const OUString& rAction, const StringMap& rParameters)
51{
52 SdrObject* pObj = get_object();
53 if (!pObj)
54 return;
55
56 if (rAction == "MOVE")
57 {
58 auto itrNX = rParameters.find("X");
59 if (itrNX == rParameters.end())
60 throw css::uno::RuntimeException("missing parameter X");
61
62 auto itrNY = rParameters.find("Y");
63 if (itrNY == rParameters.end())
64 throw css::uno::RuntimeException("missing parameter Y");
65
66 tools::Long nX = itrNX->second.toInt32();
67 tools::Long nY = itrNY->second.toInt32();
68 Size aMoveRange(nX, nY);
69 pObj->Move(aMoveRange);
70 }
71 else if (rAction == "RESIZE")
72 {
73 auto itrNX = rParameters.find("X");
74 if (itrNX == rParameters.end())
75 throw css::uno::RuntimeException("missing parameter X");
76
77 auto itrNY = rParameters.find("Y");
78 if (itrNY == rParameters.end())
79 throw css::uno::RuntimeException("missing parameter Y");
80
81 tools::Long nX = itrNX->second.toInt32();
82 tools::Long nY = itrNY->second.toInt32();
83 Point aPos(nX, nY);
84
85 auto itrFracX = rParameters.find("FRAC_X");
86 if (itrFracX == rParameters.end())
87 throw css::uno::RuntimeException("missing parameter FRAC_X");
88 double nFracX = itrFracX->second.toDouble();
89 Fraction aFracX(nFracX);
90
91 auto itrFracY = rParameters.find("FRAC_Y");
92 if (itrFracY == rParameters.end())
93 throw css::uno::RuntimeException("missing parameter FRAC_Y");
94 double nFracY = itrFracY->second.toDouble();
95 Fraction aFracY(nFracY);
96 pObj->Resize(aPos, aFracX, aFracY, true /*bRelative*/);
97 }
98 else if (rAction == "CROP")
99 {
100 // RotateFlyFrame3: Note: Crop does nothing at SdrObject
101 // anymore, see comment at SdrObject::NbcCrop
102 auto itrNX = rParameters.find("X");
103 if (itrNX == rParameters.end())
104 throw css::uno::RuntimeException("missing parameter X");
105
106 auto itrNY = rParameters.find("Y");
107 if (itrNY == rParameters.end())
108 throw css::uno::RuntimeException("missing parameter Y");
109
110 const double fX(itrNX->second.toDouble());
111 const double fY(itrNY->second.toDouble());
112 const basegfx::B2DPoint aPos(fX, fY);
113
114 auto itrFracX = rParameters.find("FRAC_X");
115 if (itrFracX == rParameters.end())
116 throw css::uno::RuntimeException("missing parameter FRAC_X");
117 const double fFracX(itrFracX->second.toDouble());
118
119 auto itrFracY = rParameters.find("FRAC_Y");
120 if (itrFracY == rParameters.end())
121 throw css::uno::RuntimeException("missing parameter FRAC_Y");
122 const double fFracY(itrFracY->second.toDouble());
123
124 pObj->Crop(aPos, fFracX, fFracY);
125 }
126 else if (rAction == "ROTATE")
127 {
128 auto itrNX = rParameters.find("X");
129 if (itrNX == rParameters.end())
130 throw css::uno::RuntimeException("missing parameter X");
131
132 auto itrNY = rParameters.find("Y");
133 if (itrNY == rParameters.end())
134 throw css::uno::RuntimeException("missing parameter Y");
135
136 tools::Long nX = itrNX->second.toInt32();
137 tools::Long nY = itrNY->second.toInt32();
138 Point aPos(nX, nY);
139
140 auto itrAngle = rParameters.find("ANGLE");
141 if (itrAngle == rParameters.end())
142 throw css::uno::RuntimeException("missing parameter ANGLE");
143
144 double nAngle = itrAngle->second.toDouble();
145 pObj->Rotate(aPos, Degree100(sal_Int32(nAngle)), 0, 0);
146 }
147 else if (rAction == "Mirror")
148 {
149 pObj->Mirror(Point(), Point());
150 }
151 else if (rAction == "SHEAR")
152 {
153 pObj->Shear(Point(), 0_deg100 /*nAngle*/, 0, false);
154 }
155}
156
157OUString SdrUIObject::get_type() const { return "SdrUIObject"; }
158
160 : DrawingAreaUIObject(pColorSetWin)
161 , mpColorSet(static_cast<SvxColorValueSet*>(mpController))
162{
163}
164
165void SvxColorValueSetUIObject::execute(const OUString& rAction, const StringMap& rParameters)
166{
167 if (rAction == "CHOOSE")
168 {
169 if (rParameters.find("POS") != rParameters.end())
170 {
171 OUString aIndexStr = rParameters.find("POS")->second;
172 sal_Int32 nIndex = aIndexStr.toInt32();
175 }
176 }
177 else
178 DrawingAreaUIObject::execute(rAction, rParameters);
179}
180
181std::unique_ptr<UIObject> SvxColorValueSetUIObject::create(vcl::Window* pWindow)
182{
183 return std::unique_ptr<UIObject>(new SvxColorValueSetUIObject(pWindow));
184}
185
186OUString SvxColorValueSetUIObject::get_name() const { return "SvxColorValueSetUIObject"; }
187
189{
191 aMap["CurrColorId"] = OUString::number(mpColorSet->GetSelectedItemId());
192 aMap["CurrColorPos"] = OUString::number(mpColorSet->GetSelectItemPos());
193 aMap["ColorsCount"] = OUString::number(mpColorSet->GetItemCount());
194 aMap["ColCount"] = OUString::number(mpColorSet->GetColCount());
197 aMap["R"] = OUString::number(currColor.GetRed());
198 aMap["G"] = OUString::number(currColor.GetGreen());
199 aMap["B"] = OUString::number(currColor.GetBlue());
200 aMap["RGB"] = "(" + OUString::number(currColor.GetRed()) + ","
201 + OUString::number(currColor.GetGreen()) + ","
202 + OUString::number(currColor.GetBlue()) + ")";
203 return aMap;
204}
205
206/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt8 GetBlue() const
sal_uInt8 GetRed() const
sal_uInt8 GetGreen() const
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Abstract DrawObject.
Definition: svdobj.hxx:261
virtual void Crop(const basegfx::B2DPoint &rRef, double fxFact, double fyFact)
Definition: svdobj.cxx:1570
virtual void Shear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear)
Definition: svdobj.cxx:1599
virtual void Mirror(const Point &rRef1, const Point &rRef2)
Definition: svdobj.cxx:1590
virtual void Move(const Size &rSiz)
Definition: svdobj.cxx:1534
virtual void Rotate(const Point &rRef, Degree100 nAngle, double sn, double cs)
Definition: svdobj.cxx:1579
virtual void Resize(const Point &rRef, const Fraction &xFact, const Fraction &yFact, bool bUnsetRelative=true)
Definition: svdobj.cxx:1551
virtual ~SdrUIObject() override
Definition: sdrobject.cxx:17
virtual SdrObject * get_object()=0
virtual OUString get_type() const override
Definition: sdrobject.cxx:157
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Definition: sdrobject.cxx:50
virtual StringMap get_state() override
Definition: sdrobject.cxx:19
virtual StringMap get_state() override
Definition: sdrobject.cxx:188
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Definition: sdrobject.cxx:165
OUString get_name() const override
Definition: sdrobject.cxx:186
SvxColorValueSetUIObject(vcl::Window *pColorSetWin)
Definition: sdrobject.cxx:159
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
Definition: sdrobject.cxx:181
size_t GetItemCount() const
OUString GetItemText(sal_uInt16 nItemId) const
void SelectItem(sal_uInt16 nItemId)
sal_uInt16 GetSelectedItemId() const
virtual void Select()
Color GetItemColor(sal_uInt16 nItemId) const
sal_uInt16 GetColCount() const
size_t GetSelectItemPos() const
virtual StringMap get_state() override
EmbeddedObjectRef * pObject
sal_Int32 nIndex
long Long
HashMap_OWString_Interface aMap
SvxTableController * mpController
std::map< OUString, OUString > StringMap