[Libreoffice-commits] core.git: Branch 'libreoffice-4-2-8' - sc/inc sc/source

Eike Rathke erack at redhat.com
Tue Dec 2 12:22:00 PST 2014


 sc/inc/column.hxx                   |    2 
 sc/inc/document.hxx                 |    2 
 sc/inc/refhint.hxx                  |   18 ++
 sc/inc/table.hxx                    |    2 
 sc/source/core/data/column.cxx      |   17 ++
 sc/source/core/data/document.cxx    |    5 
 sc/source/core/data/formulacell.cxx |   10 +
 sc/source/core/data/table2.cxx      |    4 
 sc/source/core/data/table3.cxx      |  245 +++++++++++++++++++++++-------------
 sc/source/core/tool/refhint.cxx     |    6 
 sc/source/ui/docshell/dbdocfun.cxx  |    2 
 11 files changed, 219 insertions(+), 94 deletions(-)

New commits:
commit b83207805b9902742bc6a56335293853b3883fe3
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Dec 1 23:56:44 2014 +0100

    fdo#86762 re-establish listeners to move cell broadcasters
    
    ... for UpdateReferenceOnSort=false
    
    (cherry picked from commit 6c2111f17089eb667bf526561d7667d17825e822)
    
    Conflicts:
    	sc/source/core/data/table3.cxx
    
    fdo#86762 broadcast also empty cells after sort
    
    (cherry picked from commit 08793e08c7e9cefe594c49130f782725e386c463)
    
    Conflicts:
    	sc/inc/column.hxx
    	sc/source/core/data/column.cxx
    	sc/source/core/data/document.cxx
    	sc/source/core/data/table2.cxx
    	sc/source/ui/docshell/dbdocfun.cxx
    
    fdo#86762 re-establish listeners on moved broadcasters
    
    ...  also in SortReorderByColumn() similar to SortReorderByRow()
    
    (cherry picked from commit e119f3883513aeaa49f332362620e955dc8b453f)
    
    Conflicts:
    	sc/source/core/data/table3.cxx
    
    e275a754c530d6039ed14304900dd71416f36e46
    7665dcc90d70fcf3b08bef0adb9ab6aaff1cdcdf
    
    Change-Id: Id90288660e317d6e47ee01ee3b5ff9058cfa18df
    Reviewed-on: https://gerrit.libreoffice.org/13276
    Reviewed-by: Kohei Yoshida <libreoffice at kohei.us>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 4bda39d..86d39ab 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -334,7 +334,7 @@ public:
     bool IsFormulaDirty( SCROW nRow ) const;
 
     void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
-    void        SetDirty( SCROW nRow1, SCROW nRow2 );
+    void        SetDirty( SCROW nRow1, SCROW nRow2, bool bIncludeEmptyCells = false );
     void        SetDirtyVar();
     void        SetDirtyAfterLoad();
     void        SetTableOpDirty( const ScRange& );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 44107b4..1d744a2 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -994,7 +994,7 @@ public:
     void            ResetChanged( const ScRange& rRange );
 
     void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
-    void            SetDirty( const ScRange& );
+    void            SetDirty( const ScRange&, bool bIncludeEmptyCells = false );
     void            SetTableOpDirty( const ScRange& );  // for Interpreter TableOp
     void            InterpretDirtyCells( const ScRangeList& rRanges );
     SC_DLLPUBLIC void CalcAll();
diff --git a/sc/inc/refhint.hxx b/sc/inc/refhint.hxx
index 6ccda8b..9ff8d30 100644
--- a/sc/inc/refhint.hxx
+++ b/sc/inc/refhint.hxx
@@ -21,7 +21,9 @@ public:
     enum Type {
         Moved,
         ColumnReordered,
-        RowReordered
+        RowReordered,
+        StartListening,
+        StopListening
     };
 
 private:
@@ -95,6 +97,20 @@ public:
     SCCOL getEndColumn() const;
 };
 
+class RefStartListeningHint : public RefHint
+{
+public:
+    RefStartListeningHint();
+    virtual ~RefStartListeningHint();
+};
+
+class RefStopListeningHint : public RefHint
+{
+public:
+    RefStopListeningHint();
+    virtual ~RefStopListeningHint();
+};
+
 }
 
 #endif
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 480cc2c..5d39f32 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -521,7 +521,7 @@ public:
     void        ResetChanged( const ScRange& rRange );
 
     void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
