[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Fri Jul 26 07:33:50 PDT 2013
sc/source/filter/excel/xetable.cxx | 31 ++++++++++++++++---------------
sc/source/filter/inc/xetable.hxx | 2 +-
2 files changed, 17 insertions(+), 16 deletions(-)
New commits:
commit 02b610b53d697a2d5e15674fc79ceee5b7c75207
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Jul 26 10:31:50 2013 -0400
Fix exporting of array formulas to xls.
Change-Id: I366f5ef21353d64561d82b025c7919a1dbdb3422
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 8694a49..9ef8202 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -148,23 +148,24 @@ XclExpArrayRef XclExpArrayBuffer::CreateArray( const ScTokenArray& rScTokArr, co
return rxRec;
}
-XclExpArrayRef XclExpArrayBuffer::FindArray( const ScTokenArray& rScTokArr ) const
+XclExpArrayRef XclExpArrayBuffer::FindArray( const ScTokenArray& rScTokArr, const ScAddress& rBasePos ) const
{
XclExpArrayRef xRec;
// try to extract a matrix reference token
- if( rScTokArr.GetLen() == 1 )
- {
- const formula::FormulaToken* pToken = rScTokArr.GetArray()[ 0 ];
- if( pToken && (pToken->GetOpCode() == ocMatRef) )
- {
- const ScSingleRefData& rRef = static_cast<const ScToken*>(pToken)->GetSingleRef();
- ScAddress aBasePos( rRef.nCol, rRef.nRow, GetCurrScTab() );
- XclExpArrayMap::const_iterator aIt = maRecMap.find( aBasePos );
- if( aIt != maRecMap.end() )
- xRec = aIt->second;
- }
- }
- return xRec;
+ if (rScTokArr.GetLen() != 1)
+ // Must consist of a single reference token.
+ return xRec;
+
+ const formula::FormulaToken* pToken = rScTokArr.GetArray()[0];
+ if (!pToken || pToken->GetOpCode() != ocMatRef)
+ // not a matrix reference token.
+ return xRec;
+
+ const ScSingleRefData& rRef = static_cast<const ScToken*>(pToken)->GetSingleRef();
+ ScAddress aAbsPos = rRef.toAbs(rBasePos);
+ XclExpArrayMap::const_iterator it = maRecMap.find(aAbsPos);
+
+ return (it == maRecMap.end()) ? xRec : xRec = it->second;
}
// Shared formulas ============================================================
@@ -840,7 +841,7 @@ XclExpFormulaCell::XclExpFormulaCell(
case MM_REFERENCE:
{
// other formula cell covered by a matrix - find the ARRAY record
- mxAddRec = rArrayBfr.FindArray( rScTokArr );
+ mxAddRec = rArrayBfr.FindArray(rScTokArr, aScPos);
// should always be found, if Calc document is not broken
OSL_ENSURE( mxAddRec, "XclExpFormulaCell::XclExpFormulaCell - no matrix found" );
}
diff --git a/sc/source/filter/inc/xetable.hxx b/sc/source/filter/inc/xetable.hxx
index 655d6ea..533d2ec 100644
--- a/sc/source/filter/inc/xetable.hxx
+++ b/sc/source/filter/inc/xetable.hxx
@@ -135,7 +135,7 @@ public:
/** Inserts a new ARRAY record into the buffer and returns it. */
XclExpArrayRef CreateArray( const ScTokenArray& rScTokArr, const ScRange& rScRange );
/** Tries to find an ARRAY record that corresponds to an ocMatRef token. */
- XclExpArrayRef FindArray( const ScTokenArray& rScTokArr ) const;
+ XclExpArrayRef FindArray( const ScTokenArray& rScTokArr, const ScAddress& rBasePos ) const;
private:
typedef ::std::map< ScAddress, XclExpArrayRef > XclExpArrayMap;
More information about the Libreoffice-commits
mailing list