diff options
-rw-r--r-- | include/xmloff/xmltoken.hxx | 12 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 127 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlmappingi.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/dataprovider/datatransformation.cxx | 34 | ||||
-rw-r--r-- | sc/source/ui/inc/datatransformation.hxx | 7 | ||||
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 13 | ||||
-rw-r--r-- | xmloff/source/token/tokens.txt | 12 |
7 files changed, 205 insertions, 2 deletions
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index 862741d0a0eb..1c388e5e3193 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -3283,8 +3283,20 @@ namespace xmloff { namespace token { XML_COLUMN_SPLIT_TRANSFORMATION, XML_COLUMN_MERGE_TRANSFORMATION, XML_COLUMN_SORT_TRANSFORMATION, + XML_COLUMN_TEXT_TRANSFORMATION, + XML_COLUMN_AGGREGATE_TRANSFORMATION, + XML_COLUMN_NUMBER_TRANSFORMATION, XML_SORT_PARAM, XML_MERGE_STRING, + XML_TRIM, + XML_ROUND_UP, + XML_ROUND_DOWN, + XML_LOG_10, + XML_SQUARE, + XML_SQUARE_ROOT, + XML_EVEN, + XML_ODD, + XML_SIGN, //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 58d0e197b975..63ec4abc9302 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -4075,10 +4075,9 @@ void ScXMLExport::WriteExternalDataMapping() AddAttribute(XML_NAMESPACE_CALC_EXT, XML_ID, itr.getID()); AddAttribute(XML_NAMESPACE_CALC_EXT, XML_DATABASE_NAME, itr.getDBName()); + SvXMLElementExport aMapping(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_MAPPING, true, true); // Add the data transformations WriteExternalDataTransformations(itr.getDataTransformation()); - - SvXMLElementExport aMapping(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_MAPPING, true, true); } } } @@ -4151,6 +4150,130 @@ void ScXMLExport::WriteExternalDataTransformations(const std::vector<std::shared writeSort(*this, aSortParam, aRange, pDoc); } break; + case sc::TransformationType::TEXT_TRANSFORMATION: + { + // Text Transformation + std::shared_ptr<sc::TextTransformation> aTextTransformation = std::dynamic_pointer_cast<sc::TextTransformation>(itr); + + sc::TEXT_TRANSFORM_TYPE aTextTransformType = aTextTransformation->getTextTransformationType(); + + switch ( aTextTransformType ) + { + case sc::TEXT_TRANSFORM_TYPE::TO_LOWER: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_CASEMAP_LOWERCASE); + break; + case sc::TEXT_TRANSFORM_TYPE::TO_UPPER: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_CASEMAP_UPPERCASE); + break; + case sc::TEXT_TRANSFORM_TYPE::CAPITALIZE: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_CASEMAP_CAPITALIZE); + break; + case sc::TEXT_TRANSFORM_TYPE::TRIM: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_TRIM); + break; + } + + std::set<SCCOL> aColumns = aTextTransformation->getColumns(); + + SvXMLElementExport aTransformation(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN_TEXT_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::AGGREGATE_FUNCTION: + { + // Aggregate Transformation + std::shared_ptr<sc::AggregateFunction> aAggregateFunction = std::dynamic_pointer_cast<sc::AggregateFunction>(itr); + std::set<SCCOL> aColumns = aAggregateFunction->getColumns(); + + sc::AGGREGATE_FUNCTION aAggregateType = aAggregateFunction->getAggregateType(); + + switch (aAggregateType) + { + case sc::AGGREGATE_FUNCTION::SUM: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_SUM); + break; + case sc::AGGREGATE_FUNCTION::AVERAGE: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_AVERAGE); + break; + case sc::AGGREGATE_FUNCTION::MIN: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_MIN); + break; + case sc::AGGREGATE_FUNCTION::MAX: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_MAX); + break; + } + + SvXMLElementExport aTransformation(*this, XML_NAMESPACE_CALC_EXT,XML_COLUMN_AGGREGATE_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::NUMBER_TRANSFORMATION: + { + // Number Transformation + std::shared_ptr<sc::NumberTransformation> aNumberTransformation = std::dynamic_pointer_cast<sc::NumberTransformation>(itr); + + sc::NUMBER_TRANSFORM_TYPE aNumberTransformType = aNumberTransformation->getNumberTransfromationType(); + + switch ( aNumberTransformType ) + { + case sc::NUMBER_TRANSFORM_TYPE::ROUND: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_ROUND); + break; + case sc::NUMBER_TRANSFORM_TYPE::ROUND_UP: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_ROUND_UP); + break; + case sc::NUMBER_TRANSFORM_TYPE::ROUND_DOWN: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_ROUND_DOWN); + break; + case sc::NUMBER_TRANSFORM_TYPE::ABSOLUTE: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_ABS); + break; + case sc::NUMBER_TRANSFORM_TYPE::LOG_E: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_LOG); + break; + case sc::NUMBER_TRANSFORM_TYPE::LOG_10: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_LOG_10); + break; + case sc::NUMBER_TRANSFORM_TYPE::CUBE: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_CUBE); + break; + case sc::NUMBER_TRANSFORM_TYPE::SQUARE: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_SQUARE); + break; + case sc::NUMBER_TRANSFORM_TYPE::SQUARE_ROOT: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_SQUARE_ROOT); + break; + case sc::NUMBER_TRANSFORM_TYPE::EXPONENT: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_EXPONENTIAL); + break; + case sc::NUMBER_TRANSFORM_TYPE::IS_EVEN: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_EVEN); + break; + case sc::NUMBER_TRANSFORM_TYPE::IS_ODD: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_ODD); + break; + case sc::NUMBER_TRANSFORM_TYPE::SIGN: + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_SIGN); + break; + } + + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_COLUMN, OUString::number(aNumberTransformation->getColumn())); + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_PRECISION, OUString::number(aNumberTransformation->getPrecision())); + SvXMLElementExport aTransformation(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN_NUMBER_TRANSFORMATION, true, true); + } + break; default: break; } diff --git a/sc/source/filter/xml/xmlmappingi.cxx b/sc/source/filter/xml/xmlmappingi.cxx index c2f8b4004213..907f4ea472e6 100644 --- a/sc/source/filter/xml/xmlmappingi.cxx +++ b/sc/source/filter/xml/xmlmappingi.cxx @@ -110,6 +110,8 @@ ScXMLMappingContext::ScXMLMappingContext( ScXMLImport& rImport, aSource.setID(aID); aSource.setDBData(aDBName); rDataMapper.insertDataSource(aSource); + auto& rDataSources = rDataMapper.getDataSources(); + rDataSources[0].refresh(pDoc, true); } } diff --git a/sc/source/ui/dataprovider/datatransformation.cxx b/sc/source/ui/dataprovider/datatransformation.cxx index 75e84a23c2ef..c1bfac0895ef 100644 --- a/sc/source/ui/dataprovider/datatransformation.cxx +++ b/sc/source/ui/dataprovider/datatransformation.cxx @@ -277,6 +277,16 @@ TransformationType TextTransformation::getTransformationType() const return TransformationType::TEXT_TRANSFORMATION; } +TEXT_TRANSFORM_TYPE TextTransformation::getTextTransformationType() const +{ + return maType; +} + +std::set<SCCOL> TextTransformation::getColumns() const +{ + return mnCol; +} + AggregateFunction::AggregateFunction(const std::set<SCCOL>& rColumns, const AGGREGATE_FUNCTION rType): maColumns(rColumns), maType(rType) @@ -374,6 +384,16 @@ TransformationType AggregateFunction::getTransformationType() const return TransformationType::AGGREGATE_FUNCTION; } +AGGREGATE_FUNCTION AggregateFunction::getAggregateType() const +{ + return maType; +} + +std::set<SCCOL> AggregateFunction::getColumns() const +{ + return maColumns; +} + NumberTransformation::NumberTransformation(SCCOL nCol, const NUMBER_TRANSFORM_TYPE rType): mnCol(nCol), maType(rType), @@ -608,6 +628,20 @@ TransformationType NumberTransformation::getTransformationType() const return TransformationType::NUMBER_TRANSFORMATION; } +NUMBER_TRANSFORM_TYPE NumberTransformation::getNumberTransfromationType() const +{ + return maType; +} + +int NumberTransformation::getPrecision() const +{ + return maPrecision; +} + +SCCOL NumberTransformation::getColumn() const +{ + return mnCol; +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/datatransformation.hxx b/sc/source/ui/inc/datatransformation.hxx index 3266ce456b9b..0dea9fe8773f 100644 --- a/sc/source/ui/inc/datatransformation.hxx +++ b/sc/source/ui/inc/datatransformation.hxx @@ -115,6 +115,8 @@ class SC_DLLPUBLIC TextTransformation : public DataTransformation TextTransformation(const std::set<SCCOL>& nCol, const TEXT_TRANSFORM_TYPE rType); virtual void Transform(ScDocument& rDoc) const override; virtual TransformationType getTransformationType() const override; + TEXT_TRANSFORM_TYPE getTextTransformationType() const; + std::set<SCCOL> getColumns() const; }; class SC_DLLPUBLIC AggregateFunction : public DataTransformation @@ -126,6 +128,8 @@ class SC_DLLPUBLIC AggregateFunction : public DataTransformation AggregateFunction(const std::set<SCCOL>& rColumns, const AGGREGATE_FUNCTION rType); virtual void Transform(ScDocument& rDoc) const override; virtual TransformationType getTransformationType() const override; + AGGREGATE_FUNCTION getAggregateType() const; + std::set<SCCOL> getColumns() const; }; class SC_DLLPUBLIC NumberTransformation : public DataTransformation @@ -139,6 +143,9 @@ class SC_DLLPUBLIC NumberTransformation : public DataTransformation NumberTransformation(SCCOL nCol, const NUMBER_TRANSFORM_TYPE rType, int nPrecision); virtual void Transform(ScDocument& rDoc) const override; virtual TransformationType getTransformationType() const override; + NUMBER_TRANSFORM_TYPE getNumberTransfromationType() const; + int getPrecision() const; + SCCOL getColumn() const; }; } diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index f32309b3e1a1..8287fd4797fa 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3279,8 +3279,21 @@ namespace xmloff { namespace token { TOKEN( "column-split-transformation", XML_COLUMN_SPLIT_TRANSFORMATION), TOKEN( "column-merge-transformation", XML_COLUMN_MERGE_TRANSFORMATION), TOKEN( "column-sort-transformation", XML_COLUMN_SORT_TRANSFORMATION), + TOKEN( "column-text-transformation", XML_COLUMN_TEXT_TRANSFORMATION), + TOKEN( "column-aggregate-transformation", XML_COLUMN_AGGREGATE_TRANSFORMATION), + TOKEN( "column-number-transformation", XML_COLUMN_NUMBER_TRANSFORMATION), + TOKEN( "sort-param", XML_SORT_PARAM ), TOKEN( "merge-string", XML_MERGE_STRING ), + TOKEN( "trim", XML_TRIM ), + TOKEN( "round-up", XML_ROUND_UP ), + TOKEN( "round-down", XML_ROUND_DOWN ), + TOKEN( "log-base-10", XML_LOG_10 ), + TOKEN( "number-square", XML_SQUARE ), + TOKEN( "square-root", XML_SQUARE_ROOT ), + TOKEN( "even", XML_EVEN ), + TOKEN( "odd", XML_ODD ), + TOKEN( "sign", XML_SIGN ), // 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 63e8b99015ab..6551c5b7b9f2 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -3060,8 +3060,20 @@ column-remove-transformation column-split-transformation column-merge-transformation column-sort-transformation +column-text-transformation +column-aggregate-transformation +column-number-transformation sort-param merge-string +trim +round-up +round-down +log-base-10 +number-square +square-root +even +odd +sign star asterisk horizontal-bar |