diff options
-rw-r--r-- | filter/Configuration_filter.mk | 1 | ||||
-rw-r--r-- | filter/source/config/fragments/filters/MS_Excel_2003_XML.xcu | 2 | ||||
-rw-r--r-- | filter/source/config/fragments/filters/MS_Excel_2003_XML_Orcus.xcu | 19 | ||||
-rw-r--r-- | filter/source/config/fragments/types/calc_MS_Excel_2003_XML.xcu | 4 | ||||
-rw-r--r-- | sc/inc/orcusfilters.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/inc/orcusfiltersimpl.hxx | 1 | ||||
-rw-r--r-- | sc/source/filter/orcus/filterdetect.cxx | 12 | ||||
-rw-r--r-- | sc/source/filter/orcus/orcusfiltersimpl.cxx | 33 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 8 |
9 files changed, 77 insertions, 5 deletions
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk index f7c531bccbfe..4ef9adb18431 100644 --- a/filter/Configuration_filter.mk +++ b/filter/Configuration_filter.mk @@ -509,6 +509,7 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_calc_filters.x MS_Excel_95_Vorlage_Template \ MS_Excel_97 \ MS_Excel_97_Vorlage_Template \ + MS_Excel_2003_XML_Orcus \ Rich_Text_Format__StarCalc_ \ SYLK \ StarOffice_XML__Calc_ \ diff --git a/filter/source/config/fragments/filters/MS_Excel_2003_XML.xcu b/filter/source/config/fragments/filters/MS_Excel_2003_XML.xcu index 729a73a93c7d..a0fc95939039 100644 --- a/filter/source/config/fragments/filters/MS_Excel_2003_XML.xcu +++ b/filter/source/config/fragments/filters/MS_Excel_2003_XML.xcu @@ -16,7 +16,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . --> <node oor:name="MS Excel 2003 XML" oor:op="replace"> - <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop> + <prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER</value></prop> <prop oor:name="UIComponent"/> <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop> <prop oor:name="UserData"><value oor:separator=",">com.sun.star.documentconversion.XSLTFilter,,com.sun.star.comp.Calc.XMLOasisImporter,com.sun.star.comp.Calc.XMLOasisExporter,../$(share_subdir_name)/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl,../$(share_subdir_name)/xslt/export/spreadsheetml/ooo2spreadsheetml.xsl</value></prop> diff --git a/filter/source/config/fragments/filters/MS_Excel_2003_XML_Orcus.xcu b/filter/source/config/fragments/filters/MS_Excel_2003_XML_Orcus.xcu new file mode 100644 index 000000000000..2206b02747db --- /dev/null +++ b/filter/source/config/fragments/filters/MS_Excel_2003_XML_Orcus.xcu @@ -0,0 +1,19 @@ +<!-- + * 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/. +--> +<node oor:name="MS Excel 2003 XML Orcus" oor:op="replace"> + <prop oor:name="Flags"><value>IMPORT ALIEN PREFERRED</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="FilterService"/> + <prop oor:name="UserData"/> + <prop oor:name="Type"><value>calc_MS_Excel_2003_XML</value></prop> + <prop oor:name="TemplateName"/> + <prop oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">Microsoft Excel 2003 XML</value> + </prop> +</node> diff --git a/filter/source/config/fragments/types/calc_MS_Excel_2003_XML.xcu b/filter/source/config/fragments/types/calc_MS_Excel_2003_XML.xcu index a0b3d90f2ff3..a3ee903b9ac4 100644 --- a/filter/source/config/fragments/types/calc_MS_Excel_2003_XML.xcu +++ b/filter/source/config/fragments/types/calc_MS_Excel_2003_XML.xcu @@ -16,12 +16,12 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . --> <node oor:name="calc_MS_Excel_2003_XML" oor:op="replace"> - <prop oor:name="DetectService"><value>com.sun.star.comp.filters.XMLFilterDetect</value></prop> + <prop oor:name="DetectService"><value>com.sun.star.comp.sc.OrcusFilterDetect</value></prop> <prop oor:name="URLPattern"/> <prop oor:name="Extensions"><value>xml xls</value></prop> <prop oor:name="MediaType"/> <prop oor:name="Preferred"><value>false</value></prop> - <prop oor:name="PreferredFilter"><value>MS Excel 2003 XML</value></prop> + <prop oor:name="PreferredFilter"/> <prop oor:name="UIName"> <value xml:lang="en-US">Microsoft Excel 2003 XML</value> </prop> diff --git a/sc/inc/orcusfilters.hxx b/sc/inc/orcusfilters.hxx index e96facbaa6e3..1f96d6ac1769 100644 --- a/sc/inc/orcusfilters.hxx +++ b/sc/inc/orcusfilters.hxx @@ -31,6 +31,8 @@ public: virtual bool importGnumeric(ScDocument& rDoc, SfxMedium& rMedium) const = 0; + virtual bool importExcel2003XML(ScDocument& rDoc, SfxMedium& rMedium) const = 0; + virtual bool importXLSX(ScDocument& rDoc, SfxMedium& rMedium) const = 0; virtual bool importODS(ScDocument& rDoc, SfxMedium& rMedium) const = 0; diff --git a/sc/source/filter/inc/orcusfiltersimpl.hxx b/sc/source/filter/inc/orcusfiltersimpl.hxx index ee69df00b552..48011504fc5b 100644 --- a/sc/source/filter/inc/orcusfiltersimpl.hxx +++ b/sc/source/filter/inc/orcusfiltersimpl.hxx @@ -21,6 +21,7 @@ public: virtual bool importCSV(ScDocument& rDoc, SfxMedium& rMedium) const override; virtual bool importGnumeric(ScDocument& rDoc, SfxMedium& rMedium) const override; + virtual bool importExcel2003XML(ScDocument& rDoc, SfxMedium& rMedium) const override; virtual bool importXLSX(ScDocument& rDoc, SfxMedium& rMedium) const override; virtual bool importODS(ScDocument& rDoc, SfxMedium& rMedium) const override; diff --git a/sc/source/filter/orcus/filterdetect.cxx b/sc/source/filter/orcus/filterdetect.cxx index 137585384e48..32bac167063f 100644 --- a/sc/source/filter/orcus/filterdetect.cxx +++ b/sc/source/filter/orcus/filterdetect.cxx @@ -80,8 +80,16 @@ OUString OrcusFormatDetect::detect(css::uno::Sequence<css::beans::PropertyValue> } orcus::format_t eFormat = orcus::detect(reinterpret_cast<const unsigned char*>(aContent.getStr()), aContent.getLength()); - if (eFormat == orcus::format_t::gnumeric) - return OUString("Gnumeric XML"); + + switch (eFormat) + { + case orcus::format_t::gnumeric: + return OUString("Gnumeric XML"); + case orcus::format_t::xls_xml: + return OUString("calc_MS_Excel_2003_XML"); + default: + ; + } return OUString(); } diff --git a/sc/source/filter/orcus/orcusfiltersimpl.cxx b/sc/source/filter/orcus/orcusfiltersimpl.cxx index 2aa7e8b30dc0..6fc115bdce29 100644 --- a/sc/source/filter/orcus/orcusfiltersimpl.cxx +++ b/sc/source/filter/orcus/orcusfiltersimpl.cxx @@ -25,6 +25,7 @@ #include <orcus/orcus_csv.hpp> #include <orcus/orcus_gnumeric.hpp> #include <orcus/orcus_xlsx.hpp> +#include <orcus/orcus_xls_xml.hpp> #include <orcus/orcus_ods.hpp> #include <orcus/orcus_import_ods.hpp> #include <orcus/global.hpp> @@ -115,6 +116,38 @@ bool ScOrcusFiltersImpl::importGnumeric(ScDocument& rDoc, SfxMedium& rMedium) co return true; } +bool ScOrcusFiltersImpl::importExcel2003XML(ScDocument& rDoc, SfxMedium& rMedium) const +{ + ScOrcusFactory aFactory(rDoc); + aFactory.setStatusIndicator(getStatusIndicator(rMedium)); + SvStream* pStream = rMedium.GetInStream(); + pStream->Seek(0); + static const size_t nReadBuffer = 1024*32; + OStringBuffer aBuffer((int(nReadBuffer))); + size_t nRead = 0; + do + { + char pData[nReadBuffer]; + nRead = pStream->ReadBytes(pData, nReadBuffer); + aBuffer.append(static_cast<sal_Char*>(pData), nRead); + } + while (nRead == nReadBuffer); + + try + { + rDoc.ClearTabs(); + orcus::orcus_xls_xml filter(&aFactory); + filter.read_stream(aBuffer.getStr(), aBuffer.getLength()); + } + catch (const std::exception& e) + { + SAL_WARN("sc", "Unable to load Excel 2003 XML file! " << e.what()); + return false; + } + + return true; +} + bool ScOrcusFiltersImpl::importXLSX(ScDocument& rDoc, SfxMedium& rMedium) const { ScOrcusFactory aFactory(rDoc); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 98e3e5b51eaa..6f1ba210ff4b 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -1169,6 +1169,14 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium ) bRet = pOrcus->importGnumeric(aDocument, rMedium); } + else if (aFltName == "MS Excel 2003 XML Orcus") + { + ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters(); + if (!pOrcus) + return false; + + bRet = pOrcus->importExcel2003XML(aDocument, rMedium); + } else if (aFltName == pFilterAscii) { SfxItemSet* pSet = rMedium.GetItemSet(); |