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