[Libreoffice-commits] core.git: desktop/source include/LibreOfficeKit libreofficekit/source sc/source

Szymon Kłos (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 24 19:18:01 UTC 2019


 desktop/source/lib/init.cxx                  |    3 
 include/LibreOfficeKit/LibreOfficeKitEnums.h |   16 ++
 libreofficekit/source/gtk/lokdocview.cxx     |   45 +++++++
 sc/source/ui/app/inputhdl.cxx                |  152 +++++++++++++++++++++++++++
 sc/source/ui/app/inputwin.cxx                |    8 +
 sc/source/ui/inc/inputhdl.hxx                |    6 +
 sc/source/ui/inc/output.hxx                  |   49 +++++++-
 sc/source/ui/miscdlgs/anyrefdg.cxx           |    9 +
 sc/source/ui/view/gridwin.cxx                |    2 
 sc/source/ui/view/gridwin4.cxx               |    7 -
 sc/source/ui/view/output.cxx                 |  114 +++++++++++++++++++-
 sc/source/ui/view/tabview3.cxx               |    3 
 sc/source/ui/view/tabview4.cxx               |   15 ++
 13 files changed, 414 insertions(+), 15 deletions(-)

New commits:
commit 8d0869246db0b080bf45f077c484618b7c82253f
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Sep 13 15:26:31 2018 +0200
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Tue Sep 24 21:16:15 2019 +0200

    Add reference marks callback
    
    Change-Id: Ic749e138356392b0c327a30cff28055f06e23e2e
    Reviewed-on: https://gerrit.libreoffice.org/79464
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 400e0e7f82d9..2af356e0bb7b 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1077,7 +1077,8 @@ void CallbackFlushHandler::queue(const int type, const char* data)
             type != LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR &&
             type != LOK_CALLBACK_CURSOR_VISIBLE &&
             type != LOK_CALLBACK_VIEW_CURSOR_VISIBLE &&
-            type != LOK_CALLBACK_TEXT_SELECTION)
+            type != LOK_CALLBACK_TEXT_SELECTION &&
+            type != LOK_CALLBACK_REFERENCE_MARKS)
         {
             SAL_INFO("lok", "Skipping while painting [" << type << "]: [" << payload << "].");
             return;
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 44bf83eab205..e7ba66fe7f14 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -685,6 +685,20 @@ typedef enum
      * cell.
      */
     LOK_CALLBACK_TABLE_SELECTED = 44,
+
+    /*
+     * Show reference marks from payload.
+     *
+     * Example payload:
+     * {
+     *     "marks": [
+     *         { "rectangle": "3825, 3315, 1245, 2010", "color": "0000ff", "part": "0" },
+     *         { "rectangle": "8925, 4335, 2520, 735", "color": "ff0000", "part": "0" },
+     *         ...
+     *     ]
+     * }
+     */
+    LOK_CALLBACK_REFERENCE_MARKS = 45,
 }
 LibreOfficeKitCallbackType;
 
@@ -803,6 +817,8 @@ static inline const char* lokCallbackTypeToString(int nType)
         return "LOK_CALLBACK_CELL_AUTO_FILL_AREA";
     case LOK_CALLBACK_TABLE_SELECTED:
         return "LOK_CALLBACK_TABLE_SELECTED";
+    case LOK_CALLBACK_REFERENCE_MARKS:
+        return "LOK_CALLBACK_REFERENCE_MARKS";
     }
 
     assert(!"Unknown LibreOfficeKitCallbackType type.");
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 4fa07b9c60c1..2e304a07ee49 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -139,6 +139,9 @@ struct LOKDocViewPrivateImpl
     /// see them, can't modify them. Key is the view id.
     std::map<int, ViewRectangle> m_aCellViewCursors;
     gboolean m_bInDragGraphicSelection;
+    /// Position, size and color of the reference marks. The current view can only
+    /// see them, can't modify them. Key is the view id.
+    std::vector<std::pair<ViewRectangle, sal_uInt32>> m_aReferenceMarks;
 
     /// @name Start/middle/end handle.
     ///@{
@@ -1363,6 +1366,27 @@ callback (gpointer pData)
     case LOK_CALLBACK_CELL_AUTO_FILL_AREA:
     case LOK_CALLBACK_TABLE_SELECTED:
         break; // TODO
