diff options
author | Eike Rathke <erack@redhat.com> | 2012-04-05 02:01:26 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2012-04-05 16:39:44 +0200 |
commit | c2a26cf9dab637c292e431d5cdf7bab5bbda571d (patch) | |
tree | 975bdb65dc1792b06be8fb0c9aa81f9d52c960d5 | |
parent | 37c1a9fde189f3010eec7392c44404e403555c52 (diff) |
resolved fdo#40021 CSV import got confused by erroneous HTML detection
HTMLParser::IsHTMLFormat() is convinced that anything containing a valid HTML
tag would indeed be HTML, which is a rather idiotic assumption for us in the
case of "foo <br> bar" with a preselected CSV filter. So keep this detection to
the end.
The original order where preselected CSV had precedence over others was changed
with 9f1cc58c20ee365ff2a158ad69c1091e6ad11ac6
(cherry picked from commit a5eadc6aaafec92df23c57e258882a2c98ece0ad)
Signed-off-by: Kohei Yoshida <kohei.yoshida@gmail.com>
Conflicts:
sc/source/ui/unoobj/scdetect.cxx
-rw-r--r-- | sc/source/ui/unoobj/scdetect.cxx | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx index 9d33f09eca2f..556d54fc6e68 100644 --- a/sc/source/ui/unoobj/scdetect.cxx +++ b/sc/source/ui/unoobj/scdetect.cxx @@ -729,6 +729,7 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream ) // further checks for filters only if they are preselected: ASCII, HTML, RTF, DBase // without the preselection other filters (Writer) take precedence // DBase can't be detected reliably, so it also needs preselection + bool bMaybeText = lcl_MayBeAscii( rStr ); // get file header @@ -736,21 +737,7 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream ) const sal_Size nTrySize = 80; ByteString aHeader = read_uInt8s_AsOString(rStr, nTrySize); - if ( HTMLParser::IsHTMLFormat( aHeader.GetBuffer() ) ) - { - // test for HTML - if ( pPreselectedFilter->GetName().EqualsAscii(pFilterHtml) ) - { - pFilter = pPreselectedFilter; - } - else - { - pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterHtmlWeb) ); - if ( bIsXLS ) - bFakeXLS = true; - } - } - else if ( aHeader.CompareTo( "{\\rtf", 5 ) == COMPARE_EQUAL ) + if ( aHeader.CompareTo( "{\\rtf", 5 ) == COMPARE_EQUAL ) { // test for RTF pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterRtf) ); @@ -769,6 +756,28 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream ) pFilter = pPreselectedFilter; else if ( pPreselectedFilter->GetFilterName().EqualsAscii(pFilterAscii) && bMaybeText ) pFilter = pPreselectedFilter; + else if ( HTMLParser::IsHTMLFormat( aHeader.GetBuffer() ) ) + { + // test for HTML + + // HTMLParser::IsHTMLFormat() is convinced that + // anything containing a valid HTML tag would + // indeed be HTML, which is a rather idiotic + // assumption for us in the case of + // "foo <br> bar" with a preselected CSV + // filter. So keep this detection to the end. + + if ( pPreselectedFilter->GetName().EqualsAscii(pFilterHtml) ) + { + pFilter = pPreselectedFilter; + } + else + { + pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterHtmlWeb) ); + if ( bIsXLS ) + bFakeXLS = true; + } + } } } } |