diff options
author | Vikas Mahato <vikasmahato0@gmail.com> | 2018-07-28 22:33:32 +0530 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2018-08-06 20:07:08 +0200 |
commit | f7abf77d150cf6761f6c1e3bbba81ebadc37e0ab (patch) | |
tree | 2640cdaa056d466d8b2b2b8911392a99b6772413 | |
parent | 38ec31b6ff7341f7c1b050ba650798b35f13e52c (diff) |
Export Data Transformations to ODF - follow-up
Change-Id: I8aea387f5db399e27b2a08224f6c4ac59f26c54c
Reviewed-on: https://gerrit.libreoffice.org/58254
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | include/xmloff/xmltoken.hxx | 12 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 93 | ||||
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 11 | ||||
-rw-r--r-- | xmloff/source/token/tokens.txt | 11 |
4 files changed, 127 insertions, 0 deletions
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index 2364f63d6879..815d84c599f9 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -3295,6 +3295,18 @@ namespace xmloff { namespace token { XML_EVEN, XML_ODD, XML_SIGN, + XML_REPLACE_STRING, + XML_COLUMN_REPLACENULL_TRANSFORMATION, + XML_COLUMN_DATETIME_TRANSFORMATION, + XML_START_OF_YEAR, + XML_END_OF_YEAR, + XML_MONTH_NAME, + XML_START_OF_MONTH, + XML_END_OF_MONTH, + XML_DAY_OF_YEAR, + XML_START_OF_QUARTER, + XML_END_OF_QUARTER, + //Already defined XML_SEPARATOR, // regina, ODF1.2 additional symbols in charts diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 631abf95cfc3..9312936fd3d5 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -4310,6 +4310,99 @@ void ScXMLExport::WriteExternalDataTransformations(const std::vector<std::shared } } break; + case sc::TransformationType::REMOVE_NULL_TRANSFORMATION: + { + // Replace Null Transformation + std::shared_ptr<sc::ReplaceNullTransformation> aReplaceNullTransformation = std::dynamic_pointer_cast<sc::ReplaceNullTransformation>(itr); + std::set<SCCOL> aColumns = aReplaceNullTransformation->getColumn(); + + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_REPLACE_STRING, aReplaceNullTransformation->getReplaceString()); + SvXMLElementExport aTransformation(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN_REPLACENULL_TRANSFORMATION, true, true); + + for(auto& col : aColumns) + { + // Columns + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_COLUMN, OUString::number(col)); + SvXMLElementExport aCol(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN, true, true); + } + } + break; + case sc::TransformationType::DATETIME_TRANSFORMATION: + { + // Number Transformation + std::shared_ptr<sc::DateTimeTransformation> aDateTimeTransformation = std::dynamic_pointer_cast<sc::DateTimeTransformation>(itr); + + sc::DATETIME_TRANSFORMATION_TYPE aDateTimeTransformationType = aDateTimeTransformation->getDateTimeTransfromationType(); + + switch ( aDateTimeTransformationType ) + { + case sc::DATETIME_TRANSFORMATION_TYPE::DATE_STRING: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_DATE_STRING); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::YEAR: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_YEAR); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::START_OF_YEAR: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_START_OF_YEAR); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::END_OF_YEAR: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_END_OF_YEAR); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::MONTH: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_MONTH); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::MONTH_NAME: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_MONTH_NAME); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::START_OF_MONTH: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_START_OF_MONTH); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::END_OF_MONTH: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_END_OF_MONTH); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::DAY: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_DAY); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::DAY_OF_WEEK: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_DAY_OF_WEEK); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::DAY_OF_YEAR: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_DAY_OF_YEAR); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::QUARTER: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_QUARTER); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::START_OF_QUARTER: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_START_OF_QUARTER); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::END_OF_QUARTER: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_END_OF_QUARTER); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::TIME: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_TIME); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::HOUR: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_HOUR); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::MINUTE: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_MINUTE); + break; + case sc::DATETIME_TRANSFORMATION_TYPE::SECOND: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_SECONDS); + break; + } + + SvXMLElementExport aTransformation(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN_DATETIME_TRANSFORMATION, true, true); + + std::set<SCCOL> aColumns = aDateTimeTransformation->getColumn(); + for(auto& col : aColumns) + { + // Columns + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_COLUMN, OUString::number(col)); + SvXMLElementExport aCol(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN, true, true); + } + } + break; default: break; } diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 5e6700252e78..cd3fcddf4587 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3292,6 +3292,17 @@ namespace xmloff { namespace token { TOKEN( "even", XML_EVEN ), TOKEN( "odd", XML_ODD ), TOKEN( "sign", XML_SIGN ), + TOKEN( "replace-string", XML_REPLACE_STRING ), + TOKEN( "column-replacenull-transformation", XML_COLUMN_REPLACENULL_TRANSFORMATION ), + TOKEN( "column-datetime-transformation", XML_COLUMN_DATETIME_TRANSFORMATION ), + TOKEN( "start-of-year", XML_START_OF_YEAR ), + TOKEN( "end-of-year", XML_END_OF_YEAR ), + TOKEN( "month-name", XML_MONTH_NAME ), + TOKEN( "start-of-month", XML_START_OF_MONTH ), + TOKEN( "end-of-month", XML_END_OF_MONTH ), + TOKEN( "day-of-year", XML_DAY_OF_YEAR ), + TOKEN( "start-of-quarter", XML_START_OF_QUARTER ), + TOKEN( "end-of-quarter", XML_END_OF_QUARTER ), // regina, ODF1.2 additional symbols in charts TOKEN( "star", XML_STAR ), diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index 27b83a01872e..c57d2b646ddc 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -3072,6 +3072,17 @@ square-root even odd sign +replace-string +column-replacenull-transformation +column-datetime-transformation +start-of-year +end-of-year +month-name +start-of-month +end-of-month +day-of-year +start-of-quarter +end-of-quarter star asterisk horizontal-bar |