Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / app / docstyle.cxx
blobd2dd874970ce37b1c828155139e7a87da5c39ca1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <memory>
21 #include <sal/config.h>
22 #include <sal/log.hxx>
23 #include <osl/diagnose.h>
25 #include <cstdlib>
27 #include <hintids.hxx>
28 #include <rtl/ustrbuf.hxx>
29 #include <svl/itemiter.hxx>
30 #include <svl/eitem.hxx>
31 #include <unotools/syslocale.hxx>
32 #include <editeng/boxitem.hxx>
33 #include <editeng/numitem.hxx>
34 #include <editeng/lrspitem.hxx>
35 #include <drawdoc.hxx>
36 #include <fmtcol.hxx>
37 #include <uitool.hxx>
38 #include <wrtsh.hxx>
39 #include <docsh.hxx>
40 #include <frmfmt.hxx>
41 #include <charfmt.hxx>
42 #include <tblafmt.hxx>
43 #include <poolfmt.hxx>
44 #include <pagedesc.hxx>
45 #include <docstyle.hxx>
46 #include <docary.hxx>
47 #include <ccoll.hxx>
48 #include <doc.hxx>
49 #include <IDocumentUndoRedo.hxx>
50 #include <IDocumentStylePoolAccess.hxx>
51 #include <IDocumentSettingAccess.hxx>
52 #include <IDocumentDrawModelAccess.hxx>
53 #include <IDocumentState.hxx>
54 #include <cmdid.h>
55 #include <strings.hrc>
56 #include <paratr.hxx>
57 #include <SwStyleNameMapper.hxx>
58 #include <svl/cjkoptions.hxx>
59 #include <svl/ctloptions.hxx>
60 #include <unotools/intlwrapper.hxx>
61 #include <numrule.hxx>
62 #include <svx/xdef.hxx>
63 #include <SwRewriter.hxx>
64 #include <hints.hxx>
65 #include <frameformats.hxx>
66 #include <svx/xfillit0.hxx>
67 #include <svx/xflftrit.hxx>
68 #include <svx/drawitem.hxx>
70 using namespace com::sun::star;
72 // At the names' publication, this character is removed again and the
73 // family is newly generated.
75 // In addition now there is the Bit bPhysical. In case this Bit is
76 // TRUE, the Pool-Formatnames are not being submitted.
78 namespace {
80 class SwImplShellAction
82 SwWrtShell* m_pSh;
83 std::unique_ptr<CurrShell> m_pCurrSh;
84 public:
85 explicit SwImplShellAction( SwDoc& rDoc );
86 ~SwImplShellAction() COVERITY_NOEXCEPT_FALSE;
87 SwImplShellAction(const SwImplShellAction&) = delete;
88 SwImplShellAction& operator=(const SwImplShellAction&) = delete;
93 SwImplShellAction::SwImplShellAction( SwDoc& rDoc )
95 if( rDoc.GetDocShell() )
96 m_pSh = rDoc.GetDocShell()->GetWrtShell();
97 else
98 m_pSh = nullptr;
100 if( m_pSh )
102 m_pCurrSh.reset( new CurrShell( m_pSh ) );
103 m_pSh->StartAllAction();
107 SwImplShellAction::~SwImplShellAction() COVERITY_NOEXCEPT_FALSE
109 if( m_pCurrSh )
111 m_pSh->EndAllAction();
112 m_pCurrSh.reset();
116 // find/create SwCharFormate
117 // possibly fill Style
118 static SwCharFormat* lcl_FindCharFormat( SwDoc& rDoc,
119 const OUString& rName,
120 SwDocStyleSheet* pStyle = nullptr,
121 bool bCreate = true )
123 SwCharFormat* pFormat = nullptr;
124 if (!rName.isEmpty())
126 pFormat = rDoc.FindCharFormatByName( rName );
127 if( !pFormat && rName == SwResId(STR_POOLCHR_STANDARD))
129 // Standard-Character template
130 pFormat = rDoc.GetDfltCharFormat();
133 if( !pFormat && bCreate )
134 { // explore Pool
135 const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, SwGetPoolIdFromName::ChrFmt);
136 if(nId != USHRT_MAX)
137 pFormat = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool(nId);
140 if(pStyle)
142 if(pFormat)
144 pStyle->SetPhysical(true);
145 SwFormat* p = pFormat->DerivedFrom();
146 if( p && !p->IsDefault() )
147 pStyle->PresetParent( p->GetName() );
148 else
149 pStyle->PresetParent( OUString() );
151 else
152 pStyle->SetPhysical(false);
154 return pFormat;
157 // find/create ParaFormats
158 // fill Style
159 static SwTextFormatColl* lcl_FindParaFormat( SwDoc& rDoc,
160 const OUString& rName,
161 SwDocStyleSheet* pStyle = nullptr,
162 bool bCreate = true )
164 SwTextFormatColl* pColl = nullptr;
166 if (!rName.isEmpty())
168 pColl = rDoc.FindTextFormatCollByName( rName );
169 if( !pColl && bCreate )
170 { // explore Pool
171 const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, SwGetPoolIdFromName::TxtColl);
172 if(nId != USHRT_MAX)
173 pColl = rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(nId);
177 if(pStyle)
179 if(pColl)
181 pStyle->SetPhysical(true);
182 if( pColl->DerivedFrom() && !pColl->DerivedFrom()->IsDefault() )
183 pStyle->PresetParent( pColl->DerivedFrom()->GetName() );
184 else
185 pStyle->PresetParent( OUString() );
187 SwTextFormatColl& rNext = pColl->GetNextTextFormatColl();
188 pStyle->PresetFollow(rNext.GetName());
190 else
191 pStyle->SetPhysical(false);
193 return pColl;
196 // Border formats
197 static SwFrameFormat* lcl_FindFrameFormat( SwDoc& rDoc,
198 const OUString& rName,
199 SwDocStyleSheet* pStyle = nullptr,
200 bool bCreate = true )
202 SwFrameFormat* pFormat = nullptr;
203 if( !rName.isEmpty() )
205 pFormat = rDoc.FindFrameFormatByName( rName );
206 if( !pFormat && bCreate )
207 { // explore Pool
208 const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, SwGetPoolIdFromName::FrmFmt);
209 if(nId != USHRT_MAX)
210 pFormat = rDoc.getIDocumentStylePoolAccess().GetFrameFormatFromPool(nId);
214 if(pStyle)
216 if(pFormat)
218 pStyle->SetPhysical(true);
219 if( pFormat->DerivedFrom() && !pFormat->DerivedFrom()->IsDefault() )
220 pStyle->PresetParent( pFormat->DerivedFrom()->GetName() );
221 else
222 pStyle->PresetParent( OUString() );
224 else
225 pStyle->SetPhysical(false);
227 return pFormat;
230 // Page descriptors
231 static const SwPageDesc* lcl_FindPageDesc( SwDoc& rDoc,
232 const OUString& rName,
233 SwDocStyleSheet* pStyle = nullptr,
234 bool bCreate = true )
236 const SwPageDesc* pDesc = nullptr;
238 if (!rName.isEmpty())
240 pDesc = rDoc.FindPageDesc(rName);
241 if( !pDesc && bCreate )
243 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, SwGetPoolIdFromName::PageDesc);
244 if(nId != USHRT_MAX)
245 pDesc = rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(nId);
249 if(pStyle)
251 if(pDesc)
253 pStyle->SetPhysical(true);
254 if(pDesc->GetFollow())
255 pStyle->PresetFollow(pDesc->GetFollow()->GetName());
256 else
257 pStyle->PresetParent( OUString() );
259 else
260 pStyle->SetPhysical(false);
262 return pDesc;
265 static const SwNumRule* lcl_FindNumRule( SwDoc& rDoc,
266 const OUString& rName,
267 SwDocStyleSheet* pStyle = nullptr,
268 bool bCreate = true )
270 const SwNumRule* pRule = nullptr;
272 if (!rName.isEmpty())
274 pRule = rDoc.FindNumRulePtr( rName );
275 if( !pRule && bCreate )
277 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, SwGetPoolIdFromName::NumRule);
278 if(nId != USHRT_MAX)
279 pRule = rDoc.getIDocumentStylePoolAccess().GetNumRuleFromPool(nId);
283 if(pStyle)
285 if(pRule)
287 pStyle->SetPhysical(true);
288 pStyle->PresetParent( OUString() );
290 else
291 pStyle->SetPhysical(false);
293 return pRule;
296 static SwTableAutoFormat* lcl_FindTableStyle(SwDoc& rDoc, const OUString& rName, SwDocStyleSheet *pStyle = nullptr, bool bCreate = true)
298 SwTableAutoFormat* pFormat = nullptr;
300 if (!rName.isEmpty())
302 pFormat = rDoc.GetTableStyles().FindAutoFormat(rName);
303 if (!pFormat && bCreate)
305 SwTableAutoFormat aNew(rName);
306 rDoc.GetTableStyles().AddAutoFormat(aNew);
310 if(pStyle)
312 if(pFormat)
314 pStyle->SetPhysical(true);
315 pStyle->PresetParent(OUString());
317 else
318 pStyle->SetPhysical(false);
320 return pFormat;
323 static const SwBoxAutoFormat* lcl_FindCellStyle(SwDoc& rDoc, std::u16string_view rName, SwDocStyleSheet *pStyle)
325 const SwBoxAutoFormat* pFormat = rDoc.GetCellStyles().GetBoxFormat(rName);
327 if (!pFormat)
329 const auto& aTableTemplateMap = SwTableAutoFormat::GetTableTemplateMap();
330 SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
331 for (size_t i=0; i < rTableStyles.size() && !pFormat; ++i)
333 const SwTableAutoFormat& rTableStyle = rTableStyles[i];
334 for (size_t nBoxFormat=0; nBoxFormat < aTableTemplateMap.size() && !pFormat; ++nBoxFormat)
336 const sal_uInt32 nBoxIndex = aTableTemplateMap[nBoxFormat];
337 const SwBoxAutoFormat& rBoxFormat = rTableStyle.GetBoxFormat(nBoxIndex);
338 OUString sBoxFormatName;
339 SwStyleNameMapper::FillProgName(rTableStyle.GetName(), sBoxFormatName, SwGetPoolIdFromName::TabStyle);
340 sBoxFormatName += rTableStyle.GetTableTemplateCellSubName(rBoxFormat);
341 if (rName == sBoxFormatName)
342 pFormat = &rBoxFormat;
347 if(pStyle)
349 if(pFormat)
351 pStyle->SetPhysical(true);
352 pStyle->PresetParent(OUString());
354 else
355 pStyle->SetPhysical(false);
357 return pFormat;
360 sal_uInt32 SwStyleSheetIterator::SwPoolFormatList::FindName(SfxStyleFamily eFam,
361 const OUString& rName)
363 if(!maImpl.empty())
365 UniqueHash::const_iterator it = maUnique.find(std::pair<SfxStyleFamily,OUString>{eFam, rName});
366 if (it != maUnique.end())
368 sal_uInt32 nIdx = it->second;
369 assert (nIdx < maImpl.size());
370 assert (maImpl.size() == maUnique.size());
371 return nIdx;
374 return SAL_MAX_UINT32;
377 void SwStyleSheetIterator::SwPoolFormatList::rehash()
379 maUnique.clear();
380 for (size_t i = 0; i < maImpl.size(); i++)
381 maUnique[maImpl[i]] = i;
382 assert (maImpl.size() == maUnique.size());
385 void SwStyleSheetIterator::SwPoolFormatList::RemoveName(SfxStyleFamily eFam,
386 const OUString& rName)
388 sal_uInt32 nTmpPos = FindName( eFam, rName );
389 if (nTmpPos != SAL_MAX_UINT32)
390 maImpl.erase(maImpl.begin() + nTmpPos);
392 // assumption: this seldom occurs, the iterator is built, then emptied.
393 rehash();
394 assert (maImpl.size() == maUnique.size());
397 // Add Strings to the list of templates
398 void SwStyleSheetIterator::SwPoolFormatList::Append( SfxStyleFamily eFam, const OUString& rStr )
400 UniqueHash::const_iterator it = maUnique.find(std::pair<SfxStyleFamily,OUString>{eFam, rStr});
401 if (it != maUnique.end())
402 return;
404 maUnique.emplace(std::pair<SfxStyleFamily,OUString>{eFam, rStr}, static_cast<sal_uInt32>(maImpl.size()));
405 maImpl.push_back(std::pair<SfxStyleFamily,OUString>{eFam, rStr});
408 // UI-sided implementation of StyleSheets
409 // uses the Core-Engine
410 SwDocStyleSheet::SwDocStyleSheet( SwDoc& rDocument,
411 SwDocStyleSheetPool& rPool) :
413 SfxStyleSheetBase( OUString(), &rPool, SfxStyleFamily::Char, SfxStyleSearchBits::Auto ),
414 m_pCharFormat(nullptr),
415 m_pColl(nullptr),
416 m_pFrameFormat(nullptr),
417 m_pDesc(nullptr),
418 m_pNumRule(nullptr),
419 m_pTableFormat(nullptr),
420 m_pBoxFormat(nullptr),
421 m_rDoc(rDocument),
422 m_aCoreSet(
423 rPool.GetPool(),
424 svl::Items<
425 RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
426 RES_PARATR_BEGIN, RES_FRMATR_END - 1,
427 RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END - 1,
428 // FillAttribute support:
429 XATTR_FILL_FIRST, XATTR_FILL_LAST,
430 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
431 SID_ATTR_PAGE, SID_ATTR_PAGE_EXT1,
432 SID_ATTR_PAGE_HEADERSET, SID_ATTR_PAGE_FOOTERSET,
433 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL,
434 // Items to hand over XPropertyList things like XColorList,
435 // XHatchList, XGradientList, and XBitmapList to the Area TabPage:
436 SID_COLOR_TABLE, SID_PATTERN_LIST,
437 SID_SWREGISTER_COLLECTION, SID_SWREGISTER_COLLECTION,
438 SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM,
439 SID_SWREGISTER_MODE, SID_SWREGISTER_MODE,
440 SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR,
441 SID_ATTR_NUMBERING_RULE, SID_ATTR_NUMBERING_RULE,
442 SID_ATTR_CHAR_GRABBAG, SID_ATTR_CHAR_GRABBAG,
443 SID_ATTR_AUTO_STYLE_UPDATE, SID_ATTR_AUTO_STYLE_UPDATE,
444 FN_PARAM_FTN_INFO, FN_PARAM_FTN_INFO,
445 FN_KEEP_ASPECT_RATIO, FN_KEEP_ASPECT_RATIO,
446 FN_COND_COLL, FN_COND_COLL>),
447 m_bPhysical(false)
449 nHelpId = UCHAR_MAX;
452 SwDocStyleSheet::SwDocStyleSheet( const SwDocStyleSheet& ) = default;
454 SwDocStyleSheet::~SwDocStyleSheet() = default;
456 void SwDocStyleSheet::Reset()
458 aName.clear();
459 aFollow.clear();
460 aParent.clear();
461 SetPhysical(false);
464 void SwDocStyleSheet::SetGrabBagItem(const uno::Any& rVal)
466 bool bChg = false;
467 if (!m_bPhysical)
468 FillStyleSheet(FillPhysical);
470 SwFormat* pFormat = nullptr;
471 switch (nFamily)
473 case SfxStyleFamily::Char:
474 pFormat = m_rDoc.FindCharFormatByName(aName);
475 if (pFormat)
477 pFormat->SetGrabBagItem(rVal);
478 bChg = true;
480 break;
481 case SfxStyleFamily::Para:
482 pFormat = m_rDoc.FindTextFormatCollByName(aName);
483 if (pFormat)
485 pFormat->SetGrabBagItem(rVal);
486 bChg = true;
488 break;
489 case SfxStyleFamily::Pseudo:
491 SwNumRule* pRule = m_rDoc.FindNumRulePtr(aName);
492 if (pRule)
494 pRule->SetGrabBagItem(rVal);
495 bChg = true;
498 break;
499 default:
500 break;
503 if (bChg)
505 dynamic_cast<SwDocStyleSheetPool&>(*m_pPool).InvalidateIterator();
506 m_pPool->Broadcast(SfxStyleSheetHint(SfxHintId::StyleSheetModified, *this));
507 if (SwEditShell* pSh = m_rDoc.GetEditShell())
508 pSh->CallChgLnk();
512 void SwDocStyleSheet::GetGrabBagItem(uno::Any& rVal) const
514 SwFormat* pFormat = nullptr;
515 switch (nFamily)
517 case SfxStyleFamily::Char:
518 pFormat = m_rDoc.FindCharFormatByName(aName);
519 if (pFormat)
520 pFormat->GetGrabBagItem(rVal);
521 break;
522 case SfxStyleFamily::Para:
523 pFormat = m_rDoc.FindTextFormatCollByName(aName);
524 if (pFormat)
525 pFormat->GetGrabBagItem(rVal);
526 break;
527 case SfxStyleFamily::Pseudo:
529 SwNumRule* pRule = m_rDoc.FindNumRulePtr(aName);
530 if (pRule)
531 pRule->GetGrabBagItem(rVal);
533 break;
534 default:
535 break;
538 // virtual methods
539 void SwDocStyleSheet::SetHidden( bool bValue )
541 bool bChg = false;
542 if(!m_bPhysical)
543 FillStyleSheet( FillPhysical );
545 SwFormat* pFormat = nullptr;
546 switch(nFamily)
548 case SfxStyleFamily::Char:
549 pFormat = m_rDoc.FindCharFormatByName( aName );
550 if ( pFormat )
552 pFormat->SetHidden( bValue );
553 bChg = true;
555 break;
557 case SfxStyleFamily::Para:
558 pFormat = m_rDoc.FindTextFormatCollByName( aName );
559 if ( pFormat )
561 pFormat->SetHidden( bValue );
562 bChg = true;
564 break;
566 case SfxStyleFamily::Frame:
567 pFormat = m_rDoc.FindFrameFormatByName( aName );
568 if ( pFormat )
570 pFormat->SetHidden( bValue );
571 bChg = true;
573 break;
575 case SfxStyleFamily::Page:
577 SwPageDesc* pPgDesc = m_rDoc.FindPageDesc(aName);
578 if ( pPgDesc )
580 pPgDesc->SetHidden( bValue );
581 bChg = true;
584 break;
586 case SfxStyleFamily::Pseudo:
588 SwNumRule* pRule = m_rDoc.FindNumRulePtr( aName );
589 if ( pRule )
591 pRule->SetHidden( bValue );
592 bChg = true;
595 break;
597 case SfxStyleFamily::Table:
599 SwTableAutoFormat* pTableAutoFormat = m_rDoc.GetTableStyles().FindAutoFormat( aName );
600 if ( pTableAutoFormat )
602 pTableAutoFormat->SetHidden( bValue );
603 bChg = true;
606 break;
608 default:
609 break;
612 if( bChg )
614 // calling pPool->First() here would be quite slow...
615 dynamic_cast<SwDocStyleSheetPool&>(*m_pPool).InvalidateIterator(); // internal list has to be updated
616 m_pPool->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified, *this ) );
617 if (SwEditShell* pSh = m_rDoc.GetEditShell())
618 pSh->CallChgLnk();
622 bool SwDocStyleSheet::IsHidden( ) const
624 bool bRet = false;
626 SwFormat* pFormat = nullptr;
627 switch(nFamily)
629 case SfxStyleFamily::Char:
630 pFormat = m_rDoc.FindCharFormatByName( aName );
631 bRet = pFormat && pFormat->IsHidden( );
632 break;
634 case SfxStyleFamily::Para:
635 pFormat = m_rDoc.FindTextFormatCollByName( aName );
636 bRet = pFormat && pFormat->IsHidden( );
637 break;
639 case SfxStyleFamily::Frame:
640 pFormat = m_rDoc.FindFrameFormatByName( aName );
641 bRet = pFormat && pFormat->IsHidden( );
642 break;
644 case SfxStyleFamily::Page:
646 SwPageDesc* pPgDesc = m_rDoc.FindPageDesc(aName);
647 bRet = pPgDesc && pPgDesc->IsHidden( );
649 break;
650 case SfxStyleFamily::Pseudo:
652 SwNumRule* pRule = m_rDoc.FindNumRulePtr( aName );
653 bRet = pRule && pRule->IsHidden( );
655 break;
656 case SfxStyleFamily::Table:
658 SwTableAutoFormat* pTableAutoFormat = m_rDoc.GetTableStyles().FindAutoFormat( aName );
659 bRet = pTableAutoFormat && pTableAutoFormat->IsHidden( );
661 break;
662 default:
663 break;
666 return bRet;
669 const OUString& SwDocStyleSheet::GetParent() const
671 if( !m_bPhysical )
673 // check if it's already in document
674 SwFormat* pFormat = nullptr;
675 SwGetPoolIdFromName eGetType;
676 switch(nFamily)
678 case SfxStyleFamily::Char:
679 pFormat = m_rDoc.FindCharFormatByName( aName );
680 eGetType = SwGetPoolIdFromName::ChrFmt;
681 break;
683 case SfxStyleFamily::Para:
684 pFormat = m_rDoc.FindTextFormatCollByName( aName );
685 eGetType = SwGetPoolIdFromName::TxtColl;
686 break;
688 case SfxStyleFamily::Frame:
689 pFormat = m_rDoc.FindFrameFormatByName( aName );
690 eGetType = SwGetPoolIdFromName::FrmFmt;
691 break;
693 case SfxStyleFamily::Page:
694 case SfxStyleFamily::Pseudo:
695 default:
697 static const OUString sEmpty;
698 return sEmpty; // there's no parent
702 OUString sTmp;
703 if( !pFormat ) // not yet there, so default Parent
705 sal_uInt16 i = SwStyleNameMapper::GetPoolIdFromUIName( aName, eGetType );
706 i = ::GetPoolParent( i );
707 if( i && USHRT_MAX != i )
708 SwStyleNameMapper::FillUIName( i, sTmp );
710 else
712 SwFormat* p = pFormat->DerivedFrom();
713 if( p && !p->IsDefault() )
714 sTmp = p->GetName();
716 SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
717 pThis->aParent = sTmp;
719 return aParent;
722 // Follower
723 const OUString& SwDocStyleSheet::GetFollow() const
725 if( !m_bPhysical )
727 SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
728 pThis->FillStyleSheet( FillAllInfo );
730 return aFollow;
733 void SwDocStyleSheet::SetLink(const OUString& rStr)
735 SwImplShellAction aTmpSh(m_rDoc);
736 switch (nFamily)
738 case SfxStyleFamily::Para:
740 if (m_pColl)
742 SwCharFormat* pLink = lcl_FindCharFormat(m_rDoc, rStr);
743 if (pLink)
745 m_pColl->SetLinkedCharFormat(pLink);
748 break;
750 case SfxStyleFamily::Char:
752 if (m_pCharFormat)
754 SwTextFormatColl* pLink = lcl_FindParaFormat(m_rDoc, rStr);
755 if (pLink)
757 m_pCharFormat->SetLinkedParaFormat(pLink);
760 break;
762 default:
763 break;
767 const OUString& SwDocStyleSheet::GetLink() const
769 if (!m_bPhysical)
771 SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
772 pThis->FillStyleSheet(FillAllInfo);
775 return m_aLink;
778 // What Linkage is possible
779 bool SwDocStyleSheet::HasFollowSupport() const
781 switch(nFamily)
783 case SfxStyleFamily::Para :
784 case SfxStyleFamily::Page : return true;
785 case SfxStyleFamily::Frame:
786 case SfxStyleFamily::Char :
787 case SfxStyleFamily::Pseudo: return false;
788 default:
789 OSL_ENSURE(false, "unknown style family");
791 return false;
794 // Parent ?
795 bool SwDocStyleSheet::HasParentSupport() const
797 bool bRet = false;
798 switch(nFamily)
800 case SfxStyleFamily::Char :
801 case SfxStyleFamily::Para :
802 case SfxStyleFamily::Frame: bRet = true;
803 break;
804 default:; //prevent warning
806 return bRet;
809 bool SwDocStyleSheet::HasClearParentSupport() const
811 bool bRet = false;
812 switch(nFamily)
814 case SfxStyleFamily::Para :
815 case SfxStyleFamily::Char :
816 case SfxStyleFamily::Frame: bRet = true;
817 break;
818 default:; //prevent warning
820 return bRet;
823 // determine textual description
824 OUString SwDocStyleSheet::GetDescription(MapUnit eUnit)
826 IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
828 static const OUStringLiteral sPlus(u" + ");
829 if ( SfxStyleFamily::Page == nFamily )
831 if( !pSet )
832 GetItemSet();
834 SfxItemIter aIter( *pSet );
835 OUStringBuffer aDesc;
837 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
839 if(!IsInvalidItem(pItem))
841 switch ( pItem->Which() )
843 case RES_LR_SPACE:
844 case SID_ATTR_PAGE_SIZE:
845 case SID_ATTR_PAGE_MAXSIZE:
846 case SID_ATTR_PAGE_PAPERBIN:
847 case SID_ATTR_BORDER_INNER:
848 break;
849 default:
851 OUString aItemPresentation;
852 if ( !IsInvalidItem( pItem ) &&
853 m_pPool->GetPool().GetPresentation(
854 *pItem, eUnit, aItemPresentation, aIntlWrapper ) )
856 if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
857 aDesc.append(sPlus);
858 aDesc.append(aItemPresentation);
864 return aDesc.makeStringAndClear();
867 if ( SfxStyleFamily::Frame == nFamily || SfxStyleFamily::Para == nFamily || SfxStyleFamily::Char == nFamily )
869 if( !pSet )
870 GetItemSet();
872 SfxItemIter aIter( *pSet );
873 OUStringBuffer aDesc;
874 OUString sPageNum;
875 OUString sModel;
876 OUString sBreak;
877 bool bHasWesternFontPrefix = false;
878 bool bHasCJKFontPrefix = false;
879 bool bHasCTLFontPrefix = false;
880 SvtCTLOptions aCTLOptions;
882 // Get currently used FillStyle and remember, also need the XFillFloatTransparenceItem
883 // to decide if gradient transparence is used
884 const drawing::FillStyle eFillStyle(pSet->Get(XATTR_FILLSTYLE).GetValue());
885 const bool bUseFloatTransparence(pSet->Get(XATTR_FILLFLOATTRANSPARENCE).IsEnabled());
887 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
889 if(!IsInvalidItem(pItem))
891 switch ( pItem->Which() )
893 case SID_ATTR_AUTO_STYLE_UPDATE:
894 case RES_PAGEDESC:
895 break;
896 default:
898 OUString aItemPresentation;
899 if ( !IsInvalidItem( pItem ) &&
900 m_pPool->GetPool().GetPresentation(
901 *pItem, eUnit, aItemPresentation, aIntlWrapper ) )
903 bool bIsDefault = false;
904 switch ( pItem->Which() )
906 case XATTR_FILLCOLOR:
908 // only use active FillStyle information
909 bIsDefault = (drawing::FillStyle_SOLID == eFillStyle);
910 break;
912 case XATTR_FILLGRADIENT:
914 // only use active FillStyle information
915 bIsDefault = (drawing::FillStyle_GRADIENT == eFillStyle);
916 break;
918 case XATTR_FILLHATCH:
920 // only use active FillStyle information
921 bIsDefault = (drawing::FillStyle_HATCH == eFillStyle);
922 break;
924 case XATTR_FILLBITMAP:
926 // only use active FillStyle information
927 bIsDefault = (drawing::FillStyle_BITMAP == eFillStyle);
928 break;
930 case XATTR_FILLTRANSPARENCE:
932 // only active when not FloatTransparence
933 bIsDefault = !bUseFloatTransparence;
934 break;
936 case XATTR_FILLFLOATTRANSPARENCE:
938 // only active when FloatTransparence
939 bIsDefault = bUseFloatTransparence;
940 break;
943 case SID_ATTR_PARA_PAGENUM:
944 sPageNum = aItemPresentation;
945 break;
946 case SID_ATTR_PARA_MODEL:
947 sModel = aItemPresentation;
948 break;
949 case RES_BREAK:
950 sBreak = aItemPresentation;
951 break;
952 case RES_CHRATR_CJK_FONT:
953 case RES_CHRATR_CJK_FONTSIZE:
954 case RES_CHRATR_CJK_LANGUAGE:
955 case RES_CHRATR_CJK_POSTURE:
956 case RES_CHRATR_CJK_WEIGHT:
957 if(SvtCJKOptions::IsCJKFontEnabled())
958 bIsDefault = true;
959 if(!bHasCJKFontPrefix)
961 aItemPresentation = SwResId(STR_CJK_FONT) + aItemPresentation;
962 bHasCJKFontPrefix = true;
964 break;
965 case RES_CHRATR_CTL_FONT:
966 case RES_CHRATR_CTL_FONTSIZE:
967 case RES_CHRATR_CTL_LANGUAGE:
968 case RES_CHRATR_CTL_POSTURE:
969 case RES_CHRATR_CTL_WEIGHT:
970 if(SvtCTLOptions::IsCTLFontEnabled())
971 bIsDefault = true;
972 if(!bHasCTLFontPrefix)
974 aItemPresentation = SwResId(STR_CTL_FONT) + aItemPresentation;
975 bHasCTLFontPrefix = true;
977 break;
978 case RES_CHRATR_FONT:
979 case RES_CHRATR_FONTSIZE:
980 case RES_CHRATR_LANGUAGE:
981 case RES_CHRATR_POSTURE:
982 case RES_CHRATR_WEIGHT:
983 if(!bHasWesternFontPrefix)
985 aItemPresentation = SwResId(STR_WESTERN_FONT) + aItemPresentation;
986 bHasWesternFontPrefix = true;
988 [[fallthrough]];
989 default:
990 bIsDefault = true;
992 if(bIsDefault)
994 if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
995 aDesc.append(sPlus);
996 aDesc.append(aItemPresentation);
1003 // Special treatment for Break, Page template and Site offset
1004 if (!sModel.isEmpty())
1006 if (!aDesc.isEmpty())
1007 aDesc.append(sPlus);
1008 aDesc.append(SwResId(STR_PAGEBREAK) + sPlus + sModel);
1009 if (sPageNum != "0")
1011 aDesc.append(sPlus + SwResId(STR_PAGEOFFSET) + sPageNum);
1014 else if (!sBreak.isEmpty()) // Break can be valid only when NO Model
1016 if (!aDesc.isEmpty())
1017 aDesc.append(sPlus);
1018 aDesc.append(sBreak);
1020 return aDesc.makeStringAndClear();
1023 if( SfxStyleFamily::Pseudo == nFamily )
1025 return OUString();
1028 return SfxStyleSheetBase::GetDescription(eUnit);
1031 // Set names
1032 bool SwDocStyleSheet::SetName(const OUString& rStr, bool bReindexNow)
1034 if( rStr.isEmpty() )
1035 return false;
1037 if( aName != rStr )
1039 if( !SfxStyleSheetBase::SetName(rStr, bReindexNow))
1040 return false;
1042 else if(!m_bPhysical)
1043 FillStyleSheet( FillPhysical );
1045 bool bChg = false;
1046 switch(nFamily)
1048 case SfxStyleFamily::Char :
1050 OSL_ENSURE(m_pCharFormat, "SwCharFormat missing!");
1051 if( m_pCharFormat && m_pCharFormat->GetName() != rStr )
1053 if (!m_pCharFormat->GetName().isEmpty())
1054 m_rDoc.RenameFormat(*m_pCharFormat, rStr);
1055 else
1056 m_pCharFormat->SetFormatName(rStr);
1058 bChg = true;
1060 break;
1062 case SfxStyleFamily::Para :
1064 OSL_ENSURE(m_pColl, "Collection missing!");
1065 if( m_pColl && m_pColl->GetName() != rStr )
1067 if (!m_pColl->GetName().isEmpty())
1068 m_rDoc.RenameFormat(*m_pColl, rStr);
1069 else
1070 m_pColl->SetFormatName(rStr);
1072 bChg = true;
1074 break;
1076 case SfxStyleFamily::Frame:
1078 OSL_ENSURE(m_pFrameFormat, "FrameFormat missing!");
1079 if( m_pFrameFormat && m_pFrameFormat->GetName() != rStr )
1081 if (!m_pFrameFormat->GetName().isEmpty())
1082 m_rDoc.RenameFormat(*m_pFrameFormat, rStr);
1083 else
1084 m_pFrameFormat->SetFormatName( rStr );
1086 bChg = true;
1088 break;
1090 case SfxStyleFamily::Page :
1091 OSL_ENSURE(m_pDesc, "PageDesc missing!");
1092 if( m_pDesc && m_pDesc->GetName() != rStr )
1094 // Set PageDesc - copy with earlier one - probably not
1095 // necessary for setting the name. So here we allow a
1096 // cast.
1097 SwPageDesc aPageDesc(*const_cast<SwPageDesc*>(m_pDesc));
1098 const OUString aOldName(aPageDesc.GetName());
1100 aPageDesc.SetName( rStr );
1101 bool const bDoesUndo = m_rDoc.GetIDocumentUndoRedo().DoesUndo();
1103 m_rDoc.GetIDocumentUndoRedo().DoUndo(!aOldName.isEmpty());
1104 m_rDoc.ChgPageDesc(aOldName, aPageDesc);
1105 m_rDoc.GetIDocumentUndoRedo().DoUndo(bDoesUndo);
1107 m_rDoc.getIDocumentState().SetModified();
1108 bChg = true;
1110 break;
1111 case SfxStyleFamily::Pseudo:
1112 OSL_ENSURE(m_pNumRule, "NumRule missing!");
1114 if (m_pNumRule)
1116 OUString aOldName = m_pNumRule->GetName();
1118 if (!aOldName.isEmpty())
1120 if ( aOldName != rStr &&
1121 m_rDoc.RenameNumRule(aOldName, rStr))
1123 m_pNumRule = m_rDoc.FindNumRulePtr(rStr);
1124 m_rDoc.getIDocumentState().SetModified();
1126 bChg = true;
1129 else
1131 // #i91400#
1132 const_cast<SwNumRule*>(m_pNumRule)->SetName( rStr, m_rDoc.getIDocumentListsAccess() );
1133 m_rDoc.getIDocumentState().SetModified();
1135 bChg = true;
1139 break;
1141 default:
1142 OSL_ENSURE(false, "unknown style family");
1145 if( bChg )
1147 m_pPool->First(nFamily); // internal list has to be updated
1148 m_pPool->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified, *this ) );
1149 if (SwEditShell* pSh = m_rDoc.GetEditShell())
1150 pSh->CallChgLnk();
1152 return true;
1155 // hierarchy of deduction
1156 bool SwDocStyleSheet::SetParent( const OUString& rStr)
1158 SwFormat* pFormat = nullptr, *pParent = nullptr;
1159 switch(nFamily)
1161 case SfxStyleFamily::Char :
1162 OSL_ENSURE( m_pCharFormat, "SwCharFormat missing!" );
1163 if( nullptr != ( pFormat = m_pCharFormat ) && !rStr.isEmpty() )
1164 pParent = lcl_FindCharFormat(m_rDoc, rStr);
1165 break;
1167 case SfxStyleFamily::Para :
1168 OSL_ENSURE( m_pColl, "Collection missing!");
1169 if( nullptr != ( pFormat = m_pColl ) && !rStr.isEmpty() )
1170 pParent = lcl_FindParaFormat( m_rDoc, rStr );
1171 break;
1173 case SfxStyleFamily::Frame:
1174 OSL_ENSURE(m_pFrameFormat, "FrameFormat missing!");
1175 if( nullptr != ( pFormat = m_pFrameFormat ) && !rStr.isEmpty() )
1176 pParent = lcl_FindFrameFormat( m_rDoc, rStr );
1177 break;
1179 case SfxStyleFamily::Page:
1180 case SfxStyleFamily::Pseudo:
1181 break;
1182 default:
1183 OSL_ENSURE(false, "unknown style family");
1186 bool bRet = false;
1187 if( pFormat && pFormat->DerivedFrom() &&
1188 pFormat->DerivedFrom()->GetName() != rStr )
1191 SwImplShellAction aTmp( m_rDoc );
1192 bRet = pFormat->SetDerivedFrom( pParent );
1195 if( bRet )
1197 aParent = rStr;
1198 m_pPool->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified,
1199 *this ) );
1203 return bRet;
1206 // Set Follower
1207 bool SwDocStyleSheet::SetFollow( const OUString& rStr)
1209 if( !rStr.isEmpty() && !SfxStyleSheetBase::SetFollow( rStr ))
1210 return false;
1212 SwImplShellAction aTmpSh( m_rDoc );
1213 switch(nFamily)
1215 case SfxStyleFamily::Para :
1217 OSL_ENSURE(m_pColl, "Collection missing!");
1218 if( m_pColl )
1220 SwTextFormatColl* pFollow = m_pColl;
1221 if( !rStr.isEmpty() && nullptr == (pFollow = lcl_FindParaFormat(m_rDoc, rStr) ))
1222 pFollow = m_pColl;
1224 m_pColl->SetNextTextFormatColl(*pFollow);
1226 break;
1228 case SfxStyleFamily::Page :
1230 OSL_ENSURE(m_pDesc, "PageDesc missing!");
1231 if( m_pDesc )
1233 const SwPageDesc* pFollowDesc = !rStr.isEmpty()
1234 ? lcl_FindPageDesc(m_rDoc, rStr)
1235 : nullptr;
1236 size_t nId = 0;
1237 if (pFollowDesc != m_pDesc->GetFollow() && m_rDoc.FindPageDesc(m_pDesc->GetName(), &nId))
1239 SwPageDesc aDesc( *m_pDesc );
1240 aDesc.SetFollow( pFollowDesc );
1241 m_rDoc.ChgPageDesc( nId, aDesc );
1242 m_pDesc = &m_rDoc.GetPageDesc( nId );
1245 break;
1247 case SfxStyleFamily::Char:
1248 case SfxStyleFamily::Frame:
1249 case SfxStyleFamily::Pseudo:
1250 break;
1251 default:
1252 OSL_ENSURE(false, "unknown style family");
1255 return true;
1258 static
1259 void lcl_SwFormatToFlatItemSet(SwFormat const *const pFormat, std::optional<SfxItemSet>& pRet)
1261 // note: we don't add the odd items that GetItemSet() would add
1262 // because they don't seem relevant for preview
1263 std::vector<SfxItemSet const*> sets;
1264 sets.push_back(&pFormat->GetAttrSet());
1265 while (SfxItemSet const*const pParent = sets.back()->GetParent())
1267 sets.push_back(pParent);
1269 // start by copying top-level parent set
1270 pRet.emplace(*sets.back());
1271 sets.pop_back();
1272 for (auto iter = sets.rbegin(); iter != sets.rend(); ++iter)
1273 { // in reverse so child overrides parent
1274 pRet->Put(**iter);
1278 std::optional<SfxItemSet> SwDocStyleSheet::GetItemSetForPreview()
1280 if (SfxStyleFamily::Page == nFamily || SfxStyleFamily::Pseudo == nFamily || SfxStyleFamily::Table == nFamily)
1282 SAL_WARN("sw.ui", "GetItemSetForPreview not implemented for page or number or table style");
1283 return std::optional<SfxItemSet>();
1285 if (!m_bPhysical)
1287 // because not only this style, but also any number of its parents
1288 // (or follow style) may not actually exist in the document at this
1289 // time, return one "flattened" item set that contains all items from
1290 // all parents.
1291 std::optional<SfxItemSet> pRet;
1293 bool bModifiedEnabled = m_rDoc.getIDocumentState().IsEnableSetModified();
1294 m_rDoc.getIDocumentState().SetEnableSetModified(false);
1296 FillStyleSheet(FillPreview, &pRet);
1298 m_rDoc.getIDocumentState().SetEnableSetModified(bModifiedEnabled);
1300 assert(pRet);
1301 return pRet;
1303 else
1305 std::optional<SfxItemSet> pRet;
1306 switch (nFamily)
1308 case SfxStyleFamily::Char:
1309 lcl_SwFormatToFlatItemSet(m_pCharFormat, pRet);
1310 break;
1311 case SfxStyleFamily::Para:
1312 lcl_SwFormatToFlatItemSet(m_pColl, pRet);
1313 break;
1314 case SfxStyleFamily::Frame:
1315 lcl_SwFormatToFlatItemSet(m_pFrameFormat, pRet);
1316 break;
1317 default:
1318 std::abort();
1320 return pRet;
1324 // extract ItemSet to Name and Family, Mask
1326 SfxItemSet& SwDocStyleSheet::GetItemSet()
1328 if(!m_bPhysical)
1329 FillStyleSheet( FillPhysical );
1331 switch(nFamily)
1333 case SfxStyleFamily::Char:
1334 case SfxStyleFamily::Para:
1335 case SfxStyleFamily::Frame:
1337 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1338 aBoxInfo.SetTable( false );
1339 aBoxInfo.SetDist( true ); // always show gap field
1340 aBoxInfo.SetMinDist( true );// set minimum size in tables and paragraphs
1341 aBoxInfo.SetDefDist( MIN_BORDER_DIST );// always set Default-Gap
1342 // Single lines can only have DontCare-Status in tables
1343 aBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISABLE );
1345 if( nFamily == SfxStyleFamily::Char )
1347 SAL_WARN_IF(!m_pCharFormat, "sw.ui", "Where's SwCharFormat");
1348 m_aCoreSet.Put(m_pCharFormat->GetAttrSet());
1349 m_aCoreSet.Put( aBoxInfo );
1351 if(m_pCharFormat->DerivedFrom())
1352 m_aCoreSet.SetParent(&m_pCharFormat->DerivedFrom()->GetAttrSet());
1354 else if ( nFamily == SfxStyleFamily::Para )
1356 OSL_ENSURE(m_pColl, "Where's Collection");
1357 m_aCoreSet.Put(m_pColl->GetAttrSet());
1358 m_aCoreSet.Put( aBoxInfo );
1359 m_aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, m_pColl->IsAutoUpdateOnDirectFormat()));
1361 if(m_pColl->DerivedFrom())
1362 m_aCoreSet.SetParent(&m_pColl->DerivedFrom()->GetAttrSet());
1364 else
1366 OSL_ENSURE(m_pFrameFormat, "Where's FrameFormat");
1367 m_aCoreSet.Put(m_pFrameFormat->GetAttrSet());
1368 m_aCoreSet.Put( aBoxInfo );
1369 m_aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, m_pFrameFormat->IsAutoUpdateOnDirectFormat()));
1371 if(m_pFrameFormat->DerivedFrom())
1372 m_aCoreSet.SetParent(&m_pFrameFormat->DerivedFrom()->GetAttrSet());
1374 // create needed items for XPropertyList entries from the DrawModel so that
1375 // the Area TabPage can access them
1376 const SwDrawModel* pDrawModel = m_rDoc.getIDocumentDrawModelAccess().GetDrawModel();
1378 m_aCoreSet.Put(SvxColorListItem(pDrawModel->GetColorList(), SID_COLOR_TABLE));
1379 m_aCoreSet.Put(SvxGradientListItem(pDrawModel->GetGradientList(), SID_GRADIENT_LIST));
1380 m_aCoreSet.Put(SvxHatchListItem(pDrawModel->GetHatchList(), SID_HATCH_LIST));
1381 m_aCoreSet.Put(SvxBitmapListItem(pDrawModel->GetBitmapList(), SID_BITMAP_LIST));
1382 m_aCoreSet.Put(SvxPatternListItem(pDrawModel->GetPatternList(), SID_PATTERN_LIST));
1385 break;
1387 case SfxStyleFamily::Page :
1389 // set correct parent to get the drawing::FillStyle_NONE FillStyle as needed
1390 if(!m_aCoreSet.GetParent())
1392 m_aCoreSet.SetParent(&m_rDoc.GetDfltFrameFormat()->GetAttrSet());
1395 OSL_ENSURE(m_pDesc, "No PageDescriptor");
1396 ::PageDescToItemSet(*const_cast<SwPageDesc*>(m_pDesc), m_aCoreSet);
1398 break;
1400 case SfxStyleFamily::Pseudo:
1402 OSL_ENSURE(m_pNumRule, "No NumRule");
1403 SvxNumRule aRule = m_pNumRule->MakeSvxNumRule();
1404 m_aCoreSet.Put(SvxNumBulletItem(std::move(aRule)));
1406 break;
1408 default:
1409 OSL_ENSURE(false, "unknown style family");
1411 // Member of Baseclass
1412 pSet = &m_aCoreSet;
1414 return m_aCoreSet;
1417 void SwDocStyleSheet::MergeIndentAttrsOfListStyle( SfxItemSet& rSet )
1419 if ( nFamily != SfxStyleFamily::Para )
1421 return;
1424 OSL_ENSURE( m_pColl, "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - missing paragraph style");
1425 ::sw::ListLevelIndents const indents(m_pColl->AreListLevelIndentsApplicable());
1426 if (indents == ::sw::ListLevelIndents::No)
1427 return;
1429 OSL_ENSURE( m_pColl->GetItemState( RES_PARATR_NUMRULE ) == SfxItemState::SET,
1430 "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - list level indents are applicable at paragraph style, but no list style found. Serious defect." );
1431 const OUString sNumRule = m_pColl->GetNumRule().GetValue();
1432 if (sNumRule.isEmpty())
1433 return;
1435 const SwNumRule* pRule = m_rDoc.FindNumRulePtr( sNumRule );
1436 if( pRule )
1438 const SwNumFormat& rFormat = pRule->Get( 0 );
1439 if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1441 if (indents & ::sw::ListLevelIndents::FirstLine)
1443 SvxFirstLineIndentItem const firstLine(static_cast<short>(rFormat.GetFirstLineIndent()), RES_MARGIN_FIRSTLINE);
1444 rSet.Put(firstLine);
1446 if (indents & ::sw::ListLevelIndents::LeftMargin)
1448 SvxTextLeftMarginItem const leftMargin(rFormat.GetIndentAt(), RES_MARGIN_TEXTLEFT);
1449 rSet.Put(leftMargin);
1455 // handling of parameter <bResetIndentAttrsAtParagraphStyle>
1456 void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
1457 const bool bResetIndentAttrsAtParagraphStyle )
1459 // if applicable determine format first
1460 if(!m_bPhysical)
1461 FillStyleSheet( FillPhysical );
1463 SwImplShellAction aTmpSh( m_rDoc );
1465 OSL_ENSURE( &rSet != &m_aCoreSet, "SetItemSet with own Set is not allowed" );
1467 if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
1469 SwRewriter aRewriter;
1470 aRewriter.AddRule( UndoArg1, GetName() );
1471 m_rDoc.GetIDocumentUndoRedo().StartUndo( SwUndoId::INSFMTATTR, &aRewriter );
1474 SwFormat* pFormat = nullptr;
1475 std::unique_ptr<SwPageDesc> pNewDsc;
1476 size_t nPgDscPos = 0;
1478 switch(nFamily)
1480 case SfxStyleFamily::Char :
1482 OSL_ENSURE(m_pCharFormat, "Where's CharFormat");
1483 pFormat = m_pCharFormat;
1485 break;
1487 case SfxStyleFamily::Para :
1489 OSL_ENSURE(m_pColl, "Where's Collection");
1490 if(const SfxBoolItem* pAutoUpdate = rSet.GetItemIfSet(SID_ATTR_AUTO_STYLE_UPDATE,false))
1492 m_pColl->SetAutoUpdateOnDirectFormat(pAutoUpdate->GetValue());
1495 const SwCondCollItem* pCondItem = rSet.GetItemIfSet( FN_COND_COLL, false );
1497 if( RES_CONDTXTFMTCOLL == m_pColl->Which() && pCondItem )
1499 const CommandStruct* pCmds = SwCondCollItem::GetCmds();
1500 for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++)
1502 SwCollCondition aCond( nullptr, pCmds[ i ].nCnd, pCmds[ i ].nSubCond );
1503 static_cast<SwConditionTextFormatColl*>(m_pColl)->RemoveCondition( aCond );
1504 const OUString sStyle = pCondItem->GetStyle( i );
1505 if (sStyle.isEmpty())
1506 continue;
1507 SwFormat *const pFindFormat = lcl_FindParaFormat( m_rDoc, sStyle );
1508 if (pFindFormat)
1510 aCond.RegisterToFormat( *pFindFormat );
1511 static_cast<SwConditionTextFormatColl*>(m_pColl)->InsertCondition( aCond );
1515 m_pColl->GetNotifier().Broadcast(sw::CondCollCondChg(*m_pColl));
1517 else if( pCondItem && !m_pColl->HasWriterListeners() )
1519 // no conditional template, then first create and adopt
1520 // all important values
1521 SwConditionTextFormatColl* pCColl = m_rDoc.MakeCondTextFormatColl(
1522 m_pColl->GetName(), static_cast<SwTextFormatColl*>(m_pColl->DerivedFrom()) );
1523 if( m_pColl != &m_pColl->GetNextTextFormatColl() )
1524 pCColl->SetNextTextFormatColl( m_pColl->GetNextTextFormatColl() );
1526 if( m_pColl->IsAssignedToListLevelOfOutlineStyle())
1527 pCColl->AssignToListLevelOfOutlineStyle(m_pColl->GetAssignedOutlineStyleLevel());
1528 else
1529 pCColl->DeleteAssignmentToListLevelOfOutlineStyle();
1531 const CommandStruct* pCmds = SwCondCollItem::GetCmds();
1532 for( sal_uInt16 i = 0; i < COND_COMMAND_COUNT; ++i )
1534 const OUString sStyle = pCondItem->GetStyle( i );
1535 if (sStyle.isEmpty())
1536 continue;
1537 SwTextFormatColl *const pFindFormat = lcl_FindParaFormat( m_rDoc, sStyle );
1538 if (pFindFormat)
1540 pCColl->InsertCondition( SwCollCondition( pFindFormat,
1541 pCmds[ i ].nCnd, pCmds[ i ].nSubCond ) );
1545 m_rDoc.DelTextFormatColl( m_pColl );
1546 m_pColl = pCColl;
1548 if ( bResetIndentAttrsAtParagraphStyle &&
1549 rSet.GetItemState( RES_PARATR_NUMRULE, false ) == SfxItemState::SET &&
1550 rSet.GetItemState(RES_MARGIN_FIRSTLINE, false) != SfxItemState::SET &&
1551 m_pColl->GetItemState(RES_MARGIN_FIRSTLINE, false) == SfxItemState::SET)
1553 m_rDoc.ResetAttrAtFormat(RES_MARGIN_FIRSTLINE, *m_pColl);
1555 if ( bResetIndentAttrsAtParagraphStyle &&
1556 rSet.GetItemState( RES_PARATR_NUMRULE, false ) == SfxItemState::SET &&
1557 rSet.GetItemState(RES_MARGIN_TEXTLEFT, false) != SfxItemState::SET &&
1558 m_pColl->GetItemState(RES_MARGIN_TEXTLEFT, false) == SfxItemState::SET)
1560 m_rDoc.ResetAttrAtFormat(RES_MARGIN_TEXTLEFT, *m_pColl);
1563 // #i56252: If a standard numbering style is assigned to a standard paragraph style
1564 // we have to create a physical instance of the numbering style. If we do not and
1565 // neither the paragraph style nor the numbering style is used in the document
1566 // the numbering style will not be saved with the document and the assignment got lost.
1567 if( const SfxPoolItem* pNumRuleItem = rSet.GetItemIfSet( RES_PARATR_NUMRULE, false ) )
1568 { // Setting a numbering rule?
1569 const OUString sNumRule = static_cast<const SwNumRuleItem*>(pNumRuleItem)->GetValue();
1570 if (!sNumRule.isEmpty())
1572 SwNumRule* pRule = m_rDoc.FindNumRulePtr( sNumRule );
1573 if( !pRule )
1574 { // Numbering rule not in use yet.
1575 sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sNumRule, SwGetPoolIdFromName::NumRule );
1576 if( USHRT_MAX != nPoolId ) // It's a standard numbering rule
1578 m_rDoc.getIDocumentStylePoolAccess().GetNumRuleFromPool( nPoolId ); // Create numbering rule (physical)
1584 pFormat = m_pColl;
1586 sal_uInt16 nId = m_pColl->GetPoolFormatId() &
1587 ~ ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID );
1588 switch( GetMask() & ( static_cast<SfxStyleSearchBits>(0x0fff) & ~SfxStyleSearchBits::SwCondColl ) )
1590 case SfxStyleSearchBits::SwText:
1591 nId |= COLL_TEXT_BITS;
1592 break;
1593 case SfxStyleSearchBits::SwChapter:
1594 nId |= COLL_DOC_BITS;
1595 break;
1596 case SfxStyleSearchBits::SwList:
1597 nId |= COLL_LISTS_BITS;
1598 break;
1599 case SfxStyleSearchBits::SwIndex:
1600 nId |= COLL_REGISTER_BITS;
1601 break;
1602 case SfxStyleSearchBits::SwExtra:
1603 nId |= COLL_EXTRA_BITS;
1604 break;
1605 case SfxStyleSearchBits::SwHtml:
1606 nId |= COLL_HTML_BITS;
1607 break;
1608 default: break;
1610 m_pColl->SetPoolFormatId( nId );
1611 break;
1613 case SfxStyleFamily::Frame:
1615 OSL_ENSURE(m_pFrameFormat, "Where's FrameFormat");
1617 if(const SfxPoolItem* pAutoUpdate = rSet.GetItemIfSet(SID_ATTR_AUTO_STYLE_UPDATE,false))
1619 m_pFrameFormat->SetAutoUpdateOnDirectFormat(static_cast<const SfxBoolItem*>(pAutoUpdate)->GetValue());
1621 pFormat = m_pFrameFormat;
1623 break;
1625 case SfxStyleFamily::Page :
1627 OSL_ENSURE(m_pDesc, "Where's PageDescriptor");
1629 if (m_rDoc.FindPageDesc(m_pDesc->GetName(), &nPgDscPos))
1631 pNewDsc.reset( new SwPageDesc( *m_pDesc ) );
1632 // #i48949# - no undo actions for the
1633 // copy of the page style
1634 ::sw::UndoGuard const ug(m_rDoc.GetIDocumentUndoRedo());
1635 m_rDoc.CopyPageDesc(*m_pDesc, *pNewDsc); // #i7983#
1637 pFormat = &pNewDsc->GetMaster();
1640 break;
1642 case SfxStyleFamily::Pseudo:
1644 OSL_ENSURE(m_pNumRule, "Where's NumRule");
1646 if (!m_pNumRule)
1647 break;
1649 const SfxPoolItem* pItem;
1650 switch( rSet.GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem ))
1652 case SfxItemState::SET:
1654 SvxNumRule& rSetRule = const_cast<SvxNumRule&>(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
1655 rSetRule.UnLinkGraphics();
1656 SwNumRule aSetRule(*m_pNumRule);
1657 aSetRule.SetSvxRule(rSetRule, &m_rDoc);
1658 m_rDoc.ChgNumRuleFormats( aSetRule );
1660 break;
1661 case SfxItemState::DONTCARE:
1662 // set NumRule to default values
1663 // what are the default values?
1665 SwNumRule aRule( m_pNumRule->GetName(),
1666 // #i89178#
1667 numfunc::GetDefaultPositionAndSpaceMode() );
1668 m_rDoc.ChgNumRuleFormats( aRule );
1670 break;
1671 default: break;
1674 break;
1676 default:
1677 OSL_ENSURE(false, "unknown style family");
1680 if( pFormat && rSet.Count())
1682 SfxItemIter aIter( rSet );
1683 const SfxPoolItem* pItem = aIter.GetCurItem();
1686 if( IsInvalidItem( pItem ) ) // Clear
1688 // use method <SwDoc::ResetAttrAtFormat(..)> in order to
1689 // create an Undo object for the attribute reset.
1690 m_rDoc.ResetAttrAtFormat( rSet.GetWhichByPos(aIter.GetCurPos()),
1691 *pFormat );
1694 pItem = aIter.NextItem();
1695 } while (pItem);
1696 SfxItemSet aSet(rSet);
1697 aSet.ClearInvalidItems();
1699 if(SfxStyleFamily::Frame == nFamily)
1701 // Need to check for unique item for DrawingLayer items of type NameOrIndex
1702 // and evtl. correct that item to ensure unique names for that type. This call may
1703 // modify/correct entries inside of the given SfxItemSet
1704 m_rDoc.CheckForUniqueItemForLineFillNameOrIndex(aSet);
1707 m_aCoreSet.ClearItem();
1709 if( pNewDsc )
1711 ::ItemSetToPageDesc( aSet, *pNewDsc );
1712 m_rDoc.ChgPageDesc( nPgDscPos, *pNewDsc );
1713 m_pDesc = &m_rDoc.GetPageDesc( nPgDscPos );
1714 m_rDoc.PreDelPageDesc(pNewDsc.get()); // #i7983#
1715 pNewDsc.reset();
1717 else
1718 m_rDoc.ChgFormat(*pFormat, aSet); // put all that is set
1720 else
1722 m_aCoreSet.ClearItem();
1723 if( pNewDsc ) // we still need to delete it
1725 m_rDoc.PreDelPageDesc(pNewDsc.get()); // #i7983#
1726 pNewDsc.reset();
1730 if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
1732 m_rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::END, nullptr);
1736 static void lcl_SaveStyles( SfxStyleFamily nFamily, std::vector<void*>& rArr, SwDoc& rDoc )
1738 switch( nFamily )
1740 case SfxStyleFamily::Char:
1742 const SwCharFormats& rTable = *rDoc.GetCharFormats();
1743 for(auto const& rChar: rTable)
1745 rArr.push_back(rChar);
1748 break;
1749 case SfxStyleFamily::Para:
1751 const SwTextFormatColls& rTable = *rDoc.GetTextFormatColls();
1752 for(auto const& rPara : rTable)
1754 rArr.push_back(rPara);
1757 break;
1758 case SfxStyleFamily::Frame:
1760 for(auto const& rFrame: *rDoc.GetFrameFormats())
1762 rArr.push_back(rFrame);
1765 break;
1767 case SfxStyleFamily::Page:
1769 for( size_t n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
1771 rArr.push_back( &rDoc.GetPageDesc( n ) );
1774 break;
1776 case SfxStyleFamily::Pseudo:
1778 const SwNumRuleTable& rTable = rDoc.GetNumRuleTable();
1779 for(auto const& rPseudo: rTable)
1781 rArr.push_back(rPseudo);
1784 break;
1785 default: break;
1789 static bool lcl_Contains(const std::vector<void*>& rArr, const void* p)
1791 return std::find( rArr.begin(), rArr.end(), p ) != rArr.end();
1794 static void lcl_DeleteInfoStyles( SfxStyleFamily nFamily, std::vector<void*> const & rArr, SwDoc& rDoc )
1796 size_t n, nCnt;
1797 switch( nFamily )
1799 case SfxStyleFamily::Char:
1801 std::deque<sal_uInt16> aDelArr;
1802 const SwCharFormats& rTable = *rDoc.GetCharFormats();
1803 for( n = 0, nCnt = rTable.size(); n < nCnt; ++n )
1805 if( !lcl_Contains( rArr, rTable[ n ] ))
1806 aDelArr.push_front( n );
1808 for(auto const& rDelArr: aDelArr)
1809 rDoc.DelCharFormat( rDelArr );
1811 break;
1813 case SfxStyleFamily::Para :
1815 std::deque<sal_uInt16> aDelArr;
1816 const SwTextFormatColls& rTable = *rDoc.GetTextFormatColls();
1817 for( n = 0, nCnt = rTable.size(); n < nCnt; ++n )
1819 if( !lcl_Contains( rArr, rTable[ n ] ))
1820 aDelArr.push_front( n );
1822 for(auto const& rDelArr: aDelArr)
1823 rDoc.DelTextFormatColl( rDelArr );
1825 break;
1827 case SfxStyleFamily::Frame:
1829 std::deque<SwFrameFormat*> aDelArr;
1830 for(auto const& rFrame: *rDoc.GetFrameFormats())
1832 if( !lcl_Contains( rArr, rFrame ))
1833 aDelArr.push_front( rFrame );
1835 for( auto const& rDelArr: aDelArr)
1836 rDoc.DelFrameFormat( rDelArr );
1838 break;
1840 case SfxStyleFamily::Page:
1842 std::deque<size_t> aDelArr;
1843 for( n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
1845 if( !lcl_Contains( rArr, &rDoc.GetPageDesc( n ) ))
1846 aDelArr.push_front( n );
1848 for( auto const& rDelArr: aDelArr )
1849 rDoc.DelPageDesc( rDelArr);
1851 break;
1853 case SfxStyleFamily::Pseudo:
1855 std::deque<SwNumRule*> aDelArr;
1856 const SwNumRuleTable& rTable = rDoc.GetNumRuleTable();
1857 for( auto const& rPseudo: rTable)
1859 if( !lcl_Contains( rArr, rPseudo ))
1860 aDelArr.push_front( rPseudo );
1862 for( auto const& rDelArr: aDelArr)
1863 rDoc.DelNumRule( rDelArr->GetName() );
1865 break;
1866 default: break;
1870 // determine the format
1871 bool SwDocStyleSheet::FillStyleSheet(
1872 FillStyleType const eFType, std::optional<SfxItemSet> *const o_ppFlatSet)
1874 bool bRet = false;
1875 sal_uInt16 nPoolId = USHRT_MAX;
1876 SwFormat* pFormat = nullptr;
1878 bool bCreate = FillPhysical == eFType;
1879 bool bDeleteInfo = false;
1880 bool bFillOnlyInfo = FillAllInfo == eFType || FillPreview == eFType;
1881 std::vector<void*> aDelArr;
1882 bool const isModified(m_rDoc.getIDocumentState().IsModified());
1884 switch(nFamily)
1886 case SfxStyleFamily::Char:
1887 m_pCharFormat = lcl_FindCharFormat(m_rDoc, aName, this, bCreate );
1888 m_bPhysical = nullptr != m_pCharFormat;
1889 if( bFillOnlyInfo && !m_bPhysical )
1891 // create style (plus all needed parents) and clean it up
1892 // later - without affecting the undo/redo stack
1893 ::sw::UndoGuard const ug(m_rDoc.GetIDocumentUndoRedo());
1894 bDeleteInfo = true;
1895 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
1896 m_pCharFormat = lcl_FindCharFormat(m_rDoc, aName, this );
1899 pFormat = m_pCharFormat;
1900 m_aLink.clear();
1901 if( !bCreate && !pFormat )
1903 if( aName == SwResId(STR_POOLCHR_STANDARD))
1904 nPoolId = 0;
1905 else
1906 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::ChrFmt );
1909 if (m_pCharFormat)
1911 const SwTextFormatColl* pParaFormat = m_pCharFormat->GetLinkedParaFormat();
1912 if (pParaFormat)
1914 m_aLink = pParaFormat->GetName();
1918 bRet = nullptr != m_pCharFormat || USHRT_MAX != nPoolId;
1920 if( bDeleteInfo )
1921 m_pCharFormat = nullptr;
1922 break;
1924 case SfxStyleFamily::Para:
1926 m_pColl = lcl_FindParaFormat(m_rDoc, aName, this, bCreate);
1927 m_bPhysical = nullptr != m_pColl;
1928 if( bFillOnlyInfo && !m_bPhysical )
1930 ::sw::UndoGuard const ug(m_rDoc.GetIDocumentUndoRedo());
1931 bDeleteInfo = true;
1932 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
1933 m_pColl = lcl_FindParaFormat(m_rDoc, aName, this );
1936 pFormat = m_pColl;
1937 m_aLink.clear();
1938 if( m_pColl )
1940 PresetFollow( m_pColl->GetNextTextFormatColl().GetName() );
1941 const SwCharFormat* pCharFormat = m_pColl->GetLinkedCharFormat();
1942 if (pCharFormat)
1944 m_aLink = pCharFormat->GetName();
1947 else if( !bCreate )
1948 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::TxtColl );
1950 bRet = nullptr != m_pColl || USHRT_MAX != nPoolId;
1952 if( bDeleteInfo )
1953 m_pColl = nullptr;
1955 break;
1957 case SfxStyleFamily::Frame:
1958 m_pFrameFormat = lcl_FindFrameFormat(m_rDoc, aName, this, bCreate);
1959 m_bPhysical = nullptr != m_pFrameFormat;
1960 if (bFillOnlyInfo && !m_bPhysical)
1962 ::sw::UndoGuard const ug(m_rDoc.GetIDocumentUndoRedo());
1963 bDeleteInfo = true;
1964 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
1965 m_pFrameFormat = lcl_FindFrameFormat(m_rDoc, aName, this );
1967 pFormat = m_pFrameFormat;
1968 if( !bCreate && !pFormat )
1969 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::FrmFmt );
1971 bRet = nullptr != m_pFrameFormat || USHRT_MAX != nPoolId;
1973 if( bDeleteInfo )
1974 m_pFrameFormat = nullptr;
1975 break;
1977 case SfxStyleFamily::Page:
1978 m_pDesc = lcl_FindPageDesc(m_rDoc, aName, this, bCreate);
1979 m_bPhysical = nullptr != m_pDesc;
1980 if( bFillOnlyInfo && !m_pDesc )
1982 ::sw::UndoGuard const ug(m_rDoc.GetIDocumentUndoRedo());
1983 bDeleteInfo = true;
1984 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
1985 m_pDesc = lcl_FindPageDesc( m_rDoc, aName, this );
1988 if( m_pDesc )
1990 nPoolId = m_pDesc->GetPoolFormatId();
1991 nHelpId = m_pDesc->GetPoolHelpId();
1992 if (const OUString* pattern = m_pDesc->GetPoolHlpFileId() != UCHAR_MAX
1993 ? m_rDoc.GetDocPattern(m_pDesc->GetPoolHlpFileId())
1994 : nullptr)
1995 aHelpFile = *pattern;
1996 else
1997 aHelpFile.clear();
1999 else if( !bCreate )
2000 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::PageDesc );
2001 SetMask( (USER_FMT & nPoolId) ? SfxStyleSearchBits::UserDefined : SfxStyleSearchBits::Auto );
2003 bRet = nullptr != m_pDesc || USHRT_MAX != nPoolId;
2004 if( bDeleteInfo )
2005 m_pDesc = nullptr;
2006 break;
2008 case SfxStyleFamily::Pseudo:
2009 m_pNumRule = lcl_FindNumRule(m_rDoc, aName, this, bCreate);
2010 m_bPhysical = nullptr != m_pNumRule;
2011 if( bFillOnlyInfo && !m_pNumRule )
2013 ::sw::UndoGuard const ug(m_rDoc.GetIDocumentUndoRedo());
2014 bDeleteInfo = true;
2015 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
2016 m_pNumRule = lcl_FindNumRule( m_rDoc, aName, this );
2019 if( m_pNumRule )
2021 nPoolId = m_pNumRule->GetPoolFormatId();
2022 nHelpId = m_pNumRule->GetPoolHelpId();
2023 if (const OUString* pattern = m_pNumRule->GetPoolHlpFileId() != UCHAR_MAX
2024 ? m_rDoc.GetDocPattern(m_pNumRule->GetPoolHlpFileId())
2025 : nullptr)
2026 aHelpFile = *pattern;
2027 else
2028 aHelpFile.clear();
2030 else if( !bCreate )
2031 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::NumRule );
2032 SetMask( (USER_FMT & nPoolId) ? SfxStyleSearchBits::UserDefined : SfxStyleSearchBits::Auto );
2034 bRet = nullptr != m_pNumRule || USHRT_MAX != nPoolId;
2036 if( bDeleteInfo )
2037 m_pNumRule = nullptr;
2038 break;
2040 case SfxStyleFamily::Table:
2041 m_pTableFormat = lcl_FindTableStyle(m_rDoc, aName, this, bCreate);
2042 SetMask((m_pTableFormat && m_pTableFormat->IsUserDefined()) ? SfxStyleSearchBits::UserDefined : SfxStyleSearchBits::Auto);
2043 bRet = m_bPhysical = (nullptr != m_pTableFormat);
2044 break;
2046 case SfxStyleFamily::Cell:
2047 m_pBoxFormat = lcl_FindCellStyle(m_rDoc, aName, this);
2048 bRet = m_bPhysical = (nullptr != m_pBoxFormat);
2049 break;
2050 default:; //prevent warning
2053 if( SfxStyleFamily::Char == nFamily ||
2054 SfxStyleFamily::Para == nFamily ||
2055 SfxStyleFamily::Frame == nFamily )
2057 if( pFormat )
2058 nPoolId = pFormat->GetPoolFormatId();
2060 SfxStyleSearchBits _nMask = SfxStyleSearchBits::Auto;
2061 if( pFormat == m_rDoc.GetDfltCharFormat() )
2062 _nMask |= SfxStyleSearchBits::ReadOnly;
2063 else if( USER_FMT & nPoolId )
2064 _nMask |= SfxStyleSearchBits::UserDefined;
2066 switch ( COLL_GET_RANGE_BITS & nPoolId )
2068 case COLL_TEXT_BITS: _nMask |= SfxStyleSearchBits::SwText; break;
2069 case COLL_DOC_BITS : _nMask |= SfxStyleSearchBits::SwChapter; break;
2070 case COLL_LISTS_BITS: _nMask |= SfxStyleSearchBits::SwList; break;
2071 case COLL_REGISTER_BITS: _nMask |= SfxStyleSearchBits::SwIndex; break;
2072 case COLL_EXTRA_BITS: _nMask |= SfxStyleSearchBits::SwExtra; break;
2073 case COLL_HTML_BITS: _nMask |= SfxStyleSearchBits::SwHtml; break;
2076 if( pFormat )
2078 OSL_ENSURE( m_bPhysical, "Format not found" );
2080 nHelpId = pFormat->GetPoolHelpId();
2081 if (const OUString* pattern = pFormat->GetPoolHlpFileId() != UCHAR_MAX
2082 ? m_rDoc.GetDocPattern(pFormat->GetPoolHlpFileId())
2083 : nullptr)
2084 aHelpFile = *pattern;
2085 else
2086 aHelpFile.clear();
2088 if( RES_CONDTXTFMTCOLL == pFormat->Which() )
2089 _nMask |= SfxStyleSearchBits::SwCondColl;
2091 if (FillPreview == eFType)
2093 assert(o_ppFlatSet);
2094 lcl_SwFormatToFlatItemSet(pFormat, *o_ppFlatSet);
2098 SetMask( _nMask );
2100 if( bDeleteInfo && bFillOnlyInfo )
2102 ::sw::UndoGuard const ug(m_rDoc.GetIDocumentUndoRedo());
2103 ::lcl_DeleteInfoStyles( nFamily, aDelArr, m_rDoc );
2104 if (!isModified)
2106 m_rDoc.getIDocumentState().ResetModified();
2109 return bRet;
2112 // Create new format in Core
2113 void SwDocStyleSheet::Create()
2115 switch(nFamily)
2117 case SfxStyleFamily::Char :
2118 m_pCharFormat = lcl_FindCharFormat( m_rDoc, aName );
2119 if( !m_pCharFormat )
2120 m_pCharFormat = m_rDoc.MakeCharFormat(aName,
2121 m_rDoc.GetDfltCharFormat());
2122 m_pCharFormat->SetAuto(false);
2123 break;
2125 case SfxStyleFamily::Para :
2126 m_pColl = lcl_FindParaFormat( m_rDoc, aName );
2127 if( !m_pColl )
2129 SwTextFormatColl *pPar = (*m_rDoc.GetTextFormatColls())[0];
2130 if( nMask & SfxStyleSearchBits::SwCondColl )
2131 m_pColl = m_rDoc.MakeCondTextFormatColl( aName, pPar );
2132 else
2133 m_pColl = m_rDoc.MakeTextFormatColl( aName, pPar );
2135 break;
2137 case SfxStyleFamily::Frame:
2138 m_pFrameFormat = lcl_FindFrameFormat( m_rDoc, aName );
2139 if( !m_pFrameFormat )
2140 m_pFrameFormat = m_rDoc.MakeFrameFormat(aName, m_rDoc.GetDfltFrameFormat(), false, false);
2142 break;
2144 case SfxStyleFamily::Page :
2145 m_pDesc = lcl_FindPageDesc( m_rDoc, aName );
2146 if( !m_pDesc )
2148 m_pDesc = m_rDoc.MakePageDesc(aName);
2150 break;
2152 case SfxStyleFamily::Pseudo:
2153 m_pNumRule = lcl_FindNumRule( m_rDoc, aName );
2154 if( !m_pNumRule )
2156 const OUString sTmpNm( aName.isEmpty() ? m_rDoc.GetUniqueNumRuleName() : aName );
2157 SwNumRule* pRule = m_rDoc.GetNumRuleTable()[
2158 m_rDoc.MakeNumRule( sTmpNm, nullptr, false,
2159 // #i89178#
2160 numfunc::GetDefaultPositionAndSpaceMode() ) ];
2161 pRule->SetAutoRule( false );
2162 if( aName.isEmpty() )
2164 // #i91400#
2165 pRule->SetName( aName, m_rDoc.getIDocumentListsAccess() );
2167 m_pNumRule = pRule;
2169 break;
2171 case SfxStyleFamily::Table:
2172 if (aName.isEmpty())
2173 return;
2174 m_pTableFormat = lcl_FindTableStyle(m_rDoc, aName);
2175 if (!m_pTableFormat)
2177 m_rDoc.MakeTableStyle(aName);
2178 m_pTableFormat = m_rDoc.GetTableStyles().FindAutoFormat(aName);
2179 SAL_WARN_IF(!m_pTableFormat, "sw.ui", "Recently added auto format not found");
2181 break;
2182 default:; //prevent warning
2184 m_bPhysical = true;
2185 m_aCoreSet.ClearItem();
2188 SwCharFormat* SwDocStyleSheet::GetCharFormat()
2190 if(!m_bPhysical)
2191 FillStyleSheet( FillPhysical );
2192 return m_pCharFormat;
2195 SwTextFormatColl* SwDocStyleSheet::GetCollection()
2197 if(!m_bPhysical)
2198 FillStyleSheet( FillPhysical );
2199 return m_pColl;
2202 const SwPageDesc* SwDocStyleSheet::GetPageDesc()
2204 if(!m_bPhysical)
2205 FillStyleSheet( FillPhysical );
2206 return m_pDesc;
2209 const SwNumRule * SwDocStyleSheet::GetNumRule()
2211 if(!m_bPhysical)
2212 FillStyleSheet( FillPhysical );
2213 return m_pNumRule;
2217 void SwDocStyleSheet::SetNumRule(const SwNumRule& rRule)
2219 OSL_ENSURE(m_pNumRule, "Where is the NumRule");
2220 m_rDoc.ChgNumRuleFormats( rRule );
2223 SwTableAutoFormat* SwDocStyleSheet::GetTableFormat()
2225 if(!m_bPhysical)
2226 FillStyleSheet( FillPhysical );
2227 assert(m_pTableFormat && "SwDocStyleSheet table style, SwTableAutoFormat not found");
2228 return m_pTableFormat;
2231 // re-generate Name AND Family from String
2232 // First() and Next() (see below) insert an identification letter at Pos.1
2234 void SwDocStyleSheet::PresetNameAndFamily(SfxStyleFamily eFamily, const OUString& rName)
2236 this->nFamily = eFamily;
2237 this->aName = rName;
2240 // Is the format physically present yet
2241 void SwDocStyleSheet::SetPhysical(bool bPhys)
2243 m_bPhysical = bPhys;
2245 if(!bPhys)
2247 m_pCharFormat = nullptr;
2248 m_pColl = nullptr;
2249 m_pFrameFormat = nullptr;
2250 m_pDesc = nullptr;
2254 SwFrameFormat* SwDocStyleSheet::GetFrameFormat()
2256 if(!m_bPhysical)
2257 FillStyleSheet( FillPhysical );
2258 return m_pFrameFormat;
2261 bool SwDocStyleSheet::IsUsed() const
2263 if( !m_bPhysical )
2265 SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
2266 pThis->FillStyleSheet( FillOnlyName );
2269 if( !m_bPhysical )
2270 return false;
2272 const sw::BroadcastingModify* pMod;
2273 switch( nFamily )
2275 case SfxStyleFamily::Char : pMod = m_pCharFormat; break;
2276 case SfxStyleFamily::Para : pMod = m_pColl; break;
2277 case SfxStyleFamily::Frame: pMod = m_pFrameFormat; break;
2278 case SfxStyleFamily::Page : pMod = m_pDesc; break;
2280 case SfxStyleFamily::Pseudo:
2281 return m_pNumRule && m_rDoc.IsUsed(*m_pNumRule);
2283 case SfxStyleFamily::Table:
2284 return m_pTableFormat && m_rDoc.IsUsed( *m_pTableFormat );
2286 default:
2287 OSL_ENSURE(false, "unknown style family");
2288 return false;
2290 return m_rDoc.IsUsed( *pMod );
2293 OUString SwDocStyleSheet::GetUsedBy()
2295 return m_pNumRule ? m_pNumRule->MakeParagraphStyleListString() : OUString();
2298 sal_uLong SwDocStyleSheet::GetHelpId( OUString& rFile )
2300 sal_uInt16 nId = 0;
2301 sal_uInt16 nPoolId = 0;
2302 unsigned char nFileId = UCHAR_MAX;
2304 rFile = "swrhlppi.hlp";
2306 const SwFormat* pTmpFormat = nullptr;
2307 switch( nFamily )
2309 case SfxStyleFamily::Char :
2310 if( !m_pCharFormat &&
2311 nullptr == (m_pCharFormat = lcl_FindCharFormat( m_rDoc, aName, nullptr, false )) )
2313 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::ChrFmt );
2314 return USHRT_MAX == nId ? 0 : nId;
2316 pTmpFormat = m_pCharFormat;
2317 break;
2319 case SfxStyleFamily::Para:
2320 if( !m_pColl &&
2321 nullptr == ( m_pColl = lcl_FindParaFormat( m_rDoc, aName, nullptr, false )) )
2323 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::TxtColl );
2324 return USHRT_MAX == nId ? 0 : nId;
2326 pTmpFormat = m_pColl;
2327 break;
2329 case SfxStyleFamily::Frame:
2330 if( !m_pFrameFormat &&
2331 nullptr == ( m_pFrameFormat = lcl_FindFrameFormat( m_rDoc, aName, nullptr, false ) ) )
2333 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::FrmFmt );
2334 return USHRT_MAX == nId ? 0 : nId;
2336 pTmpFormat = m_pFrameFormat;
2337 break;
2339 case SfxStyleFamily::Page:
2340 if( !m_pDesc &&
2341 nullptr == ( m_pDesc = lcl_FindPageDesc( m_rDoc, aName, nullptr, false ) ) )
2343 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::PageDesc );
2344 return USHRT_MAX == nId ? 0 : nId;
2347 nId = m_pDesc->GetPoolHelpId();
2348 nFileId = m_pDesc->GetPoolHlpFileId();
2349 nPoolId = m_pDesc->GetPoolFormatId();
2350 break;
2352 case SfxStyleFamily::Pseudo:
2353 if( !m_pNumRule &&
2354 nullptr == ( m_pNumRule = lcl_FindNumRule( m_rDoc, aName, nullptr, false ) ) )
2356 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::NumRule );
2357 return USHRT_MAX == nId ? 0 : nId;
2360 nId = m_pNumRule->GetPoolHelpId();
2361 nFileId = m_pNumRule->GetPoolHlpFileId();
2362 nPoolId = m_pNumRule->GetPoolFormatId();
2363 break;
2365 default:
2366 OSL_ENSURE(false, "unknown style family");
2367 return 0;
2370 if( pTmpFormat )
2372 nId = pTmpFormat->GetPoolHelpId();
2373 nFileId = pTmpFormat->GetPoolHlpFileId();
2374 nPoolId = pTmpFormat->GetPoolFormatId();
2377 if( UCHAR_MAX != nFileId )
2379 const OUString *pTemplate = m_rDoc.GetDocPattern( nFileId );
2380 if( pTemplate )
2382 rFile = *pTemplate;
2385 else if( !IsPoolUserFormat( nPoolId ) )
2387 nId = nPoolId;
2390 // because SFX acts like that, with HelpId:
2391 if( USHRT_MAX == nId )
2392 nId = 0; // don't show Help accordingly
2394 return nId;
2397 void SwDocStyleSheet::SetHelpId( const OUString& r, sal_uLong nId )
2399 sal_uInt8 nFileId = static_cast< sal_uInt8 >(m_rDoc.SetDocPattern( r ));
2400 sal_uInt16 nHId = static_cast< sal_uInt16 >(nId); //!! SFX changed over to ULONG arbitrarily!
2402 SwFormat* pTmpFormat = nullptr;
2403 switch( nFamily )
2405 case SfxStyleFamily::Char : pTmpFormat = m_pCharFormat; break;
2406 case SfxStyleFamily::Para : pTmpFormat = m_pColl; break;
2407 case SfxStyleFamily::Frame: pTmpFormat = m_pFrameFormat; break;
2408 case SfxStyleFamily::Page :
2409 const_cast<SwPageDesc*>(m_pDesc)->SetPoolHelpId( nHId );
2410 const_cast<SwPageDesc*>(m_pDesc)->SetPoolHlpFileId( nFileId );
2411 break;
2413 case SfxStyleFamily::Pseudo:
2414 const_cast<SwNumRule*>(m_pNumRule)->SetPoolHelpId( nHId );
2415 const_cast<SwNumRule*>(m_pNumRule)->SetPoolHlpFileId( nFileId );
2416 break;
2418 default:
2419 OSL_ENSURE(false, "unknown style family");
2420 return ;
2422 if( pTmpFormat )
2424 pTmpFormat->SetPoolHelpId( nHId );
2425 pTmpFormat->SetPoolHlpFileId( nFileId );
2429 // methods for DocStyleSheetPool
2430 SwDocStyleSheetPool::SwDocStyleSheetPool( SwDoc& rDocument, bool bOrg )
2431 : SfxStyleSheetBasePool(rDocument.GetAttrPool())
2432 , mxStyleSheet(new SwDocStyleSheet(rDocument, *this))
2433 , m_rDoc(rDocument)
2435 m_bOrganizer = bOrg;
2438 SwDocStyleSheetPool::~SwDocStyleSheetPool()
2442 SfxStyleSheetBase& SwDocStyleSheetPool::Make( const OUString& rName,
2443 SfxStyleFamily eFam,
2444 SfxStyleSearchBits _nMask)
2446 mxStyleSheet->PresetName(rName);
2447 mxStyleSheet->PresetParent(OUString());
2448 mxStyleSheet->PresetFollow(OUString());
2449 mxStyleSheet->SetMask(_nMask) ;
2450 mxStyleSheet->SetFamily(eFam);
2451 mxStyleSheet->SetPhysical(true);
2452 mxStyleSheet->Create();
2454 return *mxStyleSheet;
2457 rtl::Reference<SfxStyleSheetBase> SwDocStyleSheetPool::Create( const SfxStyleSheetBase& /*rOrg*/)
2459 OSL_ENSURE(false , "Create in SW-Stylesheet-Pool not possible" );
2460 return nullptr;
2463 rtl::Reference<SfxStyleSheetBase> SwDocStyleSheetPool::Create( const OUString &,
2464 SfxStyleFamily, SfxStyleSearchBits )
2466 OSL_ENSURE( false, "Create in SW-Stylesheet-Pool not possible" );
2467 return nullptr;
2470 std::unique_ptr<SfxStyleSheetIterator> SwDocStyleSheetPool::CreateIterator( SfxStyleFamily eFam, SfxStyleSearchBits _nMask )
2472 return std::make_unique<SwStyleSheetIterator>(*this, eFam, _nMask);
2475 void SwDocStyleSheetPool::dispose()
2477 mxStyleSheet.clear();
2480 void SwDocStyleSheetPool::Remove( SfxStyleSheetBase* pStyle)
2482 if( !pStyle )
2483 return;
2485 bool bBroadcast = true;
2486 SwImplShellAction aTmpSh( m_rDoc );
2487 const OUString sName = pStyle->GetName();
2488 switch( pStyle->GetFamily() )
2490 case SfxStyleFamily::Char:
2492 SwCharFormat* pFormat = lcl_FindCharFormat(m_rDoc, sName, nullptr, false );
2493 if(pFormat)
2494 m_rDoc.DelCharFormat(pFormat);
2496 break;
2497 case SfxStyleFamily::Para:
2499 SwTextFormatColl* pColl = lcl_FindParaFormat(m_rDoc, sName, nullptr, false );
2500 if(pColl)
2501 m_rDoc.DelTextFormatColl(pColl);
2503 break;
2504 case SfxStyleFamily::Frame:
2506 SwFrameFormat* pFormat = lcl_FindFrameFormat(m_rDoc, sName, nullptr, false );
2507 if(pFormat)
2508 m_rDoc.DelFrameFormat(pFormat);
2510 break;
2511 case SfxStyleFamily::Page :
2513 m_rDoc.DelPageDesc(sName);
2515 break;
2517 case SfxStyleFamily::Pseudo:
2519 if( !m_rDoc.DelNumRule( sName ) )
2520 // Only send Broadcast, when something was deleted
2521 bBroadcast = false;
2523 break;
2525 case SfxStyleFamily::Table:
2527 m_rDoc.DelTableStyle(sName);
2529 break;
2531 default:
2532 OSL_ENSURE(false, "unknown style family");
2533 bBroadcast = false;
2536 if( bBroadcast )
2537 Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetErased, *pStyle ) );
2540 bool SwDocStyleSheetPool::SetParent( SfxStyleFamily eFam,
2541 const OUString &rStyle, const OUString &rParent )
2543 SwFormat* pFormat = nullptr, *pParent = nullptr;
2544 switch( eFam )
2546 case SfxStyleFamily::Char :
2547 if( nullptr != ( pFormat = lcl_FindCharFormat( m_rDoc, rStyle ) ) && !rParent.isEmpty() )
2548 pParent = lcl_FindCharFormat(m_rDoc, rParent );
2549 break;
2551 case SfxStyleFamily::Para :
2552 if( nullptr != ( pFormat = lcl_FindParaFormat( m_rDoc, rStyle ) ) && !rParent.isEmpty() )
2553 pParent = lcl_FindParaFormat( m_rDoc, rParent );
2554 break;
2556 case SfxStyleFamily::Frame:
2557 if( nullptr != ( pFormat = lcl_FindFrameFormat( m_rDoc, rStyle ) ) && !rParent.isEmpty() )
2558 pParent = lcl_FindFrameFormat( m_rDoc, rParent );
2559 break;
2561 case SfxStyleFamily::Page:
2562 case SfxStyleFamily::Pseudo:
2563 break;
2565 default:
2566 OSL_ENSURE(false, "unknown style family");
2569 bool bRet = false;
2570 if( pFormat && pFormat->DerivedFrom() &&
2571 pFormat->DerivedFrom()->GetName() != rParent )
2574 SwImplShellAction aTmpSh( m_rDoc );
2575 bRet = pFormat->SetDerivedFrom( pParent );
2578 if( bRet )
2580 // only for Broadcasting
2581 mxStyleSheet->PresetName( rStyle );
2582 mxStyleSheet->PresetParent( rParent );
2583 if( SfxStyleFamily::Para == eFam )
2584 mxStyleSheet->PresetFollow( static_cast<SwTextFormatColl*>(pFormat)->
2585 GetNextTextFormatColl().GetName() );
2586 else
2587 mxStyleSheet->PresetFollow( OUString() );
2589 Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified, *mxStyleSheet ) );
2593 return bRet;
2596 SfxStyleSheetBase* SwDocStyleSheetPool::Find(const OUString& rName,
2597 SfxStyleFamily eFam, SfxStyleSearchBits n) const
2599 SfxStyleSearchBits nSMask = n;
2600 if( SfxStyleFamily::Para == eFam && m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) )
2602 // then only HTML-Templates are of interest
2603 if( SfxStyleSearchBits::All == nSMask )
2604 nSMask = SfxStyleSearchBits::SwHtml | SfxStyleSearchBits::UserDefined | SfxStyleSearchBits::Used;
2605 else
2606 nSMask &= SfxStyleSearchBits::Used | SfxStyleSearchBits::UserDefined |
2607 SfxStyleSearchBits::SwCondColl | SfxStyleSearchBits::SwHtml;
2608 if( nSMask == SfxStyleSearchBits::Auto )
2609 nSMask = SfxStyleSearchBits::SwHtml;
2612 const bool bSearchUsed = ( n != SfxStyleSearchBits::All && n & SfxStyleSearchBits::Used );
2613 const sw::BroadcastingModify* pMod = nullptr;
2615 mxStyleSheet->SetPhysical( false );
2616 mxStyleSheet->PresetName( rName );
2617 mxStyleSheet->SetFamily( eFam );
2618 bool bFnd = mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
2620 if( mxStyleSheet->IsPhysical() )
2622 switch( eFam )
2624 case SfxStyleFamily::Char:
2625 pMod = mxStyleSheet->GetCharFormat();
2626 break;
2628 case SfxStyleFamily::Para:
2629 pMod = mxStyleSheet->GetCollection();
2630 break;
2632 case SfxStyleFamily::Frame:
2633 pMod = mxStyleSheet->GetFrameFormat();
2634 break;
2636 case SfxStyleFamily::Page:
2637 pMod = mxStyleSheet->GetPageDesc();
2638 break;
2640 case SfxStyleFamily::Pseudo:
2642 const SwNumRule* pRule = mxStyleSheet->GetNumRule();
2643 if( pRule &&
2644 !bSearchUsed &&
2645 (( nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
2646 ? !(pRule->GetPoolFormatId() & USER_FMT)
2647 // searched for used and found none
2648 : bSearchUsed ))
2649 bFnd = false;
2651 break;
2653 case SfxStyleFamily::Table:
2654 case SfxStyleFamily::Cell:
2655 break;
2656 default:
2657 OSL_ENSURE(false, "unknown style family");
2661 // then evaluate the mask:
2662 if( pMod && !bSearchUsed )
2664 const sal_uInt16 nId = SfxStyleFamily::Page == eFam
2665 ? static_cast<const SwPageDesc*>(pMod)->GetPoolFormatId()
2666 : static_cast<const SwFormat*>(pMod)->GetPoolFormatId();
2668 if( ( nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
2669 && !(nId & USER_FMT) )
2670 // searched for used and found none
2671 bFnd = false;
2673 return bFnd ? mxStyleSheet.get() : nullptr;
2676 SwStyleSheetIterator::SwStyleSheetIterator(SwDocStyleSheetPool& rBase,
2677 SfxStyleFamily eFam, SfxStyleSearchBits n )
2678 : SfxStyleSheetIterator(&rBase, eFam, n)
2679 , mxIterSheet(new SwDocStyleSheet(rBase.GetDoc(), rBase))
2680 , mxStyleSheet(new SwDocStyleSheet(rBase.GetDoc(), rBase))
2682 m_bFirstCalled = false;
2683 m_nLastPos = 0;
2684 StartListening(rBase);
2687 SwStyleSheetIterator::~SwStyleSheetIterator()
2689 EndListening( *mxIterSheet->GetPool() );
2692 sal_Int32 SwStyleSheetIterator::Count()
2694 // let the list fill correctly!!
2695 if( !m_bFirstCalled )
2696 First();
2697 return m_aLst.size();
2700 SfxStyleSheetBase* SwStyleSheetIterator::operator[]( sal_Int32 nIdx )
2702 // found
2703 if( !m_bFirstCalled )
2704 First();
2705 auto const & rEntry = m_aLst[ nIdx ];
2706 mxStyleSheet->PresetNameAndFamily( rEntry.first, rEntry.second );
2707 mxStyleSheet->SetPhysical( false );
2708 mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
2710 return mxStyleSheet.get();
2713 SfxStyleSheetBase* SwStyleSheetIterator::First()
2715 // Delete old list
2716 m_bFirstCalled = true;
2717 m_nLastPos = 0;
2718 m_aLst.clear();
2720 // Delete current
2721 mxIterSheet->Reset();
2723 const SwDoc& rDoc = static_cast<const SwDocStyleSheetPool*>(pBasePool)->GetDoc();
2724 const SfxStyleSearchBits nSrchMask = nMask;
2725 const bool bIsSearchUsed = SearchUsed();
2727 bool bSearchHidden( nMask & SfxStyleSearchBits::Hidden );
2728 bool bOnlyHidden = nMask == SfxStyleSearchBits::Hidden;
2730 const bool bOrganizer = static_cast<const SwDocStyleSheetPool*>(pBasePool)->IsOrganizerMode();
2731 bool bAll = ( nSrchMask & SfxStyleSearchBits::AllVisible ) == SfxStyleSearchBits::AllVisible;
2733 if( nSearchFamily == SfxStyleFamily::Char
2734 || nSearchFamily == SfxStyleFamily::All )
2736 const size_t nArrLen = rDoc.GetCharFormats()->size();
2737 for( size_t i = 0; i < nArrLen; i++ )
2739 SwCharFormat* pFormat = (*rDoc.GetCharFormats())[ i ];
2741 const bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(*pFormat));
2742 if( ( !bSearchHidden && pFormat->IsHidden() && !bUsed ) || ( pFormat->IsDefault() && pFormat != rDoc.GetDfltCharFormat() ) )
2743 continue;
2745 if ( nSrchMask == SfxStyleSearchBits::Hidden && !pFormat->IsHidden( ) )
2746 continue;
2748 if( !bUsed )
2750 // Standard is no User template
2751 const sal_uInt16 nId = rDoc.GetDfltCharFormat() == pFormat ?
2752 sal_uInt16( RES_POOLCHR_INET_NORMAL ):
2753 pFormat->GetPoolFormatId();
2754 if( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
2755 ? !(nId & USER_FMT)
2756 // searched for used and found none
2757 : bIsSearchUsed )
2759 continue;
2762 if( rDoc.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) && !(nId & USER_FMT) &&
2763 ( RES_POOLCHR_HTML_BEGIN > nId || nId >= RES_POOLCHR_HTML_END ) &&
2764 RES_POOLCHR_INET_NORMAL != nId &&
2765 RES_POOLCHR_INET_VISIT != nId &&
2766 RES_POOLCHR_FOOTNOTE != nId &&
2767 RES_POOLCHR_ENDNOTE != nId )
2768 continue;
2771 m_aLst.Append( SfxStyleFamily::Char, pFormat == rDoc.GetDfltCharFormat()
2772 ? SwResId(STR_POOLCHR_STANDARD)
2773 : pFormat->GetName() );
2776 // PoolFormat
2777 if( bAll )
2779 if( ! rDoc.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) )
2780 AppendStyleList(SwStyleNameMapper::GetChrFormatUINameArray(),
2781 bIsSearchUsed, bSearchHidden, bOnlyHidden,
2782 SwGetPoolIdFromName::ChrFmt, SfxStyleFamily::Char);
2783 else
2785 m_aLst.Append( SfxStyleFamily::Char, SwStyleNameMapper::GetChrFormatUINameArray()[
2786 RES_POOLCHR_INET_NORMAL - RES_POOLCHR_BEGIN ] );
2787 m_aLst.Append( SfxStyleFamily::Char, SwStyleNameMapper::GetChrFormatUINameArray()[
2788 RES_POOLCHR_INET_VISIT - RES_POOLCHR_BEGIN ] );
2789 m_aLst.Append( SfxStyleFamily::Char, SwStyleNameMapper::GetChrFormatUINameArray()[
2790 RES_POOLCHR_ENDNOTE - RES_POOLCHR_BEGIN ] );
2791 m_aLst.Append( SfxStyleFamily::Char, SwStyleNameMapper::GetChrFormatUINameArray()[
2792 RES_POOLCHR_FOOTNOTE - RES_POOLCHR_BEGIN ] );
2794 AppendStyleList(SwStyleNameMapper::GetHTMLChrFormatUINameArray(),
2795 bIsSearchUsed, bSearchHidden, bOnlyHidden,
2796 SwGetPoolIdFromName::ChrFmt, SfxStyleFamily::Char);
2800 if( nSearchFamily == SfxStyleFamily::Para ||
2801 nSearchFamily == SfxStyleFamily::All )
2803 SfxStyleSearchBits nSMask = nSrchMask;
2804 if( rDoc.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) )
2806 // then only HTML-Template are of interest
2807 if( SfxStyleSearchBits::AllVisible == ( nSMask & SfxStyleSearchBits::AllVisible ) )
2808 nSMask = SfxStyleSearchBits::SwHtml | SfxStyleSearchBits::UserDefined |
2809 SfxStyleSearchBits::Used;
2810 else
2811 nSMask &= SfxStyleSearchBits::Used | SfxStyleSearchBits::UserDefined |
2812 SfxStyleSearchBits::SwCondColl | SfxStyleSearchBits::SwHtml;
2813 if( nSMask == SfxStyleSearchBits::Auto )
2814 nSMask = SfxStyleSearchBits::SwHtml;
2817 const size_t nArrLen = rDoc.GetTextFormatColls()->size();
2818 for( size_t i = 0; i < nArrLen; i++ )
2820 SwTextFormatColl* pColl = (*rDoc.GetTextFormatColls())[ i ];
2822 const bool bUsed = bOrganizer || rDoc.IsUsed(*pColl);
2823 if ( ( !bSearchHidden && pColl->IsHidden( ) && !bUsed ) || pColl->IsDefault() )
2824 continue;
2826 if ( nSMask == SfxStyleSearchBits::Hidden && !pColl->IsHidden( ) )
2827 continue;
2829 if( !(bIsSearchUsed && bUsed ))
2831 const sal_uInt16 nId = pColl->GetPoolFormatId();
2832 auto tmpMask = nSMask & ~SfxStyleSearchBits::Used;
2833 if (tmpMask == SfxStyleSearchBits::UserDefined)
2835 if(!IsPoolUserFormat(nId)) continue;
2837 else if (tmpMask == SfxStyleSearchBits::SwText)
2839 if((nId & COLL_GET_RANGE_BITS) != COLL_TEXT_BITS) continue;
2841 else if (tmpMask == SfxStyleSearchBits::SwChapter)
2843 if((nId & COLL_GET_RANGE_BITS) != COLL_DOC_BITS) continue;
2845 else if (tmpMask == SfxStyleSearchBits::SwList)
2847 if((nId & COLL_GET_RANGE_BITS) != COLL_LISTS_BITS) continue;
2849 else if (tmpMask == SfxStyleSearchBits::SwIndex)
2851 if((nId & COLL_GET_RANGE_BITS) != COLL_REGISTER_BITS) continue;
2853 else if (tmpMask == SfxStyleSearchBits::SwExtra)
2855 if((nId & COLL_GET_RANGE_BITS) != COLL_EXTRA_BITS) continue;
2857 else if (tmpMask == (SfxStyleSearchBits::SwHtml | SfxStyleSearchBits::UserDefined)
2858 || tmpMask == SfxStyleSearchBits::SwHtml)
2860 if((tmpMask & SfxStyleSearchBits::UserDefined) && IsPoolUserFormat(nId))
2861 ; // do nothing
2862 else if( (nId & COLL_GET_RANGE_BITS) != COLL_HTML_BITS)
2864 // but some we also want to see in this section
2865 bool bContinue = true;
2866 switch( nId )
2868 case RES_POOLCOLL_SEND_ADDRESS: // --> ADDRESS
2869 case RES_POOLCOLL_TABLE_HDLN: // --> TH
2870 case RES_POOLCOLL_TABLE: // --> TD
2871 case RES_POOLCOLL_TEXT: // --> P
2872 case RES_POOLCOLL_HEADLINE_BASE:// --> H
2873 case RES_POOLCOLL_HEADLINE1: // --> H1
2874 case RES_POOLCOLL_HEADLINE2: // --> H2
2875 case RES_POOLCOLL_HEADLINE3: // --> H3
2876 case RES_POOLCOLL_HEADLINE4: // --> H4
2877 case RES_POOLCOLL_HEADLINE5: // --> H5
2878 case RES_POOLCOLL_HEADLINE6: // --> H6
2879 case RES_POOLCOLL_STANDARD: // --> P
2880 case RES_POOLCOLL_FOOTNOTE:
2881 case RES_POOLCOLL_ENDNOTE:
2882 bContinue = false;
2883 break;
2885 if( bContinue )
2886 continue;
2889 else if (tmpMask == SfxStyleSearchBits::SwCondColl)
2891 if( RES_CONDTXTFMTCOLL != pColl->Which() ) continue;
2893 else
2895 // searched for used and found none
2896 if( bIsSearchUsed )
2897 continue;
2900 m_aLst.Append( SfxStyleFamily::Para, pColl->GetName() );
2903 bAll = ( nSMask & SfxStyleSearchBits::AllVisible ) == SfxStyleSearchBits::AllVisible;
2904 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwText )
2905 AppendStyleList(SwStyleNameMapper::GetTextUINameArray(),
2906 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para );
2907 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwChapter )
2908 AppendStyleList(SwStyleNameMapper::GetDocUINameArray(),
2909 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2910 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwList )
2911 AppendStyleList(SwStyleNameMapper::GetListsUINameArray(),
2912 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2913 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwIndex )
2914 AppendStyleList(SwStyleNameMapper::GetRegisterUINameArray(),
2915 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2916 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwExtra )
2917 AppendStyleList(SwStyleNameMapper::GetExtraUINameArray(),
2918 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2919 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwCondColl )
2921 if( !bIsSearchUsed ||
2922 rDoc.getIDocumentStylePoolAccess().IsPoolTextCollUsed( RES_POOLCOLL_TEXT ))
2923 m_aLst.Append( SfxStyleFamily::Para, SwStyleNameMapper::GetTextUINameArray()[
2924 RES_POOLCOLL_TEXT - RES_POOLCOLL_TEXT_BEGIN ] );
2926 if ( bAll ||
2927 (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwHtml ||
2928 (nSMask & ~SfxStyleSearchBits::Used) ==
2929 (SfxStyleSearchBits::SwHtml | SfxStyleSearchBits::UserDefined) )
2931 AppendStyleList(SwStyleNameMapper::GetHTMLUINameArray(),
2932 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2933 if( !bAll )
2935 // then also the ones, that we are mapping:
2936 static sal_uInt16 aPoolIds[] = {
2937 RES_POOLCOLL_SEND_ADDRESS, // --> ADDRESS
2938 RES_POOLCOLL_TABLE_HDLN, // --> TH
2939 RES_POOLCOLL_TABLE, // --> TD
2940 RES_POOLCOLL_STANDARD, // --> P
2941 RES_POOLCOLL_TEXT, // --> P
2942 RES_POOLCOLL_HEADLINE_BASE, // --> H
2943 RES_POOLCOLL_HEADLINE1, // --> H1
2944 RES_POOLCOLL_HEADLINE2, // --> H2
2945 RES_POOLCOLL_HEADLINE3, // --> H3
2946 RES_POOLCOLL_HEADLINE4, // --> H4
2947 RES_POOLCOLL_HEADLINE5, // --> H5
2948 RES_POOLCOLL_HEADLINE6, // --> H6
2949 RES_POOLCOLL_FOOTNOTE,
2950 RES_POOLCOLL_ENDNOTE,
2954 sal_uInt16* pPoolIds = aPoolIds;
2955 OUString s;
2956 while( *pPoolIds )
2958 if( !bIsSearchUsed || rDoc.getIDocumentStylePoolAccess().IsPoolTextCollUsed( *pPoolIds ) )
2960 s = SwStyleNameMapper::GetUIName( *pPoolIds, s );
2961 m_aLst.Append( SfxStyleFamily::Para, s);
2963 ++pPoolIds;
2969 if( nSearchFamily == SfxStyleFamily::Frame ||
2970 nSearchFamily == SfxStyleFamily::All )
2972 const size_t nArrLen = rDoc.GetFrameFormats()->size();
2973 for( size_t i = 0; i < nArrLen; i++ )
2975 const SwFrameFormat* pFormat = (*rDoc.GetFrameFormats())[ i ];
2977 bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(*pFormat));
2978 if( ( !bSearchHidden && pFormat->IsHidden( ) && !bUsed ) || pFormat->IsDefault() || pFormat->IsAuto() )
2979 continue;
2981 if ( nSrchMask == SfxStyleSearchBits::Hidden && !pFormat->IsHidden( ) )
2982 continue;
2984 const sal_uInt16 nId = pFormat->GetPoolFormatId();
2985 if( !bUsed )
2987 if( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
2988 ? !(nId & USER_FMT)
2989 // searched for used and found none
2990 : bIsSearchUsed )
2992 continue;
2996 m_aLst.Append( SfxStyleFamily::Frame, pFormat->GetName() );
2999 // PoolFormat
3000 if ( bAll )
3001 AppendStyleList(SwStyleNameMapper::GetFrameFormatUINameArray(),
3002 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::FrmFmt, SfxStyleFamily::Frame);
3005 if( nSearchFamily == SfxStyleFamily::Page ||
3006 nSearchFamily == SfxStyleFamily::All )
3008 const size_t nCount = rDoc.GetPageDescCnt();
3009 for(size_t i = 0; i < nCount; ++i)
3011 const SwPageDesc& rDesc = rDoc.GetPageDesc(i);
3012 const sal_uInt16 nId = rDesc.GetPoolFormatId();
3013 bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rDesc));
3014 if( !bUsed )
3016 if ( ( !bSearchHidden && rDesc.IsHidden() ) ||
3017 ( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
3018 ? !(nId & USER_FMT)
3019 // searched for used and found none
3020 : bIsSearchUsed ) )
3021 continue;
3024 if ( nSrchMask == SfxStyleSearchBits::Hidden && !rDesc.IsHidden( ) )
3025 continue;
3027 m_aLst.Append( SfxStyleFamily::Page, rDesc.GetName() );
3029 if ( bAll )
3030 AppendStyleList(SwStyleNameMapper::GetPageDescUINameArray(),
3031 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::PageDesc, SfxStyleFamily::Page);
3034 if( nSearchFamily == SfxStyleFamily::Pseudo ||
3035 nSearchFamily == SfxStyleFamily::All )
3037 const SwNumRuleTable& rNumTable = rDoc.GetNumRuleTable();
3038 for(auto const& rNum: rNumTable)
3040 const SwNumRule& rRule = *rNum;
3041 if( !rRule.IsAutoRule() )
3043 if ( nSrchMask == SfxStyleSearchBits::Hidden && !rRule.IsHidden( ) )
3044 continue;
3046 bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(rRule));
3047 if( !bUsed )
3049 if( ( !bSearchHidden && rRule.IsHidden() ) ||
3050 ( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
3051 ? !(rRule.GetPoolFormatId() & USER_FMT)
3052 // searched for used and found none
3053 : bIsSearchUsed ) )
3054 continue;
3057 m_aLst.Append( SfxStyleFamily::Pseudo, rRule.GetName() );
3060 if ( bAll )
3061 AppendStyleList(SwStyleNameMapper::GetNumRuleUINameArray(),
3062 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::NumRule, SfxStyleFamily::Pseudo);
3065 if( nSearchFamily == SfxStyleFamily::Table ||
3066 nSearchFamily == SfxStyleFamily::All )
3068 const SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
3069 for(size_t i = 0; i < rTableStyles.size(); ++i)
3071 const SwTableAutoFormat& rTableStyle = rTableStyles[i];
3073 bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(rTableStyle));
3074 if(!bUsed)
3076 if(nSrchMask == SfxStyleSearchBits::Hidden && !rTableStyle.IsHidden())
3077 continue;
3079 if( (!bSearchHidden && rTableStyle.IsHidden() ) ||
3080 ( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
3081 ? !rTableStyle.IsUserDefined()
3082 // searched for used and found none
3083 : bIsSearchUsed ) )
3084 continue;
3087 m_aLst.Append( SfxStyleFamily::Table, rTableStyle.GetName() );
3091 if( nSearchFamily == SfxStyleFamily::Cell ||
3092 nSearchFamily == SfxStyleFamily::All )
3094 const auto& aTableTemplateMap = SwTableAutoFormat::GetTableTemplateMap();
3095 if (rDoc.HasTableStyles())
3097 const SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
3098 for(size_t i = 0; i < rTableStyles.size(); ++i)
3100 const SwTableAutoFormat& rTableStyle = rTableStyles[i];
3101 for(size_t nBoxFormat = 0; nBoxFormat < aTableTemplateMap.size(); ++nBoxFormat)
3103 const sal_uInt32 nBoxIndex = aTableTemplateMap[nBoxFormat];
3104 const SwBoxAutoFormat& rBoxFormat = rTableStyle.GetBoxFormat(nBoxIndex);
3105 OUString sBoxFormatName;
3106 SwStyleNameMapper::FillProgName(rTableStyle.GetName(), sBoxFormatName, SwGetPoolIdFromName::TabStyle);
3107 sBoxFormatName += rTableStyle.GetTableTemplateCellSubName(rBoxFormat);
3108 m_aLst.Append( SfxStyleFamily::Cell, sBoxFormatName );
3112 const SwCellStyleTable& rCellStyles = rDoc.GetCellStyles();
3113 for(size_t i = 0; i < rCellStyles.size(); ++i)
3114 m_aLst.Append( SfxStyleFamily::Cell, rCellStyles[i].GetName() );
3117 if(!m_aLst.empty())
3119 m_nLastPos = SAL_MAX_UINT32;
3120 return Next();
3122 return nullptr;
3125 SfxStyleSheetBase* SwStyleSheetIterator::Next()
3127 assert(m_bFirstCalled);
3128 ++m_nLastPos;
3129 if(m_nLastPos < m_aLst.size())
3131 auto const & rEntry = m_aLst[m_nLastPos];
3132 mxIterSheet->PresetNameAndFamily(rEntry.first, rEntry.second);
3133 mxIterSheet->SetPhysical( false );
3134 mxIterSheet->SetMask( nMask );
3135 if(mxIterSheet->pSet)
3137 mxIterSheet->pSet->ClearItem();
3138 mxIterSheet->pSet= nullptr;
3140 return mxIterSheet.get();
3142 return nullptr;
3145 SfxStyleSheetBase* SwStyleSheetIterator::Find(const OUString& rName)
3147 // searching
3148 if( !m_bFirstCalled )
3149 First();
3151 m_nLastPos = m_aLst.FindName( nSearchFamily, rName );
3152 if( SAL_MAX_UINT32 != m_nLastPos )
3154 // found
3155 auto const & rEntry = m_aLst[m_nLastPos];
3156 mxStyleSheet->PresetNameAndFamily(rEntry.first, rEntry.second);
3157 // new name is set, so determine its Data
3158 mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
3159 if( !mxStyleSheet->IsPhysical() )
3160 mxStyleSheet->SetPhysical( false );
3162 return mxStyleSheet.get();
3164 return nullptr;
3167 void SwStyleSheetIterator::AppendStyleList(const std::vector<OUString>& rList,
3168 bool bTestUsed, bool bTestHidden, bool bOnlyHidden,
3169 SwGetPoolIdFromName nSection, SfxStyleFamily eFamily )
3171 const SwDoc& rDoc = static_cast<const SwDocStyleSheetPool*>(pBasePool)->GetDoc();
3172 bool bUsed = false;
3173 for (const auto & i : rList)
3175 bool bHidden = false;
3176 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(i, nSection);
3177 switch ( nSection )
3179 case SwGetPoolIdFromName::TxtColl:
3181 bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolTextCollUsed( nId );
3182 SwFormat* pFormat = rDoc.FindTextFormatCollByName( i );
3183 bHidden = pFormat && pFormat->IsHidden( );
3185 break;
3186 case SwGetPoolIdFromName::ChrFmt:
3188 bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolFormatUsed( nId );
3189 SwFormat* pFormat = rDoc.FindCharFormatByName( i );
3190 bHidden = pFormat && pFormat->IsHidden( );
3192 break;
3193 case SwGetPoolIdFromName::FrmFmt:
3195 bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolFormatUsed( nId );
3196 SwFormat* pFormat = rDoc.FindFrameFormatByName( i );
3197 bHidden = pFormat && pFormat->IsHidden( );
3199 break;
3200 case SwGetPoolIdFromName::PageDesc:
3202 bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolPageDescUsed( nId );
3203 SwPageDesc* pPgDesc = rDoc.FindPageDesc(i);
3204 bHidden = pPgDesc && pPgDesc->IsHidden( );
3206 break;
3207 case SwGetPoolIdFromName::NumRule:
3209 SwNumRule* pRule = rDoc.FindNumRulePtr( i );
3210 bUsed = pRule && rDoc.IsUsed(*pRule);
3211 bHidden = pRule && pRule->IsHidden( );
3213 break;
3214 default:
3215 OSL_ENSURE( false, "unknown PoolFormat-Id" );
3218 bool bMatchHidden = ( bTestHidden && ( bHidden || !bOnlyHidden ) ) || ( !bTestHidden && ( !bHidden || bUsed ) );
3219 if ( ( !bTestUsed && bMatchHidden ) || ( bTestUsed && bUsed ) )
3220 m_aLst.Append( eFamily, i );
3224 void SwDocStyleSheetPool::InvalidateIterator()
3226 if (SfxStyleSheetIterator* pIter = GetCachedIterator())
3227 dynamic_cast<SwStyleSheetIterator&>(*pIter).InvalidateIterator();
3230 void SwStyleSheetIterator::InvalidateIterator()
3232 // potentially we could send an SfxHint to Notify but currently it's
3233 // iterating over the vector anyway so would still be slow - why does
3234 // this iterator not use a map?
3235 m_bFirstCalled = false;
3236 m_nLastPos = 0;
3237 m_aLst.clear();
3240 void SwStyleSheetIterator::Notify( SfxBroadcaster&, const SfxHint& rHint )
3242 // search and remove from View-List!!
3243 const SfxStyleSheetHint* pStyleSheetHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint);
3244 if( pStyleSheetHint &&
3245 SfxHintId::StyleSheetErased == pStyleSheetHint->GetId() )
3247 SfxStyleSheetBase* pStyle = pStyleSheetHint->GetStyleSheet();
3249 if (pStyle)
3250 m_aLst.RemoveName(pStyle->GetFamily(), pStyle->GetName());
3254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */