[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jul 26 12:50:56 UTC 2021
sw/qa/uitest/ui/index/index.py | 37 ++++++++++++++++++++++
sw/source/ui/index/swuiidxmrk.cxx | 63 +++++++++++++++++++++++++-------------
2 files changed, 80 insertions(+), 20 deletions(-)
New commits:
commit 6e07c40577df013dc113310b7c2b76ee2b26e158
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Jul 26 13:16:29 2021 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Jul 26 14:50:22 2021 +0200
sw bibliography, local copy: finish UI in the Define Bibliography Entry dialog
Add the missing page check-button/spin-button, so the local copy UI is
on par with the URL one.
Change-Id: I0387ead2ad3ccdf3e36710ae23bb5e2f02e02934
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119497
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 8b76b04bc5a5..4d974764fa2a 100644
--- a/sw/qa/uitest/ui/index/index.py
+++ b/sw/qa/uitest/ui/index/index.py
@@ -52,4 +52,41 @@ class TestSwuiidxmrk(UITestCase):
# 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:
+ 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, just select a valid position
+ pagecb = define_entry.getChild("pagecb-local-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 local 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 != "LocalURL":
+ continue
+ # Without the accompanying fix in place, this test would have failed with:
+ # Could not find child with id: pagecb-local-visible
+ self.assertEqual(field.Value, "#page=1")
+
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx
index 01e0b5ed18f1..a7f13e504b14 100644
--- a/sw/source/ui/index/swuiidxmrk.cxx
+++ b/sw/source/ui/index/swuiidxmrk.cxx
@@ -1086,7 +1086,9 @@ class SwCreateAuthEntryDlg_Impl : public weld::GenericDialogController
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);
DECL_LINK(ShortNameHdl, weld::Entry&, void);
@@ -1672,30 +1674,44 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
m_xLocalBrowseButton = m_aBuilders.back()->weld_button("browse");
m_xLocalBrowseButton->connect_clicked(
LINK(this, SwCreateAuthEntryDlg_Impl, BrowseHdl));
+ m_xLocalPageCB = m_aBuilders.back()->weld_check_button("pagecb");
+ // Distinguish different instances of this for ui-testing.
+ m_xLocalPageCB->set_buildable_name(m_xLocalPageCB->get_buildable_name()
+ + "-local-visible");
+ m_xLocalPageSB = m_aBuilders.back()->weld_spin_button("pagesb");
}
// Now that both pEdits[nIndex] and m_xPageSB is initialized, set their values.
OUString aText = pFields[aCurInfo.nToxField];
- if (aCurInfo.nToxField != AUTH_FIELD_URL)
- {
- pEdits[nIndex]->set_text(aText);
- }
- else
+ if (aCurInfo.nToxField == AUTH_FIELD_URL || aCurInfo.nToxField == AUTH_FIELD_LOCAL_URL)
{
OUString aUrl;
int nPageNumber;
if (SplitUrlAndPage(aText, aUrl, nPageNumber))
{
pEdits[nIndex]->set_text(aUrl);
- m_xPageCB->set_active(true);
- m_xPageSB->set_sensitive(true);
- m_xPageSB->set_value(nPageNumber);
+ 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);
+ }
}
else
{
pEdits[nIndex]->set_text(aText);
}
}
+ else
+ {
+ pEdits[nIndex]->set_text(aText);
+ }
pEdits[nIndex]->show();
pEdits[nIndex]->set_help_id(aCurInfo.pHelpId);
@@ -1711,14 +1727,16 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
}
else if (aCurInfo.nToxField == AUTH_FIELD_URL)
{
- if (comphelper::isFileUrl(pFields[aCurInfo.nToxField]))
- {
- m_xBrowseButton->show();
- }
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();
+ m_xLocalPageCB->connect_toggled(LINK(this, SwCreateAuthEntryDlg_Impl, PageNumHdl));
+ m_xLocalPageSB->show();
+ }
m_aFixedTexts.back()->set_mnemonic_widget(pEdits[nIndex].get());
}
@@ -1750,13 +1768,17 @@ OUString SwCreateAuthEntryDlg_Impl::GetEntryText(ToxAuthorityField eField) cons
const TextInfo aCurInfo = aTextInfoArr[nIndex];
if(aCurInfo.nToxField == eField)
{
- if (aCurInfo.nToxField != AUTH_FIELD_URL)
+ if (aCurInfo.nToxField == AUTH_FIELD_URL)
{
- return pEdits[nIndex]->get_text();
+ return MergeUrlAndPage(pEdits[nIndex]->get_text(), m_xPageSB);
+ }
+ else if (aCurInfo.nToxField == AUTH_FIELD_LOCAL_URL)
+ {
+ return MergeUrlAndPage(pEdits[nIndex]->get_text(), m_xLocalPageSB);
}
else
{
- return MergeUrlAndPage(pEdits[nIndex]->get_text(), m_xPageSB);
+ return pEdits[nIndex]->get_text();
}
}
}
@@ -1845,16 +1867,17 @@ IMPL_LINK(SwCreateAuthEntryDlg_Impl, BrowseHdl, weld::Button&, rButton, void)
}
};
-IMPL_LINK_NOARG(SwCreateAuthEntryDlg_Impl, PageNumHdl, weld::Toggleable&, void)
+IMPL_LINK(SwCreateAuthEntryDlg_Impl, PageNumHdl, weld::Toggleable&, rPageCB, void)
{
- if (m_xPageCB->get_active())
+ weld::SpinButton& rPageSB = (&rPageCB == m_xPageCB.get()) ? *m_xPageSB : *m_xLocalPageSB;
+ if (rPageCB.get_active())
{
- m_xPageSB->set_sensitive(true);
- m_xPageSB->set_value(1);
+ rPageSB.set_sensitive(true);
+ rPageSB.set_value(1);
}
else
{
- m_xPageSB->set_sensitive(false);
+ rPageSB.set_sensitive(false);
}
}
More information about the Libreoffice-commits
mailing list