weld SvxFmAbsRecWin item window
Change-Id: I6a11d8ba226b28447e2ab04925090491d6953132
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88348
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/basctl/source/inc/IDEComboBox.hxx b/basctl/source/inc/IDEComboBox.hxx
index 02c0812..1552562 100644
--- a/basctl/source/inc/IDEComboBox.hxx
+++ b/basctl/source/inc/IDEComboBox.hxx
@@ -96,7 +96,12 @@ protected:
virtual void Select() = 0;
virtual void FillBox() = 0;
virtual void GetFocus() override { m_xWidget->grab_focus(); }
virtual void GetFocus() override
{
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
/// key strokes the ComboBox receives
virtual bool HandleKeyInput(const KeyEvent& rKEvt);
diff --git a/include/sfx2/InterimItemWindow.hxx b/include/sfx2/InterimItemWindow.hxx
index 84b2765..d79a1ea 100644
--- a/include/sfx2/InterimItemWindow.hxx
+++ b/include/sfx2/InterimItemWindow.hxx
@@ -21,6 +21,7 @@ public:
virtual void Resize() override;
virtual Size GetOptimalSize() const override;
virtual void GetFocus() override;
protected:
InterimItemWindow(vcl::Window* pParent, const OUString& rUIXMLDescription, const OString& rID);
diff --git a/sc/source/ui/cctrl/cbnumberformat.cxx b/sc/source/ui/cctrl/cbnumberformat.cxx
index c02f342..93f003e 100644
--- a/sc/source/ui/cctrl/cbnumberformat.cxx
+++ b/sc/source/ui/cctrl/cbnumberformat.cxx
@@ -60,7 +60,9 @@ ScNumberFormat::~ScNumberFormat()
void ScNumberFormat::GetFocus()
{
m_xWidget->grab_focus();
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
IMPL_STATIC_LINK(ScNumberFormat, NumFormatSelectHdl, weld::ComboBox&, rBox, void)
diff --git a/sd/source/ui/dlg/diactrl.cxx b/sd/source/ui/dlg/diactrl.cxx
index 33deff5..20abb42 100644
--- a/sd/source/ui/dlg/diactrl.cxx
+++ b/sd/source/ui/dlg/diactrl.cxx
@@ -81,7 +81,9 @@ void SdPagesField::dispose()
void SdPagesField::GetFocus()
{
m_xWidget->grab_focus();
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
SdPagesField::~SdPagesField()
diff --git a/sd/source/ui/dlg/gluectrl.cxx b/sd/source/ui/dlg/gluectrl.cxx
index 0364aad..ee2e49a 100644
--- a/sd/source/ui/dlg/gluectrl.cxx
+++ b/sd/source/ui/dlg/gluectrl.cxx
@@ -72,7 +72,9 @@ void GlueEscDirLB::dispose()
void GlueEscDirLB::GetFocus()
{
m_xWidget->grab_focus();
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
GlueEscDirLB::~GlueEscDirLB()
diff --git a/sfx2/source/control/InterimItemWindow.cxx b/sfx2/source/control/InterimItemWindow.cxx
index 8e6ddb0..6f26b99 100644
--- a/sfx2/source/control/InterimItemWindow.cxx
+++ b/sfx2/source/control/InterimItemWindow.cxx
@@ -18,7 +18,8 @@ InterimItemWindow::InterimItemWindow(vcl::Window* pParent, const OUString& rUIXM
m_xBuilder.reset(Application::CreateInterimBuilder(m_xVclContentArea, rUIXMLDescription));
m_xContainer = m_xBuilder->weld_container(rID);
SetBackground(Wallpaper(COL_TRANSPARENT));
SetBackground();
SetPaintTransparent(true);
}
InterimItemWindow::~InterimItemWindow() { disposeOnce(); }
@@ -45,6 +46,17 @@ Size InterimItemWindow::GetOptimalSize() const
return VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild));
}
void InterimItemWindow::GetFocus()
{
/* let toolbox know this item window has focus so it updates its mnHighItemId to point
to this toolitem in case tab means to move to another toolitem within
the toolbox
*/
vcl::Window* pToolBox = GetParent();
NotifyEvent aNEvt(MouseNotifyEvent::GETFOCUS, this);
pToolBox->EventNotify(aNEvt);
}
bool InterimItemWindow::ChildKeyInput(const KeyEvent& rKEvt)
{
sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
diff --git a/sfx2/source/inet/inettbc.cxx b/sfx2/source/inet/inettbc.cxx
index b1fc33e..ee5adc3 100644
--- a/sfx2/source/inet/inettbc.cxx
+++ b/sfx2/source/inet/inettbc.cxx
@@ -90,7 +90,9 @@ public:
virtual void GetFocus() override
{
m_xWidget->grab_focus();
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
void set_sensitive(bool bSensitive)
diff --git a/sfx2/source/view/classificationcontroller.cxx b/sfx2/source/view/classificationcontroller.cxx
index e335d6d..0346066 100644
--- a/sfx2/source/view/classificationcontroller.cxx
+++ b/sfx2/source/view/classificationcontroller.cxx
@@ -106,7 +106,9 @@ class SAL_WARN_UNUSED ClassificationControl final : public InterimItemWindow
void DataChanged(const DataChangedEvent& rEvent) override;
void GetFocus() override
{
m_xCategory->grab_focus();
if (m_xCategory)
m_xCategory->grab_focus();
InterimItemWindow::GetFocus();
}
public:
diff --git a/solenv/sanitizers/ui/svx.suppr b/solenv/sanitizers/ui/svx.suppr
index 5baa2b4..29229ee 100644
--- a/solenv/sanitizers/ui/svx.suppr
+++ b/solenv/sanitizers/ui/svx.suppr
@@ -1,3 +1,4 @@
svx/uiconfig/ui/absrecbox.ui://GtkEntry[@id='entry'] no-labelled-by
svx/uiconfig/ui/addinstancedialog.ui://GtkLabel[@id='alttitle'] orphan-label
svx/uiconfig/ui/addmodeldialog.ui://GtkLabel[@id='alttitle'] orphan-label
svx/uiconfig/ui/addnamespacedialog.ui://GtkLabel[@id='alttitle'] orphan-label
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk
index 48f8b24..e7d4788 100644
--- a/svx/UIConfig_svx.mk
+++ b/svx/UIConfig_svx.mk
@@ -10,6 +10,7 @@
$(eval $(call gb_UIConfig_UIConfig,svx))
$(eval $(call gb_UIConfig_add_uifiles,svx,\
svx/uiconfig/ui/absrecbox \
svx/uiconfig/ui/acceptrejectchangesdialog \
svx/uiconfig/ui/accessibilitycheckdialog \
svx/uiconfig/ui/accessibilitycheckentry \
diff --git a/svx/source/form/tbxform.cxx b/svx/source/form/tbxform.cxx
index 94e0064..1bd9047 100644
--- a/svx/source/form/tbxform.cxx
+++ b/svx/source/form/tbxform.cxx
@@ -39,30 +39,44 @@
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
SvxFmAbsRecWin::SvxFmAbsRecWin( vcl::Window* _pParent, SfxToolBoxControl* _pController )
:NumericField( _pParent, WB_BORDER )
,m_pController(_pController)
SvxFmAbsRecWin::SvxFmAbsRecWin(vcl::Window* pParent, SfxToolBoxControl* pController)
: InterimItemWindow(pParent, "svx/ui/absrecbox.ui", "AbsRecBox")
, m_xWidget(m_xBuilder->weld_entry("entry"))
, m_pController(pController)
{
SetMin(1);
SetFirst(1);
SetSpinSize(1);
SetSizePixel( Size(70,19) );
m_xWidget->connect_key_press(LINK(this, SvxFmAbsRecWin, KeyInputHdl));
m_xWidget->connect_activate(LINK(this, SvxFmAbsRecWin, ActivatedHdl));
m_xWidget->connect_focus_out(LINK(this, SvxFmAbsRecWin, FocusOutHdl));
SetDecimalDigits(0);
SetStrictFormat(true);
SetSizePixel(m_xWidget->get_preferred_size());
}
void SvxFmAbsRecWin::dispose()
{
m_xWidget.reset();
InterimItemWindow::dispose();
}
void SvxFmAbsRecWin::GetFocus()
{
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
SvxFmAbsRecWin::~SvxFmAbsRecWin()
{
disposeOnce();
}
void SvxFmAbsRecWin::FirePosition( bool _bForce )
{
if ( !_bForce && !IsValueChangedFromSaved() )
if (!_bForce && !m_xWidget->get_value_changed_from_saved())
return;
sal_Int64 nRecord = GetValue();
if (nRecord < GetMin() || nRecord > GetMax())
{
return;
}
sal_Int64 nRecord = m_xWidget->get_text().toInt64();
if (nRecord < 1)
nRecord = 1;
SfxInt32Item aPositionParam( FN_PARAM_1, static_cast<sal_Int32>(nRecord) );
@@ -75,24 +89,25 @@ void SvxFmAbsRecWin::FirePosition( bool _bForce )
aArgs );
m_pController->updateStatus();
SaveValue();
m_xWidget->save_value();
}
void SvxFmAbsRecWin::LoseFocus()
IMPL_LINK_NOARG(SvxFmAbsRecWin, FocusOutHdl, weld::Widget&, void)
{
FirePosition( false );
}
void SvxFmAbsRecWin::KeyInput( const KeyEvent& rKeyEvent )
IMPL_LINK(SvxFmAbsRecWin, KeyInputHdl, const KeyEvent&, rKEvt, bool)
{
if( rKeyEvent.GetKeyCode() == KEY_RETURN && !GetText().isEmpty() )
FirePosition( true );
else
NumericField::KeyInput( rKeyEvent );
return ChildKeyInput(rKEvt);
}
IMPL_LINK_NOARG(SvxFmAbsRecWin, ActivatedHdl, weld::Entry&, bool)
{
if (!m_xWidget->get_text().isEmpty())
FirePosition( true );
return true;
}
SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlAbsRec, SfxInt32Item );
@@ -106,7 +121,6 @@ SvxFmTbxCtlAbsRec::~SvxFmTbxCtlAbsRec()
{
}
void SvxFmTbxCtlAbsRec::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
{
sal_uInt16 nId = GetId();
@@ -119,12 +133,12 @@ void SvxFmTbxCtlAbsRec::StateChanged( sal_uInt16 nSID, SfxItemState eState, cons
{
const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >( pState );
DBG_ASSERT( pItem, "SvxFmTbxCtlAbsRec::StateChanged: invalid item!" );
pWin->SetValue( pItem ? pItem->GetValue() : -1 );
pWin->set_text(OUString::number(pItem ? pItem->GetValue() : -1));
}
bool bEnable = SfxItemState::DISABLED != eState && pState;
if (!bEnable)
pWin->SetText(OUString());
pWin->set_text(OUString());
// enabling/disabling of the window
diff --git a/svx/source/inc/tbxform.hxx b/svx/source/inc/tbxform.hxx
index f436a91..0d80e6e 100644
--- a/svx/source/inc/tbxform.hxx
+++ b/svx/source/inc/tbxform.hxx
@@ -20,25 +20,31 @@
#define INCLUDED_SVX_SOURCE_INC_TBXFORM_HXX
#include <sfx2/tbxctrl.hxx>
#include <vcl/field.hxx>
#include <sfx2/InterimItemWindow.hxx>
class SvxFmAbsRecWin final : public NumericField
class SvxFmAbsRecWin final : public InterimItemWindow
{
public:
SvxFmAbsRecWin( vcl::Window* _pParent, SfxToolBoxControl* _pController );
virtual void dispose() override;
virtual ~SvxFmAbsRecWin() override;
virtual void KeyInput( const KeyEvent& rKeyEvt ) override;
virtual void LoseFocus() override;
void set_text(const OUString& rText) { m_xWidget->set_text(rText); }
virtual void GetFocus() override;
private:
std::unique_ptr<weld::Entry> m_xWidget;
DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
DECL_LINK(ActivatedHdl, weld::Entry&, bool);
DECL_LINK(FocusOutHdl, weld::Widget&, void); // for invalidating our content when losing the focus
void FirePosition( bool _bForce );
SfxToolBoxControl* m_pController;
// for invalidating our content when losing the focus
};
class FixedText;
class SvxFmTbxCtlAbsRec : public SfxToolBoxControl
{
public:
@@ -53,7 +59,6 @@ public:
const SfxPoolItem* pState ) override;
};
class SvxFmTbxCtlRecText : public SfxToolBoxControl
{
public:
@@ -65,7 +70,6 @@ public:
virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window* pParent ) override;
};
class SvxFmTbxCtlRecFromText : public SfxToolBoxControl
{
public:
diff --git a/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx b/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx
index 05fdfe7..e29cb7e 100644
--- a/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx
+++ b/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx
@@ -118,7 +118,9 @@ ParaAboveSpacingWindow::ParaAboveSpacingWindow(vcl::Window* pParent)
void ParaAboveSpacingWindow::GetFocus()
{
m_xAboveSpacing->grab_focus();
if (m_xAboveSpacing)
m_xAboveSpacing->grab_focus();
ParaULSpacingWindow::GetFocus();
}
// ParaBelowSpacingWindow
@@ -134,7 +136,9 @@ ParaBelowSpacingWindow::ParaBelowSpacingWindow(vcl::Window* pParent)
void ParaBelowSpacingWindow::GetFocus()
{
m_xBelowSpacing->grab_focus();
if (m_xBelowSpacing)
m_xBelowSpacing->grab_focus();
ParaULSpacingWindow::GetFocus();
}
// ParaLRSpacingWindow
@@ -319,7 +323,9 @@ ParaLeftSpacingWindow::ParaLeftSpacingWindow(vcl::Window* pParent)
void ParaLeftSpacingWindow::GetFocus()
{
m_xBeforeSpacing->grab_focus();
if (m_xBeforeSpacing)
m_xBeforeSpacing->grab_focus();
ParaLRSpacingWindow::GetFocus();
}
// ParaRightSpacingWindow
@@ -336,7 +342,9 @@ ParaRightSpacingWindow::ParaRightSpacingWindow(vcl::Window* pParent)
void ParaRightSpacingWindow::GetFocus()
{
m_xAfterSpacing->grab_focus();
if (m_xAfterSpacing)
m_xAfterSpacing->grab_focus();
ParaLRSpacingWindow::GetFocus();
}
// ParaFirstLineSpacingWindow
@@ -353,7 +361,9 @@ ParaFirstLineSpacingWindow::ParaFirstLineSpacingWindow(vcl::Window* pParent)
void ParaFirstLineSpacingWindow::GetFocus()
{
m_xFLSpacing->grab_focus();
if (m_xFLSpacing)
m_xFLSpacing->grab_focus();
ParaLRSpacingWindow::GetFocus();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx
index 0fcf01d..bc92466 100644
--- a/svx/source/tbxctrls/grafctrl.cxx
+++ b/svx/source/tbxctrls/grafctrl.cxx
@@ -264,7 +264,9 @@ void ImplGrafControl::dispose()
void ImplGrafControl::GetFocus()
{
mxField->grab_focus();
if (mxField)
mxField->grab_focus();
InterimItemWindow::GetFocus();
}
namespace {
@@ -289,7 +291,9 @@ public:
virtual void GetFocus() override
{
m_xWidget->grab_focus();
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
void set_sensitive(bool bSensitive)
diff --git a/svx/source/tbxctrls/itemwin.cxx b/svx/source/tbxctrls/itemwin.cxx
index 4be04c1..52f28c9 100644
--- a/svx/source/tbxctrls/itemwin.cxx
+++ b/svx/source/tbxctrls/itemwin.cxx
@@ -180,7 +180,9 @@ void SvxMetricField::DataChanged( const DataChangedEvent& rDCEvt )
void SvxMetricField::GetFocus()
{
m_xWidget->grab_focus();
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
SvxFillTypeBox::SvxFillTypeBox( vcl::Window* pParent ) :
diff --git a/svx/source/tbxctrls/tbunocontroller.cxx b/svx/source/tbxctrls/tbunocontroller.cxx
index 81c4b8e..f03a9b3 100644
--- a/svx/source/tbxctrls/tbunocontroller.cxx
+++ b/svx/source/tbxctrls/tbunocontroller.cxx
@@ -157,7 +157,9 @@ SvxFontSizeBox_Impl::~SvxFontSizeBox_Impl()
void SvxFontSizeBox_Impl::GetFocus()
{
m_xWidget->grab_focus();
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
void SvxFontSizeBox_Impl::ReleaseFocus_Impl()
diff --git a/svx/uiconfig/ui/absrecbox.ui b/svx/uiconfig/ui/absrecbox.ui
new file mode 100644
index 0000000..f61f755
--- /dev/null
+++ b/svx/uiconfig/ui/absrecbox.ui
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface domain="svx">
<requires lib="gtk+" version="3.18"/>
<object class="GtkBox" id="AbsRecBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="spacing">4</property>
<child>
<object class="GtkEntry" id="entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="width_chars">4</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</interface>
diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx
index 70e5d4f..e60ce29 100644
--- a/sw/source/uibase/ribbar/workctrl.cxx
+++ b/sw/source/uibase/ribbar/workctrl.cxx
@@ -560,7 +560,9 @@ public:
virtual void GetFocus() override
{
m_xWidget->grab_focus();
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
void save_value()
@@ -768,7 +770,9 @@ public:
}
virtual void GetFocus() override
{
m_xWidget->grab_focus();
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
virtual ~SwJumpToSpecificBox_Impl() override
{
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index d53ea92..6867bcc 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -736,7 +736,8 @@ public:
virtual void set_toolbar_background() override
{
m_xWidget->SetBackground(Wallpaper(COL_TRANSPARENT));
m_xWidget->SetBackground();
m_xWidget->SetPaintTransparent(true);
}
virtual void set_highlight_background() override