Kaydet (Commit) bc00e475 authored tarafından Mike Kaganski's avatar Mike Kaganski Kaydeden (comit) Michael Meeks

tdf#89972: also copy external reference status

fixes regression from commit 4467c67d,
where the new optimized code path failed to properly register
ScFormulaCell with ScExternalRefManager.
Introduces a new public method in ScExternalRefManager: insertRefCellAsTmpl
that registers a formula cell to listen to the same external references
as template cell
Introduces new property to ScFormulaCell: mbIsExtRef
that indicates that some external references are referenced by this cell

Change-Id: Iee07d7b51949fd31953b5fa662a213052eb85181
Reviewed-on: https://gerrit.libreoffice.org/16066Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
(cherry picked from commit 17282387)
Reviewed-on: https://gerrit.libreoffice.org/16219Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 55e214eb
...@@ -701,6 +701,12 @@ public: ...@@ -701,6 +701,12 @@ public:
bool containsUnsavedReferences() const { return !maUnsavedDocShells.empty(); } bool containsUnsavedReferences() const { return !maUnsavedDocShells.empty(); }
void insertRefCell(sal_uInt16 nFileId, const ScAddress& rCell); void insertRefCell(sal_uInt16 nFileId, const ScAddress& rCell);
/**
* Add a cell to reference the same files as the template cell.
*/
void insertRefCellFromTemplate( ScFormulaCell* pTemplateCell, ScFormulaCell* pCell );
bool hasCellExternalReference(const ScAddress& rCell);
void enableDocTimer( bool bEnable ); void enableDocTimer( bool bEnable );
...@@ -790,6 +796,7 @@ private: ...@@ -790,6 +796,7 @@ private:
*/ */
void transformUnsavedRefToSavedRef( SfxObjectShell* pShell ); void transformUnsavedRefToSavedRef( SfxObjectShell* pShell );
void insertRefCell(RefCellMap::iterator& itr, ScFormulaCell* pCell);
private: private:
ScDocument* mpDoc; ScDocument* mpDoc;
......
...@@ -143,6 +143,7 @@ private: ...@@ -143,6 +143,7 @@ private:
bool bNeedListening : 1; // Listeners need to be re-established after UpdateReference bool bNeedListening : 1; // Listeners need to be re-established after UpdateReference
bool mbNeedsNumberFormat : 1; // set the calculated number format as hard number format bool mbNeedsNumberFormat : 1; // set the calculated number format as hard number format
bool mbPostponedDirty : 1; // if cell needs to be set dirty later bool mbPostponedDirty : 1; // if cell needs to be set dirty later
bool mbIsExtRef : 1; // has references in ScExternalRefManager; never cleared after set
enum ScInterpretTailParameter enum ScInterpretTailParameter
{ {
...@@ -426,6 +427,8 @@ public: ...@@ -426,6 +427,8 @@ public:
void SyncSharedCode(); void SyncSharedCode();
bool IsPostponedDirty() const { return mbPostponedDirty;} bool IsPostponedDirty() const { return mbPostponedDirty;}
void SetIsExtRef() { mbIsExtRef = true; }
}; };
#endif #endif
......
...@@ -608,6 +608,7 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos ) : ...@@ -608,6 +608,7 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos ) :
bNeedListening(false), bNeedListening(false),
mbNeedsNumberFormat(false), mbNeedsNumberFormat(false),
mbPostponedDirty(false), mbPostponedDirty(false),
mbIsExtRef(false),
aPos(rPos) aPos(rPos)
{ {
SAL_INFO( "sc.core.formulacell", "ScFormulaCell ctor this " << this); SAL_INFO( "sc.core.formulacell", "ScFormulaCell ctor this " << this);
...@@ -638,7 +639,8 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, ...@@ -638,7 +639,8 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos,
bNeedListening( false ), bNeedListening( false ),
mbNeedsNumberFormat( false ), mbNeedsNumberFormat( false ),
mbPostponedDirty(false), mbPostponedDirty(false),
aPos( rPos ) mbIsExtRef(false),
aPos(rPos)
{ {
SAL_INFO( "sc.core.formulacell", "ScFormulaCell ctor this " << this); SAL_INFO( "sc.core.formulacell", "ScFormulaCell ctor this " << this);
...@@ -672,7 +674,8 @@ ScFormulaCell::ScFormulaCell( ...@@ -672,7 +674,8 @@ ScFormulaCell::ScFormulaCell(
bNeedListening( false ), bNeedListening( false ),
mbNeedsNumberFormat( false ), mbNeedsNumberFormat( false ),
mbPostponedDirty(false), mbPostponedDirty(false),
aPos( rPos ) mbIsExtRef(false),
aPos(rPos)
{ {
SAL_INFO( "sc.core.formulacell", "ScFormulaCell ctor this " << this); SAL_INFO( "sc.core.formulacell", "ScFormulaCell ctor this " << this);
assert(pArray); // Never pass a NULL pointer here. assert(pArray); // Never pass a NULL pointer here.
...@@ -721,7 +724,8 @@ ScFormulaCell::ScFormulaCell( ...@@ -721,7 +724,8 @@ ScFormulaCell::ScFormulaCell(
bNeedListening( false ), bNeedListening( false ),
mbNeedsNumberFormat( false ), mbNeedsNumberFormat( false ),
mbPostponedDirty(false), mbPostponedDirty(false),
aPos( rPos ) mbIsExtRef(false),
aPos(rPos)
{ {
SAL_INFO( "sc.core.formulacell", "ScFormulaCell ctor this " << this); SAL_INFO( "sc.core.formulacell", "ScFormulaCell ctor this " << this);
...@@ -770,7 +774,8 @@ ScFormulaCell::ScFormulaCell( ...@@ -770,7 +774,8 @@ ScFormulaCell::ScFormulaCell(
bNeedListening( false ), bNeedListening( false ),
mbNeedsNumberFormat( false ), mbNeedsNumberFormat( false ),
mbPostponedDirty(false), mbPostponedDirty(false),
aPos( rPos ) mbIsExtRef(false),
aPos(rPos)
{ {
SAL_INFO( "sc.core.formulacell", "ScFormulaCell ctor this " << this); SAL_INFO( "sc.core.formulacell", "ScFormulaCell ctor this " << this);
...@@ -801,7 +806,8 @@ ScFormulaCell::ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, cons ...@@ -801,7 +806,8 @@ ScFormulaCell::ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, cons
bNeedListening( false ), bNeedListening( false ),
mbNeedsNumberFormat( false ), mbNeedsNumberFormat( false ),
mbPostponedDirty(false), mbPostponedDirty(false),
aPos( rPos ) mbIsExtRef(false),
aPos(rPos)
{ {
SAL_INFO( "sc.core.formulacell", "ScFormulaCell ctor this " << this); SAL_INFO( "sc.core.formulacell", "ScFormulaCell ctor this " << this);
...@@ -1296,6 +1302,8 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr ...@@ -1296,6 +1302,8 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr
bSkipCompile = true; bSkipCompile = true;
pCode = pPreviousCell->pCode; pCode = pPreviousCell->pCode;
if (pPreviousCell->mbIsExtRef)
pDocument->GetExternalRefManager()->insertRefCellFromTemplate( pPreviousCell, this );
SAL_INFO( "sc", "merged '" << aFormula << "' == '" << aShouldBe SAL_INFO( "sc", "merged '" << aFormula << "' == '" << aShouldBe
<< "'extend group to " << xGroup->mnLength ); << "'extend group to " << xGroup->mnLength );
......
...@@ -2043,6 +2043,15 @@ void ScExternalRefManager::refreshAllRefCells(sal_uInt16 nFileId) ...@@ -2043,6 +2043,15 @@ void ScExternalRefManager::refreshAllRefCells(sal_uInt16 nFileId)
pVShell->PaintGrid(); pVShell->PaintGrid();
} }
void ScExternalRefManager::insertRefCell(RefCellMap::iterator& itr, ScFormulaCell* pCell)
{
if (pCell)
{
itr->second.insert(pCell);
pCell->SetIsExtRef();
}
}
void ScExternalRefManager::insertRefCell(sal_uInt16 nFileId, const ScAddress& rCell) void ScExternalRefManager::insertRefCell(sal_uInt16 nFileId, const ScAddress& rCell)
{ {
RefCellMap::iterator itr = maRefCells.find(nFileId); RefCellMap::iterator itr = maRefCells.find(nFileId);
...@@ -2058,9 +2067,33 @@ void ScExternalRefManager::insertRefCell(sal_uInt16 nFileId, const ScAddress& rC ...@@ -2058,9 +2067,33 @@ void ScExternalRefManager::insertRefCell(sal_uInt16 nFileId, const ScAddress& rC
itr = r.first; itr = r.first;
} }
insertRefCell(itr, mpDoc->GetFormulaCell(rCell));
}
void ScExternalRefManager::insertRefCellFromTemplate( ScFormulaCell* pTemplateCell, ScFormulaCell* pCell )
{
if (!pTemplateCell || !pCell)
return;
for (RefCellMap::iterator itr = maRefCells.begin(); itr != maRefCells.end(); ++itr)
{
if (itr->second.find(pTemplateCell) != itr->second.end())
insertRefCell(itr, pCell);
}
}
bool ScExternalRefManager::hasCellExternalReference(const ScAddress& rCell)
{
ScFormulaCell* pCell = mpDoc->GetFormulaCell(rCell); ScFormulaCell* pCell = mpDoc->GetFormulaCell(rCell);
if (pCell) if (pCell)
itr->second.insert(pCell); for (RefCellMap::iterator itr = maRefCells.begin(); itr != maRefCells.end(); ++itr)
{
if (itr->second.find(pCell) != itr->second.end())
return true;
}
return false;
} }
void ScExternalRefManager::enableDocTimer( bool bEnable ) void ScExternalRefManager::enableDocTimer( bool bEnable )
......
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