diff options
author | Eike Rathke <erack@redhat.com> | 2012-04-05 02:01:26 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2012-04-05 02:01:26 +0200 |
commit | a5eadc6aaafec92df23c57e258882a2c98ece0ad (patch) | |
tree | 8d467e40fd84fda595666bbe88a55507c1ab17a3 /sc/source/ui/unoobj/scdetect.cxx | |
parent | 09d98dfe89a651c1b33a07c3d23e20b266d163e7 (diff) |
resolved fdo#40021 don't let CSV import get 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
Diffstat (limited to '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 1fb1a8444137..0efb037f0a02 100644 --- a/sc/source/ui/unoobj/scdetect.cxx +++ b/sc/source/ui/unoobj/scdetect.cxx @@ -734,6 +734,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 @@ -741,21 +742,7 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream ) const sal_Size nTrySize = 80; rtl::OString aHeader = read_uInt8s_ToOString(rStr, nTrySize); - if ( HTMLParser::IsHTMLFormat(aHeader.getStr()) ) - { - // test for HTML - if ( pPreselectedFilter->GetName().EqualsAscii(pFilterHtml) ) - { - pFilter = pPreselectedFilter; - } - else - { - pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterHtmlWeb) ); - if ( bIsXLS ) - bFakeXLS = true; - } - } - else if ( aHeader.copy(0, 5).equalsL("{\\rtf", 5) ) + if ( aHeader.copy(0, 5).equalsL("{\\rtf", 5) ) { // test for RTF pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterRtf) ); @@ -774,6 +761,28 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream ) pFilter = pPreselectedFilter; else if ( pPreselectedFilter->GetFilterName().EqualsAscii(pFilterAscii) && bMaybeText ) pFilter = pPreselectedFilter; + else if ( HTMLParser::IsHTMLFormat(aHeader.getStr()) ) + { + // 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; + } + } } } else |