-    void        SetDirty( const ScRange& );
+    void        SetDirty( const ScRange&, bool bIncludeEmptyCells = false );
     void        SetDirtyAfterLoad();
     void        SetDirtyVar();
     void        SetTableOpDirty( const ScRange& );
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 10da725..c014e00 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -3055,14 +3055,27 @@ void ScColumn::SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt )
     sc::ProcessFormula(maCells, aFunc);
 }
 
-void ScColumn::SetDirty( SCROW nRow1, SCROW nRow2 )
+void ScColumn::SetDirty( SCROW nRow1, SCROW nRow2, bool bIncludeEmptyCells )
 {
     // broadcasts everything within the range, with FormulaTracking
     sc::AutoCalcSwitch aSwitch(*pDocument, false);
 
     SetDirtyOnRangeHandler aHdl(*this);
     sc::ProcessFormula(maCells.begin(), maCells, nRow1, nRow2, aHdl, aHdl);
-    aHdl.broadcast();
+    if (bIncludeEmptyCells)
+    {
+        // Broadcast the changes.
+        ScHint aHint( SC_HINT_DATACHANGED, ScAddress( nCol, 0, nTab));
+        for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
+        {
+            aHint.GetAddress().SetRow(nRow);
+            pDocument->Broadcast(aHint);
+        }
+    }
+    else
+    {
+        aHdl.broadcast();
+    }
 }
 
 void ScColumn::SetTableOpDirty( const ScRange& rRange )
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index b739df7..c6c3196 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3550,8 +3550,7 @@ void ScDocument::SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt )
     SetAutoCalc( bOldAutoCalc );
 }
 
-
-void ScDocument::SetDirty( const ScRange& rRange )
+void ScDocument::SetDirty( const ScRange& rRange, bool bIncludeEmptyCells )
 {
     bool bOldAutoCalc = GetAutoCalc();
     bAutoCalc = false;      // keine Mehrfachberechnung
@@ -3559,7 +3558,7 @@ void ScDocument::SetDirty( const ScRange& rRange )
         ScBulkBroadcast aBulkBroadcast( GetBASM());
         SCTAB nTab2 = rRange.aEnd.Tab();
         for (SCTAB i=rRange.aStart.Tab(); i<=nTab2 && i < static_cast<SCTAB>(maTabs.size()); i++)
-            if (maTabs[i]) maTabs[i]->SetDirty( rRange );
+            if (maTabs[i]) maTabs[i]->SetDirty( rRange, bIncludeEmptyCells );
     }
     SetAutoCalc( bOldAutoCalc );
 }
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index bbaff4f..c0fead2 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1936,6 +1936,16 @@ void ScFormulaCell::Notify( const SfxHint& rHint )
                         rRefRowReorder.getRowMap());
             }
             break;
+            case sc::RefHint::StartListening:
+            {
+                StartListeningTo( pDocument);
+            }
+            break;
+            case sc::RefHint::StopListening:
+            {
+                EndListeningTo( pDocument);
+            }
+            break;
             default:
                 ;
         }
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 1a37801..5ace70e 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1691,13 +1691,13 @@ void ScTable::SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt )
 }
 
 
-void ScTable::SetDirty( const ScRange& rRange )
+void ScTable::SetDirty( const ScRange& rRange, bool bIncludeEmptyCells )
 {
     bool bOldAutoCalc = pDocument->GetAutoCalc();
     pDocument->SetAutoCalc( false );    // Mehrfachberechnungen vermeiden
     SCCOL nCol2 = rRange.aEnd.Col();
     for (SCCOL i=rRange.aStart.Col(); i<=nCol2; i++)
-        aCol[i].SetDirty(rRange.aStart.Row(), rRange.aEnd.Row());
+        aCol[i].SetDirty(rRange.aStart.Row(), rRange.aEnd.Row(), bIncludeEmptyCells);
     pDocument->SetAutoCalc( bOldAutoCalc );
 }
 
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index e49a4dc..58621c6 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -663,6 +663,30 @@ public:
 typedef ReorderNotifier<sc::RefColReorderHint, sc::ColRowReorderMapType, SCCOL> ColReorderNotifier;
 typedef ReorderNotifier<sc::RefRowReorderHint, sc::ColRowReorderMapType, SCROW> RowReorderNotifier;
 
+class StartListeningNotifier : std::unary_function<SvtListener*, void>
+{
+    sc::RefStartListeningHint maHint;
+public:
+    StartListeningNotifier() {}
+
+    void operator() ( SvtListener* p )
+    {
+        p->Notify(maHint);
+    }
+};
+
+class StopListeningNotifier : std::unary_function<SvtListener*, void>
+{
+    sc::RefStopListeningHint maHint;
+public:
+    StopListeningNotifier() {}
+
+    void operator() ( SvtListener* p )
+    {
+        p->Notify(maHint);
+    }
+};
+
 class FormulaGroupPosCollector : std::unary_function<SvtListener*, void>
 {
     sc::RefQueryFormulaGroup& mrQuery;
@@ -692,6 +716,28 @@ void ScTable::SortReorderByColumn(
     for (SCCOL nCol = nStart; nCol <= nLast; ++nCol)
         aCol[nCol].SplitFormulaGroupByRelativeRef(aSortRange);
 
+    // Collect all listeners of cell broadcasters of sorted range.
+    std::vector<SvtListener*> aCellListeners;
+
+    if (!pArray->IsUpdateRefs())
+    {
+        // Collect listeners of cell broadcasters.
+        for (SCCOL nCol = nStart; nCol <= nLast; ++nCol)
+            aCol[nCol].CollectListeners(aCellListeners, nRow1, nRow2);
+
+        // Remove any duplicate listener entries.  We must ensure that we
+        // notify each unique listener only once.
+        std::sort(aCellListeners.begin(), aCellListeners.end());
+        aCellListeners.erase(std::unique(aCellListeners.begin(), aCellListeners.end()), aCellListeners.end());
+
+        // Notify the cells' listeners to stop listening.
+        /* TODO: for performance this could be enhanced to stop and later
+         * restart only listening to within the reordered range and keep
+         * listening to everything outside untouched. */
+        StopListeningNotifier aFunc;
+        std::for_each(aCellListeners.begin(), aCellListeners.end(), aFunc);
+    }
+
     // table to keep track of column index to position in the index table.
     std::vector<SCCOLROW> aPosTable(nCount);
     for (size_t i = 0; i < nCount; ++i)
@@ -720,38 +766,38 @@ void ScTable::SortReorderByColumn(
     for (SCCOL nCol = nStart; nCol <= nLast; ++nCol)
         aCol[nCol].ResetFormulaCellPositions(nRow1, nRow2, bUpdateRefs);
 
-    // Set up column reorder map (for later broadcasting of reference updates).
-    sc::ColRowReorderMapType aColMap;
-    const std::vector<SCCOLROW>& rOldIndices = pArray->GetOrderIndices();
-    for (size_t i = 0, n = rOldIndices.size(); i < n; ++i)
-    {
-        SCCOL nNew = i + nStart;
-        SCCOL nOld = rOldIndices[i];
-        aColMap.insert(sc::ColRowReorderMapType::value_type(nOld, nNew));
-    }
-
-    // Collect all listeners within sorted range ahead of time.
-    std::vector<SvtListener*> aListeners;
-
-    // Get all area listeners that listen on one column within the range and
-    // end their listening.
-    ScRange aMoveRange( nStart, nRow1, nTab, nLast, nRow2, nTab);
-    std::vector<sc::AreaListener> aAreaListeners = pDocument->GetBASM()->GetAllListeners(
-            aMoveRange, sc::OneColumnInsideArea);
+    if (pArray->IsUpdateRefs())
     {
-        std::vector<sc::AreaListener>::iterator it = aAreaListeners.begin(), itEnd = aAreaListeners.end();
-        for (; it != itEnd; ++it)
+        // Set up column reorder map (for later broadcasting of reference updates).
+        sc::ColRowReorderMapType aColMap;
+        const std::vector<SCCOLROW>& rOldIndices = pArray->GetOrderIndices();
+        for (size_t i = 0, n = rOldIndices.size(); i < n; ++i)
         {
-            pDocument->EndListeningArea(it->maArea, it->mpListener);
-            aListeners.push_back( it->mpListener);
+            SCCOL nNew = i + nStart;
+            SCCOL nOld = rOldIndices[i];
+            aColMap.insert(sc::ColRowReorderMapType::value_type(nOld, nNew));
         }
-    }
 
-    if (pArray->IsUpdateRefs())
-    {
+        // Collect all listeners within sorted range ahead of time.
+        std::vector<SvtListener*> aListeners;
+
         for (SCCOL nCol = nStart; nCol <= nLast; ++nCol)
             aCol[nCol].CollectListeners(aListeners, nRow1, nRow2);
 
+        // Get all area listeners that listen on one column within the range
+        // and end their listening.
+        ScRange aMoveRange( nStart, nRow1, nTab, nLast, nRow2, nTab);
+        std::vector<sc::AreaListener> aAreaListeners = pDocument->GetBASM()->GetAllListeners(
+                aMoveRange, sc::OneColumnInsideArea);
+        {
+            std::vector<sc::AreaListener>::iterator it = aAreaListeners.begin(), itEnd = aAreaListeners.end();
+            for (; it != itEnd; ++it)
+            {
+                pDocument->EndListeningArea(it->maArea, it->mpListener);
+                aListeners.push_back( it->mpListener);
+            }
+        }
+
         // Remove any duplicate listener entries and notify all listeners
         // afterward.  We must ensure that we notify each unique listener only
         // once.
@@ -759,23 +805,29 @@ void ScTable::SortReorderByColumn(
         aListeners.erase(std::unique(aListeners.begin(), aListeners.end()), aListeners.end());
         ColReorderNotifier aFunc(aColMap, nTab, nRow1, nRow2);
         std::for_each(aListeners.begin(), aListeners.end(), aFunc);
-    }
 
-    // Re-start area listeners on the reordered columns.
-    {
-        std::vector<sc::AreaListener>::iterator it = aAreaListeners.begin(), itEnd = aAreaListeners.end();
-        for (; it != itEnd; ++it)
+        // Re-start area listeners on the reordered columns.
         {
-            ScRange aNewRange = it->maArea;
-            sc::ColRowReorderMapType::const_iterator itCol = aColMap.find( aNewRange.aStart.Col());
-            if (itCol != aColMap.end())
+            std::vector<sc::AreaListener>::iterator it = aAreaListeners.begin(), itEnd = aAreaListeners.end();
+            for (; it != itEnd; ++it)
             {
-                aNewRange.aStart.SetCol( itCol->second);
-                aNewRange.aEnd.SetCol( itCol->second);
+                ScRange aNewRange = it->maArea;
+                sc::ColRowReorderMapType::const_iterator itCol = aColMap.find( aNewRange.aStart.Col());
+                if (itCol != aColMap.end())
+                {
+                    aNewRange.aStart.SetCol( itCol->second);
+                    aNewRange.aEnd.SetCol( itCol->second);
+                }
+                pDocument->StartListeningArea(aNewRange, it->mpListener);
             }
-            pDocument->StartListeningArea(aNewRange, it->mpListener);
         }
     }
+    else    // !(pArray->IsUpdateRefs())
+    {
+        // Notify the cells' listeners to (re-)start listening.
+        StartListeningNotifier aFunc;
+        std::for_each(aCellListeners.begin(), aCellListeners.end(), aFunc);
+    }
 
     // Re-join formulas at row boundaries now that all the references have
     // been adjusted for column reordering.
@@ -803,6 +855,9 @@ void ScTable::SortReorderByRow(
     ScSortInfoArray::RowsType* pRows = pArray->GetDataRows();
     assert(pRows); // In sort-by-row mode we must have data rows already populated.
 
+    // Collect all listeners of cell broadcasters of sorted range.
+    std::vector<SvtListener*> aCellListeners;
+
     if (!pArray->IsUpdateRefs())
     {
         // When the update ref mode is disabled, we need to detach all formula
@@ -810,6 +865,22 @@ void ScTable::SortReorderByRow(
         // afterward.
         sc::EndListeningContext aCxt(*pDocument);
         DetachFormulaCells(aCxt, nCol1, nRow1, nCol2, nRow2);
+
+        // Collect listeners of cell broadcasters.
+        for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
+            aCol[nCol].CollectListeners(aCellListeners, nRow1, nRow2);
+
+        // Remove any duplicate listener entries.  We must ensure that we notify
+        // each unique listener only once.
+        std::sort(aCellListeners.begin(), aCellListeners.end());
+        aCellListeners.erase(std::unique(aCellListeners.begin(), aCellListeners.end()), aCellListeners.end());
+
+        // Notify the cells' listeners to stop listening.
+        /* TODO: for performance this could be enhanced to stop and later
+         * restart only listening to within the reordered range and keep
+         * listening to everything outside untouched. */
+        StopListeningNotifier aFunc;
+        std::for_each(aCellListeners.begin(), aCellListeners.end(), aFunc);
     }
 
     // Split formula groups at the sort range boundaries (if applicable).
@@ -889,15 +960,18 @@ void ScTable::SortReorderByRow(
             else
                 rAttrStore.push_back_empty();
 
-            // At this point each broadcaster instance is managed by 2
-            // containers. We will release those in the original storage
-            // below before transferring them to the document.
-            sc::BroadcasterStoreType& rBCStore = aSortedCols.at(j).maBroadcasters;
-            if (rCell.mpBroadcaster)
-                // A const pointer would be implicitly converted to a bool type.
-                rBCStore.push_back(const_cast<SvtBroadcaster*>(rCell.mpBroadcaster));
-            else
-                rBCStore.push_back_empty();
+            if (pArray->IsUpdateRefs())
+            {
+                // At this point each broadcaster instance is managed by 2
+                // containers. We will release those in the original storage
+                // below before transferring them to the document.
+                sc::BroadcasterStoreType& rBCStore = aSortedCols.at(j).maBroadcasters;
+                if (rCell.mpBroadcaster)
+                    // A const pointer would be implicitly converted to a bool type.
+                    rBCStore.push_back(const_cast<SvtBroadcaster*>(rCell.mpBroadcaster));
+                else
+                    rBCStore.push_back_empty();
+            }
 
             // The same with cell note instances ...
             sc::CellNoteStoreType& rNoteStore = aSortedCols.at(j).maCellNotes;
@@ -938,6 +1012,7 @@ void ScTable::SortReorderByRow(
             rSrc.transfer(nRow1, nRow2, rDest, nRow1);
         }
 
+        if (pArray->IsUpdateRefs())
         {
             sc::BroadcasterStoreType& rSrc = aSortedCols[i].maBroadcasters;
             sc::BroadcasterStoreType& rDest = aCol[nThisCol].maBroadcasters;
@@ -1003,39 +1078,39 @@ void ScTable::SortReorderByRow(
             SetRowFiltered(it->mnRow1, it->mnRow2, true);
     }
 
-    // Set up row reorder map (for later broadcasting of reference updates).
-    sc::ColRowReorderMapType aRowMap;
-    const std::vector<SCCOLROW>& rOldIndices = pArray->GetOrderIndices();
-    for (size_t i = 0, n = rOldIndices.size(); i < n; ++i)
-    {
-        SCROW nNew = i + nRow1;
-        SCROW nOld = rOldIndices[i];
-        aRowMap.insert(sc::ColRowReorderMapType::value_type(nOld, nNew));
-    }
-
-    // Collect all listeners within sorted range ahead of time.
-    std::vector<SvtListener*> aListeners;
-
-    // Get all area listeners that listen on one row within the range and end
-    // their listening.
-    ScRange aMoveRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab);
-    std::vector<sc::AreaListener> aAreaListeners = pDocument->GetBASM()->GetAllListeners(
-            aMoveRange, sc::OneRowInsideArea);
+    if (pArray->IsUpdateRefs())
     {
-        std::vector<sc::AreaListener>::iterator it = aAreaListeners.begin(), itEnd = aAreaListeners.end();
-        for (; it != itEnd; ++it)
+        // Set up row reorder map (for later broadcasting of reference updates).
+        sc::ColRowReorderMapType aRowMap;
+        const std::vector<SCCOLROW>& rOldIndices = pArray->GetOrderIndices();
+        for (size_t i = 0, n = rOldIndices.size(); i < n; ++i)
         {
-            pDocument->EndListeningArea(it->maArea, it->mpListener);
-            aListeners.push_back( it->mpListener);
+            SCROW nNew = i + nRow1;
+            SCROW nOld = rOldIndices[i];
+            aRowMap.insert(sc::ColRowReorderMapType::value_type(nOld, nNew));
         }
-    }
 
-    if (pArray->IsUpdateRefs())
-    {
+        // Collect all listeners within sorted range ahead of time.
+        std::vector<SvtListener*> aListeners;
+
         // Collect listeners of cell broadcasters.
         for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
             aCol[nCol].CollectListeners(aListeners, nRow1, nRow2);
 
+        // Get all area listeners that listen on one row within the range and end
+        // their listening.
+        ScRange aMoveRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab);
+        std::vector<sc::AreaListener> aAreaListeners = pDocument->GetBASM()->GetAllListeners(
+                aMoveRange, sc::OneRowInsideArea);
+        {
+            std::vector<sc::AreaListener>::iterator it = aAreaListeners.begin(), itEnd = aAreaListeners.end();
+            for (; it != itEnd; ++it)
+            {
+                pDocument->EndListeningArea(it->maArea, it->mpListener);
+                aListeners.push_back( it->mpListener);
+            }
+        }
+
         // Remove any duplicate listener entries.  We must ensure that we notify
         // each unique listener only once.
         std::sort(aListeners.begin(), aListeners.end());
@@ -1061,7 +1136,7 @@ void ScTable::SortReorderByRow(
             }
         }
 
-        // Notify the listeners.
+        // Notify the listeners to update their references.
         RowReorderNotifier aFunc(aRowMap, nTab, nCol1, nCol2);
         std::for_each(aListeners.begin(), aListeners.end(), aFunc);
 
@@ -1073,23 +1148,29 @@ void ScTable::SortReorderByRow(
             for (; itCol != itColEnd; ++itCol)
                 pDocument->RegroupFormulaCells(itGroupTab->first, itCol->first);
         }
-    }
 
-    // Re-start area listeners on the reordered rows.
-    {
-        std::vector<sc::AreaListener>::iterator it = aAreaListeners.begin(), itEnd = aAreaListeners.end();
-        for (; it != itEnd; ++it)
+        // Re-start area listeners on the reordered rows.
         {
-            ScRange aNewRange = it->maArea;
-            sc::ColRowReorderMapType::const_iterator itRow = aRowMap.find( aNewRange.aStart.Row());
-            if (itRow != aRowMap.end())
+            std::vector<sc::AreaListener>::iterator it = aAreaListeners.begin(), itEnd = aAreaListeners.end();
+            for (; it != itEnd; ++it)
             {
-                aNewRange.aStart.SetRow( itRow->second);
-                aNewRange.aEnd.SetRow( itRow->second);
+                ScRange aNewRange = it->maArea;
+                sc::ColRowReorderMapType::const_iterator itRow = aRowMap.find( aNewRange.aStart.Row());
+                if (itRow != aRowMap.end())
+                {
+                    aNewRange.aStart.SetRow( itRow->second);
+                    aNewRange.aEnd.SetRow( itRow->second);
+                }
+                pDocument->StartListeningArea(aNewRange, it->mpListener);
             }
-            pDocument->StartListeningArea(aNewRange, it->mpListener);
         }
     }
+    else    // !(pArray->IsUpdateRefs())
+    {
+        // Notify the cells' listeners to (re-)start listening.
+        StartListeningNotifier aFunc;
+        std::for_each(aCellListeners.begin(), aCellListeners.end(), aFunc);
+    }
 
     // Re-group columns in the sorted range too.
     for (SCCOL i = nCol1; i <= nCol2; ++i)
diff --git a/sc/source/core/tool/refhint.cxx b/sc/source/core/tool/refhint.cxx
index 29a9166..33b510d 100644
--- a/sc/source/core/tool/refhint.cxx
+++ b/sc/source/core/tool/refhint.cxx
@@ -81,6 +81,12 @@ SCCOL RefRowReorderHint::getEndColumn() const
     return mnCol2;
 }
 
+RefStartListeningHint::RefStartListeningHint() : RefHint(StartListening) {}
+RefStartListeningHint::~RefStartListeningHint() {}
+
+RefStopListeningHint::RefStopListeningHint() : RefHint(StopListening) {}
+RefStopListeningHint::~RefStopListeningHint() {}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 9163a84..9389a1e 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -536,7 +536,7 @@ sal_Bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
     ScRange aDirtyRange(
         aLocalParam.nCol1, nStartRow, nTab,
         aLocalParam.nCol2, aLocalParam.nRow2, nTab);
-    pDoc->SetDirty( aDirtyRange );
+    pDoc->SetDirty( aDirtyRange, true );
 
     if (bPaint)
     {


More information about the Libreoffice-commits mailing list