sw/inc/docsh.hxx | 3 + sw/source/uibase/app/docst.cxx | 108 +++++++++++++++++++++-------------------- 2 files changed, 60 insertions(+), 51 deletions(-)
New commits: commit 15690637242cec530433b5502b96ef0d92d6e8ad Author: Caolán McNamara <[email protected]> AuthorDate: Mon Jan 19 10:52:25 2026 +0000 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Jan 20 08:28:56 2026 +0100 split out a ApplyStyleSheetRequest Change-Id: Iba45dc045805fe7cf0b71bf97ec9ed76f16ed88e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197569 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index a2068a7a3305..d0dc9830463c 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -141,6 +141,9 @@ class SW_DLLPUBLIC SwDocShell SfxRequest* pRequest = nullptr, sal_uInt16 nSlot = 0); + SAL_DLLPRIVATE void ApplyStyleSheetRequest(const OUString& aParam, sal_uInt16 nSlot, SfxRequest& rReq, SfxStyleFamily nFamily, + SfxStyleSearchBits nMask, SwWrtShell* pActShell); + SAL_DLLPRIVATE void Delete(const OUString &rName, SfxStyleFamily nFamily); SAL_DLLPRIVATE void Hide(const OUString &rName, SfxStyleFamily nFamily, bool bHidden); SAL_DLLPRIVATE bool MakeInlineHeading(SwWrtShell *pSh, SwTextFormatColl* pColl, diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index 7b69cdd5c2ae..3954fac8c625 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -321,6 +321,62 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh) } } +void SwDocShell::ApplyStyleSheetRequest(const OUString& aParam, sal_uInt16 nSlot, SfxRequest& rReq, SfxStyleFamily nFamily, SfxStyleSearchBits nMask, SwWrtShell* pActShell) +{ + if (!aParam.isEmpty() || nSlot == SID_STYLE_WATERCAN ) + { + sal_uInt16 nRet = 0xffff; + bool bReturns = false; + + switch(nSlot) + { + case SID_STYLE_EDIT: + case SID_STYLE_FONT: + Edit(rReq.GetFrameWeld(), aParam, {}, nFamily, nMask, false, (nSlot == SID_STYLE_FONT) ? u"font"_ustr : OUString(), pActShell); + break; + case SID_STYLE_DELETE: + Delete(aParam, nFamily); + break; + case SID_STYLE_HIDE: + case SID_STYLE_SHOW: + Hide(aParam, nFamily, nSlot == SID_STYLE_HIDE); + break; + case SID_STYLE_APPLY: + // Shell-switch in ApplyStyles + nRet = static_cast<sal_uInt16>(ApplyStyles(aParam, nFamily, pActShell, rReq.GetModifier() )); + bReturns = true; + break; + case SID_STYLE_WATERCAN: + nRet = static_cast<sal_uInt16>(DoWaterCan(aParam, nFamily)); + bReturns = true; + break; + case SID_STYLE_UPDATE_BY_EXAMPLE: + UpdateStyle(aParam, nFamily, pActShell); + break; + case SID_STYLE_NEW_BY_EXAMPLE: + MakeByExample(aParam, nFamily, nMask, pActShell); + break; + + default: + OSL_FAIL("Invalid SlotId"); + } + + // Update formatting toolbar buttons status + if (GetWrtShell()->GetSelectionType() == SelectionType::PostIt) + GetView()->GetViewFrame().GetBindings().InvalidateAll(false); + + if (bReturns) + { + if(rReq.IsAPI()) // Basic only gets TRUE or FALSE + rReq.SetReturnValue(SfxUInt16Item(nSlot, sal_uInt16(nRet !=0))); + else + rReq.SetReturnValue(SfxUInt16Item(nSlot, nRet)); + } + + rReq.Done(); + } +} + // evaluate StyleSheet-Requests void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) { @@ -521,58 +577,8 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) rReq.AppendItem(SfxStringItem(nSlot, aParam)); } } - if (!aParam.isEmpty() || nSlot == SID_STYLE_WATERCAN ) - { - sal_uInt16 nRet = 0xffff; - bool bReturns = false; - switch(nSlot) - { - case SID_STYLE_EDIT: - case SID_STYLE_FONT: - Edit(rReq.GetFrameWeld(), aParam, {}, nFamily, nMask, false, (nSlot == SID_STYLE_FONT) ? u"font"_ustr : OUString(), pActShell); - break; - case SID_STYLE_DELETE: - Delete(aParam, nFamily); - break; - case SID_STYLE_HIDE: - case SID_STYLE_SHOW: - Hide(aParam, nFamily, nSlot == SID_STYLE_HIDE); - break; - case SID_STYLE_APPLY: - // Shell-switch in ApplyStyles - nRet = static_cast<sal_uInt16>(ApplyStyles(aParam, nFamily, pActShell, rReq.GetModifier() )); - bReturns = true; - break; - case SID_STYLE_WATERCAN: - nRet = static_cast<sal_uInt16>(DoWaterCan(aParam, nFamily)); - bReturns = true; - break; - case SID_STYLE_UPDATE_BY_EXAMPLE: - UpdateStyle(aParam, nFamily, pActShell); - break; - case SID_STYLE_NEW_BY_EXAMPLE: - MakeByExample(aParam, nFamily, nMask, pActShell); - break; - - default: - OSL_FAIL("Invalid SlotId"); - } - - // Update formatting toolbar buttons status - if (GetWrtShell()->GetSelectionType() == SelectionType::PostIt) - GetView()->GetViewFrame().GetBindings().InvalidateAll(false); - - if (bReturns) - { - if(rReq.IsAPI()) // Basic only gets TRUE or FALSE - rReq.SetReturnValue(SfxUInt16Item(nSlot, sal_uInt16(nRet !=0))); - else - rReq.SetReturnValue(SfxUInt16Item(nSlot, nRet)); - } - - rReq.Done(); - } + ApplyStyleSheetRequest(aParam, nSlot, rReq, nFamily, nMask, pActShell); break; }
