tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / svx / source / uitest / sdrobject.cxx
blob0c8d510f4d887f4b699a727cfa3e50637df03401
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/.
8 */
10 #include <svx/uiobject.hxx>
11 #include <svx/svdobj.hxx>
12 #include <svx/SvxColorValueSet.hxx>
13 #include <tools/fract.hxx>
14 #include <vcl/window.hxx>
15 #include <memory>
17 SdrUIObject::~SdrUIObject() {}
19 StringMap SdrUIObject::get_state()
21 StringMap aMap;
22 SdrObject* pObject = get_object();
24 if (!pObject)
25 return aMap;
27 aMap[u"Name"_ustr] = pObject->GetName();
28 aMap[u"Description"_ustr] = pObject->GetDescription();
29 aMap[u"Title"_ustr] = pObject->GetTitle();
30 aMap[u"Z-Order"_ustr] = OUString::number(pObject->GetOrdNum());
31 aMap[u"Layer"_ustr] = OUString::number(pObject->GetLayer().get());
32 aMap[u"IsGroupObject"_ustr] = OUString::boolean(pObject->IsGroupObject());
33 aMap[u"IsPolyObject"_ustr] = OUString::boolean(pObject->IsPolyObj());
34 aMap[u"PointCount"_ustr] = OUString::number(pObject->GetPointCount());
35 aMap[u"HasTextEdit"_ustr] = OUString::boolean(pObject->HasTextEdit());
36 aMap[u"HasMacro"_ustr] = OUString::boolean(pObject->HasMacro());
37 aMap[u"IsClosed"_ustr] = OUString::boolean(pObject->IsClosedObj());
38 aMap[u"IsEdgeObject"_ustr] = OUString::boolean(pObject->IsEdgeObj());
39 aMap[u"Is3DObject"_ustr] = OUString::boolean(pObject->Is3DObj());
40 aMap[u"IsUNOObject"_ustr] = OUString::boolean(pObject->IsUnoObj());
41 aMap[u"MoveProtected"_ustr] = OUString::boolean(pObject->IsMoveProtect());
42 aMap[u"ResizeProtected"_ustr] = OUString::boolean(pObject->IsResizeProtect());
43 aMap[u"Printable"_ustr] = OUString::boolean(pObject->IsPrintable());
44 aMap[u"Visible"_ustr] = OUString::boolean(pObject->IsVisible());
45 aMap[u"HasText"_ustr] = OUString::boolean(pObject->HasText());
47 return aMap;
50 void SdrUIObject::execute(const OUString& rAction, const StringMap& rParameters)
52 SdrObject* pObj = get_object();
53 if (!pObj)
54 return;
56 if (rAction == "MOVE")
58 auto itrNX = rParameters.find(u"X"_ustr);
59 if (itrNX == rParameters.end())
60 throw css::uno::RuntimeException(u"missing parameter X"_ustr);
62 auto itrNY = rParameters.find(u"Y"_ustr);
63 if (itrNY == rParameters.end())
64 throw css::uno::RuntimeException(u"missing parameter Y"_ustr);
66 tools::Long nX = itrNX->second.toInt32();
67 tools::Long nY = itrNY->second.toInt32();
68 Size aMoveRange(nX, nY);
69 pObj->Move(aMoveRange);
71 else if (rAction == "RESIZE")
73 auto itrNX = rParameters.find(u"X"_ustr);
74 if (itrNX == rParameters.end())
75 throw css::uno::RuntimeException(u"missing parameter X"_ustr);
77 auto itrNY = rParameters.find(u"Y"_ustr);
78 if (itrNY == rParameters.end())
79 throw css::uno::RuntimeException(u"missing parameter Y"_ustr);
81 tools::Long nX = itrNX->second.toInt32();
82 tools::Long nY = itrNY->second.toInt32();
83 Point aPos(nX, nY);
85 auto itrFracX = rParameters.find(u"FRAC_X"_ustr);
86 if (itrFracX == rParameters.end())
87 throw css::uno::RuntimeException(u"missing parameter FRAC_X"_ustr);
88 double nFracX = itrFracX->second.toDouble();
89 Fraction aFracX(nFracX);
91 auto itrFracY = rParameters.find(u"FRAC_Y"_ustr);
92 if (itrFracY == rParameters.end())
93 throw css::uno::RuntimeException(u"missing parameter FRAC_Y"_ustr);
94 double nFracY = itrFracY->second.toDouble();
95 Fraction aFracY(nFracY);
96 pObj->Resize(aPos, aFracX, aFracY, true /*bRelative*/);
98 else if (rAction == "CROP")
100 // RotateFlyFrame3: Note: Crop does nothing at SdrObject
101 // anymore, see comment at SdrObject::NbcCrop
102 auto itrNX = rParameters.find(u"X"_ustr);
103 if (itrNX == rParameters.end())
104 throw css::uno::RuntimeException(u"missing parameter X"_ustr);
106 auto itrNY = rParameters.find(u"Y"_ustr);
107 if (itrNY == rParameters.end())
108 throw css::uno::RuntimeException(u"missing parameter Y"_ustr);
110 const double fX(itrNX->second.toDouble());
111 const double fY(itrNY->second.toDouble());
112 const basegfx::B2DPoint aPos(fX, fY);
114 auto itrFracX = rParameters.find(u"FRAC_X"_ustr);
115 if (itrFracX == rParameters.end())
116 throw css::uno::RuntimeException(u"missing parameter FRAC_X"_ustr);
117 const double fFracX(itrFracX->second.toDouble());
119 auto itrFracY = rParameters.find(u"FRAC_Y"_ustr);
120 if (itrFracY == rParameters.end())
121 throw css::uno::RuntimeException(u"missing parameter FRAC_Y"_ustr);
122 const double fFracY(itrFracY->second.toDouble());
124 pObj->Crop(aPos, fFracX, fFracY);
126 else if (rAction == "ROTATE")
128 auto itrNX = rParameters.find(u"X"_ustr);
129 if (itrNX == rParameters.end())
130 throw css::uno::RuntimeException(u"missing parameter X"_ustr);
132 auto itrNY = rParameters.find(u"Y"_ustr);
133 if (itrNY == rParameters.end())
134 throw css::uno::RuntimeException(u"missing parameter Y"_ustr);
136 tools::Long nX = itrNX->second.toInt32();
137 tools::Long nY = itrNY->second.toInt32();
138 Point aPos(nX, nY);
140 auto itrAngle = rParameters.find(u"ANGLE"_ustr);
141 if (itrAngle == rParameters.end())
142 throw css::uno::RuntimeException(u"missing parameter ANGLE"_ustr);
144 double nAngle = itrAngle->second.toDouble();
145 pObj->Rotate(aPos, Degree100(sal_Int32(nAngle)), 0, 0);
147 else if (rAction == "Mirror")
149 pObj->Mirror(Point(), Point());
151 else if (rAction == "SHEAR")
153 pObj->Shear(Point(), 0_deg100 /*nAngle*/, 0, false);
157 OUString SdrUIObject::get_type() const { return u"SdrUIObject"_ustr; }
159 SvxColorValueSetUIObject::SvxColorValueSetUIObject(vcl::Window* pColorSetWin)
160 : DrawingAreaUIObject(pColorSetWin)
161 , mpColorSet(static_cast<SvxColorValueSet*>(mpController))
165 void SvxColorValueSetUIObject::execute(const OUString& rAction, const StringMap& rParameters)
167 if (rAction == "CHOOSE")
169 if (rParameters.find(u"POS"_ustr) != rParameters.end())
171 OUString aIndexStr = rParameters.find(u"POS"_ustr)->second;
172 sal_Int32 nIndex = aIndexStr.toInt32();
173 mpColorSet->SelectItem(nIndex);
174 mpColorSet->Select();
177 else
178 DrawingAreaUIObject::execute(rAction, rParameters);
181 std::unique_ptr<UIObject> SvxColorValueSetUIObject::create(vcl::Window* pWindow)
183 return std::unique_ptr<UIObject>(new SvxColorValueSetUIObject(pWindow));
186 OUString SvxColorValueSetUIObject::get_name() const { return u"SvxColorValueSetUIObject"_ustr; }
188 StringMap SvxColorValueSetUIObject::get_state()
190 StringMap aMap = DrawingAreaUIObject::get_state();
191 aMap[u"CurrColorId"_ustr] = OUString::number(mpColorSet->GetSelectedItemId());
192 aMap[u"CurrColorPos"_ustr] = OUString::number(mpColorSet->GetSelectItemPos());
193 aMap[u"ColorsCount"_ustr] = OUString::number(mpColorSet->GetItemCount());
194 aMap[u"ColCount"_ustr] = OUString::number(mpColorSet->GetColCount());
195 aMap[u"ColorText"_ustr] = mpColorSet->GetItemText(mpColorSet->GetSelectedItemId());
196 Color currColor = mpColorSet->GetItemColor(mpColorSet->GetSelectedItemId());
197 aMap[u"R"_ustr] = OUString::number(currColor.GetRed());
198 aMap[u"G"_ustr] = OUString::number(currColor.GetGreen());
199 aMap[u"B"_ustr] = OUString::number(currColor.GetBlue());
200 aMap[u"RGB"_ustr] = "(" + OUString::number(currColor.GetRed()) + ","
201 + OUString::number(currColor.GetGreen()) + ","
202 + OUString::number(currColor.GetBlue()) + ")";
203 return aMap;
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */