kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0001-avoid-problems-detecting-HTML-files-with-.xls-ext.patch

ebc4bd
From 15bb6158591e9d8350f817ca20129c2e947cceda Mon Sep 17 00:00:00 2001
f085be
From: David Tardon <dtardon@redhat.com>
f085be
Date: Tue, 8 Jul 2014 17:01:27 +0200
f085be
Subject: [PATCH] avoid problems detecting HTML files with .xls ext.
f085be
f085be
Change-Id: I9955223aac20f3f640fde51bb7231666c269ca70
f085be
---
ebc4bd
 filter/Configuration_filter.mk                     |  1 +
ebc4bd
 filter/source/config/fragments/types/calc_HTML.xcu | 35 ++++++++++++++++++++++
ebc4bd
 filter/source/textfilterdetect/filterdetect.cxx    |  6 ++--
ebc4bd
 3 files changed, 38 insertions(+), 4 deletions(-)
f085be
 create mode 100644 filter/source/config/fragments/types/calc_HTML.xcu
f085be
f085be
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
ebc4bd
index 39fabfc..787a175 100644
f085be
--- a/filter/Configuration_filter.mk
f085be
+++ b/filter/Configuration_filter.mk
ebc4bd
@@ -520,6 +520,7 @@ $(eval $(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/co
ebc4bd
 $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_calc_types.xcu,filter/source/config/fragments/types,\
f085be
 	calc_DIF \
f085be
 	calc_ODS_FlatXML \
f085be
+	calc_HTML \
f085be
 	generic_HTML \
f085be
 	generic_Text \
f085be
 	calc_Lotus \
f085be
diff --git a/filter/source/config/fragments/types/calc_HTML.xcu b/filter/source/config/fragments/types/calc_HTML.xcu
f085be
new file mode 100644
ebc4bd
index 0000000..51bf8f1
f085be
--- /dev/null
f085be
+++ b/filter/source/config/fragments/types/calc_HTML.xcu
f085be
@@ -0,0 +1,35 @@
f085be
+
f085be
+ * This file is part of the LibreOffice project.
f085be
+ *
f085be
+ * This Source Code Form is subject to the terms of the Mozilla Public
f085be
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
f085be
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
f085be
+ *
f085be
+ * This file incorporates work covered by the following license notice:
f085be
+ *
f085be
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
f085be
+ *   contributor license agreements. See the NOTICE file distributed
f085be
+ *   with this work for additional information regarding copyright
f085be
+ *   ownership. The ASF licenses this file to you under the Apache
f085be
+ *   License, Version 2.0 (the "License"); you may not use this file
f085be
+ *   except in compliance with the License. You may obtain a copy of
f085be
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
f085be
+-->
f085be
+    
f085be
+    extension. Allow to detect these early to avoid going through the
f085be
+    whole list of detectors. This also avoids the risk of misdetection
f085be
+    as something else, as there are some formats that are text files and
f085be
+    the detection is just a heuristic (e.g., wp1 or wp42 supported by
f085be
+    libwpd). -->
f085be
+    <node oor:name="calc_HTML" oor:op="replace" >
ebc4bd
+        <prop oor:name="DetectService"><value>com.sun.star.comp.filters.PlainTextFilterDetect</value></prop>
f085be
+        <prop oor:name="URLPattern"/>
f085be
+        <prop oor:name="Extensions"><value>xls</value></prop>
f085be
+        <prop oor:name="MediaType"><value>text/html</value></prop>
f085be
+        <prop oor:name="Preferred"><value>false</value></prop>
f085be
+        <prop oor:name="PreferredFilter"/>
f085be
+        <prop oor:name="UIName">
f085be
+            <value>HTML Table</value>
f085be
+        </prop>
f085be
+        <prop oor:name="ClipboardFormat"/>
f085be
+    </node>
ebc4bd
diff --git a/filter/source/textfilterdetect/filterdetect.cxx b/filter/source/textfilterdetect/filterdetect.cxx
ebc4bd
index ffad7fa..1d29dd4 100644
ebc4bd
--- a/filter/source/textfilterdetect/filterdetect.cxx
ebc4bd
+++ b/filter/source/textfilterdetect/filterdetect.cxx
ebc4bd
@@ -132,7 +132,7 @@ OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence
ebc4bd
     OUString aExt = aParser.getExtension(INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET);
ebc4bd
     aExt = aExt.toAsciiLowerCase();
f085be
 
ebc4bd
-    if (aType == "generic_HTML")
ebc4bd
+    if ((aType == "generic_HTML") || (aType == "calc_HTML"))
ebc4bd
     {
ebc4bd
         uno::Reference<io::XInputStream> xInStream(aMediaDesc[MediaDescriptor::PROP_INPUTSTREAM()], uno::UNO_QUERY);
ebc4bd
         if (!xInStream.is() || !IsHTMLStream(xInStream))
ebc4bd
@@ -141,12 +141,10 @@ OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence
ebc4bd
         // Decide which filter to use based on the document service first,
ebc4bd
         // then on extension if that's not available.
f085be
 
ebc4bd
-        if (aDocService == CALC_DOCSERVICE)
ebc4bd
+        if ((aDocService == CALC_DOCSERVICE) || (aType == "calc_HTML"))
ebc4bd
             aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(CALC_HTML_FILTER);
ebc4bd
         else if (aDocService == WRITER_DOCSERVICE)
ebc4bd
             aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(WRITER_HTML_FILTER);
ebc4bd
-        else if (aExt == "xls")
ebc4bd
-            aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(CALC_HTML_FILTER);
ebc4bd
         else
ebc4bd
             aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(WEB_HTML_FILTER);
ebc4bd
     }
f085be
-- 
ebc4bd
2.1.0
f085be