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));
508 if (pSh)
509 pSh->CallChgLnk();
510 }
511}
512
514{
515 SwFormat* pFormat = nullptr;
516 switch (nFamily)
517 {
518 case SfxStyleFamily::Char:
520 if (pFormat)
521 pFormat->GetGrabBagItem(rVal);
522 break;
523 case SfxStyleFamily::Para:
525 if (pFormat)
526 pFormat->GetGrabBagItem(rVal);
527 break;
528 case SfxStyleFamily::Pseudo:
529 {
531 if (pRule)
532 pRule->GetGrabBagItem(rVal);
533 }
534 break;
535 default:
536 break;
537 }
538}
539// virtual methods
540void SwDocStyleSheet::SetHidden( bool bValue )
541{
542 bool bChg = false;
543 if(!m_bPhysical)
545
546 SwFormat* pFormat = nullptr;
547 switch(nFamily)
548 {
549 case SfxStyleFamily::Char:
550 pFormat = m_rDoc.FindCharFormatByName( aName );
551 if ( pFormat )
552 {
553 pFormat->SetHidden( bValue );
554 bChg = true;
555 }
556 break;
557
558 case SfxStyleFamily::Para:
560 if ( pFormat )
561 {
562 pFormat->SetHidden( bValue );
563 bChg = true;
564 }
565 break;
566
567 case SfxStyleFamily::Frame:
569 if ( pFormat )
570 {
571 pFormat->SetHidden( bValue );
572 bChg = true;
573 }
574 break;
575
576 case SfxStyleFamily::Page:
577 {
579 if ( pPgDesc )
580 {
581 pPgDesc->SetHidden( bValue );
582 bChg = true;
583 }
584 }
585 break;
586
587 case SfxStyleFamily::Pseudo:
588 {
590 if ( pRule )
591 {
592 pRule->SetHidden( bValue );
593 bChg = true;
594 }
595 }
596 break;
597
598 case SfxStyleFamily::Table:
599 {
601 if ( pTableAutoFormat )
602 {
603 pTableAutoFormat->SetHidden( bValue );
604 bChg = true;
605 }
606 }
607 break;
608
609 default:
610 break;
611 }
612
613 if( bChg )
614 {
615 // calling pPool->First() here would be quite slow...
616 dynamic_cast<SwDocStyleSheetPool&>(*m_pPool).InvalidateIterator(); // internal list has to be updated
617 m_pPool->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified, *this ) );
619 if( pSh )
620 pSh->CallChgLnk();
621 }
622}
623
625{
626 bool bRet = false;
627
628 SwFormat* pFormat = nullptr;
629 switch(nFamily)
630 {
631 case SfxStyleFamily::Char:
632 pFormat = m_rDoc.FindCharFormatByName( aName );
633 bRet = pFormat && pFormat->IsHidden( );
634 break;
635
636 case SfxStyleFamily::Para:
638 bRet = pFormat && pFormat->IsHidden( );
639 break;
640
641 case SfxStyleFamily::Frame:
643 bRet = pFormat && pFormat->IsHidden( );
644 break;
645
646 case SfxStyleFamily::Page:
647 {
649 bRet = pPgDesc && pPgDesc->IsHidden( );
650 }
651 break;
652 case SfxStyleFamily::Pseudo:
653 {
655 bRet = pRule && pRule->IsHidden( );
656 }
657 break;
658 case SfxStyleFamily::Table:
659 {
661 bRet = pTableAutoFormat && pTableAutoFormat->IsHidden( );
662 }
663 break;
664 default:
665 break;
666 }
667
668 return bRet;
669}
670
671const OUString& SwDocStyleSheet::GetParent() const
672{
673 if( !m_bPhysical )
674 {
675 // check if it's already in document
676 SwFormat* pFormat = nullptr;
677 SwGetPoolIdFromName eGetType;
678 switch(nFamily)
679 {
680 case SfxStyleFamily::Char:
681 pFormat = m_rDoc.FindCharFormatByName( aName );
683 break;
684
685 case SfxStyleFamily::Para:
688 break;
689
690 case SfxStyleFamily::Frame:
693 break;
694
695 case SfxStyleFamily::Page:
696 case SfxStyleFamily::Pseudo:
697 default:
698 {
699 static const OUString sEmpty;
700 return sEmpty; // there's no parent
701 }
702 }
703
704 OUString sTmp;
705 if( !pFormat ) // not yet there, so default Parent
706 {
707 sal_uInt16 i = SwStyleNameMapper::GetPoolIdFromUIName( aName, eGetType );
708 i = ::GetPoolParent( i );
709 if( i && USHRT_MAX != i )
711 }
712 else
713 {
714 SwFormat* p = pFormat->DerivedFrom();
715 if( p && !p->IsDefault() )
716 sTmp = p->GetName();
717 }
718 SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
719 pThis->aParent = sTmp;
720 }
721 return aParent;
722}
723
724// Follower
725const OUString& SwDocStyleSheet::GetFollow() const
726{
727 if( !m_bPhysical )
728 {
729 SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
730 pThis->FillStyleSheet( FillAllInfo );
731 }
732 return aFollow;
733}
734
735void SwDocStyleSheet::SetLink(const OUString& rStr)
736{
737 SwImplShellAction aTmpSh(m_rDoc);
738 switch (nFamily)
739 {
740 case SfxStyleFamily::Para:
741 {
742 if (m_pColl)
743 {
745 if (pLink)
746 {
748 }
749 }
750 break;
751 }
752 case SfxStyleFamily::Char:
753 {
754 if (m_pCharFormat)
755 {
757 if (pLink)
758 {
760 }
761 }
762 break;
763 }
764 default:
765 break;
766 }
767}
768
769const OUString& SwDocStyleSheet::GetLink() const
770{
771 if (!m_bPhysical)
772 {
773 SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
775 }
776
777 return m_aLink;
778}
779
780// What Linkage is possible
782{
783 switch(nFamily)
784 {
785 case SfxStyleFamily::Para :
786 case SfxStyleFamily::Page : return true;
787 case SfxStyleFamily::Frame:
788 case SfxStyleFamily::Char :
789 case SfxStyleFamily::Pseudo: return false;
790 default:
791 OSL_ENSURE(false, "unknown style family");
792 }
793 return false;
794}
795
796// Parent ?
798{
799 bool bRet = false;
800 switch(nFamily)
801 {
802 case SfxStyleFamily::Char :
803 case SfxStyleFamily::Para :
804 case SfxStyleFamily::Frame: bRet = true;
805 break;
806 default:; //prevent warning
807 }
808 return bRet;
809}
810
812{
813 bool bRet = false;
814 switch(nFamily)
815 {
816 case SfxStyleFamily::Para :
817 case SfxStyleFamily::Char :
818 case SfxStyleFamily::Frame: bRet = true;
819 break;
820 default:; //prevent warning
821 }
822 return bRet;
823}
824
825// determine textual description
827{
828 IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
829
830 static const OUStringLiteral sPlus(u" + ");
831 if ( SfxStyleFamily::Page == nFamily )
832 {
833 if( !pSet )
834 GetItemSet();
835
836 SfxItemIter aIter( *pSet );
837 OUStringBuffer aDesc;
838
839 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
840 {
841 if(!IsInvalidItem(pItem))
842 {
843 switch ( pItem->Which() )
844 {
845 case RES_LR_SPACE:
846 case SID_ATTR_PAGE_SIZE:
847 case SID_ATTR_PAGE_MAXSIZE:
848 case SID_ATTR_PAGE_PAPERBIN:
849 case SID_ATTR_BORDER_INNER:
850 break;
851 default:
852 {
853 OUString aItemPresentation;
854 if ( !IsInvalidItem( pItem ) &&
856 *pItem, eUnit, aItemPresentation, aIntlWrapper ) )
857 {
858 if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
859 aDesc.append(sPlus);
860 aDesc.append(aItemPresentation);
861 }
862 }
863 }
864 }
865 }
866 return aDesc.makeStringAndClear();
867 }
868
869 if ( SfxStyleFamily::Frame == nFamily || SfxStyleFamily::Para == nFamily || SfxStyleFamily::Char == nFamily )
870 {
871 if( !pSet )
872 GetItemSet();
873
874 SfxItemIter aIter( *pSet );
875 OUStringBuffer aDesc;
876 OUString sPageNum;
877 OUString sModel;
878 OUString sBreak;
879 bool bHasWesternFontPrefix = false;
880 bool bHasCJKFontPrefix = false;
881 bool bHasCTLFontPrefix = false;
882 SvtCTLOptions aCTLOptions;
883
884 // Get currently used FillStyle and remember, also need the XFillFloatTransparenceItem
885 // to decide if gradient transparence is used
886 const drawing::FillStyle eFillStyle(pSet->Get(XATTR_FILLSTYLE).GetValue());
887 const bool bUseFloatTransparence(pSet->Get(XATTR_FILLFLOATTRANSPARENCE).IsEnabled());
888
889 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
890 {
891 if(!IsInvalidItem(pItem))
892 {
893 switch ( pItem->Which() )
894 {
895 case SID_ATTR_AUTO_STYLE_UPDATE:
896 case RES_PAGEDESC:
897 break;
898 default:
899 {
900 OUString aItemPresentation;
901 if ( !IsInvalidItem( pItem ) &&
903 *pItem, eUnit, aItemPresentation, aIntlWrapper ) )
904 {
905 bool bIsDefault = false;
906 switch ( pItem->Which() )
907 {
908 case XATTR_FILLCOLOR:
909 {
910 // only use active FillStyle information
911 bIsDefault = (drawing::FillStyle_SOLID == eFillStyle);
912 break;
913 }
915 {
916 // only use active FillStyle information
917 bIsDefault = (drawing::FillStyle_GRADIENT == eFillStyle);
918 break;
919 }
920 case XATTR_FILLHATCH:
921 {
922 // only use active FillStyle information
923 bIsDefault = (drawing::FillStyle_HATCH == eFillStyle);
924 break;
925 }
926 case XATTR_FILLBITMAP:
927 {
928 // only use active FillStyle information
929 bIsDefault = (drawing::FillStyle_BITMAP == eFillStyle);
930 break;
931 }
933 {
934 // only active when not FloatTransparence
935 bIsDefault = !bUseFloatTransparence;
936 break;
937 }
939 {
940 // only active when FloatTransparence
941 bIsDefault = bUseFloatTransparence;
942 break;
943 }
944
945 case SID_ATTR_PARA_PAGENUM:
946 sPageNum = aItemPresentation;
947 break;
948 case SID_ATTR_PARA_MODEL:
949 sModel = aItemPresentation;
950 break;
951 case RES_BREAK:
952 sBreak = aItemPresentation;
953 break;
960 bIsDefault = true;
961 if(!bHasCJKFontPrefix)
962 {
963 aItemPresentation = SwResId(STR_CJK_FONT) + aItemPresentation;
964 bHasCJKFontPrefix = true;
965 }
966 break;
972 if(aCTLOptions.IsCTLFontEnabled())
973 bIsDefault = true;
974 if(!bHasCTLFontPrefix)
975 {
976 aItemPresentation = SwResId(STR_CTL_FONT) + aItemPresentation;
977 bHasCTLFontPrefix = true;
978 }
979 break;
980 case RES_CHRATR_FONT:
985 if(!bHasWesternFontPrefix)
986 {
987 aItemPresentation = SwResId(STR_WESTERN_FONT) + aItemPresentation;
988 bHasWesternFontPrefix = true;
989 }
990 [[fallthrough]];
991 default:
992 bIsDefault = true;
993 }
994 if(bIsDefault)
995 {
996 if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
997 aDesc.append(sPlus);
998 aDesc.append(aItemPresentation);
999 }
1000 }
1001 }
1002 }
1003 }
1004 }
1005 // Special treatment for Break, Page template and Site offset
1006 if (!sModel.isEmpty())
1007 {
1008 if (!aDesc.isEmpty())
1009 aDesc.append(sPlus);
1010 aDesc.append(SwResId(STR_PAGEBREAK) + sPlus + sModel);
1011 if (sPageNum != "0")
1012 {
1013 aDesc.append(sPlus + SwResId(STR_PAGEOFFSET) + sPageNum);
1014 }
1015 }
1016 else if (!sBreak.isEmpty()) // Break can be valid only when NO Model
1017 {
1018 if (!aDesc.isEmpty())
1019 aDesc.append(sPlus);
1020 aDesc.append(sBreak);
1021 }
1022 return aDesc.makeStringAndClear();
1023 }
1024
1025 if( SfxStyleFamily::Pseudo == nFamily )
1026 {
1027 return OUString();
1028 }
1029
1031}
1032
1033// Set names
1034bool SwDocStyleSheet::SetName(const OUString& rStr, bool bReindexNow)
1035{
1036 if( rStr.isEmpty() )
1037 return false;
1038
1039 if( aName != rStr )
1040 {
1041 if( !SfxStyleSheetBase::SetName(rStr, bReindexNow))
1042 return false;
1043 }
1044 else if(!m_bPhysical)
1046
1047 bool bChg = false;
1048 switch(nFamily)
1049 {
1050 case SfxStyleFamily::Char :
1051 {
1052 OSL_ENSURE(m_pCharFormat, "SwCharFormat missing!");
1053 if( m_pCharFormat && m_pCharFormat->GetName() != rStr )
1054 {
1055 if (!m_pCharFormat->GetName().isEmpty())
1057 else
1059
1060 bChg = true;
1061 }
1062 break;
1063 }
1064 case SfxStyleFamily::Para :
1065 {
1066 OSL_ENSURE(m_pColl, "Collection missing!");
1067 if( m_pColl && m_pColl->GetName() != rStr )
1068 {
1069 if (!m_pColl->GetName().isEmpty())
1070 m_rDoc.RenameFormat(*m_pColl, rStr);
1071 else
1072 m_pColl->SetFormatName(rStr);
1073
1074 bChg = true;
1075 }
1076 break;
1077 }
1078 case SfxStyleFamily::Frame:
1079 {
1080 OSL_ENSURE(m_pFrameFormat, "FrameFormat missing!");
1081 if( m_pFrameFormat && m_pFrameFormat->GetName() != rStr )
1082 {
1083 if (!m_pFrameFormat->GetName().isEmpty())
1085 else
1087
1088 bChg = true;
1089 }
1090 break;
1091 }
1092 case SfxStyleFamily::Page :
1093 OSL_ENSURE(m_pDesc, "PageDesc missing!");
1094 if( m_pDesc && m_pDesc->GetName() != rStr )
1095 {
1096 // Set PageDesc - copy with earlier one - probably not
1097 // necessary for setting the name. So here we allow a
1098 // cast.
1099 SwPageDesc aPageDesc(*const_cast<SwPageDesc*>(m_pDesc));
1100 const OUString aOldName(aPageDesc.GetName());
1101
1102 aPageDesc.SetName( rStr );
1103 bool const bDoesUndo = m_rDoc.GetIDocumentUndoRedo().DoesUndo();
1104
1105 m_rDoc.GetIDocumentUndoRedo().DoUndo(!aOldName.isEmpty());
1106 m_rDoc.ChgPageDesc(aOldName, aPageDesc);
1107 m_rDoc.GetIDocumentUndoRedo().DoUndo(bDoesUndo);
1108
1110 bChg = true;
1111 }
1112 break;
1113 case SfxStyleFamily::Pseudo:
1114 OSL_ENSURE(m_pNumRule, "NumRule missing!");
1115
1116 if (m_pNumRule)
1117 {
1118 OUString aOldName = m_pNumRule->GetName();
1119
1120 if (!aOldName.isEmpty())
1121 {
1122 if ( aOldName != rStr &&
1123 m_rDoc.RenameNumRule(aOldName, rStr))
1124 {
1127
1128 bChg = true;
1129 }
1130 }
1131 else
1132 {
1133 // #i91400#
1134 const_cast<SwNumRule*>(m_pNumRule)->SetName( rStr, m_rDoc.getIDocumentListsAccess() );
1136
1137 bChg = true;
1138 }
1139 }
1140
1141 break;
1142
1143 default:
1144 OSL_ENSURE(false, "unknown style family");
1145 }
1146
1147 if( bChg )
1148 {
1149 m_pPool->First(nFamily); // internal list has to be updated
1150 m_pPool->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified, *this ) );
1152 if( pSh )
1153 pSh->CallChgLnk();
1154 }
1155 return true;
1156}
1157
1158// hierarchy of deduction
1159bool SwDocStyleSheet::SetParent( const OUString& rStr)
1160{
1161 SwFormat* pFormat = nullptr, *pParent = nullptr;
1162 switch(nFamily)
1163 {
1164 case SfxStyleFamily::Char :
1165 OSL_ENSURE( m_pCharFormat, "SwCharFormat missing!" );
1166 if( nullptr != ( pFormat = m_pCharFormat ) && !rStr.isEmpty() )
1167 pParent = lcl_FindCharFormat(m_rDoc, rStr);
1168 break;
1169
1170 case SfxStyleFamily::Para :
1171 OSL_ENSURE( m_pColl, "Collection missing!");
1172 if( nullptr != ( pFormat = m_pColl ) && !rStr.isEmpty() )
1173 pParent = lcl_FindParaFormat( m_rDoc, rStr );
1174 break;
1175
1176 case SfxStyleFamily::Frame:
1177 OSL_ENSURE(m_pFrameFormat, "FrameFormat missing!");
1178 if( nullptr != ( pFormat = m_pFrameFormat ) && !rStr.isEmpty() )
1179 pParent = lcl_FindFrameFormat( m_rDoc, rStr );
1180 break;
1181
1182 case SfxStyleFamily::Page:
1183 case SfxStyleFamily::Pseudo:
1184 break;
1185 default:
1186 OSL_ENSURE(false, "unknown style family");
1187 }
1188
1189 bool bRet = false;
1190 if( pFormat && pFormat->DerivedFrom() &&
1191 pFormat->DerivedFrom()->GetName() != rStr )
1192 {
1193 {
1194 SwImplShellAction aTmp( m_rDoc );
1195 bRet = pFormat->SetDerivedFrom( pParent );
1196 }
1197
1198 if( bRet )
1199 {
1200 aParent = rStr;
1201 m_pPool->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified,
1202 *this ) );
1203 }
1204 }
1205
1206 return bRet;
1207}
1208
1209// Set Follower
1210bool SwDocStyleSheet::SetFollow( const OUString& rStr)
1211{
1212 if( !rStr.isEmpty() && !SfxStyleSheetBase::SetFollow( rStr ))
1213 return false;
1214
1215 SwImplShellAction aTmpSh( m_rDoc );
1216 switch(nFamily)
1217 {
1218 case SfxStyleFamily::Para :
1219 {
1220 OSL_ENSURE(m_pColl, "Collection missing!");
1221 if( m_pColl )
1222 {
1223 SwTextFormatColl* pFollow = m_pColl;
1224 if( !rStr.isEmpty() && nullptr == (pFollow = lcl_FindParaFormat(m_rDoc, rStr) ))
1225 pFollow = m_pColl;
1226
1227 m_pColl->SetNextTextFormatColl(*pFollow);
1228 }
1229 break;
1230 }
1231 case SfxStyleFamily::Page :
1232 {
1233 OSL_ENSURE(m_pDesc, "PageDesc missing!");
1234 if( m_pDesc )
1235 {
1236 const SwPageDesc* pFollowDesc = !rStr.isEmpty()
1237 ? lcl_FindPageDesc(m_rDoc, rStr)
1238 : nullptr;
1239 size_t nId = 0;
1240 if (pFollowDesc != m_pDesc->GetFollow() && m_rDoc.FindPageDesc(m_pDesc->GetName(), &nId))
1241 {
1242 SwPageDesc aDesc( *m_pDesc );
1243 aDesc.SetFollow( pFollowDesc );
1244 m_rDoc.ChgPageDesc( nId, aDesc );
1246 }
1247 }
1248 break;
1249 }
1250 case SfxStyleFamily::Char:
1251 case SfxStyleFamily::Frame:
1252 case SfxStyleFamily::Pseudo:
1253 break;
1254 default:
1255 OSL_ENSURE(false, "unknown style family");
1256 }
1257
1258 return true;
1259}
1260
1261static
1262void lcl_SwFormatToFlatItemSet(SwFormat const *const pFormat, std::optional<SfxItemSet>& pRet)
1263{
1264 // note: we don't add the odd items that GetItemSet() would add
1265 // because they don't seem relevant for preview
1266 std::vector<SfxItemSet const*> sets;
1267 sets.push_back(&pFormat->GetAttrSet());
1268 while (SfxItemSet const*const pParent = sets.back()->GetParent())
1269 {
1270 sets.push_back(pParent);
1271 }
1272 // start by copying top-level parent set
1273 pRet.emplace(*sets.back());
1274 sets.pop_back();
1275 for (auto iter = sets.rbegin(); iter != sets.rend(); ++iter)
1276 { // in reverse so child overrides parent
1277 pRet->Put(**iter);
1278 }
1279}
1280
1281std::optional<SfxItemSet> SwDocStyleSheet::GetItemSetForPreview()
1282{
1283 if (SfxStyleFamily::Page == nFamily || SfxStyleFamily::Pseudo == nFamily || SfxStyleFamily::Table == nFamily)
1284 {
1285 SAL_WARN("sw.ui", "GetItemSetForPreview not implemented for page or number or table style");
1286 return std::optional<SfxItemSet>();
1287 }
1288 if (!m_bPhysical)
1289 {
1290 // because not only this style, but also any number of its parents
1291 // (or follow style) may not actually exist in the document at this
1292 // time, return one "flattened" item set that contains all items from
1293 // all parents.
1294 std::optional<SfxItemSet> pRet;
1295
1296 bool bModifiedEnabled = m_rDoc.getIDocumentState().IsEnableSetModified();
1298
1300
1301 m_rDoc.getIDocumentState().SetEnableSetModified(bModifiedEnabled);
1302
1303 assert(pRet);
1304 return pRet;
1305 }
1306 else
1307 {
1308 std::optional<SfxItemSet> pRet;
1309 switch (nFamily)
1310 {
1311 case SfxStyleFamily::Char:
1313 break;
1314 case SfxStyleFamily::Para:
1316 break;
1317 case SfxStyleFamily::Frame:
1319 break;
1320 default:
1321 std::abort();
1322 }
1323 return pRet;
1324 }
1325}
1326
1327// extract ItemSet to Name and Family, Mask
1328
1330{
1331 if(!m_bPhysical)
1333
1334 switch(nFamily)
1335 {
1336 case SfxStyleFamily::Char:
1337 case SfxStyleFamily::Para:
1338 case SfxStyleFamily::Frame:
1339 {
1340 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1341 aBoxInfo.SetTable( false );
1342 aBoxInfo.SetDist( true ); // always show gap field
1343 aBoxInfo.SetMinDist( true );// set minimum size in tables and paragraphs
1344 aBoxInfo.SetDefDist( MIN_BORDER_DIST );// always set Default-Gap
1345 // Single lines can only have DontCare-Status in tables
1346 aBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISABLE );
1347
1348 if( nFamily == SfxStyleFamily::Char )
1349 {
1350 SAL_WARN_IF(!m_pCharFormat, "sw.ui", "Where's SwCharFormat");
1352 m_aCoreSet.Put( aBoxInfo );
1353
1356 }
1357 else if ( nFamily == SfxStyleFamily::Para )
1358 {
1359 OSL_ENSURE(m_pColl, "Where's Collection");
1361 m_aCoreSet.Put( aBoxInfo );
1362 m_aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, m_pColl->IsAutoUpdateFormat()));
1363
1364 if(m_pColl->DerivedFrom())
1366 }
1367 else
1368 {
1369 OSL_ENSURE(m_pFrameFormat, "Where's FrameFormat");
1371 m_aCoreSet.Put( aBoxInfo );
1372 m_aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, m_pFrameFormat->IsAutoUpdateFormat()));
1373
1376
1377 // create needed items for XPropertyList entries from the DrawModel so that
1378 // the Area TabPage can access them
1380
1381 m_aCoreSet.Put(SvxColorListItem(pDrawModel->GetColorList(), SID_COLOR_TABLE));
1382 m_aCoreSet.Put(SvxGradientListItem(pDrawModel->GetGradientList(), SID_GRADIENT_LIST));
1383 m_aCoreSet.Put(SvxHatchListItem(pDrawModel->GetHatchList(), SID_HATCH_LIST));
1384 m_aCoreSet.Put(SvxBitmapListItem(pDrawModel->GetBitmapList(), SID_BITMAP_LIST));
1385 m_aCoreSet.Put(SvxPatternListItem(pDrawModel->GetPatternList(), SID_PATTERN_LIST));
1386 }
1387 }
1388 break;
1389
1390 case SfxStyleFamily::Page :
1391 {
1392 // set correct parent to get the drawing::FillStyle_NONE FillStyle as needed
1393 if(!m_aCoreSet.GetParent())
1394 {
1396 }
1397
1398 OSL_ENSURE(m_pDesc, "No PageDescriptor");
1400 }
1401 break;
1402
1403 case SfxStyleFamily::Pseudo:
1404 {
1405 OSL_ENSURE(m_pNumRule, "No NumRule");
1407 m_aCoreSet.Put(SvxNumBulletItem(std::move(aRule)));
1408 }
1409 break;
1410
1411 default:
1412 OSL_ENSURE(false, "unknown style family");
1413 }
1414 // Member of Baseclass
1415 pSet = &m_aCoreSet;
1416
1417 return m_aCoreSet;
1418}
1419
1421{
1422 if ( nFamily != SfxStyleFamily::Para )
1423 {
1424 return;
1425 }
1426
1427 OSL_ENSURE( m_pColl, "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - missing paragraph style");
1429 return;
1430
1431 OSL_ENSURE( m_pColl->GetItemState( RES_PARATR_NUMRULE ) == SfxItemState::SET,
1432 "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - list level indents are applicable at paragraph style, but no list style found. Serious defect." );
1433 const OUString sNumRule = m_pColl->GetNumRule().GetValue();
1434 if (sNumRule.isEmpty())
1435 return;
1436
1437 const SwNumRule* pRule = m_rDoc.FindNumRulePtr( sNumRule );
1438 if( pRule )
1439 {
1440 const SwNumFormat& rFormat = pRule->Get( 0 );
1442 {
1444 aLR.SetTextLeft( rFormat.GetIndentAt() );
1445 aLR.SetTextFirstLineOffset( static_cast<short>(rFormat.GetFirstLineIndent()) );
1446 rSet.Put( aLR );
1447 }
1448 }
1449}
1450
1451// handling of parameter <bResetIndentAttrsAtParagraphStyle>
1453 const bool bResetIndentAttrsAtParagraphStyle )
1454{
1455 // if applicable determine format first
1456 if(!m_bPhysical)
1458
1459 SwImplShellAction aTmpSh( m_rDoc );
1460
1461 OSL_ENSURE( &rSet != &m_aCoreSet, "SetItemSet with own Set is not allowed" );
1462
1464 {
1465 SwRewriter aRewriter;
1466 aRewriter.AddRule( UndoArg1, GetName() );
1468 }
1469
1470 SwFormat* pFormat = nullptr;
1471 std::unique_ptr<SwPageDesc> pNewDsc;
1472 size_t nPgDscPos = 0;
1473
1474 switch(nFamily)
1475 {
1476 case SfxStyleFamily::Char :
1477 {
1478 OSL_ENSURE(m_pCharFormat, "Where's CharFormat");
1479 pFormat = m_pCharFormat;
1480 }
1481 break;
1482
1483 case SfxStyleFamily::Para :
1484 {
1485 OSL_ENSURE(m_pColl, "Where's Collection");
1486 if(const SfxBoolItem* pAutoUpdate = rSet.GetItemIfSet(SID_ATTR_AUTO_STYLE_UPDATE,false))
1487 {
1488 m_pColl->SetAutoUpdateFormat(pAutoUpdate->GetValue());
1489 }
1490
1491 const SwCondCollItem* pCondItem = rSet.GetItemIfSet( FN_COND_COLL, false );
1492
1493 if( RES_CONDTXTFMTCOLL == m_pColl->Which() && pCondItem )
1494 {
1495 const CommandStruct* pCmds = SwCondCollItem::GetCmds();
1496 for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++)
1497 {
1498 SwCollCondition aCond( nullptr, pCmds[ i ].nCnd, pCmds[ i ].nSubCond );
1499 static_cast<SwConditionTextFormatColl*>(m_pColl)->RemoveCondition( aCond );
1500 const OUString sStyle = pCondItem->GetStyle( i );
1501 if (sStyle.isEmpty())
1502 continue;
1503 SwFormat *const pFindFormat = lcl_FindParaFormat( m_rDoc, sStyle );
1504 if (pFindFormat)
1505 {
1506 aCond.RegisterToFormat( *pFindFormat );
1507 static_cast<SwConditionTextFormatColl*>(m_pColl)->InsertCondition( aCond );
1508 }
1509 }
1510
1512 }
1513 else if( pCondItem && !m_pColl->HasWriterListeners() )
1514 {
1515 // no conditional template, then first create and adopt
1516 // all important values
1518 m_pColl->GetName(), static_cast<SwTextFormatColl*>(m_pColl->DerivedFrom()) );
1521
1524 else
1526
1527 const CommandStruct* pCmds = SwCondCollItem::GetCmds();
1528 for( sal_uInt16 i = 0; i < COND_COMMAND_COUNT; ++i )
1529 {
1530 const OUString sStyle = pCondItem->GetStyle( i );
1531 if (sStyle.isEmpty())
1532 continue;
1533 SwTextFormatColl *const pFindFormat = lcl_FindParaFormat( m_rDoc, sStyle );
1534 if (pFindFormat)
1535 {
1536 pCColl->InsertCondition( SwCollCondition( pFindFormat,
1537 pCmds[ i ].nCnd, pCmds[ i ].nSubCond ) );
1538 }
1539 }
1540
1542 m_pColl = pCColl;
1543 }
1544 if ( bResetIndentAttrsAtParagraphStyle &&
1545 rSet.GetItemState( RES_PARATR_NUMRULE, false ) == SfxItemState::SET &&
1546 rSet.GetItemState( RES_LR_SPACE, false ) != SfxItemState::SET &&
1547 m_pColl->GetItemState( RES_LR_SPACE, false ) == SfxItemState::SET )
1548 {
1550 }
1551
1552 // #i56252: If a standard numbering style is assigned to a standard paragraph style
1553 // we have to create a physical instance of the numbering style. If we do not and
1554 // neither the paragraph style nor the numbering style is used in the document
1555 // the numbering style will not be saved with the document and the assignment got lost.
1556 if( const SfxPoolItem* pNumRuleItem = rSet.GetItemIfSet( RES_PARATR_NUMRULE, false ) )
1557 { // Setting a numbering rule?
1558 const OUString sNumRule = static_cast<const SwNumRuleItem*>(pNumRuleItem)->GetValue();
1559 if (!sNumRule.isEmpty())
1560 {
1561 SwNumRule* pRule = m_rDoc.FindNumRulePtr( sNumRule );
1562 if( !pRule )
1563 { // Numbering rule not in use yet.
1565 if( USHRT_MAX != nPoolId ) // It's a standard numbering rule
1566 {
1567 m_rDoc.getIDocumentStylePoolAccess().GetNumRuleFromPool( nPoolId ); // Create numbering rule (physical)
1568 }
1569 }
1570 }
1571 }
1572
1573 pFormat = m_pColl;
1574
1575 sal_uInt16 nId = m_pColl->GetPoolFormatId() &
1577 switch( GetMask() & ( static_cast<SfxStyleSearchBits>(0x0fff) & ~SfxStyleSearchBits::SwCondColl ) )
1578 {
1579 case SfxStyleSearchBits::SwText:
1581 break;
1582 case SfxStyleSearchBits::SwChapter:
1583 nId |= COLL_DOC_BITS;
1584 break;
1585 case SfxStyleSearchBits::SwList:
1587 break;
1588 case SfxStyleSearchBits::SwIndex:
1590 break;
1591 case SfxStyleSearchBits::SwExtra:
1593 break;
1594 case SfxStyleSearchBits::SwHtml:
1596 break;
1597 default: break;
1598 }
1600 break;
1601 }
1602 case SfxStyleFamily::Frame:
1603 {
1604 OSL_ENSURE(m_pFrameFormat, "Where's FrameFormat");
1605
1606 if(const SfxPoolItem* pAutoUpdate = rSet.GetItemIfSet(SID_ATTR_AUTO_STYLE_UPDATE,false))
1607 {
1608 m_pFrameFormat->SetAutoUpdateFormat(static_cast<const SfxBoolItem*>(pAutoUpdate)->GetValue());
1609 }
1610 pFormat = m_pFrameFormat;
1611 }
1612 break;
1613
1614 case SfxStyleFamily::Page :
1615 {
1616 OSL_ENSURE(m_pDesc, "Where's PageDescriptor");
1617
1618 if (m_rDoc.FindPageDesc(m_pDesc->GetName(), &nPgDscPos))
1619 {
1620 pNewDsc.reset( new SwPageDesc( *m_pDesc ) );
1621 // #i48949# - no undo actions for the
1622 // copy of the page style
1624 m_rDoc.CopyPageDesc(*m_pDesc, *pNewDsc); // #i7983#
1625
1626 pFormat = &pNewDsc->GetMaster();
1627 }
1628 }
1629 break;
1630
1631 case SfxStyleFamily::Pseudo:
1632 {
1633 OSL_ENSURE(m_pNumRule, "Where's NumRule");
1634
1635 if (!m_pNumRule)
1636 break;
1637
1638 const SfxPoolItem* pItem;
1639 switch( rSet.GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem ))
1640 {
1641 case SfxItemState::SET:
1642 {
1643 SvxNumRule& rSetRule = const_cast<SvxNumRule&>(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
1644 rSetRule.UnLinkGraphics();
1645 SwNumRule aSetRule(*m_pNumRule);
1646 aSetRule.SetSvxRule(rSetRule, &m_rDoc);
1647 m_rDoc.ChgNumRuleFormats( aSetRule );
1648 }
1649 break;
1650 case SfxItemState::DONTCARE:
1651 // set NumRule to default values
1652 // what are the default values?
1653 {
1654 SwNumRule aRule( m_pNumRule->GetName(),
1655 // #i89178#
1657 m_rDoc.ChgNumRuleFormats( aRule );
1658 }
1659 break;
1660 default: break;
1661 }
1662 }
1663 break;
1664
1665 default:
1666 OSL_ENSURE(false, "unknown style family");
1667 }
1668
1669 if( pFormat && rSet.Count())
1670 {
1671 SfxItemIter aIter( rSet );
1672 const SfxPoolItem* pItem = aIter.GetCurItem();
1673 do
1674 {
1675 if( IsInvalidItem( pItem ) ) // Clear
1676 {
1677 // use method <SwDoc::ResetAttrAtFormat(..)> in order to
1678 // create an Undo object for the attribute reset.
1680 *pFormat );
1681 }
1682
1683 pItem = aIter.NextItem();
1684 } while (pItem);
1685 SfxItemSet aSet(rSet);
1686 aSet.ClearInvalidItems();
1687
1688 if(SfxStyleFamily::Frame == nFamily)
1689 {
1690 // Need to check for unique item for DrawingLayer items of type NameOrIndex
1691 // and evtl. correct that item to ensure unique names for that type. This call may
1692 // modify/correct entries inside of the given SfxItemSet
1694 }
1695
1697
1698 if( pNewDsc )
1699 {
1700 ::ItemSetToPageDesc( aSet, *pNewDsc );
1701 m_rDoc.ChgPageDesc( nPgDscPos, *pNewDsc );
1702 m_pDesc = &m_rDoc.GetPageDesc( nPgDscPos );
1703 m_rDoc.PreDelPageDesc(pNewDsc.get()); // #i7983#
1704 pNewDsc.reset();
1705 }
1706 else
1707 m_rDoc.ChgFormat(*pFormat, aSet); // put all that is set
1708 }
1709 else
1710 {
1712 if( pNewDsc ) // we still need to delete it
1713 {
1714 m_rDoc.PreDelPageDesc(pNewDsc.get()); // #i7983#
1715 pNewDsc.reset();
1716 }
1717 }
1718
1720 {
1722 }
1723}
1724
1725static void lcl_SaveStyles( SfxStyleFamily nFamily, std::vector<void*>& rArr, SwDoc& rDoc )
1726{
1727 switch( nFamily )
1728 {
1729 case SfxStyleFamily::Char:
1730 {
1731 const SwCharFormats& rTable = *rDoc.GetCharFormats();
1732 for(auto const& rChar: rTable)
1733 {
1734 rArr.push_back(rChar);
1735 }
1736 }
1737 break;
1738 case SfxStyleFamily::Para:
1739 {
1740 const SwTextFormatColls& rTable = *rDoc.GetTextFormatColls();
1741 for(auto const& rPara : rTable)
1742 {
1743 rArr.push_back(rPara);
1744 }
1745 }
1746 break;
1747 case SfxStyleFamily::Frame:
1748 {
1749 const SwFrameFormats& rTable = *rDoc.GetFrameFormats();
1750 for(auto const& rFrame: rTable)
1751 {
1752 rArr.push_back(rFrame);
1753 }
1754 }
1755 break;
1756
1757 case SfxStyleFamily::Page:
1758 {
1759 for( size_t n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
1760 {
1761 rArr.push_back( &rDoc.GetPageDesc( n ) );
1762 }
1763 }
1764 break;
1765
1766 case SfxStyleFamily::Pseudo:
1767 {
1768 const SwNumRuleTable& rTable = rDoc.GetNumRuleTable();
1769 for(auto const& rPseudo: rTable)
1770 {
1771 rArr.push_back(rPseudo);
1772 }
1773 }
1774 break;
1775 default: break;
1776 }
1777}
1778
1779static bool lcl_Contains(const std::vector<void*>& rArr, const void* p)
1780{
1781 return std::find( rArr.begin(), rArr.end(), p ) != rArr.end();
1782}
1783
1784static void lcl_DeleteInfoStyles( SfxStyleFamily nFamily, std::vector<void*> const & rArr, SwDoc& rDoc )
1785{
1786 size_t n, nCnt;
1787 switch( nFamily )
1788 {
1789 case SfxStyleFamily::Char:
1790 {
1791 std::deque<sal_uInt16> aDelArr;
1792 const SwCharFormats& rTable = *rDoc.GetCharFormats();
1793 for( n = 0, nCnt = rTable.size(); n < nCnt; ++n )
1794 {
1795 if( !lcl_Contains( rArr, rTable[ n ] ))
1796 aDelArr.push_front( n );
1797 }
1798 for(auto const& rDelArr: aDelArr)
1799 rDoc.DelCharFormat( rDelArr );
1800 }
1801 break;
1802
1803 case SfxStyleFamily::Para :
1804 {
1805 std::deque<sal_uInt16> aDelArr;
1806 const SwTextFormatColls& rTable = *rDoc.GetTextFormatColls();
1807 for( n = 0, nCnt = rTable.size(); n < nCnt; ++n )
1808 {
1809 if( !lcl_Contains( rArr, rTable[ n ] ))
1810 aDelArr.push_front( n );
1811 }
1812 for(auto const& rDelArr: aDelArr)
1813 rDoc.DelTextFormatColl( rDelArr );
1814 }
1815 break;
1816
1817 case SfxStyleFamily::Frame:
1818 {
1819 std::deque<SwFrameFormat*> aDelArr;
1820 const SwFrameFormats& rTable = *rDoc.GetFrameFormats();
1821 for( auto const& rFrame: rTable )
1822 {
1823 if( !lcl_Contains( rArr, rFrame ))
1824 aDelArr.push_front( rFrame );
1825 }
1826 for( auto const& rDelArr: aDelArr)
1827 rDoc.DelFrameFormat( rDelArr );
1828 }
1829 break;
1830
1831 case SfxStyleFamily::Page:
1832 {
1833 std::deque<size_t> aDelArr;
1834 for( n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
1835 {
1836 if( !lcl_Contains( rArr, &rDoc.GetPageDesc( n ) ))
1837 aDelArr.push_front( n );
1838 }
1839 for( auto const& rDelArr: aDelArr )
1840 rDoc.DelPageDesc( rDelArr);
1841 }
1842 break;
1843
1844 case SfxStyleFamily::Pseudo:
1845 {
1846 std::deque<SwNumRule*> aDelArr;
1847 const SwNumRuleTable& rTable = rDoc.GetNumRuleTable();
1848 for( auto const& rPseudo: rTable)
1849 {
1850 if( !lcl_Contains( rArr, rPseudo ))
1851 aDelArr.push_front( rPseudo );
1852 }
1853 for( auto const& rDelArr: aDelArr)
1854 rDoc.DelNumRule( rDelArr->GetName() );
1855 }
1856 break;
1857 default: break;
1858 }
1859}
1860
1861// determine the format
1863 FillStyleType const eFType, std::optional<SfxItemSet> *const o_ppFlatSet)
1864{
1865 bool bRet = false;
1866 sal_uInt16 nPoolId = USHRT_MAX;
1867 SwFormat* pFormat = nullptr;
1868
1869 bool bCreate = FillPhysical == eFType;
1870 bool bDeleteInfo = false;
1871 bool bFillOnlyInfo = FillAllInfo == eFType || FillPreview == eFType;
1872 std::vector<void*> aDelArr;
1873 bool const isModified(m_rDoc.getIDocumentState().IsModified());
1874
1875 switch(nFamily)
1876 {
1877 case SfxStyleFamily::Char:
1878 m_pCharFormat = lcl_FindCharFormat(m_rDoc, aName, this, bCreate );
1879 m_bPhysical = nullptr != m_pCharFormat;
1880 if( bFillOnlyInfo && !m_bPhysical )
1881 {
1882 // create style (plus all needed parents) and clean it up
1883 // later - without affecting the undo/redo stack
1885 bDeleteInfo = true;
1886 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
1888 }
1889
1890 pFormat = m_pCharFormat;
1891 m_aLink.clear();
1892 if( !bCreate && !pFormat )
1893 {
1894 if( aName == SwResId(STR_POOLCHR_STANDARD))
1895 nPoolId = 0;
1896 else
1898 }
1899
1900 if (m_pCharFormat)
1901 {
1902 const SwTextFormatColl* pParaFormat = m_pCharFormat->GetLinkedParaFormat();
1903 if (pParaFormat)
1904 {
1905 m_aLink = pParaFormat->GetName();
1906 }
1907 }
1908
1909 bRet = nullptr != m_pCharFormat || USHRT_MAX != nPoolId;
1910
1911 if( bDeleteInfo )
1912 m_pCharFormat = nullptr;
1913 break;
1914
1915 case SfxStyleFamily::Para:
1916 {
1917 m_pColl = lcl_FindParaFormat(m_rDoc, aName, this, bCreate);
1918 m_bPhysical = nullptr != m_pColl;
1919 if( bFillOnlyInfo && !m_bPhysical )
1920 {
1922 bDeleteInfo = true;
1923 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
1925 }
1926
1927 pFormat = m_pColl;
1928 m_aLink.clear();
1929 if( m_pColl )
1930 {
1932 const SwCharFormat* pCharFormat = m_pColl->GetLinkedCharFormat();
1933 if (pCharFormat)
1934 {
1935 m_aLink = pCharFormat->GetName();
1936 }
1937 }
1938 else if( !bCreate )
1940
1941 bRet = nullptr != m_pColl || USHRT_MAX != nPoolId;
1942
1943 if( bDeleteInfo )
1944 m_pColl = nullptr;
1945 }
1946 break;
1947
1948 case SfxStyleFamily::Frame:
1950 m_bPhysical = nullptr != m_pFrameFormat;
1951 if (bFillOnlyInfo && !m_bPhysical)
1952 {
1954 bDeleteInfo = true;
1955 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
1957 }
1958 pFormat = m_pFrameFormat;
1959 if( !bCreate && !pFormat )
1961
1962 bRet = nullptr != m_pFrameFormat || USHRT_MAX != nPoolId;
1963
1964 if( bDeleteInfo )
1965 m_pFrameFormat = nullptr;
1966 break;
1967
1968 case SfxStyleFamily::Page:
1969 m_pDesc = lcl_FindPageDesc(m_rDoc, aName, this, bCreate);
1970 m_bPhysical = nullptr != m_pDesc;
1971 if( bFillOnlyInfo && !m_pDesc )
1972 {
1974 bDeleteInfo = true;
1975 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
1977 }
1978
1979 if( m_pDesc )
1980 {
1981 nPoolId = m_pDesc->GetPoolFormatId();
1983 if (const OUString* pattern = m_pDesc->GetPoolHlpFileId() != UCHAR_MAX
1985 : nullptr)
1986 aHelpFile = *pattern;
1987 else
1988 aHelpFile.clear();
1989 }
1990 else if( !bCreate )
1992 SetMask( (USER_FMT & nPoolId) ? SfxStyleSearchBits::UserDefined : SfxStyleSearchBits::Auto );
1993
1994 bRet = nullptr != m_pDesc || USHRT_MAX != nPoolId;
1995 if( bDeleteInfo )
1996 m_pDesc = nullptr;
1997 break;
1998
1999 case SfxStyleFamily::Pseudo:
2000 m_pNumRule = lcl_FindNumRule(m_rDoc, aName, this, bCreate);
2001 m_bPhysical = nullptr != m_pNumRule;
2002 if( bFillOnlyInfo && !m_pNumRule )
2003 {
2005 bDeleteInfo = true;
2006 ::lcl_SaveStyles( nFamily, aDelArr, m_rDoc );
2008 }
2009
2010 if( m_pNumRule )
2011 {
2012 nPoolId = m_pNumRule->GetPoolFormatId();
2014 if (const OUString* pattern = m_pNumRule->GetPoolHlpFileId() != UCHAR_MAX
2016 : nullptr)
2017 aHelpFile = *pattern;
2018 else
2019 aHelpFile.clear();
2020 }
2021 else if( !bCreate )
2023 SetMask( (USER_FMT & nPoolId) ? SfxStyleSearchBits::UserDefined : SfxStyleSearchBits::Auto );
2024
2025 bRet = nullptr != m_pNumRule || USHRT_MAX != nPoolId;
2026
2027 if( bDeleteInfo )
2028 m_pNumRule = nullptr;
2029 break;
2030
2031 case SfxStyleFamily::Table:
2032 m_pTableFormat = lcl_FindTableStyle(m_rDoc, aName, this, bCreate);
2033 SetMask((m_pTableFormat && m_pTableFormat->IsUserDefined()) ? SfxStyleSearchBits::UserDefined : SfxStyleSearchBits::Auto);
2034 bRet = m_bPhysical = (nullptr != m_pTableFormat);
2035 break;
2036
2037 case SfxStyleFamily::Cell:
2039 bRet = m_bPhysical = (nullptr != m_pBoxFormat);
2040 break;
2041 default:; //prevent warning
2042 }
2043
2044 if( SfxStyleFamily::Char == nFamily ||
2045 SfxStyleFamily::Para == nFamily ||
2046 SfxStyleFamily::Frame == nFamily )
2047 {
2048 if( pFormat )
2049 nPoolId = pFormat->GetPoolFormatId();
2050
2051 SfxStyleSearchBits _nMask = SfxStyleSearchBits::Auto;
2052 if( pFormat == m_rDoc.GetDfltCharFormat() )
2053 _nMask |= SfxStyleSearchBits::ReadOnly;
2054 else if( USER_FMT & nPoolId )
2055 _nMask |= SfxStyleSearchBits::UserDefined;
2056
2057 switch ( COLL_GET_RANGE_BITS & nPoolId )
2058 {
2059 case COLL_TEXT_BITS: _nMask |= SfxStyleSearchBits::SwText; break;
2060 case COLL_DOC_BITS : _nMask |= SfxStyleSearchBits::SwChapter; break;
2061 case COLL_LISTS_BITS: _nMask |= SfxStyleSearchBits::SwList; break;
2062 case COLL_REGISTER_BITS: _nMask |= SfxStyleSearchBits::SwIndex; break;
2063 case COLL_EXTRA_BITS: _nMask |= SfxStyleSearchBits::SwExtra; break;
2064 case COLL_HTML_BITS: _nMask |= SfxStyleSearchBits::SwHtml; break;
2065 }
2066
2067 if( pFormat )
2068 {
2069 OSL_ENSURE( m_bPhysical, "Format not found" );
2070
2071 nHelpId = pFormat->GetPoolHelpId();
2072 if (const OUString* pattern = pFormat->GetPoolHlpFileId() != UCHAR_MAX
2074 : nullptr)
2075 aHelpFile = *pattern;
2076 else
2077 aHelpFile.clear();
2078
2079 if( RES_CONDTXTFMTCOLL == pFormat->Which() )
2080 _nMask |= SfxStyleSearchBits::SwCondColl;
2081
2082 if (FillPreview == eFType)
2083 {
2084 assert(o_ppFlatSet);
2085 lcl_SwFormatToFlatItemSet(pFormat, *o_ppFlatSet);
2086 }
2087 }
2088
2089 SetMask( _nMask );
2090 }
2091 if( bDeleteInfo && bFillOnlyInfo )
2092 {
2095 if (!isModified)
2096 {
2098 }
2099 }
2100 return bRet;
2101}
2102
2103// Create new format in Core
2105{
2106 switch(nFamily)
2107 {
2108 case SfxStyleFamily::Char :
2110 if( !m_pCharFormat )
2113 m_pCharFormat->SetAuto(false);
2114 break;
2115
2116 case SfxStyleFamily::Para :
2118 if( !m_pColl )
2119 {
2121 if( nMask & SfxStyleSearchBits::SwCondColl )
2123 else
2125 }
2126 break;
2127
2128 case SfxStyleFamily::Frame:
2130 if( !m_pFrameFormat )
2132
2133 break;
2134
2135 case SfxStyleFamily::Page :
2137 if( !m_pDesc )
2138 {
2140 }
2141 break;
2142
2143 case SfxStyleFamily::Pseudo:
2145 if( !m_pNumRule )
2146 {
2147 const OUString sTmpNm( aName.isEmpty() ? m_rDoc.GetUniqueNumRuleName() : aName );
2148 SwNumRule* pRule = m_rDoc.GetNumRuleTable()[
2149 m_rDoc.MakeNumRule( sTmpNm, nullptr, false,
2150 // #i89178#
2152 pRule->SetAutoRule( false );
2153 if( aName.isEmpty() )
2154 {
2155 // #i91400#
2157 }
2158 m_pNumRule = pRule;
2159 }
2160 break;
2161
2162 case SfxStyleFamily::Table:
2163 if (aName.isEmpty())
2164 return;
2166 if (!m_pTableFormat)
2167 {
2170 SAL_WARN_IF(!m_pTableFormat, "sw.ui", "Recently added auto format not found");
2171 }
2172 break;
2173 default:; //prevent warning
2174 }
2175 m_bPhysical = true;
2177}
2178
2180{
2181 if(!m_bPhysical)
2183 return m_pCharFormat;
2184}
2185
2187{
2188 if(!m_bPhysical)
2190 return m_pColl;
2191}
2192
2194{
2195 if(!m_bPhysical)
2197 return m_pDesc;
2198}
2199
2201{
2202 if(!m_bPhysical)
2204 return m_pNumRule;
2205}
2206
2207
2209{
2210 OSL_ENSURE(m_pNumRule, "Where is the NumRule");
2211 m_rDoc.ChgNumRuleFormats( rRule );
2212}
2213
2215{
2216 if(!m_bPhysical)
2218 assert(m_pTableFormat && "SwDocStyleSheet table style, SwTableAutoFormat not found");
2219 return m_pTableFormat;
2220}
2221
2222// re-generate Name AND Family from String
2223// First() and Next() (see below) insert an identification letter at Pos.1
2224
2225void SwDocStyleSheet::PresetNameAndFamily(SfxStyleFamily eFamily, const OUString& rName)
2226{
2227 this->nFamily = eFamily;
2228 this->aName = rName;
2229}
2230
2231// Is the format physically present yet
2233{
2234 m_bPhysical = bPhys;
2235
2236 if(!bPhys)
2237 {
2238 m_pCharFormat = nullptr;
2239 m_pColl = nullptr;
2240 m_pFrameFormat = nullptr;
2241 m_pDesc = nullptr;
2242 }
2243}
2244
2246{
2247 if(!m_bPhysical)
2249 return m_pFrameFormat;
2250}
2251
2253{
2254 if( !m_bPhysical )
2255 {
2256 SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
2257 pThis->FillStyleSheet( FillOnlyName );
2258 }
2259
2260 if( !m_bPhysical )
2261 return false;
2262
2263 const sw::BroadcastingModify* pMod;
2264 switch( nFamily )
2265 {
2266 case SfxStyleFamily::Char : pMod = m_pCharFormat; break;
2267 case SfxStyleFamily::Para : pMod = m_pColl; break;
2268 case SfxStyleFamily::Frame: pMod = m_pFrameFormat; break;
2269 case SfxStyleFamily::Page : pMod = m_pDesc; break;
2270
2271 case SfxStyleFamily::Pseudo:
2272 return m_pNumRule && m_rDoc.IsUsed(*m_pNumRule);
2273
2274 case SfxStyleFamily::Table:
2276
2277 default:
2278 OSL_ENSURE(false, "unknown style family");
2279 return false;
2280 }
2281 return m_rDoc.IsUsed( *pMod );
2282}
2283
2285{
2286 return m_pNumRule ? m_pNumRule->MakeParagraphStyleListString() : OUString();
2287}
2288
2290{
2291 sal_uInt16 nId = 0;
2292 sal_uInt16 nPoolId = 0;
2293 unsigned char nFileId = UCHAR_MAX;
2294
2295 rFile = "swrhlppi.hlp";
2296
2297 const SwFormat* pTmpFormat = nullptr;
2298 switch( nFamily )
2299 {
2300 case SfxStyleFamily::Char :
2301 if( !m_pCharFormat &&
2302 nullptr == (m_pCharFormat = lcl_FindCharFormat( m_rDoc, aName, nullptr, false )) )
2303 {
2305 return USHRT_MAX == nId ? 0 : nId;
2306 }
2307 pTmpFormat = m_pCharFormat;
2308 break;
2309
2310 case SfxStyleFamily::Para:
2311 if( !m_pColl &&
2312 nullptr == ( m_pColl = lcl_FindParaFormat( m_rDoc, aName, nullptr, false )) )
2313 {
2315 return USHRT_MAX == nId ? 0 : nId;
2316 }
2317 pTmpFormat = m_pColl;
2318 break;
2319
2320 case SfxStyleFamily::Frame:
2321 if( !m_pFrameFormat &&
2322 nullptr == ( m_pFrameFormat = lcl_FindFrameFormat( m_rDoc, aName, nullptr, false ) ) )
2323 {
2325 return USHRT_MAX == nId ? 0 : nId;
2326 }
2327 pTmpFormat = m_pFrameFormat;
2328 break;
2329
2330 case SfxStyleFamily::Page:
2331 if( !m_pDesc &&
2332 nullptr == ( m_pDesc = lcl_FindPageDesc( m_rDoc, aName, nullptr, false ) ) )
2333 {
2335 return USHRT_MAX == nId ? 0 : nId;
2336 }
2337
2339 nFileId = m_pDesc->GetPoolHlpFileId();
2340 nPoolId = m_pDesc->GetPoolFormatId();
2341 break;
2342
2343 case SfxStyleFamily::Pseudo:
2344 if( !m_pNumRule &&
2345 nullptr == ( m_pNumRule = lcl_FindNumRule( m_rDoc, aName, nullptr, false ) ) )
2346 {
2348 return USHRT_MAX == nId ? 0 : nId;
2349 }
2350
2352 nFileId = m_pNumRule->GetPoolHlpFileId();
2353 nPoolId = m_pNumRule->GetPoolFormatId();
2354 break;
2355
2356 default:
2357 OSL_ENSURE(false, "unknown style family");
2358 return 0;
2359 }
2360
2361 if( pTmpFormat )
2362 {
2363 nId = pTmpFormat->GetPoolHelpId();
2364 nFileId = pTmpFormat->GetPoolHlpFileId();
2365 nPoolId = pTmpFormat->GetPoolFormatId();
2366 }
2367
2368 if( UCHAR_MAX != nFileId )
2369 {
2370 const OUString *pTemplate = m_rDoc.GetDocPattern( nFileId );
2371 if( pTemplate )
2372 {
2373 rFile = *pTemplate;
2374 }
2375 }
2376 else if( !IsPoolUserFormat( nPoolId ) )
2377 {
2378 nId = nPoolId;
2379 }
2380
2381 // because SFX acts like that, with HelpId:
2382 if( USHRT_MAX == nId )
2383 nId = 0; // don't show Help accordingly
2384
2385 return nId;
2386}
2387
2388void SwDocStyleSheet::SetHelpId( const OUString& r, sal_uLong nId )
2389{
2390 sal_uInt8 nFileId = static_cast< sal_uInt8 >(m_rDoc.SetDocPattern( r ));
2391 sal_uInt16 nHId = static_cast< sal_uInt16 >(nId);
2392
2393 SwFormat* pTmpFormat = nullptr;
2394 switch( nFamily )
2395 {
2396 case SfxStyleFamily::Char : pTmpFormat = m_pCharFormat; break;
2397 case SfxStyleFamily::Para : pTmpFormat = m_pColl; break;
2398 case SfxStyleFamily::Frame: pTmpFormat = m_pFrameFormat; break;
2399 case SfxStyleFamily::Page :
2400 const_cast<SwPageDesc*>(m_pDesc)->SetPoolHelpId( nHId );
2401 const_cast<SwPageDesc*>(m_pDesc)->SetPoolHlpFileId( nFileId );
2402 break;
2403
2404 case SfxStyleFamily::Pseudo:
2405 const_cast<SwNumRule*>(m_pNumRule)->SetPoolHelpId( nHId );
2406 const_cast<SwNumRule*>(m_pNumRule)->SetPoolHlpFileId( nFileId );
2407 break;
2408
2409 default:
2410 OSL_ENSURE(false, "unknown style family");
2411 return ;
2412 }
2413 if( pTmpFormat )
2414 {
2415 pTmpFormat->SetPoolHelpId( nHId );
2416 pTmpFormat->SetPoolHlpFileId( nFileId );
2417 }
2418}
2419
2420// methods for DocStyleSheetPool
2422 : SfxStyleSheetBasePool(rDocument.GetAttrPool())
2423 , mxStyleSheet(new SwDocStyleSheet(rDocument, *this))
2424 , m_rDoc(rDocument)
2425{
2426 m_bOrganizer = bOrg;
2427}
2428
2430{
2431}
2432
2434 SfxStyleFamily eFam,
2435 SfxStyleSearchBits _nMask)
2436{
2437 mxStyleSheet->PresetName(rName);
2438 mxStyleSheet->PresetParent(OUString());
2439 mxStyleSheet->PresetFollow(OUString());
2440 mxStyleSheet->SetMask(_nMask) ;
2441 mxStyleSheet->SetFamily(eFam);
2442 mxStyleSheet->SetPhysical(true);
2443 mxStyleSheet->Create();
2444
2445 return *mxStyleSheet;
2446}
2447
2449{
2450 OSL_ENSURE(false , "Create in SW-Stylesheet-Pool not possible" );
2451 return nullptr;
2452}
2453
2456{
2457 OSL_ENSURE( false, "Create in SW-Stylesheet-Pool not possible" );
2458 return nullptr;
2459}
2460
2461std::unique_ptr<SfxStyleSheetIterator> SwDocStyleSheetPool::CreateIterator( SfxStyleFamily eFam, SfxStyleSearchBits _nMask )
2462{
2463 return std::make_unique<SwStyleSheetIterator>(*this, eFam, _nMask);
2464}
2465
2467{
2468 mxStyleSheet.clear();
2469}
2470
2472{
2473 if( !pStyle )
2474 return;
2475
2476 bool bBroadcast = true;
2477 SwImplShellAction aTmpSh( m_rDoc );
2478 const OUString sName = pStyle->GetName();
2479 switch( pStyle->GetFamily() )
2480 {
2481 case SfxStyleFamily::Char:
2482 {
2483 SwCharFormat* pFormat = lcl_FindCharFormat(m_rDoc, sName, nullptr, false );
2484 if(pFormat)
2485 m_rDoc.DelCharFormat(pFormat);
2486 }
2487 break;
2488 case SfxStyleFamily::Para:
2489 {
2490 SwTextFormatColl* pColl = lcl_FindParaFormat(m_rDoc, sName, nullptr, false );
2491 if(pColl)
2493 }
2494 break;
2495 case SfxStyleFamily::Frame:
2496 {
2497 SwFrameFormat* pFormat = lcl_FindFrameFormat(m_rDoc, sName, nullptr, false );
2498 if(pFormat)
2499 m_rDoc.DelFrameFormat(pFormat);
2500 }
2501 break;
2502 case SfxStyleFamily::Page :
2503 {
2505 }
2506 break;
2507
2508 case SfxStyleFamily::Pseudo:
2509 {
2510 if( !m_rDoc.DelNumRule( sName ) )
2511 // Only send Broadcast, when something was deleted
2512 bBroadcast = false;
2513 }
2514 break;
2515
2516 case SfxStyleFamily::Table:
2517 {
2519 }
2520 break;
2521
2522 default:
2523 OSL_ENSURE(false, "unknown style family");
2524 bBroadcast = false;
2525 }
2526
2527 if( bBroadcast )
2528 Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetErased, *pStyle ) );
2529}
2530
2532 const OUString &rStyle, const OUString &rParent )
2533{
2534 SwFormat* pFormat = nullptr, *pParent = nullptr;
2535 switch( eFam )
2536 {
2537 case SfxStyleFamily::Char :
2538 if( nullptr != ( pFormat = lcl_FindCharFormat( m_rDoc, rStyle ) ) && !rParent.isEmpty() )
2539 pParent = lcl_FindCharFormat(m_rDoc, rParent );
2540 break;
2541
2542 case SfxStyleFamily::Para :
2543 if( nullptr != ( pFormat = lcl_FindParaFormat( m_rDoc, rStyle ) ) && !rParent.isEmpty() )
2544 pParent = lcl_FindParaFormat( m_rDoc, rParent );
2545 break;
2546
2547 case SfxStyleFamily::Frame:
2548 if( nullptr != ( pFormat = lcl_FindFrameFormat( m_rDoc, rStyle ) ) && !rParent.isEmpty() )
2549 pParent = lcl_FindFrameFormat( m_rDoc, rParent );
2550 break;
2551
2552 case SfxStyleFamily::Page:
2553 case SfxStyleFamily::Pseudo:
2554 break;
2555
2556 default:
2557 OSL_ENSURE(false, "unknown style family");
2558 }
2559
2560 bool bRet = false;
2561 if( pFormat && pFormat->DerivedFrom() &&
2562 pFormat->DerivedFrom()->GetName() != rParent )
2563 {
2564 {
2565 SwImplShellAction aTmpSh( m_rDoc );
2566 bRet = pFormat->SetDerivedFrom( pParent );
2567 }
2568
2569 if( bRet )
2570 {
2571 // only for Broadcasting
2572 mxStyleSheet->PresetName( rStyle );
2573 mxStyleSheet->PresetParent( rParent );
2574 if( SfxStyleFamily::Para == eFam )
2575 mxStyleSheet->PresetFollow( static_cast<SwTextFormatColl*>(pFormat)->
2576 GetNextTextFormatColl().GetName() );
2577 else
2578 mxStyleSheet->PresetFollow( OUString() );
2579
2580 Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified, *mxStyleSheet ) );
2581 }
2582 }
2583
2584 return bRet;
2585}
2586
2588 SfxStyleFamily eFam, SfxStyleSearchBits n) const
2589{
2590 SfxStyleSearchBits nSMask = n;
2591 if( SfxStyleFamily::Para == eFam && m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) )
2592 {
2593 // then only HTML-Templates are of interest
2594 if( SfxStyleSearchBits::All == nSMask )
2595 nSMask = SfxStyleSearchBits::SwHtml | SfxStyleSearchBits::UserDefined | SfxStyleSearchBits::Used;
2596 else
2597 nSMask &= SfxStyleSearchBits::Used | SfxStyleSearchBits::UserDefined |
2598 SfxStyleSearchBits::SwCondColl | SfxStyleSearchBits::SwHtml;
2599 if( nSMask == SfxStyleSearchBits::Auto )
2600 nSMask = SfxStyleSearchBits::SwHtml;
2601 }
2602
2603 const bool bSearchUsed = ( n != SfxStyleSearchBits::All && n & SfxStyleSearchBits::Used );
2604 const sw::BroadcastingModify* pMod = nullptr;
2605
2606 mxStyleSheet->SetPhysical( false );
2607 mxStyleSheet->PresetName( rName );
2608 mxStyleSheet->SetFamily( eFam );
2609 bool bFnd = mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
2610
2611 if( mxStyleSheet->IsPhysical() )
2612 {
2613 switch( eFam )
2614 {
2615 case SfxStyleFamily::Char:
2616 pMod = mxStyleSheet->GetCharFormat();
2617 break;
2618
2619 case SfxStyleFamily::Para:
2620 pMod = mxStyleSheet->GetCollection();
2621 break;
2622
2623 case SfxStyleFamily::Frame:
2624 pMod = mxStyleSheet->GetFrameFormat();
2625 break;
2626
2627 case SfxStyleFamily::Page:
2628 pMod = mxStyleSheet->GetPageDesc();
2629 break;
2630
2631 case SfxStyleFamily::Pseudo:
2632 {
2633 const SwNumRule* pRule = mxStyleSheet->GetNumRule();
2634 if( pRule &&
2635 !bSearchUsed &&
2636 (( nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
2637 ? !(pRule->GetPoolFormatId() & USER_FMT)
2638 // searched for used and found none
2639 : bSearchUsed ))
2640 bFnd = false;
2641 }
2642 break;
2643
2644 case SfxStyleFamily::Table:
2645 case SfxStyleFamily::Cell:
2646 break;
2647 default:
2648 OSL_ENSURE(false, "unknown style family");
2649 }
2650 }
2651
2652 // then evaluate the mask:
2653 if( pMod && !bSearchUsed )
2654 {
2655 const sal_uInt16 nId = SfxStyleFamily::Page == eFam
2656 ? static_cast<const SwPageDesc*>(pMod)->GetPoolFormatId()
2657 : static_cast<const SwFormat*>(pMod)->GetPoolFormatId();
2658
2659 if( ( nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
2660 && !(nId & USER_FMT) )
2661 // searched for used and found none
2662 bFnd = false;
2663 }
2664 return bFnd ? mxStyleSheet.get() : nullptr;
2665}
2666
2669 : SfxStyleSheetIterator(&rBase, eFam, n)
2670 , mxIterSheet(new SwDocStyleSheet(rBase.GetDoc(), rBase))
2671 , mxStyleSheet(new SwDocStyleSheet(rBase.GetDoc(), rBase))
2672{
2673 m_bFirstCalled = false;
2674 m_nLastPos = 0;
2675 StartListening(rBase);
2676}
2677
2679{
2680 EndListening( *mxIterSheet->GetPool() );
2681}
2682
2684{
2685 // let the list fill correctly!!
2686 if( !m_bFirstCalled )
2687 First();
2688 return m_aLst.size();
2689}
2690
2692{
2693 // found
2694 if( !m_bFirstCalled )
2695 First();
2696 auto const & rEntry = m_aLst[ nIdx ];
2697 mxStyleSheet->PresetNameAndFamily( rEntry.first, rEntry.second );
2698 mxStyleSheet->SetPhysical( false );
2700
2701 return mxStyleSheet.get();
2702}
2703
2705{
2706 // Delete old list
2707 m_bFirstCalled = true;
2708 m_nLastPos = 0;
2709 m_aLst.clear();
2710
2711 // Delete current
2712 mxIterSheet->Reset();
2713
2714 const SwDoc& rDoc = static_cast<const SwDocStyleSheetPool*>(pBasePool)->GetDoc();
2715 const SfxStyleSearchBits nSrchMask = nMask;
2716 const bool bIsSearchUsed = SearchUsed();
2717
2718 bool bSearchHidden( nMask & SfxStyleSearchBits::Hidden );
2719 bool bOnlyHidden = nMask == SfxStyleSearchBits::Hidden;
2720
2721 const bool bOrganizer = static_cast<const SwDocStyleSheetPool*>(pBasePool)->IsOrganizerMode();
2722 bool bAll = ( nSrchMask & SfxStyleSearchBits::AllVisible ) == SfxStyleSearchBits::AllVisible;
2723
2724 if( nSearchFamily == SfxStyleFamily::Char
2725 || nSearchFamily == SfxStyleFamily::All )
2726 {
2727 const size_t nArrLen = rDoc.GetCharFormats()->size();
2728 for( size_t i = 0; i < nArrLen; i++ )
2729 {
2730 SwCharFormat* pFormat = (*rDoc.GetCharFormats())[ i ];
2731
2732 const bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(*pFormat));
2733 if( ( !bSearchHidden && pFormat->IsHidden() && !bUsed ) || ( pFormat->IsDefault() && pFormat != rDoc.GetDfltCharFormat() ) )
2734 continue;
2735
2736 if ( nSrchMask == SfxStyleSearchBits::Hidden && !pFormat->IsHidden( ) )
2737 continue;
2738
2739 if( !bUsed )
2740 {
2741 // Standard is no User template
2742 const sal_uInt16 nId = rDoc.GetDfltCharFormat() == pFormat ?
2743 sal_uInt16( RES_POOLCHR_INET_NORMAL ):
2744 pFormat->GetPoolFormatId();
2745 if( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
2746 ? !(nId & USER_FMT)
2747 // searched for used and found none
2748 : bIsSearchUsed )
2749 {
2750 continue;
2751 }
2752
2759 continue;
2760 }
2761
2762 m_aLst.Append( SfxStyleFamily::Char, pFormat == rDoc.GetDfltCharFormat()
2763 ? SwResId(STR_POOLCHR_STANDARD)
2764 : pFormat->GetName() );
2765 }
2766
2767 // PoolFormat
2768 if( bAll )
2769 {
2772 bIsSearchUsed, bSearchHidden, bOnlyHidden,
2773 SwGetPoolIdFromName::ChrFmt, SfxStyleFamily::Char);
2774 else
2775 {
2784 }
2786 bIsSearchUsed, bSearchHidden, bOnlyHidden,
2787 SwGetPoolIdFromName::ChrFmt, SfxStyleFamily::Char);
2788 }
2789 }
2790
2791 if( nSearchFamily == SfxStyleFamily::Para ||
2792 nSearchFamily == SfxStyleFamily::All )
2793 {
2794 SfxStyleSearchBits nSMask = nSrchMask;
2796 {
2797 // then only HTML-Template are of interest
2798 if( SfxStyleSearchBits::AllVisible == ( nSMask & SfxStyleSearchBits::AllVisible ) )
2799 nSMask = SfxStyleSearchBits::SwHtml | SfxStyleSearchBits::UserDefined |
2800 SfxStyleSearchBits::Used;
2801 else
2802 nSMask &= SfxStyleSearchBits::Used | SfxStyleSearchBits::UserDefined |
2803 SfxStyleSearchBits::SwCondColl | SfxStyleSearchBits::SwHtml;
2804 if( nSMask == SfxStyleSearchBits::Auto )
2805 nSMask = SfxStyleSearchBits::SwHtml;
2806 }
2807
2808 const size_t nArrLen = rDoc.GetTextFormatColls()->size();
2809 for( size_t i = 0; i < nArrLen; i++ )
2810 {
2811 SwTextFormatColl* pColl = (*rDoc.GetTextFormatColls())[ i ];
2812
2813 const bool bUsed = bOrganizer || rDoc.IsUsed(*pColl);
2814 if ( ( !bSearchHidden && pColl->IsHidden( ) && !bUsed ) || pColl->IsDefault() )
2815 continue;
2816
2817 if ( nSMask == SfxStyleSearchBits::Hidden && !pColl->IsHidden( ) )
2818 continue;
2819
2820 if( !(bIsSearchUsed && bUsed ))
2821 {
2822 const sal_uInt16 nId = pColl->GetPoolFormatId();
2823 auto tmpMask = nSMask & ~SfxStyleSearchBits::Used;
2824 if (tmpMask == SfxStyleSearchBits::UserDefined)
2825 {
2826 if(!IsPoolUserFormat(nId)) continue;
2827 }
2828 else if (tmpMask == SfxStyleSearchBits::SwText)
2829 {
2830 if((nId & COLL_GET_RANGE_BITS) != COLL_TEXT_BITS) continue;
2831 }
2832 else if (tmpMask == SfxStyleSearchBits::SwChapter)
2833 {
2834 if((nId & COLL_GET_RANGE_BITS) != COLL_DOC_BITS) continue;
2835 }
2836 else if (tmpMask == SfxStyleSearchBits::SwList)
2837 {
2838 if((nId & COLL_GET_RANGE_BITS) != COLL_LISTS_BITS) continue;
2839 }
2840 else if (tmpMask == SfxStyleSearchBits::SwIndex)
2841 {
2842 if((nId & COLL_GET_RANGE_BITS) != COLL_REGISTER_BITS) continue;
2843 }
2844 else if (tmpMask == SfxStyleSearchBits::SwExtra)
2845 {
2846 if((nId & COLL_GET_RANGE_BITS) != COLL_EXTRA_BITS) continue;
2847 }
2848 else if (tmpMask == (SfxStyleSearchBits::SwHtml | SfxStyleSearchBits::UserDefined)
2849 || tmpMask == SfxStyleSearchBits::SwHtml)
2850 {
2851 if((tmpMask & SfxStyleSearchBits::UserDefined) && IsPoolUserFormat(nId))
2852 ; // do nothing
2853 else if( (nId & COLL_GET_RANGE_BITS) != COLL_HTML_BITS)
2854 {
2855 // but some we also want to see in this section
2856 bool bContinue = true;
2857 switch( nId )
2858 {
2859 case RES_POOLCOLL_SEND_ADDRESS: // --> ADDRESS
2860 case RES_POOLCOLL_TABLE_HDLN: // --> TH
2861 case RES_POOLCOLL_TABLE: // --> TD
2862 case RES_POOLCOLL_TEXT: // --> P
2863 case RES_POOLCOLL_HEADLINE_BASE:// --> H
2864 case RES_POOLCOLL_HEADLINE1: // --> H1
2865 case RES_POOLCOLL_HEADLINE2: // --> H2
2866 case RES_POOLCOLL_HEADLINE3: // --> H3
2867 case RES_POOLCOLL_HEADLINE4: // --> H4
2868 case RES_POOLCOLL_HEADLINE5: // --> H5
2869 case RES_POOLCOLL_HEADLINE6: // --> H6
2870 case RES_POOLCOLL_STANDARD: // --> P
2873 bContinue = false;
2874 break;
2875 }
2876 if( bContinue )
2877 continue;
2878 }
2879 }
2880 else if (tmpMask == SfxStyleSearchBits::SwCondColl)
2881 {
2882 if( RES_CONDTXTFMTCOLL != pColl->Which() ) continue;
2883 }
2884 else
2885 {
2886 // searched for used and found none
2887 if( bIsSearchUsed )
2888 continue;
2889 }
2890 }
2891 m_aLst.Append( SfxStyleFamily::Para, pColl->GetName() );
2892 }
2893
2894 bAll = ( nSMask & SfxStyleSearchBits::AllVisible ) == SfxStyleSearchBits::AllVisible;
2895 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwText )
2897 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para );
2898 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwChapter )
2900 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2901 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwList )
2903 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2904 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwIndex )
2906 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2907 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwExtra )
2909 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2910 if ( bAll || (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwCondColl )
2911 {
2912 if( !bIsSearchUsed ||
2914 m_aLst.Append( SfxStyleFamily::Para, SwStyleNameMapper::GetTextUINameArray()[
2916 }
2917 if ( bAll ||
2918 (nSMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::SwHtml ||
2919 (nSMask & ~SfxStyleSearchBits::Used) ==
2920 (SfxStyleSearchBits::SwHtml | SfxStyleSearchBits::UserDefined) )
2921 {
2923 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, SfxStyleFamily::Para ) ;
2924 if( !bAll )
2925 {
2926 // then also the ones, that we are mapping:
2927 static sal_uInt16 aPoolIds[] = {
2928 RES_POOLCOLL_SEND_ADDRESS, // --> ADDRESS
2929 RES_POOLCOLL_TABLE_HDLN, // --> TH
2930 RES_POOLCOLL_TABLE, // --> TD
2931 RES_POOLCOLL_STANDARD, // --> P
2932 RES_POOLCOLL_TEXT, // --> P
2934 RES_POOLCOLL_HEADLINE1, // --> H1
2935 RES_POOLCOLL_HEADLINE2, // --> H2
2936 RES_POOLCOLL_HEADLINE3, // --> H3
2937 RES_POOLCOLL_HEADLINE4, // --> H4
2938 RES_POOLCOLL_HEADLINE5, // --> H5
2939 RES_POOLCOLL_HEADLINE6, // --> H6
2942 0
2943 };
2944
2945 sal_uInt16* pPoolIds = aPoolIds;
2946 OUString s;
2947 while( *pPoolIds )
2948 {
2949 if( !bIsSearchUsed || rDoc.getIDocumentStylePoolAccess().IsPoolTextCollUsed( *pPoolIds ) )
2950 {
2951 s = SwStyleNameMapper::GetUIName( *pPoolIds, s );
2952 m_aLst.Append( SfxStyleFamily::Para, s);
2953 }
2954 ++pPoolIds;
2955 }
2956 }
2957 }
2958 }
2959
2960 if( nSearchFamily == SfxStyleFamily::Frame ||
2961 nSearchFamily == SfxStyleFamily::All )
2962 {
2963 const size_t nArrLen = rDoc.GetFrameFormats()->size();
2964 for( size_t i = 0; i < nArrLen; i++ )
2965 {
2966 const SwFrameFormat* pFormat = (*rDoc.GetFrameFormats())[ i ];
2967
2968 bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(*pFormat));
2969 if( ( !bSearchHidden && pFormat->IsHidden( ) && !bUsed ) || pFormat->IsDefault() || pFormat->IsAuto() )
2970 continue;
2971
2972 if ( nSrchMask == SfxStyleSearchBits::Hidden && !pFormat->IsHidden( ) )
2973 continue;
2974
2975 const sal_uInt16 nId = pFormat->GetPoolFormatId();
2976 if( !bUsed )
2977 {
2978 if( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
2979 ? !(nId & USER_FMT)
2980 // searched for used and found none
2981 : bIsSearchUsed )
2982 {
2983 continue;
2984 }
2985 }
2986
2987 m_aLst.Append( SfxStyleFamily::Frame, pFormat->GetName() );
2988 }
2989
2990 // PoolFormat
2991 if ( bAll )
2993 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::FrmFmt, SfxStyleFamily::Frame);
2994 }
2995
2996 if( nSearchFamily == SfxStyleFamily::Page ||
2997 nSearchFamily == SfxStyleFamily::All )
2998 {
2999 const size_t nCount = rDoc.GetPageDescCnt();
3000 for(size_t i = 0; i < nCount; ++i)
3001 {
3002 const SwPageDesc& rDesc = rDoc.GetPageDesc(i);
3003 const sal_uInt16 nId = rDesc.GetPoolFormatId();
3004 bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rDesc));
3005 if( !bUsed )
3006 {
3007 if ( ( !bSearchHidden && rDesc.IsHidden() ) ||
3008 ( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
3009 ? !(nId & USER_FMT)
3010 // searched for used and found none
3011 : bIsSearchUsed ) )
3012 continue;
3013 }
3014
3015 if ( nSrchMask == SfxStyleSearchBits::Hidden && !rDesc.IsHidden( ) )
3016 continue;
3017
3018 m_aLst.Append( SfxStyleFamily::Page, rDesc.GetName() );
3019 }
3020 if ( bAll )
3022 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::PageDesc, SfxStyleFamily::Page);
3023 }
3024
3025 if( nSearchFamily == SfxStyleFamily::Pseudo ||
3026 nSearchFamily == SfxStyleFamily::All )
3027 {
3028 const SwNumRuleTable& rNumTable = rDoc.GetNumRuleTable();
3029 for(auto const& rNum: rNumTable)
3030 {
3031 const SwNumRule& rRule = *rNum;
3032 if( !rRule.IsAutoRule() )
3033 {
3034 if ( nSrchMask == SfxStyleSearchBits::Hidden && !rRule.IsHidden( ) )
3035 continue;
3036
3037 bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(rRule));
3038 if( !bUsed )
3039 {
3040 if( ( !bSearchHidden && rRule.IsHidden() ) ||
3041 ( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
3042 ? !(rRule.GetPoolFormatId() & USER_FMT)
3043 // searched for used and found none
3044 : bIsSearchUsed ) )
3045 continue;
3046 }
3047
3048 m_aLst.Append( SfxStyleFamily::Pseudo, rRule.GetName() );
3049 }
3050 }
3051 if ( bAll )
3053 bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::NumRule, SfxStyleFamily::Pseudo);
3054 }
3055
3056 if( nSearchFamily == SfxStyleFamily::Table ||
3057 nSearchFamily == SfxStyleFamily::All )
3058 {
3059 const SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
3060 for(size_t i = 0; i < rTableStyles.size(); ++i)
3061 {
3062 const SwTableAutoFormat& rTableStyle = rTableStyles[i];
3063
3064 bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(rTableStyle));
3065 if(!bUsed)
3066 {
3067 if(nSrchMask == SfxStyleSearchBits::Hidden && !rTableStyle.IsHidden())
3068 continue;
3069
3070 if( (!bSearchHidden && rTableStyle.IsHidden() ) ||
3071 ( (nSrchMask & ~SfxStyleSearchBits::Used) == SfxStyleSearchBits::UserDefined
3072 ? !rTableStyle.IsUserDefined()
3073 // searched for used and found none
3074 : bIsSearchUsed ) )
3075 continue;
3076 }
3077
3078 m_aLst.Append( SfxStyleFamily::Table, rTableStyle.GetName() );
3079 }
3080 }
3081
3082 if( nSearchFamily == SfxStyleFamily::Cell ||
3083 nSearchFamily == SfxStyleFamily::All )
3084 {
3085 const auto& aTableTemplateMap = SwTableAutoFormat::GetTableTemplateMap();
3086 if (rDoc.HasTableStyles())
3087 {
3088 const SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
3089 for(size_t i = 0; i < rTableStyles.size(); ++i)
3090 {
3091 const SwTableAutoFormat& rTableStyle = rTableStyles[i];
3092 for(size_t nBoxFormat = 0; nBoxFormat < aTableTemplateMap.size(); ++nBoxFormat)
3093 {
3094 const sal_uInt32 nBoxIndex = aTableTemplateMap[nBoxFormat];
3095 const SwBoxAutoFormat& rBoxFormat = rTableStyle.GetBoxFormat(nBoxIndex);
3096 OUString sBoxFormatName;
3098 sBoxFormatName += rTableStyle.GetTableTemplateCellSubName(rBoxFormat);
3099 m_aLst.Append( SfxStyleFamily::Cell, sBoxFormatName );
3100 }
3101 }
3102 }
3103 const SwCellStyleTable& rCellStyles = rDoc.GetCellStyles();
3104 for(size_t i = 0; i < rCellStyles.size(); ++i)
3105 m_aLst.Append( SfxStyleFamily::Cell, rCellStyles[i].GetName() );
3106 }
3107
3108 if(!m_aLst.empty())
3109 {
3111 return Next();
3112 }
3113 return nullptr;
3114}
3115
3117{
3118 assert(m_bFirstCalled);
3119 ++m_nLastPos;
3120 if(m_nLastPos < m_aLst.size())
3121 {
3122 auto const & rEntry = m_aLst[m_nLastPos];
3123 mxIterSheet->PresetNameAndFamily(rEntry.first, rEntry.second);
3124 mxIterSheet->SetPhysical( false );
3125 mxIterSheet->SetMask( nMask );
3126 if(mxIterSheet->pSet)
3127 {
3128 mxIterSheet->pSet->ClearItem();
3129 mxIterSheet->pSet= nullptr;
3130 }
3131 return mxIterSheet.get();
3132 }
3133 return nullptr;
3134}
3135
3137{
3138 // searching
3139 if( !m_bFirstCalled )
3140 First();
3141
3143 if( SAL_MAX_UINT32 != m_nLastPos )
3144 {
3145 // found
3146 auto const & rEntry = m_aLst[m_nLastPos];
3147 mxStyleSheet->PresetNameAndFamily(rEntry.first, rEntry.second);
3148 // new name is set, so determine its Data
3150 if( !mxStyleSheet->IsPhysical() )
3151 mxStyleSheet->SetPhysical( false );
3152
3153 return mxStyleSheet.get();
3154 }
3155 return nullptr;
3156}
3157
3158void SwStyleSheetIterator::AppendStyleList(const std::vector<OUString>& rList,
3159 bool bTestUsed, bool bTestHidden, bool bOnlyHidden,
3160 SwGetPoolIdFromName nSection, SfxStyleFamily eFamily )
3161{
3162 const SwDoc& rDoc = static_cast<const SwDocStyleSheetPool*>(pBasePool)->GetDoc();
3163 bool bUsed = false;
3164 for (const auto & i : rList)
3165 {
3166 bool bHidden = false;
3167 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(i, nSection);
3168 switch ( nSection )
3169 {
3171 {
3173 SwFormat* pFormat = rDoc.FindTextFormatCollByName( i );
3174 bHidden = pFormat && pFormat->IsHidden( );
3175 }
3176 break;
3178 {
3180 SwFormat* pFormat = rDoc.FindCharFormatByName( i );
3181 bHidden = pFormat && pFormat->IsHidden( );
3182 }
3183 break;
3185 {
3187 SwFormat* pFormat = rDoc.FindFrameFormatByName( i );
3188 bHidden = pFormat && pFormat->IsHidden( );
3189 }
3190 break;
3192 {
3194 SwPageDesc* pPgDesc = rDoc.FindPageDesc(i);
3195 bHidden = pPgDesc && pPgDesc->IsHidden( );
3196 }
3197 break;
3199 {
3200 SwNumRule* pRule = rDoc.FindNumRulePtr( i );
3201 bUsed = pRule && rDoc.IsUsed(*pRule);
3202 bHidden = pRule && pRule->IsHidden( );
3203 }
3204 break;
3205 default:
3206 OSL_ENSURE( false, "unknown PoolFormat-Id" );
3207 }
3208
3209 bool bMatchHidden = ( bTestHidden && ( bHidden || !bOnlyHidden ) ) || ( !bTestHidden && ( !bHidden || bUsed ) );
3210 if ( ( !bTestUsed && bMatchHidden ) || ( bTestUsed && bUsed ) )
3211 m_aLst.Append( eFamily, i );
3212 }
3213}
3214
3216{
3218 dynamic_cast<SwStyleSheetIterator&>(*pIter).InvalidateIterator();
3219}
3220
3222{
3223 // potentially we could send an SfxHint to Notify but currently it's
3224 // iterating over the vector anyway so would still be slow - why does
3225 // this iterator not use a map?
3226 m_bFirstCalled = false;
3227 m_nLastPos = 0;
3228 m_aLst.clear();
3229}
3230
3232{
3233 // search and remove from View-List!!
3234 const SfxStyleSheetHint* pStyleSheetHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint);
3235 if( pStyleSheetHint &&
3236 SfxHintId::StyleSheetErased == pStyleSheetHint->GetId() )
3237 {
3238 SfxStyleSheetBase* pStyle = pStyleSheetHint->GetStyleSheet();
3239
3240 if (pStyle)
3241 m_aLst.RemoveName(pStyle->GetFamily(), pStyle->GetName());
3242 }
3243}
3244
3245/* 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.
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
virtual bool DoesUndo() const =0
Is Undo enabled?
virtual void DoUndo(bool const bDoUndo)=0
Enable/Disable Undo.
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
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
void Broadcast(const SfxHint &rHint)
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 SetTextLeft(const tools::Long nL, const sal_uInt16 nProp=100)
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp=100)
void UnLinkGraphics()
tools::Long GetIndentAt() const
tools::Long GetFirstLineIndent() const
SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const
size_t size() const
Definition: tblafmt.cxx:1165
SwBoxAutoFormat * GetBoxFormat(std::u16string_view sName) const
If found returns a ptr to a BoxFormat. If not found returns nullptr.
Definition: tblafmt.cxx:1209
Represents the style of a text portion.
Definition: charfmt.hxx:27
void SetLinkedParaFormat(SwTextFormatColl *pLink)
Definition: chrfmt.cxx:42
const SwTextFormatColl * GetLinkedParaFormat() const
Definition: chrfmt.cxx:44
size_t size() const
Definition: charformats.hxx:71
void RegisterToFormat(SwFormat &)
Definition: fmtcol.cxx:528
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:561
void CallChgLnk()
Definition: crsrsh.cxx:2544
SwDocStyleSheetPool(SwDoc &, bool bOrganizer)
Definition: docstyle.cxx:2421
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) const override
Definition: docstyle.cxx:2587
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2433
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2461
virtual bool SetParent(SfxStyleFamily eFam, const OUString &rStyle, const OUString &rParent) override
Definition: docstyle.cxx:2531
virtual void Remove(SfxStyleSheetBase *pStyle) override
Definition: docstyle.cxx:2471
virtual rtl::Reference< SfxStyleSheetBase > Create(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask) override
Definition: docstyle.cxx:2454
virtual ~SwDocStyleSheetPool() override
Definition: docstyle.cxx:2429
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:1034
virtual bool IsUsed() const override
Definition: docstyle.cxx:2252
SwTextFormatColl * m_pColl
Definition: docstyle.hxx:52
void SetPhysical(bool bPhys)
Definition: docstyle.cxx:2232
void SetLink(const OUString &rStr)
Definition: docstyle.cxx:735
virtual std::optional< SfxItemSet > GetItemSetForPreview() override
Definition: docstyle.cxx:1281
void SetItemSet(const SfxItemSet &rSet, const bool bResetIndentAttrsAtParagraphStyle=false)
add optional parameter <bResetIndentAttrsAtParagraphStyle>, default value false, which indicates that...
Definition: docstyle.cxx:1452
SwDoc & m_rDoc
Definition: docstyle.hxx:58
const SwNumRule * m_pNumRule
Definition: docstyle.hxx:55
virtual SfxItemSet & GetItemSet() override
Definition: docstyle.cxx:1329
virtual bool SetParent(const OUString &rStr) override
Definition: docstyle.cxx:1159
const SwNumRule * GetNumRule()
Definition: docstyle.cxx:2200
virtual bool SetFollow(const OUString &rStr) override
Definition: docstyle.cxx:1210
virtual sal_uLong GetHelpId(OUString &rFile) override
Definition: docstyle.cxx:2289
SAL_DLLPRIVATE void Create()
Make empty shell a real StyleSheet (Core).
Definition: docstyle.cxx:2104
void SetGrabBagItem(const css::uno::Any &rVal)
Definition: docstyle.cxx:464
SwFrameFormat * GetFrameFormat()
Definition: docstyle.cxx:2245
SwCharFormat * m_pCharFormat
Definition: docstyle.hxx:51
SwTableAutoFormat * m_pTableFormat
Definition: docstyle.hxx:56
virtual bool HasParentSupport() const override
Definition: docstyle.cxx:797
virtual void SetHelpId(const OUString &r, sal_uLong nId) override
Definition: docstyle.cxx:2388
void PresetFollow(const OUString &rName)
Definition: docstyle.hxx:122
virtual bool HasFollowSupport() const override
Definition: docstyle.cxx:781
void PresetParent(const OUString &rName)
Definition: docstyle.hxx:121
SwCharFormat * GetCharFormat()
Definition: docstyle.cxx:2179
const OUString & GetLink() const
Definition: docstyle.cxx:769
SwFrameFormat * m_pFrameFormat
Definition: docstyle.hxx:53
OUString m_aLink
Definition: docstyle.hxx:62
virtual bool IsHidden() const override
Definition: docstyle.cxx:624
void PresetNameAndFamily(SfxStyleFamily eFamily, const OUString &rName)
Definition: docstyle.cxx:2225
virtual const OUString & GetParent() const override
Definition: docstyle.cxx:671
SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType, std::optional< SfxItemSet > *o_ppFlatSet=nullptr)
Definition: docstyle.cxx:1862
virtual OUString GetDescription(MapUnit eUnit) override
Definition: docstyle.cxx:826
void SetNumRule(const SwNumRule &rRule)
Definition: docstyle.cxx:2208
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: docstyle.cxx:513
virtual void SetHidden(bool bHidden) override
Definition: docstyle.cxx:540
const SwPageDesc * m_pDesc
Definition: docstyle.hxx:54
SwDocStyleSheet(SwDoc &rDoc, SwDocStyleSheetPool &rPool)
Definition: docstyle.cxx:410
SwTextFormatColl * GetCollection()
Definition: docstyle.cxx:2186
const SwBoxAutoFormat * m_pBoxFormat
Definition: docstyle.hxx:57
virtual ~SwDocStyleSheet() override
virtual OUString GetUsedBy() override
Definition: docstyle.cxx:2284
SwTableAutoFormat * GetTableFormat()
Definition: docstyle.cxx:2214
FillStyleType
Fill StyleSheet with data.
Definition: docstyle.hxx:68
virtual const OUString & GetFollow() const override
Definition: docstyle.cxx:725
void MergeIndentAttrsOfListStyle(SfxItemSet &rSet)
new method for paragraph styles to merge indent attributes of applied list style into the given item ...
Definition: docstyle.cxx:1420
SfxItemSet m_aCoreSet
Definition: docstyle.hxx:59
const SwPageDesc * GetPageDesc()
Definition: docstyle.cxx:2193
virtual bool HasClearParentSupport() const override
Definition: docstyle.cxx:811
Definition: doc.hxx:194
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:1423
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:922
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:400
const SwCharFormat * GetDfltCharFormat() const
Definition: doc.hxx:761
OUString GetUniqueNumRuleName(const OUString *pChkStr=nullptr, bool bAutoNum=true) const
Definition: docnum.cxx:2519
void ChgFormat(SwFormat &rFormat, const SfxItemSet &rSet)
Definition: docfmt.cxx:1868
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:497
const SwCellStyleTable & GetCellStyles() const
Definition: doc.hxx:1259
SwNumRule * FindNumRulePtr(const OUString &rName) const
Definition: docnum.cxx:2441
size_t GetPageDescCnt() const
Definition: doc.hxx:888
const SwNumRuleTable & GetNumRuleTable() const
Definition: doc.hxx:1074
void RenameFormat(SwFormat &rFormat, const OUString &sNewName, bool bBroadcast=false)
Definition: docfmt.cxx:1900
SwCharFormat * FindCharFormatByName(const OUString &rName) const
Definition: doc.hxx:779
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:748
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:150
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:329
bool RenameNumRule(const OUString &aOldName, const OUString &aNewName, bool bBroadcast=false)
Definition: docnum.cxx:1115
void ChgNumRuleFormats(const SwNumRule &rRule)
Definition: docnum.cxx:1093
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:182
const SwTextFormatColls * GetTextFormatColls() const
Definition: doc.hxx:786
std::unique_ptr< SwTableAutoFormat > DelTableStyle(const OUString &rName, bool bBroadcast=false)
Definition: ndtbl.cxx:4587
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:432
void ChgPageDesc(const OUString &rName, const SwPageDesc &)
Definition: docdesc.cxx:978
const SwFrameFormats * GetFrameFormats() const
Definition: doc.hxx:746
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: doc.hxx:807
void DelTextFormatColl(size_t nFormat, bool bBroadcast=false)
Definition: docfmt.cxx:959
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:1053
void ResetAttrAtFormat(const sal_uInt16 nWhichId, SwFormat &rChangedFormat)
Definition: docfmt.cxx:495
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:161
SwCharFormat * MakeCharFormat(const OUString &rFormatName, SwCharFormat *pDerivedFrom, bool bBroadcast=false)
Definition: docfmt.cxx:854
const SwFrameFormat * GetDfltFrameFormat() const
Definition: doc.hxx:755
void DelPageDesc(const OUString &rName, bool bBroadcast=false)
Definition: docdesc.cxx:970
SwTableAutoFormatTable & GetTableStyles()
Return the available table styles.
Definition: ndtbl.cxx:3883
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:889
bool HasTableStyles() const
Counts table styles without triggering lazy-load of them.
Definition: doc.hxx:1251
IDocumentListsAccess const & getIDocumentListsAccess() const
Definition: doc.cxx:299
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:2475
SwFrameFormat * FindFrameFormatByName(const OUString &rName) const
Definition: docfmt.cxx:745
SwTableAutoFormat * MakeTableStyle(const OUString &rName, bool bBroadcast=false)
Definition: ndtbl.cxx:4567
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
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 SetAutoUpdateFormat(bool bNew=true)
Definition: format.hxx:189
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:232
void SetPoolHlpFileId(sal_uInt8 nId)
Definition: format.hxx:170
bool IsAutoUpdateFormat() const
Query / set bAutoUpdateFormat-flag.
Definition: format.hxx:188
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
Style of a layout element.
Definition: frmfmt.hxx:62
virtual void SetFormatName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2567
Specific frame formats (frames, DrawObjects).
size_t size() const
std::pair< const_iterator, bool > push_back(const value_type &x)
Definition: docfmt.cxx:2117
bool HasWriterListeners() const
Definition: calbck.hxx:204
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:3136
rtl::Reference< SwDocStyleSheet > mxIterSheet
Definition: docstyle.hxx:178
virtual SfxStyleSheetBase * First() override
Definition: docstyle.cxx:2704
SwStyleSheetIterator(SwDocStyleSheetPool &rBase, SfxStyleFamily eFam, SfxStyleSearchBits n)
Definition: docstyle.cxx:2667
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:3231
virtual ~SwStyleSheetIterator() override
Definition: docstyle.cxx:2678
virtual SfxStyleSheetBase * operator[](sal_Int32 nIdx) override
Definition: docstyle.cxx:2691
virtual sal_Int32 Count() override
Definition: docstyle.cxx:2683
void AppendStyleList(const std::vector< OUString > &rLst, bool bUsed, bool bTestHidden, bool bOnlyHidden, SwGetPoolIdFromName nSection, SfxStyleFamily eFamily)
Definition: docstyle.cxx:3158
virtual SfxStyleSheetBase * Next() override
Definition: docstyle.cxx:3116
void AddAutoFormat(const SwTableAutoFormat &rFormat)
Append table style to the existing styles.
Definition: tblafmt.cxx:931
size_t size() const
Definition: tblafmt.cxx:917
SwTableAutoFormat * FindAutoFormat(std::u16string_view rName) const
Find table style with the provided name, return nullptr when not found.
Definition: tblafmt.cxx:983
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:878
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:838
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:59
bool AreListLevelIndentsApplicable() const
Definition: fmtcol.cxx:427
void SetLinkedCharFormat(SwCharFormat *pLink)
Definition: fmtcol.cxx:332
bool IsAssignedToListLevelOfOutlineStyle() const
Definition: fmtcol.hxx:120
void DeleteAssignmentToListLevelOfOutlineStyle()
Definition: fmtcol.cxx:651
SwTextFormatColl & GetNextTextFormatColl() const
Definition: fmtcol.hxx:104
void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel)
Definition: fmtcol.cxx:624
void SetNextTextFormatColl(SwTextFormatColl &rNext)
Inline implementations.
Definition: fmtcol.hxx:263
int GetAssignedOutlineStyleLevel() const
Definition: fmtcol.cxx:617
const SwCharFormat * GetLinkedCharFormat() const
Definition: fmtcol.cxx:334
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
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:102
#define FN_COND_COLL
Definition: cmdid.h:812
#define FN_KEEP_ASPECT_RATIO
Definition: cmdid.h:870
#define FN_PARAM_FTN_INFO
Definition: cmdid.h:789
int nCount
virtual OUString GetName() const override
SwDoc & m_rDoc
Definition: docbm.cxx:1202
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:1779
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:1725
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:1262
static void lcl_DeleteInfoStyles(SfxStyleFamily nFamily, std::vector< void * > const &rArr, SwDoc &rDoc)
Definition: docstyle.cxx:1784
float u
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CTL_FONTSIZE(28)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr sal_uInt16 RES_FRMATR_END(133)
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< SvxWeightItem > RES_CHRATR_WEIGHT(15)
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 TypedWhichId< SvxWeightItem > RES_CHRATR_CTL_WEIGHT(31)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
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 sal_uInt16 RES_UNKNOWNATR_END(154)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CJK_WEIGHT(26)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
constexpr TypedWhichId< SwConditionTextFormatColl > RES_CONDTXTFMTCOLL(160)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CJK_POSTURE(25)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
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
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:165
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)