cui/source/dialogs/cuihyperdlg.cxx            |   11 ++++++++++-
 cui/source/dialogs/iconcdlg.cxx               |    5 +++++
 sw/qa/uitest/writer_tests3/hyperlinkdialog.py |   14 ++++++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

New commits:
commit a9cea0ddeb5cd51db0720f96af75af75120908d9
Author:     Andreas Heinisch <andreas.heini...@yahoo.de>
AuthorDate: Wed Apr 26 10:37:40 2023 +0200
Commit:     Andreas Heinisch <andreas.heini...@yahoo.de>
CommitDate: Fri Apr 28 20:34:17 2023 +0200

    tdf#90496 - Remember last used view in hyperlink dialog
    
    Change-Id: I500e9e58c84486307c50f4ccb878ad0340412246
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151039
    Tested-by: Jenkins
    Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de>

diff --git a/cui/source/dialogs/cuihyperdlg.cxx 
b/cui/source/dialogs/cuihyperdlg.cxx
index 9eb5a1fa367e..782877d438f7 100644
--- a/cui/source/dialogs/cuihyperdlg.cxx
+++ b/cui/source/dialogs/cuihyperdlg.cxx
@@ -134,7 +134,16 @@ SvxHpLinkDlg::SvxHpLinkDlg(SfxBindings* pBindings, 
SfxChildWindow* pChild, weld:
         AddTabPage("newdocument", SvxHyperlinkNewDocTp::Create);
     }
 
-    SetCurPageId("internet");
+    // tdf#90496 - remember last used view in hyperlink dialog
+    OUString sPageId("internet");
+    SvtViewOptions aViewOpt(EViewType::TabDialog, 
m_xDialog->get_accessible_name());
+    if (aViewOpt.Exists())
+    {
+        const OUString sSavedPageId = aViewOpt.GetPageID();
+        if (GetPageData(sSavedPageId))
+            sPageId = sSavedPageId;
+    }
+    SetCurPageId(sPageId);
 
     // Init Dialog
     Start();
diff --git a/cui/source/dialogs/iconcdlg.cxx b/cui/source/dialogs/iconcdlg.cxx
index 0c2219f0ee71..ede5c0582b5c 100644
--- a/cui/source/dialogs/iconcdlg.cxx
+++ b/cui/source/dialogs/iconcdlg.cxx
@@ -23,6 +23,7 @@
 #include <cassert>
 #include <sal/log.hxx>
 #include <vcl/svapp.hxx>
+#include <unotools/viewoptions.hxx>
 
 /**********************************************************************
 |
@@ -148,6 +149,10 @@ void SvxHpLinkDlg::ActivatePageImpl()
         pData->xPage->ActivatePage( *pExampleSet );
     m_xDialog->set_help_id(pData->xPage->GetHelpId());
 
+    // tdf#90496 - remember last used view in hyperlink dialog
+    SvtViewOptions aViewOpt(EViewType::TabDialog, 
m_xDialog->get_accessible_name());
+    aViewOpt.SetPageID(msCurrentPageId);
+
     m_xResetBtn->show();
 }
 
diff --git a/sw/qa/uitest/writer_tests3/hyperlinkdialog.py 
b/sw/qa/uitest/writer_tests3/hyperlinkdialog.py
index 4494ab45a14c..6390310810d5 100644
--- a/sw/qa/uitest/writer_tests3/hyperlinkdialog.py
+++ b/sw/qa/uitest/writer_tests3/hyperlinkdialog.py
@@ -91,6 +91,20 @@ class HyperlinkDialog(UITestCase):
             xedit.executeAction("SELECT", mkPropertyValues({"START_POS": "0", 
"END_POS": "29"}))
             self.assertEqual(get_state_as_dict(xedit)["SelectedText"], 
"http://www.libreoffice.org:80";)
 
+    def test_tdf90496(self):
+        with self.ui_test.create_doc_in_start_center("writer"):
+            with 
self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog", 
close_button="cancel") as xDialog:
+                # Select a random tab to check the preselection in the 
hyperlink dialog
+                xTab = xDialog.getChild("tabcontrol")
+                select_pos(xTab, "1")
+
+            with 
self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog", 
close_button="cancel") as xDialog:
+                xTab = xDialog.getChild("tabcontrol")
+                # Without the fix in place, this test would have failed with
+                # AssertionError: '1' != '0'
+                # i.e. the last used tab in the hyperlink dialog was not 
remembered
+                self.assertEqual("1", get_state_as_dict(xTab)["CurrPagePos"])
+
 
     def test_tdf141166(self):
         # Skip this test for --with-help=html and --with-help=online, as that 
would fail with a

Reply via email to