diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2019-11-27 22:53:38 +0100 |
---|---|---|
committer | Marco Cecchetti <marco.cecchetti@collabora.com> | 2019-12-02 17:33:11 +0100 |
commit | cf3e968ed4de91bf38b704bb6fe66077e3cceb71 (patch) | |
tree | d36d11a32ebe8ae6b5447a65d9a48b764837bc25 /sc | |
parent | 51af04c9d1cb7b0955201b6a13714899c998cf50 (diff) |
lok: formula bar: function completion
lok clients can request to complete a function name partially typed in
the formula input box.
Change-Id: I8771fd4d2a7f79c20138d9183162da23a92f2ba4
Reviewed-on: https://gerrit.libreoffice.org/83984
Reviewed-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Tested-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/docuno.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/inc/inputhdl.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 10 |
4 files changed, 31 insertions, 0 deletions
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index c38df0a92f35..88d463569144 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -386,6 +386,9 @@ public: /// @see vcl::ITiledRenderable::getPostItsPos(). OUString getPostItsPos() override; + + /// @see vcl::ITiledRenderable::completeFunction(). + virtual void completeFunction(int nIndex) override; }; class ScDrawPagesObj : public cppu::WeakImplHelper< diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 746909dd1f2d..59f6d3c5e809 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <iterator> #include <memory> #include <inputhdl.hxx> #include <scitems.hxx> @@ -1598,6 +1599,21 @@ void ScInputHandler::PasteFunctionData() pActiveView->ShowCursor(); } +void ScInputHandler::LOKPasteFunctionData( sal_uInt32 nIndex ) +{ + if (pFormulaData && miAutoPosFormula != pFormulaData->end() && nIndex < pFormulaData->size()) + { + auto aPos = pFormulaData->begin(); + sal_uInt32 nCurIndex = std::distance(aPos, miAutoPosFormula); + nIndex += nCurIndex; + if (nIndex >= pFormulaData->size()) + nIndex -= pFormulaData->size(); + std::advance(aPos, nIndex); + miAutoPosFormula = aPos; + PasteFunctionData(); + } +} + // Calculate selection and display as tip help static OUString lcl_Calculate( const OUString& rFormula, ScDocument* pDoc, const ScAddress &rPos ) { diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx index 8c31e46c246a..70a1cd6e09d0 100644 --- a/sc/source/ui/inc/inputhdl.hxx +++ b/sc/source/ui/inc/inputhdl.hxx @@ -287,6 +287,8 @@ public: static ReferenceMark GetReferenceMark( ScViewData& rViewData, ScDocShell* pDocSh, long nX1, long nX2, long nY1, long nY2, long nTab, const Color& rColor ); + + void LOKPasteFunctionData( sal_uInt32 nIndex ); }; // ScInputHdlState diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index db81b7ea7772..8c99b02afd0d 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1087,6 +1087,16 @@ OUString ScModelObj::getPostItsPos() return OUString::fromUtf8(aStream.str().c_str()); } +void ScModelObj::completeFunction(int nIndex) +{ + ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); + if (pHdl) + { + assert(nIndex >= 0); + pHdl->LOKPasteFunctionData(nIndex); + } +} + void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& /*rArguments*/) { SolarMutexGuard aGuard; |