[PATCH libreoffice-4-0] we need a reference to the DifParser.aData, fdo#64920

Markus Mohrhard (via Code Review) gerrit at gerrit.libreoffice.org
Mon May 27 06:09:46 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/4054

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/54/4054/1

we need a reference to the DifParser.aData, fdo#64920

regression from 6191fa0847ac5b27083efe1a8c6cd84d080a638c

Change-Id: If7fc18e7d0bcbf1075a0ecdb1c0dcf3d207f1bda
---
M sc/source/filter/dif/difimp.cxx
M sc/source/filter/inc/dif.hxx
2 files changed, 12 insertions(+), 26 deletions(-)



diff --git a/sc/source/filter/dif/difimp.cxx b/sc/source/filter/dif/difimp.cxx
index 4487915..dfc68a3 100644
--- a/sc/source/filter/dif/difimp.cxx
+++ b/sc/source/filter/dif/difimp.cxx
@@ -61,7 +61,7 @@
     sal_Bool        bSyntErrWarn = false;
     sal_Bool        bOverflowWarn = false;
 
-    rtl::OUString   aData = aDifParser.aData;
+    rtl::OUString&   aData = aDifParser.aData;
     sal_Bool        bData = false;
 
     rIn.Seek( 0 );
@@ -372,7 +372,7 @@
                 if( aLine.getLength() > 2 )
                     aData = aLine.copy( 1, aLine.getLength() - 2 );
                 else
-                    aData.Erase();
+                    aData = OUString();
                 eS = S_END;
                 break;
             case S_END:
@@ -395,20 +395,14 @@
 }
 
 
-static void lcl_DeEscapeQuotesDif( String& rString )
+static void lcl_DeEscapeQuotesDif( OUString& rString )
 {
     //  Special handling for DIF import: Escaped (duplicated) quotes are resolved.
     //  Single quote characters are left in place because older versions didn't
     //  escape quotes in strings (and Excel doesn't when using the clipboard).
     //  The quotes around the string are removed before this function is called.
 
-    static const sal_Unicode aDQ[] = { '"', '"', 0 };
-    xub_StrLen nPos = 0;
-    while ( (nPos = rString.Search( aDQ, nPos )) != STRING_NOTFOUND )
-    {
-        rString.Erase( nPos, 1 );
-        ++nPos;
-    }
+    rString = rString.replaceAll("\"\"", "\"");
 }
 
 // Determine if passed in string is numeric data and set fVal/nNumFormat if so
@@ -528,18 +522,14 @@
                 ReadNextLine( aTmpLine );
                 if ( eRet == D_SYNT_ERROR )
                 {   // for broken records write "#ERR: data" to cell
-                    String aTmp( RTL_CONSTASCII_USTRINGPARAM( "#ERR: " ));
-                    aTmp += pAktBuffer;
-                    aTmp.AppendAscii( " (" );
-                    OSL_ENSURE( aTmpLine.getLength() <= STRING_MAXLEN - aTmp.Len() - 1, "GetNextDataset(): line doesn't fit into data");
-                    aTmp += aTmpLine;
-                    aTmp += sal_Unicode(')');
-                    aData = aTmp;
+                    OUStringBuffer aTmp("#ERR: ");
+                    aTmp.append(pAktBuffer).append(" (");
+                    aTmp.append(aTmpLine).append(')');
+                    aData = aTmp.makeStringAndClear();
                     eRet = D_STRING;
                 }
                 else
                 {
-                    OSL_ENSURE( aTmpLine.getLength() <= STRING_MAXLEN, "GetNextDataset(): line doesn't fit into data");
                     aData = aTmpLine;
                 }
             }
@@ -561,7 +551,6 @@
                         // Single line string
                         if( nLineLength >= 2 && pLine[nLineLength - 1] == '"' )
                         {
-                            OSL_ENSURE( aLine.getLength() - 2 <= STRING_MAXLEN, "GetNextDataset(): line doesn't fit into data");
                             aData = aLine.copy( 1, nLineLength - 2 );
                             lcl_DeEscapeQuotesDif( aData );
                             eRet = D_STRING;
@@ -570,12 +559,11 @@
                     else
                     {
                         // Multiline string
-                        OSL_ENSURE( aLine.getLength() - 1 <= STRING_MAXLEN, "GetNextDataset(): line doesn't fit into data");
                         aData = aLine.copy( 1 );
                         bool bContinue = true;
                         while ( bContinue )
                         {
-                            aData.Append( '\n' );
+                            aData = aData + "\n";
                             bContinue = !rIn.IsEof() && ReadNextLine( aLine );
                             if( bContinue )
                             {
@@ -586,13 +574,11 @@
                                     bContinue = !LookAhead();
                                     if( bContinue )
                                     {
-                                        OSL_ENSURE( aLine.getLength() <= STRING_MAXLEN - aData.Len(), "GetNextDataset(): line doesn't fit into data");
-                                        aData.Append( aLine );
+                                        aData = aData + aLine;
                                     }
                                     else if( pLine[nLineLength - 1] == '"' )
                                     {
-                                        OSL_ENSURE( nLineLength - 1 <= STRING_MAXLEN - aData.Len(), "GetNextDataset(): line doesn't fit into data");
-                                        aData.Append( pLine, nLineLength - 1 );
+                                        aData = aData + aLine.copy(0, nLineLength -1 );
                                         lcl_DeEscapeQuotesDif( aData );
                                         eRet = D_STRING;
                                     }
diff --git a/sc/source/filter/inc/dif.hxx b/sc/source/filter/inc/dif.hxx
index a8a0a56..da31ae3 100644
--- a/sc/source/filter/inc/dif.hxx
+++ b/sc/source/filter/inc/dif.hxx
@@ -62,7 +62,7 @@
 class DifParser
 {
 public:
-    String              aData;
+    OUString              aData;
     double              fVal;
     sal_uInt32              nVector;
     sal_uInt32              nVal;

-- 
To view, visit https://gerrit.libreoffice.org/4054
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If7fc18e7d0bcbf1075a0ecdb1c0dcf3d207f1bda
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Markus Mohrhard <markus.mohrhard at googlemail.com>



More information about the LibreOffice mailing list