summaryrefslogtreecommitdiff
path: root/svtools/source
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-08-13 18:58:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-08-14 11:11:49 +0200
commitecfc229b090473ad28d4b6947e2e0e0d9cd3ef4b (patch)
treea41d15766961bc004178fa95ea8865b0ee508be3 /svtools/source
parent7322fb1ed21cefe9faecc8cd5d088a3476283b5a (diff)
flatten svt::table::DefaultInputHandler
Change-Id: Idba4039bbedd7c276505c5e9763b559d505cf7a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120467 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools/source')
-rw-r--r--svtools/source/table/defaultinputhandler.cxx113
-rw-r--r--svtools/source/table/mousefunction.cxx2
-rw-r--r--svtools/source/table/mousefunction.hxx132
3 files changed, 50 insertions, 197 deletions
diff --git a/svtools/source/table/defaultinputhandler.cxx b/svtools/source/table/defaultinputhandler.cxx
index 6b84fbf318cf..0263b29689f5 100644
--- a/svtools/source/table/defaultinputhandler.cxx
+++ b/svtools/source/table/defaultinputhandler.cxx
@@ -21,8 +21,6 @@
#include <table/defaultinputhandler.hxx>
#include <table/tablecontrolinterface.hxx>
-#include "mousefunction.hxx"
-
#include <vcl/event.hxx>
#include <osl/diagnose.h>
@@ -31,24 +29,14 @@ namespace svt::table
{
- typedef ::rtl::Reference< MouseFunction > PMouseFunction;
- typedef ::std::vector< PMouseFunction > MouseFunctions;
- struct DefaultInputHandler_Impl
- {
- PMouseFunction pActiveFunction;
- MouseFunctions aMouseFunctions;
- };
-
-
//= DefaultInputHandler
DefaultInputHandler::DefaultInputHandler()
- :m_pImpl( new DefaultInputHandler_Impl )
{
- m_pImpl->aMouseFunctions.push_back( new ColumnResize );
- m_pImpl->aMouseFunctions.push_back( new RowSelection );
- m_pImpl->aMouseFunctions.push_back( new ColumnSortHandler );
+ aMouseFunctions.push_back( new ColumnResize );
+ aMouseFunctions.push_back( new RowSelection );
+ aMouseFunctions.push_back( new ColumnSortHandler );
}
@@ -57,78 +45,75 @@ namespace svt::table
}
- namespace
+ bool DefaultInputHandler::delegateMouseEvent( ITableControl& i_control, const MouseEvent& i_event,
+ FunctionResult ( MouseFunction::*i_handlerMethod )( ITableControl&, const MouseEvent& ) )
{
- bool lcl_delegateMouseEvent( DefaultInputHandler_Impl& i_impl, ITableControl& i_control, const MouseEvent& i_event,
- FunctionResult ( MouseFunction::*i_handlerMethod )( ITableControl&, const MouseEvent& ) )
+ if ( pActiveFunction.is() )
{
- if ( i_impl.pActiveFunction.is() )
+ bool furtherHandler = false;
+ switch ( (pActiveFunction.get()->*i_handlerMethod)( i_control, i_event ) )
{
- bool furtherHandler = false;
- switch ( (i_impl.pActiveFunction.get()->*i_handlerMethod)( i_control, i_event ) )
- {
- case ActivateFunction:
- OSL_ENSURE( false, "lcl_delegateMouseEvent: unexpected - function already *is* active!" );
- break;
- case ContinueFunction:
- break;
- case DeactivateFunction:
- i_impl.pActiveFunction.clear();
- break;
- case SkipFunction:
- furtherHandler = true;
- break;
- }
- if ( !furtherHandler )
- // handled the event
- return true;
+ case ActivateFunction:
+ OSL_ENSURE( false, "lcl_delegateMouseEvent: unexpected - function already *is* active!" );
+ break;
+ case ContinueFunction:
+ break;
+ case DeactivateFunction:
+ pActiveFunction.clear();
+ break;
+ case SkipFunction:
+ furtherHandler = true;
+ break;
}
+ if ( !furtherHandler )
+ // handled the event
+ return true;
+ }
+
+ // ask all other handlers
+ bool handled = false;
+ for (auto const& mouseFunction : aMouseFunctions)
+ {
+ if (handled)
+ break;
+ if (mouseFunction == pActiveFunction)
+ // we already invoked this function
+ continue;
- // ask all other handlers
- bool handled = false;
- for (auto const& mouseFunction : i_impl.aMouseFunctions)
+ switch ( (mouseFunction.get()->*i_handlerMethod)( i_control, i_event ) )
{
- if (handled)
- break;
- if (mouseFunction == i_impl.pActiveFunction)
- // we already invoked this function
- continue;
-
- switch ( (mouseFunction.get()->*i_handlerMethod)( i_control, i_event ) )
- {
- case ActivateFunction:
- i_impl.pActiveFunction = mouseFunction;
- handled = true;
- break;
- case ContinueFunction:
- case DeactivateFunction:
- OSL_ENSURE( false, "lcl_delegateMouseEvent: unexpected: inactive handler cannot be continued or deactivated!" );
- break;
- case SkipFunction:
- handled = false;
- break;
- }
+ case ActivateFunction:
+ pActiveFunction = mouseFunction;
+ handled = true;
+ break;
+ case ContinueFunction:
+ case DeactivateFunction:
+ OSL_ENSURE( false, "lcl_delegateMouseEvent: unexpected: inactive handler cannot be continued or deactivated!" );
+ break;
+ case SkipFunction:
+ handled = false;
+ break;
}
- return handled;
}
+ return handled;
}
bool DefaultInputHandler::MouseMove( ITableControl& i_tableControl, const MouseEvent& i_event )
{
- return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &MouseFunction::handleMouseMove );
+ return delegateMouseEvent( i_tableControl, i_event, &MouseFunction::handleMouseMove );
}
bool DefaultInputHandler::MouseButtonDown( ITableControl& i_tableControl, const MouseEvent& i_event )
{
- return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &MouseFunction::handleMouseDown );
+ return delegateMouseEvent( i_tableControl, i_event, &MouseFunction::handleMouseDown );
}
bool DefaultInputHandler::MouseButtonUp( ITableControl& i_tableControl, const MouseEvent& i_event )
{
- return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &MouseFunction::handleMouseUp );
+ return delegateMouseEvent( i_tableControl, i_event, &MouseFunction::handleMouseUp );
}
diff --git a/svtools/source/table/mousefunction.cxx b/svtools/source/table/mousefunction.cxx
index a62af9fcc149..8bb30390a286 100644
--- a/svtools/source/table/mousefunction.cxx
+++ b/svtools/source/table/mousefunction.cxx
@@ -18,7 +18,7 @@
*/
-#include "mousefunction.hxx"
+#include <mousefunction.hxx>
#include <table/tablecontrolinterface.hxx>
#include <table/tablesort.hxx>
diff --git a/svtools/source/table/mousefunction.hxx b/svtools/source/table/mousefunction.hxx
deleted file mode 100644
index beadbcf59206..000000000000
--- a/svtools/source/table/mousefunction.hxx
+++ /dev/null
@@ -1,132 +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 <table/tabletypes.hxx>
-
-#include <salhelper/simplereferenceobject.hxx>
-
-class MouseEvent;
-
-
-namespace svt::table
-{
-
-
- class ITableControl;
-
-
- //= FunctionResult
-
- enum FunctionResult
- {
- ActivateFunction,
- ContinueFunction,
- DeactivateFunction,
-
- SkipFunction
- };
-
-
- //= MouseFunction
-
- class MouseFunction : public ::salhelper::SimpleReferenceObject
- {
- public:
- MouseFunction() {}
- MouseFunction(const MouseFunction&) = delete;
- MouseFunction& operator=(const MouseFunction&) = delete;
- virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0;
- virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0;
- virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0;
-
- protected:
- virtual ~MouseFunction() override { }
- };
-
-
- //= ColumnResize
-
- class ColumnResize : public MouseFunction
- {
- public:
- ColumnResize()
- :m_nResizingColumn( COL_INVALID )
- {
- }
-
- public:
- // MouseFunction
- virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) override;
- virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) override;
- virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) override;
-
- private:
- ColPos m_nResizingColumn;
- };
-
-
- //= RowSelection
-
- class RowSelection : public MouseFunction
- {
- public:
- RowSelection()
- :m_bActive( false )
- {
- }
-
- public:
- // MouseFunction
- virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) override;
- virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) override;
- virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) override;
-
- private:
- bool m_bActive;
- };
-
-
- //= ColumnSortHandler
-
- class ColumnSortHandler : public MouseFunction
- {
- public:
- ColumnSortHandler()
- :m_nActiveColumn( COL_INVALID )
- {
- }
-
- public:
- // MouseFunction
- virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) override;
- virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) override;
- virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) override;
-
- private:
- ColPos m_nActiveColumn;
- };
-
-
-} // namespace svt::table
-
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */