[Libreoffice-commits] core.git: sc/source

Eike Rathke erack at redhat.com
Thu Oct 10 08:18:40 PDT 2013


 sc/source/ui/dbgui/csvgrid.cxx |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 68568d78093c37e5848a19d5eabee163117f7625
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Oct 10 17:16:00 2013 +0200

    fixed !!br0ken CSV import preview
    
    Regression introduced with 24c079605645cf29ba366ca39b7c1177da8b317f
    Previous String ctor accepted length > string length, whereas
    OUString::copy() does not.
    
    Change-Id: If51e6df4e236a59ab0302d2bb683ca8e6d148bd0

diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx
index 2fdf462..bc3f4a2 100644
--- a/sc/source/ui/dbgui/csvgrid.cxx
+++ b/sc/source/ui/dbgui/csvgrid.cxx
@@ -1152,15 +1152,16 @@ void ScCsvGrid::ImplDrawColumnBackgr( sal_uInt32 nColIndex )
     // #i67432# cut string to avoid edit engine performance problems with very large strings
     sal_Int32 nFirstVisPos = ::std::max( GetColumnPos( nColIndex ), GetFirstVisPos() );
     sal_Int32 nLastVisPos = ::std::min( GetColumnPos( nColIndex + 1 ), GetLastVisPos() );
-    xub_StrLen nStrPos = static_cast< xub_StrLen >( nFirstVisPos - GetColumnPos( nColIndex ) );
-    xub_StrLen nStrLen = static_cast< xub_StrLen >( nLastVisPos - nFirstVisPos + 1 );
+    sal_Int32 nStrPos = nFirstVisPos - GetColumnPos( nColIndex );
+    sal_Int32 nStrLen = nLastVisPos - nFirstVisPos + 1;
     sal_Int32 nStrX = GetX( nFirstVisPos );
     for( size_t nLine = 0; nLine < nLineCount; ++nLine )
     {
         StringVec& rStrVec = maTexts[ nLine ];
         if( (nColIndex < rStrVec.size()) && (rStrVec[ nColIndex ].getLength() > nStrPos) )
         {
-            OUString aText = rStrVec[ nColIndex ].copy( nStrPos, nStrLen );
+            const OUString& rStr = rStrVec[ nColIndex ];
+            OUString aText = rStr.copy( nStrPos, ::std::min( nStrLen, rStr.getLength()) - nStrPos );
             ImplDrawCellText( Point( nStrX, GetY( GetFirstVisLine() + nLine ) ), aText );
         }
     }


More information about the Libreoffice-commits mailing list