+    case LOK_CALLBACK_REFERENCE_MARKS:
+    {
+        std::stringstream aStream(pCallback->m_aPayload);
+        boost::property_tree::ptree aTree;
+        boost::property_tree::read_json(aStream, aTree);
+
+        priv->m_aReferenceMarks.clear();
+
+        for(auto& rMark : aTree.get_child("marks"))
+        {
+            sal_uInt32 nColor = std::stoi(rMark.second.get<std::string>("color"), nullptr, 16);
+            std::string sRect = rMark.second.get<std::string>("rectangle");
+            sal_uInt32 nPart = std::stoi(rMark.second.get<std::string>("part"));
+
+            GdkRectangle aRect = payloadToRectangle(pDocView, sRect.c_str());
+            priv->m_aReferenceMarks.push_back(std::pair<ViewRectangle, sal_uInt32>(ViewRectangle(nPart, aRect), nColor));
+        }
+
+        gtk_widget_queue_draw(GTK_WIDGET(pDocView));
+        break;
+    }
     default:
         g_assert(false);
         break;
@@ -1819,6 +1843,27 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
         cairo_stroke(pCairo);
     }
 
+    // Draw reference marks.
+    for (auto& rPair : priv->m_aReferenceMarks)
+    {
+        const ViewRectangle& rMark = rPair.first;
+        if (rMark.m_nPart != priv->m_nPartId)
+            continue;
+
+        sal_uInt32 nColor = rPair.second;
+        sal_uInt8 nRed = (nColor >> 16) & 0xff;
+        sal_uInt8 nGreen = (nColor >> 8) & 0xff;
+        sal_uInt8 nBlue = nColor & 0xff;
+        cairo_set_source_rgb(pCairo, nRed, nGreen, nBlue);
+        cairo_rectangle(pCairo,
+                        twipToPixel(rMark.m_aRectangle.x, priv->m_fZoom),
+                        twipToPixel(rMark.m_aRectangle.y, priv->m_fZoom),
+                        twipToPixel(rMark.m_aRectangle.width, priv->m_fZoom),
+                        twipToPixel(rMark.m_aRectangle.height, priv->m_fZoom));
+        cairo_set_line_width(pCairo, 2.0);
+        cairo_stroke(pCairo);
+    }
+
     // View locks: they are colored.
     for (const auto& rPair : priv->m_aViewLockRectangles)
     {
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 1f601a901c2a..2e9fcee02f2b 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -84,6 +84,8 @@
 #include <markdata.hxx>
 #include <tokenarray.hxx>
 #include <gridwin.hxx>
+#include <output.hxx>
+#include <fillinfo.hxx>
 
 // Maximum Ranges in RangeFinder
 #define RANGEFIND_MAX   128
@@ -260,6 +262,44 @@ ScTypedCaseStrSet::const_iterator findTextAll(
 
 }
 
+void ScInputHandler::SendReferenceMarks( const SfxViewShell* pViewShell,
+                            const std::vector<ReferenceMark>& rReferenceMarks )
+{
+    if ( !pViewShell )
+        return;
+
+    bool bSend = false;
+
+    std::stringstream ss;
+
+    ss << "{ \"marks\": [ ";
+
+    for ( size_t i = 0; i < rReferenceMarks.size(); i++ )
+    {
+        if ( rReferenceMarks[i].Is() )
+        {
+            if ( bSend )
+                ss << ", ";
+
+            ss << "{ \"rectangle\": \""
+               << rReferenceMarks[i].nX << ", "
+               << rReferenceMarks[i].nY << ", "
+               << rReferenceMarks[i].nWidth << ", "
+               << rReferenceMarks[i].nHeight << "\", "
+                  "\"color\": \"" << rReferenceMarks[i].aColor.AsRGBHexString() << "\", "
+                  "\"part\": \"" << rReferenceMarks[i].nTab << "\" } ";
+
+            bSend = true;
+        }
+    }
+
+    ss <<  " ] }";
+
+    OString aPayload = ss.str().c_str();
+    pViewShell->libreOfficeKitViewCallback(
+                LOK_CALLBACK_REFERENCE_MARKS, aPayload.getStr() );
+}
+
 void ScInputHandler::InitRangeFinder( const OUString& rFormula )
 {
     DeleteRangeFinder();
@@ -375,6 +415,8 @@ handle_r1c1:
         // Do not skip last separator; could be a quote (?)
     }
 
+    UpdateLokReferenceMarks();
+
     if (nCount)
     {
         mpEditEngine->SetUpdateMode( true );
@@ -383,6 +425,109 @@ handle_r1c1:
     }
 }
 
