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

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Tue Feb 11 11:22:57 UTC 2020


 vcl/source/control/edit.cxx |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 016da11f3643fdce7e8caaf2c1f1e29341f101dd
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Feb 11 10:38:55 2020 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Feb 11 12:22:21 2020 +0100

    Drop some static_cast from long to sal_Int32
    
    ...that would just silently hide overflow in the unexpected case that the given
    long values do not fit into sal_Int32.  (These casts had been carried over in
    3270fc628b2e6a8f73ff0d1e4389d9c7595e0a50 "use OUString(Buffer) in class Edit"
    from the casts to xub_StrLen, aka sal_uInt16, that were present ever since
    8ab086b6cc054501bfbf7ef6fa509c393691e860 "initial import".)
    
    Change-Id: I1775f44d386389f00051f11cc9d1911b10feb427
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88432
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index b3de2be3a68f..40c22f9760e1 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -726,7 +726,7 @@ void Edit::ImplDelete( const Selection& rSelection, sal_uInt8 nDirection, sal_uI
     }
 
     const auto nSelectionMin = aSelection.Min();
-    maText.remove( static_cast<sal_Int32>(nSelectionMin), static_cast<sal_Int32>(aSelection.Len()) );
+    maText.remove( nSelectionMin, aSelection.Len() );
     maSelection.Min() = nSelectionMin;
     maSelection.Max() = nSelectionMin;
     ImplAlignAndPaint();
@@ -790,9 +790,9 @@ void Edit::ImplInsertText( const OUString& rStr, const Selection* pNewSel, bool
     ImplClearLayoutData();
 
     if ( aSelection.Len() )
-        maText.remove( static_cast<sal_Int32>(aSelection.Min()), static_cast<sal_Int32>(aSelection.Len()) );
+        maText.remove( aSelection.Min(), aSelection.Len() );
     else if (!mbInsertMode && aSelection.Max() < maText.getLength())
-        maText.remove( static_cast<sal_Int32>(aSelection.Max()), 1 );
+        maText.remove( aSelection.Max(), 1 );
 
     // take care of input-sequence-checking now
     if (bIsUserInput && !rStr.isEmpty())
@@ -812,7 +812,7 @@ void Edit::ImplInsertText( const OUString& rStr, const Selection* pNewSel, bool
         if (bIsInputSequenceChecking && (xISC = ImplGetInputSequenceChecker()).is())
         {
             sal_Unicode cChar = rStr[0];
-            sal_Int32 nTmpPos = static_cast< sal_Int32 >( aSelection.Min() );
+            sal_Int32 nTmpPos = aSelection.Min();
             sal_Int16 nCheckMode = officecfg::Office::Common::I18N::CTL::CTLSequenceCheckingRestricted::get()?
                     i18n::InputSequenceCheckMode::STRICT : i18n::InputSequenceCheckMode::BASIC;
 
@@ -859,7 +859,7 @@ void Edit::ImplInsertText( const OUString& rStr, const Selection* pNewSel, bool
     }
 
     if ( !aNewText.isEmpty() )
-        maText.insert( static_cast<sal_Int32>(aSelection.Min()), aNewText );
+        maText.insert( aSelection.Min(), aNewText );
 
     if ( !pNewSel )
     {
@@ -2018,7 +2018,7 @@ void Edit::Command( const CommandEvent& rCEvt )
     else if ( rCEvt.GetCommand() == CommandEventId::StartExtTextInput )
     {
         DeleteSelected();
-        sal_Int32 nPos = static_cast<sal_Int32>(maSelection.Max());
+        sal_Int32 nPos = maSelection.Max();
         mpIMEInfos.reset(new Impl_IMEInfos( nPos, OUString(maText.getStr() + nPos ) ));
         mpIMEInfos->bWasCursorOverwrite = !IsInsertMode();
     }


More information about the Libreoffice-commits mailing list