[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - desktop/qa desktop/source include/LibreOfficeKit include/vcl sc/inc sc/source

Marco Cecchetti (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 2 16:34:01 UTC 2019


 desktop/qa/desktop_lib/test_desktop_lib.cxx |    3 ++-
 desktop/source/lib/init.cxx                 |   17 +++++++++++++++++
 include/LibreOfficeKit/LibreOfficeKit.h     |    3 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   10 ++++++++++
 include/vcl/ITiledRenderable.hxx            |    5 +++++
 sc/inc/docuno.hxx                           |    3 +++
 sc/source/ui/app/inputhdl.cxx               |   16 ++++++++++++++++
 sc/source/ui/inc/inputhdl.hxx               |    2 ++
 sc/source/ui/unoobj/docuno.cxx              |   10 ++++++++++
 9 files changed, 68 insertions(+), 1 deletion(-)

New commits:
commit cf3e968ed4de91bf38b704bb6fe66077e3cceb71
Author:     Marco Cecchetti <marco.cecchetti at collabora.com>
AuthorDate: Wed Nov 27 22:53:38 2019 +0100
Commit:     Marco Cecchetti <marco.cecchetti at collabora.com>
CommitDate: Mon Dec 2 17:33:11 2019 +0100

    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 at collabora.com>
    Tested-by: Marco Cecchetti <marco.cecchetti at collabora.com>

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 37d6ad604cca..eff6e15c6994 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2790,10 +2790,11 @@ void DesktopLOKTest::testABI()
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(56), offsetof(struct _LibreOfficeKitDocumentClass, sendDialogEvent));
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(57), offsetof(struct _LibreOfficeKitDocumentClass, renderFontOrientation));
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(58), offsetof(struct _LibreOfficeKitDocumentClass, paintWindowForView));
+    CPPUNIT_ASSERT_EQUAL(documentClassOffset(59), offsetof(struct _LibreOfficeKitDocumentClass, completeFunction));
 
     // Extending is fine, update this, and add new assert for the offsetof the
     // new method
-    CPPUNIT_ASSERT_EQUAL(documentClassOffset(59), sizeof(struct _LibreOfficeKitDocumentClass));
+    CPPUNIT_ASSERT_EQUAL(documentClassOffset(60), sizeof(struct _LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index afe99e3213de..f3520a7e83dd 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -929,6 +929,7 @@ static size_t doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char** pOu
 static void doc_resizeWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
                              const int nWidth, const int nHeight);
 
+static void doc_completeFunction(LibreOfficeKitDocument* pThis, int nIndex);
 } // extern "C"
 
 namespace {
@@ -1040,6 +1041,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->postWindowGestureEvent = doc_postWindowGestureEvent;
 
         m_pDocumentClass->createViewWithOptions = doc_createViewWithOptions;
+        m_pDocumentClass->completeFunction = doc_completeFunction;
 
         gDocumentClass = m_pDocumentClass;
     }
@@ -5150,6 +5152,21 @@ static void doc_resizeWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWin
     pWindow->SetSizePixel(Size(nWidth, nHeight));
 }
 
+static void doc_completeFunction(LibreOfficeKitDocument* pThis, int nIndex)
+{
+    SolarMutexGuard aGuard;
+    SetLastExceptionMsg();
+
+    ITiledRenderable* pDoc = getTiledRenderable(pThis);
+    if (!pDoc)
+    {
+        SetLastExceptionMsg("Document doesn't support tiled rendering");
+        return;
+    }
+
+    pDoc->completeFunction(nIndex);
+}
+
 static char* lo_getError (LibreOfficeKit *pThis)
 {
     comphelper::ProfileZone aZone("lo_getError");
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index a486886c15de..b4278625ccb0 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -436,6 +436,9 @@ struct _LibreOfficeKitDocumentClass
                                 const double dpiscale,
                                 int viewId);
 
+    /// @see lok::Document::completeFunction().
+    void (*completeFunction) (LibreOfficeKitDocument* pThis, int nIndex);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index ae17e4e710e4..d50ef4823f81 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -757,6 +757,16 @@ public:
         mpDoc->pClass->removeTextContext(mpDoc, nWindowId, nBefore, nAfter);
     }
 
+    /**
+     * Select the Calc function to be pasted into the formula input box
+     *
+     * @param nIndex is the index of the selected function
+     */
+    void completeFunction(int nIndex)
+    {
+        mpDoc->pClass->completeFunction(mpDoc, nIndex);
+    }
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index e2abb9eaaeda..0cb93fd6f7d4 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -341,6 +341,11 @@ public:
      * bDuplicate: to copy (true), or to move (false).
      */
     virtual void moveSelectedParts(int /*nPosition*/, bool /*bDuplicate*/) {}
+
+    /// @see lok::Document::completeFunction().
+    virtual void completeFunction(int /*nIndex*/)
+    {
+    }
 };
 } // namespace vcl
 
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;


More information about the Libreoffice-commits mailing list