From 96336b01a8e2836a3cabe407a92ac5d7b5ac5bf7 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Tue, 9 Aug 2011 04:47:03 +0200 Subject: [PATCH] fix for fdo#37391: don't write invalid references to files --- sc/inc/rangenam.hxx | 2 +- sc/source/core/tool/rangenam.cxx | 2 +- sc/source/filter/xml/xmlexprt.cxx | 22 ++++++++++++++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx index 5d3ff4942e93..543d7276f18e 100644 --- a/sc/inc/rangenam.hxx +++ b/sc/inc/rangenam.hxx @@ -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; } diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx index 9b19fbfa02b2..c79457ac40e2 100644 --- a/sc/source/core/tool/rangenam.cxx +++ b/sc/source/core/tool/rangenam.cxx @@ -521,7 +521,7 @@ SCCOL ScRangeData::GetMaxCol() const } -sal_uInt16 ScRangeData::GetErrCode() +sal_uInt16 ScRangeData::GetErrCode() const { return pCode ? pCode->GetCodeError() : 0; } diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 5ef06cf6bd08..5737d28bc84d 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2856,7 +2856,15 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const ReferenceGetSymbol(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 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); } }