[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 13 09:54:04 UTC 2021


 sw/qa/uitest/ui/index/index.py    |   38 -----------------------
 sw/source/ui/index/swuiidxmrk.cxx |   61 ++++++--------------------------------
 2 files changed, 11 insertions(+), 88 deletions(-)

New commits:
commit 59f3db1763e1ffb85e7b5d01b051a27a388281e2
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Aug 13 10:21:49 2021 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Aug 13 11:53:28 2021 +0200

    sw bibiliography: limit browse button / page number widgets to the local URL
    
    The normal URL is typically a HTTP resource, so the browse button is not
    helpful there after all. And if the URL is copied in manually anyway,
    then the dedicated page number widgets are not that helpful, either. So
    remove all this, and only keep it for local URLs only.
    
    Change-Id: I25733810cf38981c50014e06201555d98fd9f77f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120420
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/uitest/ui/index/index.py b/sw/qa/uitest/ui/index/index.py
index 4d974764fa2a..abfe9e27cd2d 100644
--- a/sw/qa/uitest/ui/index/index.py
+++ b/sw/qa/uitest/ui/index/index.py
@@ -14,44 +14,6 @@ from uitest.uihelper.common import type_text
 
 class TestSwuiidxmrk(UITestCase):
 
-    def test_bibliography_page_number_insert(self):
-
-        # Given an empty Writer document:
-        with self.ui_test.create_doc_in_start_center("writer") as component:
-
-            self.ui_test.execute_modeless_dialog_through_command(".uno:InsertAuthoritiesEntry")
-            insert_entry = self.xUITest.getTopFocusWindow()
-            from_document = insert_entry.getChild("fromdocument")
-            from_document.executeAction("CLICK", tuple())
-            new = insert_entry.getChild("new")
-
-            # When inserting a biblio entry field with a page number:
-            with self.ui_test.execute_blocking_action(new.executeAction, args=('CLICK', ())) as define_entry:
-                entry = define_entry.getChild("entry")
-                type_text(entry, "aaa")
-                listbox = define_entry.getChild("listbox")
-                select_pos(listbox, "16")  # WWW document
-                pagecb = define_entry.getChild("pagecb-visible")
-                pagecb.executeAction("CLICK", tuple())
-
-            insert = insert_entry.getChild("insert")
-            insert.executeAction("CLICK", tuple())
-            close = insert_entry.getChild("close")
-            self.ui_test.close_dialog_through_button(close)
-
-            # Then make sure the URL contains that page number:
-            paragraphs = component.Text.createEnumeration()
-            paragraph = paragraphs.nextElement()
-            portions = paragraph.createEnumeration()
-            portion = portions.nextElement()
-            for field in portion.TextField.Fields:
-                if field.Name != "URL":
-                    continue
-                # Without the accompanying fix in place, this test would have failed with:
-                # AssertionError: '' != '#page=1'
-                # i.e. the page number was not part of the URL.
-                self.assertEqual(field.Value, "#page=1")
-
     def test_bibliography_local_page_number_insert(self):
 
         # Given an empty Writer document:
diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx
index d090a1cf2028..7b0787caf5ff 100644
--- a/sw/source/ui/index/swuiidxmrk.cxx
+++ b/sw/source/ui/index/swuiidxmrk.cxx
@@ -1083,11 +1083,8 @@ class SwCreateAuthEntryDlg_Impl : public weld::GenericDialogController
     std::unique_ptr<weld::Container> m_xRight;
     std::unique_ptr<weld::ComboBox> m_xTypeListBox;
     std::unique_ptr<weld::ComboBox> m_xIdentifierBox;
-    std::unique_ptr<weld::Button> m_xBrowseButton;
     std::unique_ptr<weld::Button> m_xLocalBrowseButton;
-    std::unique_ptr<weld::CheckButton> m_xPageCB;
     std::unique_ptr<weld::CheckButton> m_xLocalPageCB;
-    std::unique_ptr<weld::SpinButton> m_xPageSB;
     std::unique_ptr<weld::SpinButton> m_xLocalPageSB;
 
     DECL_LINK(IdentifierHdl, weld::ComboBox&, void);
@@ -1660,16 +1657,7 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
             m_pBoxes[nIndex]->set_grid_left_attach(1);
             m_pBoxes[nIndex]->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
             m_pBoxes[nIndex]->set_hexpand(true);
-            if (aCurInfo.nToxField == AUTH_FIELD_URL)
-            {
-                m_xBrowseButton = m_aBuilders.back()->weld_button("browse");
-                m_xBrowseButton->connect_clicked(LINK(this, SwCreateAuthEntryDlg_Impl, BrowseHdl));
-                m_xPageCB = m_aBuilders.back()->weld_check_button("pagecb");
-                // Distinguish different instances of this for ui-testing.
-                m_xPageCB->set_buildable_name(m_xPageCB->get_buildable_name() + "-visible");
-                m_xPageSB = m_aBuilders.back()->weld_spin_button("pagesb");
-            }
-            else if (aCurInfo.nToxField == AUTH_FIELD_LOCAL_URL)
+            if (aCurInfo.nToxField == AUTH_FIELD_LOCAL_URL)
             {
                 m_xLocalBrowseButton = m_aBuilders.back()->weld_button("browse");
                 m_xLocalBrowseButton->connect_clicked(
@@ -1683,25 +1671,16 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
 
             // Now that both pEdits[nIndex] and m_xPageSB is initialized, set their values.
             OUString aText = pFields[aCurInfo.nToxField];
-            if (aCurInfo.nToxField == AUTH_FIELD_URL || aCurInfo.nToxField == AUTH_FIELD_LOCAL_URL)
+            if (aCurInfo.nToxField == AUTH_FIELD_LOCAL_URL)
             {
                 OUString aUrl;
                 int nPageNumber;
                 if (SplitUrlAndPage(aText, aUrl, nPageNumber))
                 {
                     pEdits[nIndex]->set_text(aUrl);
-                    if (aCurInfo.nToxField == AUTH_FIELD_URL)
-                    {
-                        m_xPageCB->set_active(true);
-                        m_xPageSB->set_sensitive(true);
-                        m_xPageSB->set_value(nPageNumber);
-                    }
-                    else
-                    {
-                        m_xLocalPageCB->set_active(true);
-                        m_xLocalPageSB->set_sensitive(true);
-                        m_xLocalPageSB->set_value(nPageNumber);
-                    }
+                    m_xLocalPageCB->set_active(true);
+                    m_xLocalPageSB->set_sensitive(true);
+                    m_xLocalPageSB->set_value(nPageNumber);
                 }
                 else
                 {
@@ -1725,12 +1704,6 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
                     pEdits[nIndex]->set_sensitive(false);
                 }
             }
-            else if (aCurInfo.nToxField == AUTH_FIELD_URL)
-            {
-                m_xPageCB->show();
-                m_xPageCB->connect_toggled(LINK(this, SwCreateAuthEntryDlg_Impl, PageNumHdl));
-                m_xPageSB->show();
-            }
             else if (aCurInfo.nToxField == AUTH_FIELD_LOCAL_URL)
             {
                 m_xLocalPageCB->show();
@@ -1768,11 +1741,7 @@ OUString  SwCreateAuthEntryDlg_Impl::GetEntryText(ToxAuthorityField eField) cons
         const TextInfo aCurInfo = aTextInfoArr[nIndex];
         if(aCurInfo.nToxField == eField)
         {
-            if (aCurInfo.nToxField == AUTH_FIELD_URL)
-            {
-                return MergeUrlAndPage(pEdits[nIndex]->get_text(), m_xPageSB);
-            }
-            else if (aCurInfo.nToxField == AUTH_FIELD_LOCAL_URL)
+            if (aCurInfo.nToxField == AUTH_FIELD_LOCAL_URL)
             {
                 return MergeUrlAndPage(pEdits[nIndex]->get_text(), m_xLocalPageSB);
             }
@@ -1825,7 +1794,6 @@ IMPL_LINK(SwCreateAuthEntryDlg_Impl, ShortNameHdl, weld::Entry&, rEdit, void)
 IMPL_LINK(SwCreateAuthEntryDlg_Impl, EnableHdl, weld::ComboBox&, rBox, void)
 {
     m_xOKBT->set_sensitive(m_bNameAllowed && rBox.get_active() != -1);
-    m_xBrowseButton->show();
     m_xLocalBrowseButton->show();
 };
 
@@ -1834,11 +1802,7 @@ IMPL_LINK(SwCreateAuthEntryDlg_Impl, BrowseHdl, weld::Button&, rButton, void)
     sfx2::FileDialogHelper aFileDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
                                     FileDialogFlags::NONE, getDialog());
     OUString aPath;
-    if (&rButton == m_xBrowseButton.get())
-    {
-        aPath = GetEntryText(AUTH_FIELD_URL);
-    }
-    else if (&rButton == m_xLocalBrowseButton.get())
+    if (&rButton == m_xLocalBrowseButton.get())
     {
         aPath = GetEntryText(AUTH_FIELD_LOCAL_URL);
     }
@@ -1857,9 +1821,7 @@ IMPL_LINK(SwCreateAuthEntryDlg_Impl, BrowseHdl, weld::Button&, rButton, void)
     for (int nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++)
     {
         const TextInfo& rCurInfo = aTextInfoArr[nIndex];
-        if ((rCurInfo.nToxField == AUTH_FIELD_URL && &rButton == m_xBrowseButton.get())
-            || (rCurInfo.nToxField == AUTH_FIELD_LOCAL_URL
-                && &rButton == m_xLocalBrowseButton.get()))
+        if (rCurInfo.nToxField == AUTH_FIELD_LOCAL_URL && &rButton == m_xLocalBrowseButton.get())
         {
             pEdits[nIndex]->set_text(aPath);
             break;
@@ -1869,15 +1831,14 @@ IMPL_LINK(SwCreateAuthEntryDlg_Impl, BrowseHdl, weld::Button&, rButton, void)
 
 IMPL_LINK(SwCreateAuthEntryDlg_Impl, PageNumHdl, weld::Toggleable&, rPageCB, void)
 {
-    weld::SpinButton& rPageSB = (&rPageCB == m_xPageCB.get()) ? *m_xPageSB : *m_xLocalPageSB;
     if (rPageCB.get_active())
     {
-        rPageSB.set_sensitive(true);
-        rPageSB.set_value(1);
+        m_xLocalPageSB->set_sensitive(true);
+        m_xLocalPageSB->set_value(1);
     }
     else
     {
-        rPageSB.set_sensitive(false);
+        m_xLocalPageSB->set_sensitive(false);
     }
 }
 


More information about the Libreoffice-commits mailing list