cui/source/tabpages/autocdlg.cxx | 10 +++++-- editeng/source/misc/acorrcfg.cxx | 18 +++++++++---- editeng/source/misc/swafopt.cxx | 1 include/editeng/swafopt.hxx | 1 officecfg/registry/schema/org/openoffice/Office/Writer.xcs | 8 +++++ sw/source/core/edit/autofmt.cxx | 6 +++- 6 files changed, 35 insertions(+), 9 deletions(-)
New commits: commit e75925138ecb67bac25cc4b4e2790581ed4f5838 Author: Samuel Mehrbrodt <[email protected]> AuthorDate: Mon Sep 15 11:02:38 2025 +0200 Commit: Samuel Mehrbrodt <[email protected]> CommitDate: Mon Nov 10 15:54:21 2025 +0100 tdf#168228 Don't replace styles unconditionally When using Autocorrect->Apply, styles were applied unconditionally. Add a second checkbox to allow disabling "Apply styles" in that case. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190955 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <[email protected]> Conflicts: editeng/source/misc/acorrcfg.cxx sw/qa/extras/uiwriter/uiwriter2.cxx sw/source/core/edit/autofmt.cxx Change-Id: I4891f906b5518f518f3ac3e256e21392ade3f824 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193718 Tested-by: allotropia jenkins <[email protected]> Reviewed-by: Samuel Mehrbrodt <[email protected]> diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index 0ea7f65c9b25..f01e58892840 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -485,9 +485,12 @@ bool OfaSwAutoFmtOptionsPage::FillItemSet( SfxItemSet* ) bModified |= pOpt->bCreateTable != bCheck; pOpt->bCreateTable = bCheck; - bCheck = m_xCheckLB->get_toggle(REPLACE_STYLES, CBCOL_SECOND) == TRISTATE_TRUE; + bCheck = m_xCheckLB->get_toggle(REPLACE_STYLES, CBCOL_FIRST) == TRISTATE_TRUE; bModified |= pOpt->bReplaceStyles != bCheck; pOpt->bReplaceStyles = bCheck; + bCheck = m_xCheckLB->get_toggle(REPLACE_STYLES, CBCOL_SECOND) == TRISTATE_TRUE; + bModified |= pOpt->bReplaceStylesByInput != bCheck; + pOpt->bReplaceStylesByInput = bCheck; bCheck = m_xCheckLB->get_toggle(REPLACE_DASHES, CBCOL_FIRST) == TRISTATE_TRUE; bModified |= pOpt->bChgToEnEmDash != bCheck; @@ -558,7 +561,7 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) CreateEntry(sNum.replaceFirst("%1", sBulletChar), CBCOL_SECOND); CreateEntry(sBorder, CBCOL_SECOND); CreateEntry(sTable, CBCOL_SECOND); - CreateEntry(sReplaceTemplates, CBCOL_SECOND); + CreateEntry(sReplaceTemplates, CBCOL_BOTH); CreateEntry(sDeleteEmptyPara, CBCOL_FIRST ); CreateEntry(sUserStyle, CBCOL_FIRST ); CreateEntry(sBullet.replaceFirst("%1", sByInputBulletChar), CBCOL_FIRST); @@ -585,7 +588,8 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) m_xCheckLB->set_toggle(APPLY_NUMBERING, pOpt->bSetNumRule ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(INSERT_BORDER, pOpt->bSetBorder ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(CREATE_TABLE, pOpt->bCreateTable ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); - m_xCheckLB->set_toggle(REPLACE_STYLES, pOpt->bReplaceStyles ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); + m_xCheckLB->set_toggle(REPLACE_STYLES, pOpt->bReplaceStyles ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); + m_xCheckLB->set_toggle(REPLACE_STYLES, pOpt->bReplaceStylesByInput ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(DEL_EMPTY_NODE, pOpt->bDelEmptyNode ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); m_xCheckLB->set_toggle(REPLACE_USER_COLL, pOpt->bChgUserColl ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); m_xCheckLB->set_toggle(REPLACE_BULLETS, pOpt->bChgEnumNum ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); diff --git a/editeng/source/misc/acorrcfg.cxx b/editeng/source/misc/acorrcfg.cxx index c2b3dbe6fe31..6f0d384749dd 100644 --- a/editeng/source/misc/acorrcfg.cxx +++ b/editeng/source/misc/acorrcfg.cxx @@ -326,9 +326,10 @@ Sequence<OUString> SvxSwAutoCorrCfg::GetPropertyNames() "Format/ByInput/ApplyNumbering/SpecialCharacter/Font", //43 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily", //44 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset", //45 - "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch" //46 + "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch", //46 + "Format/Option/ReplaceStyle", //47 }; - const int nCount = 47; + const int nCount = 48; Sequence<OUString> aNames(nCount); OUString* pNames = aNames.getArray(); for(int i = 0; i < nCount; i++) @@ -416,7 +417,7 @@ void SvxSwAutoCorrCfg::Load(bool bInit) case 27: rSwFlags.bSetNumRule = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ApplyNumbering/Enable", case 28: rSwFlags.bSetBorder = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ChangeToBorders", case 29: rSwFlags.bCreateTable = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ChangeToTable", - case 30: rSwFlags.bReplaceStyles = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ReplaceStyle", + case 30: rSwFlags.bReplaceStylesByInput = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ReplaceStyle", case 31: rSwFlags.bAFormatByInpDelSpacesAtSttEnd = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/DelSpacesAtStartEnd", case 32: rSwFlags.bAFormatByInpDelSpacesBetweenLines = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/DelSpacesBetween", case 33: rSwFlags.bAutoCompleteWords = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/Enable", @@ -477,6 +478,11 @@ void SvxSwAutoCorrCfg::Load(bool bInit) rSwFlags.aByInputBulletFont.SetPitch(FontPitch(nVal)); } break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch", + case 47 : + { + rSwFlags.bReplaceStyles = *o3tl::doAccess<bool>(pValues[nProp]); + } + break; // "Format/Option/ReplaceStyle", } } } @@ -551,7 +557,7 @@ void SvxSwAutoCorrCfg::ImplCommit() // "Format/ByInput/ApplyNumbering/Enable" css::uno::Any(rSwFlags.bSetBorder), // "Format/ByInput/ChangeToBorders" css::uno::Any(rSwFlags.bCreateTable), // "Format/ByInput/ChangeToTable" - css::uno::Any(rSwFlags.bReplaceStyles), + css::uno::Any(rSwFlags.bReplaceStylesByInput), // "Format/ByInput/ReplaceStyle" css::uno::Any(rSwFlags.bAFormatByInpDelSpacesAtSttEnd), // "Format/ByInput/DelSpacesAtStartEnd" @@ -579,8 +585,10 @@ void SvxSwAutoCorrCfg::ImplCommit() // "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily" css::uno::Any(sal_Int32(rSwFlags.aByInputBulletFont.GetCharSet())), // "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset" - css::uno::Any(sal_Int32(rSwFlags.aByInputBulletFont.GetPitch()))}); + css::uno::Any(sal_Int32(rSwFlags.aByInputBulletFont.GetPitch())), // "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch" + css::uno::Any(rSwFlags.bReplaceStyles), // "Format/Option/ReplaceStyle" + }); } void SvxSwAutoCorrCfg::Notify( const Sequence<OUString>& /* aPropertyNames */ ) diff --git a/editeng/source/misc/swafopt.cxx b/editeng/source/misc/swafopt.cxx index 751b3e575a53..795addca4912 100644 --- a/editeng/source/misc/swafopt.cxx +++ b/editeng/source/misc/swafopt.cxx @@ -40,6 +40,7 @@ SvxSwAutoFormatFlags::SvxSwAutoFormatFlags() bAFormatByInpDelSpacesBetweenLines = true; bReplaceStyles = + bReplaceStylesByInput = bDelEmptyNode = bWithRedlining = bAutoCmpltEndless = diff --git a/include/editeng/swafopt.hxx b/include/editeng/swafopt.hxx index 0d4e6ba310e8..516898a8b605 100644 --- a/include/editeng/swafopt.hxx +++ b/include/editeng/swafopt.hxx @@ -113,6 +113,7 @@ struct EDITENG_DLLPUBLIC SvxSwAutoFormatFlags bool bSetBorder : 1; bool bCreateTable : 1; bool bReplaceStyles : 1; + bool bReplaceStylesByInput : 1; bool bWithRedlining : 1; diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs index 88ac40f5057d..455544fe34f0 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs @@ -4381,6 +4381,14 @@ </info> <value>true</value> </prop> + <prop oor:name="ReplaceStyle" oor:type="xs:boolean" oor:nillable="false"> + <!-- UIHints: Tools AutoCorrect/AutoFormat Options Apply styles --> + <info> + <desc>Specifies whether styles are automatically assigned.</desc> + <label>Apply styles</label> + </info> + <value>false</value> + </prop> <prop oor:name="CombineParagraphs" oor:type="xs:boolean" oor:nillable="false"> <!-- OldPath: Writer/AutoFormat/Options --> <!-- OldLocation: Soffice.cfg --> diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 6e4bccb55bcc..2deafb5a5d35 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -2244,7 +2244,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const & if( m_aFlags.bSetNumRule && !m_aFlags.bAFormatByInput ) m_aFlags.bSetNumRule = false; - bool bReplaceStyles = !m_aFlags.bAFormatByInput || m_aFlags.bReplaceStyles; + bool bReplaceStyles = m_aFlags.bAFormatByInput ? m_aFlags.bReplaceStylesByInput : m_aFlags.bReplaceStyles; const SwTextFrame * pNextFrame = nullptr; bool bNxtEmpty = false; @@ -2562,7 +2562,10 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const & else if( bReplaceStyles ) eStat = nLevel ? TST_IDENT : TST_NEG_IDENT; else + { eStat = READ_NEXT_PARA; + BuildText(); + } } break; @@ -2811,6 +2814,7 @@ void SwEditShell::SetAutoFormatFlags(SvxSwAutoFormatFlags const * pFlags) pEditFlags->bSetBorder = pFlags->bSetBorder; pEditFlags->bCreateTable = pFlags->bCreateTable; pEditFlags->bReplaceStyles = pFlags->bReplaceStyles; + pEditFlags->bReplaceStylesByInput = pFlags->bReplaceStylesByInput; pEditFlags->bAFormatByInpDelSpacesAtSttEnd = pFlags->bAFormatByInpDelSpacesAtSttEnd; pEditFlags->bAFormatByInpDelSpacesBetweenLines =
