summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-09-17 10:18:23 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2020-09-22 13:10:17 +0200
commita22a6cb8c3afdd7db3a5d23c64cd2f20d4fbd291 (patch)
tree02cf38b3e0cc877ed27b2cd2b388ba478e61659e
parentAdded new command to delete the comment thread (diff)
downloadcore-a22a6cb8c3afdd7db3a5d23c64cd2f20d4fbd291.tar.gz
core-a22a6cb8c3afdd7db3a5d23c64cd2f20d4fbd291.zip
jsdialog: use window only if visible
When there is a name conflict we should take currently visible window. Change-Id: Iaccf03a78b083ecaca0ee6aa538674a6de093a4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102903 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103142
-rw-r--r--desktop/source/lib/init.cxx2
-rw-r--r--include/vcl/uitest/uiobject.hxx2
-rw-r--r--vcl/source/uitest/uiobject.cxx33
3 files changed, 31 insertions, 6 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 91613147b624..d6cd2f3fb9ce 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3748,7 +3748,7 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned long
if (!bIsWeldedDialog)
{
WindowUIObject aUIObject(pWindow);
- std::unique_ptr<UIObject> pUIWindow(aUIObject.get_child(aMap["id"]));
+ std::unique_ptr<UIObject> pUIWindow(aUIObject.get_visible_child(aMap["id"]));
if (pUIWindow) {
bool bIsClickAction = false;
diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx
index 43035e2fa39e..60d84dedbe24 100644
--- a/include/vcl/uitest/uiobject.hxx
+++ b/include/vcl/uitest/uiobject.hxx
@@ -119,6 +119,8 @@ public:
virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
+ virtual std::unique_ptr<UIObject> get_visible_child(const OUString& rID);
+
virtual std::set<OUString> get_children() const override;
virtual OUString dumpState() const override;
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index f2361fad3965..3d6242697066 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -381,7 +381,7 @@ OUString WindowUIObject::get_type() const
namespace {
-vcl::Window* findChild(vcl::Window* pParent, const OUString& rID)
+vcl::Window* findChild(vcl::Window* pParent, const OUString& rID, bool bRequireVisible = false)
{
if (!pParent)
return nullptr;
@@ -393,12 +393,16 @@ vcl::Window* findChild(vcl::Window* pParent, const OUString& rID)
for (size_t i = 0; i < nCount; ++i)
{
vcl::Window* pChild = pParent->GetChild(i);
- if (pChild && pChild->get_id() == rID)
+ if (pChild && pChild->get_id() == rID
+ && (!bRequireVisible || pChild->IsVisible()))
return pChild;
- vcl::Window* pResult = findChild(pChild, rID);
- if (pResult)
- return pResult;
+ if (!bRequireVisible || pChild->IsVisible())
+ {
+ vcl::Window* pResult = findChild(pChild, rID);
+ if (pResult)
+ return pResult;
+ }
}
return nullptr;
@@ -448,6 +452,25 @@ std::unique_ptr<UIObject> WindowUIObject::get_child(const OUString& rID)
return aFunction(pWindow);
}
+std::unique_ptr<UIObject> WindowUIObject::get_visible_child(const OUString& rID)
+{
+ // in a first step try the real children before moving to the top level parent
+ // This makes it easier to handle cases with the same ID as there is a way
+ // to resolve conflicts
+ vcl::Window* pWindow = findChild(mxWindow.get(), rID, true);
+ if (!pWindow)
+ {
+ vcl::Window* pDialogParent = get_top_parent(mxWindow.get());
+ pWindow = findChild(pDialogParent, rID, true);
+ }
+
+ if (!pWindow)
+ throw css::uno::RuntimeException("Could not find child with id: " + rID);
+
+ FactoryFunction aFunction = pWindow->GetUITestFactory();
+ return aFunction(pWindow);
+}
+
std::set<OUString> WindowUIObject::get_children() const
{
vcl::Window* pDialogParent = get_top_parent(mxWindow.get());