summaryrefslogtreecommitdiff
path: root/svtools/inc
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/inc
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/inc')
-rw-r--r--svtools/inc/mousefunction.hxx133
-rw-r--r--svtools/inc/table/defaultinputhandler.hxx19
2 files changed, 143 insertions, 9 deletions
diff --git a/svtools/inc/mousefunction.hxx b/svtools/inc/mousefunction.hxx
new file mode 100644
index 000000000000..979a2b6c463f
--- /dev/null
+++ b/svtools/inc/mousefunction.hxx
@@ -0,0 +1,133 @@
+/* -*- 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: */
diff --git a/svtools/inc/table/defaultinputhandler.hxx b/svtools/inc/table/defaultinputhandler.hxx
index c09328c50e66..136979db8576 100644
--- a/svtools/inc/table/defaultinputhandler.hxx
+++ b/svtools/inc/table/defaultinputhandler.hxx
@@ -20,24 +20,18 @@
#pragma once
#include <table/tableinputhandler.hxx>
+#include <rtl/ref.hxx>
+#include <mousefunction.hxx>
#include <memory>
+#include <vector>
namespace svt::table
{
-
- struct DefaultInputHandler_Impl;
-
-
- //= DefaultInputHandler
-
class DefaultInputHandler final : public ITableInputHandler
{
- private:
- ::std::unique_ptr< DefaultInputHandler_Impl > m_pImpl;
-
public:
DefaultInputHandler();
virtual ~DefaultInputHandler() override;
@@ -48,6 +42,13 @@ namespace svt::table
virtual bool KeyInput ( ITableControl& _rControl, const KeyEvent& rKEvt ) override;
virtual bool GetFocus ( ITableControl& _rControl ) override;
virtual bool LoseFocus ( ITableControl& _rControl ) override;
+
+ private:
+ bool delegateMouseEvent( ITableControl& i_control, const MouseEvent& i_event,
+ FunctionResult ( MouseFunction::*i_handlerMethod )( ITableControl&, const MouseEvent& ) );
+
+ rtl::Reference< MouseFunction > pActiveFunction;
+ std::vector< rtl::Reference< MouseFunction > > aMouseFunctions;
};