[Libreoffice-commits] .: Branch 'libreoffice-3-5' - sc/source

Eike Rathke erack at kemper.freedesktop.org
Thu Apr 5 07:39:54 PDT 2012


 sc/source/ui/unoobj/scdetect.cxx |   39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

New commits:
commit c2a26cf9dab637c292e431d5cdf7bab5bbda571d
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Apr 5 02:01:26 2012 +0200

    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 at gmail.com>
    
    Conflicts:
    
    	sc/source/ui/unoobj/scdetect.cxx

diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx
index 9d33f09..556d54f 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;
+                                }
+                            }
                         }
                     }
                 }


More information about the Libreoffice-commits mailing list