summaryrefslogtreecommitdiff
path: root/vcl/source/control/edit.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-08-27 17:37:10 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-08-28 23:09:14 +0200
commit5e9d24f08551c06a20aa01408eb708c813fe20c4 (patch)
tree3a632196284627e2c0a900d9a589ff765ae8e0d3 /vcl/source/control/edit.cxx
parente0452c6530710737c70b12faa1b8b7f0ed0aed68 (diff)
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@redhat.com>
Diffstat (limited to 'vcl/source/control/edit.cxx')
-rw-r--r--vcl/source/control/edit.cxx11
1 files changed, 8 insertions, 3 deletions
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 )