+static ReferenceMark lcl_GetReferenceMark( ScViewData& rViewData, ScDocShell* pDocSh,
+                                           long nX1, long nX2, long nY1, long nY2,
+                                           long nTab, const Color& rColor )
+{
+    ScSplitPos eWhich = rViewData.GetActivePart();
+
+    Point aScrPos = rViewData.GetScrPos( nX1, nY1, eWhich );
+    long nScrX = aScrPos.X();
+    long nScrY = aScrPos.Y();
+
+    double nPPTX = rViewData.GetPPTX();
+    double nPPTY = rViewData.GetPPTY();
+
+    Fraction aZoomX = rViewData.GetZoomX();
+    Fraction aZoomY = rViewData.GetZoomY();
+
+    ScTableInfo aTabInfo;
+    pDocSh->GetDocument().FillInfo( aTabInfo, nX1, nY1, nX2, nY2,
+                                    nTab, nPPTX, nPPTY, false, false );
+
+    ScOutputData aOutputData( nullptr, OUTTYPE_WINDOW, aTabInfo,
+                              &( pDocSh->GetDocument() ), nTab,
+                              nScrX, nScrY,
+                              nX1, nY1, nX2, nY2,
+                              nPPTX, nPPTY,
+                              &aZoomX, &aZoomY );
+
+    return aOutputData.FillReferenceMark( nX1, nY1, nX2, nY2,
+                                          rColor );
+}
+
+void ScInputHandler::UpdateLokReferenceMarks()
+{
+    if ( !comphelper::LibreOfficeKit::isActive() || !pActiveViewSh )
+        return;
+
+    ScViewData& rViewData = pActiveViewSh->GetViewData();
+    ScDocShell* pDocSh = rViewData.GetDocShell();
+    ScRangeFindList* pRangeFinder = GetRangeFindList();
+
+    if ( !pRangeFinder && !rViewData.IsRefMode() )
+        return;
+
+    sal_uInt16 nAdditionalMarks = 0;
+    std::vector<ReferenceMark> aReferenceMarks( 1 );
+
+    if ( rViewData.IsRefMode() )
+    {
+        nAdditionalMarks = 1;
+
+        const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig();
+        Color aRefColor( rColorCfg.GetColorValue( svtools::CALCREFERENCE ).nColor );
+        long nX1 = rViewData.GetRefStartX();
+        long nX2 = rViewData.GetRefEndX();
+        long nY1 = rViewData.GetRefStartY();
+        long nY2 = rViewData.GetRefEndY();
+        long nTab = rViewData.GetRefTabNo();
+
+        PutInOrder(nX1, nX2);
+        PutInOrder(nY1, nY2);
+
+        aReferenceMarks[0] = lcl_GetReferenceMark( rViewData, pDocSh,
+                                                   nX1, nX2, nY1, nY2,
+                                                   nTab, aRefColor );
+    }
+
+    sal_uInt16 nCount = pRangeFinder ?
+        ( static_cast<sal_uInt16>( pRangeFinder->Count() ) + nAdditionalMarks ) : nAdditionalMarks;
+    aReferenceMarks.resize( nCount );
+
+    if ( nCount && pRangeFinder && !pRangeFinder->IsHidden() &&
+         pRangeFinder->GetDocName() == pDocSh->GetTitle() )
+    {
+        for (sal_uInt16 i = 0; i < nCount - nAdditionalMarks; i++)
+        {
+            ScRangeFindData& rData = pRangeFinder->GetObject( i );
+            ScRange aRef = rData.aRef;
+            aRef.PutInOrder();
+
+            long nX1 = aRef.aStart.Col();
+            long nX2 = aRef.aEnd.Col();
+            long nY1 = aRef.aStart.Row();
+            long nY2 = aRef.aEnd.Row();
+            long nTab = aRef.aStart.Tab();
+
+            aReferenceMarks[i + nAdditionalMarks] = lcl_GetReferenceMark(
+                rViewData, pDocSh, nX1, nX2, nY1, nY2, nTab, rData.nColor );
+
+            ScInputHandler::SendReferenceMarks( pActiveViewSh, aReferenceMarks );
+        }
+    }
+    else if ( nCount )
+    {
+        ScInputHandler::SendReferenceMarks( pActiveViewSh, aReferenceMarks );
+    }
+    else
+    {
+        // Clear
+        aReferenceMarks.clear();
+        ScInputHandler::SendReferenceMarks( pActiveViewSh, aReferenceMarks );
+    }
+}
+
 void ScInputHandler::SetDocumentDisposing( bool b )
 {
     mbDocumentDisposing = b;
@@ -3006,6 +3151,13 @@ void ScInputHandler::CancelHandler()
     aFormText.clear();
 
     bInOwnChange = false;
+
+    if ( comphelper::LibreOfficeKit::isActive() && pExecuteSh )
+    {
+        // Clear
+        std::vector<ReferenceMark> aReferenceMarks;
+        ScInputHandler::SendReferenceMarks( pActiveViewSh, aReferenceMarks );
+    }
 }
 
 bool ScInputHandler::IsModalMode( const SfxObjectShell* pDocSh )
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 8c390ca0ebae..300d9c38d699 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -70,6 +70,7 @@
 #include <comphelper/string.hxx>
 #include <com/sun/star/frame/XLayoutManager.hpp>
 #include <helpids.h>
