include/svx/uiobject.hxx | 4 ++-- include/vcl/uitest/uiobject.hxx | 12 ++++++++++++ starmath/source/uiobject.cxx | 13 +++++-------- starmath/source/uiobject.hxx | 4 ++-- svtools/inc/uiobject.hxx | 6 +++--- svtools/source/uitest/uiobject.cxx | 18 +++++++----------- svx/inc/uiobject.hxx | 8 ++++---- svx/source/dialog/weldeditview.cxx | 14 +++++--------- svx/source/uitest/sdrobject.cxx | 15 ++++++--------- svx/source/uitest/uiobject.cxx | 23 +++++++++-------------- vcl/source/uitest/uiobject.cxx | 12 ++++++++++++ 11 files changed, 67 insertions(+), 62 deletions(-)
New commits: commit d3fff9073f70bdd9caf619a9cfe7afd7c04cffe1 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Oct 15 11:07:10 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Oct 16 12:55:07 2020 +0200 add a DrawingAreaUIObject to avoid need to include layout.hxx for uitest Change-Id: I2d7f9d38f9eac5af7b8b4d738335507beb6627df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104357 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/svx/uiobject.hxx b/include/svx/uiobject.hxx index de47586f74c9..4fd63c9d0d05 100644 --- a/include/svx/uiobject.hxx +++ b/include/svx/uiobject.hxx @@ -35,13 +35,13 @@ public: virtual SdrObject* get_object() = 0; }; -class SvxColorValueSetUIObject final : public WindowUIObject +class SvxColorValueSetUIObject final : public DrawingAreaUIObject { SvxColorValueSet* mpColorSet; public: - SvxColorValueSetUIObject(vcl::Window* xColorSetWin, SvxColorValueSet* pColorSet); + SvxColorValueSetUIObject(vcl::Window* pColorSetWin); virtual void execute(const OUString& rAction, const StringMap& rParameters) override; diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx index 750226d20be0..8f8be274b3a9 100644 --- a/include/vcl/uitest/uiobject.hxx +++ b/include/vcl/uitest/uiobject.hxx @@ -33,9 +33,11 @@ class SvTreeListEntry; class SpinButton; class SpinField; class VerticalTabControl; +class VclDrawingArea; class VclMultiLineEdit; class MenuButton; class ToolBox; +namespace weld { class CustomWidgetController; } typedef std::map<const OUString, OUString> StringMap; @@ -529,6 +531,16 @@ private: virtual OUString get_name() const override; }; +class UITEST_DLLPUBLIC DrawingAreaUIObject : public WindowUIObject +{ +private: + VclPtr<VclDrawingArea> mxDrawingArea; +protected: + weld::CustomWidgetController* mpController; +public: + DrawingAreaUIObject(const VclPtr<vcl::Window>& rDrawingArea); + virtual ~DrawingAreaUIObject() override; +}; #endif diff --git a/starmath/source/uiobject.cxx b/starmath/source/uiobject.cxx index a6f0c47cbd9b..5d7519816e52 100644 --- a/starmath/source/uiobject.cxx +++ b/starmath/source/uiobject.cxx @@ -9,7 +9,6 @@ #include <memory> #include "uiobject.hxx" -#include <vcl/layout.hxx> #include <ElementsDockingWindow.hxx> ElementUIObject::ElementUIObject(SmElementsControl* pElementSelector, @@ -52,15 +51,15 @@ void ElementUIObject::execute(const OUString& rAction, } } -ElementSelectorUIObject::ElementSelectorUIObject(vcl::Window* pElementSelectorWindow, SmElementsControl* pElementSelector) - : WindowUIObject(pElementSelectorWindow) - , mpElementsSelector(pElementSelector) +ElementSelectorUIObject::ElementSelectorUIObject(vcl::Window* pElementSelectorWindow) + : DrawingAreaUIObject(pElementSelectorWindow) + , mpElementsSelector(static_cast<SmElementsControl*>(mpController)) { } StringMap ElementSelectorUIObject::get_state() { - StringMap aMap = WindowUIObject::get_state(); + StringMap aMap = DrawingAreaUIObject::get_state(); SmElement* pElement = mpElementsSelector->current(); if (pElement) @@ -96,9 +95,7 @@ std::set<OUString> ElementSelectorUIObject::get_children() const std::unique_ptr<UIObject> ElementSelectorUIObject::create(vcl::Window* pWindow) { - VclDrawingArea* pSmElementsWin = dynamic_cast<VclDrawingArea*>(pWindow); - assert(pSmElementsWin); - return std::unique_ptr<UIObject>(new ElementSelectorUIObject(pSmElementsWin, static_cast<SmElementsControl*>(pSmElementsWin->GetUserData()))); + return std::unique_ptr<UIObject>(new ElementSelectorUIObject(pWindow)); } OUString ElementSelectorUIObject::get_name() const diff --git a/starmath/source/uiobject.hxx b/starmath/source/uiobject.hxx index 607c9194c85d..e6132ff772a8 100644 --- a/starmath/source/uiobject.hxx +++ b/starmath/source/uiobject.hxx @@ -35,14 +35,14 @@ private: SmElement* get_element(); }; -class ElementSelectorUIObject : public WindowUIObject +class ElementSelectorUIObject : public DrawingAreaUIObject { private: SmElementsControl* mpElementsSelector; public: - explicit ElementSelectorUIObject(vcl::Window* pElementSelectorWindow, SmElementsControl* pElementSelector); + explicit ElementSelectorUIObject(vcl::Window* pElementSelectorWindow); virtual StringMap get_state() override; diff --git a/svtools/inc/uiobject.hxx b/svtools/inc/uiobject.hxx index a27b6d68fdad..b201555179c4 100644 --- a/svtools/inc/uiobject.hxx +++ b/svtools/inc/uiobject.hxx @@ -16,12 +16,12 @@ class ValueSet; -class ValueSetUIObject final : public WindowUIObject +class ValueSetUIObject final : public DrawingAreaUIObject { ValueSet* mpSet; public: - ValueSetUIObject(const VclPtr<vcl::Window>& xSetWin, ValueSet* pSet); + ValueSetUIObject(const VclPtr<vcl::Window>& xSetWin); virtual void execute(const OUString& rAction, const StringMap& rParameters) override; @@ -35,4 +35,4 @@ private: #endif // INCLUDED_SVX_INC_UIOBJECT_HXX -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/uitest/uiobject.cxx b/svtools/source/uitest/uiobject.cxx index db593581d6c2..0b3d78daf7b0 100644 --- a/svtools/source/uitest/uiobject.cxx +++ b/svtools/source/uitest/uiobject.cxx @@ -10,11 +10,10 @@ #include <memory> #include <uiobject.hxx> #include <svtools/valueset.hxx> -#include <vcl/layout.hxx> -ValueSetUIObject::ValueSetUIObject(const VclPtr<vcl::Window>& xSetWin, ValueSet* pSet) - : WindowUIObject(xSetWin) - , mpSet(pSet) +ValueSetUIObject::ValueSetUIObject(const VclPtr<vcl::Window>& rSetWin) + : DrawingAreaUIObject(rSetWin) + , mpSet(static_cast<ValueSet*>(mpController)) { } @@ -32,26 +31,23 @@ void ValueSetUIObject::execute(const OUString& rAction, const StringMap& rParame } } else - WindowUIObject::execute(rAction, rParameters); + DrawingAreaUIObject::execute(rAction, rParameters); } std::unique_ptr<UIObject> ValueSetUIObject::create(vcl::Window* pWindow) { - VclDrawingArea* pSetWin = dynamic_cast<VclDrawingArea*>(pWindow); - assert(pSetWin); - return std::unique_ptr<UIObject>( - new ValueSetUIObject(pSetWin, static_cast<ValueSet*>(pSetWin->GetUserData()))); + return std::unique_ptr<UIObject>(new ValueSetUIObject(pWindow)); } OUString ValueSetUIObject::get_name() const { return "ValueSetUIObject"; } StringMap ValueSetUIObject::get_state() { - StringMap aMap = WindowUIObject::get_state(); + StringMap aMap = DrawingAreaUIObject::get_state(); aMap["SelectedItemId"] = OUString::number(mpSet->GetSelectedItemId()); aMap["SelectedItemPos"] = OUString::number(mpSet->GetSelectItemPos()); aMap["ItemsCount"] = OUString::number(mpSet->GetItemCount()); return aMap; } -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/inc/uiobject.hxx b/svx/inc/uiobject.hxx index 405b854e1f06..34659619cf83 100644 --- a/svx/inc/uiobject.hxx +++ b/svx/inc/uiobject.hxx @@ -17,12 +17,12 @@ class SvxShowCharSet; class SvxNumValueSet; -class SvxShowCharSetUIObject final : public WindowUIObject +class SvxShowCharSetUIObject final : public DrawingAreaUIObject { SvxShowCharSet* mpCharSet; public: - SvxShowCharSetUIObject(const VclPtr<vcl::Window>& xCharSetWin, SvxShowCharSet* pCharSet); + SvxShowCharSetUIObject(const VclPtr<vcl::Window>& rCharSetWin); virtual void execute(const OUString& rAction, const StringMap& rParameters) override; @@ -35,13 +35,13 @@ private: }; -class SvxNumValueSetUIObject final : public WindowUIObject +class SvxNumValueSetUIObject final : public DrawingAreaUIObject { SvxNumValueSet* mpNumValueSet; public: - SvxNumValueSetUIObject(vcl::Window* xNumValueSetWin, SvxNumValueSet* pNumValueSet); + SvxNumValueSetUIObject(vcl::Window* pNumValueSetWin); virtual void execute(const OUString& rAction, const StringMap& rParameters) override; diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx index 9f4329b7adfd..9bf6f599c857 100644 --- a/svx/source/dialog/weldeditview.cxx +++ b/svx/source/dialog/weldeditview.cxx @@ -40,7 +40,6 @@ #include <unotools/accessiblestatesethelper.hxx> #include <vcl/cursor.hxx> #include <vcl/event.hxx> -#include <vcl/layout.hxx> #include <vcl/ptrstyle.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> @@ -1499,24 +1498,21 @@ void WeldEditView::LoseFocus() namespace { -class WeldEditViewUIObject final : public WindowUIObject +class WeldEditViewUIObject final : public DrawingAreaUIObject { private: WeldEditView* mpEditView; public: - WeldEditViewUIObject(vcl::Window* pEditViewWin, WeldEditView* pEditView) - : WindowUIObject(pEditViewWin) - , mpEditView(pEditView) + WeldEditViewUIObject(const VclPtr<vcl::Window>& rDrawingArea) + : DrawingAreaUIObject(rDrawingArea) + , mpEditView(static_cast<WeldEditView*>(mpController)) { } static std::unique_ptr<UIObject> create(vcl::Window* pWindow) { - VclDrawingArea* pEditViewWin = dynamic_cast<VclDrawingArea*>(pWindow); - assert(pEditViewWin); - return std::unique_ptr<UIObject>(new WeldEditViewUIObject( - pEditViewWin, static_cast<WeldEditView*>(pEditViewWin->GetUserData()))); + return std::unique_ptr<UIObject>(new WeldEditViewUIObject(pWindow)); } virtual StringMap get_state() override diff --git a/svx/source/uitest/sdrobject.cxx b/svx/source/uitest/sdrobject.cxx index b93223acc319..d88ce6494c19 100644 --- a/svx/source/uitest/sdrobject.cxx +++ b/svx/source/uitest/sdrobject.cxx @@ -15,7 +15,6 @@ #include <memory> #include <svx/SvxColorValueSet.hxx> -#include <vcl/layout.hxx> SdrUIObject::~SdrUIObject() { @@ -166,9 +165,9 @@ OUString SdrUIObject::get_type() const } -SvxColorValueSetUIObject::SvxColorValueSetUIObject(vcl::Window* xColorSetWin, SvxColorValueSet* pColorSet): - WindowUIObject(xColorSetWin), - mpColorSet(pColorSet) +SvxColorValueSetUIObject::SvxColorValueSetUIObject(vcl::Window* pColorSetWin) + : DrawingAreaUIObject(pColorSetWin) + , mpColorSet(static_cast<SvxColorValueSet*>(mpController)) { } @@ -186,14 +185,12 @@ void SvxColorValueSetUIObject::execute(const OUString& rAction, } } else - WindowUIObject::execute(rAction, rParameters); + DrawingAreaUIObject::execute(rAction, rParameters); } std::unique_ptr<UIObject> SvxColorValueSetUIObject::create(vcl::Window* pWindow) { - VclDrawingArea* pColorSetWin = dynamic_cast<VclDrawingArea*>(pWindow); - assert(pColorSetWin); - return std::unique_ptr<UIObject>(new SvxColorValueSetUIObject(pColorSetWin, static_cast<SvxColorValueSet*>(pColorSetWin->GetUserData()))); + return std::unique_ptr<UIObject>(new SvxColorValueSetUIObject(pWindow)); } OUString SvxColorValueSetUIObject::get_name() const @@ -203,7 +200,7 @@ OUString SvxColorValueSetUIObject::get_name() const StringMap SvxColorValueSetUIObject::get_state() { - StringMap aMap = WindowUIObject::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()); diff --git a/svx/source/uitest/uiobject.cxx b/svx/source/uitest/uiobject.cxx index 046cece582ca..9c46d0993441 100644 --- a/svx/source/uitest/uiobject.cxx +++ b/svx/source/uitest/uiobject.cxx @@ -10,13 +10,12 @@ #include <memory> #include <uiobject.hxx> #include <svx/charmap.hxx> -#include <vcl/layout.hxx> #include <svx/numvset.hxx> -SvxShowCharSetUIObject::SvxShowCharSetUIObject(const VclPtr<vcl::Window>& xCharSetWin, SvxShowCharSet* pCharSet): - WindowUIObject(xCharSetWin), - mpCharSet(pCharSet) +SvxShowCharSetUIObject::SvxShowCharSetUIObject(const VclPtr<vcl::Window>& rCharSetWin) + : DrawingAreaUIObject(rCharSetWin) + , mpCharSet(static_cast<SvxShowCharSet*>(mpController)) { } @@ -51,9 +50,7 @@ void SvxShowCharSetUIObject::execute(const OUString& rAction, std::unique_ptr<UIObject> SvxShowCharSetUIObject::create(vcl::Window* pWindow) { - VclDrawingArea* pCharSetWin = dynamic_cast<VclDrawingArea*>(pWindow); - assert(pCharSetWin); - return std::unique_ptr<UIObject>(new SvxShowCharSetUIObject(pCharSetWin, static_cast<SvxShowCharSet*>(pCharSetWin->GetUserData()))); + return std::unique_ptr<UIObject>(new SvxShowCharSetUIObject(pWindow)); } OUString SvxShowCharSetUIObject::get_name() const @@ -62,9 +59,9 @@ OUString SvxShowCharSetUIObject::get_name() const } -SvxNumValueSetUIObject::SvxNumValueSetUIObject(vcl::Window* xNumValueSetWin , SvxNumValueSet* pNumValueSet): - WindowUIObject(xNumValueSetWin), - mpNumValueSet(pNumValueSet) +SvxNumValueSetUIObject::SvxNumValueSetUIObject(vcl::Window* pNumValueSetWin) + : DrawingAreaUIObject(pNumValueSetWin) + , mpNumValueSet(static_cast<SvxNumValueSet*>(mpController)) { } @@ -82,14 +79,12 @@ void SvxNumValueSetUIObject::execute(const OUString& rAction, } } else - WindowUIObject::execute(rAction, rParameters); + DrawingAreaUIObject::execute(rAction, rParameters); } std::unique_ptr<UIObject> SvxNumValueSetUIObject::create(vcl::Window* pWindow) { - VclDrawingArea* pNumValueSetWin = dynamic_cast<VclDrawingArea*>(pWindow); - assert(pNumValueSetWin); - return std::unique_ptr<UIObject>(new SvxNumValueSetUIObject(pNumValueSetWin, static_cast<SvxNumValueSet*>(pNumValueSetWin->GetUserData()))); + return std::unique_ptr<UIObject>(new SvxNumValueSetUIObject(pWindow)); } OUString SvxNumValueSetUIObject::get_name() const diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx index b768a80622d0..66211612adc0 100644 --- a/vcl/source/uitest/uiobject.cxx +++ b/vcl/source/uitest/uiobject.cxx @@ -1706,4 +1706,16 @@ std::unique_ptr<UIObject> MenuButtonUIObject::create(vcl::Window* pWindow) return std::unique_ptr<UIObject>(new MenuButtonUIObject(pMenuButton)); } +DrawingAreaUIObject::DrawingAreaUIObject(const VclPtr<vcl::Window>& rDrawingArea) + : WindowUIObject(rDrawingArea) + , mxDrawingArea(dynamic_cast<VclDrawingArea*>(rDrawingArea.get())) +{ + assert(mxDrawingArea); + mpController = static_cast<weld::CustomWidgetController*>(mxDrawingArea->GetUserData()); +} + +DrawingAreaUIObject::~DrawingAreaUIObject() +{ +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits