summaryrefslogtreecommitdiff
path: root/sw/source/core/doc/extinput.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/doc/extinput.cxx')
-rw-r--r--sw/source/core/doc/extinput.cxx30
1 files changed, 22 insertions, 8 deletions
diff --git a/sw/source/core/doc/extinput.cxx b/sw/source/core/doc/extinput.cxx
index e9076064a745..b72a78ca6635 100644
--- a/sw/source/core/doc/extinput.cxx
+++ b/sw/source/core/doc/extinput.cxx
@@ -59,7 +59,12 @@ SwExtTextInput::~SwExtTextInput()
{
// Prevent IME edited text being grouped with non-IME edited text.
bool bKeepGroupUndo = pDoc->GetIDocumentUndoRedo().DoesGroupUndo();
- pDoc->GetIDocumentUndoRedo().DoGroupUndo(false);
+ bool bWasIME = pDoc->GetIDocumentUndoRedo().GetUndoActionCount() == 0 || pDoc->getIDocumentContentOperations().GetIME();
+ if (!bWasIME)
+ {
+ pDoc->GetIDocumentUndoRedo().DoGroupUndo(false);
+ }
+ pDoc->getIDocumentContentOperations().SetIME(true);
if( nEndCnt < nSttCnt )
{
std::swap(nSttCnt, nEndCnt);
@@ -100,14 +105,24 @@ SwExtTextInput::~SwExtTextInput()
}
else
{
- pTNd->EraseText( rIdx, nEndCnt - nSttCnt );
+ // 1. Insert text at start position with EMPTYEXPAND to use correct formatting
+ // ABC<NEW><OLD>
+ // 2. Then remove old (not tracked) content
+ // ABC<NEW>
+
+ sal_Int32 nLenghtOfOldString = nEndCnt - nSttCnt;
if( bInsText )
- {
- pDoc->getIDocumentContentOperations().InsertString( *this, sText );
- }
+ pDoc->getIDocumentContentOperations().InsertString( *this, sText, SwInsertFlags::EMPTYEXPAND );
+
+ rIdx = nEndCnt;
+
+ pTNd->EraseText( rIdx, nLenghtOfOldString );
+ }
+ if (!bWasIME)
+ {
+ pDoc->GetIDocumentUndoRedo().DoGroupUndo(bKeepGroupUndo);
}
- pDoc->GetIDocumentUndoRedo().DoGroupUndo(bKeepGroupUndo);
if (eInputLanguage != LANGUAGE_DONTKNOW)
{
sal_uInt16 nWhich = RES_CHRATR_LANGUAGE;
@@ -190,8 +205,7 @@ void SwExtTextInput::SetInputData( const CommandExtTextInputData& rData )
pTNd->EraseText( aIdx, nEndCnt - nSttCnt );
}
- pTNd->InsertText( rNewStr, aIdx,
- SwInsertFlags::EMPTYEXPAND );
+ pTNd->InsertText( rNewStr, aIdx, SwInsertFlags::NOHINTEXPAND );
if( !HasMark() )
SetMark();
}