Kaydet (Commit) 842af510 authored tarafından Vikas Mahato's avatar Vikas Mahato Kaydeden (comit) Markus Mohrhard

Import ODF with data transformations

Change-Id: Iee76ed28d0dcd4ee57115ec951a181b2cf8d35fd
Reviewed-on: https://gerrit.libreoffice.org/57239
Tested-by: Jenkins
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 64ee6a4d
...@@ -346,6 +346,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ ...@@ -346,6 +346,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/filter/xml/xmlstyli \ sc/source/filter/xml/xmlstyli \
sc/source/filter/xml/xmlsubti \ sc/source/filter/xml/xmlsubti \
sc/source/filter/xml/xmltabi \ sc/source/filter/xml/xmltabi \
sc/source/filter/xml/xmltransformationi \
sc/source/filter/xml/xmlwrap \ sc/source/filter/xml/xmlwrap \
sc/source/filter/chart/chart_imp \ sc/source/filter/chart/chart_imp \
sc/source/filter/importfilterdata \ sc/source/filter/importfilterdata \
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
*/ */
#include "xmlmappingi.hxx" #include "xmlmappingi.hxx"
#include "xmltransformationi.hxx"
#include <xmloff/xmltkmap.hxx> #include <xmloff/xmltkmap.hxx>
#include <xmloff/nmspmap.hxx> #include <xmloff/nmspmap.hxx>
...@@ -51,6 +52,11 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLMappingsContext::c ...@@ -51,6 +52,11 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLMappingsContext::c
pContext = new ScXMLMappingContext( GetScImport(), pAttribList ); pContext = new ScXMLMappingContext( GetScImport(), pAttribList );
} }
break; break;
case XML_ELEMENT( CALC_EXT, XML_DATA_TRANSFORMATIONS):
{
pContext = new ScXMLTransformationsContext( GetScImport() );
}
break;
} }
if( !pContext ) if( !pContext )
...@@ -110,13 +116,36 @@ ScXMLMappingContext::ScXMLMappingContext( ScXMLImport& rImport, ...@@ -110,13 +116,36 @@ ScXMLMappingContext::ScXMLMappingContext( ScXMLImport& rImport,
aSource.setID(aID); aSource.setID(aID);
aSource.setDBData(aDBName); aSource.setDBData(aDBName);
rDataMapper.insertDataSource(aSource); rDataMapper.insertDataSource(aSource);
auto& rDataSources = rDataMapper.getDataSources();
rDataSources[0].refresh(pDoc, true);
} }
} }
ScXMLMappingContext::~ScXMLMappingContext() ScXMLMappingContext::~ScXMLMappingContext()
{ {
ScDocument* pDoc = GetScImport().GetDocument();
auto& rDataMapper = pDoc->GetExternalDataMapper();
auto& rDataSources = rDataMapper.getDataSources();
if(!rDataSources.empty())
rDataSources[0].refresh(pDoc, true);
} }
uno::Reference<xml::sax::XFastContextHandler>
SAL_CALL ScXMLMappingContext::createFastChildContext(
sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& /*xAttrList*/)
{
SvXMLImportContext *pContext = nullptr;
switch( nElement )
{
case XML_ELEMENT( CALC_EXT, XML_DATA_TRANSFORMATIONS):
{
pContext = new ScXMLTransformationsContext( GetScImport() );
}
break;
}
if( !pContext )
pContext = new SvXMLImportContext( GetImport() );
return pContext;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -38,6 +38,10 @@ public: ...@@ -38,6 +38,10 @@ public:
const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList ); const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList );
virtual ~ScXMLMappingContext() override; virtual ~ScXMLMappingContext() override;
virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext(
sal_Int32 nElement,
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
}; };
......
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SC_SOURCE_FILTER_XML_XMLTRANSFORMATIONI_HXX
#define INCLUDED_SC_SOURCE_FILTER_XML_XMLTRANSFORMATIONI_HXX
#include <xmloff/xmlictxt.hxx>
#include <xmloff/xmlimp.hxx>
#include <datatransformation.hxx>
#include "xmlimprt.hxx"
#include "importcontext.hxx"
class ScXMLTransformationsContext : public ScXMLImportContext
{
public:
ScXMLTransformationsContext(ScXMLImport& rImport);
virtual ~ScXMLTransformationsContext() override;
virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext(
sal_Int32 nElement,
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
};
class ScXMLColumnRemoveContext : public ScXMLImportContext
{
std::set<SCCOL> maColumns;
public:
ScXMLColumnRemoveContext(ScXMLImport& rImport,
const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList);
virtual ~ScXMLColumnRemoveContext() override;
virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext(
sal_Int32 nElement,
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
};
class ScXMLColumnSplitContext : public ScXMLImportContext
{
public:
ScXMLColumnSplitContext(ScXMLImport& rImport,
const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList);
virtual ~ScXMLColumnSplitContext() override;
};
class ScXMLColumnMergeContext : public ScXMLImportContext
{
std::set<SCCOL> maColumns;
OUString maMergeString;
public:
ScXMLColumnMergeContext(ScXMLImport& rImport,
const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList);
virtual ~ScXMLColumnMergeContext() override;
virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext(
sal_Int32 nElement,
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
};
class ScXMLColumnSortContext : public ScXMLImportContext
{
ScSortParam maSortParam;
public:
ScXMLColumnSortContext(ScXMLImport& rImport,
const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList);
virtual ~ScXMLColumnSortContext() override;
/*
virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext(
sal_Int32 nElement,
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
*/
};
class ScXMLColumnTextContext : public ScXMLImportContext
{
std::set<SCCOL> maColumns;
sc::TEXT_TRANSFORM_TYPE maType;
public:
ScXMLColumnTextContext(ScXMLImport& rImport,
const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList);
virtual ~ScXMLColumnTextContext() override;
virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext(
sal_Int32 nElement,
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
};
class ScXMLColumnAggregateContext : public ScXMLImportContext
{
std::set<SCCOL> maColumns;
sc::AGGREGATE_FUNCTION maType;
public:
ScXMLColumnAggregateContext(ScXMLImport& rImport,
const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList);
virtual ~ScXMLColumnAggregateContext() override;
virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext(
sal_Int32 nElement,
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
};
class ScXMLColumnNumberContext : public ScXMLImportContext
{
OUString aType;
sc::NUMBER_TRANSFORM_TYPE maType;
int maPrecision;
std::set<SCCOL> maColumns;
public:
ScXMLColumnNumberContext(ScXMLImport& rImport,
const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList);
virtual ~ScXMLColumnNumberContext() override;
virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext(
sal_Int32 nElement,
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment