[Libreoffice-commits] core.git: filter/Configuration_filter.mk filter/source
David Tardon
dtardon at redhat.com
Tue Jul 8 08:04:28 PDT 2014
filter/Configuration_filter.mk | 1
filter/source/config/fragments/types/calc_HTML.xcu | 35 +++++++++++++++++++++
filter/source/textfilterdetect/filterdetect.cxx | 6 +--
3 files changed, 38 insertions(+), 4 deletions(-)
New commits:
commit 86c6f18c2766aad43d6e3bfcf3530e40440ebca7
Author: David Tardon <dtardon at redhat.com>
Date: Tue Jul 8 17:01:27 2014 +0200
avoid problems detecting HTML files with .xls ext.
Change-Id: I9955223aac20f3f640fde51bb7231666c269ca70
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index e035464..0465f17 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -512,6 +512,7 @@ $(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/config/fr
$(call filter_Configuration_add_types,fcfg_langpack,fcfg_calc_types.xcu,filter/source/config/fragments/types,\
calc_DIF \
calc_ODS_FlatXML \
+ calc_HTML \
generic_HTML \
generic_Text \
calc_Lotus \
diff --git a/filter/source/config/fragments/types/calc_HTML.xcu b/filter/source/config/fragments/types/calc_HTML.xcu
new file mode 100644
index 0000000..51bf8f1
--- /dev/null
+++ b/filter/source/config/fragments/types/calc_HTML.xcu
@@ -0,0 +1,35 @@
+<!--
+ * 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 .
+-->
+ <!-- A special case: There are tools that export HTML with .xls
+ extension. Allow to detect these early to avoid going through the
+ whole list of detectors. This also avoids the risk of misdetection
+ as something else, as there are some formats that are text files and
+ the detection is just a heuristic (e.g., wp1 or wp42 supported by
+ libwpd). -->
+ <node oor:name="calc_HTML" oor:op="replace" >
+ <prop oor:name="DetectService"><value>com.sun.star.comp.filters.PlainTextFilterDetect</value></prop>
+ <prop oor:name="URLPattern"/>
+ <prop oor:name="Extensions"><value>xls</value></prop>
+ <prop oor:name="MediaType"><value>text/html</value></prop>
+ <prop oor:name="Preferred"><value>false</value></prop>
+ <prop oor:name="PreferredFilter"/>
+ <prop oor:name="UIName">
+ <value>HTML Table</value>
+ </prop>
+ <prop oor:name="ClipboardFormat"/>
+ </node>
diff --git a/filter/source/textfilterdetect/filterdetect.cxx b/filter/source/textfilterdetect/filterdetect.cxx
index ffad7fa..1d29dd4 100644
--- a/filter/source/textfilterdetect/filterdetect.cxx
+++ b/filter/source/textfilterdetect/filterdetect.cxx
@@ -132,7 +132,7 @@ OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyVal
OUString aExt = aParser.getExtension(INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET);
aExt = aExt.toAsciiLowerCase();
- if (aType == "generic_HTML")
+ if ((aType == "generic_HTML") || (aType == "calc_HTML"))
{
uno::Reference<io::XInputStream> xInStream(aMediaDesc[MediaDescriptor::PROP_INPUTSTREAM()], uno::UNO_QUERY);
if (!xInStream.is() || !IsHTMLStream(xInStream))
@@ -141,12 +141,10 @@ OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyVal
// Decide which filter to use based on the document service first,
// then on extension if that's not available.
- if (aDocService == CALC_DOCSERVICE)
+ if ((aDocService == CALC_DOCSERVICE) || (aType == "calc_HTML"))
aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(CALC_HTML_FILTER);
else if (aDocService == WRITER_DOCSERVICE)
aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(WRITER_HTML_FILTER);
- else if (aExt == "xls")
- aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(CALC_HTML_FILTER);
else
aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(WEB_HTML_FILTER);
}
More information about the Libreoffice-commits
mailing list