summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2014-07-08 17:01:27 +0200
committerDavid Tardon <dtardon@redhat.com>2014-07-08 17:03:42 +0200
commit86c6f18c2766aad43d6e3bfcf3530e40440ebca7 (patch)
treecf82daabab0b45c481eb9dbb76eb99b1a77e5cf4
parent8d4d3b2adee67057f88ca1f6d71a4843227b183e (diff)
avoid problems detecting HTML files with .xls ext.
Change-Id: I9955223aac20f3f640fde51bb7231666c269ca70
-rw-r--r--filter/Configuration_filter.mk1
-rw-r--r--filter/source/config/fragments/types/calc_HTML.xcu35
-rw-r--r--filter/source/textfilterdetect/filterdetect.cxx6
3 files changed, 38 insertions, 4 deletions
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index e0354647fa51..0465f1738183 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 000000000000..51bf8f1922df
--- /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 ffad7faa0282..1d29dd45cc5d 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);
}