sw/inc/docstyle.hxx | 3 + sw/sdi/annotsh.sdi | 35 ---------------------- sw/source/uibase/app/docst.cxx | 59 ++++++++++++++++++++++++++++---------- sw/source/uibase/app/docstyle.cxx | 18 +++++++---- 4 files changed, 58 insertions(+), 57 deletions(-)
New commits: commit c66afb209de6132deac8fee9425a351391edc89e Author: Maxim Monastirsky <momonas...@gmail.com> AuthorDate: Fri Jun 16 02:16:26 2023 +0300 Commit: Maxim Monastirsky <momonas...@gmail.com> CommitDate: Fri Jun 16 10:19:57 2023 +0200 tdf#103064 Improve comment style usage detection With this patch the "Applied Styles" filter should list also styles used in comments. Change-Id: Ifcb716cb66a0d271ca3d7ce477e6299015310ff1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153163 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonas...@gmail.com> diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx index 2d7bfdf3ff99..82b33adf4efd 100644 --- a/sw/inc/docstyle.hxx +++ b/sw/inc/docstyle.hxx @@ -181,6 +181,7 @@ class SwStyleSheetIterator final : public SfxStyleSheetIterator, public SfxListe sal_uInt32 m_nLastPos; bool m_bFirstCalled; + bool IsUsedInComments(const OUString& rName); void AppendStyleList(const std::vector<OUString>& rLst, bool bUsed, bool bTestHidden, @@ -235,7 +236,7 @@ public: virtual std::unique_ptr<SfxStyleSheetIterator> CreateIterator( SfxStyleFamily, SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override; SwDoc& GetDoc() const { return m_rDoc; } - SfxStyleSheetPool* GetEEStyleSheetPool() { return mxEEStyleSheetPool.get(); } + SfxStyleSheetPool* GetEEStyleSheetPool() const { return mxEEStyleSheetPool.get(); } void dispose(); diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx index c869b10f7a5c..d43d5f652ff1 100644 --- a/sw/source/uibase/app/docstyle.cxx +++ b/sw/source/uibase/app/docstyle.cxx @@ -2471,12 +2471,9 @@ bool SwDocStyleSheet::IsUsed() const if (m_rDoc.IsUsed(*pMod)) return true; - SfxStyleSheetIterator aIter(static_cast<SwDocStyleSheetPool*>(m_pPool)->GetEEStyleSheetPool(), nFamily); - auto pStyle = aIter.Find(GetName()); - if (pStyle && pStyle->IsUsed()) - return true; - - return false; + SfxStyleSheetIterator aIter(static_cast<SwDocStyleSheetPool*>(m_pPool)->GetEEStyleSheetPool(), nFamily, + SfxStyleSearchBits::Used); + return aIter.Find(GetName()) != nullptr; } OUString SwDocStyleSheet::GetUsedBy() @@ -3010,7 +3007,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() { SwTextFormatColl* pColl = (*rDoc.GetTextFormatColls())[ i ]; - const bool bUsed = bOrganizer || rDoc.IsUsed(*pColl); + const bool bUsed = bOrganizer || rDoc.IsUsed(*pColl) || IsUsedInComments(pColl->GetName()); if ( ( !bSearchHidden && pColl->IsHidden( ) && !bUsed ) || pColl->IsDefault() ) continue; @@ -3412,6 +3409,13 @@ void SwStyleSheetIterator::AppendStyleList(const std::vector<OUString>& rList, } } +bool SwStyleSheetIterator::IsUsedInComments(const OUString& rName) +{ + auto pPool = static_cast<const SwDocStyleSheetPool*>(pBasePool)->GetEEStyleSheetPool(); + SfxStyleSheetIterator aIter(pPool, GetSearchFamily(), SfxStyleSearchBits::Used); + return aIter.Find(rName) != nullptr; +} + void SwDocStyleSheetPool::InvalidateIterator() { if (SfxStyleSheetIterator* pIter = GetCachedIterator()) commit 4923ddf33292cafecb5e216a5bdaac5bbe5da869 Author: Maxim Monastirsky <momonas...@gmail.com> AuthorDate: Thu Jun 15 11:39:40 2023 +0300 Commit: Maxim Monastirsky <momonas...@gmail.com> CommitDate: Fri Jun 16 10:19:45 2023 +0200 tdf#103064 sw: enable the UI commands Change-Id: Ic3e5ab9df5386a1cad0801f7044e6148620aa3b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152643 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonas...@gmail.com> diff --git a/sw/sdi/annotsh.sdi b/sw/sdi/annotsh.sdi index 3d11cd67a60e..b137fc577f2d 100644 --- a/sw/sdi/annotsh.sdi +++ b/sw/sdi/annotsh.sdi @@ -290,11 +290,6 @@ interface Annotation : _Annotation StateMethod = StateDisableItems ; ] - SID_STYLE_FAMILY2 - [ - StateMethod = StateDisableItems ; - ] - SID_STYLE_FAMILY3 [ StateMethod = StateDisableItems ; @@ -330,36 +325,6 @@ interface Annotation : _Annotation StateMethod = StateDisableItems ; ] - SID_STYLE_APPLY // status(fina|play) - [ - StateMethod = StateDisableItems ; - ] - - SID_STYLE_NEW // ole : no, status : ? - [ - StateMethod = StateDisableItems ; - ] - - SID_STYLE_EDIT // ole : no, status : ? - [ - StateMethod = StateDisableItems ; - ] - - SID_STYLE_DELETE // ole : no, status : ? - [ - StateMethod = StateDisableItems ; - ] - - SID_STYLE_HIDE - [ - StateMethod = StateDisableItems ; - ] - - SID_STYLE_SHOW - [ - StateMethod = StateDisableItems ; - ] - FN_STAT_SELMODE [ StateMethod = StateStatusLine ; diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index 2016d712e9a7..9838e04c3f09 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -78,6 +78,8 @@ #include <tblafmt.hxx> #include <sfx2/watermarkitem.hxx> #include <svl/grabbagitem.hxx> +#include <PostItMgr.hxx> +#include <AnnotationWin.hxx> #include <SwUndoFmt.hxx> #include <strings.hrc> #include <AccessibilityCheck.hxx> @@ -129,6 +131,12 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh) if( pFormat ) aName = pFormat->GetName(); } + else if (pShell->GetSelectionType() == SelectionType::PostIt) + { + auto pStyle = pShell->GetPostItMgr()->GetActiveSidebarWin()->GetOutlinerView()->GetStyleSheet(); + if (pStyle) + aName = pStyle->GetName(); + } else { SwTextFormatColl* pColl = pShell->GetCurTextFormatColl(); @@ -154,8 +162,15 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh) if(!pShell->IsFrameSelected()) { OUString aProgName; - SwTextFormatColl* pColl = pShell->GetCurTextFormatColl(); - if(pColl) + if (pShell->GetSelectionType() == SelectionType::PostIt) + { + if (auto pStyle = pShell->GetPostItMgr()->GetActiveSidebarWin()->GetOutlinerView()->GetStyleSheet()) + { + aName = pStyle->GetName(); + aProgName = SwStyleNameMapper::GetProgName(aName, SwGetPoolIdFromName::TxtColl); + } + } + else if (auto pColl = pShell->GetCurTextFormatColl()) { aName = pColl->GetName(); sal_uInt16 nId = pColl->GetPoolFormatId(); @@ -392,12 +407,17 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) case SID_STYLE_UPDATE_BY_EXAMPLE: case SID_STYLE_EDIT: { - SwTextFormatColl* pColl = GetWrtShell()->GetCurTextFormatColl(); - if(pColl) + if (GetWrtShell()->GetSelectionType() == SelectionType::PostIt) { + auto pOLV = GetWrtShell()->GetPostItMgr()->GetActiveSidebarWin()->GetOutlinerView(); + if (auto pStyle = pOLV->GetStyleSheet()) + aParam = pStyle->GetName(); + } + else if (auto pColl = GetWrtShell()->GetCurTextFormatColl()) aParam = pColl->GetName(); + + if (!aParam.isEmpty()) rReq.AppendItem(SfxStringItem(nSlot, aParam)); - } } break; } @@ -521,6 +541,10 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) 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 @@ -1159,15 +1183,22 @@ SfxStyleFamily SwDocShell::ApplyStyles(const OUString &rName, SfxStyleFamily nFa } case SfxStyleFamily::Para: { - // When outline-folding is enabled, MakeAllOutlineContentTemporarilyVisible makes - // application of a paragraph style that has an outline-level greater than the previous - // outline node become folded content of the previous outline node if the previous - // outline node's content is folded. - MakeAllOutlineContentTemporarilyVisible a(GetDoc()); - // #i62675# - // clear also list attributes at affected text nodes, if paragraph - // style has the list style attribute set. - pSh->SetTextFormatColl( pStyle->GetCollection(), true ); + if (pSh->GetPostItMgr() && pSh->GetPostItMgr()->HasActiveSidebarWin()) + { + pSh->GetPostItMgr()->GetActiveSidebarWin()->GetOutlinerView()->SetStyleSheet(rName); + } + else + { + // When outline-folding is enabled, MakeAllOutlineContentTemporarilyVisible makes + // application of a paragraph style that has an outline-level greater than the previous + // outline node become folded content of the previous outline node if the previous + // outline node's content is folded. + MakeAllOutlineContentTemporarilyVisible a(GetDoc()); + // #i62675# + // clear also list attributes at affected text nodes, if paragraph + // style has the list style attribute set. + pSh->SetTextFormatColl( pStyle->GetCollection(), true ); + } break; } case SfxStyleFamily::Frame: