[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - vcl/inc vcl/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Tue May 5 17:37:27 UTC 2020
vcl/inc/salvtables.hxx | 105 ++++++++++
vcl/source/app/salvtables.cxx | 432 +++++++++++++++++++-----------------------
2 files changed, 304 insertions(+), 233 deletions(-)
New commits:
commit 28473e6daf51feec6133c9dc007c77cc1f7083bb
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Fri Feb 21 14:35:13 2020 +0100
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue May 5 19:36:57 2020 +0200
Move SalInstanceEdit declaration to the header file
Change-Id: I660de317b88c4e83ccc310743dc4ef5b4c955a21
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89370
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93481
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 54619e4f9735..54e07d67592c 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -7,6 +7,8 @@
#include <vcl/settings.hxx>
#include <vcl/virdev.hxx>
#include <vcl/ctrl.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/spinfld.hxx>
class SalInstanceBuilder : public weld::Builder
{
@@ -323,4 +325,107 @@ public:
virtual weld::Container* weld_content_area() override;
};
+class WeldTextFilter : public TextFilter
+{
+private:
+ Link<OUString&, bool>& m_rInsertTextHdl;
+public:
+ WeldTextFilter(Link<OUString&, bool>& rInsertTextHdl);
+
+ virtual OUString filter(const OUString &rText) override;
+};
+
+class SalInstanceEntry : public SalInstanceWidget, public virtual weld::Entry
+{
+private:
+ VclPtr<Edit> m_xEntry;
+
+ DECL_LINK(ChangeHdl, Edit&, void);
+ DECL_LINK(CursorListener, VclWindowEvent&, void);
+ DECL_LINK(ActivateHdl, Edit&, bool);
+
+ WeldTextFilter m_aTextFilter;
+public:
+ SalInstanceEntry(Edit* pEntry, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+
+ virtual void set_text(const OUString& rText) override;
+
+ virtual OUString get_text() const override;
+
+ virtual void set_width_chars(int nChars) override;
+
+ virtual int get_width_chars() const override;
+
+ virtual void set_max_length(int nChars) override;
+
+ virtual void select_region(int nStartPos, int nEndPos) override;
+
+ bool get_selection_bounds(int& rStartPos, int &rEndPos) override;
+
+ virtual void set_position(int nCursorPos) override;
+
+ virtual int get_position() const override;
+
+ virtual void set_editable(bool bEditable) override;
+
+ virtual bool get_editable() const override;
+
+ virtual void set_error(bool bError) override;
+
+ virtual vcl::Font get_font() override;
+
+ virtual void set_font(const vcl::Font& rFont) override;
+
+ virtual void connect_cursor_position(const Link<Entry&, void>& rLink) override;
+
+ Edit& getEntry();
+
+ void fire_signal_changed();
+
+ virtual ~SalInstanceEntry() override;
+};
+
+class SalInstanceSpinButton : public SalInstanceEntry, public virtual weld::SpinButton
+{
+private:
+ VclPtr<FormattedField> m_xButton;
+
+ DECL_LINK(UpDownHdl, SpinField&, void);
+ DECL_LINK(LoseFocusHdl, Control&, void);
+ DECL_LINK(OutputHdl, Edit&, bool);
+ DECL_LINK(InputHdl, sal_Int64*, TriState);
+ DECL_LINK(ActivateHdl, Edit&, bool);
+
+ double toField(int nValue) const;
+
+ int fromField(double fValue) const;
+
+public:
+ SalInstanceSpinButton(FormattedField* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+
+ virtual int get_value() const override;
+
+ virtual void set_value(int value) override;
+
+ virtual void set_range(int min, int max) override;
+
+ virtual void get_range(int& min, int& max) const override;
+
+ virtual void set_increments(int step, int /*page*/) override;
+
+ virtual void get_increments(int& step, int& page) const override;
+
+ virtual void set_digits(unsigned int digits) override;
+
+ //so with hh::mm::ss, incrementing mm will not reset ss
+ void DisableRemainderFactor();
+
+ //off by default for direct SpinButtons, MetricSpinButton enables it
+ void SetUseThousandSep();
+
+ virtual unsigned int get_digits() const override;
+
+ virtual ~SalInstanceSpinButton() override;
+};
+
#endif
\ No newline at end of file
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index fc80d016f498..7776b28522dd 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1601,174 +1601,153 @@ public:
}
};
-namespace
+WeldTextFilter::WeldTextFilter(Link<OUString&, bool>& rInsertTextHdl)
+ : TextFilter(OUString())
+ , m_rInsertTextHdl(rInsertTextHdl)
{
- class WeldTextFilter : public TextFilter
- {
- private:
- Link<OUString&, bool>& m_rInsertTextHdl;
- public:
- WeldTextFilter(Link<OUString&, bool>& rInsertTextHdl)
- : TextFilter(OUString())
- , m_rInsertTextHdl(rInsertTextHdl)
- {
- }
-
- virtual OUString filter(const OUString &rText) override
- {
- if (!m_rInsertTextHdl.IsSet())
- return rText;
- OUString sText(rText);
- const bool bContinue = m_rInsertTextHdl.Call(sText);
- if (!bContinue)
- return OUString();
- return sText;
- }
- };
}
-class SalInstanceEntry : public SalInstanceWidget, public virtual weld::Entry
+OUString WeldTextFilter::filter(const OUString &rText)
{
-private:
- VclPtr<Edit> m_xEntry;
+ if (!m_rInsertTextHdl.IsSet())
+ return rText;
+ OUString sText(rText);
+ const bool bContinue = m_rInsertTextHdl.Call(sText);
+ if (!bContinue)
+ return OUString();
+ return sText;
+}
- DECL_LINK(ChangeHdl, Edit&, void);
- DECL_LINK(CursorListener, VclWindowEvent&, void);
- DECL_LINK(ActivateHdl, Edit&, bool);
+SalInstanceEntry::SalInstanceEntry(Edit* pEntry, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+ : SalInstanceWidget(pEntry, pBuilder, bTakeOwnership)
+ , m_xEntry(pEntry)
+ , m_aTextFilter(m_aInsertTextHdl)
+{
+ m_xEntry->SetModifyHdl(LINK(this, SalInstanceEntry, ChangeHdl));
+ m_xEntry->SetActivateHdl(LINK(this, SalInstanceEntry, ActivateHdl));
+ m_xEntry->SetTextFilter(&m_aTextFilter);
+}
- WeldTextFilter m_aTextFilter;
-public:
- SalInstanceEntry(Edit* pEntry, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
- : SalInstanceWidget(pEntry, pBuilder, bTakeOwnership)
- , m_xEntry(pEntry)
- , m_aTextFilter(m_aInsertTextHdl)
- {
- m_xEntry->SetModifyHdl(LINK(this, SalInstanceEntry, ChangeHdl));
- m_xEntry->SetActivateHdl(LINK(this, SalInstanceEntry, ActivateHdl));
- m_xEntry->SetTextFilter(&m_aTextFilter);
- }
+void SalInstanceEntry::set_text(const OUString& rText)
+{
+ disable_notify_events();
+ m_xEntry->SetText(rText);
+ enable_notify_events();
+}
- virtual void set_text(const OUString& rText) override
- {
- disable_notify_events();
- m_xEntry->SetText(rText);
- enable_notify_events();
- }
+OUString SalInstanceEntry::get_text() const
+{
+ return m_xEntry->GetText();
+}
- virtual OUString get_text() const override
- {
- return m_xEntry->GetText();
- }
+void SalInstanceEntry::set_width_chars(int nChars)
+{
+ m_xEntry->SetWidthInChars(nChars);
+}
- virtual void set_width_chars(int nChars) override
- {
- m_xEntry->SetWidthInChars(nChars);
- }
+int SalInstanceEntry::get_width_chars() const
+{
+ return m_xEntry->GetWidthInChars();
+}
- virtual int get_width_chars() const override
- {
- return m_xEntry->GetWidthInChars();
- }
+void SalInstanceEntry::set_max_length(int nChars)
+{
+ m_xEntry->SetMaxTextLen(nChars);
+}
- virtual void set_max_length(int nChars) override
- {
- m_xEntry->SetMaxTextLen(nChars);
- }
+void SalInstanceEntry::select_region(int nStartPos, int nEndPos)
+{
+ disable_notify_events();
+ m_xEntry->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX : nEndPos));
+ enable_notify_events();
+}
- virtual void select_region(int nStartPos, int nEndPos) override
- {
- disable_notify_events();
- m_xEntry->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX : nEndPos));
- enable_notify_events();
- }
+bool SalInstanceEntry::get_selection_bounds(int& rStartPos, int &rEndPos)
+{
+ const Selection& rSelection = m_xEntry->GetSelection();
+ rStartPos = rSelection.Min();
+ rEndPos = rSelection.Max();
+ return rSelection.Len();
+}
- bool get_selection_bounds(int& rStartPos, int &rEndPos) override
- {
- const Selection& rSelection = m_xEntry->GetSelection();
- rStartPos = rSelection.Min();
- rEndPos = rSelection.Max();
- return rSelection.Len();
- }
+void SalInstanceEntry::set_position(int nCursorPos)
+{
+ disable_notify_events();
+ if (nCursorPos < 0)
+ m_xEntry->SetCursorAtLast();
+ else
+ m_xEntry->SetSelection(Selection(nCursorPos, nCursorPos));
+ enable_notify_events();
+}
- virtual void set_position(int nCursorPos) override
- {
- disable_notify_events();
- if (nCursorPos < 0)
- m_xEntry->SetCursorAtLast();
- else
- m_xEntry->SetSelection(Selection(nCursorPos, nCursorPos));
- enable_notify_events();
- }
+int SalInstanceEntry::get_position() const
+{
+ return m_xEntry->GetSelection().Max();
+}
- virtual int get_position() const override
- {
- return m_xEntry->GetSelection().Max();
- }
+void SalInstanceEntry::set_editable(bool bEditable)
+{
+ m_xEntry->SetReadOnly(!bEditable);
+}
- virtual void set_editable(bool bEditable) override
- {
- m_xEntry->SetReadOnly(!bEditable);
- }
+bool SalInstanceEntry::get_editable() const
+{
+ return !m_xEntry->IsReadOnly();
+}
- virtual bool get_editable() const override
+void SalInstanceEntry::set_error(bool bError)
+{
+ if (bError)
{
- return !m_xEntry->IsReadOnly();
+ // #i75179# enable setting the background to a different color
+ m_xEntry->SetForceControlBackground(true);
+ m_xEntry->SetControlForeground(COL_WHITE);
+ m_xEntry->SetControlBackground(0xff6563);
}
-
- virtual void set_error(bool bError) override
+ else
{
- if (bError)
- {
- // #i75179# enable setting the background to a different color
- m_xEntry->SetForceControlBackground(true);
- m_xEntry->SetControlForeground(COL_WHITE);
- m_xEntry->SetControlBackground(0xff6563);
- }
- else
- {
- m_xEntry->SetForceControlBackground(false);
- m_xEntry->SetControlForeground();
- m_xEntry->SetControlBackground();
- }
+ m_xEntry->SetForceControlBackground(false);
+ m_xEntry->SetControlForeground();
+ m_xEntry->SetControlBackground();
}
+}
- virtual vcl::Font get_font() override
- {
- return m_xEntry->GetFont();
- }
+vcl::Font SalInstanceEntry::get_font()
+{
+ return m_xEntry->GetFont();
+}
- virtual void set_font(const vcl::Font& rFont) override
- {
- m_xEntry->SetFont(rFont);
- m_xEntry->Invalidate();
- }
+void SalInstanceEntry::set_font(const vcl::Font& rFont)
+{
+ m_xEntry->SetFont(rFont);
+ m_xEntry->Invalidate();
+}
- virtual void connect_cursor_position(const Link<Entry&, void>& rLink) override
- {
- assert(!m_aCursorPositionHdl.IsSet());
- m_xEntry->AddEventListener(LINK(this, SalInstanceEntry, CursorListener));
- weld::Entry::connect_cursor_position(rLink);
- }
+void SalInstanceEntry::connect_cursor_position(const Link<Entry&, void>& rLink)
+{
+ assert(!m_aCursorPositionHdl.IsSet());
+ m_xEntry->AddEventListener(LINK(this, SalInstanceEntry, CursorListener));
+ weld::Entry::connect_cursor_position(rLink);
+}
- Edit& getEntry()
- {
- return *m_xEntry;
- }
+Edit& SalInstanceEntry::getEntry()
+{
+ return *m_xEntry;
+}
- void fire_signal_changed()
- {
- signal_changed();
- }
+void SalInstanceEntry::fire_signal_changed()
+{
+ signal_changed();
+}
- virtual ~SalInstanceEntry() override
- {
- if (m_aCursorPositionHdl.IsSet())
- m_xEntry->RemoveEventListener(LINK(this, SalInstanceEntry, CursorListener));
- m_xEntry->SetTextFilter(nullptr);
- m_xEntry->SetActivateHdl(Link<Edit&, bool>());
- m_xEntry->SetModifyHdl(Link<Edit&, void>());
- }
-};
+SalInstanceEntry::~SalInstanceEntry()
+{
+ if (m_aCursorPositionHdl.IsSet())
+ m_xEntry->RemoveEventListener(LINK(this, SalInstanceEntry, CursorListener));
+ m_xEntry->SetTextFilter(nullptr);
+ m_xEntry->SetActivateHdl(Link<Edit&, bool>());
+ m_xEntry->SetModifyHdl(Link<Edit&, void>());
+}
IMPL_LINK_NOARG(SalInstanceEntry, ChangeHdl, Edit&, void)
{
@@ -2476,112 +2455,99 @@ IMPL_LINK_NOARG(SalInstanceTreeView, ExpandingHdl, SvTreeListBox*, bool)
return bRet;
}
-class SalInstanceSpinButton : public SalInstanceEntry, public virtual weld::SpinButton
+double SalInstanceSpinButton::toField(int nValue) const
{
-private:
- VclPtr<FormattedField> m_xButton;
-
- DECL_LINK(UpDownHdl, SpinField&, void);
- DECL_LINK(LoseFocusHdl, Control&, void);
- DECL_LINK(OutputHdl, Edit&, bool);
- DECL_LINK(InputHdl, sal_Int64*, TriState);
- DECL_LINK(ActivateHdl, Edit&, bool);
-
- double toField(int nValue) const
- {
- return static_cast<double>(nValue) / Power10(get_digits());
- }
+ return static_cast<double>(nValue) / Power10(get_digits());
+}
- int fromField(double fValue) const
- {
- return FRound(fValue * Power10(get_digits()));
- }
+int SalInstanceSpinButton::fromField(double fValue) const
+{
+ return FRound(fValue * Power10(get_digits()));
+}
-public:
- SalInstanceSpinButton(FormattedField* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
- : SalInstanceEntry(pButton, pBuilder, bTakeOwnership)
- , m_xButton(pButton)
- {
- m_xButton->SetThousandsSep(false); //off by default, MetricSpinButton enables it
- m_xButton->SetUpHdl(LINK(this, SalInstanceSpinButton, UpDownHdl));
- m_xButton->SetDownHdl(LINK(this, SalInstanceSpinButton, UpDownHdl));
- m_xButton->SetLoseFocusHdl(LINK(this, SalInstanceSpinButton, LoseFocusHdl));
- m_xButton->SetOutputHdl(LINK(this, SalInstanceSpinButton, OutputHdl));
- m_xButton->SetInputHdl(LINK(this, SalInstanceSpinButton, InputHdl));
- if (Edit* pEdit = m_xButton->GetSubEdit())
- pEdit->SetActivateHdl(LINK(this, SalInstanceSpinButton, ActivateHdl));
- else
- m_xButton->SetActivateHdl(LINK(this, SalInstanceSpinButton, ActivateHdl));
- }
+SalInstanceSpinButton::SalInstanceSpinButton(FormattedField* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+ : SalInstanceEntry(pButton, pBuilder, bTakeOwnership)
+ , m_xButton(pButton)
+{
+ m_xButton->SetThousandsSep(false); //off by default, MetricSpinButton enables it
+ m_xButton->SetUpHdl(LINK(this, SalInstanceSpinButton, UpDownHdl));
+ m_xButton->SetDownHdl(LINK(this, SalInstanceSpinButton, UpDownHdl));
+ m_xButton->SetLoseFocusHdl(LINK(this, SalInstanceSpinButton, LoseFocusHdl));
+ m_xButton->SetOutputHdl(LINK(this, SalInstanceSpinButton, OutputHdl));
+ m_xButton->SetInputHdl(LINK(this, SalInstanceSpinButton, InputHdl));
+ if (Edit* pEdit = m_xButton->GetSubEdit())
+ pEdit->SetActivateHdl(LINK(this, SalInstanceSpinButton, ActivateHdl));
+ else
+ m_xButton->SetActivateHdl(LINK(this, SalInstanceSpinButton, ActivateHdl));
+}
- virtual int get_value() const override
- {
- return fromField(m_xButton->GetValue());
- }
+int SalInstanceSpinButton::get_value() const
+{
+ return fromField(m_xButton->GetValue());
+}
- virtual void set_value(int value) override
- {
- m_xButton->SetValue(toField(value));
- }
+void SalInstanceSpinButton::set_value(int value)
+{
+ m_xButton->SetValue(toField(value));
+}
- virtual void set_range(int min, int max) override
- {
- m_xButton->SetMinValue(toField(min));
- m_xButton->SetMaxValue(toField(max));
- }
+void SalInstanceSpinButton::set_range(int min, int max)
+{
+ m_xButton->SetMinValue(toField(min));
+ m_xButton->SetMaxValue(toField(max));
+}
- virtual void get_range(int& min, int& max) const override
- {
- min = fromField(m_xButton->GetMinValue());
- max = fromField(m_xButton->GetMaxValue());
- }
+void SalInstanceSpinButton::get_range(int& min, int& max) const
+{
+ min = fromField(m_xButton->GetMinValue());
+ max = fromField(m_xButton->GetMaxValue());
+}
- virtual void set_increments(int step, int /*page*/) override
- {
- m_xButton->SetSpinSize(toField(step));
- }
+void SalInstanceSpinButton::set_increments(int step, int /*page*/)
+{
+ m_xButton->SetSpinSize(toField(step));
+}
- virtual void get_increments(int& step, int& page) const override
- {
- step = fromField(m_xButton->GetSpinSize());
- page = fromField(m_xButton->GetSpinSize());
- }
+void SalInstanceSpinButton::get_increments(int& step, int& page) const
+{
+ step = fromField(m_xButton->GetSpinSize());
+ page = fromField(m_xButton->GetSpinSize());
+}
- virtual void set_digits(unsigned int digits) override
- {
- m_xButton->SetDecimalDigits(digits);
- }
+void SalInstanceSpinButton::set_digits(unsigned int digits)
+{
+ m_xButton->SetDecimalDigits(digits);
+}
- //so with hh::mm::ss, incrementing mm will not reset ss
- void DisableRemainderFactor()
- {
- m_xButton->DisableRemainderFactor();
- }
+//so with hh::mm::ss, incrementing mm will not reset ss
+void SalInstanceSpinButton::DisableRemainderFactor()
+{
+ m_xButton->DisableRemainderFactor();
+}
- //off by default for direct SpinButtons, MetricSpinButton enables it
- void SetUseThousandSep()
- {
- m_xButton->SetThousandsSep(true);
- }
+//off by default for direct SpinButtons, MetricSpinButton enables it
+void SalInstanceSpinButton::SetUseThousandSep()
+{
+ m_xButton->SetThousandsSep(true);
+}
- virtual unsigned int get_digits() const override
- {
- return m_xButton->GetDecimalDigits();
- }
+unsigned int SalInstanceSpinButton::get_digits() const
+{
+ return m_xButton->GetDecimalDigits();
+}
- virtual ~SalInstanceSpinButton() override
- {
- if (Edit* pEdit = m_xButton->GetSubEdit())
- pEdit->SetActivateHdl(Link<Edit&, bool>());
- else
- m_xButton->SetActivateHdl(Link<Edit&, bool>());
- m_xButton->SetInputHdl(Link<sal_Int64*, TriState>());
- m_xButton->SetOutputHdl(Link<Edit&, bool>());
- m_xButton->SetLoseFocusHdl(Link<Control&, void>());
- m_xButton->SetDownHdl(Link<SpinField&, void>());
- m_xButton->SetUpHdl(Link<SpinField&, void>());
- }
-};
+SalInstanceSpinButton::~SalInstanceSpinButton()
+{
+ if (Edit* pEdit = m_xButton->GetSubEdit())
+ pEdit->SetActivateHdl(Link<Edit&, bool>());
+ else
+ m_xButton->SetActivateHdl(Link<Edit&, bool>());
+ m_xButton->SetInputHdl(Link<sal_Int64*, TriState>());
+ m_xButton->SetOutputHdl(Link<Edit&, bool>());
+ m_xButton->SetLoseFocusHdl(Link<Control&, void>());
+ m_xButton->SetDownHdl(Link<SpinField&, void>());
+ m_xButton->SetUpHdl(Link<SpinField&, void>());
+}
IMPL_LINK_NOARG(SalInstanceSpinButton, ActivateHdl, Edit&, bool)
{
More information about the Libreoffice-commits
mailing list