include/vcl/toolkit/treelistbox.hxx | 1 + sw/qa/uitest/writer_tests2/bookmark.py | 30 ++++++++++++++++++++++++++++++ vcl/source/treelist/treelistbox.cxx | 6 ++++++ vcl/source/treelist/uiobject.cxx | 13 +++++++++++++ 4 files changed, 50 insertions(+)
New commits: commit a89b221afe2d2d8aa670236fce6e95022ffa1cd9 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Tue Jul 26 12:12:49 2022 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Jul 26 20:16:17 2022 +0200 tdf#150017 vcl,sw: add UITest Unfortunately i couldn't figure out how to send keyboard input to the Edit widget in the SvTreeListBox; it's created by SvTreeListBox::EditText() and shows up when calling dumpHierarchy() on the DialogUIObject as a child of the SvTreeListBox/"19LclHeaderTabListBox" but the execute() doesn't send it events, neither when called on DialogUIObject nor on TreeListUIObject. So forward explicitly in TreeListUIObject::execute() - probably not the best way to do this? When using the UI, events arrive like this: 0 SvInplaceEdit2::KeyInput(KeyEvent const&) at vcl/source/treelist/treelistbox.cxx:202 1 (anonymous namespace)::MyEdit_Impl::KeyInput(KeyEvent const&) at vcl/source/treelist/treelistbox.cxx:117 2 ImplHandleKey(vcl::Window*, MouseNotifyEvent, sal_uInt16, sal_uInt16, sal_uInt16, bool) (pWindow=0x6dc4bc0, nSVEvent=MouseNotifyEvent::KEYINPUT, nKeyCode=1026, nCharCode=0, nRepeat=0, bForward=true) at vcl/source/window/winproc.cxx:1209 3 ImplWindowFrameProc(vcl::Window*, SalEvent, void const*) at vcl/source/window/winproc.cxx:2672 4 SalFrame::CallCallback(SalEvent, void const*) const (this=0x8a19fb0, nEvent=SalEvent::KeyInput, pEvent=0x7ffc7f3639a0) at vcl/inc/salframe.hxx:306 5 X11SalFrame::HandleKeyEvent(XKeyEvent*) at vcl/unx/generic/window/salframe.cxx:3190 Change-Id: I0be42330aeef98ef09e21297acef6cf616b7f2d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137459 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/include/vcl/toolkit/treelistbox.hxx b/include/vcl/toolkit/treelistbox.hxx index 355b6343de20..62bee8ea976e 100644 --- a/include/vcl/toolkit/treelistbox.hxx +++ b/include/vcl/toolkit/treelistbox.hxx @@ -392,6 +392,7 @@ public: SvViewDataItem* GetViewDataItem(SvTreeListEntry const *, SvLBoxItem const *); const SvViewDataItem* GetViewDataItem(const SvTreeListEntry*, const SvLBoxItem*) const; + VclPtr<Edit> GetEditWidget() const; // for UITest bool IsInplaceEditingEnabled() const { return bool(nImpFlags & SvTreeListBoxFlags::EDT_ENABLED); } bool IsEditingActive() const { return bool(nImpFlags & SvTreeListBoxFlags::IN_EDT); } void EndEditing( bool bCancel = false ); diff --git a/sw/qa/uitest/writer_tests2/bookmark.py b/sw/qa/uitest/writer_tests2/bookmark.py index 62cf57735d60..8eaf8e323e31 100644 --- a/sw/qa/uitest/writer_tests2/bookmark.py +++ b/sw/qa/uitest/writer_tests2/bookmark.py @@ -90,5 +90,35 @@ class bookmarkDialog(UITestCase): xGoToBtn = xBookDlg.getChild("goto") xGoToBtn.executeAction("CLICK", tuple()) # goto 1st bookmark + def test_bookmark_dialog_edittext(self): + with self.ui_test.create_doc_in_start_center("writer") as xDoc: + + xDoc.Text.insertString(xDoc.Text.getStart(), "foo", False) + self.xUITest.executeCommand(".uno:SelectAll") + + with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"): + pass + + with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="close") as xBookDlg: + xBmk = xBookDlg.getChild("bookmarks") + xFirstListEntry = xBmk.getChild("0") # select first bookmark + xFirstListEntry.executeAction("SELECT", tuple()) + xEditBtn = xBookDlg.getChild("edittext") + + xEditBtn.executeAction('CLICK', ()) + + # this does not work - the Edit widget has the focus but it's not forwarded +# xBookDlg.executeAction("TYPE", mkPropertyValues({"TEXT":"fubar"})) +# xBookDlg.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + # this did not work previously but now works due to explicit + # forwarding in TreeListUIObject::execute() + xBmk.executeAction("TYPE", mkPropertyValues({"TEXT":"fubar"})) + xBmk.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + + x1stListEntry = xBmk.getChild("O") # select first bookmark + x1stListEntry.executeAction("SELECT", tuple()) + + self.assertEqual(xDoc.Text.String, "fubar") + self.assertEqual(get_state_as_dict(x1stListEntry)["Text"], "1\tBookmark 1\tfubar\tNo\t") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index 8919a3096539..e5062c085b80 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -84,6 +84,7 @@ public: OUString const & GetSavedValue() const; void StopEditing( bool bCancel ); void Hide(); + VclPtr<Edit> GetEditWidget() const { return pEdit; }; }; // *************************************************************** @@ -874,6 +875,11 @@ void SvTreeListBox::EnableSelectionAsDropTarget( bool bEnable ) // InplaceEditing // ****************************************************************** +VclPtr<Edit> SvTreeListBox::GetEditWidget() const +{ + return pEdCtrl ? pEdCtrl->GetEditWidget() : nullptr; +} + void SvTreeListBox::EditText( const OUString& rStr, const tools::Rectangle& rRect, const Selection& rSel ) { diff --git a/vcl/source/treelist/uiobject.cxx b/vcl/source/treelist/uiobject.cxx index ccc066804139..89d92808c3fb 100644 --- a/vcl/source/treelist/uiobject.cxx +++ b/vcl/source/treelist/uiobject.cxx @@ -8,6 +8,8 @@ */ #include <memory> + +#include <vcl/toolkit/edit.hxx> #include <vcl/toolkit/svlbitm.hxx> #include <vcl/uitest/uiobject.hxx> #include <vcl/toolkit/treelistbox.hxx> @@ -49,6 +51,10 @@ void TreeListUIObject::execute(const OUString& rAction, if (rAction.isEmpty()) { } + else if (auto const pEdit = mxTreeList->GetEditWidget()) + { + std::unique_ptr<UIObject>(new EditUIObject(pEdit))->execute(rAction, rParameters); + } else WindowUIObject::execute(rAction, rParameters); } @@ -64,6 +70,13 @@ std::unique_ptr<UIObject> TreeListUIObject::get_child(const OUString& rID) return std::unique_ptr<UIObject>(new TreeListEntryUIObject(mxTreeList, pEntry)); } + else if (nID == -1) // FIXME hack? + { + if (auto const pEdit = mxTreeList->GetEditWidget()) + { + return std::unique_ptr<UIObject>(new EditUIObject(pEdit)); + } + } return nullptr; }