summaryrefslogtreecommitdiff
path: root/sd/source
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-09-30 21:25:37 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-10-01 14:36:52 +0000
commit786971a13adba78072c0ec03101c6c63d76a432f (patch)
treea3885fa9f2c560a33a52f93bb37525dd98584d22 /sd/source
parentd751af3f84909996d44b9354ce9ed34891d374e1 (diff)
add initial drawinglayer support to UI testing framework
Change-Id: Id0450cdf655accb6bd1a50871e83d5c8ecdaab5f Reviewed-on: https://gerrit.libreoffice.org/29417 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sd/source')
-rw-r--r--sd/source/ui/inc/uiobject.hxx6
-rw-r--r--sd/source/ui/uitest/uiobject.cxx120
2 files changed, 78 insertions, 48 deletions
diff --git a/sd/source/ui/inc/uiobject.hxx b/sd/source/ui/inc/uiobject.hxx
index 8e3d4796e83f..66ca0273e575 100644
--- a/sd/source/ui/inc/uiobject.hxx
+++ b/sd/source/ui/inc/uiobject.hxx
@@ -30,6 +30,8 @@ public:
virtual void execute(const OUString& rAction,
const StringMap& rParameters) override;
+ virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
+
virtual std::set<OUString> get_children() const override;
static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
@@ -42,10 +44,6 @@ private:
VclPtr<sd::Window> mxWindow;
- sd::DrawViewShell* getViewShell() const;
-
- SdrObject* getObject(const OUString& rName);
-
SdrPageView* getPageView();
};
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: */