summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-12-17 13:19:28 +0100
committerAshod Nakashian <ash@collabora.com>2022-01-23 16:51:28 +0100
commitde3db2fdce1ee20db65a0275e987ce32d94f2cfd (patch)
treea161bf78342444d59101d9f67d0b8f1b90a2f957 /sw/source
parent74a04d020dc1215b2008afd84d57a91115b9a90a (diff)
tdf#146728 lok: IME: preset formatting in the new paragraph
When we wrote something using Heading or Title style and then moved to the next paragraph by pressing enter we should get "Text Body" style in the new line. Do not copy style. Use NOHINTEXPAND when inserting initially so we can use EMPTYEXPAND later - at the end of composing - and use correct styling. followup for: lok: IME: directly copy formatting for inserted text d8dbd123bfa7f39489ceb15ac83142635531fd43 https://cgit.freedesktop.org/libreoffice/core/commit/?id=d8dbd123bfa7f39489ceb15ac83142635531fd43 Change-Id: I55b764068337e125eea3fba641edb6486b2ac9d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127875 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Ashod Nakashian <ash@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/doc/extinput.cxx19
1 files changed, 8 insertions, 11 deletions
diff --git a/sw/source/core/doc/extinput.cxx b/sw/source/core/doc/extinput.cxx
index 500f5d157b6c..a9b89ed93b9d 100644
--- a/sw/source/core/doc/extinput.cxx
+++ b/sw/source/core/doc/extinput.cxx
@@ -107,20 +107,17 @@ SwExtTextInput::~SwExtTextInput()
}
else
{
- // we need to keep correct formatting
- // ie. when we erase first, then we will lost information about format
+ // 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( m_bInsText )
- {
- rDoc.getIDocumentContentOperations().InsertString( *this, sText );
+ rDoc.getIDocumentContentOperations().InsertString( *this, sText, SwInsertFlags::EMPTYEXPAND );
- // Copy formatting to the inserted string
- SfxItemSet aSet(pTNd->GetDoc().GetAttrPool(), aCharFormatSetRange);
- pTNd->GetParaAttr( aSet, nSttCnt + nLenghtOfOldString, nEndCnt + nLenghtOfOldString );
- pTNd->SetAttr( aSet, nSttCnt, nEndCnt );
- }
+ rIdx = nEndCnt;
pTNd->EraseText( rIdx, nLenghtOfOldString );
}
@@ -208,8 +205,8 @@ void SwExtTextInput::SetInputData( const CommandExtTextInputData& rData )
pTNd->EraseText( aIdx, nEndCnt - nSttCnt );
}
- pTNd->InsertText( rNewStr, aIdx,
- SwInsertFlags::EMPTYEXPAND );
+ // NOHINTEXPAND so we can use correct formatting in desctructor when we finish composing
+ pTNd->InsertText( rNewStr, aIdx, SwInsertFlags::NOHINTEXPAND );
if( !HasMark() )
SetMark();
}