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