solenv/clang-format/excludelist | 1 toolkit/inc/controls/table/defaultinputhandler.hxx | 24 ++++-- toolkit/inc/controls/table/tableinputhandler.hxx | 63 ------------------ toolkit/inc/controls/table/tablemodel.hxx | 2 toolkit/source/controls/table/defaultinputhandler.cxx | 15 ---- toolkit/source/controls/table/tablecontrol.cxx | 14 ++-- 6 files changed, 25 insertions(+), 94 deletions(-)
New commits: commit 9391dd417ec20e033c6d61cf41c9945aa039ce0a Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Jan 23 13:00:29 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jan 24 07:36:58 2025 +0100 toolkit: Move DefaultInputHandler::{Get,Lose}Focus logic to only callers Both always return false, so Control::{Get,Lose}Focus always gets called. Change-Id: If26132d68cebfb7930f12418480480ddd3cb9333 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180631 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/toolkit/inc/controls/table/defaultinputhandler.hxx b/toolkit/inc/controls/table/defaultinputhandler.hxx index 12cd70ea1f53..51610b4b5d2d 100644 --- a/toolkit/inc/controls/table/defaultinputhandler.hxx +++ b/toolkit/inc/controls/table/defaultinputhandler.hxx @@ -45,8 +45,6 @@ namespace svt::table bool MouseButtonDown(ITableControl& _rControl, const MouseEvent& rMEvt); bool MouseButtonUp(ITableControl& _rControl, const MouseEvent& rMEvt); static bool KeyInput(ITableControl& _rControl, const KeyEvent& rKEvt); - static bool GetFocus(ITableControl& _rControl); - static bool LoseFocus(ITableControl& _rControl); private: bool delegateMouseEvent( ITableControl& i_control, const MouseEvent& i_event, diff --git a/toolkit/source/controls/table/defaultinputhandler.cxx b/toolkit/source/controls/table/defaultinputhandler.cxx index 171458ef7acf..0164af385201 100644 --- a/toolkit/source/controls/table/defaultinputhandler.cxx +++ b/toolkit/source/controls/table/defaultinputhandler.cxx @@ -159,21 +159,6 @@ namespace svt::table return bHandled; } - - bool DefaultInputHandler::GetFocus( ITableControl& _rControl ) - { - _rControl.showCursor(); - return false; // continue processing - } - - - bool DefaultInputHandler::LoseFocus( ITableControl& _rControl ) - { - _rControl.hideCursor(); - return false; // continue processing - } - - } // namespace svt::table diff --git a/toolkit/source/controls/table/tablecontrol.cxx b/toolkit/source/controls/table/tablecontrol.cxx index 94810d138ed5..2b6afc18d863 100644 --- a/toolkit/source/controls/table/tablecontrol.cxx +++ b/toolkit/source/controls/table/tablecontrol.cxx @@ -78,15 +78,19 @@ namespace svt::table void TableControl::GetFocus() { - if (!m_pImpl || !DefaultInputHandler::GetFocus(*m_pImpl)) - Control::GetFocus(); + if (m_pImpl) + m_pImpl->showCursor(); + + Control::GetFocus(); } void TableControl::LoseFocus() { - if (!m_pImpl || !DefaultInputHandler::LoseFocus(*m_pImpl)) - Control::LoseFocus(); + if (m_pImpl) + m_pImpl->hideCursor(); + + Control::LoseFocus(); } commit 17bd739038c18b99f61e341fbb6b93495efb4eb3 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Jan 23 12:34:51 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jan 24 07:36:48 2025 +0100 toolkit: Drop ITableInputHandler Drop the ITableInputHandler interface (abstract class) that is only implemented by a single subclass, DefaultInputHandler, and use that one directly. Adjust the PTableInputHandler to typedef std::shared_ptr<DefaultInputHandler> PTableInputHandler and take over method comments to DefaultInputHandler. Make methods non-virtual and follow the loplugin:staticaccess suggestion to make 3 of the methods static. This also prepares for further code simplification in upcoming commits. Change-Id: Ib4f3c2eb9f132da0484ef86a404251e3cdd84890 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180630 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index d21563262bb8..69533c61e5f1 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -13417,7 +13417,6 @@ toolkit/inc/controls/table/defaultinputhandler.hxx toolkit/inc/controls/table/gridtablerenderer.hxx toolkit/inc/controls/table/tablecontrol.hxx toolkit/inc/controls/table/tablecontrolinterface.hxx -toolkit/inc/controls/table/tableinputhandler.hxx toolkit/inc/controls/table/tablemodel.hxx toolkit/inc/controls/table/tablerenderer.hxx toolkit/inc/controls/table/tablesort.hxx diff --git a/toolkit/inc/controls/table/defaultinputhandler.hxx b/toolkit/inc/controls/table/defaultinputhandler.hxx index 3f3d425a69cb..12cd70ea1f53 100644 --- a/toolkit/inc/controls/table/defaultinputhandler.hxx +++ b/toolkit/inc/controls/table/defaultinputhandler.hxx @@ -20,26 +20,33 @@ #pragma once #include <controls/table/mousefunction.hxx> -#include <controls/table/tableinputhandler.hxx> #include <rtl/ref.hxx> +#include <memory> #include <vector> +class KeyEvent; +class MouseEvent; + namespace svt::table { - class DefaultInputHandler final : public ITableInputHandler + class DefaultInputHandler final { public: DefaultInputHandler(); - virtual ~DefaultInputHandler() override; + ~DefaultInputHandler(); - virtual bool MouseMove ( ITableControl& _rControl, const MouseEvent& rMEvt ) override; - virtual bool MouseButtonDown ( ITableControl& _rControl, const MouseEvent& rMEvt ) override; - virtual bool MouseButtonUp ( ITableControl& _rControl, const MouseEvent& rMEvt ) override; - virtual bool KeyInput ( ITableControl& _rControl, const KeyEvent& rKEvt ) override; - virtual bool GetFocus ( ITableControl& _rControl ) override; - virtual bool LoseFocus ( ITableControl& _rControl ) override; + // all those methods have the same semantics as the equal-named methods of ->Window, + // with the additional option to return a boolean value indicating whether + // the event should be further processed by the ->Window implementations (<FALSE/>), + // or whether it has been sufficiently handled by this class (<FALSE/>). + bool MouseMove(ITableControl& _rControl, const MouseEvent& rMEvt); + bool MouseButtonDown(ITableControl& _rControl, const MouseEvent& rMEvt); + bool MouseButtonUp(ITableControl& _rControl, const MouseEvent& rMEvt); + static bool KeyInput(ITableControl& _rControl, const KeyEvent& rKEvt); + static bool GetFocus(ITableControl& _rControl); + static bool LoseFocus(ITableControl& _rControl); private: bool delegateMouseEvent( ITableControl& i_control, const MouseEvent& i_event, @@ -49,6 +56,7 @@ namespace svt::table std::vector< rtl::Reference< MouseFunction > > aMouseFunctions; }; + typedef std::shared_ptr<DefaultInputHandler> PTableInputHandler; } // namespace svt::table diff --git a/toolkit/inc/controls/table/tableinputhandler.hxx b/toolkit/inc/controls/table/tableinputhandler.hxx deleted file mode 100644 index 9d11df38db3d..000000000000 --- a/toolkit/inc/controls/table/tableinputhandler.hxx +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#include <memory> - -class MouseEvent; -class KeyEvent; - - -namespace svt::table -{ - - - class ITableControl; - - - //= ITableInputHandler - - /** interface for components handling input in a ->TableControl - */ - class ITableInputHandler - { - public: - // all those methods have the same semantics as the equal-named methods of ->Window, - // with the additional option to return a boolean value indicating whether - // the event should be further processed by the ->Window implementations (<FALSE/>), - // or whether it has been sufficiently handled by the ->ITableInputHandler instance - // (<FALSE/>). - - virtual bool MouseMove ( ITableControl& _rControl, const MouseEvent& rMEvt ) = 0; - virtual bool MouseButtonDown ( ITableControl& _rControl, const MouseEvent& rMEvt ) = 0; - virtual bool MouseButtonUp ( ITableControl& _rControl, const MouseEvent& rMEvt ) = 0; - virtual bool KeyInput ( ITableControl& _rControl, const KeyEvent& rKEvt ) = 0; - virtual bool GetFocus ( ITableControl& _rControl ) = 0; - virtual bool LoseFocus ( ITableControl& _rControl ) = 0; - - virtual ~ITableInputHandler() { } - }; - typedef std::shared_ptr< ITableInputHandler > PTableInputHandler; - - -} // namespace svt::table - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/controls/table/tablemodel.hxx b/toolkit/inc/controls/table/tablemodel.hxx index 7add49629a2a..97d0c56c9ea7 100644 --- a/toolkit/inc/controls/table/tablemodel.hxx +++ b/toolkit/inc/controls/table/tablemodel.hxx @@ -20,9 +20,9 @@ #pragma once #include <toolkit/dllapi.h> +#include <controls/table/defaultinputhandler.hxx> #include <controls/table/tabletypes.hxx> #include <controls/table/tablerenderer.hxx> -#include <controls/table/tableinputhandler.hxx> #include <com/sun/star/style/VerticalAlignment.hpp> #include <com/sun/star/style/HorizontalAlignment.hpp> diff --git a/toolkit/source/controls/table/tablecontrol.cxx b/toolkit/source/controls/table/tablecontrol.cxx index 7e609601722a..94810d138ed5 100644 --- a/toolkit/source/controls/table/tablecontrol.cxx +++ b/toolkit/source/controls/table/tablecontrol.cxx @@ -78,21 +78,21 @@ namespace svt::table void TableControl::GetFocus() { - if ( !m_pImpl || !m_pImpl->getInputHandler()->GetFocus( *m_pImpl ) ) + if (!m_pImpl || !DefaultInputHandler::GetFocus(*m_pImpl)) Control::GetFocus(); } void TableControl::LoseFocus() { - if ( !m_pImpl || !m_pImpl->getInputHandler()->LoseFocus( *m_pImpl ) ) + if (!m_pImpl || !DefaultInputHandler::LoseFocus(*m_pImpl)) Control::LoseFocus(); } void TableControl::KeyInput( const KeyEvent& rKEvt ) { - if ( !m_pImpl->getInputHandler()->KeyInput( *m_pImpl, rKEvt ) ) + if (!m_pImpl || !DefaultInputHandler::KeyInput(*m_pImpl, rKEvt)) Control::KeyInput( rKEvt ); else {