filter/Configuration_filter.mk | 3 filter/source/config/fragments/filters/calc_Gnumeric.xcu | 29 ++ filter/source/config/fragments/filters/calc_MS_Excel_2007_VBA_XML.xcu | 2 filter/source/config/fragments/types/MS_Excel_2007_VBA_XML.xcu | 27 ++ filter/source/config/fragments/types/MS_Excel_2007_XML.xcu | 2 filter/source/config/fragments/types/calc_Gnumeric.xcu | 17 + framework/source/loadenv/loadenv.cxx | 7 oox/source/core/filterdetect.cxx | 6 sc/Library_scfilt.mk | 1 sc/source/filter/ftools/fapihelper.cxx | 5 sc/source/filter/orcus/filterdetect.cxx | 111 ++++++++++ sc/util/scfilt.component | 4 12 files changed, 199 insertions(+), 15 deletions(-)
New commits: commit e72e8c59fb1103f46b3d0b3e6a2386566068b1a2 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Sun Sep 27 07:35:39 2015 +0200 OOXML with VBA needs to be a different filter type The filter type also contains the file format, so we need to use a different type to keep the xlsm extension during export. Now the only missing part is the warning that saving as the non-VBA version will loose the VBA stream. Change-Id: I11f78d2c33cb2834086a4e9fad141b3e374b8991 diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk index 1f72807..5fe58b0 100644 --- a/filter/Configuration_filter.mk +++ b/filter/Configuration_filter.mk @@ -506,6 +506,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_calc_types.xcu,f calc8 \ calc8_template \ MS_Excel_2007_XML \ + MS_Excel_2007_VBA_XML \ MS_Excel_2007_XML_Template \ MS_Excel_2007_Binary \ calc_OOXML \ diff --git a/filter/source/config/fragments/filters/calc_MS_Excel_2007_VBA_XML.xcu b/filter/source/config/fragments/filters/calc_MS_Excel_2007_VBA_XML.xcu index afd66db..f832135 100644 --- a/filter/source/config/fragments/filters/calc_MS_Excel_2007_VBA_XML.xcu +++ b/filter/source/config/fragments/filters/calc_MS_Excel_2007_VBA_XML.xcu @@ -21,7 +21,7 @@ <prop oor:name="FilterService"><value>com.sun.star.comp.oox.xls.ExcelFilter</value></prop> <prop oor:name="UserData"><value>macro-enabled</value></prop> <prop oor:name="FileFormatVersion"/> - <prop oor:name="Type"><value>MS Excel 2007 XML</value></prop> + <prop oor:name="Type"><value>MS Excel 2007 VBA XML</value></prop> <prop oor:name="TemplateName"/> <prop oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop> <prop oor:name="UIName"> diff --git a/filter/source/config/fragments/types/MS_Excel_2007_VBA_XML.xcu b/filter/source/config/fragments/types/MS_Excel_2007_VBA_XML.xcu new file mode 100644 index 0000000..17f6f0a --- /dev/null +++ b/filter/source/config/fragments/types/MS_Excel_2007_VBA_XML.xcu @@ -0,0 +1,27 @@ +<!-- + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> +<node oor:name="MS Excel 2007 VBA XML" oor:op="replace" > + <prop oor:name="DetectService"><value>com.sun.star.comp.oox.FormatDetector</value></prop> + <prop oor:name="URLPattern"/> + <prop oor:name="Extensions"><value>xlsm</value></prop> + <prop oor:name="MediaType"><value>application/vnd.ms-excel.sheet.macroEnabled.12</value></prop> + <prop oor:name="Preferred"><value>false</value></prop> + <prop oor:name="PreferredFilter"><value>Calc MS Excel 2007 VBA XML</value></prop> + <prop oor:name="UIName"><value xml:lang="en-US">Microsoft Excel 2007-2016 VBA XML</value></prop> + <prop oor:name="ClipboardFormat"/> +</node> diff --git a/filter/source/config/fragments/types/MS_Excel_2007_XML.xcu b/filter/source/config/fragments/types/MS_Excel_2007_XML.xcu index 42819b8..b39c3c1 100644 --- a/filter/source/config/fragments/types/MS_Excel_2007_XML.xcu +++ b/filter/source/config/fragments/types/MS_Excel_2007_XML.xcu @@ -18,7 +18,7 @@ <node oor:name="MS Excel 2007 XML" oor:op="replace" > <prop oor:name="DetectService"><value>com.sun.star.comp.oox.FormatDetector</value></prop> <prop oor:name="URLPattern"/> - <prop oor:name="Extensions"><value>xlsx xlsm</value></prop> + <prop oor:name="Extensions"><value>xlsx</value></prop> <prop oor:name="MediaType"><value>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</value></prop> <prop oor:name="Preferred"><value>false</value></prop> <prop oor:name="PreferredFilter"><value>Calc MS Excel 2007 XML</value></prop> diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx index d48d25c..1742c91 100644 --- a/oox/source/core/filterdetect.cxx +++ b/oox/source/core/filterdetect.cxx @@ -178,10 +178,12 @@ OUString FilterDetectDocHandler::getFilterNameFromContentType( const OUString& r rContentType == "application/vnd.ms-word.template.macroEnabledTemplate.main+xml" ) return OUString( "writer_MS_Word_2007_Template" ); - if( rContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" || - rContentType == "application/vnd.ms-excel.sheet.macroEnabled.main+xml" ) + if( rContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml") return OUString( "MS Excel 2007 XML" ); + if (rContentType == "application/vnd.ms-excel.sheet.macroEnabled.main+xml") + return OUString( "MS Excel 2007 VBA XML" ); + if( rContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml" || rContentType == "application/vnd.ms-excel.template.macroEnabled.main+xml" ) return OUString( "MS Excel 2007 XML Template" ); commit c6726bdbd2143ae2875f3373b07b23611eb263d7 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Sun Sep 27 07:14:52 2015 +0200 make gnumeric xml a real LibreOffice filter format Change-Id: I502f4610718b5c1914a54346c46d4f998c4d370f diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk index 4ff9855..1f72807 100644 --- a/filter/Configuration_filter.mk +++ b/filter/Configuration_filter.mk @@ -486,6 +486,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_calc_types.xcu,f calc_HTML \ generic_HTML \ generic_Text \ + calc_Gnumeric \ calc_Lotus \ calc_QPro \ calc_MS_Excel_40 \ @@ -545,6 +546,7 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_calc_filters.x dBase \ calc8 \ calc8_template \ + calc_Gnumeric \ calc_MS_Excel_2007_XML \ calc_MS_Excel_2007_VBA_XML \ calc_MS_Excel_2007_XML_Template \ diff --git a/filter/source/config/fragments/filters/calc_Gnumeric.xcu b/filter/source/config/fragments/filters/calc_Gnumeric.xcu new file mode 100644 index 0000000..4210615 --- /dev/null +++ b/filter/source/config/fragments/filters/calc_Gnumeric.xcu @@ -0,0 +1,29 @@ +<!-- + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> +<node oor:name="Gnumeric Spreadsheet" oor:op="replace"> + <prop oor:name="Flags"><value>IMPORT ALIEN 3RDPARTYFILTER PREFERRED</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="FilterService"/> + <prop oor:name="UserData"/> + <prop oor:name="Type"><value>Gnumeric 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">Gnumeric Spreadsheet</value> + </prop> +</node> diff --git a/filter/source/config/fragments/types/calc_Gnumeric.xcu b/filter/source/config/fragments/types/calc_Gnumeric.xcu new file mode 100644 index 0000000..4c158cc --- /dev/null +++ b/filter/source/config/fragments/types/calc_Gnumeric.xcu @@ -0,0 +1,17 @@ +<!-- + * 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="Gnumeric XML" oor:op="replace" > + <prop oor:name="DetectService"><value>com.sun.star.comp.sc.OrcusFilterDetect</value></prop> + <prop oor:name="URLPattern"/> + <prop oor:name="Extensions"><value>gnumeric gnm</value></prop> + <prop oor:name="MediaType"><value>application/x-gnumeric</value></prop> + <prop oor:name="Preferred"><value>false</value></prop> + <prop oor:name="PreferredFilter"><value>Gnumeric Spreadsheet</value></prop> + <prop oor:name="UIName"><value xml:lang="en-US">Gnumeric Spreadsheet</value></prop> + <prop oor:name="ClipboardFormat"/> +</node> diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index aca4c09..2a7e6e8 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -685,13 +685,6 @@ bool queryOrcusTypeAndFilter(const uno::Sequence<beans::PropertyValue>& rDescrip // exists) in order to find a usable loader. Exploit it as a temporary // hack. - if (aURL.endsWith(".gnumeric")) - { - rType = "generic_Text"; - rFilter = "gnumeric"; - return true; - } - // depending on the experimental mode uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); if (!xContext.is() || !officecfg::Office::Common::Misc::ExperimentalMode::get(xContext)) diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk index ed9f435..74f2ce5 100644 --- a/sc/Library_scfilt.mk +++ b/sc/Library_scfilt.mk @@ -236,6 +236,7 @@ $(eval $(call gb_Library_add_exception_objects,scfilt,\ sc/source/filter/orcus/interface \ sc/source/filter/orcus/orcusfiltersimpl \ sc/source/filter/orcus/xmlcontext \ + sc/source/filter/orcus/filterdetect \ )) endif diff --git a/sc/source/filter/orcus/filterdetect.cxx b/sc/source/filter/orcus/filterdetect.cxx new file mode 100644 index 0000000..8c84a5d --- /dev/null +++ b/sc/source/filter/orcus/filterdetect.cxx @@ -0,0 +1,111 @@ +/* -*- 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/. + */ + +#include <com/sun/star/document/XExtendedFilterDetection.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <cppuhelper/implbase.hxx> + +#include <unotools/mediadescriptor.hxx> + +#include <rtl/strbuf.hxx> + +#include <orcus/format_detection.hpp> + +namespace { + +class OrcusFormatDetect : public ::cppu::WeakImplHelper< + ::com::sun::star::document::XExtendedFilterDetection, + ::com::sun::star::lang::XServiceInfo > +{ +public: + explicit OrcusFormatDetect(); + virtual ~OrcusFormatDetect(); + + virtual OUString SAL_CALL getImplementationName() + throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; + + virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) + throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; + + virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() + throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; + + virtual OUString SAL_CALL + detect( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rMediaDescSeq ) + throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; + +private: +}; + +OrcusFormatDetect::OrcusFormatDetect() +{ +} + +OrcusFormatDetect::~OrcusFormatDetect() +{ +} + +OUString OrcusFormatDetect::getImplementationName() + throw( ::com::sun::star::uno::RuntimeException, std::exception ) +{ + return OUString(""); +} + +sal_Bool OrcusFormatDetect::supportsService(const OUString& /*rServiceName*/) + throw( ::com::sun::star::uno::RuntimeException, std::exception ) +{ + return false; +} + +css::uno::Sequence<OUString> OrcusFormatDetect::getSupportedServiceNames() + throw( ::com::sun::star::uno::RuntimeException, std::exception ) +{ + return css::uno::Sequence<OUString>(); +} + +OUString OrcusFormatDetect::detect(css::uno::Sequence<css::beans::PropertyValue>& rMediaDescSeq) + throw( ::com::sun::star::uno::RuntimeException, std::exception ) +{ + utl::MediaDescriptor aMediaDescriptor( rMediaDescSeq ); + bool bAborted = aMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_ABORTED(), false); + if (bAborted) + return OUString(); + + css::uno::Reference<css::io::XInputStream> xInputStream(aMediaDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM()], css::uno::UNO_QUERY ); + + static const sal_Int32 nBytes = 4096; + css::uno::Sequence<sal_Int8> aSeq(nBytes); + bool bEnd = false; + OStringBuffer aContent; + while(!bEnd) + { + sal_Int32 nReadBytes = xInputStream->readBytes(aSeq, nBytes); + bEnd = !(nReadBytes == nBytes); + aContent.append(reinterpret_cast<const char*>(aSeq.getConstArray()), nReadBytes); + } + + orcus::format_t eFormat = orcus::detect(reinterpret_cast<const unsigned char*>(aContent.getStr()), aContent.getLength()); + if (eFormat == orcus::format_gnumeric) + return OUString("Gnumeric XML"); + + return OUString(); +} + +} + +extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL +com_sun_star_comp_oox_sc_OrcusFormatDetect_get_implementation(::com::sun::star::uno::XComponentContext* , + ::com::sun::star::uno::Sequence<css::uno::Any> const &) +{ + return cppu::acquire(new OrcusFormatDetect()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/util/scfilt.component b/sc/util/scfilt.component index 42227f4..0df939f 100644 --- a/sc/util/scfilt.component +++ b/sc/util/scfilt.component @@ -28,4 +28,8 @@ constructor="com_sun_star_comp_oox_xls_FormulaParser_get_implementation"> <service name="com.sun.star.sheet.FilterFormulaParser"/> </implementation> + <implementation name="com.sun.star.comp.sc.OrcusFormatDetect" + constructor="com_sun_star_comp_sc_OrcusFormatDetect_get_implementation"> + <service name="com.sun.star.frame.ExtendedTypeDetection"/> + </implementation> </component> commit 3bcc1762216c2b9dff8bf5414b4930b271f038ae Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Sun Sep 27 06:23:22 2015 +0200 simplify code Change-Id: I5150299c68576e2442f1ef4c8722a3f5ccb3a070 diff --git a/sc/source/filter/ftools/fapihelper.cxx b/sc/source/filter/ftools/fapihelper.cxx index 1384c7d..b69fa64 100644 --- a/sc/source/filter/ftools/fapihelper.cxx +++ b/sc/source/filter/ftools/fapihelper.cxx @@ -246,10 +246,7 @@ void ScfPropertySet::SetAnyProperty( const OUString& rPropName, const Any& rValu } catch (const Exception&) { - OSL_FAIL(OStringBuffer("ScfPropertySet::SetAnyProperty - cannot set property \"") - .append(OUStringToOString(rPropName, - RTL_TEXTENCODING_ASCII_US)) - .append('"').getStr()); + SAL_WARN("sc", "ScfPropertySet::SetAnyProperty - cannot set property \"" + rPropName + "\""); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits