sc/source/ui/unoobj/scdetect.cxx | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-)
New commits: commit a5eadc6aaafec92df23c57e258882a2c98ece0ad Author: Eike Rathke <er...@redhat.com> Date: Thu Apr 5 02:01:26 2012 +0200 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 diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx index 1fb1a84..0efb037 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 _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits