LibreOffice Module sw (master)  1
number.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 <hintids.hxx>
22 
23 #include <vcl/font.hxx>
24 #include <editeng/brushitem.hxx>
25 #include <editeng/numitem.hxx>
26 #include <svl/grabbagitem.hxx>
27 #include <fmtornt.hxx>
28 #include <doc.hxx>
29 #include <charfmt.hxx>
30 #include <ndtxt.hxx>
31 #include <docary.hxx>
32 #include <SwStyleNameMapper.hxx>
33 
34 // Needed to load default bullet list configuration
35 #include <unotools/configmgr.hxx>
36 #include <unotools/configitem.hxx>
37 
38 #include <numrule.hxx>
39 #include <SwNodeNum.hxx>
40 
41 #include <list.hxx>
42 
43 #include <algorithm>
44 #include <unordered_map>
45 #include <libxml/xmlwriter.h>
46 
48 #include <unotools/saveopt.hxx>
49 #include <osl/diagnose.h>
50 
51 #include <IDocumentListsAccess.hxx>
53 #include <IDocumentState.hxx>
54 
55 #include <com/sun/star/beans/PropertyValue.hpp>
56 
57 using namespace ::com::sun::star;
58 
59 sal_uInt16 SwNumRule::mnRefCount = 0;
61  {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr } };
62 
64  {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr } };
65 
66 const sal_uInt16 SwNumRule::maDefNumIndents[ MAXLEVEL ] = {
67 //inch: 0,5 1,0 1,5 2,0 2,5 3,0 3,5 4,0 4,5 5,0
68  1440/4, 1440/2, 1440*3/4, 1440, 1440*5/4, 1440*3/2, 1440*7/4, 1440*2,
69  1440*9/4, 1440*5/2
70 };
71 
73 {
74  return "Outline";
75 }
76 
77 const SwNumFormat& SwNumRule::Get( sal_uInt16 i ) const
78 {
79  assert( i < MAXLEVEL && meRuleType < RULE_END );
80  return maFormats[ i ]
81  ? *maFormats[ i ]
83  ? *maBaseFormats[ meRuleType ][ i ]
85 }
86 
87 const SwNumFormat* SwNumRule::GetNumFormat( sal_uInt16 i ) const
88 {
89  const SwNumFormat * pResult = nullptr;
90 
91  assert( i < MAXLEVEL && meRuleType < RULE_END );
92  if ( i < MAXLEVEL && meRuleType < RULE_END)
93  {
94  pResult = maFormats[ i ].get();
95  }
96 
97  return pResult;
98 }
99 
100 // #i91400#
101 void SwNumRule::SetName( const OUString & rName,
102  IDocumentListsAccess& rDocListAccess)
103 {
104  if ( msName != rName )
105  {
106  if (mpNumRuleMap)
107  {
108  mpNumRuleMap->erase(msName);
109  (*mpNumRuleMap)[rName] = this;
110 
111  if ( !GetDefaultListId().isEmpty() )
112  {
113  rDocListAccess.trackChangeOfListStyleName( msName, rName );
114  }
115  }
116 
117  msName = rName;
118  }
119 }
120 
122 {
123  rTextNodeList = maTextNodeList;
124 }
125 
126 SwNumRule::tTextNodeList::size_type SwNumRule::GetTextNodeListSize() const
127 {
128  return maTextNodeList.size();
129 }
130 
132 {
133  tTextNodeList::iterator aIter =
134  std::find( maTextNodeList.begin(), maTextNodeList.end(), &rTextNode );
135 
136  if ( aIter == maTextNodeList.end() )
137  {
138  maTextNodeList.push_back( &rTextNode );
139  }
140 }
141 
143 {
144  tTextNodeList::iterator aIter =
145  std::find( maTextNodeList.begin(), maTextNodeList.end(), &rTextNode );
146 
147  if ( aIter != maTextNodeList.end() )
148  {
149  maTextNodeList.erase( aIter );
150  }
151 }
152 
153 void SwNumRule::SetNumRuleMap(std::unordered_map<OUString, SwNumRule *> *
154  pNumRuleMap)
155 {
156  mpNumRuleMap = pNumRuleMap;
157 }
158 
160 {
161  OSL_ENSURE( MAXLEVEL > nLvl, "NumLevel is out of range" );
162  return maDefNumIndents[ nLvl ];
163 }
164 
166 {
167  OSL_ENSURE( MAXLEVEL > nLvl, "NumLevel is out of range" );
168  return maDefNumIndents[ nLvl ];
169 }
170 
171 static void lcl_SetRuleChgd( SwTextNode& rNd, sal_uInt8 nLevel )
172 {
173  if( rNd.GetActualListLevel() == nLevel )
174  rNd.NumRuleChgd();
175 }
176 
179  SwClient( nullptr ),
180  m_pVertOrient(new SwFormatVertOrient( 0, text::VertOrientation::NONE))
181  ,m_cGrfBulletCP(USHRT_MAX)//For i120928,record the cp info of graphic within bullet
182 {
183 }
184 
186  SvxNumberFormat(rFormat),
187  SwClient( rFormat.GetRegisteredInNonConst() ),
188  m_pVertOrient(new SwFormatVertOrient( 0, rFormat.GetVertOrient()))
189  ,m_cGrfBulletCP(rFormat.m_cGrfBulletCP)//For i120928,record the cp info of graphic within bullet
190 {
191  sal_Int16 eMyVertOrient = rFormat.GetVertOrient();
192  SetGraphicBrush( rFormat.GetBrush(), &rFormat.GetGraphicSize(),
193  &eMyVertOrient);
194 }
195 
197  : SvxNumberFormat(rNumFormat)
198  , m_pVertOrient(new SwFormatVertOrient( 0, rNumFormat.GetVertOrient()))
199  , m_cGrfBulletCP(USHRT_MAX)
200 {
201  sal_Int16 eMyVertOrient = rNumFormat.GetVertOrient();
202  SetGraphicBrush( rNumFormat.GetBrush(), &rNumFormat.GetGraphicSize(),
203  &eMyVertOrient);
204  const OUString rCharStyleName = rNumFormat.SvxNumberFormat::GetCharFormatName();
205  if( !rCharStyleName.isEmpty() )
206  {
207  SwCharFormat* pCFormat = pDoc->FindCharFormatByName( rCharStyleName );
208  if( !pCFormat )
209  {
210  sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rCharStyleName,
212  pCFormat = nId != USHRT_MAX
214  : pDoc->MakeCharFormat( rCharStyleName, nullptr );
215  }
216  pCFormat->Add( this );
217  }
218  else
219  EndListeningAll();
220 }
221 
223 {
224 }
225 
226 // #i22362#
228 {
229  // #i30655# native numbering did not work any longer
230  // using this code. Therefore HBRINKM and I agreed upon defining
231  // IsEnumeration() as !IsItemize()
232  return !IsItemize();
233 }
234 
236 {
237  bool bResult;
238 
239  switch(GetNumberingType())
240  {
242  case SVX_NUM_BITMAP:
243  bResult = true;
244 
245  break;
246 
247  default:
248  bResult = false;
249  }
250 
251  return bResult;
252 
253 }
254 
256 {
257  SvxNumberFormat::operator=(rNumFormat);
258  StartListeningToSameModifyAs(rNumFormat);
259  //For i120928,record the cp info of graphic within bullet
260  m_cGrfBulletCP = rNumFormat.m_cGrfBulletCP;
261  return *this;
262 }
263 
264 bool SwNumFormat::operator==( const SwNumFormat& rNumFormat) const
265 {
266  bool bRet = SvxNumberFormat::operator==(rNumFormat) &&
267  GetRegisteredIn() == rNumFormat.GetRegisteredIn();
268  return bRet;
269 }
270 
272 {
273  if( pChFormat )
274  pChFormat->Add( this );
275  else
276  EndListeningAll();
277 }
278 
279 void SwNumFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
280 {
281  // Look for the NumRules object in the Doc where this NumFormat is set.
282  // The format does not need to exist!
283  const SwCharFormat* pFormat = nullptr;
284  sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
285  switch( nWhich )
286  {
287  case RES_ATTRSET_CHG:
288  case RES_FMT_CHG:
289  pFormat = GetCharFormat();
290  break;
291  }
292 
293  if( pFormat && !pFormat->GetDoc()->IsInDtor() )
294  UpdateNumNodes( const_cast<SwDoc*>(pFormat->GetDoc()) );
295  else
296  CheckRegistration( pOld );
297 }
298 
300 {
301  if(static_cast<const SwCharFormat*>(GetRegisteredIn()))
302  return static_cast<const SwCharFormat*>(GetRegisteredIn())->GetName();
303 
304  return OUString();
305 }
306 
307 void SwNumFormat::SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize,
308  const sal_Int16* pOrient)
309 {
310  if(pOrient)
311  m_pVertOrient->SetVertOrient( *pOrient );
312  SvxNumberFormat::SetGraphicBrush( pBrushItem, pSize, pOrient);
313 }
314 
316 {
317  bool bDocIsModified = pDoc->getIDocumentState().IsModified();
318  bool bFnd = false;
319  for( SwNumRuleTable::size_type n = pDoc->GetNumRuleTable().size(); !bFnd && n; )
320  {
321  const SwNumRule* pRule = pDoc->GetNumRuleTable()[ --n ];
322  for( sal_uInt8 i = 0; i < MAXLEVEL; ++i )
323  if( pRule->GetNumFormat( i ) == this )
324  {
325  SwNumRule::tTextNodeList aTextNodeList;
326  pRule->GetTextNodeList( aTextNodeList );
327  for ( auto& rpTextNode : aTextNodeList )
328  {
329  lcl_SetRuleChgd( *rpTextNode, i );
330  }
331  bFnd = true;
332  break;
333  }
334  }
335 
336  if( bFnd && !bDocIsModified )
338 }
339 
341 {
342  sal_Int16 eOrient = SvxNumberFormat::GetVertOrient();
343  if(text::VertOrientation::NONE == eOrient)
344  return nullptr;
345  else
346  {
347  m_pVertOrient->SetVertOrient(eOrient);
348  return m_pVertOrient.get();
349  }
350 }
351 
352 SwNumRule::SwNumRule( const OUString& rNm,
353  const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode,
354  SwNumRuleType eType )
355  : maTextNodeList(),
356  maParagraphStyleList(),
357  mpNumRuleMap(nullptr),
358  msName( rNm ),
359  meRuleType( eType ),
360  mnPoolFormatId( USHRT_MAX ),
361  mnPoolHelpId( USHRT_MAX ),
362  mnPoolHlpFileId( UCHAR_MAX ),
363  mbAutoRuleFlag( true ),
364  mbInvalidRuleFlag( true ),
365  mbContinusNum( false ),
366  mbAbsSpaces( false ),
367  mbHidden( false ),
368  mbCountPhantoms( true ),
369  mbUsedByRedline( false ),
370  meDefaultNumberFormatPositionAndSpaceMode( eDefaultNumberFormatPositionAndSpaceMode ),
371  msDefaultListId()
372 {
373  if( !mnRefCount++ ) // for the first time, initialize
374  {
375  SwNumFormat* pFormat;
376  sal_uInt8 n;
377 
378  // numbering:
379  // position-and-space mode LABEL_WIDTH_AND_POSITION:
380  for( n = 0; n < MAXLEVEL; ++n )
381  {
382  pFormat = new SwNumFormat;
383  pFormat->SetIncludeUpperLevels( 1 );
384  pFormat->SetStart( 1 );
387  pFormat->SetSuffix( "." );
389  SwNumRule::maBaseFormats[ NUM_RULE ][ n ] = pFormat;
390  }
391  // position-and-space mode LABEL_ALIGNMENT
392  // first line indent of general numbering in inch: -0,25 inch
393  const long cFirstLineIndent = -1440/4;
394  // indent values of general numbering in inch:
395  // 0,5 0,75 1,0 1,25 1,5
396  // 1,75 2,0 2,25 2,5 2,75
397  const long cIndentAt[ MAXLEVEL ] = {
398  1440/2, 1440*3/4, 1440, 1440*5/4, 1440*3/2,
399  1440*7/4, 1440*2, 1440*9/4, 1440*5/2, 1440*11/4 };
400  for( n = 0; n < MAXLEVEL; ++n )
401  {
402  pFormat = new SwNumFormat;
403  pFormat->SetIncludeUpperLevels( 1 );
404  pFormat->SetStart( 1 );
407  pFormat->SetListtabPos( cIndentAt[ n ] );
408  pFormat->SetFirstLineIndent( cFirstLineIndent );
409  pFormat->SetIndentAt( cIndentAt[ n ] );
410  pFormat->SetSuffix( "." );
412  SwNumRule::maLabelAlignmentBaseFormats[ NUM_RULE ][ n ] = pFormat;
413  }
414 
415  // outline:
416  // position-and-space mode LABEL_WIDTH_AND_POSITION:
417  for( n = 0; n < MAXLEVEL; ++n )
418  {
419  pFormat = new SwNumFormat;
421  pFormat->SetIncludeUpperLevels( MAXLEVEL );
422  pFormat->SetStart( 1 );
425  SwNumRule::maBaseFormats[ OUTLINE_RULE ][ n ] = pFormat;
426  }
427  // position-and-space mode LABEL_ALIGNMENT:
428  for( n = 0; n < MAXLEVEL; ++n )
429  {
430  pFormat = new SwNumFormat;
432  pFormat->SetIncludeUpperLevels( MAXLEVEL );
433  pFormat->SetStart( 1 );
436  SwNumRule::maLabelAlignmentBaseFormats[ OUTLINE_RULE ][ n ] = pFormat;
437  }
438  }
439  OSL_ENSURE( !msName.isEmpty(), "NumRule without a name!" );
440 }
441 
442 SwNumRule::SwNumRule( const SwNumRule& rNumRule )
443  : maTextNodeList(),
444  maParagraphStyleList(),
445  mpNumRuleMap(nullptr),
446  msName( rNumRule.msName ),
447  meRuleType( rNumRule.meRuleType ),
448  mnPoolFormatId( rNumRule.GetPoolFormatId() ),
449  mnPoolHelpId( rNumRule.GetPoolHelpId() ),
450  mnPoolHlpFileId( rNumRule.GetPoolHlpFileId() ),
451  mbAutoRuleFlag( rNumRule.mbAutoRuleFlag ),
452  mbInvalidRuleFlag( true ),
453  mbContinusNum( rNumRule.mbContinusNum ),
454  mbAbsSpaces( rNumRule.mbAbsSpaces ),
455  mbHidden( rNumRule.mbHidden ),
456  mbCountPhantoms( true ),
457  mbUsedByRedline( false ),
458  meDefaultNumberFormatPositionAndSpaceMode( rNumRule.meDefaultNumberFormatPositionAndSpaceMode ),
459  msDefaultListId( rNumRule.msDefaultListId )
460 {
461  ++mnRefCount;
462  for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
463  if( rNumRule.maFormats[ n ] )
464  Set( n, *rNumRule.maFormats[ n ] );
465 }
466 
468 {
469  for (auto & i : maFormats)
470  i.reset();
471 
472  if (mpNumRuleMap)
473  {
474  mpNumRuleMap->erase(GetName());
475  }
476 
477  if( !--mnRefCount ) // the last one closes the door (?)
478  {
479  // Numbering:
480  SwNumFormat** ppFormats = &SwNumRule::maBaseFormats[0][0];
481  int n;
482 
483  for( n = 0; n < MAXLEVEL; ++n, ++ppFormats )
484  {
485  delete *ppFormats;
486  *ppFormats = nullptr;
487  }
488 
489  // Outline:
490  for( n = 0; n < MAXLEVEL; ++n, ++ppFormats )
491  {
492  delete *ppFormats;
493  *ppFormats = nullptr;
494  }
495 
496  ppFormats = &SwNumRule::maLabelAlignmentBaseFormats[0][0];
497  for( n = 0; n < MAXLEVEL; ++n, ++ppFormats )
498  {
499  delete *ppFormats;
500  *ppFormats = nullptr;
501  }
502  for( n = 0; n < MAXLEVEL; ++n, ++ppFormats )
503  {
504  delete *ppFormats;
505  *ppFormats = nullptr;
506  }
507  }
508 
509  maTextNodeList.clear();
510  maParagraphStyleList.clear();
511 }
512 
514 {
515  for(auto& rpNumFormat : maFormats)
516  {
517  SwCharFormat* pFormat;
518  if( rpNumFormat && nullptr != ( pFormat = rpNumFormat->GetCharFormat() ) &&
519  pFormat->GetDoc() != pDoc )
520  {
521  // copy
522  SwNumFormat* pNew = new SwNumFormat( *rpNumFormat );
523  pNew->SetCharFormat( pDoc->CopyCharFormat( *pFormat ) );
524  rpNumFormat.reset(pNew);
525  }
526  }
527 }
528 
530 {
531  if( this != &rNumRule )
532  {
533  for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
534  Set( n, rNumRule.maFormats[ n ].get() );
535 
536  meRuleType = rNumRule.meRuleType;
537  msName = rNumRule.msName;
538  mbAutoRuleFlag = rNumRule.mbAutoRuleFlag;
539  mbInvalidRuleFlag = true;
540  mbContinusNum = rNumRule.mbContinusNum;
541  mbAbsSpaces = rNumRule.mbAbsSpaces;
542  mbHidden = rNumRule.mbHidden;
543  mnPoolFormatId = rNumRule.GetPoolFormatId();
544  mnPoolHelpId = rNumRule.GetPoolHelpId();
545  mnPoolHlpFileId = rNumRule.GetPoolHlpFileId();
546  }
547  return *this;
548 }
549 
550 bool SwNumRule::operator==( const SwNumRule& rRule ) const
551 {
552  bool bRet = meRuleType == rRule.meRuleType &&
553  msName == rRule.msName &&
554  mbAutoRuleFlag == rRule.mbAutoRuleFlag &&
555  mbContinusNum == rRule.mbContinusNum &&
556  mbAbsSpaces == rRule.mbAbsSpaces &&
557  mnPoolFormatId == rRule.GetPoolFormatId() &&
558  mnPoolHelpId == rRule.GetPoolHelpId() &&
560  if( bRet )
561  {
562  for( sal_uInt8 n = 0; n < MAXLEVEL; ++n )
563  if( rRule.Get( n ) != Get( n ) )
564  {
565  bRet = false;
566  break;
567  }
568  }
569  return bRet;
570 }
571 
572 void SwNumRule::Set( sal_uInt16 i, const SwNumFormat& rNumFormat )
573 {
574  OSL_ENSURE( i < MAXLEVEL, "Serious defect" );
575  if( i < MAXLEVEL )
576  {
577  if( !maFormats[ i ] || (rNumFormat != Get( i )) )
578  {
579  maFormats[ i ].reset(new SwNumFormat( rNumFormat ));
580  mbInvalidRuleFlag = true;
581  }
582  }
583 }
584 
585 void SwNumRule::Set( sal_uInt16 i, const SwNumFormat* pNumFormat )
586 {
587  OSL_ENSURE( i < MAXLEVEL, "Serious defect" );
588  if( i >= MAXLEVEL )
589  return;
590  if( !maFormats[ i ] )
591  {
592  if( pNumFormat )
593  {
594  maFormats[ i ].reset(new SwNumFormat( *pNumFormat ));
595  mbInvalidRuleFlag = true;
596  }
597  }
598  else if( !pNumFormat )
599  {
600  maFormats[ i ].reset();
601  mbInvalidRuleFlag = true;
602  }
603  else if( *maFormats[i] != *pNumFormat )
604  {
605  *maFormats[ i ] = *pNumFormat;
606  mbInvalidRuleFlag = true;
607  }
608 }
609 
610 OUString SwNumRule::MakeNumString( const SwNodeNum& rNum, bool bInclStrings ) const
611 {
612  if (rNum.IsCounted())
613  return MakeNumString(rNum.GetNumberVector(), bInclStrings);
614 
615  return OUString();
616 }
617 
619  const bool bInclStrings,
620  const bool bOnlyArabic,
621  const unsigned int _nRestrictToThisLevel,
622  SwNumRule::Extremities* pExtremities,
623  LanguageType nLang ) const
624 {
625  OUStringBuffer aStr;
626 
627  SwNumberTree::tNumberVector::size_type nLevel = rNumVector.size() - 1;
628 
629  if ( pExtremities )
630  pExtremities->nPrefixChars = pExtremities->nSuffixChars = 0;
631 
632  if ( nLevel > _nRestrictToThisLevel )
633  {
634  nLevel = _nRestrictToThisLevel;
635  }
636 
637  if (nLevel < MAXLEVEL)
638  {
639  const SwNumFormat& rMyNFormat = Get( static_cast<sal_uInt16>(nLevel) );
640 
641  {
642  SwNumberTree::tNumberVector::size_type i = nLevel;
643 
644  if( !IsContinusNum() &&
645  // - do not include upper levels, if level isn't numbered.
646  rMyNFormat.GetNumberingType() != SVX_NUM_NUMBER_NONE &&
647  rMyNFormat.GetIncludeUpperLevels() ) // Just the own level?
648  {
649  sal_uInt8 n = rMyNFormat.GetIncludeUpperLevels();
650  if( 1 < n )
651  {
652  if( i+1 >= n )
653  i -= n - 1;
654  else
655  i = 0;
656  }
657  }
658 
659  css::lang::Locale aLocale( LanguageTag::convertToLocale(nLang));
660 
661  for( ; i <= nLevel; ++i )
662  {
663  const SwNumFormat& rNFormat = Get( i );
664  if( SVX_NUM_NUMBER_NONE == rNFormat.GetNumberingType() )
665  {
666  // Should 1.1.1 --> 2. NoNum --> 1..1 or 1.1 ??
667  // if( i != rNum.nMyLevel )
668  // aStr += ".";
669  continue;
670  }
671 
672  if( rNumVector[ i ] )
673  {
674  if( bOnlyArabic )
675  aStr.append(OUString::number( rNumVector[ i ] ));
676  else
677  aStr.append(rNFormat.GetNumStr( rNumVector[ i ], aLocale ));
678  }
679  else
680  aStr.append("0"); // all 0 level are a 0
681  if( i != nLevel && !aStr.isEmpty() )
682  aStr.append(".");
683  }
684 
685  // The type doesn't have any number, so don't append
686  // the post-/prefix string
687  if( bInclStrings && !bOnlyArabic &&
688  SVX_NUM_CHAR_SPECIAL != rMyNFormat.GetNumberingType() &&
689  SVX_NUM_BITMAP != rMyNFormat.GetNumberingType() )
690  {
691  const OUString& sPrefix = rMyNFormat.GetPrefix();
692  const OUString& sSuffix = rMyNFormat.GetSuffix();
693 
694  aStr.insert(0, sPrefix);
695  aStr.append(sSuffix);
696  if ( pExtremities )
697  {
698  pExtremities->nPrefixChars = sPrefix.getLength();
699  pExtremities->nSuffixChars = sSuffix.getLength();
700  }
701  }
702  }
703  }
704 
705  return aStr.makeStringAndClear();
706 }
707 
708 OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
709  const bool bInclSuperiorNumLabels,
710  const int nRestrictInclToThisLevel ) const
711 {
712  OUString aRefNumStr;
713 
714  if ( rNodeNum.GetLevelInListTree() >= 0 )
715  {
716  bool bOldHadPrefix = true;
717 
718  const SwNodeNum* pWorkingNodeNum( &rNodeNum );
719  do
720  {
721  bool bMakeNumStringForPhantom( false );
722  if ( pWorkingNodeNum->IsPhantom() )
723  {
724  int nListLevel = pWorkingNodeNum->GetLevelInListTree();
725 
726  if (nListLevel < 0)
727  nListLevel = 0;
728 
729  if (nListLevel >= MAXLEVEL)
730  nListLevel = MAXLEVEL - 1;
731 
732  SwNumFormat aFormat( Get( static_cast<sal_uInt16>(nListLevel) ) );
733  bMakeNumStringForPhantom = aFormat.IsEnumeration() &&
735 
736  }
737  if ( bMakeNumStringForPhantom ||
738  ( !pWorkingNodeNum->IsPhantom() &&
739  pWorkingNodeNum->GetTextNode() &&
740  pWorkingNodeNum->GetTextNode()->HasNumber() ) )
741  {
742  Extremities aExtremities;
743  OUString aPrevStr = MakeNumString( pWorkingNodeNum->GetNumberVector(),
744  true, false, MAXLEVEL,
745  &aExtremities);
746  sal_Int32 nStrip = 0;
747  while ( nStrip < aExtremities.nPrefixChars )
748  {
749  const sal_Unicode c = aPrevStr[nStrip];
750  if ( c!='\t' && c!=' ')
751  break;
752  ++nStrip;
753  }
754 
755  if (nStrip)
756  {
757  aPrevStr = aPrevStr.copy( nStrip );
758  aExtremities.nPrefixChars -= nStrip;
759  }
760 
761  if (bOldHadPrefix &&
762  aExtremities.nSuffixChars &&
763  !aExtremities.nPrefixChars
764  )
765  {
766  aPrevStr = aPrevStr.copy(0,
767  aPrevStr.getLength() - aExtremities.nSuffixChars);
768  }
769 
770  bOldHadPrefix = ( aExtremities.nPrefixChars > 0);
771 
772  aRefNumStr = aPrevStr + aRefNumStr;
773  }
774 
775  if ( bInclSuperiorNumLabels && pWorkingNodeNum->GetLevelInListTree() > 0 )
776  {
777  sal_uInt8 n = Get( static_cast<sal_uInt16>(pWorkingNodeNum->GetLevelInListTree()) ).GetIncludeUpperLevels();
778  pWorkingNodeNum = dynamic_cast<SwNodeNum*>(pWorkingNodeNum->GetParent());
779  // skip parents, whose list label is already contained in the actual list label.
780  while ( pWorkingNodeNum && n > 1 )
781  {
782  pWorkingNodeNum = dynamic_cast<SwNodeNum*>(pWorkingNodeNum->GetParent());
783  --n;
784  }
785  }
786  else
787  {
788  break;
789  }
790  } while ( pWorkingNodeNum &&
791  pWorkingNodeNum->GetLevelInListTree() >= 0 &&
792  pWorkingNodeNum->GetLevelInListTree() >= nRestrictInclToThisLevel );
793  }
794 
795  return aRefNumStr;
796 }
797 
799 {
800  OUString aParagraphStyleListString;
801  for (const auto& rParagraphStyle : maParagraphStyleList)
802  {
803  if (!aParagraphStyleListString.isEmpty())
804  aParagraphStyleListString += ", ";
805  aParagraphStyleListString += rParagraphStyle->GetName();
806  }
807  return aParagraphStyleListString;
808 }
809 
816 {
817  for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
818  {
819  Set( n, rNumRule.maFormats[ n ].get() );
820  if( maFormats[ n ] && maFormats[ n ]->GetCharFormat() &&
821  !pDoc->GetCharFormats()->IsAlive(maFormats[n]->GetCharFormat()))
822  {
823  // If we copy across different Documents, then copy the
824  // corresponding CharFormat into the new Document.
825  maFormats[n]->SetCharFormat( pDoc->CopyCharFormat( *maFormats[n]->
826  GetCharFormat() ) );
827  }
828  }
829  meRuleType = rNumRule.meRuleType;
830  msName = rNumRule.msName;
831  mbAutoRuleFlag = rNumRule.mbAutoRuleFlag;
832  mnPoolFormatId = rNumRule.GetPoolFormatId();
833  mnPoolHelpId = rNumRule.GetPoolHelpId();
834  mnPoolHlpFileId = rNumRule.GetPoolHlpFileId();
835  mbInvalidRuleFlag = true;
836  return *this;
837 }
838 
839 void SwNumRule::SetSvxRule(const SvxNumRule& rNumRule, SwDoc* pDoc)
840 {
841  for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
842  {
843  const SvxNumberFormat* pSvxFormat = rNumRule.Get(n);
844  maFormats[n].reset( pSvxFormat ? new SwNumFormat(*pSvxFormat, pDoc) : nullptr );
845  }
846 
847  mbInvalidRuleFlag = true;
849 }
850 
852 {
853  SvxNumRule aRule(SvxNumRuleFlags::CONTINUOUS | SvxNumRuleFlags::CHAR_STYLE |
854  SvxNumRuleFlags::ENABLE_LINKED_BMP | SvxNumRuleFlags::ENABLE_EMBEDDED_BMP,
856  meRuleType == NUM_RULE ? SvxNumRuleType::NUMBERING : SvxNumRuleType::OUTLINE_NUMBERING );
857  for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
858  {
859  SwNumFormat aNumFormat = Get(n);
860  if(aNumFormat.GetCharFormat())
861  aNumFormat.SetCharFormatName(aNumFormat.GetCharFormat()->GetName());
862  aRule.SetLevel(n, aNumFormat, maFormats[n] != nullptr);
863  }
864  return aRule;
865 }
866 
868 {
869  if (bFlag)
870  {
871  std::set< SwList* > aLists;
872  for ( const SwTextNode* pTextNode : maTextNodeList )
873  {
874  // #i111681# - applying patch from cmc
875  SwList* pList = pTextNode->GetDoc()->getIDocumentListsAccess().getListByName( pTextNode->GetListId() );
876  OSL_ENSURE( pList, "<SwNumRule::SetInvalidRule(..)> - list at which the text node is registered at does not exist. This is a serious issue.");
877  if ( pList )
878  {
879  aLists.insert( pList );
880  }
881  }
882  for ( auto aList : aLists )
883  aList->InvalidateListTree();
884  }
885 
886  mbInvalidRuleFlag = bFlag;
887 }
888 
890 void SwNumRule::ChangeIndent( const sal_Int32 nDiff )
891 {
892  for ( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
893  {
894  SwNumFormat aTmpNumFormat( Get(i) );
895 
896  const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode(
897  aTmpNumFormat.GetPositionAndSpaceMode() );
898  if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
899  {
900  auto nNewIndent = nDiff +
901  aTmpNumFormat.GetAbsLSpace();
902  if ( nNewIndent < 0 )
903  {
904  nNewIndent = 0;
905  }
906  aTmpNumFormat.SetAbsLSpace( nNewIndent );
907  }
908  else if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
909  {
910  // adjust also the list tab position, if a list tab stop is applied
911  if ( aTmpNumFormat.GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
912  {
913  const long nNewListTab = aTmpNumFormat.GetListtabPos() + nDiff;
914  aTmpNumFormat.SetListtabPos( nNewListTab );
915  }
916 
917  const long nNewIndent = nDiff +
918  aTmpNumFormat.GetIndentAt();
919  aTmpNumFormat.SetIndentAt( nNewIndent );
920  }
921 
922  Set( i, aTmpNumFormat );
923  }
924 
925  SetInvalidRule( true );
926 }
927 
929 void SwNumRule::SetIndent( const short nNewIndent,
930  const sal_uInt16 nListLevel )
931 {
932  SwNumFormat aTmpNumFormat( Get(nListLevel) );
933 
934  const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode(
935  aTmpNumFormat.GetPositionAndSpaceMode() );
936  if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
937  {
938  aTmpNumFormat.SetAbsLSpace( nNewIndent );
939  }
940  else if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
941  {
942  // adjust also the list tab position, if a list tab stop is applied
943  if ( aTmpNumFormat.GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
944  {
945  const long nNewListTab = aTmpNumFormat.GetListtabPos() +
946  ( nNewIndent - aTmpNumFormat.GetIndentAt() );
947  aTmpNumFormat.SetListtabPos( nNewListTab );
948  }
949 
950  aTmpNumFormat.SetIndentAt( nNewIndent );
951  }
952 
953  SetInvalidRule( true );
954 }
955 
959 {
960  SwNumFormat aTmpNumFormat( Get(0) );
961 
962  sal_Int32 nDiff( 0 );
963  const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode(
964  aTmpNumFormat.GetPositionAndSpaceMode() );
965  if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
966  {
967  nDiff = nNewIndent
968  - aTmpNumFormat.GetFirstLineOffset()
969  - aTmpNumFormat.GetAbsLSpace();
970  }
971  else if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
972  {
973  nDiff = nNewIndent - aTmpNumFormat.GetIndentAt();
974  }
975  if ( nDiff != 0 )
976  {
977  ChangeIndent( nDiff );
978  }
979 }
980 
982 {
983  std::set< SwList* > aLists;
984  for ( const SwTextNode* pTextNode : maTextNodeList )
985  {
986  aLists.insert( pTextNode->GetDoc()->getIDocumentListsAccess().getListByName( pTextNode->GetListId() ) );
987  }
988  for ( auto aList : aLists )
989  aList->ValidateListTree();
990 
991  SetInvalidRule(false);
992 }
993 
994 void SwNumRule::SetCountPhantoms(bool bCountPhantoms)
995 {
996  mbCountPhantoms = bCountPhantoms;
997 }
998 
999 SwNumRule::tParagraphStyleList::size_type SwNumRule::GetParagraphStyleListSize() const
1000 {
1001  return maParagraphStyleList.size();
1002 }
1003 
1005 {
1006  tParagraphStyleList::iterator aIter =
1007  std::find( maParagraphStyleList.begin(), maParagraphStyleList.end(), &rTextFormatColl );
1008 
1009  if ( aIter == maParagraphStyleList.end() )
1010  {
1011  maParagraphStyleList.push_back( &rTextFormatColl );
1012  }
1013 }
1014 
1016 {
1017  tParagraphStyleList::iterator aIter =
1018  std::find( maParagraphStyleList.begin(), maParagraphStyleList.end(), &rTextFormatColl );
1019 
1020  if ( aIter != maParagraphStyleList.end() )
1021  {
1022  maParagraphStyleList.erase( aIter );
1023  }
1024 }
1025 
1027 {
1028  xmlTextWriterStartElement(pWriter, BAD_CAST("SwNumRule"));
1029  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("msName"), BAD_CAST(msName.toUtf8().getStr()));
1030  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("mnPoolFormatId"), BAD_CAST(OString::number(mnPoolFormatId).getStr()));
1031  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("mbAutoRuleFlag"), BAD_CAST(OString::boolean(mbAutoRuleFlag).getStr()));
1032  xmlTextWriterEndElement(pWriter);
1033 }
1034 
1036 {
1037  if (mpGrabBagItem.get())
1038  mpGrabBagItem->QueryValue(rVal);
1039  else
1040  rVal <<= uno::Sequence<beans::PropertyValue>();
1041 }
1042 
1044 {
1045  if (!mpGrabBagItem.get())
1046  mpGrabBagItem.reset(new SfxGrabBagItem);
1047 
1048  mpGrabBagItem->PutValue(rVal, 0);
1049 }
1050 
1051 namespace numfunc
1052 {
1053  namespace {
1054 
1056  class SwDefBulletConfig : private utl::ConfigItem
1057  {
1058  public:
1059  static SwDefBulletConfig& getInstance();
1060 
1061  const OUString& GetFontname() const
1062  {
1063  return msFontname;
1064  }
1065 
1066  bool IsFontnameUserDefined() const
1067  {
1068  return mbUserDefinedFontname;
1069  }
1070 
1071  const vcl::Font& GetFont() const
1072  {
1073  return *mpFont;
1074  }
1075 
1076  sal_Unicode GetChar( sal_uInt8 p_nListLevel ) const
1077  {
1078  if (p_nListLevel >= MAXLEVEL)
1079  {
1080  p_nListLevel = MAXLEVEL - 1;
1081  }
1082 
1083  return mnLevelChars[p_nListLevel];
1084  }
1085 
1086  SwDefBulletConfig();
1087 
1088  private:
1090  void SetToDefault();
1091 
1093  static uno::Sequence<OUString> GetPropNames();
1094 
1097  void LoadConfig();
1098 
1100  void InitFont();
1101 
1103  virtual void Notify( const uno::Sequence<OUString>& aPropertyNames ) override;
1104  virtual void ImplCommit() override;
1105 
1106  // default bullet list configuration data
1107  OUString msFontname;
1112 
1113  // default bullet list font instance
1114  std::unique_ptr<vcl::Font> mpFont;
1115  };
1116 
1117  class theSwDefBulletConfig
1118  : public rtl::Static<SwDefBulletConfig, theSwDefBulletConfig>{};
1119  }
1120 
1121  SwDefBulletConfig& SwDefBulletConfig::getInstance()
1122  {
1123  return theSwDefBulletConfig::get();
1124  }
1125 
1126  SwDefBulletConfig::SwDefBulletConfig()
1127  : ConfigItem( "Office.Writer/Numbering/DefaultBulletList" ),
1128  // default bullet font is now OpenSymbol
1129  msFontname( OUString("OpenSymbol") ),
1130  mbUserDefinedFontname( false ),
1133  {
1134  SetToDefault();
1135  LoadConfig();
1136  InitFont();
1137 
1138  // enable notification for changes on default bullet configuration change
1139  EnableNotification( GetPropNames() );
1140  }
1141 
1142  void SwDefBulletConfig::SetToDefault()
1143  {
1144  msFontname = "OpenSymbol";
1145  mbUserDefinedFontname = false;
1148 
1149  mnLevelChars[0] = 0x2022;
1150  mnLevelChars[1] = 0x25e6;
1151  mnLevelChars[2] = 0x25aa;
1152  mnLevelChars[3] = 0x2022;
1153  mnLevelChars[4] = 0x25e6;
1154  mnLevelChars[5] = 0x25aa;
1155  mnLevelChars[6] = 0x2022;
1156  mnLevelChars[7] = 0x25e6;
1157  mnLevelChars[8] = 0x25aa;
1158  mnLevelChars[9] = 0x2022;
1159  }
1160 
1161  uno::Sequence<OUString> SwDefBulletConfig::GetPropNames()
1162  {
1163  uno::Sequence<OUString> aPropNames(13);
1164  OUString* pNames = aPropNames.getArray();
1165  pNames[0] = "BulletFont/FontFamilyname";
1166  pNames[1] = "BulletFont/FontWeight";
1167  pNames[2] = "BulletFont/FontItalic";
1168  pNames[3] = "BulletCharLvl1";
1169  pNames[4] = "BulletCharLvl2";
1170  pNames[5] = "BulletCharLvl3";
1171  pNames[6] = "BulletCharLvl4";
1172  pNames[7] = "BulletCharLvl5";
1173  pNames[8] = "BulletCharLvl6";
1174  pNames[9] = "BulletCharLvl7";
1175  pNames[10] = "BulletCharLvl8";
1176  pNames[11] = "BulletCharLvl9";
1177  pNames[12] = "BulletCharLvl10";
1178 
1179  return aPropNames;
1180  }
1181 
1182  void SwDefBulletConfig::LoadConfig()
1183  {
1184  uno::Sequence<OUString> aPropNames = GetPropNames();
1185  uno::Sequence<uno::Any> aValues =
1186  GetProperties( aPropNames );
1187  const uno::Any* pValues = aValues.getConstArray();
1188  OSL_ENSURE( aValues.getLength() == aPropNames.getLength(),
1189  "<SwDefBulletConfig::SwDefBulletConfig()> - GetProperties failed");
1190  if ( aValues.getLength() == aPropNames.getLength() )
1191  {
1192  for ( int nProp = 0; nProp < aPropNames.getLength(); ++nProp )
1193  {
1194  if ( pValues[nProp].hasValue() )
1195  {
1196  switch ( nProp )
1197  {
1198  case 0:
1199  {
1200  OUString aStr;
1201  pValues[nProp] >>= aStr;
1202  msFontname = aStr;
1203  mbUserDefinedFontname = true;
1204  }
1205  break;
1206  case 1:
1207  case 2:
1208  {
1209  sal_Int16 nTmp = 0;
1210  pValues[nProp] >>= nTmp;
1211  if ( nProp == 1 )
1212  meFontWeight = static_cast<FontWeight>(nTmp);
1213  else if ( nProp == 2 )
1214  meFontItalic = static_cast<FontItalic>(nTmp);
1215  }
1216  break;
1217  case 3:
1218  case 4:
1219  case 5:
1220  case 6:
1221  case 7:
1222  case 8:
1223  case 9:
1224  case 10:
1225  case 11:
1226  case 12:
1227  {
1228  sal_Unicode cChar = sal_Unicode();
1229  pValues[nProp] >>= cChar;
1230  mnLevelChars[nProp-3] = cChar;
1231  }
1232  break;
1233  }
1234  }
1235  }
1236  }
1237 
1238  }
1239 
1240  void SwDefBulletConfig::InitFont()
1241  {
1242  mpFont.reset( new vcl::Font( msFontname, OUString(), Size( 0, 14 ) ) );
1243  mpFont->SetWeight( meFontWeight );
1244  mpFont->SetItalic( meFontItalic );
1245  mpFont->SetCharSet( RTL_TEXTENCODING_SYMBOL );
1246  }
1247 
1248  void SwDefBulletConfig::Notify( const uno::Sequence<OUString>& )
1249  {
1250  SetToDefault();
1251  LoadConfig();
1252  InitFont();
1253  }
1254 
1255  void SwDefBulletConfig::ImplCommit()
1256  {
1257  }
1258 
1259  OUString const & GetDefBulletFontname()
1260  {
1261  return SwDefBulletConfig::getInstance().GetFontname();
1262  }
1263 
1265  {
1266  return SwDefBulletConfig::getInstance().IsFontnameUserDefined();
1267  }
1268 
1270  {
1271  return SwDefBulletConfig::getInstance().GetFont();
1272  }
1273 
1275  {
1276  return SwDefBulletConfig::getInstance().GetChar( nLevel );
1277  }
1278 
1279  namespace {
1280 
1286  class SwNumberingUIBehaviorConfig : private utl::ConfigItem
1287  {
1288  public:
1289  static SwNumberingUIBehaviorConfig& getInstance();
1290 
1292  {
1294  }
1295 
1296  SwNumberingUIBehaviorConfig();
1297 
1298  private:
1299 
1301  void SetToDefault();
1302 
1304  static css::uno::Sequence<OUString> GetPropNames();
1305 
1307  void LoadConfig();
1308 
1310  virtual void Notify( const css::uno::Sequence<OUString>& aPropertyNames ) override;
1311  virtual void ImplCommit() override;
1312 
1313  // configuration data
1315  };
1316 
1317  class theSwNumberingUIBehaviorConfig : public rtl::Static<SwNumberingUIBehaviorConfig, theSwNumberingUIBehaviorConfig>{};
1318  }
1319 
1320  SwNumberingUIBehaviorConfig& SwNumberingUIBehaviorConfig::getInstance()
1321  {
1323  }
1324 
1325  SwNumberingUIBehaviorConfig::SwNumberingUIBehaviorConfig()
1326  : ConfigItem( "Office.Writer/Numbering/UserInterfaceBehavior" ),
1328  {
1329  SetToDefault();
1330  LoadConfig();
1331 
1332  // enable notification for changes on configuration change
1333  EnableNotification( GetPropNames() );
1334  }
1335 
1336  void SwNumberingUIBehaviorConfig::SetToDefault()
1337  {
1339  }
1340 
1341  css::uno::Sequence<OUString> SwNumberingUIBehaviorConfig::GetPropNames()
1342  {
1343  css::uno::Sequence<OUString> aPropNames { "ChangeIndentOnTabAtFirstPosOfFirstListItem" };
1344 
1345  return aPropNames;
1346  }
1347 
1348  void SwNumberingUIBehaviorConfig::ImplCommit() {}
1349 
1350  void SwNumberingUIBehaviorConfig::LoadConfig()
1351  {
1352  css::uno::Sequence<OUString> aPropNames = GetPropNames();
1353  css::uno::Sequence<css::uno::Any> aValues = GetProperties( aPropNames );
1354  const css::uno::Any* pValues = aValues.getConstArray();
1355  OSL_ENSURE( aValues.getLength() == aPropNames.getLength(),
1356  "<SwNumberingUIBehaviorConfig::LoadConfig()> - GetProperties failed");
1357  if ( aValues.getLength() == aPropNames.getLength() )
1358  {
1359  for ( int nProp = 0; nProp < aPropNames.getLength(); ++nProp )
1360  {
1361  if ( pValues[nProp].hasValue() )
1362  {
1363  switch ( nProp )
1364  {
1365  case 0:
1366  {
1368  }
1369  break;
1370  default:
1371  {
1372  OSL_FAIL( "<SwNumberingUIBehaviorConfig::LoadConfig()> - unknown configuration property");
1373  }
1374  }
1375  }
1376  }
1377  }
1378  }
1379 
1380  void SwNumberingUIBehaviorConfig::Notify( const css::uno::Sequence<OUString>& )
1381  {
1382  SetToDefault();
1383  LoadConfig();
1384  }
1385 
1387  {
1388  return SwNumberingUIBehaviorConfig::getInstance().ChangeIndentOnTabAtFirstPosOfFirstListItem();
1389  }
1390 
1392  {
1395 
1397  SvtSaveOptions aSaveOptions;
1398  switch ( aSaveOptions.GetODFDefaultVersion() )
1399  {
1402  {
1403  ePosAndSpaceMode = SvxNumberFormat::LABEL_WIDTH_AND_POSITION;
1404  }
1405  break;
1406  default: // ODFVER_UNKNOWN or ODFVER_012
1407  {
1408  ePosAndSpaceMode = SvxNumberFormat::LABEL_ALIGNMENT;
1409  }
1410  }
1411 
1412  return ePosAndSpaceMode;
1413  }
1414 }
1415 
1417 {
1418  xmlTextWriterStartElement(pWriter, BAD_CAST("SwNumRuleTable"));
1419  for (SwNumRule* pNumRule : *this)
1420  pNumRule->dumpAsXml(pWriter);
1421  xmlTextWriterEndElement(pWriter);
1422 }
1423 
1424 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
virtual SwCharFormat * GetCharFormatFromPool(sal_uInt16 nId)=0
SvxNumberFormat & operator=(const SvxNumberFormat &)
OUString GetNumStr(sal_Int32 nNo) const
SvxNumType GetNumberingType() const
void AddParagraphStyle(SwTextFormatColl &rTextFormatColl)
Definition: number.cxx:1004
sal_uInt16 mnPoolHelpId
HelpId for this Pool-style.
Definition: numrule.hxx:128
void SetLabelFollowedBy(const LabelFollowedBy eLabelFollowedBy)
bool mbHidden
Is the numbering rule to be hidden in the UI?
Definition: numrule.hxx:134
void Add(SwClient *pDepend)
Definition: calbck.cxx:217
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
SwNumFormat & operator=(const SwNumFormat &)
Definition: number.cxx:255
static sal_uInt16 GetBullIndent(sal_uInt8 nLvl)
Definition: number.cxx:165
static void lcl_SetRuleChgd(SwTextNode &rNd, sal_uInt8 nLevel)
Definition: number.cxx:171
virtual void trackChangeOfListStyleName(const OUString &rListStyleName, const OUString &rNewListStyleName)=0
OUString MakeRefNumString(const SwNodeNum &rNodeNum, const bool bInclSuperiorNumLabels, const int nRestrictInclToThisLevel) const
Definition: number.cxx:708
#define RES_ATTRSET_CHG
Definition: hintids.hxx:380
OUString MakeNumString(const SwNodeNum &, bool bInclStrings=true) const
Definition: number.cxx:610
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
Notify the background based on the difference between old and new rectangle.
Definition: frmtool.cxx:3003
SwCharFormat * MakeCharFormat(const OUString &rFormatName, SwCharFormat *pDerivedFrom, bool bBroadcast=false)
Definition: docfmt.cxx:835
const SwNumFormat * GetNumFormat(sal_uInt16 i) const
Definition: number.cxx:87
void SetPositionAndSpaceMode(SvxNumPositionAndSpaceMode ePositionAndSpaceMode)
const SvxBrushItem * GetBrush() const
OUString msFontname
Definition: number.cxx:1107
SVX_NUM_NUMBER_NONE
const short lNumberFirstLineOffset
Definition: swtypes.hxx:114
void AddTextNode(SwTextNode &rTextNode)
Definition: number.cxx:131
SwNumberTreeNode * GetParent() const
Returns the parent of this node.
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames)=0
OUString MakeParagraphStyleListString() const
Definition: number.cxx:798
sal_uInt16 GetPoolFormatId() const
Query and set PoolFormat IDs.
Definition: numrule.hxx:248
const OUString & GetDefaultListId() const
Definition: numrule.hxx:192
Definition: list.hxx:35
sal_Int64 n
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: number.cxx:1035
FontWeight meFontWeight
Definition: number.cxx:1109
Definition: doc.hxx:185
const SvxNumberFormat * Get(sal_uInt16 nLevel) const
void RemoveParagraphStyle(SwTextFormatColl &rTextFormatColl)
Definition: number.cxx:1015
OUString msName
sal_uInt8 mnPoolHlpFileId
FilePos at Doc on style helps.
Definition: numrule.hxx:129
sal_Int16 nId
sal_uInt8 GetIncludeUpperLevels() const
SwNumRuleType
Definition: numrule.hxx:91
virtual bool IsCounted() const override
Return if this node is counted.
Definition: SwNodeNum.cxx:167
const OUString & GetName() const
Definition: numrule.hxx:222
sal_uInt16 GetPoolHelpId() const
Query and set Help-IDs for document styles.
Definition: numrule.hxx:252
SwNumberTree::tNumberVector GetNumberVector() const
Returns level numbers of this node.
bool operator==(const SwNumRule &) const
Definition: number.cxx:550
void SetIncludeUpperLevels(sal_uInt8 nSet)
bool HasNumber() const
Returns if this text node has a number.
Definition: ndtxt.cxx:3086
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: number.cxx:1416
bool mbInvalidRuleFlag
Definition: numrule.hxx:131
SwTextNode * GetTextNode() const
Definition: SwNodeNum.hxx:41
bool operator==(const SwNumFormat &) const
Definition: number.cxx:264
int GetActualListLevel() const
Returns the actual list level of this text node, when it is a list item.
Definition: ndtxt.cxx:4088
int GetLevelInListTree() const
Return level of this node.
static LanguageType nLang
Definition: srtdlg.cxx:60
void StartListeningToSameModifyAs(const SwClient &)
Definition: calbck.cxx:116
sal_uInt16 sal_Unicode
void SetGrabBagItem(const css::uno::Any &rVal)
Definition: number.cxx:1043
bool operator==(const SvxNumberFormat &) const
OUString sSuffix
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:425
sal_Unicode GetBulletChar(sal_uInt8 nLevel)
retrieve unicode of character used for the default bullet list for the given list level ...
Definition: number.cxx:1274
const OUString & GetName() const
Definition: format.hxx:111
static bool IsFuzzing()
void SetCharFormatName(const OUString &rSet)
SVX_NUM_ARABIC
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
bool mbAutoRuleFlag
Definition: numrule.hxx:130
const OUString & GetPrefix() const
void SetNumRuleMap(std::unordered_map< OUString, SwNumRule * > *pNumRuleMap)
Register this rule in a "name->numrule" map.
Definition: number.cxx:153
const OUString & GetSuffix() const
FontItalic meFontItalic
Definition: number.cxx:1110
sal_Unicode mnLevelChars[MAXLEVEL]
Definition: number.cxx:1111
SvxNumRule MakeSvxNumRule() const
Definition: number.cxx:851
void SetFirstLineIndent(const long nFirstLineIndent)
bool IsAlive(typename std::remove_pointer< Value >::type const *const p) const
check that given format is still alive (i.e. contained here)
Definition: docary.hxx:144
void EndListeningAll()
Definition: calbck.cxx:124
void CheckCharFormats(SwDoc *pDoc)
Tests whether the CharFormats are from the given doc and copies them if appropriate.
Definition: number.cxx:513
bool IsContinusNum() const
Definition: numrule.hxx:233
SVX_NUM_BITMAP
bool mbChangeIndentOnTabAtFirstPosOfFirstListItem
Definition: number.cxx:1314
SVX_NUM_CHAR_SPECIAL
WEIGHT_DONTKNOW
SwCharFormat * GetCharFormat() const
Definition: numrule.hxx:73
SwNumRule & CopyNumRule(SwDoc *, const SwNumRule &)
A kind of copy-constructor to make sure the num formats are attached to the correctCharFormats of a d...
Definition: number.cxx:815
SwNumRule(const OUString &rNm, const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode, SwNumRuleType=NUM_RULE)
add parameter
Definition: number.cxx:352
struct _xmlTextWriter * xmlTextWriterPtr
const SwFormatVertOrient * GetGraphicOrientation() const
Definition: number.cxx:340
void SetListtabPos(const long nListtabPos)
std::unique_ptr< SwFormatVertOrient > m_pVertOrient
Definition: numrule.hxx:51
std::unique_ptr< sw::ModifyChangedHint > CheckRegistration(const SfxPoolItem *pOldValue)
Definition: calbck.cxx:78
void SetIndentAt(const long nIndentAt)
LabelFollowedBy GetLabelFollowedBy() const
sal_Int32 GetAbsLSpace() const
std::vector< SwNumRule * >::size_type size_type
Definition: docary.hxx:70
virtual bool IsModified() const =0
Changes of document?
const vcl::Font & GetDefBulletFont()
retrieve font used for the default bullet list characters
Definition: number.cxx:1269
bool IsPhantom() const
Return if this node is a phantom.
int i
bool mbAbsSpaces
Levels represent absolute indents.
Definition: numrule.hxx:133
bool IsEnumeration() const
Definition: number.cxx:227
void RemoveTextNode(SwTextNode &rTextNode)
Definition: number.cxx:142
size_t size() const
Definition: docary.hxx:91
virtual ~SwNumFormat() override
Definition: number.cxx:222
SwNumRuleType meRuleType
Definition: numrule.hxx:126
void SetBulletChar(sal_Unicode cSet)
static OUString GetOutlineRuleName()
Definition: number.cxx:72
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:393
sal_Unicode m_cGrfBulletCP
Definition: numrule.hxx:53
bool IsItemize() const
Definition: number.cxx:235
sal_uInt8 GetPoolHlpFileId() const
Definition: numrule.hxx:254
void GetTextNodeList(SwNumRule::tTextNodeList &rTextNodeList) const
Definition: number.cxx:121
static sal_uInt16 GetNumIndent(sal_uInt8 nLvl)
Definition: number.cxx:159
const short lOutlineMinTextDistance
Definition: swtypes.hxx:115
void SetCountPhantoms(bool bCountPhantoms)
Definition: number.cxx:994
std::unordered_map< OUString, SwNumRule * > * mpNumRuleMap
unordered_map containing "name->rule" relation
Definition: numrule.hxx:123
OUString sPrefix
ITALIC_NONE
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
void SetIndent(const short nNewIndent, const sal_uInt16 nListLevel)
set indent of certain list level to given value
Definition: number.cxx:929
ODFDefaultVersion GetODFDefaultVersion() const
void SetCharTextDistance(short nSet)
SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const
void dumpAsXml(xmlTextWriterPtr w) const
Definition: number.cxx:1026
#define RES_FMT_CHG
Definition: hintids.hxx:379
SAL_DLLPRIVATE void UpdateNumNodes(SwDoc *pDoc)
Definition: number.cxx:315
SwNumRule::tParagraphStyleList::size_type GetParagraphStyleListSize() const
Definition: number.cxx:999
std::unique_ptr< vcl::Font > mpFont
Definition: number.cxx:1114
Provides access to the lists of a document.
void ChangeIndent(const sal_Int32 nDiff)
change indent of all list levels by given difference
Definition: number.cxx:890
std::vector< tSwNumTreeNumber > tNumberVector
long GetIndentAt() const
bool mbContinusNum
Continuous numbering without levels.
Definition: numrule.hxx:132
const SvxNumberFormat::SvxNumPositionAndSpaceMode meDefaultNumberFormatPositionAndSpaceMode
it needs to export as part of tracked numbering change
Definition: numrule.hxx:138
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:77
SwCharFormat * FindCharFormatByName(const OUString &rName) const
Definition: doc.hxx:768
sal_uInt16 nPrefixChars
Definition: numrule.hxx:101
std::unique_ptr< SwNumFormat > maFormats[MAXLEVEL]
Definition: numrule.hxx:114
const PropertyValue * pValues
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
bool IsContinuousNumbering() const
static SwNumFormat * maBaseFormats[RULE_END][MAXLEVEL]
Definition: numrule.hxx:108
FontWeight
void Set(sal_uInt16 i, const SwNumFormat *)
Definition: number.cxx:585
SwNumRule::tTextNodeList::size_type GetTextNodeListSize() const
Definition: number.cxx:126
void Validate()
Definition: number.cxx:981
void SetCharFormat(SwCharFormat *)
Definition: number.cxx:271
const Size & GetGraphicSize() const
void SetInvalidRule(bool bFlag)
Definition: number.cxx:867
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:734
SvxNumberFormat::SvxNumPositionAndSpaceMode GetDefaultPositionAndSpaceMode()
Definition: number.cxx:1391
bool IsDefBulletFontUserDefined()
determine if default bullet font is user defined
Definition: number.cxx:1264
unsigned char sal_uInt8
OUString const & GetDefBulletFontname()
retrieve font family name used for the default bullet list characters
Definition: number.cxx:1259
SwCharFormat * CopyCharFormat(const SwCharFormat &)
copy the char format
Definition: docfmt.cxx:1148
void SetFirstLineOffset(sal_Int32 nSet)
sal_uInt16 nSuffixChars
Definition: numrule.hxx:102
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:253
tTextNodeList maTextNodeList
container for associated text nodes
Definition: numrule.hxx:117
const SwNumRuleTable & GetNumRuleTable() const
Definition: doc.hxx:1061
static sal_uInt16 mnRefCount
Definition: numrule.hxx:112
const sal_uInt16 lNumberIndent
Definition: swtypes.hxx:113
static SwNumFormat * maLabelAlignmentBaseFormats[RULE_END][MAXLEVEL]
default list level properties for position-and-space mode LABEL_ALIGNMENT
Definition: numrule.hxx:111
void SetSvxRule(const SvxNumRule &, SwDoc *pDoc)
Definition: number.cxx:839
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:157
~SwNumRule()
Definition: number.cxx:467
SwNumRule & operator=(const SwNumRule &)
Definition: number.cxx:529
void SetSuffix(const OUString &rSet)
long GetListtabPos() const
sal_Int32 GetFirstLineOffset() const
std::vector< SwTextNode * > tTextNodeList
Definition: numrule.hxx:96
void SetStart(sal_uInt16 nSet)
virtual void SetGraphicBrush(const SvxBrushItem *pBrushItem, const Size *pSize=nullptr, const sal_Int16 *pOrient=nullptr)
virtual void SetGraphicBrush(const SvxBrushItem *pBrushItem, const Size *pSize=nullptr, const sal_Int16 *pOrient=nullptr) override
Definition: number.cxx:307
def text(shape, st)
std::shared_ptr< SfxGrabBagItem > mpGrabBagItem
Style InteropGrabBag.
Definition: numrule.hxx:140
bool IsInDtor() const
Definition: doc.hxx:398
tParagraphStyleList maParagraphStyleList
container for associated paragraph styles
Definition: numrule.hxx:120
void NumRuleChgd()
Notify this textnode that its numbering rule has changed.
Definition: ndtxt.cxx:2844
static const sal_uInt16 maDefNumIndents[MAXLEVEL]
Definition: numrule.hxx:109
bool mbUserDefinedFontname
Definition: number.cxx:1108
void SetAbsLSpace(sal_Int32 nSet)
virtual void ImplCommit()=0
void SetNumberingType(SvxNumType nSet)
void SetName(const OUString &rNm, IDocumentListsAccess &rDocListAccess)
Definition: number.cxx:101
void SetIndentOfFirstListLevelAndChangeOthers(const short nNewIndent)
set indent of first list level to given value and change other list level's indents accordingly ...
Definition: number.cxx:958
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override
Definition: number.cxx:279
void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat &rFmt, bool bIsValid=true)
aStr
virtual OUString GetCharFormatName() const override
Definition: number.cxx:299
sal_uInt16 mnPoolFormatId
Id-for NumRules created "automatically".
Definition: numrule.hxx:127
sal_Int16 GetVertOrient() const
sal_uInt16 Which() const
bool ChangeIndentOnTabAtFirstPosOfFirstListItem()
configuration, if at first position of the first list item the -key increased the indent of the ...
Definition: number.cxx:1386
OUString msName
Definition: numrule.hxx:125
FontItalic
bool mbCountPhantoms
Definition: numrule.hxx:135
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
virtual void ResetModified()=0
namespace for static functions and methods for numbering and bullets
Definition: number.cxx:1051