[Libreoffice-commits] core.git: 4 commits - sc/source
Eike Rathke
erack at redhat.com
Tue Dec 1 05:13:02 PST 2015
sc/source/core/data/formulacell.cxx | 66 +++++++++++++++++++++++++++++-------
1 file changed, 54 insertions(+), 12 deletions(-)
New commits:
commit d46203b55d92185ab2c1d3ac79761100d26aaee3
Author: Eike Rathke <erack at redhat.com>
Date: Tue Dec 1 14:09:02 2015 +0100
Resolves: tdf#95748 no group interpreter when calculations are running
Change-Id: I17283fc5e39da2d7222c302dd63522df69d0ad96
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index b37fbaa3..9079d56 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1551,15 +1551,24 @@ void ScFormulaCell::Interpret()
}
else
{
+ // Do not attempt to interpret a group when calculations are already
+ // running, otherwise we may run into a circular reference hell. See
+ // tdf#95748
+ if (rRecursionHelper.GetRecursionCount())
+ InterpretTail( SCITP_NORMAL);
+ else
+ {
#if DEBUG_CALCULATION
- aDC.enterGroup();
-#endif
- bool bGroupInterpreted = InterpretFormulaGroup();
-#if DEBUG_CALCULATION
- aDC.leaveGroup();
+ aDC.enterGroup();
+ bool bGroupInterpreted = InterpretFormulaGroup();
+ aDC.leaveGroup();
+ if (!bGroupInterpreted)
+ InterpretTail( SCITP_NORMAL);
+#else
+ if (!InterpretFormulaGroup())
+ InterpretTail( SCITP_NORMAL);
#endif
- if (!bGroupInterpreted)
- InterpretTail( SCITP_NORMAL);
+ }
}
// While leaving a recursion or iteration stack, insert its cells to the
commit 87ad1705746f8e6a15ae60037a1dd8a163eeecd7
Author: Eike Rathke <erack at redhat.com>
Date: Tue Dec 1 13:48:56 2015 +0100
add DebugCalculationEntry::mnGroup
Change-Id: Ic8b6c661be7570479c271d3ce0aa750e13724fc7
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 3963e6a..b37fbaa3 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -78,11 +78,13 @@ struct DebugCalculationEntry
ScAddress maPos;
OUString maResult;
const ScDocument* mpDoc;
+ sal_uInt32 mnGroup;
sal_uInt16 mnRecursion;
- DebugCalculationEntry( const ScAddress& rPos, ScDocument* pDoc ) :
+ DebugCalculationEntry( const ScAddress& rPos, ScDocument* pDoc, sal_uInt32 nGroup ) :
maPos(rPos),
mpDoc(pDoc),
+ mnGroup(nGroup),
mnRecursion(pDoc->GetRecursionHelper().GetRecursionCount())
{
}
@@ -99,12 +101,14 @@ static struct DebugCalculation
std::vector< DebugCalculationEntry > mvPos;
std::vector< DebugCalculationEntry > mvResults;
ScAddress maTrigger;
+ sal_uInt32 mnGroup;
bool mbActive;
bool mbSwitchOff;
bool mbPrint;
bool mbPrintResults;
- DebugCalculation() : mbActive(bDebugCalculationActive), mbSwitchOff(false), mbPrint(true), mbPrintResults(false) {}
+ DebugCalculation() : mnGroup(0), mbActive(bDebugCalculationActive), mbSwitchOff(false),
+ mbPrint(true), mbPrintResults(false) {}
/** Print chain in encountered dependency order. */
void print() const
@@ -112,7 +116,7 @@ static struct DebugCalculation
for (auto const& it : mvPos)
{
OUString aStr( it.maPos.Format( SCA_VALID | SCA_TAB_3D, it.mpDoc) +
- " [" + OUString::number( it.mnRecursion) + "]");
+ " [" + OUString::number( it.mnRecursion) + "," + OUString::number( it.mnGroup) + "]");
fprintf( stderr, "%s -> ", aStr.toUtf8().getStr());
}
fprintf( stderr, "%s", "END\n");
@@ -148,6 +152,16 @@ static struct DebugCalculation
mvPos.back().maResult = "Err:" + OUString::number( nErr);
}
+ void enterGroup()
+ {
+ ++mnGroup;
+ }
+
+ void leaveGroup()
+ {
+ --mnGroup;
+ }
+
} aDC;
struct DebugCalculationStacker
@@ -158,7 +172,7 @@ struct DebugCalculationStacker
aDC.mbActive = aDC.mbSwitchOff = true;
if (aDC.mbActive)
{
- aDC.mvPos.push_back( DebugCalculationEntry( rPos, pDoc));
+ aDC.mvPos.push_back( DebugCalculationEntry( rPos, pDoc, aDC.mnGroup));
aDC.mbPrint = true;
}
}
@@ -1537,7 +1551,14 @@ void ScFormulaCell::Interpret()
}
else
{
- if ( ! InterpretFormulaGroup() )
+#if DEBUG_CALCULATION
+ aDC.enterGroup();
+#endif
+ bool bGroupInterpreted = InterpretFormulaGroup();
+#if DEBUG_CALCULATION
+ aDC.leaveGroup();
+#endif
+ if (!bGroupInterpreted)
InterpretTail( SCITP_NORMAL);
}
commit 6d7b984ed17930bbfb884734ed83b98fb03ab06a
Author: Eike Rathke <erack at redhat.com>
Date: Tue Dec 1 12:50:09 2015 +0100
add DebugCalculationEntry::mnRecursion
Change-Id: I159cb1dcbe7a9678f7353292c3eab2fbc325d7f9
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 6adf106..3963e6a 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -70,17 +70,20 @@ IMPL_FIXEDMEMPOOL_NEWDEL( ScFormulaCell )
#define DEBUG_CALCULATION 0
#if DEBUG_CALCULATION
-static ScAddress aDebugCalculationTriggerAddress(1,2,0); // Sheet1.B3, whatever you like
+static bool bDebugCalculationActive = false; // Set to true for global active init,
+static ScAddress aDebugCalculationTriggerAddress(1,2,0); // or on cell Sheet1.B3, whatever you like
struct DebugCalculationEntry
{
ScAddress maPos;
OUString maResult;
const ScDocument* mpDoc;
+ sal_uInt16 mnRecursion;
- DebugCalculationEntry( const ScAddress& rPos, const ScDocument* pDoc ) :
+ DebugCalculationEntry( const ScAddress& rPos, ScDocument* pDoc ) :
maPos(rPos),
- mpDoc(pDoc)
+ mpDoc(pDoc),
+ mnRecursion(pDoc->GetRecursionHelper().GetRecursionCount())
{
}
};
@@ -101,14 +104,15 @@ static struct DebugCalculation
bool mbPrint;
bool mbPrintResults;
- DebugCalculation() : mbActive(false), mbSwitchOff(false), mbPrint(true), mbPrintResults(false) {}
+ DebugCalculation() : mbActive(bDebugCalculationActive), mbSwitchOff(false), mbPrint(true), mbPrintResults(false) {}
/** Print chain in encountered dependency order. */
void print() const
{
for (auto const& it : mvPos)
{
- OUString aStr( it.maPos.Format( SCA_VALID | SCA_TAB_3D, it.mpDoc));
+ OUString aStr( it.maPos.Format( SCA_VALID | SCA_TAB_3D, it.mpDoc) +
+ " [" + OUString::number( it.mnRecursion) + "]");
fprintf( stderr, "%s -> ", aStr.toUtf8().getStr());
}
fprintf( stderr, "%s", "END\n");
@@ -120,7 +124,7 @@ static struct DebugCalculation
for (auto const& it : mvResults)
{
OUString aStr( it.maPos.Format( SCA_VALID | SCA_TAB_3D, it.mpDoc));
- aStr += "(" + it.maResult + ")";
+ aStr += " (" + it.maResult + ")";
fprintf( stderr, "%s, ", aStr.toUtf8().getStr());
}
fprintf( stderr, "%s", "END\n");
@@ -148,7 +152,7 @@ static struct DebugCalculation
struct DebugCalculationStacker
{
- DebugCalculationStacker( const ScAddress& rPos, const ScDocument* pDoc )
+ DebugCalculationStacker( const ScAddress& rPos, ScDocument* pDoc )
{
if (!aDC.mbActive && rPos == aDC.maTrigger)
aDC.mbActive = aDC.mbSwitchOff = true;
commit 625a2f424004959254e618c60cff444e25444afe
Author: Eike Rathke <erack at redhat.com>
Date: Mon Nov 30 21:24:39 2015 +0100
add DebugCalculation::storeResultError()
Change-Id: I26ab76c5d53d606ddb141c9dadb534b4739a6c64
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 94250a1..6adf106 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -129,13 +129,19 @@ static struct DebugCalculation
void storeResult( const svl::SharedString& rStr )
{
if (mbActive && !mvPos.empty())
- mvPos.back().maResult = rStr.getString();
+ mvPos.back().maResult = "\"" + rStr.getString() + "\"";
}
void storeResult( const double& fVal )
{
if (mbActive && !mvPos.empty())
- storeResult( rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 2, '.', true));
+ mvPos.back().maResult = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 2, '.', true);
+ }
+
+ void storeResultError( const sal_uInt16& nErr )
+ {
+ if (mbActive && !mvPos.empty())
+ mvPos.back().maResult = "Err:" + OUString::number( nErr);
}
} aDC;
@@ -1714,7 +1720,9 @@ void ScFormulaCell::Interpret()
}
#if DEBUG_CALCULATION
- if (aResult.IsValue())
+ if (sal_uInt16 nErr = aResult.GetResultError())
+ aDC.storeResultError( nErr);
+ else if (aResult.IsValue())
aDC.storeResult( aResult.GetDouble());
else
aDC.storeResult( aResult.GetString());
More information about the Libreoffice-commits
mailing list