From 8328d84a0ce8c1b9592ce0dbab17dbbecc423b3c Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 9 Jul 2020 20:16:22 +0100 Subject: weld CheckBoxControl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iea057189ab17c1fdaf6663f1c328b9d288d97a18 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98532 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- dbaccess/source/ui/control/TableGrantCtrl.cxx | 9 +- .../source/ui/querydesign/SelectionBrowseBox.cxx | 28 +++-- include/svtools/editbrowsebox.hxx | 53 +++++---- solenv/sanitizers/ui/svt.suppr | 1 + svtools/UIConfig_svt.mk | 1 + svtools/source/brwbox/ebbcontrols.cxx | 117 +++++--------------- svtools/source/brwbox/editbrowsebox.cxx | 30 +++-- svtools/uiconfig/ui/checkboxcontrol.ui | 30 +++++ svx/source/fmcomp/gridcell.cxx | 123 ++++++--------------- svx/source/inc/gridcell.hxx | 14 +-- sw/source/ui/index/cnttab.cxx | 7 +- vcl/source/app/salvtables.cxx | 5 +- vcl/unx/gtk3/gtk3gtkinst.cxx | 2 +- 13 files changed, 169 insertions(+), 251 deletions(-) create mode 100644 svtools/uiconfig/ui/checkboxcontrol.ui diff --git a/dbaccess/source/ui/control/TableGrantCtrl.cxx b/dbaccess/source/ui/control/TableGrantCtrl.cxx index dd2f4b4574b8..6aba975d6b8a 100644 --- a/dbaccess/source/ui/control/TableGrantCtrl.cxx +++ b/dbaccess/source/ui/control/TableGrantCtrl.cxx @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -133,8 +132,8 @@ void OTableGrantControl::Init() // instantiate ComboBox if(!m_pCheckCell) { - m_pCheckCell = VclPtr::Create( &GetDataWindow() ); - m_pCheckCell->GetBox().EnableTriState(false); + m_pCheckCell = VclPtr::Create( &GetDataWindow() ); + m_pCheckCell->EnableTriState(false); m_pEdit = VclPtr::Create(&GetDataWindow()); weld::Entry& rEntry = m_pEdit->get_widget(); @@ -195,7 +194,7 @@ bool OTableGrantControl::IsTabAllowed(bool bForward) const } #define GRANT_REVOKE_RIGHT(what) \ - if(m_pCheckCell->GetBox().IsChecked()) \ + if (m_pCheckCell->GetBox().get_active()) \ xAuth->grantPrivileges(sTableName,PrivilegeObject::TABLE,what);\ else \ xAuth->revokePrivileges(sTableName,PrivilegeObject::TABLE,what) @@ -281,7 +280,7 @@ void OTableGrantControl::InitController( CellControllerRef& /*rController*/, lon { // get the privileges from the user TTablePrivilegeMap::const_iterator aFind = findPrivilege(nRow); - m_pCheckCell->GetBox().Check(aFind != m_aPrivMap.end() && isAllowed(nColumnId,aFind->second.nRights)); + m_pCheckCell->GetBox().set_active(aFind != m_aPrivMap.end() && isAllowed(nColumnId,aFind->second.nRights)); } } diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index ecdd09bd4fb4..bb7bd9584115 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -34,7 +34,6 @@ #include #include #include "QTableWindow.hxx" -#include #include #include #include "QueryDesignFieldUndoAct.hxx" @@ -134,7 +133,7 @@ OSelectionBrowseBox::OSelectionBrowseBox( vcl::Window* pParent ) m_pFunctionCell->SetHelpId(HID_QRYDGN_ROW_FUNCTION); // switch off triState of css::form::CheckBox - m_pVisibleCell->GetBox().EnableTriState( false ); + m_pVisibleCell->EnableTriState( false ); vcl::Font aTitleFont = OutputDevice::GetDefaultFont( DefaultFontType::SANS_UNICODE,Window::GetSettings().GetLanguageTag().getLanguageType(),GetDefaultFontFlags::OnlyOne); aTitleFont.SetFontSize(Size(0, 6)); @@ -513,8 +512,8 @@ void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, lon } break; case BROW_VIS_ROW: { - m_pVisibleCell->GetBox().Check(pEntry->IsVisible()); - m_pVisibleCell->GetBox().SaveValue(); + m_pVisibleCell->GetBox().set_active(pEntry->IsVisible()); + m_pVisibleCell->GetBox().save_state(); enableControl(pEntry,m_pTextCell); @@ -522,10 +521,9 @@ void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, lon { // a column has to visible in order to show up in ORDER BY pEntry->SetVisible(); - m_pVisibleCell->GetBox().Check(pEntry->IsVisible()); - m_pVisibleCell->GetBox().SaveValue(); - m_pVisibleCell->GetBox().Disable(); - m_pVisibleCell->GetBox().EnableInput(false); + m_pVisibleCell->GetBox().set_active(pEntry->IsVisible()); + m_pVisibleCell->GetBox().save_state(); + m_pVisibleCell->GetBox().set_sensitive(false); OUString aMessage(DBA_RES(STR_QRY_ORDERBY_UNRELATED)); OQueryDesignView* paDView = getDesignView(); std::unique_ptr xInfoBox(Application::CreateMessageDialog(paDView ? paDView->GetFrameWeld() : nullptr, @@ -914,19 +912,19 @@ bool OSelectionBrowseBox::SaveModified() { case BROW_VIS_ROW: { - bool bOldValue = m_pVisibleCell->GetBox().GetSavedValue() != TRISTATE_FALSE; + bool bOldValue = m_pVisibleCell->GetBox().get_saved_state() != TRISTATE_FALSE; strOldCellContents = bOldValue ? OUStringLiteral("1") : OUStringLiteral("0"); sNewValue = !bOldValue ? OUStringLiteral("1") : OUStringLiteral("0"); } if((m_bOrderByUnRelated || pEntry->GetOrderDir() == ORDER_NONE) && (m_bGroupByUnRelated || !pEntry->IsGroupBy())) { - pEntry->SetVisible(m_pVisibleCell->GetBox().IsChecked()); + pEntry->SetVisible(m_pVisibleCell->GetBox().get_active()); } else { pEntry->SetVisible(); - m_pVisibleCell->GetBox().Check(); + m_pVisibleCell->GetBox().set_active(true); } break; @@ -1030,7 +1028,7 @@ bool OSelectionBrowseBox::SaveModified() if(!m_bOrderByUnRelated) { pEntry->SetVisible(); - m_pVisibleCell->GetBox().Check(); + m_pVisibleCell->GetBox().set_active(true); RowModified(GetBrowseRow(BROW_VIS_ROW), GetCurColumnId()); } sNewValue = OUString::number(static_cast(pEntry->GetOrderDir())); @@ -1058,7 +1056,7 @@ bool OSelectionBrowseBox::SaveModified() { // we have to change the visible flag, so we must append also an undo action pEntry->SetVisible(); - m_pVisibleCell->GetBox().Check(); + m_pVisibleCell->GetBox().set_active(true); appendUndoAction("0","1",BROW_VIS_ROW,bListAction); RowModified(GetBrowseRow(BROW_VIS_ROW), GetCurColumnId()); } @@ -1873,11 +1871,11 @@ void OSelectionBrowseBox::CellModified() !pEntry->IsEmpty() && pEntry->GetOrderDir() != ORDER_NONE) { - m_pVisibleCell->GetBox().Check(); + m_pVisibleCell->GetBox().set_active(true); pEntry->SetVisible(); } else - pEntry->SetVisible(m_pVisibleCell->GetBox().IsChecked()); + pEntry->SetVisible(m_pVisibleCell->GetBox().get_active()); } break; } diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx index cbeb152c15d1..3b21aaea53c4 100644 --- a/include/svtools/editbrowsebox.hxx +++ b/include/svtools/editbrowsebox.hxx @@ -37,7 +37,6 @@ class BrowserDataWin; class Button; -class CheckBox; class SpinField; // EditBrowseBoxFlags (EBBF) @@ -219,11 +218,10 @@ namespace svt virtual bool ProcessKey(const KeyEvent& rKEvt); + virtual void Draw(OutputDevice* pDevice, const Point& rPos, DrawFlags nFlags) override; protected: void InitControlBase(weld::Widget* pWidget); - virtual void Draw(OutputDevice* pDevice, const Point& rPos, DrawFlags nFlags) override; - DECL_LINK(KeyInputHdl, const KeyEvent&, bool); private: weld::Widget* m_pWidget; @@ -580,33 +578,48 @@ namespace svt }; //= CheckBoxControl - class SVT_DLLPUBLIC CheckBoxControl final : public Control + class SVT_DLLPUBLIC CheckBoxControl final : public ControlBase { - VclPtr pBox; - Link,void> m_aClickLink; - Link m_aModifyLink; + std::unique_ptr m_xBox; + Link m_aClickLink; + Link m_aModify1Hdl; + Link m_aModify2Hdl; + bool m_bTriState; public: - CheckBoxControl(vcl::Window* pParent); + CheckBoxControl(BrowserDataWin* pParent); virtual ~CheckBoxControl() override; virtual void dispose() override; - virtual void GetFocus() override; - virtual bool PreNotify(NotifyEvent& rEvt) override; - virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rClientRect) override; - virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; - virtual void StateChanged( StateChangedType nStateChange ) override; - virtual void DataChanged( const DataChangedEvent& _rEvent ) override; - virtual void Resize() override; + void SetClickHdl(const Link& rHdl) {m_aClickLink = rHdl;} - void SetClickHdl(const Link,void>& rHdl) {m_aClickLink = rHdl;} + // sets a link to call when the text is changed by the user + void SetModifyHdl(const Link& rHdl) + { + m_aModify1Hdl = rHdl; + } - void SetModifyHdl(const Link& rHdl) {m_aModifyLink = rHdl;} + // sets an additional link to call when the text is changed by the user + void SetAuxModifyHdl(const Link& rLink) + { + m_aModify2Hdl = rLink; + } - CheckBox& GetBox() {return *pBox;}; + void SetState(TriState eState); + TriState GetState() const { return m_xBox->get_state(); } + + void EnableTriState(bool bTriState); + + weld::CheckButton& GetBox() {return *m_xBox;}; private: - DECL_LINK( OnClick, Button*, void ); + DECL_LINK(OnClick, weld::Button&, void); + + void CallModifyHdls() + { + m_aModify1Hdl.Call(nullptr); + m_aModify2Hdl.Call(nullptr); + } }; //= CheckBoxCellController @@ -615,7 +628,7 @@ namespace svt public: CheckBoxCellController(CheckBoxControl* pWin); - CheckBox& GetCheckBox() const; + weld::CheckButton& GetCheckBox() const; virtual bool IsValueChangedFromSaved() const override; virtual void SaveValue() override; diff --git a/solenv/sanitizers/ui/svt.suppr b/solenv/sanitizers/ui/svt.suppr index 9c5609725170..9dbf9314d933 100644 --- a/solenv/sanitizers/ui/svt.suppr +++ b/solenv/sanitizers/ui/svt.suppr @@ -1,3 +1,4 @@ +svtools/uiconfig/ui/checkboxcontrol.ui://GtkCheckButton[@id='checkbox'] button-no-label svtools/uiconfig/ui/editcontrol.ui://GtkEntry[@id='entry'] no-labelled-by svtools/uiconfig/ui/graphicexport.ui://GtkSpinButton[@id='compressionjpgnf'] no-labelled-by svtools/uiconfig/ui/graphicexport.ui://GtkScale[@id='compressionjpgsb'] no-labelled-by diff --git a/svtools/UIConfig_svt.mk b/svtools/UIConfig_svt.mk index 4b7cbecf4e75..d11f9ff97509 100644 --- a/svtools/UIConfig_svt.mk +++ b/svtools/UIConfig_svt.mk @@ -12,6 +12,7 @@ $(eval $(call gb_UIConfig_UIConfig,svt)) $(eval $(call gb_UIConfig_add_uifiles,svt,\ svtools/uiconfig/ui/addresstemplatedialog \ svtools/uiconfig/ui/calendar \ + svtools/uiconfig/ui/checkboxcontrol \ svtools/uiconfig/ui/combocontrol \ svtools/uiconfig/ui/datewindow \ svtools/uiconfig/ui/editcontrol \ diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx index fc96e14e4de4..911063b82d4e 100644 --- a/svtools/source/brwbox/ebbcontrols.cxx +++ b/svtools/source/brwbox/ebbcontrols.cxx @@ -17,7 +17,6 @@ */ #include -#include #include #include #include @@ -166,109 +165,52 @@ namespace svt } //= CheckBoxControl - CheckBoxControl::CheckBoxControl(vcl::Window* pParent) - :Control(pParent, 0) + CheckBoxControl::CheckBoxControl(BrowserDataWin* pParent) + : ControlBase(pParent, "svt/ui/checkboxcontrol.ui", "CheckBoxControl") + , m_xBox(m_xBuilder->weld_check_button("checkbox")) + , m_bTriState(true) { - const Wallpaper& rParentBackground = pParent->GetBackground(); - if ( (pParent->GetStyle() & WB_CLIPCHILDREN) || rParentBackground.IsFixed() ) - SetBackground( rParentBackground ); - else - { - SetPaintTransparent( true ); - SetBackground(); - } - - EnableChildTransparentMode(); - - pBox = VclPtr::Create(this,WB_CENTER|WB_VCENTER); - pBox->EnableTriState( true ); - pBox->SetLegacyNoTextAlign( true ); - pBox->EnableChildTransparentMode(); - pBox->SetPaintTransparent( true ); - pBox->SetClickHdl( LINK( this, CheckBoxControl, OnClick ) ); - pBox->Show(); - } - - CheckBoxControl::~CheckBoxControl() - { - disposeOnce(); + InitControlBase(m_xBox.get()); + m_xBox->connect_key_press(LINK(this, ControlBase, KeyInputHdl)); + m_xBox->connect_clicked(LINK(this, CheckBoxControl, OnClick)); } - void CheckBoxControl::dispose() - { - pBox.disposeAndClear(); - Control::dispose(); - } - - - IMPL_LINK_NOARG(CheckBoxControl, OnClick, Button*, void) - { - m_aClickLink.Call(pBox); - m_aModifyLink.Call(nullptr); - } - - - void CheckBoxControl::Resize() - { - Control::Resize(); - pBox->SetPosSizePixel(Point(0,0),GetSizePixel()); - } - - - void CheckBoxControl::DataChanged( const DataChangedEvent& _rEvent ) + void CheckBoxControl::EnableTriState( bool bTriState ) { - if ( _rEvent.GetType() == DataChangedEventType::SETTINGS ) - pBox->SetSettings( GetSettings() ); - } - + if (m_bTriState != bTriState) + { + m_bTriState = bTriState; - void CheckBoxControl::StateChanged( StateChangedType nStateChange ) - { - Control::StateChanged(nStateChange); - if ( nStateChange == StateChangedType::Zoom ) - pBox->SetZoom(GetZoom()); + if (!m_bTriState && GetState() == TRISTATE_INDET) + SetState(TRISTATE_FALSE); + } } - void CheckBoxControl::Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) + void CheckBoxControl::SetState(TriState eState) { - pBox->Draw(pDev, rPos, nFlags); + if (!m_bTriState && (eState == TRISTATE_INDET)) + eState = TRISTATE_FALSE; + m_xBox->set_state(eState); } - void CheckBoxControl::GetFocus() + CheckBoxControl::~CheckBoxControl() { - if (pBox) - pBox->GrabFocus(); + disposeOnce(); } - - void CheckBoxControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rClientRect) + void CheckBoxControl::dispose() { - Control::Paint(rRenderContext, rClientRect); - if (HasFocus()) - ShowFocus(tools::Rectangle()); + m_xBox.reset(); + ControlBase::dispose(); } - - bool CheckBoxControl::PreNotify(NotifyEvent& rEvt) + IMPL_LINK_NOARG(CheckBoxControl, OnClick, weld::Button&, void) { - switch (rEvt.GetType()) - { - case MouseNotifyEvent::GETFOCUS: - ShowFocus(tools::Rectangle()); - break; - case MouseNotifyEvent::LOSEFOCUS: - HideFocus(); - break; - default: - break; - } - return Control::PreNotify(rEvt); + m_aClickLink.Call(*m_xBox); + CallModifyHdls(); } - //= CheckBoxCellController - - CheckBoxCellController::CheckBoxCellController(CheckBoxControl* pWin) : CellController(pWin) { @@ -280,20 +222,19 @@ namespace svt return true; } - - CheckBox& CheckBoxCellController::GetCheckBox() const + weld::CheckButton& CheckBoxCellController::GetCheckBox() const { return static_cast(GetWindow()).GetBox(); } bool CheckBoxCellController::IsValueChangedFromSaved() const { - return GetCheckBox().IsValueChangedFromSaved(); + return GetCheckBox().get_state_changed_from_saved(); } void CheckBoxCellController::SaveValue() { - GetCheckBox().SaveValue(); + GetCheckBox().save_state(); } IMPL_LINK_NOARG(CheckBoxCellController, ModifyHdl, LinkParamNone*, void) diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx index 72c66b786cc0..b9249ccd9ebc 100644 --- a/svtools/source/brwbox/editbrowsebox.cxx +++ b/svtools/source/brwbox/editbrowsebox.cxx @@ -19,12 +19,11 @@ #include -#include #include -#include - -#include +#include #include +#include +#include #include @@ -1204,13 +1203,11 @@ namespace svt return nNewColWidth; } - sal_uInt32 EditBrowseBox::GetTotalCellWidth(long, sal_uInt16) { return 0; } - void EditBrowseBox::InvalidateHandleColumn() { tools::Rectangle aHdlFieldRect( GetFieldRectPixel( 0, 0 )); @@ -1219,20 +1216,21 @@ namespace svt Invalidate( aInvalidRect ); } - void EditBrowseBox::PaintTristate(const tools::Rectangle& rRect, const TriState& eState, bool _bEnabled) const { - pCheckBoxPaint->GetBox().SetState(eState); - pCheckBoxPaint->SetPosSizePixel(rRect.TopLeft(), rRect.GetSize()); + pCheckBoxPaint->SetState(eState); - pCheckBoxPaint->GetBox().Enable(_bEnabled); - pCheckBoxPaint->Show(); - pCheckBoxPaint->SetParentUpdateMode( false ); - pCheckBoxPaint->PaintImmediately(); - pCheckBoxPaint->Hide(); - pCheckBoxPaint->SetParentUpdateMode( true ); - } + pCheckBoxPaint->GetBox().set_sensitive(_bEnabled); + auto nWidth = pCheckBoxPaint->GetBox().get_preferred_size().Width(); + auto nHeight = pCheckBoxPaint->GetBox().get_preferred_size().Height(); + tools::Rectangle aRect(Point(rRect.Left() + ((rRect.GetWidth() - nWidth) / 2), + rRect.Top() + ((rRect.GetHeight() - nHeight) / 2)), + Size(nWidth, nHeight)); + pCheckBoxPaint->SetPosSizePixel(aRect.TopLeft(), aRect.GetSize()); + + pCheckBoxPaint->Draw(&GetDataWindow(), aRect.TopLeft(), DrawFlags::NONE); + } void EditBrowseBox::AsynchGetFocus() { diff --git a/svtools/uiconfig/ui/checkboxcontrol.ui b/svtools/uiconfig/ui/checkboxcontrol.ui new file mode 100644 index 000000000000..786b09107db3 --- /dev/null +++ b/svtools/uiconfig/ui/checkboxcontrol.ui @@ -0,0 +1,30 @@ + + + + + + True + False + True + True + vertical + + + True + True + False + center + center + True + True + True + True + + + True + True + 0 + + + + diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index d5633c10f4e3..67137720d18b 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -56,7 +56,6 @@ #include #include -#include #include #include #include @@ -1625,7 +1624,6 @@ namespace } } - void DbCheckBox::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCursor) { setTransparent( true ); @@ -1650,8 +1648,8 @@ void DbCheckBox::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCurs bool bTristate = true; OSL_VERIFY( xModel->getPropertyValue( FM_PROP_TRISTATE ) >>= bTristate ); - static_cast< CheckBoxControl* >( m_pWindow.get() )->GetBox().EnableTriState( bTristate ); - static_cast< CheckBoxControl* >( m_pPainter.get() )->GetBox().EnableTriState( bTristate ); + static_cast< CheckBoxControl* >( m_pWindow.get() )->EnableTriState( bTristate ); + static_cast< CheckBoxControl* >( m_pPainter.get() )->EnableTriState( bTristate ); } catch( const Exception& ) { @@ -1661,7 +1659,6 @@ void DbCheckBox::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCurs DbCellControl::Init( rParent, xCursor ); } - CellControllerRef DbCheckBox::CreateController() const { return new CheckBoxCellController(static_cast(m_pWindow.get())); @@ -1684,16 +1681,14 @@ static void lcl_setCheckBoxState( const Reference< css::sdb::XColumn >& _rxFie DBG_UNHANDLED_EXCEPTION("svx"); } } - _pCheckBoxControl->GetBox().SetState(eState); + _pCheckBoxControl->SetState(eState); } - void DbCheckBox::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/) { lcl_setCheckBoxState( _rxField, static_cast(m_pWindow.get()) ); } - void DbCheckBox::PaintFieldToCell(OutputDevice& rDev, const tools::Rectangle& rRect, const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter) @@ -1710,25 +1705,22 @@ void DbCheckBox::PaintFieldToCell(OutputDevice& rDev, const tools::Rectangle& rR DbCellControl::PaintFieldToCell(rDev, aRect, _rxField, xFormatter); } - void DbCheckBox::updateFromModel( Reference< XPropertySet > _rxModel ) { OSL_ENSURE( _rxModel.is() && m_pWindow, "DbCheckBox::updateFromModel: invalid call!" ); sal_Int16 nState = TRISTATE_INDET; _rxModel->getPropertyValue( FM_PROP_STATE ) >>= nState; - static_cast< CheckBoxControl* >( m_pWindow.get() )->GetBox().SetState( static_cast< TriState >( nState ) ); + static_cast< CheckBoxControl* >( m_pWindow.get() )->SetState( static_cast< TriState >( nState ) ); } - bool DbCheckBox::commitControl() { m_rColumn.getModel()->setPropertyValue( FM_PROP_STATE, - makeAny( static_cast( static_cast< CheckBoxControl* >( m_pWindow.get() )->GetBox().GetState() ) ) ); + makeAny( static_cast( static_cast< CheckBoxControl* >( m_pWindow.get() )->GetState() ) ) ); return true; } - OUString DbCheckBox::GetFormatText(const Reference< XColumn >& /*_rxField*/, const Reference< XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/) { return OUString(); @@ -2120,19 +2112,16 @@ namespace } } - OUString DbCurrencyField::GetFormatText(const Reference< css::sdb::XColumn >& _rxField, const Reference< css::util::XNumberFormatter >& _rxFormatter, Color** /*ppColor*/) { return lcl_setFormattedCurrency_nothrow( dynamic_cast< LongCurrencyField& >( *m_pPainter ), *this, _rxField, _rxFormatter ); } - void DbCurrencyField::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< css::util::XNumberFormatter >& _rxFormatter) { lcl_setFormattedCurrency_nothrow( dynamic_cast< LongCurrencyField& >( *m_pWindow ), *this, _rxField, _rxFormatter ); } - void DbCurrencyField::updateFromModel( Reference< XPropertySet > _rxModel ) { OSL_ENSURE( _rxModel.is() && m_pWindow, "DbCurrencyField::updateFromModel: invalid call!" ); @@ -2266,13 +2255,11 @@ OUString DbDateField::GetFormatText(const Reference< css::sdb::XColumn >& _rxFie return lcl_setFormattedDate_nothrow(dynamic_cast(*m_pPainter), _rxField); } - void DbDateField::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/) { lcl_setFormattedDate_nothrow(dynamic_cast(*m_pWindow), _rxField); } - void DbDateField::updateFromModel( Reference< XPropertySet > _rxModel ) { OSL_ENSURE( _rxModel.is() && m_pWindow, "DbDateField::updateFromModel: invalid call!" ); @@ -2284,7 +2271,6 @@ void DbDateField::updateFromModel( Reference< XPropertySet > _rxModel ) static_cast< DateField* >( m_pWindow.get() )->SetText( OUString() ); } - bool DbDateField::commitControl() { OUString aText(m_pWindow->GetText()); @@ -2373,13 +2359,11 @@ OUString DbTimeField::GetFormatText(const Reference< css::sdb::XColumn >& _rxFie return lcl_setFormattedTime_nothrow( *static_cast< TimeField* >( m_pPainter.get() ), _rxField ); } - void DbTimeField::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/) { lcl_setFormattedTime_nothrow( *static_cast< TimeField* >( m_pWindow.get() ), _rxField ); } - void DbTimeField::updateFromModel( Reference< XPropertySet > _rxModel ) { OSL_ENSURE( _rxModel.is() && m_pWindow, "DbTimeField::updateFromModel: invalid call!" ); @@ -2391,7 +2375,6 @@ void DbTimeField::updateFromModel( Reference< XPropertySet > _rxModel ) static_cast< TimeField* >( m_pWindow.get() )->SetText( OUString() ); } - bool DbTimeField::commitControl() { OUString aText(m_pWindow->GetText()); @@ -2470,13 +2453,11 @@ void DbComboBox::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCurs DbCellControl::Init( rParent, xCursor ); } - CellControllerRef DbComboBox::CreateController() const { return new ComboBoxCellController(static_cast(m_pWindow.get())); } - OUString DbComboBox::GetFormatText(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter, Color** /*ppColor*/) { const css::uno::Reference xPS(_rxField, UNO_QUERY); @@ -2670,7 +2651,7 @@ DbFilterField::DbFilterField(const Reference< XComponentContext >& rxContext,DbG DbFilterField::~DbFilterField() { if (m_nControlClass == css::form::FormComponentType::CHECKBOX) - static_cast(m_pWindow.get())->SetClickHdl( Link,void>() ); + static_cast(m_pWindow.get())->SetClickHdl( Link() ); } @@ -2932,8 +2913,8 @@ void DbFilterField::SetText(const OUString& rText) else eState = TRISTATE_INDET; - static_cast(m_pWindow.get())->GetBox().SetState(eState); - static_cast(m_pPainter.get())->GetBox().SetState(eState); + static_cast(m_pWindow.get())->SetState(eState); + static_cast(m_pPainter.get())->SetState(eState); } break; case css::form::FormComponentType::LISTBOX: { @@ -3073,16 +3054,14 @@ OUString DbFilterField::GetFormatText(const Reference< XColumn >& /*_rxField*/, return OUString(); } - void DbFilterField::UpdateFromField(const Reference< XColumn >& /*_rxField*/, const Reference< XNumberFormatter >& /*xFormatter*/) { OSL_FAIL( "DbFilterField::UpdateFromField: cannot update a filter control from a field!" ); } - -IMPL_LINK_NOARG(DbFilterField, OnClick, VclPtr, void) +IMPL_LINK_NOARG(DbFilterField, OnClick, weld::Button&, void) { - TriState eState = static_cast(m_pWindow.get())->GetBox().GetState(); + TriState eState = static_cast(m_pWindow.get())->GetState(); OUStringBuffer aTextBuf; Reference< XRowSet > xDataSourceRowSet( @@ -3578,12 +3557,9 @@ FmXEditCell::~FmXEditCell() acquire(); dispose(); } - - } // OComponentHelper - void FmXEditCell::disposing() { css::lang::EventObject aEvt(*this); @@ -3597,7 +3573,6 @@ void FmXEditCell::disposing() FmXDataCell::disposing(); } - Any SAL_CALL FmXEditCell::queryAggregation( const css::uno::Type& _rType ) { Any aReturn = FmXTextCell::queryAggregation( _rType ); @@ -3608,7 +3583,6 @@ Any SAL_CALL FmXEditCell::queryAggregation( const css::uno::Type& _rType ) return aReturn; } - Sequence< css::uno::Type > SAL_CALL FmXEditCell::getTypes( ) { return ::comphelper::concatSequences( @@ -3617,11 +3591,9 @@ Sequence< css::uno::Type > SAL_CALL FmXEditCell::getTypes( ) ); } - IMPLEMENT_GET_IMPLEMENTATION_ID( FmXEditCell ) // css::awt::XTextComponent - void SAL_CALL FmXEditCell::addTextListener(const Reference< css::awt::XTextListener >& l) { m_aTextListeners.addInterface( l ); @@ -3721,7 +3693,6 @@ sal_Bool SAL_CALL FmXEditCell::isEditable() return m_pEditImplementation && !m_pEditImplementation->IsReadOnly() && m_pEditImplementation->GetControl().IsEnabled(); } - void SAL_CALL FmXEditCell::setEditable( sal_Bool bEditable ) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -3730,7 +3701,6 @@ void SAL_CALL FmXEditCell::setEditable( sal_Bool bEditable ) m_pEditImplementation->SetReadOnly( !bEditable ); } - sal_Int16 SAL_CALL FmXEditCell::getMaxTextLen() { ::osl::MutexGuard aGuard( m_aMutex ); @@ -3738,7 +3708,6 @@ sal_Int16 SAL_CALL FmXEditCell::getMaxTextLen() return m_pEditImplementation ? m_pEditImplementation->GetMaxTextLen() : 0; } - void SAL_CALL FmXEditCell::setMaxTextLen( sal_Int16 nLen ) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -3747,19 +3716,16 @@ void SAL_CALL FmXEditCell::setMaxTextLen( sal_Int16 nLen ) m_pEditImplementation->SetMaxTextLen( nLen ); } - void SAL_CALL FmXEditCell::addChangeListener( const Reference< form::XChangeListener >& Listener ) { m_aChangeListeners.addInterface( Listener ); } - void SAL_CALL FmXEditCell::removeChangeListener( const Reference< form::XChangeListener >& Listener ) { m_aChangeListeners.removeInterface( Listener ); } - void FmXEditCell::onTextChanged() { css::awt::TextEvent aEvent; @@ -3794,8 +3760,9 @@ FmXCheckBoxCell::FmXCheckBoxCell( DbGridColumn* pColumn, std::unique_ptr( m_pCellControl->GetWindow() ).GetBox() ) + ,m_pBox( & static_cast< CheckBoxControl& >( m_pCellControl->GetWindow() ) ) { + m_pBox->SetAuxModifyHdl(LINK(this, FmXCheckBoxCell, ModifyHdl)); } FmXCheckBoxCell::~FmXCheckBoxCell() @@ -3814,7 +3781,7 @@ void FmXCheckBoxCell::disposing() m_aItemListeners.disposeAndClear(aEvt); m_aActionListeners.disposeAndClear(aEvt); - static_cast< CheckBoxControl& >( m_pCellControl->GetWindow() ).SetClickHdl(Link,void>()); + m_pBox->SetClickHdl(Link()); m_pBox = nullptr; FmXDataCell::disposing(); @@ -3843,19 +3810,16 @@ Sequence< css::uno::Type > SAL_CALL FmXCheckBoxCell::getTypes( ) IMPLEMENT_GET_IMPLEMENTATION_ID( FmXCheckBoxCell ) - void SAL_CALL FmXCheckBoxCell::addItemListener( const Reference< css::awt::XItemListener >& l ) { m_aItemListeners.addInterface( l ); } - void SAL_CALL FmXCheckBoxCell::removeItemListener( const Reference< css::awt::XItemListener >& l ) { m_aItemListeners.removeInterface( l ); } - void SAL_CALL FmXCheckBoxCell::setState( sal_Int16 n ) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -3867,7 +3831,6 @@ void SAL_CALL FmXCheckBoxCell::setState( sal_Int16 n ) } } - sal_Int16 SAL_CALL FmXCheckBoxCell::getState() { ::osl::MutexGuard aGuard( m_aMutex ); @@ -3880,8 +3843,7 @@ sal_Int16 SAL_CALL FmXCheckBoxCell::getState() return TRISTATE_INDET; } - -void SAL_CALL FmXCheckBoxCell::enableTriState( sal_Bool b ) +void SAL_CALL FmXCheckBoxCell::enableTriState(sal_Bool b) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -3889,7 +3851,6 @@ void SAL_CALL FmXCheckBoxCell::enableTriState( sal_Bool b ) m_pBox->EnableTriState( b ); } - void SAL_CALL FmXCheckBoxCell::addActionListener( const Reference< awt::XActionListener >& Listener ) { m_aActionListeners.addInterface( Listener ); @@ -3901,7 +3862,6 @@ void SAL_CALL FmXCheckBoxCell::removeActionListener( const Reference< awt::XActi m_aActionListeners.removeInterface( Listener ); } - void SAL_CALL FmXCheckBoxCell::setLabel( const OUString& Label ) { SolarMutexGuard aGuard; @@ -3912,52 +3872,33 @@ void SAL_CALL FmXCheckBoxCell::setLabel( const OUString& Label ) } } - void SAL_CALL FmXCheckBoxCell::setActionCommand( const OUString& Command ) { m_aActionCommand = Command; } - -vcl::Window* FmXCheckBoxCell::getEventWindow() const +IMPL_LINK_NOARG(FmXCheckBoxCell, ModifyHdl, LinkParamNone*, void) { - return m_pBox; -} + // check boxes are to be committed immediately (this holds for ordinary check box controls in + // documents, and this must hold for check boxes in grid columns, too + // 91210 - 22.08.2001 - frank.schoenheit@sun.com + m_pCellControl->Commit(); - -void FmXCheckBoxCell::onWindowEvent( const VclEventId _nEventId, const vcl::Window& _rWindow, const void* _pEventData ) -{ - switch ( _nEventId ) - { - case VclEventId::CheckboxToggle: + Reference< XWindow > xKeepAlive( this ); + if ( m_aItemListeners.getLength() && m_pBox ) { - // check boxes are to be committed immediately (this holds for ordinary check box controls in - // documents, and this must hold for check boxes in grid columns, too - // 91210 - 22.08.2001 - frank.schoenheit@sun.com - m_pCellControl->Commit(); - - Reference< XWindow > xKeepAlive( this ); - if ( m_aItemListeners.getLength() && m_pBox ) - { - awt::ItemEvent aEvent; - aEvent.Source = *this; - aEvent.Highlighted = 0; - aEvent.Selected = m_pBox->GetState(); - m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent ); - } - if ( m_aActionListeners.getLength() ) - { - awt::ActionEvent aEvent; - aEvent.Source = *this; - aEvent.ActionCommand = m_aActionCommand; - m_aActionListeners.notifyEach( &awt::XActionListener::actionPerformed, aEvent ); - } + awt::ItemEvent aEvent; + aEvent.Source = *this; + aEvent.Highlighted = 0; + aEvent.Selected = m_pBox->GetState(); + m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent ); } - break; - - default: - FmXDataCell::onWindowEvent( _nEventId, _rWindow, _pEventData ); - break; + if ( m_aActionListeners.getLength() ) + { + awt::ActionEvent aEvent; + aEvent.Source = *this; + aEvent.ActionCommand = m_aActionCommand; + m_aActionListeners.notifyEach( &awt::XActionListener::actionPerformed, aEvent ); } } diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx index d4fb36b9bfb3..1bff25674390 100644 --- a/svx/source/inc/gridcell.hxx +++ b/svx/source/inc/gridcell.hxx @@ -681,7 +681,7 @@ private: void SetList(const css::uno::Any& rItems, bool bComboBox); void CreateControl(BrowserDataWin* pParent, const css::uno::Reference< css::beans::XPropertySet >& xModel); - DECL_LINK( OnClick, VclPtr, void ); + DECL_LINK( OnClick, weld::Button&, void ); css::uno::Sequence< OUString > m_aValueList; OUString m_aText; @@ -785,7 +785,6 @@ public: { m_pCellControl->AlignControl(nAlignment);} protected: - virtual vcl::Window* getEventWindow() const; virtual void onWindowEvent( const VclEventId _nEventId, const vcl::Window& _rWindow, const void* _pEventData ); // default implementations call our focus listeners, don't forget to call them if you override this @@ -793,6 +792,7 @@ protected: virtual void onFocusLost( const css::awt::FocusEvent& _rEvent ); private: + vcl::Window* getEventWindow() const; DECL_LINK( OnWindowEvent, VclWindowEvent&, void ); }; @@ -906,7 +906,6 @@ private: bool m_bOwnEditImplementation; }; - typedef ::cppu::ImplHelper2 < css::awt::XCheckBox , css::awt::XButton > FmXCheckBoxCell_Base; @@ -916,7 +915,9 @@ class FmXCheckBoxCell : public FmXDataCell, ::comphelper::OInterfaceContainerHelper2 m_aItemListeners; ::comphelper::OInterfaceContainerHelper2 m_aActionListeners; OUString m_aActionCommand; - VclPtr m_pBox; + VclPtr<::svt::CheckBoxControl> m_pBox; + + DECL_LINK(ModifyHdl, LinkParamNone*, void); protected: virtual ~FmXCheckBoxCell() override; @@ -946,13 +947,8 @@ public: virtual void SAL_CALL removeActionListener( const css::uno::Reference< css::awt::XActionListener >& l ) override; //virtual void SAL_CALL setLabel( const OUString& Label ) throw (css::uno::RuntimeException); virtual void SAL_CALL setActionCommand( const OUString& Command ) override; - -protected: - virtual vcl::Window* getEventWindow() const override; - virtual void onWindowEvent( const VclEventId _nEventId, const vcl::Window& _rWindow, const void* _pEventData ) override; }; - class FmXListBoxCell final :public FmXTextCell { public: diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 3abc2f4299b6..3cb000eba8ec 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -3565,7 +3564,7 @@ SwEntryBrowseBox::SwEntryBrowseBox(const css::uno::Reference m_sYes = SwResId(STR_AUTOMARK_YES); m_sNo = SwResId(STR_AUTOMARK_NO); - m_aCellCheckBox->GetBox().EnableTriState(false); + m_aCellCheckBox->EnableTriState(false); m_xController = new ::svt::EditCellController(m_aCellEdit.get()); m_xCheckController = new ::svt::CheckBoxCellController(m_aCellCheckBox.get()); @@ -3717,7 +3716,7 @@ bool SwEntryBrowseBox::SaveModified() else { pController = m_xCheckController.get(); - bVal = static_cast< ::svt::CheckBoxCellController*>(pController)->GetCheckBox().IsChecked(); + bVal = static_cast< ::svt::CheckBoxCellController*>(pController)->GetCheckBox().get_active(); } const bool bAddEntry = nRow >= m_Entries.size(); std::unique_ptr xNewEntry(bAddEntry ? new AutoMarkEntry : nullptr); @@ -3759,7 +3758,7 @@ void SwEntryBrowseBox::InitController( { rController = m_xCheckController; ::svt::CellController* pController = m_xCheckController.get(); - static_cast< ::svt::CheckBoxCellController*>(pController)->GetCheckBox().Check( + static_cast< ::svt::CheckBoxCellController*>(pController)->GetCheckBox().set_active( rText == m_sYes ); } } diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 901d7c9b8d1e..d28a7cc3f0d4 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1136,10 +1136,11 @@ std::unique_ptr SalInstanceWidget::weld_parent() const void SalInstanceWidget::draw(OutputDevice& rOutput, const tools::Rectangle& rRect) { Size aOrigSize(m_xWidget->GetSizePixel()); - m_xWidget->SetSizePixel(rRect.GetSize()); + Size aSize = rRect.GetSize(); + m_xWidget->SetSizePixel(aSize); rOutput.Push(PushFlags::CLIPREGION); rOutput.IntersectClipRegion(rRect); - m_xWidget->Draw(&rOutput, rRect.TopLeft(), DrawFlags::NONE); + m_xWidget->PaintToDevice(&rOutput, rRect.TopLeft()); rOutput.Pop(); m_xWidget->SetSizePixel(aOrigSize); } diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index ebcb51236fed..76bd00278bd1 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -3068,7 +3068,7 @@ public: GtkAllocation aOrigAllocation; gtk_widget_get_allocation(m_pWidget, &aOrigAllocation); - GtkAllocation aNewAllocation {aOrigAllocation.x + 100, + GtkAllocation aNewAllocation {aOrigAllocation.x, aOrigAllocation.y, static_cast(aSize.Width()), static_cast(aSize.Height()) }; -- cgit