summaryrefslogtreecommitdiff
path: root/sc/source/filter/oox/formulabuffer.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-03-10 17:03:52 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-03-10 17:28:54 -0400
commitaa5ad7b8096cd15a55c467b1a23d03849aeb870d (patch)
tree521e30badf69b02b18eee0ce77048bc2f5f26f7f /sc/source/filter/oox/formulabuffer.cxx
parent304e6144c66affd7adcea66f72fb5757eddfb12f (diff)
fdo#74747: Make use of cached string formula results.
Just like we do with cached numeric formula results. Change-Id: Ib8b311b540caeb47d8c2162a456f7490c5882ad5
Diffstat (limited to 'sc/source/filter/oox/formulabuffer.cxx')
-rw-r--r--sc/source/filter/oox/formulabuffer.cxx44
1 files changed, 35 insertions, 9 deletions
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index ca241a6b2113..e5a2874d5271 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -28,6 +28,7 @@
#include "externalrefmgr.hxx"
#include "tokenstringcontext.hxx"
#include "oox/token/tokens.hxx"
+#include <svl/sharedstringpool.hxx>
using namespace com::sun::star;
using namespace ::com::sun::star::uno;
@@ -256,19 +257,39 @@ void applyArrayFormulas(
}
void applyCellFormulaValues(
- ScDocumentImport& rDoc, const std::vector<FormulaBuffer::ValueAddressPair>& rVector )
+ ScDocumentImport& rDoc, const std::vector<FormulaBuffer::FormulaValue>& rVector )
{
- std::vector<FormulaBuffer::ValueAddressPair>::const_iterator it = rVector.begin(), itEnd = rVector.end();
+ svl::SharedStringPool& rStrPool = rDoc.getDoc().GetSharedStringPool();
+
+ std::vector<FormulaBuffer::FormulaValue>::const_iterator it = rVector.begin(), itEnd = rVector.end();
for (; it != itEnd; ++it)
{
ScAddress aCellPos;
- ScUnoConversion::FillScAddress(aCellPos, it->first);
+ ScUnoConversion::FillScAddress(aCellPos, it->maCellAddress);
ScFormulaCell* pCell = rDoc.getDoc().GetFormulaCell(aCellPos);
- if (pCell)
+ const OUString& rValueStr = it->maValueStr;
+ if (!pCell)
+ continue;
+
+ switch (it->mnCellType)
{
- pCell->SetHybridDouble(it->second);
- pCell->ResetDirty();
- pCell->SetChanged(false);
+ case XML_n:
+ {
+ pCell->SetResultDouble(rValueStr.toDouble());
+ pCell->ResetDirty();
+ pCell->SetChanged(false);
+ }
+ break;
+ case XML_str:
+ {
+ svl::SharedString aSS = rStrPool.intern(rValueStr);
+ pCell->SetResultToken(new formula::FormulaStringToken(aSS));
+ pCell->ResetDirty();
+ pCell->SetChanged(false);
+ }
+ break;
+ default:
+ ;
}
}
}
@@ -470,10 +491,15 @@ void FormulaBuffer::setCellArrayFormula( const ::com::sun::star::table::CellRang
maCellArrayFormulas[ rRangeAddress.Sheet ].push_back( TokenRangeAddressItem( tokenPair, rRangeAddress ) );
}
-void FormulaBuffer::setCellFormulaValue( const ::com::sun::star::table::CellAddress& rAddress, double fValue )
+void FormulaBuffer::setCellFormulaValue(
+ const css::table::CellAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType )
{
assert( rAddress.Sheet >= 0 && (size_t)rAddress.Sheet < maCellFormulaValues.size() );
- maCellFormulaValues[ rAddress.Sheet ].push_back( ValueAddressPair( rAddress, fValue ) );
+ FormulaValue aVal;
+ aVal.maCellAddress = rAddress;
+ aVal.maValueStr = rValueStr;
+ aVal.mnCellType = nCellType;
+ maCellFormulaValues[rAddress.Sheet].push_back(aVal);
}
}}