LibreOffice Module sw (master) 1
docstyle.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <memory>
21#include <sal/config.h>
22#include <sal/log.hxx>
23#include <osl/diagnose.h>
24
25#include <cstdlib>
26
27#include <hintids.hxx>
28#include <rtl/ustrbuf.hxx>
29#include <svl/itemiter.hxx>
30#include <svl/eitem.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>
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>
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>
69
70using namespace com::sun::star;
71
72// At the names' publication, this character is removed again and the
73// family is newly generated.
74
75// In addition now there is the Bit bPhysical. In case this Bit is
76// TRUE, the Pool-Formatnames are not being submitted.
77
78namespace {
79
80class SwImplShellAction
81{
82 SwWrtShell* m_pSh;
83 std::unique_ptr<CurrShell> m_pCurrSh;
84public:
85 explicit SwImplShellAction( SwDoc& rDoc );
86 ~SwImplShellAction() COVERITY_NOEXCEPT_FALSE;
87 SwImplShellAction(const SwImplShellAction&) = delete;
88 SwImplShellAction& operator=(const SwImplShellAction&) = delete;
89};
90
91}
92
93SwImplShellAction::SwImplShellAction( SwDoc& rDoc )
94{
95 if( rDoc.GetDocShell() )
96 m_pSh = rDoc.GetDocShell()->GetWrtShell();
97 else
98 m_pSh = nullptr;
99
100 if( m_pSh )
101 {
102 m_pCurrSh.reset( new CurrShell( m_pSh ) );
103 m_pSh->StartAllAction();
104 }
105}
106
107SwImplShellAction::~SwImplShellAction() COVERITY_NOEXCEPT_FALSE
108{
109 if( m_pCurrSh )
110 {
111 m_pSh->EndAllAction();
112 m_pCurrSh.reset();
113 }
114}
115
116// find/create SwCharFormate
117// possibly fill Style
119 const OUString& rName,
120 SwDocStyleSheet* pStyle = nullptr,
121 bool bCreate = true )
122{
123 SwCharFormat* pFormat = nullptr;
124 if (!rName.isEmpty())
125 {
126 pFormat = rDoc.FindCharFormatByName( rName );
127 if( !pFormat && rName == SwResId(STR_POOLCHR_STANDARD))
128 {
129 // Standard-Character template
130 pFormat = rDoc.GetDfltCharFormat();
131 }
132
133 if( !pFormat && bCreate )
134 { // explore Pool
136 if(nId != USHRT_MAX)
138 }
139 }
140 if(pStyle)
141 {
142 if(pFormat)
143 {
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() );
150 }
151 else
152 pStyle->SetPhysical(false);
153 }
154 return pFormat;
155}
156
157// find/create ParaFormats
158// fill Style
160 const OUString& rName,
161 SwDocStyleSheet* pStyle = nullptr,
162 bool bCreate = true )
163{
164 SwTextFormatColl* pColl = nullptr;
165
166 if (!rName.isEmpty())
167 {
168 pColl = rDoc.FindTextFormatCollByName( rName );
169 if( !pColl && bCreate )
170 { // explore Pool
172 if(nId != USHRT_MAX)
174 }
175 }
176
177 if(pStyle)
178 {
179 if(pColl)
180 {
181 pStyle->SetPhysical(true);
182 if( pColl->DerivedFrom() && !pColl->DerivedFrom()->IsDefault() )
183 pStyle->PresetParent( pColl->DerivedFrom()->GetName() );
184 else
185 pStyle->PresetParent( OUString() );
186
187 SwTextFormatColl& rNext = pColl->GetNextTextFormatColl();
188 pStyle->PresetFollow(rNext.GetName());
189 }
190 else
191 pStyle->SetPhysical(false);
192 }
193 return pColl;
194}
195
196// Border formats
198 const OUString& rName,
199 SwDocStyleSheet* pStyle = nullptr,
200 bool bCreate = true )
201{
202 SwFrameFormat* pFormat = nullptr;
203 if( !rName.isEmpty() )
204 {
205 pFormat = rDoc.FindFrameFormatByName( rName );
206 if( !pFormat && bCreate )
207 { // explore Pool
209 if(nId != USHRT_MAX)
211 }
212 }
213
214 if(pStyle)
215 {
216 if(pFormat)
217 {
218 pStyle->SetPhysical(true);
219 if( pFormat->DerivedFrom() && !pFormat->DerivedFrom()->IsDefault() )
220 pStyle->PresetParent( pFormat->DerivedFrom()->GetName() );
221 else
222 pStyle->PresetParent( OUString() );
223 }
224 else
225 pStyle->SetPhysical(false);
226 }
227 return pFormat;
228}
229
230// Page descriptors
231static const SwPageDesc* lcl_FindPageDesc( SwDoc& rDoc,
232 const OUString& rName,
233 SwDocStyleSheet* pStyle = nullptr,
234 bool bCreate = true )
235{
236 const SwPageDesc* pDesc = nullptr;
237
238 if (!rName.isEmpty())
239 {
240 pDesc = rDoc.FindPageDesc(rName);
241 if( !pDesc && bCreate )
242 {
244 if(nId != USHRT_MAX)
246 }
247 }
248
249 if(pStyle)
250 {
251 if(pDesc)
252 {
253 pStyle->SetPhysical(true);
254 if(pDesc->GetFollow())
255 pStyle->PresetFollow(pDesc->GetFollow()->GetName());
256 else
257 pStyle->PresetParent( OUString() );
258 }
259 else
260 pStyle->SetPhysical(false);
261 }
262 return pDesc;
263}
264
265static const SwNumRule* lcl_FindNumRule( SwDoc& rDoc,
266 const OUString& rName,
267 SwDocStyleSheet* pStyle = nullptr,
268 bool bCreate = true )
269{
270 const SwNumRule* pRule = nullptr;
271
272 if (!rName.isEmpty())
273 {
274 pRule = rDoc.FindNumRulePtr( rName );
275 if( !pRule && bCreate )
276 {
278 if(nId != USHRT_MAX)
280 }
281 }
282
283 if(pStyle)
284 {
285 if(pRule)
286 {
287 pStyle->SetPhysical(true);
288 pStyle->PresetParent( OUString() );
289 }
290 else
291 pStyle->SetPhysical(false);
292 }
293 return pRule;
294}
295
296static SwTableAutoFormat* lcl_FindTableStyle(SwDoc& rDoc, const OUString& rName, SwDocStyleSheet *pStyle = nullptr, bool bCreate = true)
297{
298 SwTableAutoFormat* pFormat = nullptr;
299
300 if (!rName.isEmpty())
301 {
302 pFormat = rDoc.GetTableStyles().FindAutoFormat(rName);
303 if (!pFormat && bCreate)
304 {
305 SwTableAutoFormat aNew(rName);
306 rDoc.GetTableStyles().AddAutoFormat(aNew);
307 }
308 }
309
310 if(pStyle)
311 {
312 if(pFormat)
313 {
314 pStyle->SetPhysical(true);
315 pStyle->PresetParent(OUString());
316 }
317 else
318 pStyle->SetPhysical(false);
319 }
320 return pFormat;
321}
322
323static const SwBoxAutoFormat* lcl_FindCellStyle(SwDoc& rDoc, std::u16string_view rName, SwDocStyleSheet *pStyle)
324{
325 const SwBoxAutoFormat* pFormat = rDoc.GetCellStyles().GetBoxFormat(rName);
326
327 if (!pFormat)
328 {
329 const auto& aTableTemplateMap = SwTableAutoFormat::GetTableTemplateMap();
330 SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
331 for (size_t i=0; i < rTableStyles.size() && !pFormat; ++i)
332 {
333 const SwTableAutoFormat& rTableStyle = rTableStyles[i];
334 for (size_t nBoxFormat=0; nBoxFormat < aTableTemplateMap.size() && !pFormat; ++nBoxFormat)
335 {
336 const sal_uInt32 nBoxIndex = aTableTemplateMap[nBoxFormat];
337 const SwBoxAutoFormat& rBoxFormat = rTableStyle.GetBoxFormat(nBoxIndex);
338 OUString sBoxFormatName;
340 sBoxFormatName += rTableStyle.GetTableTemplateCellSubName(rBoxFormat);
341 if (rName == sBoxFormatName)
342 pFormat = &rBoxFormat;
343 }
344 }
345 }
346
347 if(pStyle)
348 {
349 if(pFormat)
350 {
351 pStyle->SetPhysical(true);
352 pStyle->PresetParent(OUString());
353 }
354 else
355 pStyle->SetPhysical(false);
356 }
357 return pFormat;
358}
359
361 const OUString& rName)
362{
363 if(!maImpl.empty())
364 {
365 UniqueHash::const_iterator it = maUnique.find(std::pair<SfxStyleFamily,OUString>{eFam, rName});
366 if (it != maUnique.end())
367 {
368 sal_uInt32 nIdx = it->second;
369 assert (nIdx < maImpl.size());
370 assert (maImpl.size() == maUnique.size());
371 return nIdx;
372 }
373 }
374 return SAL_MAX_UINT32;
375}
376
378{
379 maUnique.clear();
380 for (size_t i = 0; i < maImpl.size(); i++)
381 maUnique[maImpl[i]] = i;
382 assert (maImpl.size() == maUnique.size());
383}
384
386 const OUString& rName)
387{
388 sal_uInt32 nTmpPos = FindName( eFam, rName );
389 if (nTmpPos != SAL_MAX_UINT32)
390 maImpl.erase(maImpl.begin() + nTmpPos);
391
392 // assumption: this seldom occurs, the iterator is built, then emptied.
393 rehash();
394 assert (maImpl.size() == maUnique.size());
395}
396
397// Add Strings to the list of templates
399{
400 UniqueHash::const_iterator it = maUnique.find(std::pair<SfxStyleFamily,OUString>{eFam, rStr});
401 if (it != maUnique.end())
402 return;
403
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});
406}
407
408// UI-sided implementation of StyleSheets
409// uses the Core-Engine
411 SwDocStyleSheetPool& rPool) :
412
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<
428 // FillAttribute support:
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,
447 m_bPhysical(false)
448{
449 nHelpId = UCHAR_MAX;
450}
451
453
455
457{
458 aName.clear();
459 aFollow.clear();
460 aParent.clear();
461 SetPhysical(false);
462}
463
465{
466 bool bChg = false;
467 if (!m_bPhysical)
469
470 SwFormat* pFormat = nullptr;
471 switch (nFamily)
472 {
473 case SfxStyleFamily::Char:
475 if (pFormat)
476 {
477 pFormat->SetGrabBagItem(rVal);
478 bChg = true;
479 }
480 break;
481 case SfxStyleFamily::Para:
483 if (pFormat)
484 {
485 pFormat->SetGrabBagItem(rVal);
486 bChg = true;
487 }
488 break;
489 case SfxStyleFamily::Pseudo:
490 {
492 if (pRule)
493 {
494 pRule->SetGrabBagItem(rVal);
495 bChg = true;
496 }
497 }
498 break;
499 default:
500 break;
501 }
502
503 if (bChg)
504 {
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();
509 }
510}
511
513{
514 SwFormat* pFormat = nullptr;
515 switch (nFamily)
516 {
517 case SfxStyleFamily::Char:
519 if (pFormat)
520 pFormat->GetGrabBagItem(rVal);
521 break;
522 case SfxStyleFamily::Para:
524 if (pFormat)
525 pFormat->GetGrabBagItem(rVal);
526 break;
527 case SfxStyleFamily::Pseudo:
528 {
530 if (pRule)
531 pRule->GetGrabBagItem(rVal);
532 }
533 break;
534 default:
535 break;
536 }
537}
538// virtual methods
539void SwDocStyleSheet::SetHidden( bool bValue )
540{
541 bool bChg = false;
542 if(!m_bPhysical)
544
545 SwFormat* pFormat = nullptr;
546 switch(nFamily)
547 {
548 case SfxStyleFamily::Char:
549 pFormat = m_rDoc.FindCharFormatByName( aName );
550 if ( pFormat )
551 {
552 pFormat->SetHidden( bValue );
553 bChg = true;
554 }
555 break;
556
557 case SfxStyleFamily::Para:
559 if ( pFormat )
560 {
561 pFormat->SetHidden( bValue );
562 bChg = true;
563 }
564 break;
565
566 case SfxStyleFamily::Frame:
568 if ( pFormat )
569 {
570 pFormat->SetHidden( bValue );
571 bChg = true;
572 }
573 break;
574
575 case SfxStyleFamily::Page:
576 {
578 if ( pPgDesc )
579 {
580 pPgDesc->SetHidden( bValue );
581 bChg = true;
582 }
583 }
584 break;
585
586 case SfxStyleFamily::Pseudo:
587 {
589 if ( pRule )
590 {
591 pRule->SetHidden( bValue );
592 bChg = true;
593 }
594 }
595 break;
596
597 case SfxStyleFamily::Table:
598 {
600 if ( pTableAutoFormat )
601 {
602 pTableAutoFormat->SetHidden( bValue );
603 bChg = true;
604 }
605 }
606 break;
607
608 default:
609 break;
610 }
611
612 if( bChg )
613 {
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();
619 }
620}
621
623{
624 bool bRet = false;
625
626 SwFormat* pFormat = nullptr;
627 switch(nFamily)
628 {
629 case SfxStyleFamily::Char:
630 pFormat = m_rDoc.FindCharFormatByName( aName );
631 bRet = pFormat && pFormat->IsHidden( );
632 break;
633
634 case SfxStyleFamily::Para:
636 bRet = pFormat && pFormat->IsHidden( );
637 break;
638
639 case SfxStyleFamily::Frame:
641 bRet = pFormat && pFormat->IsHidden( );
642 break;
643
644 case SfxStyleFamily::Page:
645 {
647 bRet = pPgDesc && pPgDesc->IsHidden( );
648 }
649 break;
650 case SfxStyleFamily::Pseudo:
651 {
653 bRet = pRule && pRule->IsHidden( );
654 }
655 break;
656 case SfxStyleFamily::Table:
657 {
659 bRet = pTableAutoFormat && pTableAutoFormat->IsHidden( );
660 }
661 break;
662 default:
663 break;
664 }
665
666 return bRet;
667}
668
669const OUString& SwDocStyleSheet::GetParent() const
670{
671 if( !m_bPhysical )
672 {
673 // check if it's already in document
674 SwFormat* pFormat = nullptr;
675 SwGetPoolIdFromName eGetType;
676 switch(nFamily)
677 {
678 case SfxStyleFamily::Char:
679 pFormat = m_rDoc.FindCharFormatByName( aName );
681 break;
682
683 case SfxStyleFamily::Para:
686 break;
687
688 case SfxStyleFamily::Frame:
691 break;
692
693 case SfxStyleFamily::Page:
694 case SfxStyleFamily::Pseudo:
695 default:
696 {
697 static const OUString sEmpty;
698 return sEmpty; // there's no parent
699 }
700 }
701
702 OUString sTmp;
703 if( !pFormat ) // not yet there, so default Parent
704 {
705 sal_uInt16 i = SwStyleNameMapper::GetPoolIdFromUIName( aName, eGetType );
706 i = ::GetPoolParent( i );
707 if( i && USHRT_MAX != i )
709 }
710 else
711 {
712 SwFormat* p = pFormat->DerivedFrom();
713 if( p && !p->IsDefault() )
714 sTmp = p->GetName();
715 }
716 SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
717 pThis->aParent = sTmp;
718 }
719 return aParent;
720}
721
722// Follower
723const OUString& SwDocStyleSheet::GetFollow() const
724{
725 if( !m_bPhysical )
726 {
727 SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
728 pThis->FillStyleSheet( FillAllInfo );
729 }
730 return aFollow;
731}
732
733void SwDocStyleSheet::SetLink(const OUString& rStr)
734{
735 SwImplShellAction aTmpSh(m_rDoc);
736 switch (nFamily)
737 {
738 case SfxStyleFamily::Para:
739 {
740 if (m_pColl)
741 {
743 if (pLink)
744 {
746 }
747 }
748 break;
749 }
750 case SfxStyleFamily::Char:
751 {
752 if (m_pCharFormat)
753 {
755 if (pLink)
756 {
758 }
759 }
760 break;
761 }
762 default:
763 break;
764 }
765}
766
767const OUString& SwDocStyleSheet::GetLink() const
768{
769 if (!m_bPhysical)
770 {
771 SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
773 }
774
775 return m_aLink;
776}
777
778// What Linkage is possible
780{
781 switch(nFamily)
782 {
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");
790 }
791 return false;
792}
793
794// Parent ?
796{
797 bool bRet = false;
798 switch(nFamily)
799 {
800 case SfxStyleFamily::Char :
801 case SfxStyleFamily::Para :
802 case SfxStyleFamily::Frame: bRet = true;
803 break;
804 default:; //prevent warning
805 }
806 return bRet;
807}
808
810{
811 bool bRet = false;
812 switch(nFamily)
813 {
814 case SfxStyleFamily::Para :
815 case SfxStyleFamily::Char :
816 case SfxStyleFamily::Frame: bRet = true;
817 break;
818 default:; //prevent warning
819 }
820 return bRet;
821}
822
823// determine textual description
825{
826 IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
827
828 static const OUStringLiteral sPlus(u" + ");
829 if ( SfxStyleFamily::Page == nFamily )
830 {
831 if( !pSet )
832 GetItemSet();
833
834 SfxItemIter aIter( *pSet );
835 OUStringBuffer aDesc;
836
837 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
838 {
839 if(!IsInvalidItem(pItem))
840 {
841 switch ( pItem->Which() )
842 {
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:
850 {
851 OUString aItemPresentation;
852 if ( !IsInvalidItem( pItem ) &&
854 *pItem, eUnit, aItemPresentation, aIntlWrapper ) )
855 {
856 if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
857 aDesc.append(sPlus);
858 aDesc.append(aItemPresentation);
859 }
860 }
861 }
862 }
863 }
864 return aDesc.makeStringAndClear();
865 }
866
867 if ( SfxStyleFamily::Frame == nFamily || SfxStyleFamily::Para == nFamily || SfxStyleFamily::Char == nFamily )
868 {
869 if( !pSet )
870 GetItemSet();
871
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;
881
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());
886
887 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
888 {
889 if(!IsInvalidItem(pItem))
890 {
891 switch ( pItem->Which() )
892 {
893 case SID_ATTR_AUTO_STYLE_UPDATE:
894 case RES_PAGEDESC:
895 break;
896 default:
897 {
898 OUString aItemPresentation;
899 if ( !IsInvalidItem( pItem ) &&
901 *pItem, eUnit, aItemPresentation, aIntlWrapper ) )
902 {
903 bool bIsDefault = false;
904 switch ( pItem->Which() )
905 {
906 case XATTR_FILLCOLOR:
907 {
908 // only use active FillStyle information
909 bIsDefault = (drawing::FillStyle_SOLID == eFillStyle);
910 break;
911 }
913 {
914 // only use active FillStyle information
915 bIsDefault = (drawing::FillStyle_GRADIENT == eFillStyle);
916 break;
917 }
918 case XATTR_FILLHATCH:
919 {
920 // only use active FillStyle information
921 bIsDefault = (drawing::FillStyle_HATCH == eFillStyle);
922 break;
923 }
924 case XATTR_FILLBITMAP:
925 {
926 // only use active FillStyle information
927 bIsDefault = (drawing::FillStyle_BITMAP == eFillStyle);
928 break;
929 }
931 {
932 // only active when not FloatTransparence
933 bIsDefault = !bUseFloatTransparence;
934 break;
935 }
937 {
938 // only active when FloatTransparence
939 bIsDefault = bUseFloatTransparence;
940 break;
941 }
942
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;
958 bIsDefault = true;
959 if(!bHasCJKFontPrefix)
960 {
961 aItemPresentation = SwResId(STR_CJK_FONT) + aItemPresentation;
962 bHasCJKFontPrefix = true;
963 }
964 break;
970 if(aCTLOptions.IsCTLFontEnabled())
971 bIsDefault = true;
972 if(!bHasCTLFontPrefix)
973 {
974 aItemPresentation = SwResId(STR_CTL_FONT) + aItemPresentation;
975 bHasCTLFontPrefix = true;
976 }
977 break;
978 case RES_CHRATR_FONT:
983 if(!bHasWesternFontPrefix)
984 {
985 aItemPresentation = SwResId(STR_WESTERN_FONT) + aItemPresentation;
986 bHasWesternFontPrefix = true;
987 }
988 [[fallthrough]];
989 default:
990 bIsDefault = true;
991 }
992 if(bIsDefault)
993 {
994 if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
995 aDesc.append(sPlus);
996 aDesc.append(aItemPresentation);
997 }
998 }
999 }
1000 }
1001 }
1002 }
1003 // Special treatment for Break, Page template and Site offset
1004 if (!sModel.isEmpty())
1005 {
1006 if (!aDesc.isEmpty())
1007 aDesc.append(sPlus);
1008 aDesc.append(SwResId(STR_PAGEBREAK) + sPlus + sModel);
1009 if (sPageNum != "0")
1010 {
1011 aDesc.append(sPlus + SwResId(STR_PAGEOFFSET) + sPageNum);
1012 }
1013 }
1014 else if (!sBreak.isEmpty()) // Break can be valid only when NO Model
1015 {
1016 if (!aDesc.isEmpty())
1017 aDesc.append(sPlus);
1018 aDesc.append(sBreak);
1019 }
1020 return aDesc.makeStringAndClear();
1021 }
1022
1023 if( SfxStyleFamily::Pseudo == nFamily )
1024 {
1025 return OUString();
1026 }
1027
1029}
1030
1031// Set names
1032bool SwDocStyleSheet::SetName(const OUString& rStr, bool bReindexNow)
1033{
1034 if( rStr.isEmpty() )
1035 return false;
1036
1037 if( aName != rStr )
1038 {
1039 if( !SfxStyleSheetBase::SetName(rStr, bReindexNow))
1040 return false;
1041 }
1042 else if(!m_bPhysical)
1044
1045 bool bChg = false;
1046 switch(nFamily)
1047 {
1048 case SfxStyleFamily::Char :
1049 {
1050 OSL_ENSURE(m_pCharFormat, "SwCharFormat missing!");
1051 if( m_pCharFormat && m_pCharFormat->GetName() != rStr )
1052 {
1053 if (!m_pCharFormat->GetName().isEmpty())
1055 else
1057
1058 bChg = true;
1059 }
1060 break;
1061 }
1062 case SfxStyleFamily::Para :
1063 {
1064 OSL_ENSURE(m_pColl, "Collection missing!");
1065 if( m_pColl && m_pColl->GetName() != rStr )
1066 {
1067 if (!m_pColl->GetName().isEmpty())
1068 m_rDoc.RenameFormat(*m_pColl, rStr);
1069 else
1070 m_pColl->SetFormatName(rStr);
1071
1072 bChg = true;
1073 }
1074 break;
1075 }
1076 case SfxStyleFamily::Frame:
1077 {
1078 OSL_ENSURE(m_pFrameFormat, "FrameFormat missing!");
1079 if( m_pFrameFormat && m_pFrameFormat->GetName() != rStr )
1080 {
1081 if (!m_pFrameFormat->GetName().isEmpty())
1083 else
1085
1086 bChg = true;
1087 }
1088 break;
1089 }
1090 case SfxStyleFamily::Page :
1091 OSL_ENSURE(m_pDesc, "PageDesc missing!");
1092 if( m_pDesc && m_pDesc->GetName() != rStr )
1093 {
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());
1099
1100 aPageDesc.SetName( rStr );
1101 bool const bDoesUndo = m_rDoc.GetIDocumentUndoRedo().DoesUndo();
1102
1103 m_rDoc.GetIDocumentUndoRedo().DoUndo(!aOldName.isEmpty());
1104 m_rDoc.ChgPageDesc(aOldName, aPageDesc);
1105 m_rDoc.GetIDocumentUndoRedo().DoUndo(bDoesUndo);
1106
1108 bChg = true;
1109 }
1110 break;
1111 case SfxStyleFamily::Pseudo:
1112 OSL_ENSURE(m_pNumRule, "NumRule missing!");
1113
1114 if (m_pNumRule)
1115 {
1116 OUString aOldName = m_pNumRule->GetName();
1117
1118 if (!aOldName.isEmpty())
1119 {
1120 if ( aOldName != rStr &&
1121 m_rDoc.RenameNumRule(aOldName, rStr))
1122 {
1125
1126 bChg = true;
1127 }
1128 }
1129 else
1130 {
1131 // #i91400#
1132 const_cast<SwNumRule*>(m_pNumRule)->SetName( rStr, m_rDoc.getIDocumentListsAccess() );
1134
1135 bChg = true;
1136 }
1137 }
1138
1139 break;
1140
1141 default:
1142 OSL_ENSURE(false, "unknown style family");
1143 }
1144
1145 if( bChg )
1146 {
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();
1151 }
1152 return true;
1153}
1154
1155// hierarchy of deduction
1156bool SwDocStyleSheet::SetParent( const OUString& rStr)
1157{
1158 SwFormat* pFormat = nullptr, *pParent = nullptr;
1159 switch(nFamily)
1160 {
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;
1166
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;
1172
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;
1178
1179 case SfxStyleFamily::Page:
1180 case SfxStyleFamily::Pseudo:
1181 break;
1182 default:
1183 OSL_ENSURE(false, "unknown style family");
1184 }
1185
1186 bool bRet = false;
1187 if( pFormat && pFormat->DerivedFrom() &&
1188 pFormat->DerivedFrom()->GetName() != rStr )
1189 {
1190 {
1191 SwImplShellAction aTmp( m_rDoc );
1192 bRet = pFormat->SetDerivedFrom( pParent );
1193 }
1194
1195 if( bRet )
1196 {
1197 aParent = rStr;
1198 m_pPool->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified,
1199 *this ) );
1200 }
1201 }
1202
1203 return bRet;
1204}
1205
1206// Set Follower
1207bool SwDocStyleSheet::SetFollow( const OUString& rStr)
1208{
1209 if( !rStr.isEmpty() && !SfxStyleSheetBase::SetFollow( rStr ))
1210 return false;
1211
1212 SwImplShellAction aTmpSh( m_rDoc );
1213 switch(nFamily)
1214 {
1215 case SfxStyleFamily::Para :
1216 {
1217 OSL_ENSURE(m_pColl, "Collection missing!");
1218 if( m_pColl )
1219 {
1220 SwTextFormatColl* pFollow = m_pColl;
1221 if( !rStr.isEmpty() && nullptr == (pFollow = lcl_FindParaFormat(m_rDoc, rStr) ))
1222 pFollow = m_pColl;
1223
1224 m_pColl->SetNextTextFormatColl(*pFollow);
1225 }
1226 break;
1227 }
1228 case SfxStyleFamily::Page :
1229 {
1230 OSL_ENSURE(m_pDesc, "PageDesc missing!");
1231 if( m_pDesc )
1232 {
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))
1238 {
1239 SwPageDesc aDesc( *m_pDesc );
1240 aDesc.SetFollow( pFollowDesc );
1241 m_rDoc.ChgPageDesc( nId, aDesc );
1243 }
1244 }
1245 break;
1246 }
1247 case SfxStyleFamily::Char:
1248 case SfxStyleFamily::Frame:
1249 case SfxStyleFamily::Pseudo:
1250 break;
1251 default:
1252 OSL_ENSURE(false, "unknown style family");
1253 }
1254
1255 return true;
1256}
1257
1258static
1259void lcl_SwFormatToFlatItemSet(SwFormat const *const pFormat, std::optional<SfxItemSet>& pRet)
1260{
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())
1266 {
1267 sets.push_back(pParent);
1268 }
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);
1275 }
1276}
1277
1278std::optional<SfxItemSet> SwDocStyleSheet::GetItemSetForPreview()
1279{
1280 if (SfxStyleFamily::Page == nFamily || SfxStyleFamily::Pseudo == nFamily || SfxStyleFamily::Table == nFamily)
1281 {
1282 SAL_WARN("sw.ui", "GetItemSetForPreview not implemented for page or number or table style");
1283 return std::optional<SfxItemSet>();
1284 }
1285 if (!m_bPhysical)
1286 {
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;
1292
1293 bool bModifiedEnabled = m_rDoc.getIDocumentState().IsEnableSetModified();
1295
1297
1298 m_rDoc.getIDocumentState().SetEnableSetModified(bModifiedEnabled);
1299
1300 assert(pRet);
1301 return pRet;
1302 }
1303 else
1304 {
1305 std::optional<SfxItemSet> pRet;
1306 switch (nFamily)
1307 {
1308 case SfxStyleFamily::Char:
1310 break;
1311 case SfxStyleFamily::Para:
1313 break;
1314 case SfxStyleFamily::Frame:
1316 break;
1317 default:
1318 std::abort();
1319 }
1320 return pRet;
1321 }
1322}
1323
1324// extract ItemSet to Name and Family, Mask
1325
1327{
1328 if(!m_bPhysical)
1330
1331 switch(nFamily)
1332 {
1333 case SfxStyleFamily::Char:
1334 case SfxStyleFamily::Para:
1335 case SfxStyleFamily::Frame:
1336 {
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 );
1344
1345 if( nFamily == SfxStyleFamily::Char )
1346 {
1347 SAL_WARN_IF(!m_pCharFormat, "sw.ui", "Where's SwCharFormat");
1349 m_aCoreSet.Put( aBoxInfo );
1350
1353 }
1354 else if ( nFamily == SfxStyleFamily::Para )
1355 {
1356 OSL_ENSURE(m_pColl, "Where's Collection");
1358 m_aCoreSet.Put( aBoxInfo );
1359 m_aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, m_pColl->IsAutoUpdateOnDirectFormat()));
1360
1361 if(m_pColl->DerivedFrom())
1363 }
1364 else
1365 {
1366 OSL_ENSURE(m_pFrameFormat, "Where's FrameFormat");
1368 m_aCoreSet.Put( aBoxInfo );
1369 m_aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, m_pFrameFormat->IsAutoUpdateOnDirectFormat()));
1370
1373
1374 // create needed items for XPropertyList entries from the DrawModel so that
1375 // the Area TabPage can access them
1377
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));
1383 }
1384 }
1385 break;
1386
1387 case SfxStyleFamily::Page :
1388 {
1389 // set correct parent to get the drawing::FillStyle_NONE FillStyle as needed
1390 if(!m_aCoreSet.GetParent())
1391 {
1393 }
1394
1395 OSL_ENSURE(m_pDesc, "No PageDescriptor");
1397 }
1398 break;
1399
1400 case SfxStyleFamily::Pseudo:
1401 {
1402 OSL_ENSURE(m_pNumRule, "No NumRule");
1404 m_aCoreSet.Put(SvxNumBulletItem(std::move(aRule)));
1405 }
1406 break;
1407
1408 default:
1409 OSL_ENSURE(false, "unknown style family");
1410 }
1411 // Member of Baseclass
1412 pSet = &m_aCoreSet;
1413
1414 return m_aCoreSet;
1415}
1416
1418{
1419 if ( nFamily != SfxStyleFamily::Para )
1420 {
1421 return;
1422 }
1423
1424 OSL_ENSURE( m_pColl, "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - missing paragraph style");
1426 if (indents == ::sw::ListLevelIndents::No)
1427 return;
1428
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;
1434
1435 const SwNumRule* pRule = m_rDoc.FindNumRulePtr( sNumRule );
1436 if( pRule )
1437 {
1438 const SwNumFormat& rFormat = pRule->Get( 0 );
1440 {
1441 if (indents & ::sw::ListLevelIndents::FirstLine)
1442 {
1443 SvxFirstLineIndentItem const firstLine(static_cast<short>(rFormat.GetFirstLineIndent()), RES_MARGIN_FIRSTLINE);
1444 rSet.Put(firstLine);
1445 }
1447 {
1448 SvxTextLeftMarginItem const leftMargin(rFormat.GetIndentAt(), RES_MARGIN_TEXTLEFT);
1449 rSet.Put(leftMargin);
1450 }
1451 }
1452 }
1453}
1454
1455// handling of parameter <bResetIndentAttrsAtParagraphStyle>
1457 const bool bResetIndentAttrsAtParagraphStyle )
1458{
1459 // if applicable determine format first
1460 if(!m_bPhysical)
1462
1463 SwImplShellAction aTmpSh( m_rDoc );
1464
1465 OSL_ENSURE( &rSet != &m_aCoreSet, "SetItemSet with own Set is not allowed" );
1466
1467 if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
1468 {
1469 SwRewriter aRewriter;
1470 aRewriter.AddRule( UndoArg1, GetName() );
1471 m_rDoc.GetIDocumentUndoRedo().StartUndo( SwUndoId::INSFMTATTR, &aRewriter );
1472 }
1473
1474 SwFormat* pFormat = nullptr;
1475 std::unique_ptr<SwPageDesc> pNewDsc;
1476 size_t nPgDscPos = 0;
1477
1478 switch(nFamily)
1479 {
1480 case SfxStyleFamily::Char :
1481 {
1482 OSL_ENSURE(m_pCharFormat, "Where's CharFormat");
1483 pFormat = m_pCharFormat;
1484 }
1485 break;
1486
1487 case SfxStyleFamily::Para :
1488 {
1489 OSL_ENSURE(m_pColl, "Where's Collection");
1490 if(const SfxBoolItem* pAutoUpdate = rSet.GetItemIfSet(SID_ATTR_AUTO_STYLE_UPDATE,false))
1491 {
1492 m_pColl->SetAutoUpdateOnDirectFormat(pAutoUpdate->GetValue());
1493 }
1494
1495 const SwCondCollItem* pCondItem = rSet.GetItemIfSet( FN_COND_COLL, false );
1496
1497 if( RES_CONDTXTFMTCOLL == m_pColl->Which() && pCondItem )
1498 {
1499 const CommandStruct* pCmds = SwCondCollItem::GetCmds();
1500 for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++)
1501 {
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)
1509 {
1510 aCond.RegisterToFormat( *pFindFormat );
1511 static_cast<SwConditionTextFormatColl*>(m_pColl)->InsertCondition( aCond );
1512 }
1513 }
1514
1515 m_pColl->GetNotifier().Broadcast(sw::CondCollCondChg(*m_pColl));
1516 }
1517 else if( pCondItem && !m_pColl->HasWriterListeners() )
1518 {
1519 // no conditional template, then first create and adopt
1520 // all important values
1522 m_pColl->GetName(), static_cast<SwTextFormatColl*>(m_pColl->DerivedFrom()) );
1525
1528 else
1530
1531 const CommandStruct* pCmds = SwCondCollItem::GetCmds();
1532 for( sal_uInt16 i = 0; i < COND_COMMAND_COUNT; ++i )
1533 {
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)
1539 {
1540 pCColl->InsertCondition( SwCollCondition( pFindFormat,
1541 pCmds[ i ].nCnd, pCmds[ i ].nSubCond ) );
1542 }
1543 }
1544
1546 m_pColl = pCColl;
1547 }
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)
1552 {
1554 }
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)
1559 {
1561 }
1562
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())
1571 {
1572 SwNumRule* pRule = m_rDoc.FindNumRulePtr( sNumRule );
1573 if( !pRule )
1574 { // Numbering rule not in use yet.
1576 if( USHRT_MAX != nPoolId ) // It's a standard numbering rule
1577 {
1578 m_rDoc.getIDocumentStylePoolAccess().GetNumRuleFromPool( nPoolId ); // Create numbering rule (physical)
1579 }
1580 }
1581 }
1582 }
1583
1584 pFormat = m_pColl;
1585
1586 sal_uInt16 nId = m_pColl->GetPoolFormatId() &
1588 switch( GetMask() & ( static_cast<SfxStyleSearchBits>(0x0fff) & ~SfxStyleSearchBits::SwCondColl ) )
1589 {
1590 case SfxStyleSearchBits::SwText:
1592 break;
1593 case SfxStyleSearchBits::SwChapter:
1594 nId |= COLL_DOC_BITS;
1595 break;
1596 case SfxStyleSearchBits::SwList:
1598 break;
1599 case SfxStyleSearchBits::SwIndex:
1601 break;
1602 case SfxStyleSearchBits::SwExtra:
1604 break;
1605 case SfxStyleSearchBits::SwHtml:
1607 break;
1608 default: break;
1609 }
1611 break;
1612 }
1613 case SfxStyleFamily::Frame:
1614 {
1615 OSL_ENSURE(m_pFrameFormat, "Where's FrameFormat");
1616
1617 if(const SfxPoolItem* pAutoUpdate = rSet.GetItemIfSet(SID_ATTR_AUTO_STYLE_UPDATE,false))
1618 {
1619 m_pFrameFormat->SetAutoUpdateOnDirectFormat(static_cast<const SfxBoolItem*>(pAutoUpdate)->GetValue());
1620 }
1621 pFormat = m_pFrameFormat;
1622 }
1623 break;
1624
1625 case SfxStyleFamily::Page :
1626 {
1627 OSL_ENSURE(m_pDesc, "Where's PageDescriptor");
1628
1629 if (m_rDoc.FindPageDesc(m_pDesc->GetName(), &nPgDscPos))
1630 {
1631 pNewDsc.reset( new SwPageDesc( *m_pDesc ) );
1632 // #i48949# - no undo actions for the
1633 // copy of the page style
1635 m_rDoc.CopyPageDesc(*m_pDesc, *pNewDsc); // #i7983#
1636
1637 pFormat = &pNewDsc->GetMaster();
1638 }
1639 }
1640 break;
1641
1642 case SfxStyleFamily::Pseudo:
1643 {
1644 OSL_ENSURE(m_pNumRule, "Where's NumRule");
1645
1646 if (!m_pNumRule)
1647 break;
1648
1649 const SfxPoolItem* pItem;
1650 switch( rSet.GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem ))
1651 {
1652 case SfxItemState::SET:
1653 {
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 );
1659 }
1660 break;
1661 case SfxItemState::DONTCARE:
1662 // set NumRule to default values
1663 // what are the default values?
1664 {
1665 SwNumRule aRule( m_pNumRule->GetName(),
1666 // #i89178#
1668 m_rDoc.ChgNumRuleFormats( aRule );
1669 }
1670 break;
1671 default: break;
1672 }
1673 }
1674 break;
1675
1676 default:
1677 OSL_ENSURE(false, "unknown style family");
1678 }
1679
1680 if( pFormat && rSet.Count())
1681 {
1682 SfxItemIter aIter( rSet );
1683 const SfxPoolItem* pItem = aIter.GetCurItem();
1684 do
1685 {
1686 if( IsInvalidItem( pItem ) ) // Clear
1687 {
1688 // use method <SwDoc::ResetAttrAtFormat(..)> in order to
1689 // create an Undo object for the attribute reset.
1691 *pFormat );
1692 }
1693
1694 pItem = aIter.NextItem();
1695 } while (pItem);
1696 SfxItemSet aSet(rSet);
1697 aSet.ClearInvalidItems();
1698
1699 if(SfxStyleFamily::Frame == nFamily)
1700 {
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
1705 }
1706
1708
1709 if( pNewDsc )
1710 {
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();
1716 }
1717 else
1718 m_rDoc.ChgFormat(*pFormat, aSet); // put all that is set
1719 }
1720 else
1721 {
1723 if( pNewDsc ) // we still need to delete it
1724 {
1725 m_rDoc.PreDelPageDesc(pNewDsc.get()); // #i7983#
1726 pNewDsc.reset();
1727 }
1728 }
1729
1730 if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
1731 {
1732 m_rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::END, nullptr);
1733 }
1734}
1735
1736static void lcl_SaveStyles( SfxStyleFamily nFamily, std::vector<void*>& rArr, SwDoc& rDoc )
1737{
1738 switch( nFamily )
1739 {
1740 case SfxStyleFamily::Char:
1741 {
1742 const SwCharFormats& rTable = *rDoc.GetCharFormats();
1743 for(auto const& rChar: rTable)
1744 {
1745 rArr.push_back(rChar);
1746 }
1747 }
1748 break;
1749 case SfxStyleFamily::Para:
1750 {
1751 const SwTextFormatColls& rTable = *rDoc.GetTextFormatColls();
1752 for(auto const& rPara : rTable)
1753 {
1754 rArr.push_back(rPara);
1755 }
1756 }
1757 break;
1758 case SfxStyleFamily::Frame:
1759 {
1760 const SwFrameFormats& rTable = *rDoc.GetFrameFormats();
1761 for(auto const& rFrame: rTable)
1762 {
1763 rArr.push_back(rFrame);
1764 }
1765 }
1766 break;
1767
1768 case SfxStyleFamily::Page:
1769 {
1770 for( size_t n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
1771 {
1772 rArr.push_back( &rDoc.GetPageDesc( n ) );
1773 }
1774 }
1775 break;
1776
1777 case SfxStyleFamily::Pseudo:
1778 {
1779 const SwNumRuleTable& rTable = rDoc.GetNumRuleTable();
1780 for(auto const& rPseudo: rTable)
1781 {
1782 rArr.push_back(rPseudo);
1783 }
1784 }
1785 break;
1786 default: break;
1787 }
1788}
1789
1790static bool lcl_Contains(const std::vector<void*>& rArr, const void* p)
1791{
1792 return std::find( rArr.begin(), rArr.end(), p ) != rArr.end();
1793}
1794
1795static void lcl_DeleteInfoStyles( SfxStyleFamily nFamily, std::vector<void*> const & rArr, SwDoc& rDoc )
1796{
1797 size_t n, nCnt;
1798 switch( nFamily )
1799 {
1800 case SfxStyleFamily::Char:
1801 {
1802 std::deque<sal_uInt16> aDelArr;
1803 const SwCharFormats& rTable = *rDoc.GetCharFormats();
1804 for( n = 0, nCnt = rTable.size(); n < nCnt; ++n )
1805 {
1806 if( !lcl_Contains( rArr, rTable[ n ] ))
1807 aDelArr.push_front( n );
1808 }
1809 for(auto const& rDelArr: aDelArr)
1810 rDoc.DelCharFormat( rDelArr );
1811 }
1812 break;
1813
1814 case SfxStyleFamily::Para :
1815 {
1816 std::deque<sal_uInt16> aDelArr;
1817 const SwTextFormatColls& rTable = *rDoc.GetTextFormatColls();
1818 for( n = 0, nCnt = rTable.size(); n < nCnt; ++n )
1819 {
1820 if( !lcl_Contains( rArr, rTable[ n ] ))
1821 aDelArr.push_front( n );
1822 }
1823 for(auto const& rDelArr: aDelArr)
1824 rDoc.DelTextFormatColl( rDelArr );
1825 }
1826 break;
1827
1828 case SfxStyleFamily::Frame:
1829 {
1830 std::deque<SwFrameFormat*> aDelArr;
1831 const SwFrameFormats& rTable = *rDoc.GetFrameFormats();
1832 for( auto const& rFrame: rTable )
1833 {
1834 if( !lcl_Contains( rArr, rFrame ))
1835 aDelArr.push_front( rFrame );
1836 }
1837 for( auto const& rDelArr: aDelArr)
1838 rDoc.DelFrameFormat( rDelArr );
1839 }
1840 break;
1841
1842 case SfxStyleFamily::Page:
1843 {
1844 std::deque<size_t> aDelArr;
1845 for( n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
1846 {
1847 if( !lcl_Contains( rArr, &rDoc.GetPageDesc( n ) ))
1848 aDelArr.push_front( n );
1849 }
1850 for( auto const& rDelArr: aDelArr )
1851 rDoc.DelPageDesc( rDelArr);
1852 }
1853 break;
1854
1855 case SfxStyleFamily::Pseudo:
1856 {
1857 std::deque<SwNumRule*> aDelArr;
1858 const SwNumRuleTable& rTable = rDoc.GetNumRuleTable();
1859 for( auto const& rPseudo: rTable)
1860 {
1861 if( !lcl_Contains( rArr, rPseudo ))
1862 aDelArr.push_front( rPseudo );
1863 }
1864 for( auto const& rDelArr: aDelArr)
1865 rDoc.DelNumRule( rDelArr->GetName() );
1866 }
1867 break;
1868 default: break;
1869 }
1870}
1871
1872// determine the format
1874 FillStyleType const eFType, std::optional<SfxItemSet> *const o_ppFlatSet)
1875{
1876 bool bRet = false;
1877 sal_uInt16 nPoolId = USHRT_MAX;
1878 SwFormat* pFormat = nullptr;
1879
1880 bool bCreate = FillPhysical == eFType;
1881 bool bDeleteInfo = false;
1882 bool bFillOnlyInfo = FillAllInfo == eFType || FillPreview == eFType;
1883 std::vector<void*> aDelArr;
1884 bool const isModified(m_rDoc.getIDocumentState().IsModified());
1885
1886 switch(nFamily)
1887 {
1888 case SfxStyleFamily::Char:
1889 m_pCharFormat = lcl_FindCharFormat(m_rDoc, aName, this, bCreate );
1890 m_bPhysical = nullptr != m_pCharFormat;
1891 if( bFillOnlyInfo && !m_bPhysical )
1892 {
1893 // create style (plus all needed parents) and clean it up
1894 // later - without affecting the undo/redo stack
1896 bDeleteInfo = true;
1897 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
1899 }
1900
1901 pFormat = m_pCharFormat;
1902 m_aLink.clear();
1903 if( !bCreate && !pFormat )
1904 {
1905 if( aName == SwResId(STR_POOLCHR_STANDARD))
1906 nPoolId = 0;
1907 else
1909 }
1910
1911 if (m_pCharFormat)
1912 {
1913 const SwTextFormatColl* pParaFormat = m_pCharFormat->GetLinkedParaFormat();
1914 if (pParaFormat)
1915 {
1916 m_aLink = pParaFormat->GetName();
1917 }
1918 }
1919
1920 bRet = nullptr != m_pCharFormat || USHRT_MAX != nPoolId;
1921
1922 if( bDeleteInfo )
1923 m_pCharFormat = nullptr;
1924 break;
1925
1926 case SfxStyleFamily::Para:
1927 {
1928 m_pColl = lcl_FindParaFormat(m_rDoc, aName, this, bCreate);
1929 m_bPhysical = nullptr != m_pColl;
1930 if( bFillOnlyInfo && !m_bPhysical )
1931 {
1933 bDeleteInfo = true;
1934 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
1936 }
1937
1938 pFormat = m_pColl;
1939 m_aLink.clear();
1940 if( m_pColl )
1941 {
1943 const SwCharFormat* pCharFormat = m_pColl->GetLinkedCharFormat();
1944 if (pCharFormat)
1945 {
1946 m_aLink = pCharFormat->GetName();
1947 }
1948 }
1949 else if( !bCreate )
1951
1952 bRet = nullptr != m_pColl || USHRT_MAX != nPoolId;
1953
1954 if( bDeleteInfo )
1955 m_pColl = nullptr;
1956 }
1957 break;
1958
1959 case SfxStyleFamily::Frame:
1961 m_bPhysical = nullptr != m_pFrameFormat;
1962 if (bFillOnlyInfo && !m_bPhysical)
1963 {
1965 bDeleteInfo = true;
1966 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
1968 }
1969 pFormat = m_pFrameFormat;
1970 if( !bCreate && !pFormat )
1972
1973 bRet = nullptr != m_pFrameFormat || USHRT_MAX != nPoolId;
1974
1975 if( bDeleteInfo )
1976 m_pFrameFormat = nullptr;
1977 break;
1978
1979 case SfxStyleFamily::Page:
1980 m_pDesc = lcl_FindPageDesc(m_rDoc, aName, this, bCreate);
1981 m_bPhysical = nullptr != m_pDesc;
1982 if( bFillOnlyInfo && !m_pDesc )
1983 {
1985 bDeleteInfo = true;
1986 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
1988 }
1989
1990 if( m_pDesc )
1991 {
1992 nPoolId = m_pDesc->GetPoolFormatId();
1994 if (const OUString* pattern = m_pDesc->GetPoolHlpFileId() != UCHAR_MAX
1996 : nullptr)
1997 aHelpFile = *pattern;
1998 else
1999 aHelpFile.clear();
2000 }
2001 else if( !bCreate )
2003 SetMask( (USER_FMT & nPoolId) ? SfxStyleSearchBits::UserDefined : SfxStyleSearchBits::Auto );
2004
2005 bRet = nullptr != m_pDesc || USHRT_MAX != nPoolId;
2006 if( bDeleteInfo )
2007 m_pDesc = nullptr;
2008 break;
2009
2010 case SfxStyleFamily::Pseudo:
2011 m_pNumRule = lcl_FindNumRule(m_rDoc, aName, this, bCreate);
2012 m_bPhysical = nullptr != m_pNumRule;
2013 if( bFillOnlyInfo && !m_pNumRule )
2014 {
2016 bDeleteInfo = true;
2017 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
2019 }
2020
2021 if( m_pNumRule )
2022 {
2023 nPoolId = m_pNumRule->GetPoolFormatId();
2025 if (const OUString* pattern = m_pNumRule->GetPoolHlpFileId() != UCHAR_MAX
2027 : nullptr)
2028 aHelpFile = *pattern;
2029 else
2030 aHelpFile.clear();
2031 }
2032 else if( !bCreate )
2034 SetMask( (USER_FMT & nPoolId) ? SfxStyleSearchBits::UserDefined : SfxStyleSearchBits::Auto );
2035
2036 bRet = nullptr != m_pNumRule || USHRT_MAX != nPoolId;
2037
2038 if( bDeleteInfo )
2039 m_pNumRule = nullptr;
2040 break;
2041
2042 case SfxStyleFamily::Table:
2043 m_pTableFormat = lcl_FindTableStyle(m_rDoc, aName, this, bCreate);
2044 SetMask((m_pTableFormat && m_pTableFormat->IsUserDefined()) ? SfxStyleSearchBits::UserDefined : SfxStyleSearchBits::Auto);
2045 bRet = m_bPhysical = (nullptr != m_pTableFormat);
2046 break;
2047
2048 case SfxStyleFamily::Cell:
2050 bRet = m_bPhysical = (nullptr != m_pBoxFormat);
2051 break;
2052 default:; //prevent warning
2053 }
2054
2055 if( SfxStyleFamily::Char == nFamily ||
2056 SfxStyleFamily::Para == nFamily ||
2057 SfxStyleFamily::Frame == nFamily )
2058 {
2059 if( pFormat )
2060 nPoolId = pFormat->GetPoolFormatId();
2061
2062 SfxStyleSearchBits _nMask = SfxStyleSearchBits::Auto;
2063 if( pFormat == m_rDoc.GetDfltCharFormat() )
2064 _nMask |= SfxStyleSearchBits::ReadOnly;
2065 else if( USER_FMT & nPoolId )
2066 _nMask |= SfxStyleSearchBits::UserDefined;
2067
2068 switch ( COLL_GET_RANGE_BITS & nPoolId )
2069 {
2070 case COLL_TEXT_BITS: _nMask |= SfxStyleSearchBits::SwText; break;
2071 case COLL_DOC_BITS : _nMask |= SfxStyleSearchBits::SwChapter; break;
2072 case COLL_LISTS_BITS: _nMask |= SfxStyleSearchBits::SwList; break;
2073 case COLL_REGISTER_BITS: _nMask |= SfxStyleSearchBits::SwIndex; break;
2074 case COLL_EXTRA_BITS: _nMask |= SfxStyleSearchBits::SwExtra; break;
2075 case COLL_HTML_BITS: _nMask |= SfxStyleSearchBits::SwHtml; break;
2076 }
2077
2078 if( pFormat )
2079 {
2080 OSL_ENSURE( m_bPhysical, "Format not found" );
2081
2082 nHelpId = pFormat->GetPoolHelpId();
2083 if (const OUString* pattern = pFormat->GetPoolHlpFileId() != UCHAR_MAX
2085 : nullptr)
2086 aHelpFile = *pattern;
2087 else
2088 aHelpFile.clear();
2089
2090 if( RES_CONDTXTFMTCOLL == pFormat->Which() )
2091 _nMask |= SfxStyleSearchBits::SwCondColl;
2092
2093 if (FillPreview == eFType)
2094 {
2095 assert(o_ppFlatSet);
2096 lcl_SwFormatToFlatItemSet(pFormat, *o_ppFlatSet);
2097 }
2098 }
2099
2100 SetMask( _nMask );
2101 }
2102 if( bDeleteInfo && bFillOnlyInfo )
2103 {
2106 if (!isModified)
2107 {
2109 }
2110 }
2111 return bRet;
2112}
2113
2114// Create new format in Core
2116{
2117 switch(nFamily)
2118 {
2119 case SfxStyleFamily::Char :
2121 if( !m_pCharFormat )
2124 m_pCharFormat->SetAuto(false);
2125 break;
2126
2127 case SfxStyleFamily::Para :
2129 if( !m_pColl )
2130 {
2132 if( nMask & SfxStyleSearchBits::SwCondColl )
2134 else
2136 }
2137 break;
2138
2139 case SfxStyleFamily::Frame:
2141 if( !m_pFrameFormat )
2143
2144 break;
2145
2146 case SfxStyleFamily::Page :
2148 if( !m_pDesc )
2149 {
2151 }
2152 break;
2153
2154 case SfxStyleFamily::Pseudo:
2156 if( !m_pNumRule )
2157 {
2158 const OUString sTmpNm( aName.isEmpty() ? m_rDoc.GetUniqueNumRuleName() : aName );
2159 SwNumRule* pRule = m_rDoc.GetNumRuleTable()[
2160 m_rDoc.MakeNumRule( sTmpNm, nullptr, false,
2161 // #i89178#
2163 pRule->SetAutoRule( false );
2164 if( aName.isEmpty() )
2165 {
2166 // #i91400#
2168 }
2169 m_pNumRule = pRule;
2170 }
2171 break;
2172
2173 case SfxStyleFamily::Table:
2174 if (aName.isEmpty())
2175 return;
2177 if (!m_pTableFormat)
2178 {
2181 SAL_WARN_IF(!m_pTableFormat, "sw.ui", "Recently added auto format not found");
2182 }
2183 break;
2184 default:; //prevent warning
2185 }
2186 m_bPhysical = true;
2188}
2189
2191{
2192 if(!m_bPhysical)
2194 return m_pCharFormat;
2195}
2196
2198{
2199 if(!m_bPhysical)
2201 return m_pColl;
2202}
2203
2205{
2206 if(!m_bPhysical)
2208 return m_pDesc;
2209}
2210
2212{
2213 if(!m_bPhysical)
2215 return m_pNumRule;
2216}
2217
2218
2220{
2221 OSL_ENSURE(m_pNumRule, "Where is the NumRule");
2222 m_rDoc.ChgNumRuleFormats( rRule );
2223}
2224
2226{
2227 if(!m_bPhysical)
2229 assert(m_pTableFormat && "SwDocStyleSheet table style, SwTableAutoFormat not found");
2230 return m_pTableFormat;
2231}
2232
2233// re-generate Name AND Family from String
2234// First() and Next() (see below) insert an identification letter at Pos.1
2235
2236void SwDocStyleSheet::PresetNameAndFamily(SfxStyleFamily eFamily, const OUString& rName)
2237{
2238 this->nFamily = eFamily;
2239 this->aName = rName;
2240}
2241
2242// Is the format physically present yet
2244{
2245 m_bPhysical = bPhys;
2246
2247 if(!bPhys)
2248 {
2249 m_pCharFormat = nullptr;
2250 m_pColl = nullptr;
2251 m_pFrameFormat = nullptr;
2252 m_pDesc = nullptr;
2253 }
2254}
2255
2257{
2258 if(!m_bPhysical)
2260 return m_pFrameFormat;
2261}
2262
2264{
2265 if( !m_bPhysical )
2266 {
2267 SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
2268 pThis->FillStyleSheet( FillOnlyName );
2269 }
2270
2271 if( !m_bPhysical )
2272 return false;
2273
2274 const sw::BroadcastingModify* pMod;
2275 switch( nFamily )
2276 {
2277 case SfxStyleFamily::Char : pMod = m_pCharFormat; break;
2278 case SfxStyleFamily::Para : pMod = m_pColl; break;
2279 case SfxStyleFamily::Frame: pMod = m_pFrameFormat; break;
2280 case SfxStyleFamily::Page : pMod = m_pDesc; break;
2281
2282 case SfxStyleFamily::Pseudo:
2283 return m_pNumRule && m_rDoc.IsUsed(*m_pNumRule);
2284
2285 case SfxStyleFamily::Table:
2287
2288 default:
2289 OSL_ENSURE(false, "unknown style family");
2290 return false;
2291 }
2292 return m_rDoc.IsUsed( *pMod );
2293}
2294
2296{
2297 return m_pNumRule ? m_pNumRule->MakeParagraphStyleListString() : OUString();
2298}
2299
2301{
2302 sal_uInt16 nId = 0;
2303 sal_uInt16 nPoolId = 0;
2304 unsigned char nFileId = UCHAR_MAX;
2305
2306 rFile = "swrhlppi.hlp";
2307
2308 const SwFormat* pTmpFormat = nullptr;
2309 switch( nFamily )
2310 {
2311 case SfxStyleFamily::Char :
2312 if( !m_pCharFormat &&
2313 nullptr == (m_pCharFormat = lcl_FindCharFormat( m_rDoc, aName, nullptr, false )) )
2314 {
2316 return USHRT_MAX == nId ? 0 : nId;
2317 }
2318 pTmpFormat = m_pCharFormat;
2319 break;
2320
2321 case SfxStyleFamily::Para:
2322 if( !m_pColl &&
2323 nullptr == ( m_pColl = lcl_FindParaFormat( m_rDoc, aName, nullptr, false )) )
2324 {
2326 return USHRT_MAX == nId ? 0 : nId;
2327 }
2328 pTmpFormat = m_pColl;
2329 break;
2330
2331 case SfxStyleFamily::Frame:
2332 if( !m_pFrameFormat &&
2333 nullptr == ( m_pFrameFormat = lcl_FindFrameFormat( m_rDoc, aName, nullptr, false ) ) )
2334 {
2336 return USHRT_MAX == nId ? 0 : nId;
2337 }
2338 pTmpFormat = m_pFrameFormat;
2339 break;
2340
2341 case SfxStyleFamily::Page:
2342 if( !m_pDesc &&
2343 nullptr == ( m_pDesc = lcl_FindPageDesc( m_rDoc, aName, nullptr, false ) ) )
2344 {
2346 return USHRT_MAX == nId ? 0 : nId;
2347 }
2348
2350 nFileId = m_pDesc->GetPoolHlpFileId();
2351 nPoolId = m_pDesc->GetPoolFormatId();
2352 break;
2353
2354 case SfxStyleFamily::Pseudo:
2355 if( !m_pNumRule &&
2356 nullptr == ( m_pNumRule = lcl_FindNumRule( m_rDoc, aName, nullptr, false ) ) )
2357 {
2359 return USHRT_MAX == nId ? 0 : nId;
2360 }
2361
2363 nFileId = m_pNumRule->GetPoolHlpFileId();
2364 nPoolId = m_pNumRule->GetPoolFormatId();
2365 break;
2366
2367 default:
2368 OSL_ENSURE(false, "unknown style family");
2369 return 0;
2370 }
2371
2372 if( pTmpFormat )
2373 {
2374 nId = pTmpFormat->GetPoolHelpId();
2375 nFileId = pTmpFormat->GetPoolHlpFileId();
2376 nPoolId = pTmpFormat->GetPoolFormatId();
2377 }
2378
2379 if( UCHAR_MAX != nFileId )
2380 {
2381 const OUString *pTemplate = m_rDoc.GetDocPattern( nFileId );
2382 if( pTemplate )
2383 {
2384 rFile = *pTemplate;
2385 }
2386 }
2387 else if( !IsPoolUserFormat( nPoolId ) )
2388 {
2389 nId = nPoolId;
2390 }
2391
2392 // because SFX acts like that, with HelpId:
2393 if( USHRT_MAX == nId )
2394 nId = 0; // don't show Help accordingly
2395
2396 return nId;
2397}
2398
2399void SwDocStyleSheet::SetHelpId( const OUString& r, sal_uLong nId )
2400{
2401 sal_uInt8 nFileId = static_cast< sal_uInt8 >(m_rDoc.SetDocPattern( r ));
2402 sal_uInt16 nHId = static_cast< sal_uInt16 >(nId);
2403
2404 SwFormat* pTmpFormat = nullptr;
2405 switch( nFamily )
2406 {
2407 case SfxStyleFamily::Char : pTmpFormat = m_pCharFormat; break;
2408 case SfxStyleFamily::Para : pTmpFormat = m_pColl; break;
2409 case SfxStyleFamily::Frame: pTmpFormat = m_pFrameFormat; break;
2410 case SfxStyleFamily::Page :
2411 const_cast<SwPageDesc*>(m_pDesc)->SetPoolHelpId( nHId );
2412 const_cast<SwPageDesc*>(m_pDesc)->SetPoolHlpFileId( nFileId );
2413 break;
2414
2415 case SfxStyleFamily::Pseudo:
2416 const_cast<SwNumRule*>(m_pNumRule)->SetPoolHelpId( nHId );
2417 const_cast<SwNumRule*>(m_pNumRule)->SetPoolHlpFileId( nFileId );
2418 break;
2419
2420 default:
2421 OSL_ENSURE(false, "unknown style family");
2422 return ;
2423 }
2424 if( pTmpFormat )
2425 {
2426 pTmpFormat->SetPoolHelpId( nHId );
2427 pTmpFormat->SetPoolHlpFileId( nFileId );
2428 }
2429}
2430
2431// methods for DocStyleSheetPool
2433 : SfxStyleSheetBasePool(rDocument.GetAttrPool())
2434 , mxStyleSheet(new SwDocStyleSheet(rDocument, *this))
2435 , m_rDoc(rDocument)
2436{
2437 m_bOrganizer = bOrg;
2438}
2439
2441{
2442}
2443
2445 SfxStyleFamily eFam,
2446 SfxStyleSearchBits _nMask)
2447{
2448 mxStyleSheet->PresetName(rName);
2449 mxStyleSheet->PresetParent(OUString());
2450 mxStyleSheet->PresetFollow(OUString());
2451 mxStyleSheet->SetMask(_nMask) ;
2452 mxStyleSheet->SetFamily(eFam);
2453 mxStyleSheet->SetPhysical(true);
2454 mxStyleSheet->Create();
2455
2456 return *mxStyleSheet;
2457}
2458
2460{
2461 OSL_ENSURE(false , "Create in SW-Stylesheet-Pool not possible" );
2462 return nullptr;
2463}
2464
2467{
2468 OSL_ENSURE( false, "Create in SW-Stylesheet-Pool not possible" );
2469 return nullptr;
2470}
2471
2472std::unique_ptr<SfxStyleSheetIterator> SwDocStyleSheetPool::CreateIterator( SfxStyleFamily eFam, SfxStyleSearchBits _nMask )
2473{
2474 return std::make_unique<SwStyleSheetIterator>(*this, eFam, _nMask);
2475}
2476
2478{
2479 mxStyleSheet.clear();
2480}
2481
2483{
2484 if( !pStyle )
2485 return;
2486
2487 bool bBroadcast = true;
2488 SwImplShellAction aTmpSh( m_rDoc );
2489 const OUString sName = pStyle->GetName();
2490 switch( pStyle->GetFamily() )
2491 {
2492 case SfxStyleFamily::Char:
2493 {
2494 SwCharFormat* pFormat = lcl_FindCharFormat(m_rDoc, sName, nullptr, false );
2495 if(pFormat)
2496 m_rDoc.DelCharFormat(pFormat);
2497 }
2498 break;
2499 case SfxStyleFamily::Para:
2500 {
2501 SwTextFormatColl* pColl = lcl_FindParaFormat(m_rDoc, sName, nullptr, false );
2502 if(pColl)
2504 }
2505 break;
2506 case SfxStyleFamily::Frame:
2507 {
2508 SwFrameFormat* pFormat = lcl_FindFrameFormat(m_rDoc, sName, nullptr, false );
2509 if(pFormat)
2510 m_rDoc.DelFrameFormat(pFormat);
2511 }
2512 break;
2513 case SfxStyleFamily::Page :
2514 {
2516 }
2517 break;
2518
2519 case SfxStyleFamily::Pseudo:
2520 {
2521 if( !m_rDoc.DelNumRule( sName ) )
2522 // Only send Broadcast, when something was deleted
2523 bBroadcast = false;
2524 }
2525 break;
2526
2527 case SfxStyleFamily::Table:
2528 {
2530 }
2531 break;
2532
2533 default:
2534 OSL_ENSURE(false, "unknown style family");
2535 bBroadcast = false;
2536 }
2537
2538 if( bBroadcast )
2539 Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetErased, *pStyle ) );
2540}
2541
2543 const OUString &rStyle, const OUString &rParent )
2544{
2545 SwFormat* pFormat = nullptr, *pParent = nullptr;
2546 switch( eFam )
2547 {
2548 case SfxStyleFamily::Char :
2549 if( nullptr != ( pFormat = lcl_FindCharFormat( m_rDoc, rStyle ) ) && !rParent.isEmpty() )
2550 pParent = lcl_FindCharFormat(m_rDoc, rParent );
2551 break;
2552
2553 case SfxStyleFamily::Para :
2554 if( nullptr != ( pFormat = lcl_FindParaFormat( m_rDoc, rStyle ) ) && !rParent.isEmpty() )
2555 pParent = lcl_FindParaFormat( m_rDoc, rParent );
2556 break;
2557
2558 case SfxStyleFamily::Frame:
2559 if( nullptr != ( pFormat = lcl_FindFrameFormat( m_rDoc, rStyle ) ) && !rParent.isEmpty() )
2560 pParent = lcl_FindFrameFormat( m_rDoc, rParent );
2561 break;
2562
2563 case SfxStyleFamily::Page:
2564 case SfxStyleFamily::Pseudo:
2565 break;
2566
2567 default:
2568 OSL_ENSURE(false, "unknown style family");
2569 }
2570
2571 bool bRet = false;
2572 if( pFormat && pFormat->DerivedFrom() &&
2573 pFormat->DerivedFrom()->GetName() != rParent )
2574 {
2575 {
2576 SwImplShellAction aTmpSh( m_rDoc );
2577 bRet = pFormat->SetDerivedFrom( pParent );
2578 }
2579
2580 if( bRet )
2581 {
2582 // only for Broadcasting
2583 mxStyleSheet->PresetName( rStyle );
2584 mxStyleSheet->PresetParent( rParent );
2585 if( SfxStyleFamily::Para == eFam )
2586 mxStyleSheet->PresetFollow( static_cast<SwTextFormatColl*>(pFormat)->
2587 GetNextTextFormatColl().GetName() );
2588 else
2589 mxStyleSheet->PresetFollow( OUString() );
2590
2591 Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified, *mxStyleSheet ) );
2592 }
2593 }
2594
2595 return bRet;
2596}
2597
2599 SfxStyleFamily eFam, SfxStyleSearchBits n) const
2600{
2601 SfxStyleSearchBits nSMask = n;
2602 if( SfxStyleFamily::Para == eFam && m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) )
2603 {
2604 // then only HTML-Templates are of interest
2605 if( SfxStyleSearchBits::All == nSMask )
2606 nSMask = SfxStyleSearchBits::SwHtml | SfxStyleSearchBits::UserDefined | SfxStyleSearchBits::Used;
2607 else
2608 nSMask &= SfxStyleSearchBits::Used | SfxStyleSearchBits::UserDefined |
2609 SfxStyleSearchBits::SwCondColl | SfxStyleSearchBits::SwHtml;
2610 if( nSMask == SfxStyleSearchBits::Auto )
2611 nSMask = SfxStyleSearchBits::SwHtml;
2612 }
2613
2614 const bool bSearchUsed = ( n != SfxStyleSearchBits::All && n & SfxStyleSearchBits::Used );
2615 const sw::BroadcastingModify* pMod = nullptr;
2616
2617 mxStyleSheet->SetPhysical( false );
2618 mxStyleSheet->PresetName( rName );
2619 mxStyleSheet->SetFamily( eFam );
2620 bool bFnd = mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
2621
2622 if( mxStyleSheet->IsPhysical() )
2623 {
2624 switch( eFam )
2625 {
2626 case SfxStyleFamily::Char:
2627 pMod = mxStyleSheet->GetCharFormat();
2628 break;
2629
2630 case SfxStyleFamily::Para:
2631 pMod = mxStyleSheet->GetCollection();
2632 break;
2633
2634 case SfxStyleFamily::Frame:
2635 pMod = mxStyleSheet->GetFrameFormat();
2636 break;
2637
2638 case SfxStyleFamily::Page:
2639 pMod = mxStyleSheet->GetPageDesc();
2640 break;
2641
2642 case SfxStyleFamily::Pseudo:
2643 {
2644 const SwNumRule* pRule = mxStyleSheet->GetNumRule();
2645 if( pRule &&
2646 !bSearchUsed &&
2647 (( nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
2648 ? !(pRule->GetPoolFormatId() & USER_FMT)
2649 // searched for used and found none
2650 : bSearchUsed ))
2651 bFnd = false;
2652 }
2653 break;
2654
2655 case SfxStyleFamily::Table:
2656 case SfxStyleFamily::Cell:
2657 break;
2658 default:
2659 OSL_ENSURE(false, "unknown style family");
2660 }
2661 }
2662
2663 // then evaluate the mask:
2664 if( pMod && !bSearchUsed )
2665 {
2666 const sal_uInt16 nId = SfxStyleFamily::Page == eFam
2667 ? static_cast<const SwPageDesc*>(pMod)->GetPoolFormatId()
2668 : static_cast<const SwFormat*>(pMod)->GetPoolFormatId();
2669
2670 if( ( nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
2671 && !(nId & USER_FMT) )
2672 // searched for used and found none
2673 bFnd = false;
2674 }
2675 return bFnd ? mxStyleSheet.get() : nullptr;
2676}
2677
2680 : SfxStyleSheetIterator(&rBase, eFam, n)
2681 , mxIterSheet(new SwDocStyleSheet(rBase.GetDoc(), rBase))
2682 , mxStyleSheet(new SwDocStyleSheet(rBase.GetDoc(), rBase))
2683{
2684 m_bFirstCalled = false;
2685 m_nLastPos = 0;
2686 StartListening(rBase);
2687}
2688
2690{
2691 EndListening( *mxIterSheet->GetPool() );
2692}
2693
2695{
2696 // let the list fill correctly!!
2697 if( !m_bFirstCalled )
2698 First();
2699 return m_aLst.size();
2700}
2701
2703{
2704 // found
2705 if( !m_bFirstCalled )
2706 First();
2707 auto const & rEntry = m_aLst[ nIdx ];
2708 mxStyleSheet->PresetNameAndFamily( rEntry.first, rEntry.second );
2709 mxStyleSheet->SetPhysical( false );
2711
2712 return mxStyleSheet.get();
2713}
2714
2716{
2717 // Delete old list
2718 m_bFirstCalled = true;
2719 m_nLastPos = 0;
2720 m_aLst.clear();
2721
2722 // Delete current
2723 mxIterSheet->Reset();
2724
2725 const SwDoc& rDoc = static_cast<const SwDocStyleSheetPool*>(pBasePool)->GetDoc();
2726 const SfxStyleSearchBits nSrchMask = nMask;
2727 const bool bIsSearchUsed = SearchUsed();
2728
2729 bool bSearchHidden( nMask & SfxStyleSearchBits::Hidden );
2730 bool bOnlyHidden = nMask == SfxStyleSearchBits::Hidden;
2731
2732 const bool bOrganizer = static_cast<const SwDocStyleSheetPool*>(pBasePool)->IsOrganizerMode();
2733 bool bAll = ( nSrchMask & SfxStyleSearchBits::AllVisible ) == SfxStyleSearchBits::AllVisible;
2734
2735 if( nSearchFamily == SfxStyleFamily::Char
2736 || nSearchFamily == SfxStyleFamily::All )
2737 {
2738 const size_t nArrLen = rDoc.GetCharFormats()->size();
2739 for( size_t i = 0; i < nArrLen; i++ )
2740 {
2741 SwCharFormat* pFormat = (*rDoc.GetCharFormats())[ i ];
2742
2743 const bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(*pFormat));
2744 if( ( !bSearchHidden && pFormat->IsHidden() && !bUsed ) || ( pFormat->IsDefault() && pFormat != rDoc.GetDfltCharFormat() ) )
2745 continue;
2746
2747 if ( nSrchMask == SfxStyleSearchBits::Hidden && !pFormat->IsHidden( ) )
2748 continue;
2749
2750 if( !bUsed )
2751 {
2752 // Standard is no User template
2753 const sal_uInt16 nId = rDoc.GetDfltCharFormat() == pFormat ?
2754 sal_uInt16( RES_POOLCHR_INET_NORMAL ):
2755 pFormat->GetPoolFormatId();
2756 if( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
2757 ? !(nId & USER_FMT)
2758 // searched for used and found none
2759 : bIsSearchUsed )
2760 {
2761 continue;
2762 }
2763
2770 continue;
2771 }
2772
2773 m_aLst.Append( SfxStyleFamily::Char, pFormat == rDoc.GetDfltCharFormat()
2774 ? SwResId(STR_POOLCHR_STANDARD)
2775 : pFormat->GetName() );
2776 }
2777
2778 // PoolFormat
2779 if( bAll )
2780 {
2783 bIsSearchUsed, bSearchHidden, bOnlyHidden,
2784 SwGetPoolIdFromName::ChrFmt, SfxStyleFamily::Char);
2785 else
2786 {
2795 }
2797 bIsSearchUsed, bSearchHidden, bOnlyHidden,
2798 SwGetPoolIdFromName::ChrFmt, SfxStyleFamily::Char);
2799 }
2800 }
2801
2802 if( nSearchFamily == SfxStyleFamily::Para ||
2803 nSearchFamily == SfxStyleFamily::All )
2804 {
2805 SfxStyleSearchBits nSMask = nSrchMask;
2807 {
2808 // then only HTML-Template are of interest
2809 if( SfxStyleSearchBits::AllVisible == ( nSMask & SfxStyleSearchBits::AllVisible ) )
2810 nSMask = SfxStyleSearchBits::SwHtml | SfxStyleSearchBits::UserDefined |
2811 SfxStyleSearchBits::Used;
2812 else
2813 nSMask &= SfxStyleSearchBits::Used | SfxStyleSearchBits::UserDefined |
2814 SfxStyleSearchBits::SwCondColl | SfxStyleSearchBits::SwHtml;
2815 if( nSMask == SfxStyleSearchBits::Auto )
2816 nSMask = SfxStyleSearchBits::SwHtml;
2817 }
2818
2819 const size_t nArrLen = rDoc.GetTextFormatColls()->size();
2820 for( size_t i = 0; i < nArrLen; i++ )
2821 {
2822 SwTextFormatColl* pColl = (*rDoc.GetTextFormatColls())[ i ];
2823
2824 const bool bUsed = bOrganizer || rDoc.IsUsed(*pColl);
2825 if ( ( !bSearchHidden && pColl->IsHidden( ) && !bUsed ) || pColl->IsDefault() )
2826 continue;
2827
2828 if ( nSMask == SfxStyleSearchBits::Hidden && !pColl->IsHidden( ) )
2829 continue;
2830
2831 if( !(bIsSearchUsed && bUsed ))
2832 {
2833 const sal_uInt16 nId = pColl->GetPoolFormatId();
2834 auto tmpMask = nSMask & ~SfxStyleSearchBits::Used;
2835 if (tmpMask == SfxStyleSearchBits::UserDefined)
2836 {
2837 if(!IsPoolUserFormat(nId)) continue;
2838 }
2839 else if (tmpMask == SfxStyleSearchBits::SwText)
2840 {
2841 if((nId & COLL_GET_RANGE_BITS) != COLL_TEXT_BITS) continue;
2842 }
2843 else if (tmpMask == SfxStyleSearchBits::SwChapter)
2844 {
2845 if((nId & COLL_GET_RANGE_BITS) != COLL_DOC_BITS) continue;
2846 }
2847 else if (tmpMask == SfxStyleSearchBits::SwList)
2848 {
2849 if((nId & COLL_GET_RANGE_BITS) != COLL_LISTS_BITS) continue;
2850 }
2851 else if (tmpMask == SfxStyleSearchBits::SwIndex)
2852 {
2853 if((nId & COLL_GET_RANGE_BITS) != COLL_REGISTER_BITS) continue;
2854 }
2855 else if (tmpMask == SfxStyleSearchBits::SwExtra)
2856 {
2857 if((nId & COLL_GET_RANGE_BITS) != COLL_EXTRA_BITS) continue;
2858 }
2859 else if (tmpMask == (SfxStyleSearchBits::SwHtml | SfxStyleSearchBits::UserDefined)
2860 || tmpMask == SfxStyleSearchBits::SwHtml)
2861 {
2862 if((tmpMask & SfxStyleSearchBits::UserDefined) && IsPoolUserFormat(nId))
2863 ; // do nothing
2864 else if( (nId & COLL_GET_RANGE_BITS) != COLL_HTML_BITS)
2865 {
2866 // but some we also want to see in this section
2867 bool bContinue = true;
2868 switch( nId )
2869 {
2870 case RES_POOLCOLL_SEND_ADDRESS: // --> ADDRESS
2871 case RES_POOLCOLL_TABLE_HDLN: // --> TH
2872 case RES_POOLCOLL_TABLE: // --> TD
2873 case RES_POOLCOLL_TEXT: // --> P
2874 case RES_POOLCOLL_HEADLINE_BASE:// --> H
2875 case RES_POOLCOLL_HEADLINE1: // --> H1
2876 case RES_POOLCOLL_HEADLINE2: // --> H2
2877 case RES_POOLCOLL_HEADLINE3: // --> H3
2878 case RES_POOLCOLL_HEADLINE4: // --> H4
2879 case RES_POOLCOLL_HEADLINE5: // --> H5
2880 case RES_POOLCOLL_HEADLINE6: // --> H6
2881 case RES_POOLCOLL_STANDARD: // --> P
2884 bContinue = false;
2885 break;
2886 }
2887 if( bContinue )
2888 continue;
2889 }
2890 }
2891 else if (tmpMask == SfxStyleSearchBits::SwCondColl)
2892 {
2893 if( RES_CONDTXTFMTCOLL != pColl->Which() ) continue;
2894 }
2895 else
2896 {
2897 // searched for used and found none
2898 if( bIsSearchUsed )
2899 continue;
2900 }
2901 }
2902 m_aLst.Append( SfxStyleFamily::Para, pColl->GetName() );
2903 }
2904
2905 bAll = ( nSMask & SfxStyleSearchBits::AllVisible ) == SfxStyleSearchBits::AllVisible;
2906 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwText )
2908 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para );
2909 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwChapter )
2911 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2912 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwList )
2914 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2915 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwIndex )
2917 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2918 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwExtra )
2920 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2921 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwCondColl )
2922 {
2923 if( !bIsSearchUsed ||
2925 m_aLst.Append( SfxStyleFamily::Para, SwStyleNameMapper::GetTextUINameArray()[
2927 }
2928 if ( bAll ||
2929 (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwHtml ||
2930 (nSMask & ~SfxStyleSearchBits::Used) ==
2931 (SfxStyleSearchBits::SwHtml | SfxStyleSearchBits::UserDefined) )
2932 {
2934 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2935 if( !bAll )
2936 {
2937 // then also the ones, that we are mapping:
2938 static sal_uInt16 aPoolIds[] = {
2939 RES_POOLCOLL_SEND_ADDRESS, // --> ADDRESS
2940 RES_POOLCOLL_TABLE_HDLN, // --> TH
2941 RES_POOLCOLL_TABLE, // --> TD
2942 RES_POOLCOLL_STANDARD, // --> P
2943 RES_POOLCOLL_TEXT, // --> P
2945 RES_POOLCOLL_HEADLINE1, // --> H1
2946 RES_POOLCOLL_HEADLINE2, // --> H2
2947 RES_POOLCOLL_HEADLINE3, // --> H3
2948 RES_POOLCOLL_HEADLINE4, // --> H4
2949 RES_POOLCOLL_HEADLINE5, // --> H5
2950 RES_POOLCOLL_HEADLINE6, // --> H6
2953 0
2954 };
2955
2956 sal_uInt16* pPoolIds = aPoolIds;
2957 OUString s;
2958 while( *pPoolIds )
2959 {
2960 if( !bIsSearchUsed || rDoc.getIDocumentStylePoolAccess().IsPoolTextCollUsed( *pPoolIds ) )
2961 {
2962 s = SwStyleNameMapper::GetUIName( *pPoolIds, s );
2963 m_aLst.Append( SfxStyleFamily::Para, s);
2964 }
2965 ++pPoolIds;
2966 }
2967 }
2968 }
2969 }
2970
2971 if( nSearchFamily == SfxStyleFamily::Frame ||
2972 nSearchFamily == SfxStyleFamily::All )
2973 {
2974 const size_t nArrLen = rDoc.GetFrameFormats()->size();
2975 for( size_t i = 0; i < nArrLen; i++ )
2976 {
2977 const SwFrameFormat* pFormat = (*rDoc.GetFrameFormats())[ i ];
2978
2979 bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(*pFormat));
2980 if( ( !bSearchHidden && pFormat->IsHidden( ) && !bUsed ) || pFormat->IsDefault() || pFormat->IsAuto() )
2981 continue;
2982
2983 if ( nSrchMask == SfxStyleSearchBits::Hidden && !pFormat->IsHidden( ) )
2984 continue;
2985
2986 const sal_uInt16 nId = pFormat->GetPoolFormatId();
2987 if( !bUsed )
2988 {
2989 if( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
2990 ? !(nId & USER_FMT)
2991 // searched for used and found none
2992 : bIsSearchUsed )
2993 {
2994 continue;
2995 }
2996 }
2997
2998 m_aLst.Append( SfxStyleFamily::Frame, pFormat->GetName() );
2999 }
3000
3001 // PoolFormat
3002 if ( bAll )
3004 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::FrmFmt, SfxStyleFamily::Frame);
3005 }
3006
3007 if( nSearchFamily == SfxStyleFamily::Page ||
3008 nSearchFamily == SfxStyleFamily::All )
3009 {
3010 const size_t nCount = rDoc.GetPageDescCnt();
3011 for(size_t i = 0; i < nCount; ++i)
3012 {
3013 const SwPageDesc& rDesc = rDoc.GetPageDesc(i);
3014 const sal_uInt16 nId = rDesc.GetPoolFormatId();
3015 bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rDesc));
3016 if( !bUsed )
3017 {
3018 if ( ( !bSearchHidden && rDesc.IsHidden() ) ||
3019 ( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
3020 ? !(nId & USER_FMT)
3021 // searched for used and found none
3022 : bIsSearchUsed ) )
3023 continue;
3024 }
3025
3026 if ( nSrchMask == SfxStyleSearchBits::Hidden && !rDesc.IsHidden( ) )
3027 continue;
3028
3029 m_aLst.Append( SfxStyleFamily::Page, rDesc.GetName() );
3030 }
3031 if ( bAll )
3033 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::PageDesc, SfxStyleFamily::Page);
3034 }
3035
3036 if( nSearchFamily == SfxStyleFamily::Pseudo ||
3037 nSearchFamily == SfxStyleFamily::All )
3038 {
3039 const SwNumRuleTable& rNumTable = rDoc.GetNumRuleTable();
3040 for(auto const& rNum: rNumTable)
3041 {
3042 const SwNumRule& rRule = *rNum;
3043 if( !rRule.IsAutoRule() )
3044 {
3045 if ( nSrchMask == SfxStyleSearchBits::Hidden && !rRule.IsHidden( ) )
3046 continue;
3047
3048 bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(rRule));
3049 if( !bUsed )
3050 {
3051 if( ( !bSearchHidden && rRule.IsHidden() ) ||
3052 ( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
3053 ? !(rRule.GetPoolFormatId() & USER_FMT)
3054 // searched for used and found none
3055 : bIsSearchUsed ) )
3056 continue;
3057 }
3058
3059 m_aLst.Append( SfxStyleFamily::Pseudo, rRule.GetName() );
3060 }
3061 }
3062 if ( bAll )
3064 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::NumRule, SfxStyleFamily::Pseudo);
3065 }
3066
3067 if( nSearchFamily == SfxStyleFamily::Table ||
3068 nSearchFamily == SfxStyleFamily::All )
3069 {
3070 const SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
3071 for(size_t i = 0; i < rTableStyles.size(); ++i)
3072 {
3073 const SwTableAutoFormat& rTableStyle = rTableStyles[i];
3074
3075 bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(rTableStyle));
3076 if(!bUsed)
3077 {
3078 if(nSrchMask == SfxStyleSearchBits::Hidden && !rTableStyle.IsHidden())
3079 continue;
3080
3081 if( (!bSearchHidden && rTableStyle.IsHidden() ) ||
3082 ( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
3083 ? !rTableStyle.IsUserDefined()
3084 // searched for used and found none
3085 : bIsSearchUsed ) )
3086 continue;
3087 }
3088
3089 m_aLst.Append( SfxStyleFamily::Table, rTableStyle.GetName() );
3090 }
3091 }
3092
3093 if( nSearchFamily == SfxStyleFamily::Cell ||
3094 nSearchFamily == SfxStyleFamily::All )
3095 {
3096 const auto& aTableTemplateMap = SwTableAutoFormat::GetTableTemplateMap();
3097 if (rDoc.HasTableStyles())
3098 {
3099 const SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
3100 for(size_t i = 0; i < rTableStyles.size(); ++i)
3101 {
3102 const SwTableAutoFormat& rTableStyle = rTableStyles[i];
3103 for(size_t nBoxFormat = 0; nBoxFormat < aTableTemplateMap.size(); ++nBoxFormat)
3104 {
3105 const sal_uInt32 nBoxIndex = aTableTemplateMap[nBoxFormat];
3106 const SwBoxAutoFormat& rBoxFormat = rTableStyle.GetBoxFormat(nBoxIndex);
3107 OUString sBoxFormatName;
3109 sBoxFormatName += rTableStyle.GetTableTemplateCellSubName(rBoxFormat);
3110 m_aLst.Append( SfxStyleFamily::Cell, sBoxFormatName );
3111 }
3112 }
3113 }
3114 const SwCellStyleTable& rCellStyles = rDoc.GetCellStyles();
3115 for(size_t i = 0; i < rCellStyles.size(); ++i)
3116 m_aLst.Append( SfxStyleFamily::Cell, rCellStyles[i].GetName() );
3117 }
3118
3119 if(!m_aLst.empty())
3120 {
3122 return Next();
3123 }
3124 return nullptr;
3125}
3126
3128{
3129 assert(m_bFirstCalled);
3130 ++m_nLastPos;
3131 if(m_nLastPos < m_aLst.size())
3132 {
3133 auto const & rEntry = m_aLst[m_nLastPos];
3134 mxIterSheet->PresetNameAndFamily(rEntry.first, rEntry.second);
3135 mxIterSheet->SetPhysical( false );
3136 mxIterSheet->SetMask( nMask );
3137 if(mxIterSheet->pSet)
3138 {
3139 mxIterSheet->pSet->ClearItem();
3140 mxIterSheet->pSet= nullptr;
3141 }
3142 return mxIterSheet.get();
3143 }
3144 return nullptr;
3145}
3146
3148{
3149 // searching
3150 if( !m_bFirstCalled )
3151 First();
3152
3154 if( SAL_MAX_UINT32 != m_nLastPos )
3155 {
3156 // found
3157 auto const & rEntry = m_aLst[m_nLastPos];
3158 mxStyleSheet->PresetNameAndFamily(rEntry.first, rEntry.second);
3159 // new name is set, so determine its Data
3161 if( !mxStyleSheet->IsPhysical() )
3162 mxStyleSheet->SetPhysical( false );
3163
3164 return mxStyleSheet.get();
3165 }
3166 return nullptr;
3167}
3168
3169void SwStyleSheetIterator::AppendStyleList(const std::vector<OUString>& rList,
3170 bool bTestUsed, bool bTestHidden, bool bOnlyHidden,
3171 SwGetPoolIdFromName nSection, SfxStyleFamily eFamily )
3172{
3173 const SwDoc& rDoc = static_cast<const SwDocStyleSheetPool*>(pBasePool)->GetDoc();
3174 bool bUsed = false;
3175 for (const auto & i : rList)
3176 {
3177 bool bHidden = false;
3178 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(i, nSection);
3179 switch ( nSection )
3180 {
3182 {
3184 SwFormat* pFormat = rDoc.FindTextFormatCollByName( i );
3185 bHidden = pFormat && pFormat->IsHidden( );
3186 }
3187 break;
3189 {
3191 SwFormat* pFormat = rDoc.FindCharFormatByName( i );
3192 bHidden = pFormat && pFormat->IsHidden( );
3193 }
3194 break;
3196 {
3198 SwFormat* pFormat = rDoc.FindFrameFormatByName( i );
3199 bHidden = pFormat && pFormat->IsHidden( );
3200 }
3201 break;
3203 {
3205 SwPageDesc* pPgDesc = rDoc.FindPageDesc(i);
3206 bHidden = pPgDesc && pPgDesc->IsHidden( );
3207 }
3208 break;
3210 {
3211 SwNumRule* pRule = rDoc.FindNumRulePtr( i );
3212 bUsed = pRule && rDoc.IsUsed(*pRule);
3213 bHidden = pRule && pRule->IsHidden( );
3214 }
3215 break;
3216 default:
3217 OSL_ENSURE( false, "unknown PoolFormat-Id" );
3218 }
3219
3220 bool bMatchHidden = ( bTestHidden && ( bHidden || !bOnlyHidden ) ) || ( !bTestHidden && ( !bHidden || bUsed ) );
3221 if ( ( !bTestUsed && bMatchHidden ) || ( bTestUsed && bUsed ) )
3222 m_aLst.Append( eFamily, i );
3223 }
3224}
3225
3227{
3229 dynamic_cast<SwStyleSheetIterator&>(*pIter).InvalidateIterator();
3230}
3231
3233{
3234 // potentially we could send an SfxHint to Notify but currently it's
3235 // iterating over the vector anyway so would still be slow - why does
3236 // this iterator not use a map?
3237 m_bFirstCalled = false;
3238 m_nLastPos = 0;
3239 m_aLst.clear();
3240}
3241
3243{
3244 // search and remove from View-List!!
3245 const SfxStyleSheetHint* pStyleSheetHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint);
3246 if( pStyleSheetHint &&
3247 SfxHintId::StyleSheetErased == pStyleSheetHint->GetId() )
3248 {
3249 SfxStyleSheetBase* pStyle = pStyleSheetHint->GetStyleSheet();
3250
3251 if (pStyle)
3252 m_aLst.RemoveName(pStyle->GetFamily(), pStyle->GetName());
3253 }
3254}
3255
3256/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwGetPoolIdFromName
@ UndoArg1
Definition: SwRewriter.hxx:29
constexpr OUStringLiteral sModel
#define COND_COMMAND_COUNT
Definition: ccoll.hxx:29
const OUString & GetValue() const
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
virtual void SetEnableSetModified(bool bEnableSetModified)=0
virtual void ResetModified()=0
virtual void SetModified()=0
Must be called manually at changes of format.
virtual bool IsModified() const =0
Changes of document?
virtual bool IsEnableSetModified() const =0
virtual bool IsPoolTextCollUsed(sal_uInt16 nId) const =0
Check whether this "auto-collection" is used in document.
virtual SwFrameFormat * GetFrameFormatFromPool(sal_uInt16 nId)=0
Return required automatic format.
virtual SwPageDesc * GetPageDescFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return required automatic page style.
virtual SwCharFormat * GetCharFormatFromPool(sal_uInt16 nId)=0
virtual bool IsPoolPageDescUsed(sal_uInt16 nId) const =0
virtual bool IsPoolFormatUsed(sal_uInt16 nId) const =0
virtual SwNumRule * GetNumRuleFromPool(sal_uInt16 nId)=0
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
XBitmapListRef GetBitmapList() const
XGradientListRef GetGradientList() const
XPatternListRef GetPatternList() const
XColorListRef GetColorList() const
XHatchListRef GetHatchList() const
void Broadcast(const SfxHint &rHint)
SfxHintId GetId() const
const SfxPoolItem * GetCurItem() const
sal_uInt16 GetCurPos() const
const SfxPoolItem * NextItem()
virtual bool GetPresentation(const SfxPoolItem &rItem, MapUnit ePresentationMetric, OUString &rText, const IntlWrapper &rIntlWrapper) const
void SetParent(const SfxItemSet *pNew)
sal_uInt16 Count() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxItemSet * GetParent() const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
void ClearInvalidItems()
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetWhichByPos(sal_uInt16 nPos) const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
SfxStyleSheetBase * First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask=SfxStyleSearchBits::All)
SfxItemPool & GetPool()
SfxStyleSheetIterator * GetCachedIterator()
SfxStyleSearchBits GetMask() const
virtual bool SetName(const OUString &rNewName, bool bReindexNow=true)
const OUString & GetName() const
SfxStyleSearchBits nMask
SfxStyleFamily GetFamily() const
SfxItemSet * pSet
virtual bool SetFollow(const OUString &)
SfxStyleSheetBasePool * m_pPool
void SetMask(SfxStyleSearchBits mask)
virtual OUString GetDescription(MapUnit eMetric)
SfxStyleFamily nFamily
SfxStyleSheetBase * GetStyleSheet() const
SfxStyleFamily nSearchFamily
bool SearchUsed() const
const SfxStyleSheetBasePool * pBasePool
SfxStyleSearchBits nMask
bool IsCTLFontEnabled() const
void SetTable(bool bNew)
void SetDist(bool bNew)
void SetMinDist(bool bNew)
void SetDefDist(sal_uInt16 nNew)
void SetValid(SvxBoxInfoItemValidFlags nValid, bool bValid=true)
void UnLinkGraphics()
tools::Long GetIndentAt() const
tools::Long GetFirstLineIndent() const
SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const
size_t size() const
Definition: tblafmt.cxx:1172
SwBoxAutoFormat * GetBoxFormat(std::u16string_view sName) const
If found returns a ptr to a BoxFormat. If not found returns nullptr.
Definition: tblafmt.cxx:1216
Represents the style of a text portion.
Definition: charfmt.hxx:27
void SetLinkedParaFormat(SwTextFormatColl *pLink)
Definition: chrfmt.cxx:43
const SwTextFormatColl * GetLinkedParaFormat() const
Definition: chrfmt.cxx:45
size_t size() const
Definition: charformats.hxx:71
void RegisterToFormat(SwFormat &)
Definition: fmtcol.cxx:590
OUString GetStyle(sal_uInt16 nPos) const
Definition: ccoll.cxx:149
static const CommandStruct * GetCmds()
Definition: ccoll.hxx:58
void InsertCondition(const SwCollCondition &rCond)
Definition: fmtcol.cxx:623
SwDocStyleSheetPool(SwDoc &, bool bOrganizer)
Definition: docstyle.cxx:2432
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) const override
Definition: docstyle.cxx:2598
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2444
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2472
virtual bool SetParent(SfxStyleFamily eFam, const OUString &rStyle, const OUString &rParent) override
Definition: docstyle.cxx:2542
virtual void Remove(SfxStyleSheetBase *pStyle) override
Definition: docstyle.cxx:2482
virtual rtl::Reference< SfxStyleSheetBase > Create(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask) override
Definition: docstyle.cxx:2465
virtual ~SwDocStyleSheetPool() override
Definition: docstyle.cxx:2440
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:209
bool m_bOrganizer
Organizer.
Definition: docstyle.hxx:211
virtual bool SetName(const OUString &rNewName, bool bReindexNow=true) override
Definition: docstyle.cxx:1032
virtual bool IsUsed() const override
Definition: docstyle.cxx:2263
SwTextFormatColl * m_pColl
Definition: docstyle.hxx:52
void SetPhysical(bool bPhys)
Definition: docstyle.cxx:2243
void SetLink(const OUString &rStr)
Definition: docstyle.cxx:733
virtual std::optional< SfxItemSet > GetItemSetForPreview() override
Definition: docstyle.cxx:1278
void SetItemSet(const SfxItemSet &rSet, const bool bResetIndentAttrsAtParagraphStyle=false)
add optional parameter <bResetIndentAttrsAtParagraphStyle>, default value false, which indicates that...
Definition: docstyle.cxx:1456
SwDoc & m_rDoc
Definition: docstyle.hxx:58
const SwNumRule * m_pNumRule
Definition: docstyle.hxx:55
virtual SfxItemSet & GetItemSet() override
Definition: docstyle.cxx:1326
virtual bool SetParent(const OUString &rStr) override
Definition: docstyle.cxx:1156
const SwNumRule * GetNumRule()
Definition: docstyle.cxx:2211
virtual bool SetFollow(const OUString &rStr) override
Definition: docstyle.cxx:1207
virtual sal_uLong GetHelpId(OUString &rFile) override
Definition: docstyle.cxx:2300
SAL_DLLPRIVATE void Create()
Make empty shell a real StyleSheet (Core).
Definition: docstyle.cxx:2115
void SetGrabBagItem(const css::uno::Any &rVal)
Definition: docstyle.cxx:464
SwFrameFormat * GetFrameFormat()
Definition: docstyle.cxx:2256
SwCharFormat * m_pCharFormat
Definition: docstyle.hxx:51
SwTableAutoFormat * m_pTableFormat
Definition: docstyle.hxx:56
virtual bool HasParentSupport() const override
Definition: docstyle.cxx:795
virtual void SetHelpId(const OUString &r, sal_uLong nId) override
Definition: docstyle.cxx:2399
void PresetFollow(const OUString &rName)
Definition: docstyle.hxx:122
virtual bool HasFollowSupport() const override
Definition: docstyle.cxx:779
void PresetParent(const OUString &rName)
Definition: docstyle.hxx:121
SwCharFormat * GetCharFormat()
Definition: docstyle.cxx:2190
const OUString & GetLink() const
Definition: docstyle.cxx:767
SwFrameFormat * m_pFrameFormat
Definition: docstyle.hxx:53
OUString m_aLink
Definition: docstyle.hxx:62
virtual bool IsHidden() const override
Definition: docstyle.cxx:622
void PresetNameAndFamily(SfxStyleFamily eFamily, const OUString &rName)
Definition: docstyle.cxx:2236
virtual const OUString & GetParent() const override
Definition: docstyle.cxx:669
SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType, std::optional< SfxItemSet > *o_ppFlatSet=nullptr)
Definition: docstyle.cxx:1873
virtual OUString GetDescription(MapUnit eUnit) override
Definition: docstyle.cxx:824
void SetNumRule(const SwNumRule &rRule)
Definition: docstyle.cxx:2219
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: docstyle.cxx:512
virtual void SetHidden(bool bHidden) override
Definition: docstyle.cxx:539
const SwPageDesc * m_pDesc
Definition: docstyle.hxx:54
SwDocStyleSheet(SwDoc &rDoc, SwDocStyleSheetPool &rPool)
Definition: docstyle.cxx:410
SwTextFormatColl * GetCollection()
Definition: docstyle.cxx:2197
const SwBoxAutoFormat * m_pBoxFormat
Definition: docstyle.hxx:57
virtual ~SwDocStyleSheet() override
virtual OUString GetUsedBy() override
Definition: docstyle.cxx:2295
SwTableAutoFormat * GetTableFormat()
Definition: docstyle.cxx:2225
FillStyleType
Fill StyleSheet with data.
Definition: docstyle.hxx:68
virtual const OUString & GetFollow() const override
Definition: docstyle.cxx:723
void MergeIndentAttrsOfListStyle(SfxItemSet &rSet)
new method for paragraph styles to merge indent attributes of applied list style into the given item ...
Definition: docstyle.cxx:1417
SfxItemSet m_aCoreSet
Definition: docstyle.hxx:59
const SwPageDesc * GetPageDesc()
Definition: docstyle.cxx:2204
virtual bool HasClearParentSupport() const override
Definition: docstyle.cxx:809
Definition: doc.hxx:195
void CopyPageDesc(const SwPageDesc &rSrcDesc, SwPageDesc &rDstDesc, bool bCopyPoolIds=true)
Copy the complete PageDesc - beyond document and "deep"! Optionally copying of PoolFormatId,...
Definition: docfmt.cxx:1417
SwPageDesc * FindPageDesc(const OUString &rName, size_t *pPos=nullptr) const
Definition: docdesc.cxx:947
const OUString * GetDocPattern(size_t nPos) const
Definition: poolfmt.cxx:123
SwConditionTextFormatColl * MakeCondTextFormatColl(const OUString &rFormatName, SwTextFormatColl *pDerivedFrom, bool bBroadcast=false)
Definition: docfmt.cxx:921
size_t SetDocPattern(const OUString &rPatternName)
Definition: poolfmt.cxx:132
void DelCharFormat(size_t nFormat, bool bBroadcast=false)
Delete the formats.
Definition: docfmt.cxx:670
SwFrameFormat * MakeFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom, bool bBroadcast=false, bool bAuto=true)
Definition: docfmt.cxx:820
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:402
const SwCharFormat * GetDfltCharFormat() const
Definition: doc.hxx:764
OUString GetUniqueNumRuleName(const OUString *pChkStr=nullptr, bool bAutoNum=true) const
Definition: docnum.cxx:2521
void ChgFormat(SwFormat &rFormat, const SfxItemSet &rSet)
Definition: docfmt.cxx:1871
void PreDelPageDesc(SwPageDesc const *pDel)
All descriptors whose Follow point to the to-be-deleted have to be adapted.
Definition: docdesc.cxx:680
bool IsUsed(const sw::BroadcastingModify &) const
Definition: poolfmt.cxx:86
void CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet &rSet)
Definition: docfly.cxx:492
const SwCellStyleTable & GetCellStyles() const
Definition: doc.hxx:1262
SwNumRule * FindNumRulePtr(const OUString &rName) const
Definition: docnum.cxx:2443
size_t GetPageDescCnt() const
Definition: doc.hxx:891
const SwNumRuleTable & GetNumRuleTable() const
Definition: doc.hxx:1077
void RenameFormat(SwFormat &rFormat, const OUString &sNewName, bool bBroadcast=false)
Definition: docfmt.cxx:1903
SwCharFormat * FindCharFormatByName(const OUString &rName) const
Definition: doc.hxx:782
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:751
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:152
SwPageDesc * MakePageDesc(const OUString &rName, const SwPageDesc *pCpy=nullptr, bool bRegardLanguage=true, bool bBroadcast=false)
Definition: docdesc.cxx:765
SwEditShell const * GetEditShell() const
Definition: doccorr.cxx:330
bool RenameNumRule(const OUString &aOldName, const OUString &aNewName, bool bBroadcast=false)
Definition: docnum.cxx:1117
void ChgNumRuleFormats(const SwNumRule &rRule)
Definition: docnum.cxx:1095
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:184
const SwTextFormatColls * GetTextFormatColls() const
Definition: doc.hxx:789
std::unique_ptr< SwTableAutoFormat > DelTableStyle(const OUString &rName, bool bBroadcast=false)
Definition: ndtbl.cxx:4563
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:434
void ChgPageDesc(const OUString &rName, const SwPageDesc &)
Definition: docdesc.cxx:978
const SwFrameFormats * GetFrameFormats() const
Definition: doc.hxx:749
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: doc.hxx:810
void DelTextFormatColl(size_t nFormat, bool bBroadcast=false)
Definition: docfmt.cxx:957
void DelFrameFormat(SwFrameFormat *pFormat, bool bBroadcast=false)
Definition: docfmt.cxx:697
SwTextFormatColl * MakeTextFormatColl(const OUString &rFormatName, SwTextFormatColl *pDerivedFrom, bool bBroadcast=false)
Create the FormatCollections.
Definition: docfmt.cxx:888
bool DelNumRule(const OUString &rName, bool bBroadCast=false)
Definition: docnum.cxx:1055
void ResetAttrAtFormat(const sal_uInt16 nWhichId, SwFormat &rChangedFormat)
Definition: docfmt.cxx:495
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:163
SwCharFormat * MakeCharFormat(const OUString &rFormatName, SwCharFormat *pDerivedFrom, bool bBroadcast=false)
Definition: docfmt.cxx:854
const SwFrameFormat * GetDfltFrameFormat() const
Definition: doc.hxx:758
void DelPageDesc(const OUString &rName, bool bBroadcast=false)
Definition: docdesc.cxx:970
SwTableAutoFormatTable & GetTableStyles()
Return the available table styles.
Definition: ndtbl.cxx:3862
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:892
bool HasTableStyles() const
Counts table styles without triggering lazy-load of them.
Definition: doc.hxx:1254
IDocumentListsAccess const & getIDocumentListsAccess() const
Definition: doc.cxx:301
sal_uInt16 MakeNumRule(const OUString &rName, const SwNumRule *pCpy=nullptr, bool bBroadcast=false, const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode=SvxNumberFormat::LABEL_WIDTH_AND_POSITION)
Definition: docnum.cxx:2477
SwFrameFormat * FindFrameFormatByName(const OUString &rName) const
Definition: docfmt.cxx:745
SwTableAutoFormat * MakeTableStyle(const OUString &rName, bool bBroadcast=false)
Definition: ndtbl.cxx:4543
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
void EndAllAction()
Definition: edws.cxx:97
Base class for various Writer styles.
Definition: format.hxx:47
bool IsDefault() const
Definition: format.hxx:129
void SetGrabBagItem(const css::uno::Any &rVal)
Definition: format.cxx:728
sal_uInt16 GetPoolFormatId() const
Get and set Pool style IDs.
Definition: format.hxx:163
bool IsHidden() const
Definition: format.hxx:181
void SetPoolHelpId(sal_uInt16 nId)
Definition: format.hxx:168
void SetPoolFormatId(sal_uInt16 nId)
Definition: format.hxx:164
virtual void SetFormatName(const OUString &rNewName, bool bBroadcast=false)
Definition: format.cxx:145
void SetAutoUpdateOnDirectFormat(bool bNew=true)
Definition: format.hxx:189
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
const OUString & GetName() const
Definition: format.hxx:131
sal_uInt16 GetPoolHelpId() const
Get and set Help-IDs for document templates.
Definition: format.hxx:167
void SetAuto(bool bNew)
Definition: format.hxx:179
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:385
sal_uInt8 GetPoolHlpFileId() const
Definition: format.hxx:169
const SwNumRuleItem & GetNumRule(bool=true) const
Definition: paratr.hxx:241
void SetPoolHlpFileId(sal_uInt8 nId)
Definition: format.hxx:170
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:136
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:318
SwFormat * DerivedFrom() const
Definition: format.hxx:128
bool IsAuto() const
Query / set AutoFormat-flag.
Definition: format.hxx:178
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: format.cxx:720
void SetHidden(bool bValue)
Definition: format.hxx:182
bool IsAutoUpdateOnDirectFormat() const
Query / set m_bAutoUpdateOnDirectFormat-flag.
Definition: format.hxx:188
Style of a layout element.
Definition: frmfmt.hxx:62
virtual void SetFormatName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2593
Specific frame formats (frames, DrawObjects).
size_t size() const
std::pair< const_iterator, bool > push_back(const value_type &x)
Definition: docfmt.cxx:2120
void SetAutoRule(bool bFlag)
Definition: numrule.hxx:230
bool IsAutoRule() const
Definition: numrule.hxx:229
sal_uInt8 GetPoolHlpFileId() const
Definition: numrule.hxx:256
void SetSvxRule(const SvxNumRule &, SwDoc *pDoc)
Definition: number.cxx:925
void SetHidden(bool bValue)
Definition: numrule.hxx:162
void SetName(const OUString &rNm, IDocumentListsAccess &rDocListAccess)
Definition: number.cxx:111
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:87
const OUString & GetName() const
Definition: numrule.hxx:224
bool IsHidden() const
Definition: numrule.hxx:161
sal_uInt16 GetPoolFormatId() const
Query and set PoolFormat IDs.
Definition: numrule.hxx:250
SvxNumRule MakeSvxNumRule() const
Definition: number.cxx:937
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: number.cxx:1140
void SetGrabBagItem(const css::uno::Any &rVal)
Definition: number.cxx:1148
OUString MakeParagraphStyleListString() const
Definition: number.cxx:884
sal_uInt16 GetPoolHelpId() const
Query and set Help-IDs for document styles.
Definition: numrule.hxx:254
sal_uInt16 GetPoolFormatId() const
Query and set PoolFormat-Id.
Definition: pagedesc.hxx:275
sal_uInt16 GetPoolHelpId() const
Definition: pagedesc.hxx:277
const OUString & GetName() const
Definition: pagedesc.hxx:196
void SetFollow(const SwPageDesc *pNew)
Definition: pagedesc.hxx:314
sal_uInt8 GetPoolHlpFileId() const
Definition: pagedesc.hxx:279
bool SetName(const OUString &rNewName)
Definition: pagedesc.cxx:147
const SwPageDesc * GetFollow() const
Definition: pagedesc.hxx:267
void SetHidden(bool const bValue)
Definition: pagedesc.hxx:217
bool IsHidden() const
Definition: pagedesc.hxx:216
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:25
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
static const std::vector< OUString > & GetChrFormatUINameArray()
static const std::vector< OUString > & GetExtraUINameArray()
static const std::vector< OUString > & GetHTMLUINameArray()
static const std::vector< OUString > & GetListsUINameArray()
static const std::vector< OUString > & GetPageDescUINameArray()
static const std::vector< OUString > & GetNumRuleUINameArray()
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
static const std::vector< OUString > & GetHTMLChrFormatUINameArray()
static void FillProgName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
static const std::vector< OUString > & GetFrameFormatUINameArray()
static const std::vector< OUString > & GetTextUINameArray()
static const std::vector< OUString > & GetRegisterUINameArray()
static const std::vector< OUString > & GetDocUINameArray()
static void FillUIName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
void RemoveName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:385
sal_uInt32 FindName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:360
void Append(SfxStyleFamily eFam, const OUString &rStr)
Definition: docstyle.cxx:398
virtual SfxStyleSheetBase * Find(const OUString &rStr) override
Definition: docstyle.cxx:3147
rtl::Reference< SwDocStyleSheet > mxIterSheet
Definition: docstyle.hxx:178
virtual SfxStyleSheetBase * First() override
Definition: docstyle.cxx:2715
SwStyleSheetIterator(SwDocStyleSheetPool &rBase, SfxStyleFamily eFam, SfxStyleSearchBits n)
Definition: docstyle.cxx:2678
sal_uInt32 m_nLastPos
Definition: docstyle.hxx:181
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:179
SwPoolFormatList m_aLst
Definition: docstyle.hxx:180
virtual void Notify(SfxBroadcaster &, const SfxHint &) override
Definition: docstyle.cxx:3242
virtual ~SwStyleSheetIterator() override
Definition: docstyle.cxx:2689
virtual SfxStyleSheetBase * operator[](sal_Int32 nIdx) override
Definition: docstyle.cxx:2702
virtual sal_Int32 Count() override
Definition: docstyle.cxx:2694
void AppendStyleList(const std::vector< OUString > &rLst, bool bUsed, bool bTestHidden, bool bOnlyHidden, SwGetPoolIdFromName nSection, SfxStyleFamily eFamily)
Definition: docstyle.cxx:3169
virtual SfxStyleSheetBase * Next() override
Definition: docstyle.cxx:3127
void AddAutoFormat(const SwTableAutoFormat &rFormat)
Append table style to the existing styles.
Definition: tblafmt.cxx:938
size_t size() const
Definition: tblafmt.cxx:924
SwTableAutoFormat * FindAutoFormat(std::u16string_view rName) const
Find table style with the provided name, return nullptr when not found.
Definition: tblafmt.cxx:990
const SwBoxAutoFormat & GetBoxFormat(sal_uInt8 nPos) const
Definition: tblafmt.cxx:449
static const std::vector< sal_Int32 > & GetTableTemplateMap()
Returns a vector of indexes in aBoxAutoFormat array. Returned indexes points to cells which are mappe...
Definition: tblafmt.cxx:885
bool IsUserDefined() const
Check if style is defined by user.
Definition: tblafmt.hxx:222
const OUString & GetName() const
Definition: tblafmt.hxx:202
OUString GetTableTemplateCellSubName(const SwBoxAutoFormat &rBoxFormat) const
Returns the cell's name postfix. eg. ".1".
Definition: tblafmt.cxx:845
void SetHidden(bool bHidden)
Set if style is hidden.
Definition: tblafmt.hxx:232
bool IsHidden() const
Check if style is hidden.
Definition: tblafmt.hxx:220
Represents the style of a paragraph.
Definition: fmtcol.hxx:61
void SetLinkedCharFormat(SwCharFormat *pLink)
Definition: fmtcol.cxx:380
bool IsAssignedToListLevelOfOutlineStyle() const
Definition: fmtcol.hxx:122
void DeleteAssignmentToListLevelOfOutlineStyle()
Definition: fmtcol.cxx:712
SwTextFormatColl & GetNextTextFormatColl() const
Definition: fmtcol.hxx:106
void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel)
Definition: fmtcol.cxx:685
void SetNextTextFormatColl(SwTextFormatColl &rNext)
Inline implementations.
Definition: fmtcol.hxx:266
::sw::ListLevelIndents AreListLevelIndentsApplicable() const
Definition: fmtcol.cxx:475
int GetAssignedOutlineStyleLevel() const
Definition: fmtcol.cxx:678
const SwCharFormat * GetLinkedCharFormat() const
Definition: fmtcol.cxx:382
size_t size() const
Definition: docary.hxx:87
void push_back(Value const &rVal)
Definition: docary.hxx:101
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
#define FN_COND_COLL
Definition: cmdid.h:828
#define FN_KEEP_ASPECT_RATIO
Definition: cmdid.h:886
#define FN_PARAM_FTN_INFO
Definition: cmdid.h:805
int nCount
virtual OUString GetName() const override
SwDoc & m_rDoc
Definition: docbm.cxx:1215
static SwTableAutoFormat * lcl_FindTableStyle(SwDoc &rDoc, const OUString &rName, SwDocStyleSheet *pStyle=nullptr, bool bCreate=true)
Definition: docstyle.cxx:296
static SwTextFormatColl * lcl_FindParaFormat(SwDoc &rDoc, const OUString &rName, SwDocStyleSheet *pStyle=nullptr, bool bCreate=true)
Definition: docstyle.cxx:159
static SwCharFormat * lcl_FindCharFormat(SwDoc &rDoc, const OUString &rName, SwDocStyleSheet *pStyle=nullptr, bool bCreate=true)
Definition: docstyle.cxx:118
static const SwBoxAutoFormat * lcl_FindCellStyle(SwDoc &rDoc, std::u16string_view rName, SwDocStyleSheet *pStyle)
Definition: docstyle.cxx:323
static bool lcl_Contains(const std::vector< void * > &rArr, const void *p)
Definition: docstyle.cxx:1790
static const SwPageDesc * lcl_FindPageDesc(SwDoc &rDoc, const OUString &rName, SwDocStyleSheet *pStyle=nullptr, bool bCreate=true)
Definition: docstyle.cxx:231
static SwFrameFormat * lcl_FindFrameFormat(SwDoc &rDoc, const OUString &rName, SwDocStyleSheet *pStyle=nullptr, bool bCreate=true)
Definition: docstyle.cxx:197
static void lcl_SaveStyles(SfxStyleFamily nFamily, std::vector< void * > &rArr, SwDoc &rDoc)
Definition: docstyle.cxx:1736
static const SwNumRule * lcl_FindNumRule(SwDoc &rDoc, const OUString &rName, SwDocStyleSheet *pStyle=nullptr, bool bCreate=true)
Definition: docstyle.cxx:265
static void lcl_SwFormatToFlatItemSet(SwFormat const *const pFormat, std::optional< SfxItemSet > &pRet)
Definition: docstyle.cxx:1259
static void lcl_DeleteInfoStyles(SfxStyleFamily nFamily, std::vector< void * > const &rArr, SwDoc &rDoc)
Definition: docstyle.cxx:1795
float u
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CTL_FONTSIZE(28)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr sal_uInt16 RES_CHRATR_END(46)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
constexpr TypedWhichId< SvxFirstLineIndentItem > RES_MARGIN_FIRSTLINE(91)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_WEIGHT(15)
constexpr sal_uInt16 RES_UNKNOWNATR_END(160)
constexpr TypedWhichId< SwConditionTextFormatColl > RES_CONDTXTFMTCOLL(166)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CJK_FONTSIZE(23)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
constexpr sal_uInt16 RES_FRMATR_END(141)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(99)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CTL_WEIGHT(31)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CTL_POSTURE(30)
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_POSTURE(11)
constexpr TypedWhichId< SwNumRuleItem > RES_PARATR_NUMRULE(72)
constexpr sal_uInt16 RES_UNKNOWNATR_BEGIN(RES_BOXATR_END)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(100)
constexpr TypedWhichId< SvxTextLeftMarginItem > RES_MARGIN_TEXTLEFT(92)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CJK_WEIGHT(26)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CJK_POSTURE(25)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(97)
void * p
sal_Int64 n
SvBaseLink * pLink
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
MapUnit
const char * sName
bool IsCJKFontEnabled()
int i
const OUString sEmpty
SvxNumberFormat::SvxNumPositionAndSpaceMode GetDefaultPositionAndSpaceMode()
Definition: number.cxx:1561
ListLevelIndents
Definition: paratr.hxx:52
sal_Int16 nId
const char GetValue[]
sal_uInt16 GetPoolParent(sal_uInt16 nId)
Query defined parent of a POOL-ID Returns 0 if standard USHRT_MAX if no parent the parent in all othe...
Definition: poolfmt.cxx:150
const sal_uInt16 COLL_DOC_BITS
Definition: poolfmt.hxx:69
@ RES_POOLCOLL_HEADLINE5
Heading 5.
Definition: poolfmt.hxx:266
@ RES_POOLCOLL_TEXT
Text body.
Definition: poolfmt.hxx:251
@ RES_POOLCOLL_STANDARD
Standard.
Definition: poolfmt.hxx:250
@ RES_POOLCOLL_HEADLINE6
Heading 6.
Definition: poolfmt.hxx:267
@ RES_POOLCOLL_TEXT_BEGIN
Definition: poolfmt.hxx:248
@ RES_POOLCOLL_TABLE
Subgroup table.
Definition: poolfmt.hxx:341
@ RES_POOLCOLL_HEADLINE_BASE
Subgroup headings.
Definition: poolfmt.hxx:261
@ RES_POOLCOLL_SEND_ADDRESS
Sender.
Definition: poolfmt.hxx:355
@ RES_POOLCOLL_HEADLINE2
Heading 2.
Definition: poolfmt.hxx:263
@ RES_POOLCOLL_HEADLINE4
Heading 4.
Definition: poolfmt.hxx:265
@ RES_POOLCOLL_FOOTNOTE
Footnotes.
Definition: poolfmt.hxx:353
@ RES_POOLCOLL_HEADLINE1
Heading 1.
Definition: poolfmt.hxx:262
@ RES_POOLCOLL_TABLE_HDLN
Table of Contents - heading.
Definition: poolfmt.hxx:342
@ RES_POOLCOLL_HEADLINE3
Heading 3.
Definition: poolfmt.hxx:264
@ RES_POOLCOLL_ENDNOTE
Endnotes.
Definition: poolfmt.hxx:356
@ RES_POOLCHR_INET_VISIT
Internet visited.
Definition: poolfmt.hxx:121
@ RES_POOLCHR_BEGIN
Definition: poolfmt.hxx:110
@ RES_POOLCHR_FOOTNOTE
Footnote.
Definition: poolfmt.hxx:113
@ RES_POOLCHR_ENDNOTE
Endnote.
Definition: poolfmt.hxx:124
@ RES_POOLCHR_INET_NORMAL
Internet normal.
Definition: poolfmt.hxx:120
@ RES_POOLCHR_HTML_END
Definition: poolfmt.hxx:144
@ RES_POOLCHR_HTML_BEGIN
HTML-styles.
Definition: poolfmt.hxx:134
const sal_uInt16 POOLGRP_NOCOLLID
POOLCOLL-IDs: +-—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+ !User! Range ! 0 ! Offset ! +-—+—+—+—+—+—+—+—+—+—+—+...
Definition: poolfmt.hxx:59
const sal_uInt16 COLL_GET_RANGE_BITS
Definition: poolfmt.hxx:71
const sal_uInt16 COLL_REGISTER_BITS
Definition: poolfmt.hxx:68
const sal_uInt16 COLL_TEXT_BITS
Definition: poolfmt.hxx:65
const sal_uInt16 USER_FMT
POLLCOLL-groups:
Definition: poolfmt.hxx:63
bool IsPoolUserFormat(sal_uInt16 nId)
Definition: poolfmt.hxx:86
const sal_uInt16 COLL_HTML_BITS
Definition: poolfmt.hxx:70
const sal_uInt16 COLL_LISTS_BITS
Definition: poolfmt.hxx:66
const sal_uInt16 COLL_EXTRA_BITS
Definition: poolfmt.hxx:67
bool IsInvalidItem(const SfxPoolItem *pItem)
static SfxItemSet & rSet
sal_uIntPtr sal_uLong
SfxStyleFamily
SfxStyleSearchBits
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:168
constexpr SwTwips MIN_BORDER_DIST
Definition: swtypes.hxx:70
unsigned char sal_uInt8
#define SAL_MAX_UINT32
void PageDescToItemSet(const SwPageDesc &rPageDesc, SfxItemSet &rSet)
Definition: uitool.cxx:457
void ItemSetToPageDesc(const SfxItemSet &rSet, SwPageDesc &rPageDesc)
Definition: uitool.cxx:277
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
constexpr TypedWhichId< XFillTransparenceItem > XATTR_FILLTRANSPARENCE(XATTR_FILL_FIRST+5)
constexpr sal_uInt16 XATTR_FILL_FIRST(XATTRSET_LINE+1)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLUSESLIDEBACKGROUND)
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
constexpr TypedWhichId< XFillFloatTransparenceItem > XATTR_FILLFLOATTRANSPARENCE(XATTR_FILL_FIRST+11)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)