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.heinisch@yahoo.de>
diff --git a/cui/source/dialogs/cuihyperdlg.cxx b/cui/source/dialogs/cuihyperdlg.cxx
index 9eb5a1f..782877d 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 0c2219f..ede5c05 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 4494ab4..6390310 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