editeng/source/editeng/editeng.cxx | 15 +++++++++++++-- editeng/source/editeng/editview.cxx | 7 ++++++- editeng/source/editeng/impedit.hxx | 2 +- editeng/source/editeng/impedit5.cxx | 6 +++--- editeng/source/editeng/textconv.cxx | 2 +- include/editeng/editdata.hxx | 2 ++ include/editeng/editeng.hxx | 1 + include/editeng/editview.hxx | 1 + translations | 2 +- 9 files changed, 29 insertions(+), 9 deletions(-)
New commits: commit 5b74b3322fd51cf075eb0c218b3adb786a28b4c9 Author: Mark Hung <mark...@gmail.com> AuthorDate: Mon Oct 19 00:07:34 2020 +0800 Commit: Mark Hung <mark...@gmail.com> CommitDate: Fri Oct 23 15:36:22 2020 +0200 tdf#104378: don't reset para attributes while converting Chinese characters. In TextConvWrapper::ChangeText_impl, calls to EditView::RemoveAttribs() reset the paragraph attributes. That makes SvxLanguageItem of EE_CHAR_LANGUAGE_CJK become LANGUAGE_DONTKNOW. Hence it always stops converting after the first success. This patch overload EditView::RemoveAttribs() so that it is possible to clear all character attributes of the selction without touching paragraph attributes. Before, bRemoveParaAttribs either removes items between EE_ITEMS_START and EE_CHAR_END, or removes items between EE_CHAR_START and EE_CHAR_END. The patch add a new enum class EERemoveParaAttribsMode, with the following values: 1. RemoveAll : correspond to the old bRemoveParaAttribs = true 2. RemoveCharItems: correspond to the old bRemoveParaAttribs = false 3. RemoveNone: new thing for "don't touch para attributes." Change-Id: I5132e708dea9e2066f13f1b001bd954d7b477f56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104484 Tested-by: Jenkins Reviewed-by: Mark Hung <mark...@gmail.com> diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 91bb8217ec3f..da9520aae81a 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -754,7 +754,15 @@ void EditEngine::RemoveCharAttribs(sal_Int32 nPara, sal_uInt16 nWhich, bool bRem void EditEngine::RemoveCharAttribs(const EditSelection& rSel, bool bRemoveParaAttribs, sal_uInt16 nWhich) { - pImpEditEngine->RemoveCharAttribs(rSel, bRemoveParaAttribs, nWhich); + const EERemoveParaAttribsMode eMode = bRemoveParaAttribs? + EERemoveParaAttribsMode::RemoveAll : + EERemoveParaAttribsMode::RemoveCharItems; + pImpEditEngine->RemoveCharAttribs(rSel, eMode, nWhich); +} + +void EditEngine::RemoveCharAttribs(const EditSelection& rSel, EERemoveParaAttribsMode eMode, sal_uInt16 nWhich) +{ + pImpEditEngine->RemoveCharAttribs(rSel, eMode, nWhich); } EditEngine::ViewsType& EditEngine::GetEditViews() @@ -1770,10 +1778,13 @@ SfxItemSet EditEngine::GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int32 void EditEngine::RemoveAttribs( const ESelection& rSelection, bool bRemoveParaAttribs, sal_uInt16 nWhich ) { + const EERemoveParaAttribsMode eMode = bRemoveParaAttribs? + EERemoveParaAttribsMode::RemoveAll : + EERemoveParaAttribsMode::RemoveCharItems; pImpEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS ); EditSelection aSel( pImpEditEngine->ConvertSelection( rSelection.nStartPara, rSelection.nStartPos, rSelection.nEndPara, rSelection.nEndPos ) ); - pImpEditEngine->RemoveCharAttribs( aSel, bRemoveParaAttribs, nWhich ); + pImpEditEngine->RemoveCharAttribs( aSel, eMode, nWhich ); pImpEditEngine->UndoActionEnd(); pImpEditEngine->FormatAndUpdate(); } diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index f13a67870902..94012cf70651 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -568,10 +568,15 @@ void EditView::RemoveAttribsKeepLanguages( bool bRemoveParaAttribs ) void EditView::RemoveAttribs( bool bRemoveParaAttribs, sal_uInt16 nWhich ) { + RemoveAttribs(bRemoveParaAttribs ? EERemoveParaAttribsMode::RemoveAll + : EERemoveParaAttribsMode::RemoveCharItems, nWhich); +} +void EditView::RemoveAttribs( EERemoveParaAttribsMode eMode, sal_uInt16 nWhich ) +{ pImpEditView->DrawSelectionXOR(); pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS ); - pImpEditView->pEditEngine->RemoveCharAttribs( pImpEditView->GetEditSelection(), bRemoveParaAttribs, nWhich ); + pImpEditView->pEditEngine->RemoveCharAttribs( pImpEditView->GetEditSelection(), eMode, nWhich ); pImpEditView->pEditEngine->UndoActionEnd(); pImpEditView->pEditEngine->FormatAndUpdate( this ); } diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 9ab6c7fdfe88..921c0dfe5498 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -900,7 +900,7 @@ public: SfxItemSet GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, GetAttribsFlags nFlags = GetAttribsFlags::ALL ) const; SfxItemSet GetAttribs( EditSelection aSel, EditEngineAttribs nOnlyHardAttrib = EditEngineAttribs::All ); void SetAttribs( EditSelection aSel, const SfxItemSet& rSet, SetAttribsMode nSpecial = SetAttribsMode::NONE ); - void RemoveCharAttribs( EditSelection aSel, bool bRemoveParaAttribs, sal_uInt16 nWhich ); + void RemoveCharAttribs( EditSelection aSel, EERemoveParaAttribsMode eMode, sal_uInt16 nWhich ); void RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich = 0, bool bRemoveFeatures = false ); void SetFlatMode( bool bFlat ); diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx index b871247fa70d..248d78455dc4 100644 --- a/editeng/source/editeng/impedit5.cxx +++ b/editeng/source/editeng/impedit5.cxx @@ -577,13 +577,13 @@ void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, SetA } } -void ImpEditEngine::RemoveCharAttribs( EditSelection aSel, bool bRemoveParaAttribs, sal_uInt16 nWhich ) +void ImpEditEngine::RemoveCharAttribs( EditSelection aSel, EERemoveParaAttribsMode eMode, sal_uInt16 nWhich ) { aSel.Adjust( aEditDoc ); sal_Int32 nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() ); sal_Int32 nEndNode = aEditDoc.GetPos( aSel.Max().GetNode() ); - + bool bRemoveParaAttribs = eMode == EERemoveParaAttribsMode::RemoveAll; const SfxItemSet* _pEmptyItemSet = bRemoveParaAttribs ? &GetEmptyItemSet() : nullptr; if ( IsUndoEnabled() && !IsInUndo() && aStatus.DoUndoAttribs() ) @@ -614,7 +614,7 @@ void ImpEditEngine::RemoveCharAttribs( EditSelection aSel, bool bRemoveParaAttri { SetParaAttribs( nNode, *_pEmptyItemSet ); // Invalidated } - else + else if (eMode == EERemoveParaAttribsMode::RemoveCharItems) { // For 'Format-Standard' also the character attributes should // disappear, which were set as paragraph attributes by the diff --git a/editeng/source/editeng/textconv.cxx b/editeng/source/editeng/textconv.cxx index ed08c698f5e6..3caa1124ce2b 100644 --- a/editeng/source/editeng/textconv.cxx +++ b/editeng/source/editeng/textconv.cxx @@ -515,7 +515,7 @@ void TextConvWrapper::ChangeText_impl( const OUString &rNewText, bool bKeepAttri // all attributes now. (Those attributes that may take effect left // to the position where the new text gets inserted after the old text // was deleted) - m_pEditView->RemoveAttribs(); + m_pEditView->RemoveAttribs(EERemoveParaAttribsMode::RemoveNone, 0); // apply saved attributes to new inserted text m_pEditView->SetAttribs( aSet ); } diff --git a/include/editeng/editdata.hxx b/include/editeng/editdata.hxx index 8d3d39591a42..40c74cb2b8c6 100644 --- a/include/editeng/editdata.hxx +++ b/include/editeng/editdata.hxx @@ -42,6 +42,8 @@ enum class EEAnchorMode { VCenterLeft, VCenterHCenter, VCenterRight, BottomLeft, BottomHCenter, BottomRight }; +enum class EERemoveParaAttribsMode { RemoveAll, RemoveCharItems, RemoveNone }; + #define EE_PARA_NOT_FOUND SAL_MAX_INT32 #define EE_PARA_APPEND SAL_MAX_INT32 #define EE_PARA_ALL SAL_MAX_INT32 diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index 871acf2f43b5..575e43d49e3f 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -609,6 +609,7 @@ public: void RemoveCharAttribs(sal_Int32 nPara, sal_uInt16 nWhich = 0, bool bRemoveFeatures = false); void RemoveCharAttribs(const EditSelection& rSel, bool bRemoveParaAttribs, sal_uInt16 nWhich); + void RemoveCharAttribs(const EditSelection& rSel, EERemoveParaAttribsMode eMode, sal_uInt16 nWhich); ViewsType& GetEditViews(); const ViewsType& GetEditViews() const; diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx index a449eff4b742..f75b5ca1228b 100644 --- a/include/editeng/editview.hxx +++ b/include/editeng/editview.hxx @@ -240,6 +240,7 @@ public: SfxItemSet GetAttribs(); void SetAttribs( const SfxItemSet& rSet ); void RemoveAttribs( bool bRemoveParaAttribs = false, sal_uInt16 nWhich = 0 ); + void RemoveAttribs( EERemoveParaAttribsMode eMode, sal_uInt16 nWhich ); void RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich ); void RemoveAttribsKeepLanguages( bool bRemoveParaAttribs ); commit f4c56849b52be5e6daebdffb1f54eccbce277414 Author: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> AuthorDate: Fri Oct 23 15:28:12 2020 +0200 Commit: Gerrit Code Review <ger...@gerrit.libreoffice.org> CommitDate: Fri Oct 23 15:28:12 2020 +0200 Update git submodules * Update translations from branch 'master' to 236b483252c94f7b38ca7fecfa16cabab498a1ac - update translations for master/7.1.0 alpha1 and force-fix errors using pocheck Change-Id: If200fbab2e1c793a45c3f361275028afdced7b91 - update translations for master and force-fix errors using pocheck Change-Id: Ia30711726a4e2c71ba0d1c4fb24c370deefc0f98 diff --git a/translations b/translations index b7dd30b210d1..236b483252c9 160000 --- a/translations +++ b/translations @@ -1 +1 @@ -Subproject commit b7dd30b210d1d080404aed2dc7cf2270a10d1260 +Subproject commit 236b483252c94f7b38ca7fecfa16cabab498a1ac _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits