summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-09-15 15:13:43 +0200
committerEike Rathke <erack@redhat.com>2015-09-15 15:36:19 +0200
commitf501fe4da88e1d64fcc88a492a52911113d28f6a (patch)
treea0379bff31eb18e5a9e3e6ed81ec15d43f7b82bc
parent00e0ce3f79bb90836402ca6285867b8e02d2497b (diff)
do not write MM_REFERENCE formulas to OOXML, tdf#61908 follow-up
The array range is covered by MM_FORMULA. Excel even complained when loading such a document. Change-Id: I10e1b19fbfb8ea849ffe3d46504fdf3389633c5f
-rw-r--r--sc/source/filter/excel/xetable.cxx113
1 files changed, 67 insertions, 46 deletions
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 9437d8cde5f4..c30334a9f98c 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -932,60 +932,81 @@ void XclExpFormulaCell::SaveXml( XclExpXmlStream& rStrm )
// OOXTODO: XML_cm, XML_vm, XML_ph
FSEND );
+ bool bWriteFormula = true;
bool bTagStarted = false;
- ScAddress aScPos( static_cast< SCCOL >( GetXclPos().mnCol ), static_cast< SCROW >( GetXclPos().mnRow ), rStrm.GetRoot().GetCurrScTab() );
+ ScAddress aScPos( static_cast< SCCOL >( GetXclPos().mnCol ),
+ static_cast< SCROW >( GetXclPos().mnRow ), rStrm.GetRoot().GetCurrScTab() );
- if ( mrScFmlaCell.GetMatrixFlag() == MM_FORMULA)
+ switch (mrScFmlaCell.GetMatrixFlag())
{
- // origin of the matrix - find the used matrix range
- SCCOL nMatWidth;
- SCROW nMatHeight;
- mrScFmlaCell.GetMatColsRows( nMatWidth, nMatHeight );
- OSL_ENSURE( nMatWidth && nMatHeight, "XclExpFormulaCell::XclExpFormulaCell - empty matrix" );
- ScRange aMatScRange( aScPos );
- ScAddress& rMatEnd = aMatScRange.aEnd;
- rMatEnd.IncCol( static_cast< SCsCOL >( nMatWidth - 1 ) );
- rMatEnd.IncRow( static_cast< SCsROW >( nMatHeight - 1 ) );
- // reduce to valid range (range keeps valid, because start position IS valid
- rStrm.GetRoot().GetAddressConverter().ValidateRange( aMatScRange, true );
-
- OStringBuffer sFmlaCellRange;
- if (ValidRange(aMatScRange))
- {
- // calculate the cell range.
- sFmlaCellRange.append(XclXmlUtils::ToOString( rStrm.GetRoot().GetStringBuf(), aMatScRange.aStart ).getStr());
- sFmlaCellRange.append(":");
- sFmlaCellRange.append(XclXmlUtils::ToOString( rStrm.GetRoot().GetStringBuf(), aMatScRange.aEnd ).getStr());
- }
+ case MM_NONE:
+ break;
+ case MM_REFERENCE:
+ bWriteFormula = false;
+ break;
+ case MM_FORMULA:
+ case MM_FAKE:
+ {
+ // origin of the matrix - find the used matrix range
+ SCCOL nMatWidth;
+ SCROW nMatHeight;
+ mrScFmlaCell.GetMatColsRows( nMatWidth, nMatHeight );
+ OSL_ENSURE( nMatWidth && nMatHeight, "XclExpFormulaCell::XclExpFormulaCell - empty matrix" );
+ ScRange aMatScRange( aScPos );
+ ScAddress& rMatEnd = aMatScRange.aEnd;
+ rMatEnd.IncCol( static_cast< SCsCOL >( nMatWidth - 1 ) );
+ rMatEnd.IncRow( static_cast< SCsROW >( nMatHeight - 1 ) );
+ // reduce to valid range (range keeps valid, because start position IS valid
+ rStrm.GetRoot().GetAddressConverter().ValidateRange( aMatScRange, true );
+
+ OStringBuffer sFmlaCellRange;
+ if (ValidRange(aMatScRange))
+ {
+ // calculate the cell range.
+ sFmlaCellRange.append( XclXmlUtils::ToOString(
+ rStrm.GetRoot().GetStringBuf(), aMatScRange.aStart ).getStr());
+ sFmlaCellRange.append(":");
+ sFmlaCellRange.append( XclXmlUtils::ToOString(
+ rStrm.GetRoot().GetStringBuf(), aMatScRange.aEnd ).getStr());
+ }
- if (aMatScRange.aStart.Col() == GetXclPos().mnCol && aMatScRange.aStart.Row() == static_cast<SCROW>(GetXclPos().mnRow))
+ if ( aMatScRange.aStart.Col() == GetXclPos().mnCol &&
+ aMatScRange.aStart.Row() == static_cast<SCROW>(GetXclPos().mnRow))
+ {
+ rWorksheet->startElement( XML_f,
+ XML_aca, XclXmlUtils::ToPsz( (mxTokArr && mxTokArr->IsVolatile()) ||
+ (mxAddRec && mxAddRec->IsVolatile())),
+ XML_t, mxAddRec ? "array" : NULL,
+ XML_ref, !sFmlaCellRange.isEmpty()? sFmlaCellRange.getStr() : NULL,
+ // OOXTODO: XML_dt2D, bool
+ // OOXTODO: XML_dtr, bool
+ // OOXTODO: XML_del1, bool
+ // OOXTODO: XML_del2, bool
+ // OOXTODO: XML_r1, ST_CellRef
+ // OOXTODO: XML_r2, ST_CellRef
+ // OOXTODO: XML_ca, bool
+ // OOXTODO: XML_si, uint
+ // OOXTODO: XML_bx bool
+ FSEND );
+ bTagStarted = true;
+ }
+ }
+ break;
+ }
+
+ if (bWriteFormula)
+ {
+ if (!bTagStarted)
{
rWorksheet->startElement( XML_f,
- XML_aca, XclXmlUtils::ToPsz( (mxTokArr && mxTokArr->IsVolatile()) || (mxAddRec && mxAddRec->IsVolatile()) ),
- XML_t, mxAddRec ? "array" : NULL,
- XML_ref, !sFmlaCellRange.isEmpty()? sFmlaCellRange.getStr() : NULL,
- // OOXTODO: XML_dt2D, bool
- // OOXTODO: XML_dtr, bool
- // OOXTODO: XML_del1, bool
- // OOXTODO: XML_del2, bool
- // OOXTODO: XML_r1, ST_CellRef
- // OOXTODO: XML_r2, ST_CellRef
- // OOXTODO: XML_ca, bool
- // OOXTODO: XML_si, uint
- // OOXTODO: XML_bx bool
- FSEND );
- bTagStarted = true;
+ XML_aca, XclXmlUtils::ToPsz( (mxTokArr && mxTokArr->IsVolatile()) ||
+ (mxAddRec && mxAddRec->IsVolatile()) ),
+ FSEND );
}
+ rWorksheet->writeEscaped( XclXmlUtils::ToOUString(
+ rStrm.GetRoot().GetCompileFormulaContext(), mrScFmlaCell.aPos, mrScFmlaCell.GetCode()));
+ rWorksheet->endElement( XML_f );
}
- if (!bTagStarted)
- {
- rWorksheet->startElement( XML_f,
- XML_aca, XclXmlUtils::ToPsz( (mxTokArr && mxTokArr->IsVolatile()) || (mxAddRec && mxAddRec->IsVolatile()) ),
- FSEND );
- }
- rWorksheet->writeEscaped( XclXmlUtils::ToOUString(
- rStrm.GetRoot().GetCompileFormulaContext(), mrScFmlaCell.aPos, mrScFmlaCell.GetCode()));
- rWorksheet->endElement( XML_f );
if( strcmp( sType, "inlineStr" ) == 0 )
{