summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-04-27 17:11:00 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-04-28 08:24:49 +0200
commitd524f5b28e2b9bcf7ab681eb6ad93a4da3f5663d (patch)
treea8a5a3a2c0f3068f73a7acd4c899ca7f483dd6a0
parentc9c6b0d75bcbb6ff3343502a19fb3448d361d335 (diff)
sw bibliography, refer to a page: add insert/delete UI
If the toggle button's activate state changes, adapt the sensitivity of the next spinbutton, this way a new page number can be added and an old one can be deleted. Change-Id: I97067182e8cd42a02b164ac941598bada2630e07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114750 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--sw/Module_sw.mk1
-rw-r--r--sw/UITest_sw_ui_index.mk16
-rw-r--r--sw/qa/uitest/ui/index/index.py61
-rw-r--r--sw/source/ui/index/swuiidxmrk.cxx17
4 files changed, 95 insertions, 0 deletions
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 793ed739daa4..dc976c4eb7b5 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -186,6 +186,7 @@ $(eval $(call gb_Module_add_uicheck_targets,sw,\
UITest_sw_sidebar \
UITest_sw_styleInspector \
UITest_sw_ui_fmtui \
+ UITest_sw_ui_index \
UITest_classification \
UITest_writer_macro_tests \
UITest_writer_dialogs \
diff --git a/sw/UITest_sw_ui_index.mk b/sw/UITest_sw_ui_index.mk
new file mode 100644
index 000000000000..c46321bea414
--- /dev/null
+++ b/sw/UITest_sw_ui_index.mk
@@ -0,0 +1,16 @@
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_UITest_UITest,sw_ui_index))
+
+$(eval $(call gb_UITest_add_modules,sw_ui_index,$(SRCDIR)/sw/qa/uitest,\
+ ui/index/ \
+))
+
+$(eval $(call gb_UITest_set_defs,sw_ui_index, \
+ TDOC="$(SRCDIR)/sw/qa/uitest/data" \
+))
diff --git a/sw/qa/uitest/ui/index/index.py b/sw/qa/uitest/ui/index/index.py
new file mode 100644
index 000000000000..c8309cdc14cc
--- /dev/null
+++ b/sw/qa/uitest/ui/index/index.py
@@ -0,0 +1,61 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+"""Covers sw/source/ui/index/ fixes."""
+
+from uitest.framework import UITestCase
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.common import type_text
+
+
+class TestSwuiidxmrk(UITestCase):
+
+ def test_bibliography_page_number_insert(self):
+
+ # Given an empty Writer document:
+ self.ui_test.create_doc_in_start_center("writer")
+
+ # When inserting a biblio entry field with a page number:
+ def handle_define_entry(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())
+ ok = define_entry.getChild("ok")
+ self.ui_test.close_dialog_through_button(ok)
+
+ 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")
+ self.ui_test.execute_blocking_action(new.executeAction,
+ args=('CLICK', ()),
+ dialog_handler=handle_define_entry)
+ 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:
+ component = self.ui_test.get_component()
+ 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")
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx
index 58cd9e0e2bc3..7b988a4cbec6 100644
--- a/sw/source/ui/index/swuiidxmrk.cxx
+++ b/sw/source/ui/index/swuiidxmrk.cxx
@@ -1091,6 +1091,7 @@ class SwCreateAuthEntryDlg_Impl : public weld::GenericDialogController
DECL_LINK(ShortNameHdl, weld::Entry&, void);
DECL_LINK(EnableHdl, weld::ComboBox&, void);
DECL_LINK(BrowseHdl, weld::Button&, void);
+ DECL_LINK(PageNumHdl, weld::ToggleButton&, void);
public:
SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
@@ -1673,6 +1674,8 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
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");
}
@@ -1718,6 +1721,7 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
m_xBrowseButton->show();
}
m_xPageCB->show();
+ m_xPageCB->connect_toggled(LINK(this, SwCreateAuthEntryDlg_Impl, PageNumHdl));
m_xPageSB->show();
}
@@ -1852,6 +1856,19 @@ IMPL_LINK_NOARG(SwCreateAuthEntryDlg_Impl, BrowseHdl, weld::Button&, void)
}
};
+IMPL_LINK_NOARG(SwCreateAuthEntryDlg_Impl, PageNumHdl, weld::ToggleButton&, void)
+{
+ if (m_xPageCB->get_active())
+ {
+ m_xPageSB->set_sensitive(true);
+ m_xPageSB->set_value(1);
+ }
+ else
+ {
+ m_xPageSB->set_sensitive(false);
+ }
+}
+
SwAuthMarkFloatDlg::SwAuthMarkFloatDlg(SfxBindings* _pBindings,
SfxChildWindow* pChild,
weld::Window *pParent,