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