Kaydet (Commit) e6103885 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

We only need to send the broadcaster instance with ScHint.

Another ScBaseCell eliminated.

Change-Id: I32a07024dd1d8ab536038942aa7209a7829d193c
üst f847a0e2
...@@ -180,6 +180,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ ...@@ -180,6 +180,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/tool/adiasync \ sc/source/core/tool/adiasync \
sc/source/core/tool/appoptio \ sc/source/core/tool/appoptio \
sc/source/core/tool/autoform \ sc/source/core/tool/autoform \
sc/source/core/tool/brdcst \
sc/source/core/tool/calcconfig \ sc/source/core/tool/calcconfig \
sc/source/core/tool/callform \ sc/source/core/tool/callform \
sc/source/core/tool/cellform \ sc/source/core/tool/cellform \
......
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
#include <tools/rtti.hxx> #include <tools/rtti.hxx>
#include <svl/hint.hxx> #include <svl/hint.hxx>
#include <svl/smplhint.hxx> #include <svl/smplhint.hxx>
class ScBaseCell;
class SvtBroadcaster;
#define SC_HINT_DYING SFX_HINT_DYING #define SC_HINT_DYING SFX_HINT_DYING
#define SC_HINT_DATACHANGED SFX_HINT_DATACHANGED #define SC_HINT_DATACHANGED SFX_HINT_DATACHANGED
...@@ -35,14 +36,13 @@ class ScHint : public SfxSimpleHint ...@@ -35,14 +36,13 @@ class ScHint : public SfxSimpleHint
{ {
private: private:
ScAddress aAddress; ScAddress aAddress;
ScBaseCell* pCell; SvtBroadcaster* mpBroadcaster;
public: public:
TYPEINFO(); TYPEINFO();
ScHint( sal_uLong n, const ScAddress& a, ScBaseCell* p ) ScHint( sal_uLong n, const ScAddress& a, SvtBroadcaster* p );
: SfxSimpleHint( n ), aAddress( a ), pCell( p ) {} SvtBroadcaster* GetBroadcaster() const;
ScBaseCell* GetCell() const { return pCell; } void SetBroadcaster( SvtBroadcaster* p );
void SetCell( ScBaseCell* p ) { pCell = p; }
const ScAddress& GetAddress() const { return aAddress; } const ScAddress& GetAddress() const { return aAddress; }
ScAddress& GetAddress() { return aAddress; } ScAddress& GetAddress() { return aAddress; }
void SetAddress( const ScAddress& rAdr ) { aAddress = rAdr; } void SetAddress( const ScAddress& rAdr ) { aAddress = rAdr; }
......
...@@ -2155,7 +2155,7 @@ void ScColumn::SetDirty( const ScRange& rRange ) ...@@ -2155,7 +2155,7 @@ void ScColumn::SetDirty( const ScRange& rRange )
else else
{ {
aHint.GetAddress().SetRow( nRow ); aHint.GetAddress().SetRow( nRow );
aHint.SetCell( pCell ); aHint.SetBroadcaster(pCell->GetBroadcaster());
pDocument->Broadcast( aHint ); pDocument->Broadcast( aHint );
} }
nIndex++; nIndex++;
...@@ -2184,7 +2184,7 @@ void ScColumn::SetTableOpDirty( const ScRange& rRange ) ...@@ -2184,7 +2184,7 @@ void ScColumn::SetTableOpDirty( const ScRange& rRange )
else else
{ {
aHint.GetAddress().SetRow( nRow ); aHint.GetAddress().SetRow( nRow );
aHint.SetCell( pCell ); aHint.SetBroadcaster(pCell->GetBroadcaster());
pDocument->Broadcast( aHint ); pDocument->Broadcast( aHint );
} }
nIndex++; nIndex++;
......
...@@ -122,7 +122,7 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell ) ...@@ -122,7 +122,7 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell )
((ScFormulaCell*)pNewCell)->SetDirty(); ((ScFormulaCell*)pNewCell)->SetDirty();
else else
pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED, pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED,
ScAddress( nCol, nRow, nTab ), pNewCell ) ); ScAddress( nCol, nRow, nTab ), pNewCell->GetBroadcaster()) );
} }
} }
bDirtyGroups = true; bDirtyGroups = true;
...@@ -160,7 +160,7 @@ void ScColumn::Delete( SCROW nRow ) ...@@ -160,7 +160,7 @@ void ScColumn::Delete( SCROW nRow )
ScNoteCell* pNoteCell = new ScNoteCell; ScNoteCell* pNoteCell = new ScNoteCell;
maItems[nIndex].pCell = pNoteCell; // Dummy for Interpret maItems[nIndex].pCell = pNoteCell; // Dummy for Interpret
pDocument->Broadcast( ScHint( SC_HINT_DYING, pDocument->Broadcast( ScHint( SC_HINT_DYING,
ScAddress( nCol, nRow, nTab ), pCell ) ); ScAddress( nCol, nRow, nTab ), pCell->GetBroadcaster()));
if ( SvtBroadcaster* pBC = pCell->ReleaseBroadcaster() ) if ( SvtBroadcaster* pBC = pCell->ReleaseBroadcaster() )
{ {
pNoteCell->TakeBroadcaster( pBC ); pNoteCell->TakeBroadcaster( pBC );
...@@ -190,7 +190,7 @@ void ScColumn::DeleteAtIndex( SCSIZE nIndex ) ...@@ -190,7 +190,7 @@ void ScColumn::DeleteAtIndex( SCSIZE nIndex )
ScNoteCell* pNoteCell = new ScNoteCell; ScNoteCell* pNoteCell = new ScNoteCell;
maItems[nIndex].pCell = pNoteCell; // Dummy for Interpret maItems[nIndex].pCell = pNoteCell; // Dummy for Interpret
pDocument->Broadcast( pDocument->Broadcast(
ScHint(SC_HINT_DYING, ScAddress(nCol, nRow, nTab), pCell)); ScHint(SC_HINT_DYING, ScAddress(nCol, nRow, nTab), pCell->GetBroadcaster()));
pNoteCell->Delete(); pNoteCell->Delete();
maItems.erase(maItems.begin() + nIndex); maItems.erase(maItems.begin() + nIndex);
if (pCell->GetCellType() == CELLTYPE_FORMULA) if (pCell->GetCellType() == CELLTYPE_FORMULA)
...@@ -414,7 +414,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe ...@@ -414,7 +414,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
// interpret in broadcast must not use the old cell // interpret in broadcast must not use the old cell
maItems[ nIdx ].pCell = pDummyCell.get(); maItems[ nIdx ].pCell = pDummyCell.get();
aHint.GetAddress().SetRow( maItems[ nIdx ].nRow ); aHint.GetAddress().SetRow( maItems[ nIdx ].nRow );
aHint.SetCell( pOldCell ); aHint.SetBroadcaster(pOldCell->GetBroadcaster());
pDocument->Broadcast( aHint ); pDocument->Broadcast( aHint );
pOldCell->Delete(); pOldCell->Delete();
} }
...@@ -470,7 +470,12 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe ...@@ -470,7 +470,12 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
else else
{ {
aHint.GetAddress().SetRow(nOldRow); 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); pDocument->Broadcast(aHint);
if (pNoteCell != pOldCell) if (pNoteCell != pOldCell)
{ {
...@@ -553,7 +558,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe ...@@ -553,7 +558,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
// from maItems. // from maItems.
SCSIZE nIndex; SCSIZE nIndex;
ScBaseCell* pCell = (Search( (*aIt)->aPos.Row(), nIndex) ? maItems[nIndex].pCell : NULL); ScBaseCell* pCell = (Search( (*aIt)->aPos.Row(), nIndex) ? maItems[nIndex].pCell : NULL);
aHint.SetCell( pCell ); aHint.SetBroadcaster(pCell ? pCell->GetBroadcaster() : NULL);
aHint.SetAddress( (*aIt)->aPos ); aHint.SetAddress( (*aIt)->aPos );
pDocument->Broadcast( aHint ); pDocument->Broadcast( aHint );
(*aIt)->Delete(); (*aIt)->Delete();
...@@ -1195,7 +1200,7 @@ void ScColumn::BroadcastInArea( SCROW nRow1, SCROW nRow2 ) ...@@ -1195,7 +1200,7 @@ void ScColumn::BroadcastInArea( SCROW nRow1, SCROW nRow2 )
((ScFormulaCell*)pCell)->SetDirty(); ((ScFormulaCell*)pCell)->SetDirty();
else else
pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED, pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED,
ScAddress( nCol, nRow, nTab ), pCell ) ); ScAddress(nCol, nRow, nTab), pCell->GetBroadcaster()));
nIndex++; nIndex++;
} }
} }
...@@ -1469,7 +1474,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, ...@@ -1469,7 +1474,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
} }
else else
pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED, pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED,
ScAddress( nCol, nRow, nTabP ), pNewCell ) ); ScAddress(nCol, nRow, nTabP), pNewCell->GetBroadcaster()));
} }
else else
{ {
......
...@@ -69,7 +69,7 @@ void ScDocument::Broadcast( sal_uLong nHint, const ScAddress& rAddr, ...@@ -69,7 +69,7 @@ void ScDocument::Broadcast( sal_uLong nHint, const ScAddress& rAddr,
{ {
if ( !pBASM ) if ( !pBASM )
return ; // Clipboard or Undo return ; // Clipboard or Undo
ScHint aHint( nHint, rAddr, pCell ); ScHint aHint(nHint, rAddr, pCell ? pCell->GetBroadcaster() : NULL);
Broadcast( aHint ); Broadcast( aHint );
} }
...@@ -82,15 +82,11 @@ void ScDocument::Broadcast( const ScHint& rHint ) ...@@ -82,15 +82,11 @@ void ScDocument::Broadcast( const ScHint& rHint )
{ {
ScBulkBroadcast aBulkBroadcast( pBASM); // scoped bulk broadcast ScBulkBroadcast aBulkBroadcast( pBASM); // scoped bulk broadcast
bool bIsBroadcasted = false; bool bIsBroadcasted = false;
ScBaseCell* pCell = rHint.GetCell(); SvtBroadcaster* pBC = rHint.GetBroadcaster();
if ( pCell ) if ( pBC )
{ {
SvtBroadcaster* pBC = pCell->GetBroadcaster(); pBC->Broadcast( rHint );
if ( pBC ) bIsBroadcasted = true;
{
pBC->Broadcast( rHint );
bIsBroadcasted = true;
}
} }
if ( pBASM->AreaBroadcast( rHint ) || bIsBroadcasted ) if ( pBASM->AreaBroadcast( rHint ) || bIsBroadcasted )
TrackFormulas( rHint.GetId() ); TrackFormulas( rHint.GetId() );
...@@ -457,7 +453,7 @@ void ScDocument::TrackFormulas( sal_uLong nHintId ) ...@@ -457,7 +453,7 @@ void ScDocument::TrackFormulas( sal_uLong nHintId )
pTrack = pFormulaTrack; pTrack = pFormulaTrack;
do do
{ {
ScHint aHint( nHintId, pTrack->aPos, pTrack ); ScHint aHint( nHintId, pTrack->aPos, pTrack->GetBroadcaster() );
if ( ( pBC = pTrack->GetBroadcaster() ) != NULL ) if ( ( pBC = pTrack->GetBroadcaster() ) != NULL )
pBC->Broadcast( aHint ); pBC->Broadcast( aHint );
pBASM->AreaBroadcast( aHint ); pBASM->AreaBroadcast( aHint );
......
/* -*- 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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment