diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /svx/source/uitest | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'svx/source/uitest')
-rw-r--r-- | svx/source/uitest/sdrobject.cxx | 206 | ||||
-rw-r--r-- | svx/source/uitest/uiobject.cxx | 104 |
2 files changed, 310 insertions, 0 deletions
diff --git a/svx/source/uitest/sdrobject.cxx b/svx/source/uitest/sdrobject.cxx new file mode 100644 index 000000000..bc72ee2a8 --- /dev/null +++ b/svx/source/uitest/sdrobject.cxx @@ -0,0 +1,206 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <svx/uiobject.hxx> +#include <svx/svdobj.hxx> +#include <svx/SvxColorValueSet.hxx> +#include <tools/fract.hxx> +#include <vcl/window.hxx> +#include <memory> + +SdrUIObject::~SdrUIObject() {} + +StringMap SdrUIObject::get_state() +{ + StringMap aMap; + SdrObject* pObject = get_object(); + + if (!pObject) + return aMap; + + aMap["Name"] = pObject->GetName(); + aMap["Description"] = pObject->GetDescription(); + aMap["Title"] = pObject->GetTitle(); + aMap["Z-Order"] = OUString::number(pObject->GetOrdNum()); + aMap["Layer"] = OUString::number(pObject->GetLayer().get()); + aMap["IsGroupObject"] = OUString::boolean(pObject->IsGroupObject()); + aMap["IsPolyObject"] = OUString::boolean(pObject->IsPolyObj()); + aMap["PointCount"] = OUString::number(pObject->GetPointCount()); + aMap["HasTextEdit"] = OUString::boolean(pObject->HasTextEdit()); + aMap["HasMacro"] = OUString::boolean(pObject->HasMacro()); + aMap["IsClosed"] = OUString::boolean(pObject->IsClosedObj()); + aMap["IsEdgeObject"] = OUString::boolean(pObject->IsEdgeObj()); + aMap["Is3DObject"] = OUString::boolean(pObject->Is3DObj()); + aMap["IsUNOObject"] = OUString::boolean(pObject->IsUnoObj()); + aMap["MoveProtected"] = OUString::boolean(pObject->IsMoveProtect()); + aMap["ResizeProtected"] = OUString::boolean(pObject->IsResizeProtect()); + aMap["Printable"] = OUString::boolean(pObject->IsPrintable()); + aMap["Visible"] = OUString::boolean(pObject->IsVisible()); + aMap["HasText"] = OUString::boolean(pObject->HasText()); + + return aMap; +} + +void SdrUIObject::execute(const OUString& rAction, const StringMap& rParameters) +{ + SdrObject* pObj = get_object(); + if (!pObj) + return; + + if (rAction == "MOVE") + { + auto itrNX = rParameters.find("X"); + if (itrNX == rParameters.end()) + throw css::uno::RuntimeException("missing parameter X"); + + auto itrNY = rParameters.find("Y"); + if (itrNY == rParameters.end()) + throw css::uno::RuntimeException("missing parameter Y"); + + tools::Long nX = itrNX->second.toInt32(); + tools::Long nY = itrNY->second.toInt32(); + Size aMoveRange(nX, nY); + pObj->Move(aMoveRange); + } + else if (rAction == "RESIZE") + { + auto itrNX = rParameters.find("X"); + if (itrNX == rParameters.end()) + throw css::uno::RuntimeException("missing parameter X"); + + auto itrNY = rParameters.find("Y"); + if (itrNY == rParameters.end()) + throw css::uno::RuntimeException("missing parameter Y"); + + tools::Long nX = itrNX->second.toInt32(); + tools::Long nY = itrNY->second.toInt32(); + Point aPos(nX, nY); + + auto itrFracX = rParameters.find("FRAC_X"); + if (itrFracX == rParameters.end()) + throw css::uno::RuntimeException("missing parameter FRAC_X"); + double nFracX = itrFracX->second.toDouble(); + Fraction aFracX(nFracX); + + auto itrFracY = rParameters.find("FRAC_Y"); + if (itrFracY == rParameters.end()) + throw css::uno::RuntimeException("missing parameter FRAC_Y"); + double nFracY = itrFracY->second.toDouble(); + Fraction aFracY(nFracY); + pObj->Resize(aPos, aFracX, aFracY, true /*bRelative*/); + } + else if (rAction == "CROP") + { + // RotateFlyFrame3: Note: Crop does nothing at SdrObject + // anymore, see comment at SdrObject::NbcCrop + auto itrNX = rParameters.find("X"); + if (itrNX == rParameters.end()) + throw css::uno::RuntimeException("missing parameter X"); + + auto itrNY = rParameters.find("Y"); + if (itrNY == rParameters.end()) + throw css::uno::RuntimeException("missing parameter Y"); + + const double fX(itrNX->second.toDouble()); + const double fY(itrNY->second.toDouble()); + const basegfx::B2DPoint aPos(fX, fY); + + auto itrFracX = rParameters.find("FRAC_X"); + if (itrFracX == rParameters.end()) + throw css::uno::RuntimeException("missing parameter FRAC_X"); + const double fFracX(itrFracX->second.toDouble()); + + auto itrFracY = rParameters.find("FRAC_Y"); + if (itrFracY == rParameters.end()) + throw css::uno::RuntimeException("missing parameter FRAC_Y"); + const double fFracY(itrFracY->second.toDouble()); + + pObj->Crop(aPos, fFracX, fFracY); + } + else if (rAction == "ROTATE") + { + auto itrNX = rParameters.find("X"); + if (itrNX == rParameters.end()) + throw css::uno::RuntimeException("missing parameter X"); + + auto itrNY = rParameters.find("Y"); + if (itrNY == rParameters.end()) + throw css::uno::RuntimeException("missing parameter Y"); + + tools::Long nX = itrNX->second.toInt32(); + tools::Long nY = itrNY->second.toInt32(); + Point aPos(nX, nY); + + auto itrAngle = rParameters.find("ANGLE"); + if (itrAngle == rParameters.end()) + throw css::uno::RuntimeException("missing parameter ANGLE"); + + double nAngle = itrAngle->second.toDouble(); + pObj->Rotate(aPos, Degree100(sal_Int32(nAngle)), 0, 0); + } + else if (rAction == "Mirror") + { + pObj->Mirror(Point(), Point()); + } + else if (rAction == "SHEAR") + { + pObj->Shear(Point(), 0_deg100 /*nAngle*/, 0, false); + } +} + +OUString SdrUIObject::get_type() const { return "SdrUIObject"; } + +SvxColorValueSetUIObject::SvxColorValueSetUIObject(vcl::Window* pColorSetWin) + : DrawingAreaUIObject(pColorSetWin) + , mpColorSet(static_cast<SvxColorValueSet*>(mpController)) +{ +} + +void SvxColorValueSetUIObject::execute(const OUString& rAction, const StringMap& rParameters) +{ + if (rAction == "CHOOSE") + { + if (rParameters.find("POS") != rParameters.end()) + { + OUString aIndexStr = rParameters.find("POS")->second; + sal_Int32 nIndex = aIndexStr.toInt32(); + mpColorSet->SelectItem(nIndex); + mpColorSet->Select(); + } + } + else + DrawingAreaUIObject::execute(rAction, rParameters); +} + +std::unique_ptr<UIObject> SvxColorValueSetUIObject::create(vcl::Window* pWindow) +{ + return std::unique_ptr<UIObject>(new SvxColorValueSetUIObject(pWindow)); +} + +OUString SvxColorValueSetUIObject::get_name() const { return "SvxColorValueSetUIObject"; } + +StringMap SvxColorValueSetUIObject::get_state() +{ + StringMap aMap = DrawingAreaUIObject::get_state(); + aMap["CurrColorId"] = OUString::number(mpColorSet->GetSelectedItemId()); + aMap["CurrColorPos"] = OUString::number(mpColorSet->GetSelectItemPos()); + aMap["ColorsCount"] = OUString::number(mpColorSet->GetItemCount()); + aMap["ColCount"] = OUString::number(mpColorSet->GetColCount()); + aMap["ColorText"] = mpColorSet->GetItemText(mpColorSet->GetSelectedItemId()); + Color currColor = mpColorSet->GetItemColor(mpColorSet->GetSelectedItemId()); + aMap["R"] = OUString::number(currColor.GetRed()); + aMap["G"] = OUString::number(currColor.GetGreen()); + aMap["B"] = OUString::number(currColor.GetBlue()); + aMap["RGB"] = "(" + OUString::number(currColor.GetRed()) + "," + + OUString::number(currColor.GetGreen()) + "," + + OUString::number(currColor.GetBlue()) + ")"; + return aMap; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/uitest/uiobject.cxx b/svx/source/uitest/uiobject.cxx new file mode 100644 index 000000000..1c56b9b61 --- /dev/null +++ b/svx/source/uitest/uiobject.cxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <memory> +#include <uiobject.hxx> +#include <svx/charmap.hxx> +#include <svx/numvset.hxx> +#include <vcl/window.hxx> + +SvxShowCharSetUIObject::SvxShowCharSetUIObject(const VclPtr<vcl::Window>& rCharSetWin) + : DrawingAreaUIObject(rCharSetWin) + , mpCharSet(static_cast<SvxShowCharSet*>(mpController)) +{ +} + +void SvxShowCharSetUIObject::execute(const OUString& rAction, + const StringMap& rParameters) +{ + if (rAction == "SELECT") + { + if (rParameters.find("INDEX") != rParameters.end()) + { + OUString aIndexStr = rParameters.find("INDEX")->second; + + sal_Int32 nIndex = aIndexStr.toInt32(); + mpCharSet->OutputIndex(nIndex); + } + else if (rParameters.find("COLUMN") != rParameters.end() && + rParameters.find("ROW") != rParameters.end()) + { + OUString aColStr = rParameters.find("COLUMN")->second; + OUString aRowStr = rParameters.find("ROW")->second; + + sal_Int32 nColumn = aColStr.toInt32(); + sal_Int32 nRow = aRowStr.toInt32(); + + sal_Int32 nIndex = nColumn * COLUMN_COUNT + nRow; + mpCharSet->OutputIndex(nIndex); + } + } + else + WindowUIObject::execute(rAction, rParameters); +} + +std::unique_ptr<UIObject> SvxShowCharSetUIObject::create(vcl::Window* pWindow) +{ + return std::unique_ptr<UIObject>(new SvxShowCharSetUIObject(pWindow)); +} + +OUString SvxShowCharSetUIObject::get_name() const +{ + return "SvxShowCharSetUIObject"; +} + + +SvxNumValueSetUIObject::SvxNumValueSetUIObject(vcl::Window* pNumValueSetWin) + : DrawingAreaUIObject(pNumValueSetWin) + , mpNumValueSet(static_cast<SvxNumValueSet*>(mpController)) +{ +} + +void SvxNumValueSetUIObject::execute(const OUString& rAction, + const StringMap& rParameters) +{ + if (rAction == "CHOOSE") + { + if (rParameters.find("POS") != rParameters.end()) + { + OUString aIndexStr = rParameters.find("POS")->second; + sal_Int32 nIndex = aIndexStr.toInt32(); + mpNumValueSet->SelectItem(nIndex); + mpNumValueSet->Select(); + } + } + else + DrawingAreaUIObject::execute(rAction, rParameters); +} + +std::unique_ptr<UIObject> SvxNumValueSetUIObject::create(vcl::Window* pWindow) +{ + return std::unique_ptr<UIObject>(new SvxNumValueSetUIObject(pWindow)); +} + +OUString SvxNumValueSetUIObject::get_name() const +{ + return "SvxNumValueSetUIObject"; +} + +StringMap SvxNumValueSetUIObject::get_state() +{ + StringMap aMap = WindowUIObject::get_state(); + aMap["SelectedItemId"] = OUString::number( mpNumValueSet->GetSelectedItemId() ); + aMap["SelectedItemPos"] = OUString::number( mpNumValueSet->GetSelectItemPos() ); + aMap["ItemsCount"] = OUString::number(mpNumValueSet->GetItemCount()); + aMap["ItemText"] = mpNumValueSet->GetItemText(mpNumValueSet->GetSelectedItemId()); + return aMap; +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |