fix for fdo#37391: don't write invalid references to files

This commit is contained in:
Markus Mohrhard 2011-08-09 04:47:03 +02:00
parent 8b0e9caca9
commit 96336b01a8
3 changed files with 22 additions and 4 deletions

View file

@ -119,7 +119,7 @@ public:
sal_uInt16 GetIndex() const { return nIndex; }
ScTokenArray* GetCode() { return pCode; }
const ScTokenArray* GetCode() const { return pCode; }
sal_uInt16 GetErrCode();
sal_uInt16 GetErrCode() const;
sal_Bool HasReferences() const;
void SetDocument( ScDocument* pDocument){ pDoc = pDocument; }
ScDocument* GetDocument() const { return pDoc; }

View file

@ -521,7 +521,7 @@ SCCOL ScRangeData::GetMaxCol() const
}
sal_uInt16 ScRangeData::GetErrCode()
sal_uInt16 ScRangeData::GetErrCode() const
{
return pCode ? pCode->GetCodeError() : 0;
}

View file

@ -2856,7 +2856,15 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const Reference<sheet::XSpreadshe
AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, aStr);
// expression
itr->GetSymbol(aStr, pDoc->GetStorageGrammar());
ScRange aRan;
if (itr->GetErrCode() || itr->IsValidReference(aRan))
{
aStr = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("[#REF!]"));
}
else
{
itr->GetSymbol(aStr, pDoc->GetStorageGrammar());
}
AddAttribute(XML_NAMESPACE_TABLE, XML_EXPRESSION, aStr);
SvXMLElementExport aElemNR(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSION, sal_True, sal_True);
@ -3808,7 +3816,17 @@ void ScXMLExport::WriteNamedExpressions(const com::sun::star::uno::Reference <co
}
else
{
AddAttribute(XML_NAMESPACE_TABLE, XML_EXPRESSION, sOUTempContent);
ScRange aRange;
rtl::OUString aStr;
if (pNamedRange->GetErrCode() || !pNamedRange->IsValidReference(aRange))
{
aStr = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("[#REF!]"));
}
else
{
pNamedRange->GetSymbol(aStr, pDoc->GetStorageGrammar());
}
AddAttribute(XML_NAMESPACE_TABLE, XML_EXPRESSION, aStr);
SvXMLElementExport aElemNE(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSION, sal_True, sal_True);
}
}