[Libreoffice-commits] .: Branch 'distro/suse/suse-3.6' - 2 commits - sc/source svl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Nov 20 08:11:26 PST 2012


 sc/source/core/data/column3.cxx |   67 ++++++++++++++++++++--------------------
 svl/source/numbers/zforfind.cxx |   22 +++++++++----
 2 files changed, 51 insertions(+), 38 deletions(-)

New commits:
commit ece86458f09e91b57729b82c8897339c37949960
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Nov 14 21:48:33 2012 +0100

    resolved fdo#56278 broadcast deletion to dependent formula cells
    
    Consolidated changes for fdo#56278 fdo#54074 fdo#53364 fdo#55059 (and
    earlier i#99844 and i#101869). The replacement cell for the broadcaster
    to inform listeners, if any, is transferred the broadcaster and owns it,
    the remembered formula cell never does. When broadcasting the change use
    the replacement cell instead of the remembered formula cell. Don't
    fiddle around with ReleaseBroadcaster() at the remembered cell, we don't
    delete twice and now also don't leak.
    
    (cherry picked from commit 8165bfa2afbe828caf37df57b83cb31bef2559cb)
    
    Change-Id: Ia11b6d3d751c784af64aaed05f8508887f869a80
    Reviewed-on: https://gerrit.libreoffice.org/1069
    Reviewed-by: Norbert Thiebaud <nthiebaud at gmail.com>
    Tested-by: Norbert Thiebaud <nthiebaud at gmail.com>

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 475299d..a355551 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -399,11 +399,13 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
                 // try to create a replacement note cell, if note or broadcaster exists
                 ScNoteCell* pNoteCell = NULL;
                 SvtBroadcaster* pBC = pOldCell->GetBroadcaster();
-                bool bKeepBC = pBC && pBC->HasListeners();
-                // #i99844# do not release broadcaster from old cell, it still has to notify deleted content
-                if (bKeepBC)
+                if (pBC && pBC->HasListeners())
                 {
                     pNoteCell = new ScNoteCell( pBC );
+                    // NOTE: the broadcaster here is transferred and released
+                    // only if it has listeners! If it does not, it will simply
+                    // be deleted when the cell is deleted and no replacement
+                    // cell is created.
                     pOldCell->ReleaseBroadcaster();
                 }
 
@@ -427,15 +429,10 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
                 else
                 {
                     aHint.GetAddress().SetRow( nOldRow );
-                    if(bKeepBC)
-                        aHint.SetCell( pNoteCell );
-                    else
-                        aHint.SetCell( pOldCell );
+                    aHint.SetCell( pNoteCell ? pNoteCell : pOldCell );
                     pDocument->Broadcast( aHint );
                     if (pNoteCell != pOldCell)
                     {
-                        // #i99844# after broadcasting, old cell has to forget the broadcaster (owned by pNoteCell)
-                        pOldCell->ReleaseBroadcaster();
                         pOldCell->Delete();
                     }
                 }
@@ -456,7 +453,9 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
     if (nFirst <= nEndIndex)
         aRemovedSegments.insert_back(nFirst, nEndIndex + 1, true);
 
