add error to office:value-type for calc cells and fdo#51810
For cached value import we need the information which cells are error cells. For ODF 1.2 extended we therefore export now calcext:office-value with the additional value "error". Change-Id: I9bc988ea4924bea767ba5e504b77f6a16e51a82e
This commit is contained in:
parent
6bec369008
commit
a8b7c72425
@ -21,6 +21,7 @@
|
|||||||
#define XMLOFF_NUMEHELP_HXX
|
#define XMLOFF_NUMEHELP_HXX
|
||||||
|
|
||||||
#include "sal/config.h"
|
#include "sal/config.h"
|
||||||
|
#include "xmloff/xmlnmspe.hxx"
|
||||||
#include "xmloff/dllapi.h"
|
#include "xmloff/dllapi.h"
|
||||||
#include <sal/types.h>
|
#include <sal/types.h>
|
||||||
#include <com/sun/star/frame/XModel.hpp>
|
#include <com/sun/star/frame/XModel.hpp>
|
||||||
@ -59,7 +60,6 @@ class XMLOFF_DLLPUBLIC XMLNumberFormatAttributesExportHelper
|
|||||||
const OUString sEmpty;
|
const OUString sEmpty;
|
||||||
const OUString sStandardFormat;
|
const OUString sStandardFormat;
|
||||||
const OUString sType;
|
const OUString sType;
|
||||||
const OUString sAttrValueType;
|
|
||||||
const OUString sAttrValue;
|
const OUString sAttrValue;
|
||||||
const OUString sAttrDateValue;
|
const OUString sAttrDateValue;
|
||||||
const OUString sAttrTimeValue;
|
const OUString sAttrTimeValue;
|
||||||
@ -101,14 +101,15 @@ public :
|
|||||||
void WriteAttributes(const sal_Int16 nTypeKey,
|
void WriteAttributes(const sal_Int16 nTypeKey,
|
||||||
const double& rValue,
|
const double& rValue,
|
||||||
const OUString& rCurrencySymbol,
|
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,
|
void SetNumberFormatAttributes(const sal_Int32 nNumberFormat,
|
||||||
const double& rValue,
|
const double& rValue,
|
||||||
sal_Bool bExportValue = sal_True);
|
sal_Bool bExportValue = sal_True, sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE);
|
||||||
void SetNumberFormatAttributes(const OUString& rValue,
|
void SetNumberFormatAttributes(const OUString& rValue,
|
||||||
const OUString& rCharacters,
|
const OUString& rCharacters,
|
||||||
sal_Bool bExportValue = sal_True,
|
sal_Bool bExportValue = sal_True,
|
||||||
sal_Bool bExportTypeAttribute = sal_True);
|
sal_Bool bExportTypeAttribute = sal_True,
|
||||||
|
sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2884,6 +2884,9 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
|
|||||||
}
|
}
|
||||||
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
|
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
|
||||||
aCell.nNumberFormat, aCell.fValue);
|
aCell.nNumberFormat, aCell.fValue);
|
||||||
|
if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
|
||||||
|
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
|
||||||
|
aCell.nNumberFormat, aCell.fValue, false, XML_NAMESPACE_CALC_EXT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case table::CellContentType_TEXT :
|
case table::CellContentType_TEXT :
|
||||||
@ -2893,6 +2896,9 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
|
|||||||
OUString sFormula(lcl_GetRawString(pDoc, aCellPos));
|
OUString sFormula(lcl_GetRawString(pDoc, aCellPos));
|
||||||
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
|
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
|
||||||
sFormula, aCell.sStringValue, true, true);
|
sFormula, aCell.sStringValue, true, true);
|
||||||
|
if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
|
||||||
|
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
|
||||||
|
sFormula, aCell.sStringValue, false, true, XML_NAMESPACE_CALC_EXT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
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 ));
|
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;
|
bool bIsStandard;
|
||||||
OUString sCurrency;
|
OUString sCurrency;
|
||||||
@ -2927,15 +2944,31 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
|
|||||||
if (bIsStandard)
|
if (bIsStandard)
|
||||||
{
|
{
|
||||||
if (pDoc)
|
if (pDoc)
|
||||||
|
{
|
||||||
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
|
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
|
||||||
pFormulaCell->GetStandardFormat(*pDoc->GetFormatTable(), 0),
|
pFormulaCell->GetStandardFormat(*pDoc->GetFormatTable(), 0),
|
||||||
pDoc->GetValue( aCellPos ));
|
pDoc->GetValue( aCellPos ));
|
||||||
|
if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
|
||||||
|
{
|
||||||
|
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
|
||||||
|
pFormulaCell->GetStandardFormat(*pDoc->GetFormatTable(), 0),
|
||||||
|
pDoc->GetValue( aCellPos ), false, XML_NAMESPACE_CALC_EXT);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (pDoc)
|
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
|
else
|
||||||
@ -2945,6 +2978,10 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
|
|||||||
{
|
{
|
||||||
AddAttribute(sAttrValueType, XML_STRING);
|
AddAttribute(sAttrValueType, XML_STRING);
|
||||||
AddAttribute(sAttrStringValue, aCell.sStringValue);
|
AddAttribute(sAttrStringValue, aCell.sStringValue);
|
||||||
|
if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
|
||||||
|
{
|
||||||
|
AddAttribute(XML_NAMESPACE_CALC_EXT,XML_VALUE_TYPE, XML_STRING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,6 @@ XMLNumberFormatAttributesExportHelper::XMLNumberFormatAttributesExportHelper(
|
|||||||
pExport(&rTempExport),
|
pExport(&rTempExport),
|
||||||
sStandardFormat(XML_STANDARDFORMAT),
|
sStandardFormat(XML_STANDARDFORMAT),
|
||||||
sType(XML_TYPE),
|
sType(XML_TYPE),
|
||||||
sAttrValueType(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_VALUE_TYPE))),
|
|
||||||
sAttrValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_VALUE))),
|
sAttrValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_VALUE))),
|
||||||
sAttrDateValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_DATE_VALUE))),
|
sAttrDateValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_DATE_VALUE))),
|
||||||
sAttrTimeValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_TIME_VALUE))),
|
sAttrTimeValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_TIME_VALUE))),
|
||||||
@ -384,12 +383,13 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
|
|||||||
const sal_Int16 nTypeKey,
|
const sal_Int16 nTypeKey,
|
||||||
const double& rValue,
|
const double& rValue,
|
||||||
const OUString& rCurrency,
|
const OUString& rCurrency,
|
||||||
sal_Bool bExportValue)
|
sal_Bool bExportValue, sal_uInt16 nNamespace)
|
||||||
{
|
{
|
||||||
if (!pExport)
|
if (!pExport)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sal_Bool bWasSetTypeAttribute = sal_False;
|
sal_Bool bWasSetTypeAttribute = sal_False;
|
||||||
|
OUString sAttrValType = pExport->GetNamespaceMap().GetQNameByKey( nNamespace, GetXMLToken(XML_VALUE_TYPE));
|
||||||
switch(nTypeKey & ~util::NumberFormat::DEFINED)
|
switch(nTypeKey & ~util::NumberFormat::DEFINED)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -399,7 +399,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
|
|||||||
{
|
{
|
||||||
if (!bWasSetTypeAttribute)
|
if (!bWasSetTypeAttribute)
|
||||||
{
|
{
|
||||||
pExport->AddAttribute(sAttrValueType, XML_FLOAT);
|
pExport->AddAttribute(sAttrValType, XML_FLOAT);
|
||||||
bWasSetTypeAttribute = sal_True;
|
bWasSetTypeAttribute = sal_True;
|
||||||
}
|
}
|
||||||
} // No Break
|
} // No Break
|
||||||
@ -407,7 +407,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
|
|||||||
{
|
{
|
||||||
if (!bWasSetTypeAttribute)
|
if (!bWasSetTypeAttribute)
|
||||||
{
|
{
|
||||||
pExport->AddAttribute(sAttrValueType, XML_PERCENTAGE);
|
pExport->AddAttribute(sAttrValType, XML_PERCENTAGE);
|
||||||
bWasSetTypeAttribute = sal_True;
|
bWasSetTypeAttribute = sal_True;
|
||||||
}
|
}
|
||||||
} // No Break
|
} // No Break
|
||||||
@ -415,7 +415,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
|
|||||||
{
|
{
|
||||||
if (!bWasSetTypeAttribute)
|
if (!bWasSetTypeAttribute)
|
||||||
{
|
{
|
||||||
pExport->AddAttribute(sAttrValueType, XML_CURRENCY);
|
pExport->AddAttribute(sAttrValType, XML_CURRENCY);
|
||||||
if (!rCurrency.isEmpty())
|
if (!rCurrency.isEmpty())
|
||||||
pExport->AddAttribute(sAttrCurrency, rCurrency);
|
pExport->AddAttribute(sAttrCurrency, rCurrency);
|
||||||
bWasSetTypeAttribute = sal_True;
|
bWasSetTypeAttribute = sal_True;
|
||||||
@ -435,7 +435,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
|
|||||||
{
|
{
|
||||||
if (!bWasSetTypeAttribute)
|
if (!bWasSetTypeAttribute)
|
||||||
{
|
{
|
||||||
pExport->AddAttribute(sAttrValueType, XML_DATE);
|
pExport->AddAttribute(sAttrValType, XML_DATE);
|
||||||
bWasSetTypeAttribute = sal_True;
|
bWasSetTypeAttribute = sal_True;
|
||||||
}
|
}
|
||||||
if (bExportValue)
|
if (bExportValue)
|
||||||
@ -453,7 +453,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
|
|||||||
{
|
{
|
||||||
if (!bWasSetTypeAttribute)
|
if (!bWasSetTypeAttribute)
|
||||||
{
|
{
|
||||||
pExport->AddAttribute(sAttrValueType, XML_TIME);
|
pExport->AddAttribute(sAttrValType, XML_TIME);
|
||||||
bWasSetTypeAttribute = sal_True;
|
bWasSetTypeAttribute = sal_True;
|
||||||
}
|
}
|
||||||
if (bExportValue)
|
if (bExportValue)
|
||||||
@ -468,7 +468,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
|
|||||||
{
|
{
|
||||||
if (!bWasSetTypeAttribute)
|
if (!bWasSetTypeAttribute)
|
||||||
{
|
{
|
||||||
pExport->AddAttribute(sAttrValueType, XML_BOOLEAN);
|
pExport->AddAttribute(sAttrValType, XML_BOOLEAN);
|
||||||
bWasSetTypeAttribute = sal_True;
|
bWasSetTypeAttribute = sal_True;
|
||||||
}
|
}
|
||||||
if (bExportValue)
|
if (bExportValue)
|
||||||
@ -501,7 +501,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
|
|||||||
{
|
{
|
||||||
if (!bWasSetTypeAttribute)
|
if (!bWasSetTypeAttribute)
|
||||||
{
|
{
|
||||||
pExport->AddAttribute(sAttrValueType, XML_FLOAT);
|
pExport->AddAttribute(sAttrValType, XML_FLOAT);
|
||||||
bWasSetTypeAttribute = sal_True;
|
bWasSetTypeAttribute = sal_True;
|
||||||
if (bExportValue)
|
if (bExportValue)
|
||||||
{
|
{
|
||||||
@ -517,14 +517,14 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
|
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)
|
if (pExport)
|
||||||
{
|
{
|
||||||
bool bIsStandard;
|
bool bIsStandard;
|
||||||
OUString sCurrency;
|
OUString sCurrency;
|
||||||
sal_Int16 nTypeKey = GetCellType(nNumberFormat, sCurrency, bIsStandard);
|
sal_Int16 nTypeKey = GetCellType(nNumberFormat, sCurrency, bIsStandard);
|
||||||
WriteAttributes(nTypeKey, rValue, sCurrency, bExportValue);
|
WriteAttributes(nTypeKey, rValue, sCurrency, bExportValue, nNamespace);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
OSL_FAIL("no SvXMLExport given");
|
OSL_FAIL("no SvXMLExport given");
|
||||||
@ -533,12 +533,13 @@ void XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
|
|||||||
|
|
||||||
void XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
|
void XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
|
||||||
const OUString& rValue, const OUString& rCharacters,
|
const OUString& rValue, const OUString& rCharacters,
|
||||||
sal_Bool bExportValue, sal_Bool bExportTypeAttribute)
|
sal_Bool bExportValue, sal_Bool bExportTypeAttribute,
|
||||||
|
sal_uInt16 nNamespace)
|
||||||
{
|
{
|
||||||
if (pExport)
|
if (pExport)
|
||||||
{
|
{
|
||||||
if (bExportTypeAttribute)
|
if (bExportTypeAttribute)
|
||||||
pExport->AddAttribute(sAttrValueType, XML_STRING);
|
pExport->AddAttribute(nNamespace, XML_VALUE_TYPE, XML_STRING);
|
||||||
if (bExportValue && !rValue.isEmpty() && (rValue != rCharacters))
|
if (bExportValue && !rValue.isEmpty() && (rValue != rCharacters))
|
||||||
pExport->AddAttribute(sAttrStringValue, rValue);
|
pExport->AddAttribute(sAttrStringValue, rValue);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user