+#include <output.hxx>
 
 namespace com::sun::star::accessibility { class XAccessible; }
 
@@ -1747,6 +1748,13 @@ void ScTextWnd::StopEditEngine( bool bAll )
         if (bSelection)
             Invalidate(); // So that the Selection is not left there
     }
+
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        // Clear
+        std::vector<ReferenceMark> aReferenceMarks;
+        ScInputHandler::SendReferenceMarks( mpViewShell, aReferenceMarks );
+    }
 }
 
 static sal_Int32 findFirstNonMatchingChar(const OUString& rStr1, const OUString& rStr2)
diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx
index a03461784783..ecb394b5f809 100644
--- a/sc/source/ui/inc/inputhdl.hxx
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -49,6 +49,8 @@ class KeyEvent;
 class CommandEvent;
 class VclWindowEvent;
 namespace vcl { class Window; }
+struct ReferenceMark;
+struct ESelection;
 
 //  ScInputHandler
 
@@ -273,6 +275,10 @@ public:
                     // actually private, public for SID_INPUT_SUM
     void            InitRangeFinder(const OUString& rFormula);
 
+    void            UpdateLokReferenceMarks();
+    static void     SendReferenceMarks( const SfxViewShell* pViewShell,
+                         const std::vector<ReferenceMark>& rReferenceMarks );
+
     void SetDocumentDisposing( bool b );
 
     static void     SetAutoComplete(bool bSet)  { bAutoComplete = bSet; }
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index f78d5e4933f3..943183ec5c76 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -58,6 +58,39 @@ enum ScOutputType { OUTTYPE_WINDOW, OUTTYPE_PRINTER };
 class ClearableClipRegion;
 typedef std::unique_ptr<ClearableClipRegion, o3tl::default_delete<ClearableClipRegion>> ClearableClipRegionPtr;
 
