summaryrefslogtreecommitdiff
path: root/sc/source/core/tool/formulalogger.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2016-11-09 21:00:02 -0500
committerKohei Yoshida <libreoffice@kohei.us>2016-11-10 12:17:12 +0000
commit6eb3d90aeb9438bd3249aaae32a445e81f278879 (patch)
treeff747e38ee794a2ee98aa5134e140536ce533b94 /sc/source/core/tool/formulalogger.cxx
parent50e9065cbbb2c62fa925cf5b561a85c715a0eb1e (diff)
Avoid writing to the log for the same group twice.
This can happen when the group calculation is disabled and falls back to non-group calculations. And we only care about the first entry in case of non-group calculation of grouped cells. Change-Id: I545980acf8e35b4d0504aa2a77f86bdc85799e29 Reviewed-on: https://gerrit.libreoffice.org/30738 Reviewed-by: Kohei Yoshida <libreoffice@kohei.us> Tested-by: Kohei Yoshida <libreoffice@kohei.us>
Diffstat (limited to 'sc/source/core/tool/formulalogger.cxx')
-rw-r--r--sc/source/core/tool/formulalogger.cxx73
1 files changed, 43 insertions, 30 deletions
diff --git a/sc/source/core/tool/formulalogger.cxx b/sc/source/core/tool/formulalogger.cxx
index a9480aa52e05..036be66a0239 100644
--- a/sc/source/core/tool/formulalogger.cxx
+++ b/sc/source/core/tool/formulalogger.cxx
@@ -64,56 +64,66 @@ struct FormulaLogger::GroupScope::Impl
OUString maPrefix;
std::vector<OUString> maMessages;
- bool mbCalcComplete = false;
+ bool mbCalcComplete;
+ bool mbOutputEnabled;
- Impl( FormulaLogger& rLogger, const OUString& rPrefix, const ScDocument& rDoc, const ScFormulaCell& rCell ) :
- mrLogger(rLogger), mrDoc(rDoc), maPrefix(rPrefix)
+ Impl( FormulaLogger& rLogger, const OUString& rPrefix, const ScDocument& rDoc,
+ const ScFormulaCell& rCell, bool bOutputEnabled ) :
+ mrLogger(rLogger), mrDoc(rDoc), maPrefix(rPrefix),
+ mbCalcComplete(false), mbOutputEnabled(bOutputEnabled)
{
++mrLogger.mnNestLevel;
- sc::TokenStringContext aCxt(&rDoc, rDoc.GetGrammar());
- OUString aFormula = rCell.GetCode()->CreateString(aCxt, rCell.aPos);
+ if (mbOutputEnabled)
+ {
+ sc::TokenStringContext aCxt(&rDoc, rDoc.GetGrammar());
+ OUString aFormula = rCell.GetCode()->CreateString(aCxt, rCell.aPos);
- mrLogger.write(maPrefix);
- mrLogger.writeNestLevel();
+ mrLogger.write(maPrefix);
+ mrLogger.writeNestLevel();
- mrLogger.writeAscii("-- enter (formula='");
- mrLogger.write(aFormula);
- mrLogger.writeAscii("', size=");
- mrLogger.write(rCell.GetSharedLength());
- mrLogger.writeAscii(")\n");
+ mrLogger.writeAscii("-- enter (formula='");
+ mrLogger.write(aFormula);
+ mrLogger.writeAscii("', size=");
+ mrLogger.write(rCell.GetSharedLength());
+ mrLogger.writeAscii(")\n");
+ }
}
~Impl()
{
- for (const OUString& rMsg : maMessages)
+ if (mbOutputEnabled)
{
+ for (const OUString& rMsg : maMessages)
+ {
+ mrLogger.write(maPrefix);
+ mrLogger.writeNestLevel();
+ mrLogger.writeAscii(" * ");
+ mrLogger.write(rMsg);
+ mrLogger.writeAscii("\n");
+ }
+
mrLogger.write(maPrefix);
mrLogger.writeNestLevel();
- mrLogger.writeAscii(" * ");
- mrLogger.write(rMsg);
- mrLogger.writeAscii("\n");
- }
-
- mrLogger.write(maPrefix);
- mrLogger.writeNestLevel();
- mrLogger.writeAscii("-- exit (");
- if (mbCalcComplete)
- mrLogger.writeAscii("calculation complete");
- else
- mrLogger.writeAscii("without calculation");
+ mrLogger.writeAscii("-- exit (");
+ if (mbCalcComplete)
+ mrLogger.writeAscii("calculation complete");
+ else
+ mrLogger.writeAscii("without calculation");
- mrLogger.writeAscii(")\n");
+ mrLogger.writeAscii(")\n");
- mrLogger.sync();
+ mrLogger.sync();
+ }
--mrLogger.mnNestLevel;
}
};
FormulaLogger::GroupScope::GroupScope(
- FormulaLogger& rLogger, const OUString& rPrefix, const ScDocument& rDoc, const ScFormulaCell& rCell ) :
- mpImpl(o3tl::make_unique<Impl>(rLogger, rPrefix, rDoc, rCell)) {}
+ FormulaLogger& rLogger, const OUString& rPrefix, const ScDocument& rDoc,
+ const ScFormulaCell& rCell, bool bOutputEnabled ) :
+ mpImpl(o3tl::make_unique<Impl>(rLogger, rPrefix, rDoc, rCell, bOutputEnabled)) {}
FormulaLogger::GroupScope::GroupScope( GroupScope&& r ) : mpImpl(std::move(r.mpImpl)) {}
@@ -327,7 +337,10 @@ FormulaLogger::GroupScope FormulaLogger::enterGroup(
aGroupPrefix += rCell.aPos.Format(ScRefFlags::VALID | ScRefFlags::TAB_3D, &rDoc, rDoc.GetAddressConvention());
aGroupPrefix += ": ";
- return GroupScope(*this, aGroupPrefix, rDoc, rCell);
+ bool bOutputEnabled = mpLastGroup != rCell.GetCellGroup().get();
+ mpLastGroup = rCell.GetCellGroup().get();
+
+ return GroupScope(*this, aGroupPrefix, rDoc, rCell, bOutputEnabled);
}
}