include/svl/style.hxx | 3 ++- svx/source/tbxctrls/StylesPreviewWindow.cxx | 4 ++-- sw/inc/format.hxx | 2 ++ sw/source/core/attr/format.cxx | 19 +++++++++++++++++++ sw/source/uibase/app/docstyle.cxx | 14 ++++++++++++-- sw/source/writerfilter/dmapper/StyleSheetTable.cxx | 1 + 6 files changed, 38 insertions(+), 5 deletions(-)
New commits: commit cee5c21e0c8c64c78e5d04ff4e300edfaac30404 Author: Szymon Kłos <[email protected]> AuthorDate: Wed Nov 12 16:50:25 2025 +0000 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Nov 14 14:17:46 2025 +0100 Writer: iterate styles to show also favourite in the notebookbar - qFormat - specifies if style should be shown in more prominent places in the UI even if unused - we show it in that case not only in all styles in sidebar, but also in the notebookbar style previews - this is Writer specific, implemented on sw/ style iterator and SwFormat level - XStyles is interface common for all modules but in fact we do per module implementations it seems and there is no sense to propagate that value everywhere - currently we have also qFormat export so just reuse grab bag value Change-Id: Iee8f35a3e575c3c1caf6c67f8b489d7d64932cf5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193398 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/include/svl/style.hxx b/include/svl/style.hxx index 4c9d34272bdb..c0aa959c5083 100644 --- a/include/svl/style.hxx +++ b/include/svl/style.hxx @@ -65,6 +65,7 @@ enum class SfxStyleSearchBits { SwCondColl = 0x0040, Auto = 0x0000, ///< automatic: flags from application + Favourite = 0x0100, ///< styles selected to be always visible (search mask) Hidden = 0x0200, ///< hidden styles (search mask) ReadOnly = 0x2000, ///< readonly styles (search mask) Used = 0x4000, ///< used styles (search mask) @@ -73,7 +74,7 @@ enum class SfxStyleSearchBits { All = 0xe27f, ///< all styles }; namespace o3tl { - template<> struct typed_flags<SfxStyleSearchBits> : is_typed_flags<SfxStyleSearchBits, 0xe27f> {}; + template<> struct typed_flags<SfxStyleSearchBits> : is_typed_flags<SfxStyleSearchBits, 0xe37f> {}; } diff --git a/svx/source/tbxctrls/StylesPreviewWindow.cxx b/svx/source/tbxctrls/StylesPreviewWindow.cxx index fafeaf71cedd..cd679978d572 100644 --- a/svx/source/tbxctrls/StylesPreviewWindow.cxx +++ b/svx/source/tbxctrls/StylesPreviewWindow.cxx @@ -627,8 +627,8 @@ void StylesPreviewWindow_Base::UpdateStylesList() if (pStyleSheetPool) { - auto xIter = pStyleSheetPool->CreateIterator(SfxStyleFamily::Para, - SfxStyleSearchBits::UserDefined); + auto xIter + = pStyleSheetPool->CreateIterator(SfxStyleFamily::Para, SfxStyleSearchBits::Favourite); SfxStyleSheetBase* pStyle = xIter->First(); diff --git a/sw/inc/format.hxx b/sw/inc/format.hxx index 3f88d6ae2927..bfdf45af9c5f 100644 --- a/sw/inc/format.hxx +++ b/sw/inc/format.hxx @@ -178,6 +178,8 @@ public: bool IsAuto() const { return m_bAutoFormat; } void SetAuto( bool bNew ) { m_bAutoFormat = bNew; } + bool IsFavourite() const; + bool IsHidden() const { return m_bHidden; } void SetHidden( bool bValue ) { m_bHidden = bValue; } diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx index 5c4683a07897..ed11607a3a8f 100644 --- a/sw/source/core/attr/format.cxx +++ b/sw/source/core/attr/format.cxx @@ -754,6 +754,25 @@ void SwFormat::RemoveAllUnos() SwClientNotify(*this, aMsgHint); } +bool SwFormat::IsFavourite() const +{ + if (!m_pGrabBagItem) return false; + + const auto& rItems = m_pGrabBagItem->GetGrabBag(); + const auto aIt = rItems.find(u"qFormat"_ustr); + if (aIt != rItems.end()) + { + sal_Int32 nVal = 0; + if (aIt->second >>= nVal) + { + if (nVal == 1) + return true; + } + } + + return false; +} + bool SwFormat::IsUsed() const { auto pDoc = GetDoc(); diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx index ca81fb5b740a..7d5a247a3a21 100644 --- a/sw/source/uibase/app/docstyle.cxx +++ b/sw/source/uibase/app/docstyle.cxx @@ -2887,6 +2887,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() bool bSearchHidden( nMask & SfxStyleSearchBits::Hidden ); bool bOnlyHidden = nMask == SfxStyleSearchBits::Hidden; + bool bFavourite = nMask == SfxStyleSearchBits::Favourite; const bool bOrganizer = static_cast<const SwDocStyleSheetPool*>(pBasePool)->IsOrganizerMode(); bool bAll = ( nSrchMask & SfxStyleSearchBits::AllVisible ) == SfxStyleSearchBits::AllVisible; @@ -2982,7 +2983,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() SwTextFormatColl* pColl = (*rDoc.GetTextFormatColls())[ i ]; const bool bUsed = bOrganizer || rDoc.IsUsed(*pColl) || IsUsedInComments(pColl->GetName()); - if ( ( !bSearchHidden && pColl->IsHidden( ) && !bUsed ) || pColl->IsDefault() ) + if ( ( !bSearchHidden && pColl->IsHidden( ) && !bUsed && !bFavourite ) || pColl->IsDefault() ) continue; if ( nSMask == SfxStyleSearchBits::Hidden && !pColl->IsHidden( ) ) @@ -3054,6 +3055,12 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() } else { + if ( tmpMask & SfxStyleSearchBits::Favourite ) + { + SwFormat* pFormat = rDoc.FindTextFormatCollByName( pColl->GetName() ); + if (!(pFormat && pFormat->IsFavourite())) continue; + } + // searched for used and found none if( bIsSearchUsed ) continue; @@ -3335,6 +3342,7 @@ void SwStyleSheetIterator::AppendStyleList(const std::vector<OUString>& rList, for (const auto & i : rList) { bool bHidden = false; + bool bFavourite = false; sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(i, nSection); switch ( nSection ) { @@ -3343,6 +3351,7 @@ void SwStyleSheetIterator::AppendStyleList(const std::vector<OUString>& rList, bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolTextCollUsed( nId ); SwFormat* pFormat = rDoc.FindTextFormatCollByName( i ); bHidden = pFormat && pFormat->IsHidden( ); + bFavourite = pFormat && pFormat->IsFavourite(); } break; case SwGetPoolIdFromName::ChrFmt: @@ -3350,6 +3359,7 @@ void SwStyleSheetIterator::AppendStyleList(const std::vector<OUString>& rList, bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolFormatUsed( nId ); SwFormat* pFormat = rDoc.FindCharFormatByName( i ); bHidden = pFormat && pFormat->IsHidden( ); + bFavourite = pFormat && pFormat->IsFavourite(); } break; case SwGetPoolIdFromName::FrmFmt: @@ -3378,7 +3388,7 @@ void SwStyleSheetIterator::AppendStyleList(const std::vector<OUString>& rList, } bool bMatchHidden = ( bTestHidden && ( bHidden || !bOnlyHidden ) ) || ( !bTestHidden && ( !bHidden || bUsed ) ); - if ( ( !bTestUsed && bMatchHidden ) || ( bTestUsed && bUsed ) ) + if ( ( !bTestUsed && bMatchHidden ) || ( bTestUsed && bUsed ) || bFavourite ) m_aLst.Append( eFamily, i ); } } diff --git a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx index 099ae839e7ef..166fe4006723 100644 --- a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx +++ b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx @@ -635,6 +635,7 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm) break; case NS_ooxml::LN_CT_Style_qFormat: aValue.Name = "qFormat"; + aValue.Value <<= nIntValue; break; case NS_ooxml::LN_CT_Style_semiHidden: aValue.Name = "semiHidden";
