diff options
Diffstat (limited to 'sd/source/ui/uitest/uiobject.cxx')
-rw-r--r-- | sd/source/ui/uitest/uiobject.cxx | 120 |
1 files changed, 76 insertions, 44 deletions
diff --git a/sd/source/ui/uitest/uiobject.cxx b/sd/source/ui/uitest/uiobject.cxx index c4be758f082e..b665abc82fd6 100644 --- a/sd/source/ui/uitest/uiobject.cxx +++ b/sd/source/ui/uitest/uiobject.cxx @@ -13,6 +13,71 @@ #include "DrawViewShell.hxx" #include "sdpage.hxx" +#include <svx/uiobject.hxx> + +class ImpressSdrObject : public SdrUIObject +{ +public: + ImpressSdrObject(VclPtr<sd::Window> xImpressWin, const OUString& rName); + + SdrObject* get_object() override; + +private: + VclPtr<sd::Window> mxWindow; + + OUString maName; +}; + +namespace { + +sd::DrawViewShell* getViewShell(VclPtr<sd::Window> xWindow) +{ + sd::DrawViewShell* pViewShell = dynamic_cast<sd::DrawViewShell*>(xWindow->GetViewShell()); + assert(pViewShell); + + return pViewShell; +} + +OUString getObjectName(SdrObject* pObject) +{ + if (pObject->GetName().isEmpty()) + return "Unnamed Drawinglayer object " + OUString::number(pObject->GetOrdNum()); + else + return pObject->GetName(); +} + +SdrObject* getObject(VclPtr<sd::Window> xWindow, const OUString& rName) +{ + SdrPage* pPage = getViewShell(xWindow)->getCurrentPage(); + + if (!pPage) + return nullptr; + + size_t nObjs = pPage->GetObjCount(); + for (size_t i = 0; i < nObjs; ++i) + { + SdrObject* pObj = pPage->GetObj(i); + if (rName == getObjectName(pObj)) + return pObj; + } + + return nullptr; +} + + +} + +ImpressSdrObject::ImpressSdrObject(VclPtr<sd::Window> xImpressWin, const OUString& rName): + mxWindow(xImpressWin), + maName(rName) +{ +} + +SdrObject* ImpressSdrObject::get_object() +{ + return getObject(mxWindow, maName); +} + ImpressWindowUIObject::ImpressWindowUIObject(VclPtr<sd::Window> xWindow): WindowUIObject(xWindow), mxWindow(xWindow) @@ -23,8 +88,8 @@ StringMap ImpressWindowUIObject::get_state() { StringMap aMap = WindowUIObject::get_state(); - aMap["SelectedText"] = getViewShell()->GetSelectionText(false); - aMap["CurrentSlide"] = OUString::number(getViewShell()->GetCurPageId()); + aMap["SelectedText"] = getViewShell(mxWindow)->GetSelectionText(false); + aMap["CurrentSlide"] = OUString::number(getViewShell(mxWindow)->GetCurPageId()); return aMap; } @@ -39,7 +104,7 @@ void ImpressWindowUIObject::execute(const OUString& rAction, auto itr = rParameters.find("ZOOM"); OUString aVal = itr->second; sal_Int32 nVal = aVal.toInt32(); - getViewShell()->SetZoom(nVal); + getViewShell(mxWindow)->SetZoom(nVal); } } else if (rAction == "GOTO") @@ -49,7 +114,7 @@ void ImpressWindowUIObject::execute(const OUString& rAction, auto itr = rParameters.find("PAGE"); OUString aVal = itr->second; sal_Int32 nVal = aVal.toInt32(); - getViewShell()->SwitchPage(nVal); + getViewShell(mxWindow)->SwitchPage(nVal); } } else if (rAction == "SELECT") @@ -58,34 +123,27 @@ void ImpressWindowUIObject::execute(const OUString& rAction, { auto itr = rParameters.find("OBJECT"); OUString aName = itr->second; - SdrObject* pObj = getObject(aName); + SdrObject* pObj = getObject(mxWindow, aName); SdrPageView* pPageView = getPageView(); - getViewShell()->GetView()->MarkObj(pObj, pPageView); + getViewShell(mxWindow)->GetView()->MarkObj(pObj, pPageView); } } else if (rAction == "DESELECT") { - getViewShell()->GetView()->UnMarkAll(); + getViewShell(mxWindow)->GetView()->UnMarkAll(); } else WindowUIObject::execute(rAction, rParameters); } -namespace { - -OUString getObjectName(SdrObject* pObject) +std::unique_ptr<UIObject> ImpressWindowUIObject::get_child(const OUString& rID) { - if (pObject->GetName().isEmpty()) - return "Unnamed Drawinglayer object " + OUString::number(pObject->GetOrdNum()); - else - return pObject->GetName(); -} - + return std::unique_ptr<UIObject>(new ImpressSdrObject(mxWindow, rID)); } std::set<OUString> ImpressWindowUIObject::get_children() const { - SdrPage* pPage = getViewShell()->getCurrentPage(); + SdrPage* pPage = getViewShell(mxWindow)->getCurrentPage(); std::set<OUString> aRet; if (!pPage) @@ -113,35 +171,9 @@ std::unique_ptr<UIObject> ImpressWindowUIObject::create(vcl::Window* pWindow) return std::unique_ptr<UIObject>(new ImpressWindowUIObject(pWin)); } -sd::DrawViewShell* ImpressWindowUIObject::getViewShell() const -{ - sd::DrawViewShell* pViewShell = dynamic_cast<sd::DrawViewShell*>(mxWindow->GetViewShell()); - assert(pViewShell); - - return pViewShell; -} - -SdrObject* ImpressWindowUIObject::getObject(const OUString& rName) -{ - SdrPage* pPage = getViewShell()->getCurrentPage(); - - if (!pPage) - return nullptr; - - size_t nObjs = pPage->GetObjCount(); - for (size_t i = 0; i < nObjs; ++i) - { - SdrObject* pObj = pPage->GetObj(i); - if (rName == getObjectName(pObj)) - return pObj; - } - - return nullptr; -} - SdrPageView* ImpressWindowUIObject::getPageView() { - return getViewShell()->GetView()->GetSdrPageView(); + return getViewShell(mxWindow)->GetView()->GetSdrPageView(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |