[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/Library_sc.mk sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Wed Mar 27 19:53:04 PDT 2013


 sc/Library_sc.mk                 |    1 +
 sc/inc/brdcst.hxx                |   12 ++++++------
 sc/source/core/data/column.cxx   |    4 ++--
 sc/source/core/data/column3.cxx  |   21 +++++++++++++--------
 sc/source/core/data/documen7.cxx |   16 ++++++----------
 sc/source/core/tool/brdcst.cxx   |   35 +++++++++++++++++++++++++++++++++++
 6 files changed, 63 insertions(+), 26 deletions(-)

New commits:
commit ad1e2988640785ad6c28577cbd359ce976069d43
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Mar 27 22:52:31 2013 -0400

    We only need to send the broadcaster instance with ScHint.
    
    Another ScBaseCell eliminated.
    
    Change-Id: I32a07024dd1d8ab536038942aa7209a7829d193c

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 2ee7004..46ab330 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -180,6 +180,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 	sc/source/core/tool/adiasync \
 	sc/source/core/tool/appoptio \
 	sc/source/core/tool/autoform \
+	sc/source/core/tool/brdcst \
 	sc/source/core/tool/calcconfig \
 	sc/source/core/tool/callform \
 	sc/source/core/tool/cellform \
diff --git a/sc/inc/brdcst.hxx b/sc/inc/brdcst.hxx
index ee18de4..737e7e8 100644
--- a/sc/inc/brdcst.hxx
+++ b/sc/inc/brdcst.hxx
@@ -24,7 +24,8 @@
 #include <tools/rtti.hxx>
 #include <svl/hint.hxx>
 #include <svl/smplhint.hxx>
-class ScBaseCell;
+
+class SvtBroadcaster;
 
 #define SC_HINT_DYING       SFX_HINT_DYING
 #define SC_HINT_DATACHANGED SFX_HINT_DATACHANGED
@@ -35,14 +36,13 @@ class ScHint : public SfxSimpleHint
 {
 private:
     ScAddress   aAddress;
-    ScBaseCell* pCell;
+    SvtBroadcaster* mpBroadcaster;
 
 public:
     TYPEINFO();
-                        ScHint( sal_uLong n, const ScAddress& a, ScBaseCell* p )
-                            : SfxSimpleHint( n ), aAddress( a ), pCell( p ) {}
-    ScBaseCell*         GetCell() const { return pCell; }
-    void                SetCell( ScBaseCell* p )    { pCell = p; }
+    ScHint( sal_uLong n, const ScAddress& a, SvtBroadcaster* p );
+    SvtBroadcaster* GetBroadcaster() const;
+    void SetBroadcaster( SvtBroadcaster* p );
     const ScAddress&    GetAddress() const { return aAddress; }
           ScAddress&    GetAddress()       { return aAddress; }
     void                SetAddress( const ScAddress& rAdr ) { aAddress = rAdr; }
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index cf09270..150b5ad 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2155,7 +2155,7 @@ void ScColumn::SetDirty( const ScRange& rRange )
         else
         {
             aHint.GetAddress().SetRow( nRow );
-            aHint.SetCell( pCell );
+            aHint.SetBroadcaster(pCell->GetBroadcaster());
             pDocument->Broadcast( aHint );
         }
         nIndex++;
@@ -2184,7 +2184,7 @@ void ScColumn::SetTableOpDirty( const ScRange& rRange )
         else
         {
             aHint.GetAddress().SetRow( nRow );
-            aHint.SetCell( pCell );
+            aHint.SetBroadcaster(pCell->GetBroadcaster());
             pDocument->Broadcast( aHint );
         }
         nIndex++;
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 8e6fb19..5316ee0 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -122,7 +122,7 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell )
                 ((ScFormulaCell*)pNewCell)->SetDirty();
             else
                 pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED,
-                    ScAddress( nCol, nRow, nTab ), pNewCell ) );
+                    ScAddress( nCol, nRow, nTab ), pNewCell->GetBroadcaster()) );
         }
     }
     bDirtyGroups = true;
@@ -160,7 +160,7 @@ void ScColumn::Delete( SCROW nRow )
         ScNoteCell* pNoteCell = new ScNoteCell;
         maItems[nIndex].pCell = pNoteCell; // Dummy for Interpret
         pDocument->Broadcast( ScHint( SC_HINT_DYING,
-            ScAddress( nCol, nRow, nTab ), pCell ) );
+            ScAddress( nCol, nRow, nTab ), pCell->GetBroadcaster()));
         if ( SvtBroadcaster* pBC = pCell->ReleaseBroadcaster() )
         {
             pNoteCell->TakeBroadcaster( pBC );
@@ -190,7 +190,7 @@ void ScColumn::DeleteAtIndex( SCSIZE nIndex )
     ScNoteCell* pNoteCell = new ScNoteCell;
     maItems[nIndex].pCell = pNoteCell; // Dummy for Interpret
     pDocument->Broadcast(
-        ScHint(SC_HINT_DYING, ScAddress(nCol, nRow, nTab), pCell));
+        ScHint(SC_HINT_DYING, ScAddress(nCol, nRow, nTab), pCell->GetBroadcaster()));
     pNoteCell->Delete();
     maItems.erase(maItems.begin() + nIndex);
     if (pCell->GetCellType() == CELLTYPE_FORMULA)
@@ -414,7 +414,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
                 // interpret in broadcast must not use the old cell
                 maItems[ nIdx ].pCell = pDummyCell.get();
                 aHint.GetAddress().SetRow( maItems[ nIdx ].nRow );
-                aHint.SetCell( pOldCell );
+                aHint.SetBroadcaster(pOldCell->GetBroadcaster());
                 pDocument->Broadcast( aHint );
                 pOldCell->Delete();
             }
@@ -470,7 +470,12 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
             else
             {
                 aHint.GetAddress().SetRow(nOldRow);
-                aHint.SetCell(pNoteCell ? pNoteCell : pOldCell);
+                SvtBroadcaster* pHintBC = NULL;
+                if (pNoteCell)
+                    pHintBC = pNoteCell->GetBroadcaster();
+                else if (pOldCell)
+                    pHintBC = pOldCell->GetBroadcaster();
+                aHint.SetBroadcaster(pHintBC);
                 pDocument->Broadcast(aHint);
                 if (pNoteCell != pOldCell)
                 {
@@ -553,7 +558,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
             // from maItems.
             SCSIZE nIndex;
             ScBaseCell* pCell = (Search( (*aIt)->aPos.Row(), nIndex) ? maItems[nIndex].pCell : NULL);
-            aHint.SetCell( pCell );
+            aHint.SetBroadcaster(pCell ? pCell->GetBroadcaster() : NULL);
             aHint.SetAddress( (*aIt)->aPos );
             pDocument->Broadcast( aHint );
             (*aIt)->Delete();
@@ -1195,7 +1200,7 @@ void ScColumn::BroadcastInArea( SCROW nRow1, SCROW nRow2 )
                 ((ScFormulaCell*)pCell)->SetDirty();
             else
                 pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED,
-                    ScAddress( nCol, nRow, nTab ), pCell ) );
+                    ScAddress(nCol, nRow, nTab), pCell->GetBroadcaster()));
             nIndex++;
         }
     }
@@ -1469,7 +1474,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
                 }
                 else
                     pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED,
-                        ScAddress( nCol, nRow, nTabP ), pNewCell ) );
+                        ScAddress(nCol, nRow, nTabP), pNewCell->GetBroadcaster()));
             }
             else
             {
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index 56eb5651..f813464 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -69,7 +69,7 @@ void ScDocument::Broadcast( sal_uLong nHint, const ScAddress& rAddr,
 {
     if ( !pBASM )
         return ;    // Clipboard or Undo
-    ScHint aHint( nHint, rAddr, pCell );
+    ScHint aHint(nHint, rAddr, pCell ? pCell->GetBroadcaster() : NULL);
     Broadcast( aHint );
 }
 
@@ -82,15 +82,11 @@ void ScDocument::Broadcast( const ScHint& rHint )
     {
         ScBulkBroadcast aBulkBroadcast( pBASM);     // scoped bulk broadcast
         bool bIsBroadcasted = false;
-        ScBaseCell* pCell = rHint.GetCell();
-        if ( pCell )
+        SvtBroadcaster* pBC = rHint.GetBroadcaster();
+        if ( pBC )
         {
-            SvtBroadcaster* pBC = pCell->GetBroadcaster();
-            if ( pBC )
-            {
-                pBC->Broadcast( rHint );
-                bIsBroadcasted = true;
-            }
+            pBC->Broadcast( rHint );
+            bIsBroadcasted = true;
         }
         if ( pBASM->AreaBroadcast( rHint ) || bIsBroadcasted )
             TrackFormulas( rHint.GetId() );
@@ -457,7 +453,7 @@ void ScDocument::TrackFormulas( sal_uLong nHintId )
         pTrack = pFormulaTrack;
         do
         {
-            ScHint aHint( nHintId, pTrack->aPos, pTrack );
+            ScHint aHint( nHintId, pTrack->aPos, pTrack->GetBroadcaster() );
             if ( ( pBC = pTrack->GetBroadcaster() ) != NULL )
                 pBC->Broadcast( aHint );
             pBASM->AreaBroadcast( aHint );
diff --git a/sc/source/core/tool/brdcst.cxx b/sc/source/core/tool/brdcst.cxx
new file mode 100644
index 0000000..e860026
--- /dev/null
+++ b/sc/source/core/tool/brdcst.cxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "brdcst.hxx"
+
+ScHint::ScHint( sal_uLong n, const ScAddress& a, SvtBroadcaster* p ) :
+    SfxSimpleHint(n), aAddress(a), mpBroadcaster(p) {}
+
+SvtBroadcaster* ScHint::GetBroadcaster() const
+{
+    return mpBroadcaster;
+}
+
+void ScHint::SetBroadcaster( SvtBroadcaster* p )
+{
+    mpBroadcaster = p;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list