fdo#74747: Make use of cached string formula results.
Just like we do with cached numeric formula results. Change-Id: Ib8b311b540caeb47d8c2162a456f7490c5882ad5
This commit is contained in:
@@ -77,13 +77,19 @@ public:
|
|||||||
TokenRangeAddressItem( const TokenAddressItem& rTokenAndAddress, const ::com::sun::star::table::CellRangeAddress& rCellRangeAddress ) : maTokenAndAddress( rTokenAndAddress ), maCellRangeAddress( rCellRangeAddress ) {}
|
TokenRangeAddressItem( const TokenAddressItem& rTokenAndAddress, const ::com::sun::star::table::CellRangeAddress& rCellRangeAddress ) : maTokenAndAddress( rTokenAndAddress ), maCellRangeAddress( rCellRangeAddress ) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FormulaValue
|
||||||
|
{
|
||||||
|
com::sun::star::table::CellAddress maCellAddress;
|
||||||
|
OUString maValueStr;
|
||||||
|
sal_Int32 mnCellType;
|
||||||
|
};
|
||||||
typedef std::pair<com::sun::star::table::CellAddress, double> ValueAddressPair;
|
typedef std::pair<com::sun::star::table::CellAddress, double> ValueAddressPair;
|
||||||
|
|
||||||
struct SheetItem
|
struct SheetItem
|
||||||
{
|
{
|
||||||
std::vector<TokenAddressItem>* mpCellFormulas;
|
std::vector<TokenAddressItem>* mpCellFormulas;
|
||||||
std::vector<TokenRangeAddressItem>* mpArrayFormulas;
|
std::vector<TokenRangeAddressItem>* mpArrayFormulas;
|
||||||
std::vector<ValueAddressPair>* mpCellFormulaValues;
|
std::vector<FormulaValue>* mpCellFormulaValues;
|
||||||
std::vector<SharedFormulaEntry>* mpSharedFormulaEntries;
|
std::vector<SharedFormulaEntry>* mpSharedFormulaEntries;
|
||||||
std::vector<SharedFormulaDesc>* mpSharedFormulaIDs;
|
std::vector<SharedFormulaDesc>* mpSharedFormulaIDs;
|
||||||
|
|
||||||
@@ -98,7 +104,7 @@ private:
|
|||||||
typedef ::std::vector< std::vector<SharedFormulaDesc> > SheetToSharedFormulaid;
|
typedef ::std::vector< std::vector<SharedFormulaDesc> > SheetToSharedFormulaid;
|
||||||
// sheet -> stuff needed to create shared formulae
|
// sheet -> stuff needed to create shared formulae
|
||||||
typedef ::std::vector< std::vector<SharedFormulaEntry> > SheetToFormulaEntryArray;
|
typedef ::std::vector< std::vector<SharedFormulaEntry> > SheetToFormulaEntryArray;
|
||||||
typedef ::std::vector< std::vector<ValueAddressPair> > FormulaValueArray;
|
typedef ::std::vector< std::vector<FormulaValue> > FormulaValueArray;
|
||||||
|
|
||||||
osl::Mutex maMtxData;
|
osl::Mutex maMtxData;
|
||||||
FormulaDataArray maCellFormulas;
|
FormulaDataArray maCellFormulas;
|
||||||
@@ -118,8 +124,9 @@ public:
|
|||||||
const ::com::sun::star::table::CellAddress& rAddress, sal_Int32 nSharedId,
|
const ::com::sun::star::table::CellAddress& rAddress, sal_Int32 nSharedId,
|
||||||
const OUString& rCellValue, sal_Int32 nValueType );
|
const OUString& rCellValue, sal_Int32 nValueType );
|
||||||
|
|
||||||
void setCellFormulaValue( const ::css::table::CellAddress& rAddress,
|
void setCellFormulaValue(
|
||||||
double fValue );
|
const css::table::CellAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType );
|
||||||
|
|
||||||
void setCellArrayFormula( const ::css::table::CellRangeAddress& rRangeAddress,
|
void setCellArrayFormula( const ::css::table::CellRangeAddress& rRangeAddress,
|
||||||
const ::css::table::CellAddress& rTokenAddress,
|
const ::css::table::CellAddress& rTokenAddress,
|
||||||
const OUString& );
|
const OUString& );
|
||||||
|
@@ -325,8 +325,9 @@ public:
|
|||||||
const com::sun::star::table::CellRangeAddress& rRange,
|
const com::sun::star::table::CellRangeAddress& rRange,
|
||||||
sal_Int32 nSharedId, const OUString& rTokens );
|
sal_Int32 nSharedId, const OUString& rTokens );
|
||||||
|
|
||||||
void setCellFormulaValue( const ::com::sun::star::table::CellAddress& rAddress,
|
void setCellFormulaValue(
|
||||||
double fValue );
|
const css::table::CellAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WorksheetGlobals& mrSheetGlob;
|
WorksheetGlobals& mrSheetGlob;
|
||||||
};
|
};
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "externalrefmgr.hxx"
|
#include "externalrefmgr.hxx"
|
||||||
#include "tokenstringcontext.hxx"
|
#include "tokenstringcontext.hxx"
|
||||||
#include "oox/token/tokens.hxx"
|
#include "oox/token/tokens.hxx"
|
||||||
|
#include <svl/sharedstringpool.hxx>
|
||||||
|
|
||||||
using namespace com::sun::star;
|
using namespace com::sun::star;
|
||||||
using namespace ::com::sun::star::uno;
|
using namespace ::com::sun::star::uno;
|
||||||
@@ -256,19 +257,39 @@ void applyArrayFormulas(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void applyCellFormulaValues(
|
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)
|
for (; it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
ScAddress aCellPos;
|
ScAddress aCellPos;
|
||||||
ScUnoConversion::FillScAddress(aCellPos, it->first);
|
ScUnoConversion::FillScAddress(aCellPos, it->maCellAddress);
|
||||||
ScFormulaCell* pCell = rDoc.getDoc().GetFormulaCell(aCellPos);
|
ScFormulaCell* pCell = rDoc.getDoc().GetFormulaCell(aCellPos);
|
||||||
if (pCell)
|
const OUString& rValueStr = it->maValueStr;
|
||||||
|
if (!pCell)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch (it->mnCellType)
|
||||||
{
|
{
|
||||||
pCell->SetHybridDouble(it->second);
|
case XML_n:
|
||||||
pCell->ResetDirty();
|
{
|
||||||
pCell->SetChanged(false);
|
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 ) );
|
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() );
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
@@ -161,8 +161,8 @@ void SheetDataContext::onEndElement()
|
|||||||
|
|
||||||
// If a number cell has some preloaded value, stick it into the buffer
|
// If a number cell has some preloaded value, stick it into the buffer
|
||||||
// but do this only for real cell formulas (not array, shared etc.)
|
// but do this only for real cell formulas (not array, shared etc.)
|
||||||
if( !( maCellValue.isEmpty() ) && ( maCellData.mnCellType == XML_n ) )
|
if (!maCellValue.isEmpty())
|
||||||
setCellFormulaValue( maCellData.maCellAddr, maCellValue.toDouble() );
|
setCellFormulaValue(maCellData.maCellAddr, maCellValue, maCellData.mnCellType);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XML_shared:
|
case XML_shared:
|
||||||
|
@@ -1567,10 +1567,10 @@ void WorksheetHelper::putValue( const CellAddress& rAddress, double fValue )
|
|||||||
getDocImport().setNumericCell(aAddress, fValue);
|
getDocImport().setNumericCell(aAddress, fValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorksheetHelper::setCellFormulaValue( const ::com::sun::star::table::CellAddress& rAddress,
|
void WorksheetHelper::setCellFormulaValue(
|
||||||
double fValue )
|
const css::table::CellAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType )
|
||||||
{
|
{
|
||||||
getFormulaBuffer().setCellFormulaValue( rAddress, fValue );
|
getFormulaBuffer().setCellFormulaValue(rAddress, rValueStr, nCellType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorksheetHelper::putString( const CellAddress& rAddress, const OUString& rText )
|
void WorksheetHelper::putString( const CellAddress& rAddress, const OUString& rText )
|
||||||
|
Reference in New Issue
Block a user