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 "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  mbUsedByRedline( false ),
376  meDefaultNumberFormatPositionAndSpaceMode( eDefaultNumberFormatPositionAndSpaceMode ),
377  msDefaultListId()
378 {
379  if( !mnRefCount++ ) // for the first time, initialize
380  {
381  SwNumFormat* pFormat;
382  sal_uInt8 n;
383 
384  // numbering:
385  // position-and-space mode LABEL_WIDTH_AND_POSITION:
386  for( n = 0; n < MAXLEVEL; ++n )
387  {
388  pFormat = new SwNumFormat;
389  pFormat->SetIncludeUpperLevels( 1 );
390  pFormat->SetStart( 1 );
393  pFormat->SetSuffix( "." );
395  SwNumRule::maBaseFormats[ NUM_RULE ][ n ] = pFormat;
396  }
397  // position-and-space mode LABEL_ALIGNMENT
398  // first line indent of general numbering in inch: -0,25 inch
399  const long cFirstLineIndent = -1440/4;
400  // indent values of general numbering in inch:
401  // 0,5 0,75 1,0 1,25 1,5
402  // 1,75 2,0 2,25 2,5 2,75
403  const long cIndentAt[ MAXLEVEL ] = {
404  1440/2, 1440*3/4, 1440, 1440*5/4, 1440*3/2,
405  1440*7/4, 1440*2, 1440*9/4, 1440*5/2, 1440*11/4 };
406  for( n = 0; n < MAXLEVEL; ++n )
407  {
408  pFormat = new SwNumFormat;
409  pFormat->SetIncludeUpperLevels( 1 );
410  pFormat->SetStart( 1 );
413  pFormat->SetListtabPos( cIndentAt[ n ] );
414  pFormat->SetFirstLineIndent( cFirstLineIndent );
415  pFormat->SetIndentAt( cIndentAt[ n ] );
416  pFormat->SetSuffix( "." );
418  SwNumRule::maLabelAlignmentBaseFormats[ NUM_RULE ][ n ] = pFormat;
419  }
420 
421  // outline:
422  // position-and-space mode LABEL_WIDTH_AND_POSITION:
423  for( n = 0; n < MAXLEVEL; ++n )
424  {
425  pFormat = new SwNumFormat;
427  pFormat->SetIncludeUpperLevels( MAXLEVEL );
428  pFormat->SetStart( 1 );
431  SwNumRule::maBaseFormats[ OUTLINE_RULE ][ n ] = pFormat;
432  }
433  // position-and-space mode LABEL_ALIGNMENT:
434  for( n = 0; n < MAXLEVEL; ++n )
435  {
436  pFormat = new SwNumFormat;
438  pFormat->SetIncludeUpperLevels( MAXLEVEL );
439  pFormat->SetStart( 1 );
442  SwNumRule::maLabelAlignmentBaseFormats[ OUTLINE_RULE ][ n ] = pFormat;
443  }
444  }
445  memset( maFormats, 0, sizeof( maFormats ));
446  OSL_ENSURE( !msName.isEmpty(), "NumRule without a name!" );
447 }
448 
449 SwNumRule::SwNumRule( const SwNumRule& rNumRule )
450  : maTextNodeList(),
451  maParagraphStyleList(),
452  mpNumRuleMap(nullptr),
453  msName( rNumRule.msName ),
454  meRuleType( rNumRule.meRuleType ),
455  mnPoolFormatId( rNumRule.GetPoolFormatId() ),
456  mnPoolHelpId( rNumRule.GetPoolHelpId() ),
457  mnPoolHlpFileId( rNumRule.GetPoolHlpFileId() ),
458  mbAutoRuleFlag( rNumRule.mbAutoRuleFlag ),
459  mbInvalidRuleFlag( true ),
460  mbContinusNum( rNumRule.mbContinusNum ),
461  mbAbsSpaces( rNumRule.mbAbsSpaces ),
462  mbHidden( rNumRule.mbHidden ),
463  mbCountPhantoms( true ),
464  mbUsedByRedline( false ),
465  meDefaultNumberFormatPositionAndSpaceMode( rNumRule.meDefaultNumberFormatPositionAndSpaceMode ),
466  msDefaultListId( rNumRule.msDefaultListId )
467 {
468  ++mnRefCount;
469  for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
470  if( rNumRule.maFormats[ n ] )
471  Set( n, *rNumRule.maFormats[ n ] );
472 }
473 
475 {
476  for (auto & i : maFormats)
477  i.reset();
478 
479  if (mpNumRuleMap)
480  {
481  mpNumRuleMap->erase(GetName());
482  }
483 
484  if( !--mnRefCount ) // the last one closes the door (?)
485  {
486  // Numbering:
487  SwNumFormat** ppFormats = &SwNumRule::maBaseFormats[0][0];
488  int n;
489 
490  for( n = 0; n < MAXLEVEL; ++n, ++ppFormats )
491  {
492  delete *ppFormats;
493  *ppFormats = nullptr;
494  }
495 
496  // Outline:
497  for( n = 0; n < MAXLEVEL; ++n, ++ppFormats )
498  {
499  delete *ppFormats;
500  *ppFormats = nullptr;
501  }
502 
503  ppFormats = &SwNumRule::maLabelAlignmentBaseFormats[0][0];
504  for( n = 0; n < MAXLEVEL; ++n, ++ppFormats )
505  {
506  delete *ppFormats;
507  *ppFormats = nullptr;
508  }
509  for( n = 0; n < MAXLEVEL; ++n, ++ppFormats )
510  {
511  delete *ppFormats;
512  *ppFormats = nullptr;
513  }
514  }
515 
516  maTextNodeList.clear();
517  maParagraphStyleList.clear();
518 }
519 
521 {
522  for(auto& rpNumFormat : maFormats)
523  {
524  SwCharFormat* pFormat;
525  if( rpNumFormat && nullptr != ( pFormat = rpNumFormat->GetCharFormat() ) &&
526  pFormat->GetDoc() != pDoc )
527  {
528  // copy
529  SwNumFormat* pNew = new SwNumFormat( *rpNumFormat );
530  pNew->SetCharFormat( pDoc->CopyCharFormat( *pFormat ) );
531  rpNumFormat.reset(pNew);
532  }
533  }
534 }
535 
537 {
538  if( this != &rNumRule )
539  {
540  for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
541  Set( n, rNumRule.maFormats[ n ].get() );
542 
543  meRuleType = rNumRule.meRuleType;
544  msName = rNumRule.msName;
545  mbAutoRuleFlag = rNumRule.mbAutoRuleFlag;
546  mbInvalidRuleFlag = true;
547  mbContinusNum = rNumRule.mbContinusNum;
548  mbAbsSpaces = rNumRule.mbAbsSpaces;
549  mbHidden = rNumRule.mbHidden;
550  mnPoolFormatId = rNumRule.GetPoolFormatId();
551  mnPoolHelpId = rNumRule.GetPoolHelpId();
552  mnPoolHlpFileId = rNumRule.GetPoolHlpFileId();
553  }
554  return *this;
555 }
556 
557 bool SwNumRule::operator==( const SwNumRule& rRule ) const
558 {
559  bool bRet = meRuleType == rRule.meRuleType &&
560  msName == rRule.msName &&
561  mbAutoRuleFlag == rRule.mbAutoRuleFlag &&
562  mbContinusNum == rRule.mbContinusNum &&
563  mbAbsSpaces == rRule.mbAbsSpaces &&
564  mnPoolFormatId == rRule.GetPoolFormatId() &&
565  mnPoolHelpId == rRule.GetPoolHelpId() &&
567  if( bRet )
568  {
569  for( sal_uInt8 n = 0; n < MAXLEVEL; ++n )
570  if( rRule.Get( n ) != Get( n ) )
571  {
572  bRet = false;
573  break;
574  }
575  }
576  return bRet;
577 }
578 
579 void SwNumRule::Set( sal_uInt16 i, const SwNumFormat& rNumFormat )
580 {
581  OSL_ENSURE( i < MAXLEVEL, "Serious defect" );
582  if( i < MAXLEVEL )
583  {
584  if( !maFormats[ i ] || (rNumFormat != Get( i )) )
585  {
586  maFormats[ i ].reset(new SwNumFormat( rNumFormat ));
587  mbInvalidRuleFlag = true;
588  }
589  }
590 }
591 
592 void SwNumRule::Set( sal_uInt16 i, const SwNumFormat* pNumFormat )
593 {
594  OSL_ENSURE( i < MAXLEVEL, "Serious defect" );
595  if( i >= MAXLEVEL )
596  return;
597  if( !maFormats[ i ] )
598  {
599  if( pNumFormat )
600  {
601  maFormats[ i ].reset(new SwNumFormat( *pNumFormat ));
602  mbInvalidRuleFlag = true;
603  }
604  }
605  else if( !pNumFormat )
606  {
607  maFormats[ i ].reset();
608  mbInvalidRuleFlag = true;
609  }
610  else if( *maFormats[i] != *pNumFormat )
611  {
612  *maFormats[ i ] = *pNumFormat;
613  mbInvalidRuleFlag = true;
614  }
615 }
616 
617 OUString SwNumRule::MakeNumString( const SwNodeNum& rNum, bool bInclStrings ) const
618 {
619  if (rNum.IsCounted())
620  return MakeNumString(rNum.GetNumberVector(), bInclStrings);
621 
622  return OUString();
623 }
624 
626  const bool bInclStrings,
627  const bool bOnlyArabic,
628  const unsigned int _nRestrictToThisLevel,
629  SwNumRule::Extremities* pExtremities,
630  LanguageType nLang ) const
631 {
632  OUStringBuffer aStr;
633 
634  SwNumberTree::tNumberVector::size_type nLevel = rNumVector.size() - 1;
635 
636  if ( pExtremities )
637  pExtremities->nPrefixChars = pExtremities->nSuffixChars = 0;
638 
639  if ( nLevel > _nRestrictToThisLevel )
640  {
641  nLevel = _nRestrictToThisLevel;
642  }
643 
644  if (nLevel < MAXLEVEL)
645  {
646  const SwNumFormat& rMyNFormat = Get( static_cast<sal_uInt16>(nLevel) );
647 
648  {
649  SwNumberTree::tNumberVector::size_type i = nLevel;
650 
651  if( !IsContinusNum() &&
652  // - do not include upper levels, if level isn't numbered.
653  rMyNFormat.GetNumberingType() != SVX_NUM_NUMBER_NONE &&
654  rMyNFormat.GetIncludeUpperLevels() ) // Just the own level?
655  {
656  sal_uInt8 n = rMyNFormat.GetIncludeUpperLevels();
657  if( 1 < n )
658  {
659  if( i+1 >= n )
660  i -= n - 1;
661  else
662  i = 0;
663  }
664  }
665 
666  css::lang::Locale aLocale( LanguageTag::convertToLocale(nLang));
667 
668  for( ; i <= nLevel; ++i )
669  {
670  const SwNumFormat& rNFormat = Get( i );
671  if( SVX_NUM_NUMBER_NONE == rNFormat.GetNumberingType() )
672  {
673  // Should 1.1.1 --> 2. NoNum --> 1..1 or 1.1 ??
674  // if( i != rNum.nMyLevel )
675  // aStr += ".";
676  continue;
677  }
678 
679  if( rNumVector[ i ] )
680  {
681  if( bOnlyArabic )
682  aStr.append(OUString::number( rNumVector[ i ] ));
683  else
684  aStr.append(rNFormat.GetNumStr( rNumVector[ i ], aLocale ));
685  }
686  else
687  aStr.append("0"); // all 0 level are a 0
688  if( i != nLevel && !aStr.isEmpty() )
689  aStr.append(".");
690  }
691 
692  // The type doesn't have any number, so don't append
693  // the post-/prefix string
694  if( bInclStrings && !bOnlyArabic &&
695  SVX_NUM_CHAR_SPECIAL != rMyNFormat.GetNumberingType() &&
696  SVX_NUM_BITMAP != rMyNFormat.GetNumberingType() )
697  {
698  const OUString& sPrefix = rMyNFormat.GetPrefix();
699  const OUString& sSuffix = rMyNFormat.GetSuffix();
700 
701  aStr.insert(0, sPrefix);
702  aStr.append(sSuffix);
703  if ( pExtremities )
704  {
705  pExtremities->nPrefixChars = sPrefix.getLength();
706  pExtremities->nSuffixChars = sSuffix.getLength();
707  }
708  }
709  }
710  }
711 
712  return aStr.makeStringAndClear();
713 }
714 
715 OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
716  const bool bInclSuperiorNumLabels,
717  const int nRestrictInclToThisLevel ) const
718 {
719  OUString aRefNumStr;
720 
721  if ( rNodeNum.GetLevelInListTree() >= 0 )
722  {
723  bool bOldHadPrefix = true;
724 
725  const SwNodeNum* pWorkingNodeNum( &rNodeNum );
726  do
727  {
728  bool bMakeNumStringForPhantom( false );
729  if ( pWorkingNodeNum->IsPhantom() )
730  {
731  int nListLevel = pWorkingNodeNum->GetLevelInListTree();
732 
733  if (nListLevel < 0)
734  nListLevel = 0;
735 
736  if (nListLevel >= MAXLEVEL)
737  nListLevel = MAXLEVEL - 1;
738 
739  SwNumFormat aFormat( Get( static_cast<sal_uInt16>(nListLevel) ) );
740  bMakeNumStringForPhantom = aFormat.IsEnumeration() &&
742 
743  }
744  if ( bMakeNumStringForPhantom ||
745  ( !pWorkingNodeNum->IsPhantom() &&
746  pWorkingNodeNum->GetTextNode() &&
747  pWorkingNodeNum->GetTextNode()->HasNumber() ) )
748  {
749  Extremities aExtremities;
750  OUString aPrevStr = MakeNumString( pWorkingNodeNum->GetNumberVector(),
751  true, false, MAXLEVEL,
752  &aExtremities);
753  sal_Int32 nStrip = 0;
754  while ( nStrip < aExtremities.nPrefixChars )
755  {
756  const sal_Unicode c = aPrevStr[nStrip];
757  if ( c!='\t' && c!=' ')
758  break;
759  ++nStrip;
760  }
761 
762  if (nStrip)
763  {
764  aPrevStr = aPrevStr.copy( nStrip );
765  aExtremities.nPrefixChars -= nStrip;
766  }
767 
768  if (bOldHadPrefix &&
769  aExtremities.nSuffixChars &&
770  !aExtremities.nPrefixChars
771  )
772  {
773  aPrevStr = aPrevStr.copy(0,
774  aPrevStr.getLength() - aExtremities.nSuffixChars);
775  }
776 
777  bOldHadPrefix = ( aExtremities.nPrefixChars > 0);
778 
779  aRefNumStr = aPrevStr + aRefNumStr;
780  }
781 
782  if ( bInclSuperiorNumLabels && pWorkingNodeNum->GetLevelInListTree() > 0 )
783  {
784  sal_uInt8 n = Get( static_cast<sal_uInt16>(pWorkingNodeNum->GetLevelInListTree()) ).GetIncludeUpperLevels();
785  pWorkingNodeNum = dynamic_cast<SwNodeNum*>(pWorkingNodeNum->GetParent());
786  // skip parents, whose list label is already contained in the actual list label.
787  while ( pWorkingNodeNum && n > 1 )
788  {
789  pWorkingNodeNum = dynamic_cast<SwNodeNum*>(pWorkingNodeNum->GetParent());
790  --n;
791  }
792  }
793  else
794  {
795  break;
796  }
797  } while ( pWorkingNodeNum &&
798  pWorkingNodeNum->GetLevelInListTree() >= 0 &&
799  pWorkingNodeNum->GetLevelInListTree() >= nRestrictInclToThisLevel );
800  }
801 
802  return aRefNumStr;
803 }
804 
811 {
812  for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
813  {
814  Set( n, rNumRule.maFormats[ n ].get() );
815  if( maFormats[ n ] && maFormats[ n ]->GetCharFormat() &&
816  !pDoc->GetCharFormats()->IsAlive(maFormats[n]->GetCharFormat()))
817  {
818  // If we copy across different Documents, then copy the
819  // corresponding CharFormat into the new Document.
820  maFormats[n]->SetCharFormat( pDoc->CopyCharFormat( *maFormats[n]->
821  GetCharFormat() ) );
822  }
823  }
824  meRuleType = rNumRule.meRuleType;
825  msName = rNumRule.msName;
826  mbAutoRuleFlag = rNumRule.mbAutoRuleFlag;
827  mnPoolFormatId = rNumRule.GetPoolFormatId();
828  mnPoolHelpId = rNumRule.GetPoolHelpId();
829  mnPoolHlpFileId = rNumRule.GetPoolHlpFileId();
830  mbInvalidRuleFlag = true;
831  return *this;
832 }
833 
834 void SwNumRule::SetSvxRule(const SvxNumRule& rNumRule, SwDoc* pDoc)
835 {
836  for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
837  {
838  const SvxNumberFormat* pSvxFormat = rNumRule.Get(n);
839  maFormats[n].reset( pSvxFormat ? new SwNumFormat(*pSvxFormat, pDoc) : nullptr );
840  }
841 
842  mbInvalidRuleFlag = true;
844 }
845 
847 {
848  SvxNumRule aRule(SvxNumRuleFlags::CONTINUOUS | SvxNumRuleFlags::CHAR_STYLE |
849  SvxNumRuleFlags::ENABLE_LINKED_BMP | SvxNumRuleFlags::ENABLE_EMBEDDED_BMP,
851  meRuleType == NUM_RULE ? SvxNumRuleType::NUMBERING : SvxNumRuleType::OUTLINE_NUMBERING );
852  for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
853  {
854  SwNumFormat aNumFormat = Get(n);
855  if(aNumFormat.GetCharFormat())
856  aNumFormat.SetCharFormatName(aNumFormat.GetCharFormat()->GetName());
857  aRule.SetLevel(n, aNumFormat, maFormats[n] != nullptr);
858  }
859  return aRule;
860 }
861 
863 {
864  if (bFlag)
865  {
866  std::set< SwList* > aLists;
867  for ( const SwTextNode* pTextNode : maTextNodeList )
868  {
869  // #i111681# - applying patch from cmc
870  SwList* pList = pTextNode->GetDoc()->getIDocumentListsAccess().getListByName( pTextNode->GetListId() );
871  OSL_ENSURE( pList, "<SwNumRule::SetInvalidRule(..)> - list at which the text node is registered at does not exist. This is a serious issue.");
872  if ( pList )
873  {
874  aLists.insert( pList );
875  }
876  }
877  for ( auto aList : aLists )
878  aList->InvalidateListTree();
879  }
880 
881  mbInvalidRuleFlag = bFlag;
882 }
883 
885 void SwNumRule::ChangeIndent( const sal_Int32 nDiff )
886 {
887  for ( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
888  {
889  SwNumFormat aTmpNumFormat( Get(i) );
890 
891  const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode(
892  aTmpNumFormat.GetPositionAndSpaceMode() );
893  if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
894  {
895  auto nNewIndent = nDiff +
896  aTmpNumFormat.GetAbsLSpace();
897  if ( nNewIndent < 0 )
898  {
899  nNewIndent = 0;
900  }
901  aTmpNumFormat.SetAbsLSpace( nNewIndent );
902  }
903  else if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
904  {
905  // adjust also the list tab position, if a list tab stop is applied
906  if ( aTmpNumFormat.GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
907  {
908  const long nNewListTab = aTmpNumFormat.GetListtabPos() + nDiff;
909  aTmpNumFormat.SetListtabPos( nNewListTab );
910  }
911 
912  const long nNewIndent = nDiff +
913  aTmpNumFormat.GetIndentAt();
914  aTmpNumFormat.SetIndentAt( nNewIndent );
915  }
916 
917  Set( i, aTmpNumFormat );
918  }
919 
920  SetInvalidRule( true );
921 }
922 
924 void SwNumRule::SetIndent( const short nNewIndent,
925  const sal_uInt16 nListLevel )
926 {
927  SwNumFormat aTmpNumFormat( Get(nListLevel) );
928 
929  const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode(
930  aTmpNumFormat.GetPositionAndSpaceMode() );
931  if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
932  {
933  aTmpNumFormat.SetAbsLSpace( nNewIndent );
934  }
935  else if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
936  {
937  // adjust also the list tab position, if a list tab stop is applied
938  if ( aTmpNumFormat.GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
939  {
940  const long nNewListTab = aTmpNumFormat.GetListtabPos() +
941  ( nNewIndent - aTmpNumFormat.GetIndentAt() );
942  aTmpNumFormat.SetListtabPos( nNewListTab );
943  }
944 
945  aTmpNumFormat.SetIndentAt( nNewIndent );
946  }
947 
948  SetInvalidRule( true );
949 }
950 
954 {
955  SwNumFormat aTmpNumFormat( Get(0) );
956 
957  sal_Int32 nDiff( 0 );
958  const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode(
959  aTmpNumFormat.GetPositionAndSpaceMode() );
960  if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
961  {
962  nDiff = nNewIndent
963  - aTmpNumFormat.GetFirstLineOffset()
964  - aTmpNumFormat.GetAbsLSpace();
965  }
966  else if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
967  {
968  nDiff = nNewIndent - aTmpNumFormat.GetIndentAt();
969  }
970  if ( nDiff != 0 )
971  {
972  ChangeIndent( nDiff );
973  }
974 }
975 
977 {
978  std::set< SwList* > aLists;
979  for ( const SwTextNode* pTextNode : maTextNodeList )
980  {
981  aLists.insert( pTextNode->GetDoc()->getIDocumentListsAccess().getListByName( pTextNode->GetListId() ) );
982  }
983  for ( auto aList : aLists )
984  aList->ValidateListTree();
985 
986  SetInvalidRule(false);
987 }
988 
989 void SwNumRule::SetCountPhantoms(bool bCountPhantoms)
990 {
991  mbCountPhantoms = bCountPhantoms;
992 }
993 
994 SwNumRule::tParagraphStyleList::size_type SwNumRule::GetParagraphStyleListSize() const
995 {
996  return maParagraphStyleList.size();
997 }
998 
1000 {
1001  tParagraphStyleList::iterator aIter =
1002  std::find( maParagraphStyleList.begin(), maParagraphStyleList.end(), &rTextFormatColl );
1003 
1004  if ( aIter == maParagraphStyleList.end() )
1005  {
1006  maParagraphStyleList.push_back( &rTextFormatColl );
1007  }
1008 }
1009 
1011 {
1012  tParagraphStyleList::iterator aIter =
1013  std::find( maParagraphStyleList.begin(), maParagraphStyleList.end(), &rTextFormatColl );
1014 
1015  if ( aIter != maParagraphStyleList.end() )
1016  {
1017  maParagraphStyleList.erase( aIter );
1018  }
1019 }
1020 
1022 {
1023  xmlTextWriterStartElement(pWriter, BAD_CAST("SwNumRule"));
1024  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("msName"), BAD_CAST(msName.toUtf8().getStr()));
1025  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("mnPoolFormatId"), BAD_CAST(OString::number(mnPoolFormatId).getStr()));
1026  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("mbAutoRuleFlag"), BAD_CAST(OString::boolean(mbAutoRuleFlag).getStr()));
1027  xmlTextWriterEndElement(pWriter);
1028 }
1029 
1031 {
1032  if (mpGrabBagItem.get())
1033  mpGrabBagItem->QueryValue(rVal);
1034  else
1035  rVal <<= uno::Sequence<beans::PropertyValue>();
1036 }
1037 
1039 {
1040  if (!mpGrabBagItem.get())
1041  mpGrabBagItem.reset(new SfxGrabBagItem);
1042 
1043  mpGrabBagItem->PutValue(rVal, 0);
1044 }
1045 
1046 namespace numfunc
1047 {
1050  {
1051  public:
1052  static SwDefBulletConfig& getInstance();
1053 
1054  const OUString& GetFontname() const
1055  {
1056  return msFontname;
1057  }
1058 
1060  {
1061  return mbUserDefinedFontname;
1062  }
1063 
1064  const vcl::Font& GetFont() const
1065  {
1066  return *mpFont;
1067  }
1068 
1069  sal_Unicode GetChar( sal_uInt8 p_nListLevel ) const
1070  {
1071  if (p_nListLevel >= MAXLEVEL)
1072  {
1073  p_nListLevel = MAXLEVEL - 1;
1074  }
1075 
1076  return mnLevelChars[p_nListLevel];
1077  }
1078 
1080 
1081  private:
1083  void SetToDefault();
1084 
1086  static uno::Sequence<OUString> GetPropNames();
1087 
1090  void LoadConfig();
1091 
1093  void InitFont();
1094 
1096  virtual void Notify( const uno::Sequence<OUString>& aPropertyNames ) override;
1097  virtual void ImplCommit() override;
1098 
1099  // default bullet list configuration data
1100  OUString msFontname;
1105 
1106  // default bullet list font instance
1107  std::unique_ptr<vcl::Font> mpFont;
1108  };
1109 
1110  namespace
1111  {
1112  class theSwDefBulletConfig
1113  : public rtl::Static<SwDefBulletConfig, theSwDefBulletConfig>{};
1114  }
1115 
1117  {
1118  return theSwDefBulletConfig::get();
1119  }
1120 
1122  : ConfigItem( "Office.Writer/Numbering/DefaultBulletList" ),
1123  // default bullet font is now OpenSymbol
1124  msFontname( OUString("OpenSymbol") ),
1125  mbUserDefinedFontname( false ),
1126  meFontWeight( WEIGHT_DONTKNOW ),
1127  meFontItalic( ITALIC_NONE )
1128  {
1129  SetToDefault();
1130  LoadConfig();
1131  InitFont();
1132 
1133  // enable notification for changes on default bullet configuration change
1135  }
1136 
1138  {
1139  msFontname = "OpenSymbol";
1140  mbUserDefinedFontname = false;
1143 
1144  mnLevelChars[0] = 0x2022;
1145  mnLevelChars[1] = 0x25e6;
1146  mnLevelChars[2] = 0x25aa;
1147  mnLevelChars[3] = 0x2022;
1148  mnLevelChars[4] = 0x25e6;
1149  mnLevelChars[5] = 0x25aa;
1150  mnLevelChars[6] = 0x2022;
1151  mnLevelChars[7] = 0x25e6;
1152  mnLevelChars[8] = 0x25aa;
1153  mnLevelChars[9] = 0x2022;
1154  }
1155 
1156  uno::Sequence<OUString> SwDefBulletConfig::GetPropNames()
1157  {
1158  uno::Sequence<OUString> aPropNames(13);
1159  OUString* pNames = aPropNames.getArray();
1160  pNames[0] = "BulletFont/FontFamilyname";
1161  pNames[1] = "BulletFont/FontWeight";
1162  pNames[2] = "BulletFont/FontItalic";
1163  pNames[3] = "BulletCharLvl1";
1164  pNames[4] = "BulletCharLvl2";
1165  pNames[5] = "BulletCharLvl3";
1166  pNames[6] = "BulletCharLvl4";
1167  pNames[7] = "BulletCharLvl5";
1168  pNames[8] = "BulletCharLvl6";
1169  pNames[9] = "BulletCharLvl7";
1170  pNames[10] = "BulletCharLvl8";
1171  pNames[11] = "BulletCharLvl9";
1172  pNames[12] = "BulletCharLvl10";
1173 
1174  return aPropNames;
1175  }
1176 
1178  {
1179  uno::Sequence<OUString> aPropNames = GetPropNames();
1180  uno::Sequence<uno::Any> aValues =
1181  GetProperties( aPropNames );
1182  const uno::Any* pValues = aValues.getConstArray();
1183  OSL_ENSURE( aValues.getLength() == aPropNames.getLength(),
1184  "<SwDefBulletConfig::SwDefBulletConfig()> - GetProperties failed");
1185  if ( aValues.getLength() == aPropNames.getLength() )
1186  {
1187  for ( int nProp = 0; nProp < aPropNames.getLength(); ++nProp )
1188  {
1189  if ( pValues[nProp].hasValue() )
1190  {
1191  switch ( nProp )
1192  {
1193  case 0:
1194  {
1195  OUString aStr;
1196  pValues[nProp] >>= aStr;
1197  msFontname = aStr;
1198  mbUserDefinedFontname = true;
1199  }
1200  break;
1201  case 1:
1202  case 2:
1203  {
1204  sal_Int16 nTmp = 0;
1205  pValues[nProp] >>= nTmp;
1206  if ( nProp == 1 )
1207  meFontWeight = static_cast<FontWeight>(nTmp);
1208  else if ( nProp == 2 )
1209  meFontItalic = static_cast<FontItalic>(nTmp);
1210  }
1211  break;
1212  case 3:
1213  case 4:
1214  case 5:
1215  case 6:
1216  case 7:
1217  case 8:
1218  case 9:
1219  case 10:
1220  case 11:
1221  case 12:
1222  {
1223  sal_Unicode cChar = sal_Unicode();
1224  pValues[nProp] >>= cChar;
1225  mnLevelChars[nProp-3] = cChar;
1226  }
1227  break;
1228  }
1229  }
1230  }
1231  }
1232 
1233  }
1234 
1236  {
1237  mpFont.reset( new vcl::Font( msFontname, OUString(), Size( 0, 14 ) ) );
1238  mpFont->SetWeight( meFontWeight );
1239  mpFont->SetItalic( meFontItalic );
1240  mpFont->SetCharSet( RTL_TEXTENCODING_SYMBOL );
1241  }
1242 
1243  void SwDefBulletConfig::Notify( const uno::Sequence<OUString>& )
1244  {
1245  SetToDefault();
1246  LoadConfig();
1247  InitFont();
1248  }
1249 
1251  {
1252  }
1253 
1254  OUString const & GetDefBulletFontname()
1255  {
1257  }
1258 
1260  {
1262  }
1263 
1265  {
1267  }
1268 
1270  {
1271  return SwDefBulletConfig::getInstance().GetChar( nLevel );
1272  }
1273 
1280  {
1281  public:
1283 
1285  {
1287  }
1288 
1290 
1291  private:
1292 
1294  void SetToDefault();
1295 
1297  static css::uno::Sequence<OUString> GetPropNames();
1298 
1300  void LoadConfig();
1301 
1303  virtual void Notify( const css::uno::Sequence<OUString>& aPropertyNames ) override;
1304  virtual void ImplCommit() override;
1305 
1306  // configuration data
1308  };
1309 
1310  namespace
1311  {
1312  class theSwNumberingUIBehaviorConfig : public rtl::Static<SwNumberingUIBehaviorConfig, theSwNumberingUIBehaviorConfig>{};
1313  }
1314 
1316  {
1318  }
1319 
1321  : ConfigItem( "Office.Writer/Numbering/UserInterfaceBehavior" ),
1322  mbChangeIndentOnTabAtFirstPosOfFirstListItem( true )
1323  {
1324  SetToDefault();
1325  LoadConfig();
1326 
1327  // enable notification for changes on configuration change
1329  }
1330 
1332  {
1334  }
1335 
1336  css::uno::Sequence<OUString> SwNumberingUIBehaviorConfig::GetPropNames()
1337  {
1338  css::uno::Sequence<OUString> aPropNames { "ChangeIndentOnTabAtFirstPosOfFirstListItem" };
1339 
1340  return aPropNames;
1341  }
1342 
1344 
1346  {
1347  css::uno::Sequence<OUString> aPropNames = GetPropNames();
1348  css::uno::Sequence<css::uno::Any> aValues = GetProperties( aPropNames );
1349  const css::uno::Any* pValues = aValues.getConstArray();
1350  OSL_ENSURE( aValues.getLength() == aPropNames.getLength(),
1351  "<SwNumberingUIBehaviorConfig::LoadConfig()> - GetProperties failed");
1352  if ( aValues.getLength() == aPropNames.getLength() )
1353  {
1354  for ( int nProp = 0; nProp < aPropNames.getLength(); ++nProp )
1355  {
1356  if ( pValues[nProp].hasValue() )
1357  {
1358  switch ( nProp )
1359  {
1360  case 0:
1361  {
1363  }
1364  break;
1365  default:
1366  {
1367  OSL_FAIL( "<SwNumberingUIBehaviorConfig::LoadConfig()> - unknown configuration property");
1368  }
1369  }
1370  }
1371  }
1372  }
1373  }
1374 
1375  void SwNumberingUIBehaviorConfig::Notify( const css::uno::Sequence<OUString>& )
1376  {
1377  SetToDefault();
1378  LoadConfig();
1379  }
1380 
1382  {
1384  }
1385 
1387  {
1390 
1392  SvtSaveOptions aSaveOptions;
1393  switch ( aSaveOptions.GetODFDefaultVersion() )
1394  {
1397  {
1398  ePosAndSpaceMode = SvxNumberFormat::LABEL_WIDTH_AND_POSITION;
1399  }
1400  break;
1401  default: // ODFVER_UNKNOWN or ODFVER_012
1402  {
1403  ePosAndSpaceMode = SvxNumberFormat::LABEL_ALIGNMENT;
1404  }
1405  }
1406 
1407  return ePosAndSpaceMode;
1408  }
1409 }
1410 
1412 {
1413  xmlTextWriterStartElement(pWriter, BAD_CAST("SwNumRuleTable"));
1414  for (SwNumRule* pNumRule : *this)
1415  pNumRule->dumpAsXml(pWriter);
1416  xmlTextWriterEndElement(pWriter);
1417 }
1418 
1419 /* 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:1104
void AddParagraphStyle(SwTextFormatColl &rTextFormatColl)
Definition: number.cxx:999
virtual void Notify(const uno::Sequence< OUString > &aPropertyNames) override
catches notification about changed default bullet configuration data
Definition: number.cxx:1243
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:715
bool ChangeIndentOnTabAtFirstPosOfFirstListItem() const
Definition: number.cxx:1284
#define RES_ATTRSET_CHG
Definition: hintids.hxx:285
OUString MakeNumString(const SwNodeNum &, bool bInclStrings=true) const
Definition: number.cxx:617
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:1116
void AddTextNode(SwTextNode &rTextNode)
Definition: number.cxx:137
static SwNumberingUIBehaviorConfig & getInstance()
Definition: number.cxx:1315
SwNumberTreeNode * GetParent() const
Returns the parent of this node.
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
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: number.cxx:1030
Definition: doc.hxx:185
const SvxNumberFormat * Get(sal_uInt16 nLevel) const
void RemoveParagraphStyle(SwTextFormatColl &rTextFormatColl)
Definition: number.cxx:1010
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: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.
class containing configuration data about user interface behavior regarding lists and list items...
Definition: number.cxx:1279
bool operator==(const SwNumRule &) const
Definition: number.cxx:557
void SetIncludeUpperLevels(sal_uInt8 nSet)
bool HasNumber() const
Returns if this text node has a number.
Definition: ndtxt.cxx:3095
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: number.cxx:1411
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:4096
int GetLevelInListTree() const
Return level of this node.
static LanguageType nLang
Definition: srtdlg.cxx:60
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:1038
bool operator==(const SvxNumberFormat &) const
const vcl::Font & GetFont() const
Definition: number.cxx:1064
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:1269
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:1235
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:1177
const OUString & GetSuffix() const
SvxNumRule MakeSvxNumRule() const
Definition: number.cxx:846
void SetFirstLineIndent(const long nFirstLineIndent)
bool IsAlive(typename std::remove_pointer< Value >::type const *const p) const
check that given format is still alive (i.e. contained here)
Definition: docary.hxx:144
void EndListeningAll()
Definition: calbck.cxx:124
void CheckCharFormats(SwDoc *pDoc)
Tests whether the CharFormats are from the given doc and copies them if appropriate.
Definition: number.cxx:520
bool IsContinusNum() const
Definition: numrule.hxx:233
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:1343
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:810
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:1059
LabelFollowedBy GetLabelFollowedBy() const
sal_Int32 GetAbsLSpace() const
void LoadConfig()
loads configuration properties and applies values to internal data
Definition: number.cxx:1345
std::vector< SwNumRule * >::size_type size_type
Definition: docary.hxx:70
virtual bool IsModified() const =0
Changes of document?
const vcl::Font & GetDefBulletFont()
retrieve font used for the default bullet list characters
Definition: number.cxx:1264
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:91
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:1069
sal_Unicode m_cGrfBulletCP
Definition: numrule.hxx:53
bool IsItemize() const
Definition: number.cxx:241
sal_uInt8 GetPoolHlpFileId() const
Definition: numrule.hxx:254
void SetToDefault()
sets internal default bullet configuration data to default values
Definition: number.cxx:1137
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:989
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:924
virtual void ImplCommit() override
Definition: number.cxx:1250
ODFDefaultVersion GetODFDefaultVersion() const
void SetCharTextDistance(short nSet)
void SetToDefault()
sets internal configuration data to default values
Definition: number.cxx:1331
SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const
void dumpAsXml(xmlTextWriterPtr w) const
Definition: number.cxx:1021
#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:994
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:885
std::vector< tSwNumTreeNumber > tNumberVector
long GetIndentAt() const
bool mbContinusNum
Continuous numbering without levels.
Definition: numrule.hxx:133
const SvxNumberFormat::SvxNumPositionAndSpaceMode meDefaultNumberFormatPositionAndSpaceMode
it needs to export as part of tracked numbering change
Definition: numrule.hxx:139
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:83
SwCharFormat * FindCharFormatByName(const OUString &rName) const
Definition: doc.hxx:767
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:592
SwNumRule::tTextNodeList::size_type GetTextNodeListSize() const
Definition: number.cxx:132
void Validate()
Definition: number.cxx:976
void SetCharFormat(SwCharFormat *)
Definition: number.cxx:277
const Size & GetGraphicSize() const
void SetInvalidRule(bool bFlag)
Definition: number.cxx:862
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:733
SvxNumberFormat::SvxNumPositionAndSpaceMode GetDefaultPositionAndSpaceMode()
Definition: number.cxx:1386
const OUString & GetFontname() const
Definition: number.cxx:1054
static uno::Sequence< OUString > GetPropNames()
returns sequence of default bullet configuration property names
Definition: number.cxx:1156
bool IsDefBulletFontUserDefined()
determine if default bullet font is user defined
Definition: number.cxx:1259
unsigned char sal_uInt8
OUString const & GetDefBulletFontname()
retrieve font family name used for the default bullet list characters
Definition: number.cxx:1254
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:261
tTextNodeList maTextNodeList
container for associated text nodes
Definition: numrule.hxx:118
const SwNumRuleTable & GetNumRuleTable() const
Definition: doc.hxx:1056
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:834
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:157
~SwNumRule()
Definition: number.cxx:474
SwNumRule & operator=(const SwNumRule &)
Definition: number.cxx:536
static css::uno::Sequence< OUString > GetPropNames()
returns sequence of configuration property names
Definition: number.cxx:1336
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:1375
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:141
bool IsInDtor() const
Definition: doc.hxx:397
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:2853
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:1049
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:953
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:1381
OUString msName
Definition: numrule.hxx:126
FontItalic
std::unique_ptr< vcl::Font > mpFont
Definition: number.cxx:1107
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:1046