summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2015-09-08 07:29:38 +0800
committerAndras Timar <andras.timar@collabora.com>2015-10-02 14:58:35 +0200
commitda08a8f277b6a7f0f0a96715a8dac8fadc87258c (patch)
tree11dfcc6260daa77c4230ec4ed1c2e47d06e8a673
parent14bb5cc67c73d620262ae1fc595cd2c9d1ee644f (diff)
Fix tdf#87500 - Freeze with English/Japanese mixture undo.
Language poolitem will be inserted after user completes editing with IME, making it refer to valid range when undo. Reviewed-on: https://gerrit.libreoffice.org/18392 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> Conflicts: sw/source/core/doc/extinput.cxx Change-Id: Id2876aa74dba6f7d134b8e2df4d9b36a8f429bb1 Reviewed-on: https://gerrit.libreoffice.org/18894 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/source/core/doc/extinput.cxx43
1 files changed, 25 insertions, 18 deletions
diff --git a/sw/source/core/doc/extinput.cxx b/sw/source/core/doc/extinput.cxx
index f7109fa2765c..73a3135fd6c3 100644
--- a/sw/source/core/doc/extinput.cxx
+++ b/sw/source/core/doc/extinput.cxx
@@ -59,6 +59,9 @@ SwExtTextInput::~SwExtTextInput()
sal_Int32 nEndCnt = GetMark()->nContent.GetIndex();
if( nEndCnt != nSttCnt )
{
+ // Prevent IME edited text being grouped with non-IME edited text.
+ bool bKeepGroupUndo = pDoc->GetIDocumentUndoRedo().DoesGroupUndo();
+ pDoc->GetIDocumentUndoRedo().DoGroupUndo(false);
if( nEndCnt < nSttCnt )
{
std::swap(nSttCnt, nEndCnt);
@@ -66,24 +69,6 @@ SwExtTextInput::~SwExtTextInput()
// In order to get Undo/Redlining etc. working correctly,
// we need to go through the Doc interface
- if(eInputLanguage != LANGUAGE_DONTKNOW)
- {
- // #i41974# Only set language attribute
- // for CJK/CTL scripts.
- bool bLang = true;
- sal_uInt16 nWhich = RES_CHRATR_LANGUAGE;
- switch(GetI18NScriptTypeOfLanguage(eInputLanguage))
- {
- case i18n::ScriptType::ASIAN: nWhich = RES_CHRATR_CJK_LANGUAGE; break;
- case i18n::ScriptType::COMPLEX: nWhich = RES_CHRATR_CTL_LANGUAGE; break;
- default: bLang = false;
- }
- if ( bLang )
- {
- SvxLanguageItem aLangItem( eInputLanguage, nWhich );
- pDoc->getIDocumentContentOperations().InsertPoolItem(*this, aLangItem, 0 );
- }
- }
rIdx = nSttCnt;
const OUString sTxt( pTNd->GetTxt().copy(nSttCnt, nEndCnt - nSttCnt));
if( bIsOverwriteCursor && !sOverwriteText.isEmpty() )
@@ -124,6 +109,28 @@ SwExtTextInput::~SwExtTextInput()
pDoc->getIDocumentContentOperations().InsertString( *this, sTxt );
}
}
+ pDoc->GetIDocumentUndoRedo().DoGroupUndo(bKeepGroupUndo);
+ if (eInputLanguage != LANGUAGE_DONTKNOW)
+ {
+ sal_uInt16 nWhich = RES_CHRATR_LANGUAGE;
+ sal_Int16 nScriptType = GetI18NScriptTypeOfLanguage(eInputLanguage);
+ switch(nScriptType)
+ {
+ case i18n::ScriptType::ASIAN:
+ nWhich = RES_CHRATR_CJK_LANGUAGE; break;
+ case i18n::ScriptType::COMPLEX:
+ nWhich = RES_CHRATR_CTL_LANGUAGE; break;
+ }
+ // #i41974# Only set language attribute for CJK/CTL scripts.
+ if (RES_CHRATR_LANGUAGE != nWhich && pTNd->GetLang( nSttCnt, nEndCnt-nSttCnt, nScriptType) != eInputLanguage)
+ {
+ SvxLanguageItem aLangItem( eInputLanguage, nWhich );
+ rIdx = nSttCnt;
+ GetMark()->nContent = nEndCnt;
+ pDoc->getIDocumentContentOperations().InsertPoolItem(*this, aLangItem, 0 );
+ }
+
+ }
}
}
}