+/// Describes reference mark to be drawn, position & size in TWIPs
+struct ReferenceMark {
+    long nX;
+    long nY;
+    long nWidth;
+    long nHeight;
+    long nTab;
+    Color aColor;
+
+    ReferenceMark()
+        : nX( 0 )
+        , nY( 0 )
+        , nWidth( 0 )
+        , nHeight( 0 )
+        , nTab( 0 )
+        , aColor( COL_AUTO ) {}
+
+    ReferenceMark( long aX,
+                   long aY,
+                   long aWidth,
+                   long aHeight,
+                   long aTab,
+                   const Color& rColor )
+        : nX( aX )
+        , nY( aY )
+        , nWidth( aWidth )
+        , nHeight( aHeight )
+        , nTab( aTab )
+        , aColor( rColor ) {}
+
+    bool Is() const { return ( nWidth > 0 && nHeight > 0 ); }
+};
+
 class ScOutputData
 {
 friend class ScDrawStringsVars;
@@ -152,8 +185,10 @@ private:
     long nScrW;                 // Output size (Pixel)
     long nScrH;
     long nMirrorW;              // Visible output width for mirroring (default: nScrW)
-    SCCOL const nX1;                  // Start-/End coordinates
-    SCROW const nY1;                  //  ( incl. hidden )
+    long nTilePosX;             // Current tile X offset (twips)
+    long nTilePosY;             // Current tile Y offset (twips)
+    SCCOL const nX1;            // Start-/End coordinates
+    SCROW const nY1;            //  ( incl. hidden )
     SCCOL const nX2;
     SCROW const nY2;
     SCCOL nVisX1;               // Start-/End coordinates
@@ -259,6 +294,7 @@ private:
     void    SetCellRotations();
 
 public:
+
     /**
      * @param nNewScrX: X-Offset in the output device for the table
      * @param nNewScrY: Y-Offset in the output device for the table
@@ -270,7 +306,8 @@ public:
                                     SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2,
                                     double nPixelPerTwipsX, double nPixelPerTwipsY,
                                     const Fraction* pZoomX = nullptr,
-                                    const Fraction* pZoomY = nullptr );
+                                    const Fraction* pZoomY = nullptr,
+                                    long nNewTilePosX = 0, long nNewTilePosY = 0 );
 
                     ~ScOutputData();
 
@@ -331,9 +368,13 @@ public:
 
     void    FindChanged();
     void    SetPagebreakMode( ScPageBreakData* pPageData );
-    void    DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
+    /// Draws reference mark and returns its properties
+    ReferenceMark DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
                          SCCOL nRefEndX, SCROW nRefEndY,
                          const Color& rColor, bool bHandle );
+    ReferenceMark FillReferenceMark( SCCOL nRefStartX, SCROW nRefStartY,
+                                    SCCOL nRefEndX, SCROW nRefEndY,
+                                    const Color& rColor );
     void    DrawOneChange( SCCOL nRefStartX, SCROW nRefStartY,
                             SCCOL nRefEndX, SCROW nRefEndY,
                             const Color& rColor, sal_uInt16 nType );
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index b9e5b271006e..3a21ac941788 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -37,6 +37,8 @@
 #include <inputopt.hxx>
 #include <rangeutl.hxx>
 #include <tokenarray.hxx>
+#include <comphelper/lok.hxx>
+#include <output.hxx>
 
 #include <memory>
 
@@ -241,6 +243,13 @@ void ScFormulaReferenceHelper::HideReference( bool bDoneRefMode )
             if ( bDoneRefMode )
                 pTabViewShell->DoneRefMode();
             pTabViewShell->ClearHighlightRanges();
+
+            if( comphelper::LibreOfficeKit::isActive() )
+            {
+                // Clear
+                std::vector<ReferenceMark> aReferenceMarks;
+                ScInputHandler::SendReferenceMarks( pTabViewShell, aReferenceMarks );
+            }
         }
         m_bHighlightRef=false;
     }
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index dab34195c1cf..0bfbcce82ddf 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5079,6 +5079,8 @@ void ScGridWindow::RFMouseMove( const MouseEvent& rMEvt, bool bUp )
 
         ScDocShell* pDocSh = pViewData->GetDocShell();
 
+        pHdl->UpdateLokReferenceMarks();
+
         // only redrawing what has been changed...
         lcl_PaintRefChanged( pDocSh, aOld, aNew );
 
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 8cdf4572337e..4893b31c6b1b 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -828,8 +828,8 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
     {
         Color aRefColor( rColorCfg.GetColorValue(svtools::CALCREFERENCE).nColor );
         aOutputData.DrawRefMark( pViewData->GetRefStartX(), pViewData->GetRefStartY(),
-                                 pViewData->GetRefEndX(), pViewData->GetRefEndY(),
-                                 aRefColor, false );
+                                pViewData->GetRefEndX(), pViewData->GetRefEndY(),
+                                aRefColor, false );
     }
 
         // range finder
@@ -1212,7 +1212,8 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
                              -nTopLeftTileRowOffset,
                              nTopLeftTileCol, nTopLeftTileRow,
                              nBottomRightTileCol, nBottomRightTileRow,
-                             fPPTX, fPPTY);
+                             fPPTX, fPPTY, nullptr, nullptr,
+                             nTilePosX, nTilePosY);
 
     // setup the SdrPage so that drawinglayer works correctly
     ScDrawLayer* pModel = pDoc->GetDrawLayer();
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 6dea393f43f7..9697bd8dc9de 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -37,6 +37,8 @@
 #include <vcl/settings.hxx>
 #include <svx/unoapi.hxx>
 #include <sal/log.hxx>
+#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
 #include <output.hxx>
 #include <document.hxx>
@@ -134,7 +136,8 @@ ScOutputData::ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
                             SCTAB nNewTab, long nNewScrX, long nNewScrY,
                             SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2,
                             double nPixelPerTwipsX, double nPixelPerTwipsY,
-                            const Fraction* pZoomX, const Fraction* pZoomY ) :
+                            const Fraction* pZoomX, const Fraction* pZoomY,
+                            long nNewTilePosX, long nNewTilePosY ) :
     mpDev( pNewDev ),
     mpRefDevice( pNewDev ),      // default is output device
     pFmtDevice( pNewDev ),      // default is output device
@@ -145,6 +148,8 @@ ScOutputData::ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
     nTab( nNewTab ),
     nScrX( nNewScrX ),
     nScrY( nNewScrY ),
+    nTilePosX( nNewTilePosX ),
+    nTilePosY( nNewTilePosY ),
     nX1( nNewX1 ),
     nY1( nNewY1 ),
     nX2( nNewX2 ),
@@ -1877,10 +1882,103 @@ void ScOutputData::FindChanged()
     mpDoc->EnableIdle(bWasIdleEnabled);
 }
 
-void ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
+ReferenceMark ScOutputData::FillReferenceMark( SCCOL nRefStartX, SCROW nRefStartY,
+                                SCCOL nRefEndX, SCROW nRefEndY, const Color& rColor)
+{
+    ReferenceMark aResult;
+
+    PutInOrder( nRefStartX, nRefEndX );
+    PutInOrder( nRefStartY, nRefEndY );
+
+    if ( nRefStartX == nRefEndX && nRefStartY == nRefEndY )
+        mpDoc->ExtendMerge( nRefStartX, nRefStartY, nRefEndX, nRefEndY, nTab );
+
+    if ( nRefStartX <= nVisX2 && nRefEndX >= nVisX1 &&
+         nRefStartY <= nVisY2 && nRefEndY >= nVisY1 )
+    {
+        long nMinX = nScrX;
+        long nMinY = nScrY;
+        long nMaxX = nScrX + nScrW - 1;
+        long nMaxY = nScrY + nScrH - 1;
+        if ( bLayoutRTL )
+        {
+            long nTemp = nMinX;
+            nMinX = nMaxX;
+            nMaxX = nTemp;
+        }
+        long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+        bool bTop    = false;
+        bool bBottom = false;
+        bool bLeft   = false;
+        bool bRight  = false;
+
+        long nPosY = nScrY;
+        bool bNoStartY = ( nY1 < nRefStartY );
+        bool bNoEndY   = false;
+        for (SCSIZE nArrY=1; nArrY<nArrCount; nArrY++)      // loop to end for bNoEndY check
+        {
+            SCROW nY = pRowInfo[nArrY].nRowNo;
+
+            if ( nY==nRefStartY || (nY>nRefStartY && bNoStartY) )
+            {
+                nMinY = nPosY;
+                bTop = true;
+            }
+            if ( nY==nRefEndY )
+            {
+                nMaxY = nPosY + pRowInfo[nArrY].nHeight - 2;
+                bBottom = true;
+            }
+            if ( nY>nRefEndY && bNoEndY )
+            {
+                nMaxY = nPosY-2;
+                bBottom = true;
+            }
+            bNoStartY = ( nY < nRefStartY );
+            bNoEndY   = ( nY < nRefEndY );
+            nPosY += pRowInfo[nArrY].nHeight;
+        }
+
+        long nPosX = nScrX;
+        if ( bLayoutRTL )
+            nPosX += nMirrorW - 1;      // always in pixels
+
+        for (SCCOL nX=nX1; nX<=nX2; nX++)
+        {
+            if ( nX==nRefStartX )
+            {
+                nMinX = nPosX;
+                bLeft = true;
+            }
+            if ( nX==nRefEndX )
+            {
+                nMaxX = nPosX + ( pRowInfo[0].pCellInfo[nX+1].nWidth - 2 ) * nLayoutSign;
+                bRight = true;
+            }
+            nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign;
+        }
+
+        if (bTop && bBottom && bLeft && bRight)
+        {
+            aResult = ReferenceMark( nMinX / mnPPTX * double( aZoomX ),
+                                     nMinY / mnPPTY * double( aZoomY ),
+                                     ( nMaxX - nMinX ) / mnPPTX * double( aZoomX ),
+                                     ( nMaxY - nMinY ) / mnPPTY * double( aZoomY ),
+                                     nTab,
+                                     rColor );
+        }
+    }
+
+    return aResult;
+}
+
+ReferenceMark ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
                                 SCCOL nRefEndX, SCROW nRefEndY,
                                 const Color& rColor, bool bHandle )
 {
+    ReferenceMark aResult;
+
     PutInOrder( nRefStartX, nRefEndX );
     PutInOrder( nRefStartY, nRefEndY );
 
@@ -1957,12 +2055,12 @@ void ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
              nMaxY >= nMinY )
         {
             mpDev->SetLineColor( rColor );
-            if (bTop && bBottom && bLeft && bRight)
+            if (bTop && bBottom && bLeft && bRight && !comphelper::LibreOfficeKit::isActive() )
             {
-                mpDev->SetFillColor();
-                mpDev->DrawRect( tools::Rectangle( nMinX, nMinY, nMaxX, nMaxY ) );
+                    mpDev->SetFillColor();
+                    mpDev->DrawRect( tools::Rectangle( nMinX, nMinY, nMaxX, nMaxY ) );
             }
-            else
+            else if ( !comphelper::LibreOfficeKit::isActive() )
             {
                 if (bTop)
                     mpDev->DrawLine( Point( nMinX, nMinY ), Point( nMaxX, nMinY ) );
@@ -1973,7 +2071,7 @@ void ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
                 if (bRight)
                     mpDev->DrawLine( Point( nMaxX, nMinY ), Point( nMaxX, nMaxY ) );
             }
-            if ( bHandle && bRight && bBottom )
+            if ( bHandle && bRight && bBottom && !comphelper::LibreOfficeKit::isActive() )
             {
                 mpDev->SetLineColor( rColor );
                 mpDev->SetFillColor( rColor );
@@ -2003,6 +2101,8 @@ void ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
             }
         }
     }
+
+    return aResult;
 }
 
 void ScOutputData::DrawOneChange( SCCOL nRefStartX, SCROW nRefStartY,
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index f9dbc14bbd76..ae81a4254b78 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -2057,6 +2057,9 @@ void ScTabView::OnLibreOfficeKitTabChanged()
         SfxLokHelper::forEachOtherView(pThisViewShell, lTabSwitch);
 
         pThisViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_HEADER, "all");
+
+        if (pThisViewShell->GetInputHandler())
+            pThisViewShell->GetInputHandler()->UpdateLokReferenceMarks();
     }
 }
 
diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx
index 653c368d5b3e..70e72d0f2ace 100644
--- a/sc/source/ui/view/tabview4.cxx
+++ b/sc/source/ui/view/tabview4.cxx
@@ -27,6 +27,9 @@
 #include <gridwin.hxx>
 #include <globstr.hrc>
 #include <scresid.hxx>
+#include <formulacell.hxx>
+#include <dociter.hxx>
+#include <inputhdl.hxx>
 
 // ---  Referenz-Eingabe / Fill-Cursor
 
@@ -247,6 +250,12 @@ void ScTabView::UpdateRef( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ )
         SCROW nPaintEndY;
         if (aRect.GetDiff( nPaintStartX, nPaintStartY, nPaintEndX, nPaintEndY ))
             PaintArea( nPaintStartX, nPaintStartY, nPaintEndX, nPaintEndY, ScUpdateMode::Marks );
+
+        ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl();
+        if (pInputHandler)
+        {
+            pInputHandler->UpdateLokReferenceMarks();
+        }
     }
 
     //  autocomplete for Auto-Fill
@@ -324,6 +333,12 @@ void ScTabView::InitRefMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScRefType eT
             ScRange aRef( nCurX,nCurY,nCurZ, nCurX,nCurY,nCurZ );
             SC_MOD()->SetReference( aRef, pDoc, &rMark );
         }
+
+        ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl();
+        if (pInputHandler)
+        {
+            pInputHandler->UpdateLokReferenceMarks();
+        }
     }
 }
 


More information about the Libreoffice-commits mailing list