sc/source/ui/docshell/docsh.cxx |   28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

New commits:
commit 76fa8d13c5244cf8b1f573e849f4cd2d2347a128
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Feb 6 21:22:56 2022 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Feb 7 06:06:59 2022 +0100

    Simplify the code a bit
    
    Change-Id: I9c35a32dcb877634d885b64ee56099fb8f314a94
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129559
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 1d68cfd1e070..8995aceafdff 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1843,33 +1843,21 @@ void lcl_ScDocShell_GetFixedWidthString( OUString& 
rStr, const ScDocument& rDoc,
     {
         if ( bValue && eHorJust == SvxCellHorJustify::Standard )
             eHorJust = SvxCellHorJustify::Right;
-        sal_Int32 nBlanks = nLen - aString.getLength();
+        OUStringBuffer aTmp(nLen);
         switch ( eHorJust )
         {
             case SvxCellHorJustify::Right:
-            {
-                OUStringBuffer aTmp;
-                comphelper::string::padToLength( aTmp, nBlanks, ' ' );
-                aString = aTmp.append(aString).makeStringAndClear();
-            }
-            break;
+                comphelper::string::padToLength( aTmp, nLen - 
aString.getLength(), ' ' );
+                aString = aTmp.append(aString);
+                break;
             case SvxCellHorJustify::Center:
-            {
-                sal_Int32 nLeftPad = nBlanks / 2;
-                OUStringBuffer aTmp;
-                comphelper::string::padToLength( aTmp, nLeftPad, ' ' );
-                aTmp.append(aString);
-                comphelper::string::padToLength( aTmp, nLen, ' ' );
-                aString = aTmp.makeStringAndClear();
-            }
-            break;
+                comphelper::string::padToLength( aTmp, (nLen - 
aString.getLength()) / 2, ' ' );
+                [[fallthrough]];
             default:
-            {
-                OUStringBuffer aTmp(aString);
+                aTmp.append(aString);
                 comphelper::string::padToLength( aTmp, nLen, ' ' );
-                aString = aTmp.makeStringAndClear();
-            }
         }
+        aString = aTmp.makeStringAndClear();
     }
     rStr = aString;
 }

Reply via email to