-    {
+    // Remove segments from the column array, containing pDummyCell and formula
+    // cell pointers to be deleted.
+    { // own scope for variables
         RemovedSegments_t::const_iterator aIt(aRemovedSegments.begin());
         RemovedSegments_t::const_iterator aEnd(aRemovedSegments.end());
         // The indexes in aRemovedSegments denote cell positions in the
@@ -499,29 +498,33 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
     }
 
     // *** delete all formula cells ***
-
-    // first, all cells stop listening, may save unneeded recalcualtions
-    for ( FormulaCellVector::iterator aIt = aDelCells.begin(), aEnd = aDelCells.end(); aIt != aEnd; ++aIt )
-        (*aIt)->EndListeningTo( pDocument );
-
-    // #i101869# if the note cell with the broadcaster was deleted in EndListening,
-    // forget the pointer to the broadcaster
-    for ( FormulaCellVector::iterator aIt = aDelCells.begin(), aEnd = aDelCells.end(); aIt != aEnd; ++aIt )
-    {
-        SCSIZE nIndex;
-        if ( !Search( (*aIt)->aPos.Row(), nIndex ) )
-            (*aIt)->ReleaseBroadcaster();
-    }
-
-    // broadcast SC_HINT_DYING for all cells and delete them
-    for ( FormulaCellVector::iterator aIt = aDelCells.begin(), aEnd = aDelCells.end(); aIt != aEnd; ++aIt )
+    if (!aDelCells.empty())
     {
-        aHint.SetAddress( (*aIt)->aPos );
-        aHint.SetCell( *aIt );
-        pDocument->Broadcast( aHint );
-        // #i99844# after broadcasting, old cell has to forget the broadcaster (owned by replacement note cell)
-        (*aIt)->ReleaseBroadcaster();
-        (*aIt)->Delete();
+        // First, all cells stop listening, may save unneeded broadcasts and
+        // recalcualtions.
+        // NOTE: this actually may remove ScNoteCell entries from maItems if
+        // the last listener is removed from a broadcaster.
+        for ( FormulaCellVector::iterator aIt = aDelCells.begin(), aEnd = aDelCells.end(); aIt != aEnd; ++aIt )
+            (*aIt)->EndListeningTo( pDocument );
+
+        // NOTE: the vector does not contain cells with broadcasters that have
+        // listeners. If it would, broadcasters that were deleted during
+        // EndListeningTo() would have to be released from these cells.
+
+        // broadcast SC_HINT_DYING for all cells and delete them
+        for ( FormulaCellVector::iterator aIt = aDelCells.begin(), aEnd = aDelCells.end(); aIt != aEnd; ++aIt )
+        {
+            // A formula cell's broadcaster now is at the replacement cell, use
+            // that. If there is no cell anymore it means all listeners are
+            // gone for this formula cell and the replacement cell was removed
+            // from maItems.
+            SCSIZE nIndex;
+            ScBaseCell* pCell = (Search( (*aIt)->aPos.Row(), nIndex) ? maItems[nIndex].pCell : NULL);
+            aHint.SetCell( pCell );
+            aHint.SetAddress( (*aIt)->aPos );
+            pDocument->Broadcast( aHint );
+            (*aIt)->Delete();
+        }
     }
 }
 
commit 2fc41695d7b62ecb20ac9f28466745f90b094348
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Nov 13 14:23:01 2012 +0100

    resolved fdo#55369 accept fraction input if preset
    
    Accept fraction input without integer portion if the format was preset
    as fraction, e.g. 1/5 instead of  0 1/5  and don't force to date.
    
    (cherry picked from commit 5391bd1e54157457abe1098b29f067d6e0059113)
    
    Change-Id: I326ec85b163962425efa074119405ec1395af481
    Reviewed-on: https://gerrit.libreoffice.org/1045
    Reviewed-by: Petr Mladek <pmladek at suse.cz>
    Tested-by: Petr Mladek <pmladek at suse.cz>

diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index eae56da..ef6015e 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -2025,14 +2025,24 @@ bool ImpSvNumberInputScan::ScanMidString( const String& rString,
     {
         if (   eScannedType != NUMBERFORMAT_UNDEFINED   // already another type
             && eScannedType != NUMBERFORMAT_DATE)       // except date
-            return MatchedReturn();                               // => jan/31/1994
-        else if (    eScannedType != NUMBERFORMAT_DATE      // analyzed date until now
-                 && (    eSetType == NUMBERFORMAT_FRACTION  // and preset was fraction
-                     || (nAnzNums == 3                      // or 3 numbers
-                         && nStringPos > 2) ) )             // and what ???
+            return MatchedReturn();                     // => jan/31/1994
+        else if (eScannedType != NUMBERFORMAT_DATE      // analyzed no date until now
+                && ( eSetType == NUMBERFORMAT_FRACTION  // and preset was fraction
+                    || (nAnzNums == 3                   // or 3 numbers
+                        && (nStringPos == 3             // and 3rd string particle
+                            || (nStringPos == 4         // or 4th
+                                && nSign)))))           //   if signed
         {
             SkipBlanks(rString, nPos);
-            eScannedType = NUMBERFORMAT_FRACTION;   // !!! it IS a fraction
+            if (nPos == rString.Len())
+            {
+                eScannedType = NUMBERFORMAT_FRACTION;   // !!! it IS a fraction (so far)
+                if (eSetType == NUMBERFORMAT_FRACTION
+                        && nAnzNums == 2
+                        && (nStringPos == 1                     // for 4/5
+                            || (nStringPos == 2 && nSign)))     // or signed -4/5
+                    return true;                                // don't fall into date trap
+            }
         }
         else
             nPos--;                                 // put '/' back


More information about the Libreoffice-commits mailing list