Kaydet (Commit) 86c6f18c authored tarafından David Tardon's avatar David Tardon

avoid problems detecting HTML files with .xls ext.

Change-Id: I9955223aac20f3f640fde51bb7231666c269ca70
üst 8d4d3b2a
......@@ -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 \
......
<!--
* 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>
......@@ -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);
}
......
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