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

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 28 21:10:00 UTC 2020


 vcl/source/control/edit.cxx |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 5e9d24f08551c06a20aa01408eb708c813fe20c4
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Aug 27 17:37:10 2020 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Aug 28 23:09:14 2020 +0200

    Simplify some operations involving OUString and OUStringBuffer
    
    Change-Id: Ic6e3357bb857c46a2bd117ea213b2644b96131d7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101569
    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 8d8bb1b43276..f90a7f0bd8ed 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -65,6 +65,7 @@
 
 #include <algorithm>
 #include <memory>
+#include <string_view>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -895,7 +896,8 @@ void Edit::ImplSetText( const OUString& rText, const Selection* pNewSelection )
 {
     // we delete text by "selecting" the old text completely then calling InsertText; this is flicker free
     if ( ( rText.getLength() > mnMaxTextLen ) ||
-         ( rText == maText.getStr() && (!pNewSelection || (*pNewSelection == maSelection)) ) )
+         ( std::u16string_view(rText) == std::u16string_view(maText.getStr(), maText.getLength())
+           && (!pNewSelection || (*pNewSelection == maSelection)) ) )
         return;
 
     ImplClearLayoutData();
@@ -1969,7 +1971,10 @@ void Edit::Command( const CommandEvent& rCEvt )
         pPopup->EnableItem(pPopup->GetItemId("delete"), bEnableDelete);
         pPopup->EnableItem(pPopup->GetItemId("paste"), bEnablePaste);
         pPopup->EnableItem(pPopup->GetItemId("specialchar"), bEnableSpecialChar);
-        pPopup->EnableItem(pPopup->GetItemId("undo"), maUndoText != maText.getStr());
+        pPopup->EnableItem(
+            pPopup->GetItemId("undo"),
+            std::u16string_view(maUndoText)
+                != std::u16string_view(maText.getStr(), maText.getLength()));
         bool bAllSelected = maSelection.Min() == 0 && maSelection.Max() == maText.getLength();
         pPopup->EnableItem(pPopup->GetItemId("selectall"), !bAllSelected);
         pPopup->ShowItem(pPopup->GetItemId("specialchar"), pImplFncGetSpecialChars != nullptr);
@@ -2031,7 +2036,7 @@ void Edit::Command( const CommandEvent& rCEvt )
     {
         DeleteSelected();
         sal_Int32 nPos = maSelection.Max();
-        mpIMEInfos.reset(new Impl_IMEInfos( nPos, OUString(maText.getStr() + nPos ) ));
+        mpIMEInfos.reset(new Impl_IMEInfos( nPos, maText.copy(nPos).makeStringAndClear() ));
         mpIMEInfos->bWasCursorOverwrite = !IsInsertMode();
     }
     else if ( rCEvt.GetCommand() == CommandEventId::EndExtTextInput )


More information about the Libreoffice-commits mailing list