[Libreoffice-commits] core.git: 7 commits - include/xmloff sc/inc sc/source xmloff/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Thu Apr 25 08:04:03 PDT 2013
include/xmloff/numehelp.hxx | 9 +
sc/inc/document.hxx | 18 +--
sc/source/filter/xml/xmlcelli.cxx | 29 +++++-
sc/source/filter/xml/xmlcelli.hxx | 2
sc/source/filter/xml/xmlexprt.cxx | 179 +++++++++++++++++++++-----------------
sc/source/filter/xml/xmlexprt.hxx | 2
sc/source/filter/xml/xmlimprt.cxx | 31 +++---
sc/source/filter/xml/xmlimprt.hxx | 1
sc/source/filter/xml/xmlsubti.cxx | 2
xmloff/source/style/numehelp.cxx | 27 ++---
10 files changed, 178 insertions(+), 122 deletions(-)
New commits:
commit 53f7f39818e22ca1bf049c2e3fea845ac49e5bfc
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Apr 25 16:58:36 2013 +0200
prevent unnecessary String->OUString conversions
Change-Id: I075467d17f6c59bd66a7a2d8e1e82f2a3ba42cad
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index 1228827..a92abe7 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -290,7 +290,7 @@ void ScMyTables::AddMatrixRange(
pDoc->InsertMatrixFormula(
aScRange.aStart.Col(), aScRange.aStart.Row(),
aScRange.aEnd.Col(), aScRange.aEnd.Row(),
- aMark, EMPTY_STRING, pCode, eGrammar, false );
+ aMark, EMPTY_OUSTRING, pCode, eGrammar, false );
delete pCode;
pDoc->IncXMLImportedFormulaCount( rFormula.getLength() );
}
commit bb369fd9b7f38eed85eb925432b337414864c2d0
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Apr 24 23:16:37 2013 +0200
remove some unnecessary whitespace in document.hxx
Change-Id: Iab19ae876162e72104267ad5f760f55e7d854934
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index afdd493..71dfb2c 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -781,9 +781,9 @@ public:
void SetEmptyCell( const ScAddress& rPos );
- SC_DLLPUBLIC void SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal );
+ SC_DLLPUBLIC void SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal );
SC_DLLPUBLIC void SetValue( const ScAddress& rPos, double fVal );
- void SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const sal_uInt16 nError);
+ void SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const sal_uInt16 nError);
SC_DLLPUBLIC void SetFormula(
const ScAddress& rPos, const ScTokenArray& rArray,
@@ -795,14 +795,14 @@ public:
SC_DLLPUBLIC void SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell );
- SC_DLLPUBLIC void InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
+ SC_DLLPUBLIC void InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
SCCOL nCol2, SCROW nRow2,
const ScMarkData& rMark,
const OUString& rFormula,
const ScTokenArray* p = NULL,
const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT,
bool bDirtyFlag=true );
- SC_DLLPUBLIC void InsertTableOp(const ScTabOpParam& rParam, // multi-operation
+ SC_DLLPUBLIC void InsertTableOp(const ScTabOpParam& rParam, // multi-operation
SCCOL nCol1, SCROW nRow1,
SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark);
@@ -830,19 +830,19 @@ public:
*/
double* GetValueCell( const ScAddress& rPos );
- SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rString );
- SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString );
- sal_uInt16 GetStringForFormula( const ScAddress& rPos, OUString& rString );
+ SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rString );
+ SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString );
+ sal_uInt16 GetStringForFormula( const ScAddress& rPos, OUString& rString );
SC_DLLPUBLIC double GetValue( const ScAddress& rPos ) const;
SC_DLLPUBLIC double GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab ) const { ScAddress aAdr(nCol, nRow, nTab); return GetValue(aAdr);}
SC_DLLPUBLIC void GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, double& rValue ) const;
SC_DLLPUBLIC const EditTextObject* GetEditText( const ScAddress& rPos ) const;
void RemoveEditTextCharAttribs( const ScAddress& rPos, const ScPatternAttr& rAttr );
SC_DLLPUBLIC double RoundValueAsShown( double fVal, sal_uInt32 nFormat ) const;
- SC_DLLPUBLIC void GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB nTab,
+ SC_DLLPUBLIC void GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB nTab,
sal_uInt32& rFormat ) const;
sal_uInt32 GetNumberFormat( const ScRange& rRange ) const;
- SC_DLLPUBLIC sal_uInt32 GetNumberFormat( const ScAddress& ) const;
+ SC_DLLPUBLIC sal_uInt32 GetNumberFormat( const ScAddress& ) const;
void SetNumberFormat( const ScAddress& rPos, sal_uInt32 nNumberFormat );
/**
commit 9fb60c6a7390f782f1878f0e943ba17fd419ebab
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Apr 24 22:56:05 2013 +0200
implement import for calcext:value-type
This saves us several string comparisons for every cell during import
which should speed-up our cached value import quite a bit. I haven't
profiled it yet. Additionally it lets us move away from a heuristic
based approach.
Change-Id: Id9ca92a1251b62e99ca54209fdd52031694784b1
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index b97a245..556f27b 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -149,6 +149,8 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
bIsMatrix(false),
bIsCovered(bTempIsCovered),
bIsEmpty(true),
+ mbNewValueType(false),
+ mbErrorValue(false),
bIsFirstTextImport(false),
bSolarMutexLocked(false),
bFormulaTextResult(false),
@@ -207,6 +209,14 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
nCellType = GetScImport().GetCellType(sValue);
bIsEmpty = false;
break;
+ case XML_TOK_TABLE_ROW_CELL_ATTR_NEW_VALUE_TYPE:
+ if(sValue == "error")
+ mbErrorValue = true;
+ else
+ nCellType = GetScImport().GetCellType(sValue);
+ bIsEmpty = false;
+ mbNewValueType = true;
+ break;
case XML_TOK_TABLE_ROW_CELL_ATTR_VALUE:
{
if (!sValue.isEmpty())
@@ -968,7 +978,12 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const
{
if(pFCell)
{
- if( bFormulaTextResult && maStringValue )
+ if(mbErrorValue)
+ {
+ // don't do anything here
+ // we need to recalc anyway
+ }
+ else if( bFormulaTextResult && maStringValue )
{
if( !IsPossibleErrorString() )
{
@@ -1010,6 +1025,9 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
else
bDoIncrement = false;
+ if(mbErrorValue)
+ bDoIncrement = false;
+
if(!aCellString.isEmpty())
{
if (bDoIncrement && !IsPossibleErrorString())
@@ -1422,9 +1440,10 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
// - is blank
// - has a constant error value beginning with "#" (such as "#VALUE!" or "#N/A")
// - has an "Err:[###]" (where "[###]" is an error number)
+// Libreoffice 4.1+ with ODF1.2 extended write however calcext:value-type="error" in that case
void ScXMLTableRowCellContext::HasSpecialCaseFormulaText()
{
- if (!mbEditEngineHasText)
+ if (!mbEditEngineHasText || mbNewValueType)
return;
OUString aStr = mpEditEngine->GetText(0);
@@ -1436,7 +1455,11 @@ void ScXMLTableRowCellContext::HasSpecialCaseFormulaText()
bool ScXMLTableRowCellContext::IsPossibleErrorString() const
{
- return mbPossibleErrorCell || ( mbCheckWithCompilerForError && GetScImport().IsFormulaErrorConstant(*maStringValue) );
+ if(mbNewValueType && !mbErrorValue)
+ return false;
+ else if(mbNewValueType && mbErrorValue)
+ return true;
+ return mbPossibleErrorCell || ( mbCheckWithCompilerForError && GetScImport().IsFormulaErrorConstant(*maStringValue) );
}
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index 7555a46..6874e5e 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -84,6 +84,8 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
bool bIsMatrix;
bool bIsCovered;
bool bIsEmpty;
+ bool mbNewValueType;
+ bool mbErrorValue;
bool bIsFirstTextImport;
bool bSolarMutexLocked;
bool bFormulaTextResult;
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 315695b..c7ec58c 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -210,6 +210,7 @@ const SvXMLTokenMap& ScXMLImport::GetTableRowCellAttrTokenMap()
{ XML_NAMESPACE_TABLE, XML_NUMBER_MATRIX_ROWS_SPANNED, XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_ROWS },
{ XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, XML_TOK_TABLE_ROW_CELL_ATTR_REPEATED },
{ XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_TOK_TABLE_ROW_CELL_ATTR_VALUE_TYPE },
+ { XML_NAMESPACE_CALC_EXT, XML_VALUE_TYPE, XML_TOK_TABLE_ROW_CELL_ATTR_NEW_VALUE_TYPE },
{ XML_NAMESPACE_OFFICE, XML_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_VALUE },
{ XML_NAMESPACE_OFFICE, XML_DATE_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_DATE_VALUE },
{ XML_NAMESPACE_OFFICE, XML_TIME_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_TIME_VALUE },
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 0e63909..aa85f7e 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -339,6 +339,7 @@ enum ScXMLTableRowCellAttrTokens
XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_ROWS,
XML_TOK_TABLE_ROW_CELL_ATTR_REPEATED,
XML_TOK_TABLE_ROW_CELL_ATTR_VALUE_TYPE,
+ XML_TOK_TABLE_ROW_CELL_ATTR_NEW_VALUE_TYPE,
XML_TOK_TABLE_ROW_CELL_ATTR_VALUE,
XML_TOK_TABLE_ROW_CELL_ATTR_DATE_VALUE,
XML_TOK_TABLE_ROW_CELL_ATTR_TIME_VALUE,
commit d691181f9ead97bba8970759255ba64f6c26aee6
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Apr 24 19:01:36 2013 +0200
remove a bit of unnecessary whitespace to make lines shorter
Change-Id: I364afb6d638f47a41ea31bf3df00540db417d505
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index efccaee..315695b 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -202,21 +202,21 @@ const SvXMLTokenMap& ScXMLImport::GetTableRowCellAttrTokenMap()
{
static SvXMLTokenMapEntry aTableRowCellAttrTokenMap[] =
{
- { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_ROW_CELL_ATTR_STYLE_NAME },
- { XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION_NAME, XML_TOK_TABLE_ROW_CELL_ATTR_CONTENT_VALIDATION_NAME },
- { XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_ROWS },
- { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED, XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_COLS },
- { XML_NAMESPACE_TABLE, XML_NUMBER_MATRIX_COLUMNS_SPANNED, XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_COLS },
- { XML_NAMESPACE_TABLE, XML_NUMBER_MATRIX_ROWS_SPANNED, XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_ROWS },
- { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, XML_TOK_TABLE_ROW_CELL_ATTR_REPEATED },
- { XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_TOK_TABLE_ROW_CELL_ATTR_VALUE_TYPE },
- { XML_NAMESPACE_OFFICE, XML_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_VALUE },
- { XML_NAMESPACE_OFFICE, XML_DATE_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_DATE_VALUE },
- { XML_NAMESPACE_OFFICE, XML_TIME_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_TIME_VALUE },
- { XML_NAMESPACE_OFFICE, XML_STRING_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_STRING_VALUE },
- { XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_BOOLEAN_VALUE },
- { XML_NAMESPACE_TABLE, XML_FORMULA, XML_TOK_TABLE_ROW_CELL_ATTR_FORMULA },
- { XML_NAMESPACE_OFFICE, XML_CURRENCY, XML_TOK_TABLE_ROW_CELL_ATTR_CURRENCY },
+ { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_ROW_CELL_ATTR_STYLE_NAME },
+ { XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION_NAME, XML_TOK_TABLE_ROW_CELL_ATTR_CONTENT_VALIDATION_NAME },
+ { XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_ROWS },
+ { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED, XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_COLS },
+ { XML_NAMESPACE_TABLE, XML_NUMBER_MATRIX_COLUMNS_SPANNED, XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_COLS },
+ { XML_NAMESPACE_TABLE, XML_NUMBER_MATRIX_ROWS_SPANNED, XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_ROWS },
+ { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, XML_TOK_TABLE_ROW_CELL_ATTR_REPEATED },
+ { XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_TOK_TABLE_ROW_CELL_ATTR_VALUE_TYPE },
+ { XML_NAMESPACE_OFFICE, XML_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_VALUE },
+ { XML_NAMESPACE_OFFICE, XML_DATE_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_DATE_VALUE },
+ { XML_NAMESPACE_OFFICE, XML_TIME_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_TIME_VALUE },
+ { XML_NAMESPACE_OFFICE, XML_STRING_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_STRING_VALUE },
+ { XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, XML_TOK_TABLE_ROW_CELL_ATTR_BOOLEAN_VALUE },
+ { XML_NAMESPACE_TABLE, XML_FORMULA, XML_TOK_TABLE_ROW_CELL_ATTR_FORMULA },
+ { XML_NAMESPACE_OFFICE, XML_CURRENCY, XML_TOK_TABLE_ROW_CELL_ATTR_CURRENCY },
XML_TOKEN_MAP_END
};
commit a0ba44951c54f2331f8ce25c24d8f59fb8d2a6d5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Apr 24 18:53:54 2013 +0200
ScXMLExport::GetCellText returned always true
Change-Id: Ia5dbea0a496f578f619276def349ff21674fb644
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 1e25b28..8a059e5 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2635,15 +2635,12 @@ bool ScXMLExport::IsMatrix (const ScAddress& aCell,
return false;
}
-bool ScXMLExport::GetCellText (ScMyCell& rMyCell, const ScAddress& aPos) const
+void ScXMLExport::GetCellText (ScMyCell& rMyCell, const ScAddress& aPos) const
{
- if (rMyCell.bHasStringValue)
- return true;
- else
+ if (!rMyCell.bHasStringValue)
{
- rMyCell.sStringValue = ScCellObj::GetOutputString_Impl(pDoc, aPos);
- rMyCell.bHasStringValue = true;
- return true;
+ rMyCell.sStringValue = ScCellObj::GetOutputString_Impl(pDoc, aPos);
+ rMyCell.bHasStringValue = true;
}
}
@@ -2891,15 +2888,13 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
break;
case table::CellContentType_TEXT :
{
- if (GetCellText(aCell, aCellPos))
- {
- OUString sFormula(lcl_GetRawString(pDoc, aCellPos));
- GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
+ GetCellText(aCell, aCellPos);
+ 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);
- }
+ if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
+ GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
+ sFormula, aCell.sStringValue, false, true, XML_NAMESPACE_CALC_EXT);
}
break;
case table::CellContentType_FORMULA :
@@ -2973,16 +2968,16 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
}
else
{
- if (GetCellText(aCell, aCellPos))
- if (!aCell.sStringValue.isEmpty())
+ GetCellText(aCell, aCellPos);
+ if (!aCell.sStringValue.isEmpty())
+ {
+ AddAttribute(sAttrValueType, XML_STRING);
+ AddAttribute(sAttrStringValue, aCell.sStringValue);
+ if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
{
- AddAttribute(sAttrValueType, XML_STRING);
- AddAttribute(sAttrStringValue, aCell.sStringValue);
- if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
- {
- AddAttribute(XML_NAMESPACE_CALC_EXT,XML_VALUE_TYPE, XML_STRING);
- }
+ AddAttribute(XML_NAMESPACE_CALC_EXT,XML_VALUE_TYPE, XML_STRING);
}
+ }
}
}
}
@@ -3031,8 +3026,8 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
{
SvXMLElementExport aElemP(*this, sElemP, true, false);
bool bPrevCharWasSpace(true);
- if (GetCellText(aCell, aCellPos))
- GetTextParagraphExport()->exportText(aCell.sStringValue, bPrevCharWasSpace);
+ GetCellText(aCell, aCellPos);
+ GetTextParagraphExport()->exportText(aCell.sStringValue, bPrevCharWasSpace);
}
}
WriteShapes(aCell);
@@ -3507,13 +3502,10 @@ bool ScXMLExport::IsCellEqual (ScMyCell& aCell1, ScMyCell& aCell2)
bIsEqual = false;
else
{
- if (GetCellText(aCell1, aCellPos1) && GetCellText(aCell2, aCellPos2))
- {
- bIsEqual = (aCell1.sStringValue == aCell2.sStringValue) &&
- (lcl_GetRawString(pDoc, aCellPos1) == lcl_GetRawString(pDoc, aCellPos2));
- }
- else
- bIsEqual = false;
+ GetCellText(aCell1, aCellPos1);
+ GetCellText(aCell2, aCellPos2);
+ bIsEqual = (aCell1.sStringValue == aCell2.sStringValue) &&
+ (lcl_GetRawString(pDoc, aCellPos1) == lcl_GetRawString(pDoc, aCellPos2));
}
}
break;
diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx
index 6cd196c..b3bfdb1 100644
--- a/sc/source/filter/xml/xmlexprt.hxx
+++ b/sc/source/filter/xml/xmlexprt.hxx
@@ -170,7 +170,7 @@ class ScXMLExport : public SvXMLExport
bool GetMerged (const com::sun::star::table::CellRangeAddress* pCellRange,
const com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheet>& xTable);
- bool GetCellText (ScMyCell& rMyCell, const ScAddress& aPos) const;
+ void GetCellText (ScMyCell& rMyCell, const ScAddress& aPos) const;
void WriteTable(sal_Int32 nTable, const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet>& xTable);
void WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount);
commit a8b7c72425aabae87bfd2e141aa06f06319ae11c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Apr 24 18:45:15 2013 +0200
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
diff --git a/include/xmloff/numehelp.hxx b/include/xmloff/numehelp.hxx
index 9f0bac4..7aa3922 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 8b86e60..1e25b28 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 fcefcc6..f510bd5 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);
}
commit 6bec369008596f74dfa49721f52d16a684fc4581
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Apr 24 15:19:35 2013 +0200
fix indentation
Change-Id: Ie70d580cd2a4ad88751672fd257c825b9813c86e
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 2248f90..8b86e60 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2870,90 +2870,88 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
bool bIsEmpty(false);
switch (aCell.nType)
{
- case table::CellContentType_EMPTY :
- {
- bIsEmpty = true;
- }
- break;
- case table::CellContentType_VALUE :
- {
- if (!aCell.bHasDoubleValue)
+ case table::CellContentType_EMPTY :
{
- aCell.fValue = pDoc->GetValue( aCellPos );
- aCell.bHasDoubleValue = true;
+ bIsEmpty = true;
}
- GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
- aCell.nNumberFormat, aCell.fValue);
- }
- break;
- case table::CellContentType_TEXT :
- {
- if (GetCellText(aCell, aCellPos))
+ break;
+ case table::CellContentType_VALUE :
{
- OUString sFormula(lcl_GetRawString(pDoc, aCellPos));
+ if (!aCell.bHasDoubleValue)
+ {
+ aCell.fValue = pDoc->GetValue( aCellPos );
+ aCell.bHasDoubleValue = true;
+ }
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
- sFormula, aCell.sStringValue, true, true);
+ aCell.nNumberFormat, aCell.fValue);
}
- }
- break;
- case table::CellContentType_FORMULA :
- {
- ScRefCellValue aCellVal;
- aCellVal.assign(*pDoc, aCellPos);
- if (aCellVal.meType == CELLTYPE_FORMULA)
+ break;
+ case table::CellContentType_TEXT :
{
- OUStringBuffer sFormula;
- ScFormulaCell* pFormulaCell = aCellVal.mpFormula;
- if (!bIsMatrix || (bIsMatrix && bIsFirstMatrixCell))
+ if (GetCellText(aCell, aCellPos))
{
- const formula::FormulaGrammar::Grammar eGrammar = pDoc->GetStorageGrammar();
- sal_uInt16 nNamespacePrefix = (eGrammar == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC);
- pFormulaCell->GetFormula(sFormula, eGrammar);
- OUString sOUFormula(sFormula.makeStringAndClear());
- if (!bIsMatrix)
- {
- AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sOUFormula, false ));
- }
- else
- {
- AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sOUFormula.copy(1, sOUFormula.getLength() - 2), false ));
- }
+ OUString sFormula(lcl_GetRawString(pDoc, aCellPos));
+ GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
+ sFormula, aCell.sStringValue, true, true);
}
- if (pFormulaCell->IsValue())
+ }
+ break;
+ case table::CellContentType_FORMULA :
+ {
+ ScRefCellValue aCellVal;
+ aCellVal.assign(*pDoc, aCellPos);
+ if (aCellVal.meType == CELLTYPE_FORMULA)
{
- bool bIsStandard;
- OUString sCurrency;
- GetNumberFormatAttributesExportHelper()->GetCellType(aCell.nNumberFormat, sCurrency, bIsStandard);
- if (bIsStandard)
+ OUStringBuffer sFormula;
+ ScFormulaCell* pFormulaCell = aCellVal.mpFormula;
+ if (!bIsMatrix || (bIsMatrix && bIsFirstMatrixCell))
{
- if (pDoc)
- GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
- pFormulaCell->GetStandardFormat(*pDoc->GetFormatTable(), 0),
- pDoc->GetValue( aCellPos ));
+ const formula::FormulaGrammar::Grammar eGrammar = pDoc->GetStorageGrammar();
+ sal_uInt16 nNamespacePrefix = (eGrammar == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC);
+ pFormulaCell->GetFormula(sFormula, eGrammar);
+ OUString sOUFormula(sFormula.makeStringAndClear());
+ if (!bIsMatrix)
+ {
+ AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sOUFormula, false ));
+ }
+ else
+ {
+ AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sOUFormula.copy(1, sOUFormula.getLength() - 2), false ));
+ }
}
- else
+ if (pFormulaCell->IsValue())
{
- if (pDoc)
- GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
- aCell.nNumberFormat, pDoc->GetValue( aCellPos ));
- }
- }
- else
- {
- if (GetCellText(aCell, aCellPos))
- if (!aCell.sStringValue.isEmpty())
+ bool bIsStandard;
+ OUString sCurrency;
+ GetNumberFormatAttributesExportHelper()->GetCellType(aCell.nNumberFormat, sCurrency, bIsStandard);
+ if (bIsStandard)
+ {
+ if (pDoc)
+ GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
+ pFormulaCell->GetStandardFormat(*pDoc->GetFormatTable(), 0),
+ pDoc->GetValue( aCellPos ));
+ }
+ else
{
- AddAttribute(sAttrValueType, XML_STRING);
- AddAttribute(sAttrStringValue, aCell.sStringValue);
+ if (pDoc)
+ GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
+ aCell.nNumberFormat, pDoc->GetValue( aCellPos ));
}
+ }
+ else
+ {
+ if (GetCellText(aCell, aCellPos))
+ if (!aCell.sStringValue.isEmpty())
+ {
+ AddAttribute(sAttrValueType, XML_STRING);
+ AddAttribute(sAttrStringValue, aCell.sStringValue);
+ }
+ }
}
}
- }
- break;
+ break;
default:
- {
- // added to avoid warnings
- }
+ break;
}
OUString* pCellString(&sElemCell);
if (aCell.bIsCovered)
More information about the Libreoffice-commits
mailing list