summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2012-05-10 19:07:47 +0200
committerEike Rathke <erack@redhat.com>2012-05-10 19:07:47 +0200
commitaeb1451dff06ad00b1719f9bc45a2c8bdfa904f8 (patch)
treecc4e622d9f6d4290f6d60c413bd37979e9491ea6
parent5df9e10d27a071f878ed160f99129a7f3c34f5ed (diff)
resolved fdo#49639 import .xls with HTML as such, not CSV
This restores the previous behavior for this content type, regression introduced with the fix for fdo#40021 a5eadc6aaafec92df23c57e258882a2c98ece0ad
-rw-r--r--sc/source/ui/unoobj/scdetect.cxx17
1 files changed, 9 insertions, 8 deletions
diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx
index 6ef14291107c..7fe787da7d02 100644
--- a/sc/source/ui/unoobj/scdetect.cxx
+++ b/sc/source/ui/unoobj/scdetect.cxx
@@ -438,20 +438,19 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream )
pFilter = SfxFilterMatcher( String::CreateFromAscii("scalc") ).GetFilter4EA( aTypeName );
}
}
else
{
- bool bIsXLS = false;
SvStream* pStream = aMedium.GetInStream();
const SfxFilter* pPreselectedFilter = pFilter;
- bool bCsvSelected = (pPreselectedFilter ?
- pPreselectedFilter->GetFilterName().EqualsAscii( pFilterAscii ) : false);
- if ( pPreselectedFilter && ( ( pPreselectedFilter->GetName().SearchAscii("Excel") != STRING_NOTFOUND ) ||
- ( !aPreselectedFilterName.Len() && bCsvSelected ) ) )
- bIsXLS = true;
+ bool bCsvSelected = (pPreselectedFilter &&
+ pPreselectedFilter->GetFilterName().EqualsAscii( pFilterAscii ));
+ bool bExcelSelected = (pPreselectedFilter &&
+ (pPreselectedFilter->GetName().SearchAscii("Excel") != STRING_NOTFOUND));
+ bool bIsXLS = (bExcelSelected || (bCsvSelected && !aPreselectedFilterName.Len()));
pFilter = 0;
if ( pStream )
{
pStream->Seek( STREAM_SEEK_TO_END);
sal_Size nSize = pStream->Tell();
pStream->Seek( 0);
@@ -747,18 +746,20 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream )
// get file header
rStr.Seek( 0 );
const sal_Size nTrySize = 80;
rtl::OString aHeader = read_uInt8s_ToOString(rStr, nTrySize);
+ bool bMaybeHtml = HTMLParser::IsHTMLFormat( aHeader.getStr());
+
if ( aHeader.copy(0, 5).equalsL("{\\rtf", 5) )
{
// test for RTF
pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterRtf) );
}
- else if ( bIsXLS && bMaybeText )
+ else if ( bIsXLS && (bMaybeText && !bMaybeHtml) )
{
aHeader = comphelper::string::stripStart(aHeader, ' ');
// Detect Excel 2003 XML here only if XLS was preselected.
// The configured detection for Excel 2003 XML is still in XMLFilterDetect.
pFilter = lcl_DetectExcelXML( rStr, aMatcher );
if (!pFilter)
@@ -766,13 +767,13 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream )
bFakeXLS = true;
}
else if ( pPreselectedFilter->GetName().EqualsAscii(pFilterDBase) && lcl_MayBeDBase( rStr ) )
pFilter = pPreselectedFilter;
else if ( bCsvSelected && bMaybeText )
pFilter = pPreselectedFilter;
- else if ( HTMLParser::IsHTMLFormat(aHeader.getStr()) )
+ else if ( bMaybeHtml )
{
// test for HTML
// HTMLParser::IsHTMLFormat() is convinced that
// anything containing a valid HTML tag would
// indeed be HTML, which is a rather idiotic