diff options
-rw-r--r-- | include/xmloff/numehelp.hxx | 9 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 43 | ||||
-rw-r--r-- | xmloff/source/style/numehelp.cxx | 27 |
3 files changed, 59 insertions, 20 deletions
diff --git a/include/xmloff/numehelp.hxx b/include/xmloff/numehelp.hxx index 9f0bac4f9e4b..7aa3922ebc72 100644 --- a/include/xmloff/numehelp.hxx +++ b/include/xmloff/numehelp.hxx @@ -21,6 +21,7 @@ #define XMLOFF_NUMEHELP_HXX #include "sal/config.h" +#include "xmloff/xmlnmspe.hxx" #include "xmloff/dllapi.h" #include <sal/types.h> #include <com/sun/star/frame/XModel.hpp> @@ -59,7 +60,6 @@ class XMLOFF_DLLPUBLIC XMLNumberFormatAttributesExportHelper const OUString sEmpty; const OUString sStandardFormat; const OUString sType; - const OUString sAttrValueType; const OUString sAttrValue; const OUString sAttrDateValue; const OUString sAttrTimeValue; @@ -101,14 +101,15 @@ public : void WriteAttributes(const sal_Int16 nTypeKey, const double& rValue, const OUString& rCurrencySymbol, - sal_Bool bExportValue = sal_True); + sal_Bool bExportValue = sal_True, sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE); void SetNumberFormatAttributes(const sal_Int32 nNumberFormat, const double& rValue, - sal_Bool bExportValue = sal_True); + sal_Bool bExportValue = sal_True, sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE); void SetNumberFormatAttributes(const OUString& rValue, const OUString& rCharacters, sal_Bool bExportValue = sal_True, - sal_Bool bExportTypeAttribute = sal_True); + sal_Bool bExportTypeAttribute = sal_True, + sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE); }; #endif diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 8b86e6086324..1e25b2831120 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2884,6 +2884,9 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount) } GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( aCell.nNumberFormat, aCell.fValue); + if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 ) + GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( + aCell.nNumberFormat, aCell.fValue, false, XML_NAMESPACE_CALC_EXT); } break; case table::CellContentType_TEXT : @@ -2893,6 +2896,9 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount) OUString sFormula(lcl_GetRawString(pDoc, aCellPos)); GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( sFormula, aCell.sStringValue, true, true); + if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 ) + GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( + sFormula, aCell.sStringValue, false, true, XML_NAMESPACE_CALC_EXT); } } break; @@ -2919,7 +2925,18 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount) AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sOUFormula.copy(1, sOUFormula.getLength() - 2), false )); } } - if (pFormulaCell->IsValue()) + if (pFormulaCell->GetErrCode()) + { + GetCellText(aCell, aCellPos); + AddAttribute(sAttrValueType, XML_STRING); + AddAttribute(sAttrStringValue, aCell.sStringValue); + if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 ) + { + //export calcext:value-type="error" + AddAttribute(XML_NAMESPACE_CALC_EXT,XML_VALUE_TYPE, OUString("error")); + } + } + else if (pFormulaCell->IsValue()) { bool bIsStandard; OUString sCurrency; @@ -2927,15 +2944,31 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount) if (bIsStandard) { if (pDoc) + { GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( pFormulaCell->GetStandardFormat(*pDoc->GetFormatTable(), 0), pDoc->GetValue( aCellPos )); + if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 ) + { + GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( + pFormulaCell->GetStandardFormat(*pDoc->GetFormatTable(), 0), + pDoc->GetValue( aCellPos ), false, XML_NAMESPACE_CALC_EXT); + } + } } else { if (pDoc) - GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( - aCell.nNumberFormat, pDoc->GetValue( aCellPos )); + { + GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( + aCell.nNumberFormat, pDoc->GetValue( aCellPos )); + if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 ) + { + GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( + aCell.nNumberFormat, pDoc->GetValue( aCellPos ), false, XML_NAMESPACE_CALC_EXT ); + + } + } } } else @@ -2945,6 +2978,10 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount) { AddAttribute(sAttrValueType, XML_STRING); AddAttribute(sAttrStringValue, aCell.sStringValue); + if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 ) + { + AddAttribute(XML_NAMESPACE_CALC_EXT,XML_VALUE_TYPE, XML_STRING); + } } } } diff --git a/xmloff/source/style/numehelp.cxx b/xmloff/source/style/numehelp.cxx index fcefcc690784..f510bd5eddf9 100644 --- a/xmloff/source/style/numehelp.cxx +++ b/xmloff/source/style/numehelp.cxx @@ -60,7 +60,6 @@ XMLNumberFormatAttributesExportHelper::XMLNumberFormatAttributesExportHelper( pExport(&rTempExport), sStandardFormat(XML_STANDARDFORMAT), sType(XML_TYPE), - sAttrValueType(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_VALUE_TYPE))), sAttrValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_VALUE))), sAttrDateValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_DATE_VALUE))), sAttrTimeValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_TIME_VALUE))), @@ -384,12 +383,13 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes( const sal_Int16 nTypeKey, const double& rValue, const OUString& rCurrency, - sal_Bool bExportValue) + sal_Bool bExportValue, sal_uInt16 nNamespace) { if (!pExport) return; sal_Bool bWasSetTypeAttribute = sal_False; + OUString sAttrValType = pExport->GetNamespaceMap().GetQNameByKey( nNamespace, GetXMLToken(XML_VALUE_TYPE)); switch(nTypeKey & ~util::NumberFormat::DEFINED) { case 0: @@ -399,7 +399,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes( { if (!bWasSetTypeAttribute) { - pExport->AddAttribute(sAttrValueType, XML_FLOAT); + pExport->AddAttribute(sAttrValType, XML_FLOAT); bWasSetTypeAttribute = sal_True; } } // No Break @@ -407,7 +407,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes( { if (!bWasSetTypeAttribute) { - pExport->AddAttribute(sAttrValueType, XML_PERCENTAGE); + pExport->AddAttribute(sAttrValType, XML_PERCENTAGE); bWasSetTypeAttribute = sal_True; } } // No Break @@ -415,7 +415,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes( { if (!bWasSetTypeAttribute) { - pExport->AddAttribute(sAttrValueType, XML_CURRENCY); + pExport->AddAttribute(sAttrValType, XML_CURRENCY); if (!rCurrency.isEmpty()) pExport->AddAttribute(sAttrCurrency, rCurrency); bWasSetTypeAttribute = sal_True; @@ -435,7 +435,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes( { if (!bWasSetTypeAttribute) { - pExport->AddAttribute(sAttrValueType, XML_DATE); + pExport->AddAttribute(sAttrValType, XML_DATE); bWasSetTypeAttribute = sal_True; } if (bExportValue) @@ -453,7 +453,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes( { if (!bWasSetTypeAttribute) { - pExport->AddAttribute(sAttrValueType, XML_TIME); + pExport->AddAttribute(sAttrValType, XML_TIME); bWasSetTypeAttribute = sal_True; } if (bExportValue) @@ -468,7 +468,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes( { if (!bWasSetTypeAttribute) { - pExport->AddAttribute(sAttrValueType, XML_BOOLEAN); + pExport->AddAttribute(sAttrValType, XML_BOOLEAN); bWasSetTypeAttribute = sal_True; } if (bExportValue) @@ -501,7 +501,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes( { if (!bWasSetTypeAttribute) { - pExport->AddAttribute(sAttrValueType, XML_FLOAT); + pExport->AddAttribute(sAttrValType, XML_FLOAT); bWasSetTypeAttribute = sal_True; if (bExportValue) { @@ -517,14 +517,14 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes( } void XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes( - const sal_Int32 nNumberFormat, const double& rValue, sal_Bool bExportValue) + const sal_Int32 nNumberFormat, const double& rValue, sal_Bool bExportValue, sal_uInt16 nNamespace) { if (pExport) { bool bIsStandard; OUString sCurrency; sal_Int16 nTypeKey = GetCellType(nNumberFormat, sCurrency, bIsStandard); - WriteAttributes(nTypeKey, rValue, sCurrency, bExportValue); + WriteAttributes(nTypeKey, rValue, sCurrency, bExportValue, nNamespace); } else { OSL_FAIL("no SvXMLExport given"); @@ -533,12 +533,13 @@ void XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes( void XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes( const OUString& rValue, const OUString& rCharacters, - sal_Bool bExportValue, sal_Bool bExportTypeAttribute) + sal_Bool bExportValue, sal_Bool bExportTypeAttribute, + sal_uInt16 nNamespace) { if (pExport) { if (bExportTypeAttribute) - pExport->AddAttribute(sAttrValueType, XML_STRING); + pExport->AddAttribute(nNamespace, XML_VALUE_TYPE, XML_STRING); if (bExportValue && !rValue.isEmpty() && (rValue != rCharacters)) pExport->AddAttribute(sAttrStringValue, rValue); } |