sw bibliography, local copy: handle the bibliography database window

- update generalpage.ui to have the same widgets for both the URL and
  the local URL

- extend BibGeneralPage to map LocalURL to m_xLocalURLED

- get the usual browse / page number handling buttons working

- introduce a separate GtkAdjustment for the additional spinbutton,
  which seems to be necessary for gtk3, but not for gen (otherwise
  increasing the value sets a new value for both spinbuttons)

Change-Id: I9ea616102cd6a8a060217a4e404a8eb93a0c2a04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119545
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Miklos Vajna
2021-07-27 12:54:18 +02:00
parent d2c2985024
commit 5fd2f212a1
6 changed files with 211 additions and 21 deletions
+1
View File
@@ -58,6 +58,7 @@
#define HID_BIB_CUSTOM3_POS "EXTENSIONS_HID_BIB_CUSTOM3_POS"
#define HID_BIB_CUSTOM4_POS "EXTENSIONS_HID_BIB_CUSTOM4_POS"
#define HID_BIB_CUSTOM5_POS "EXTENSIONS_HID_BIB_CUSTOM5_POS"
#define HID_BIB_LOCAL_URL_POS "EXTENSIONS_HID_BIB_LOCAL_URL_POS"
#define HID_BIB_DB_GRIDCTRL "EXTENSIONS_HID_BIB_DB_GRIDCTRL"
#define HID_GROUPWIZARD_PREVIOUS "EXTENSIONS_HID_GROUPWIZARD_PREVIOUS"
@@ -90,6 +90,7 @@ BibConfig::BibConfig()
aColumnDefaults[28] = "Custom3";
aColumnDefaults[29] = "Custom4";
aColumnDefaults[30] = "Custom5";
aColumnDefaults[31] = "LocalURL";
const Sequence< OUString > aPropertyNames = GetPropertyNames();
+2 -1
View File
@@ -28,7 +28,7 @@ struct Mapping;
typedef std::vector<std::unique_ptr<Mapping> > MappingArray;
#define COLUMN_COUNT 31
#define COLUMN_COUNT 32
#define IDENTIFIER_POS 0
#define AUTHORITYTYPE_POS 1
#define AUTHOR_POS 2
@@ -60,6 +60,7 @@ typedef std::vector<std::unique_ptr<Mapping> > MappingArray;
#define CUSTOM3_POS 28
#define CUSTOM4_POS 29
#define CUSTOM5_POS 30
#define LOCAL_URL_POS 31
struct StringPair
{
+90 -18
View File
@@ -197,6 +197,11 @@ BibGeneralPage::BibGeneralPage(vcl::Window* pParent, BibDataManager* pMan)
, xCustom4ED(m_xBuilder->weld_entry("custom4control"))
, xCustom5FT(m_xBuilder->weld_label("custom5"))
, xCustom5ED(m_xBuilder->weld_entry("custom5control"))
, m_xLocalURLFT(m_xBuilder->weld_label("localurl"))
, m_xLocalURLED(m_xBuilder->weld_entry("localurlcontrol"))
, m_xLocalBrowseButton(m_xBuilder->weld_button("localbrowse"))
, m_xLocalPageCB(m_xBuilder->weld_check_button("localpagecb"))
, m_xLocalPageSB(m_xBuilder->weld_spin_button("localpagesb"))
, pDatMan(pMan)
{
SetStyle(GetStyle() | WB_DIALOGCONTROL);
@@ -315,6 +320,7 @@ BibGeneralPage::BibGeneralPage(vcl::Window* pParent, BibDataManager* pMan)
sTableErrorString, HID_BIB_URL_POS);
m_xBrowseButton->connect_clicked(LINK(this, BibGeneralPage, BrowseHdl));
m_xPageCB->connect_toggled(LINK(this, BibGeneralPage, PageNumHdl));
AddControlWithError(lcl_GetColumnName(pMapping, CUSTOM1_POS),
xCustom1FT->get_label(), *xCustom1ED,
@@ -336,7 +342,14 @@ BibGeneralPage::BibGeneralPage(vcl::Window* pParent, BibDataManager* pMan)
xCustom5FT->get_label(), *xCustom5ED,
sTableErrorString, HID_BIB_CUSTOM5_POS);
xCustom5ED->connect_key_press(LINK(this, BibGeneralPage, LastElementKeyInputHdl));
AddControlWithError(lcl_GetColumnName(pMapping, LOCAL_URL_POS),
m_xLocalURLFT->get_label(), *m_xLocalURLED,
sTableErrorString, HID_BIB_LOCAL_URL_POS);
m_xLocalBrowseButton->connect_clicked(LINK(this, BibGeneralPage, BrowseHdl));
m_xLocalPageCB->connect_toggled(LINK(this, BibGeneralPage, PageNumHdl));
m_xLocalURLED->connect_key_press(LINK(this, BibGeneralPage, LastElementKeyInputHdl));
if(!sTableErrorString.isEmpty())
sTableErrorString = BibResId(ST_ERROR_PREFIX) + sTableErrorString;
@@ -347,11 +360,11 @@ BibGeneralPage::BibGeneralPage(vcl::Window* pParent, BibDataManager* pMan)
set_height_request(aSize.Height());
}
IMPL_LINK_NOARG(BibGeneralPage, BrowseHdl, weld::Button&, void)
IMPL_LINK(BibGeneralPage, BrowseHdl, weld::Button&, rButton, void)
{
sfx2::FileDialogHelper aFileDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
FileDialogFlags::NONE, GetFrameWeld());
OUString aPath = xURLED->get_text();
OUString aPath = (&rButton == m_xBrowseButton.get()) ? xURLED->get_text() : m_xLocalURLED->get_text();
if (!aPath.isEmpty())
{
aFileDlg.SetDisplayDirectory(aPath);
@@ -362,9 +375,24 @@ IMPL_LINK_NOARG(BibGeneralPage, BrowseHdl, weld::Button&, void)
return;
}
xURLED->set_text(aFileDlg.GetPath());
weld::Entry& rEntry = (&rButton == m_xBrowseButton.get()) ? *xURLED : *m_xLocalURLED;
rEntry.set_text(aFileDlg.GetPath());
};
IMPL_LINK(BibGeneralPage, 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);
}
else
{
rPageSB.set_sensitive(false);
}
}
IMPL_LINK(BibGeneralPage, FirstElementKeyInputHdl, const KeyEvent&, rKeyEvent, bool)
{
sal_uInt16 nCode = rKeyEvent.GetKeyCode().GetCode();
@@ -377,9 +405,9 @@ IMPL_LINK(BibGeneralPage, FirstElementKeyInputHdl, const KeyEvent&, rKeyEvent, b
uno::Reference<sdbc::XRowSet> xRowSet(pDatMan->getForm(), UNO_QUERY);
if (xRowSet.is() && !xRowSet->isFirst())
xRowSet->previous();
xCustom5ED->grab_focus();
xCustom5ED->select_region(0, -1);
GainFocusHdl(*xCustom5ED);
m_xLocalURLED->grab_focus();
m_xLocalURLED->select_region(0, -1);
GainFocusHdl(*m_xLocalURLED);
return true;
}
return false;
@@ -515,11 +543,7 @@ namespace
{
OUString sNewName;
rValue >>= sNewName;
if (&m_rEntry != &m_rPage.GetURLED())
{
m_rEntry.set_text(sNewName);
}
else
if (&m_rEntry == &m_rPage.GetURLED())
{
OUString aUrl;
int nPageNumber;
@@ -538,32 +562,65 @@ namespace
m_rPage.GetPageSB().set_value(0);
}
}
else if (&m_rEntry == &m_rPage.GetLocalURLED())
{
OUString aUrl;
int nPageNumber;
if (SplitUrlAndPage(sNewName, aUrl, nPageNumber))
{
m_rEntry.set_text(aUrl);
m_rPage.GetLocalPageCB().set_active(true);
m_rPage.GetLocalPageSB().set_sensitive(true);
m_rPage.GetLocalPageSB().set_value(nPageNumber);
}
else
{
m_rEntry.set_text(sNewName);
m_rPage.GetLocalPageCB().set_active(false);
m_rPage.GetLocalPageSB().set_sensitive(false);
m_rPage.GetLocalPageSB().set_value(0);
}
}
else
{
m_rEntry.set_text(sNewName);
}
m_rEntry.save_value();
if (&m_rEntry == &m_rPage.GetURLED())
{
m_rPage.GetPageSB().save_value();
}
else if (&m_rEntry == &m_rPage.GetLocalURLED())
{
m_rPage.GetLocalPageSB().save_value();
}
}
/// Updates m_xPropSet based on the UI widget(s).
virtual void WriteBack() override
{
if (!m_rEntry.get_value_changed_from_saved()
&& !(&m_rEntry == &m_rPage.GetURLED()
&& m_rPage.GetPageSB().get_value_changed_from_saved()))
bool bURL = &m_rEntry == &m_rPage.GetURLED()
&& m_rPage.GetPageSB().get_value_changed_from_saved();
bool bLocalURL = &m_rEntry == &m_rPage.GetLocalURLED()
&& m_rPage.GetLocalPageSB().get_value_changed_from_saved();
if (!m_rEntry.get_value_changed_from_saved() && !(bURL || bLocalURL))
return;
m_bSelfChanging = true;
OUString aText;
if (&m_rEntry != &m_rPage.GetURLED())
if (&m_rEntry == &m_rPage.GetURLED())
{
aText = m_rEntry.get_text();
aText = MergeUrlAndPage(m_rEntry.get_text(), m_rPage.GetPageSB());
}
else if (&m_rEntry == &m_rPage.GetLocalURLED())
{
aText = MergeUrlAndPage(m_rEntry.get_text(), m_rPage.GetLocalPageSB());
}
else
{
aText = MergeUrlAndPage(m_rEntry.get_text(), m_rPage.GetPageSB());
aText = m_rEntry.get_text();
}
m_xPropSet->setPropertyValue("Text", makeAny(aText));
@@ -577,6 +634,10 @@ namespace
{
m_rPage.GetPageSB().save_value();
}
else if (&m_rEntry == &m_rPage.GetLocalURLED())
{
m_rPage.GetLocalPageSB().save_value();
}
}
};
@@ -732,6 +793,11 @@ void BibGeneralPage::dispose()
xCustom4ED.reset();
xCustom5FT.reset();
xCustom5ED.reset();
m_xLocalURLFT.reset();
m_xLocalURLED.reset();
m_xLocalBrowseButton.reset();
m_xLocalPageCB.reset();
m_xLocalPageSB.reset();
InterimItemWindow::dispose();
}
@@ -741,6 +807,12 @@ weld::CheckButton& BibGeneralPage::GetPageCB() { return *m_xPageCB; }
weld::SpinButton& BibGeneralPage::GetPageSB() { return *m_xPageSB; }
weld::Entry& BibGeneralPage::GetLocalURLED() { return *m_xLocalURLED; }
weld::CheckButton& BibGeneralPage::GetLocalPageCB() { return *m_xLocalPageCB; }
weld::SpinButton& BibGeneralPage::GetLocalPageSB() { return *m_xLocalPageSB; }
bool BibGeneralPage::AddXControl(const OUString& rName, weld::Entry& rEntry)
{
uno::Reference< awt::XControlModel > xCtrModel;
@@ -121,6 +121,11 @@ class BibGeneralPage : public InterimItemWindow
std::unique_ptr<weld::Entry> xCustom4ED;
std::unique_ptr<weld::Label> xCustom5FT;
std::unique_ptr<weld::Entry> xCustom5ED;
std::unique_ptr<weld::Label> m_xLocalURLFT;
std::unique_ptr<weld::Entry> m_xLocalURLED;
std::unique_ptr<weld::Button> m_xLocalBrowseButton;
std::unique_ptr<weld::CheckButton> m_xLocalPageCB;
std::unique_ptr<weld::SpinButton> m_xLocalPageSB;
OUString sTableErrorString;
@@ -142,6 +147,7 @@ class BibGeneralPage : public InterimItemWindow
DECL_LINK(FirstElementKeyInputHdl, const KeyEvent&, bool);
DECL_LINK(LastElementKeyInputHdl, const KeyEvent&, bool);
DECL_LINK(BrowseHdl, weld::Button&, void);
DECL_LINK(PageNumHdl, weld::Toggleable&, void);
DECL_LINK(LosePageFocusHdl, weld::Widget&, void);
public:
@@ -157,6 +163,9 @@ public:
weld::Entry& GetURLED();
weld::CheckButton& GetPageCB();
weld::SpinButton& GetPageSB();
weld::Entry& GetLocalURLED();
weld::CheckButton& GetLocalPageCB();
weld::SpinButton& GetLocalPageSB();
};
@@ -7,6 +7,11 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
<property name="upper">55535</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkBox" id="GeneralPage">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -956,10 +961,111 @@
</packing>
</child>
<child>
<placeholder/>
<object class="GtkLabel" id="localurl">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes" context="generalpage|localurl">Local copy</property>
<property name="use-underline">True</property>
<property name="mnemonic-widget">localurlcontrol</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left-attach">4</property>
<property name="top-attach">14</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkBox" id="localvbox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="localhbox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkEntry" id="localurlcontrol">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="truncate-multiline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="localbrowse">
<property name="label" translatable="yes" context="generalpage|browse">Browse...</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="localhbox2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkCheckButton" id="localpagecb">
<property name="label" translatable="yes" context="generalpage|localpagecb">Page</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<accessibility>
<relation type="label-for" target="localpagesb"/>
</accessibility>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="localpagesb">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="truncate-multiline">True</property>
<property name="adjustment">adjustment2</property>
<accessibility>
<relation type="labelled-by" target="localpagecb"/>
</accessibility>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">5</property>
<property name="top-attach">14</property>
</packing>
</child>
<child>
<placeholder/>