Kaydet (Commit) c6726bdb authored tarafından Markus Mohrhard's avatar Markus Mohrhard

make gnumeric xml a real LibreOffice filter format

Change-Id: I502f4610718b5c1914a54346c46d4f998c4d370f
üst 3bcc1762
...@@ -486,6 +486,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_calc_types.xcu,f ...@@ -486,6 +486,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_calc_types.xcu,f
calc_HTML \ calc_HTML \
generic_HTML \ generic_HTML \
generic_Text \ generic_Text \
calc_Gnumeric \
calc_Lotus \ calc_Lotus \
calc_QPro \ calc_QPro \
calc_MS_Excel_40 \ calc_MS_Excel_40 \
...@@ -545,6 +546,7 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_calc_filters.x ...@@ -545,6 +546,7 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_calc_filters.x
dBase \ dBase \
calc8 \ calc8 \
calc8_template \ calc8_template \
calc_Gnumeric \
calc_MS_Excel_2007_XML \ calc_MS_Excel_2007_XML \
calc_MS_Excel_2007_VBA_XML \ calc_MS_Excel_2007_VBA_XML \
calc_MS_Excel_2007_XML_Template \ calc_MS_Excel_2007_XML_Template \
......
<!--
* 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>
<!--
* 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>
...@@ -685,13 +685,6 @@ bool queryOrcusTypeAndFilter(const uno::Sequence<beans::PropertyValue>& rDescrip ...@@ -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 // exists) in order to find a usable loader. Exploit it as a temporary
// hack. // hack.
if (aURL.endsWith(".gnumeric"))
{
rType = "generic_Text";
rFilter = "gnumeric";
return true;
}
// depending on the experimental mode // depending on the experimental mode
uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
if (!xContext.is() || !officecfg::Office::Common::Misc::ExperimentalMode::get(xContext)) if (!xContext.is() || !officecfg::Office::Common::Misc::ExperimentalMode::get(xContext))
......
...@@ -236,6 +236,7 @@ $(eval $(call gb_Library_add_exception_objects,scfilt,\ ...@@ -236,6 +236,7 @@ $(eval $(call gb_Library_add_exception_objects,scfilt,\
sc/source/filter/orcus/interface \ sc/source/filter/orcus/interface \
sc/source/filter/orcus/orcusfiltersimpl \ sc/source/filter/orcus/orcusfiltersimpl \
sc/source/filter/orcus/xmlcontext \ sc/source/filter/orcus/xmlcontext \
sc/source/filter/orcus/filterdetect \
)) ))
endif endif
......
/* -*- 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: */
...@@ -28,4 +28,8 @@ ...@@ -28,4 +28,8 @@
constructor="com_sun_star_comp_oox_xls_FormulaParser_get_implementation"> constructor="com_sun_star_comp_oox_xls_FormulaParser_get_implementation">
<service name="com.sun.star.sheet.FilterFormulaParser"/> <service name="com.sun.star.sheet.FilterFormulaParser"/>
</implementation> </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> </component>
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