LibreOffice Module sw (master)  1
wrtw8num.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 <hintids.hxx>
21 #include <vcl/font.hxx>
22 #include <editeng/fontitem.hxx>
23 #include <editeng/lrspitem.hxx>
24 #include <editeng/langitem.hxx>
25 #include <doc.hxx>
26 #include <docary.hxx>
27 #include <numrule.hxx>
28 #include <paratr.hxx>
29 #include <charfmt.hxx>
30 #include <ndtxt.hxx>
31 #include <unotools/fontcfg.hxx>
32 #include <com/sun/star/i18n/ScriptType.hpp>
33 
34 #include "sprmids.hxx"
35 
36 #include "ww8attributeoutput.hxx"
37 #include "writerhelper.hxx"
38 #include "writerwordglue.hxx"
39 #include "wrtww8.hxx"
40 #include "ww8par.hxx"
41 
42 #include <mutex>
43 #include <numeric>
44 
45 using namespace ::com::sun::star;
46 using namespace sw::types;
47 using namespace sw::util;
48 
50 {
51  const OUString sPrefix("WW8TempExport" + OUString::number( m_nUniqueList++ ));
52  SwNumRule* pMyNumRule =
53  new SwNumRule( m_pDoc->GetUniqueNumRuleName( &sPrefix ),
55  m_pUsedNumTable->push_back( pMyNumRule );
56 
57  for ( sal_uInt16 i = 0; i < MAXLEVEL; i++ )
58  {
59  const SwNumFormat& rSubRule = pRule->Get(i);
60  pMyNumRule->Set( i, rSubRule );
61  }
62  return pMyNumRule;
63 }
64 
65 sal_uInt16 MSWordExportBase::DuplicateNumRule( const SwNumRule *pRule, sal_uInt8 nLevel, sal_uInt16 nVal )
66 {
67  sal_uInt16 nNumId = USHRT_MAX;
68 
69  SwNumRule *const pMyNumRule = DuplicateNumRuleImpl(pRule);
70 
71  SwNumFormat aNumFormat( pMyNumRule->Get( nLevel ) );
72  aNumFormat.SetStart( nVal );
73  pMyNumRule->Set( nLevel, aNumFormat );
74 
75  nNumId = GetNumberingId( *pMyNumRule );
76 
77  // Map the old list to our new list
78  m_aRuleDuplicates[GetNumberingId( *pRule )] = nNumId;
79 
80  return nNumId;
81 }
82 
83 // multiple SwList can be based on the same SwNumRule; ensure one w:abstractNum
84 // per SwList
85 sal_uInt16 MSWordExportBase::DuplicateAbsNum(OUString const& rListId,
86  SwNumRule const& rAbstractRule)
87 {
88  auto const it(m_Lists.find(rListId));
89  if (it != m_Lists.end())
90  {
91  return it->second;
92  }
93  else
94  {
95  auto const pNewAbstractRule = DuplicateNumRuleImpl(&rAbstractRule);
96  assert(GetNumberingId(*pNewAbstractRule) == m_pUsedNumTable->size() - 1);
97  (void) pNewAbstractRule;
98  m_Lists.insert(std::make_pair(rListId, m_pUsedNumTable->size() - 1));
99  return m_pUsedNumTable->size() - 1;
100  }
101 }
102 
103 // Ideally we want to map SwList to w:abstractNum and SwNumRule to w:num
104 // The current approach is to keep exporting every SwNumRule to
105 // 1 w:abstractNum and 1 w:num, and then add extra w:num via this function
106 // that reference an existing w:abstractNum and may override its formatting;
107 // of course this will end up exporting some w:num that aren't actually used.
109  SwNumRule const& rExistingRule,
110  OUString const& rListId,
111  SwNumRule const& rAbstractRule)
112 {
113  assert(&rExistingRule != &rAbstractRule);
114  auto const numdef = GetNumberingId(rExistingRule);
115  auto const absnumdef = rListId == rAbstractRule.GetDefaultListId()
116  ? GetNumberingId(rAbstractRule)
117  : DuplicateAbsNum(rListId, rAbstractRule);
118  auto const mapping = std::make_pair(numdef, absnumdef);
119 
120  auto it = m_OverridingNumsR.find(mapping);
121  if (it == m_OverridingNumsR.end())
122  {
123  it = m_OverridingNumsR.insert(std::make_pair(mapping, m_pUsedNumTable->size())).first;
124  m_OverridingNums.insert(std::make_pair(m_pUsedNumTable->size(), mapping));
125 
126  m_pUsedNumTable->push_back(nullptr); // dummy, it's unique_ptr...
127  ++m_nUniqueList; // counter for DuplicateNumRule...
128  }
129  return it->second;
130 }
131 
132 sal_uInt16 MSWordExportBase::GetNumberingId( const SwNumRule& rNumRule )
133 {
134  if ( !m_pUsedNumTable )
135  {
136  m_pUsedNumTable.reset(new SwNumRuleTable);
137  m_pUsedNumTable->insert( m_pUsedNumTable->begin(), m_pDoc->GetNumRuleTable().begin(), m_pDoc->GetNumRuleTable().end() );
138  // Check, if the outline rule is already inserted into <pUsedNumTable>.
139  // If yes, do not insert it again.
140  bool bOutlineRuleAdded( false );
141  for ( sal_uInt16 n = m_pUsedNumTable->size(); n; )
142  {
143  const SwNumRule& rRule = *(*m_pUsedNumTable)[ --n ];
144  if ( !SwDoc::IsUsed( rRule ) )
145  {
146  m_pUsedNumTable->erase( m_pUsedNumTable->begin() + n );
147  }
148  else if ( &rRule == m_pDoc->GetOutlineNumRule() )
149  {
150  bOutlineRuleAdded = true;
151  }
152  }
153 
154  if ( !bOutlineRuleAdded )
155  {
156  // still need to paste the OutlineRule
157  SwNumRule* pR = m_pDoc->GetOutlineNumRule();
158  m_pUsedNumTable->push_back( pR );
159  }
160  }
161  SwNumRule* p = const_cast<SwNumRule*>(&rNumRule);
162  sal_uInt16 nRet = static_cast<sal_uInt16>(m_pUsedNumTable->GetPos(p));
163 
164  // Is this list now duplicated into a new list which we should use
165  // #i77812# - perform 'deep' search in duplication map
166  std::map<sal_uInt16,sal_uInt16>::const_iterator aResult = m_aRuleDuplicates.end();
167  do {
168  aResult = m_aRuleDuplicates.find(nRet);
169  if ( aResult != m_aRuleDuplicates.end() )
170  {
171  nRet = (*aResult).second;
172  }
173  } while ( aResult != m_aRuleDuplicates.end() );
174 
175  return nRet;
176 }
177 
178 // GetFirstLineOffset should problem never appear unadorned apart from
179 // here in the ww export filter
180 sal_Int16 GetWordFirstLineOffset(const SwNumFormat &rFormat)
181 {
183  "<GetWordFirstLineOffset> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION" );
184 
185  short nFirstLineOffset;
186  if (rFormat.GetNumAdjust() == SvxAdjust::Right)
187  nFirstLineOffset = -rFormat.GetCharTextDistance();
188  else
189  nFirstLineOffset = rFormat.GetFirstLineOffset(); //TODO: overflow
190  return nFirstLineOffset;
191 }
192 
194 {
195  if ( !m_pUsedNumTable )
196  return; // no numbering is used
197 
198  // list formats - LSTF
199  pFib->m_fcPlcfLst = pTableStrm->Tell();
200  SwWW8Writer::WriteShort( *pTableStrm, m_pUsedNumTable->size() );
201  NumberingDefinitions();
202  // set len to FIB
203  pFib->m_lcbPlcfLst = pTableStrm->Tell() - pFib->m_fcPlcfLst;
204 
205  // list formats - LVLF
206  AbstractNumberingDefinitions();
207 
208  // list formats - LFO
209  OutOverrideListTab();
210 
211  // list formats - ListNames
212  OutListNamesTab();
213 }
214 
215 void WW8AttributeOutput::NumberingDefinition( sal_uInt16 nId, const SwNumRule &rRule )
216 {
217  SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, nId );
218  SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, nId );
219 
220  // not associated with a Style
221  for ( int i = 0; i < WW8ListManager::nMaxLevel; ++i )
222  SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, 0xFFF );
223 
224  sal_uInt8 nFlags = 0;
225  if ( rRule.IsContinusNum() )
226  nFlags |= 0x1;
227 
228  m_rWW8Export.pTableStrm->WriteUChar( nFlags ).WriteUChar( 0/*nDummy*/ );
229 }
230 
232 {
233  if ( !m_pUsedNumTable )
234  return; // no numbering is used
235 
236  sal_uInt16 nCount = m_pUsedNumTable->size();
237 
238  // Write static data of SwNumRule - LSTF
239  for ( sal_uInt16 n = 0; n < nCount; ++n )
240  {
241  const SwNumRule * pRule = (*m_pUsedNumTable)[ n ];
242  if (pRule)
243  {
244  AttrOutput().NumberingDefinition(n + 1, *pRule);
245  }
246  else
247  {
248  auto it = m_OverridingNums.find(n);
249  assert(it != m_OverridingNums.end());
250  pRule = (*m_pUsedNumTable)[it->second.first];
251  assert(pRule);
252  AttrOutput().OverrideNumberingDefinition(*pRule, n + 1, it->second.second + 1);
253  }
254  }
255 }
256 
257 static sal_uInt8 GetLevelNFC( sal_uInt16 eNumType, const SfxItemSet *pOutSet)
258 {
259  sal_uInt8 nRet = 0;
260  switch( eNumType )
261  {
263  case SVX_NUM_CHARS_UPPER_LETTER_N: nRet = 3; break;
265  case SVX_NUM_CHARS_LOWER_LETTER_N: nRet = 4; break;
266  case SVX_NUM_ROMAN_UPPER: nRet = 1; break;
267  case SVX_NUM_ROMAN_LOWER: nRet = 2; break;
268 
269  case SVX_NUM_BITMAP:
270  case SVX_NUM_CHAR_SPECIAL: nRet = 23; break;
271  case SVX_NUM_FULL_WIDTH_ARABIC: nRet = 14; break;
272  case SVX_NUM_CIRCLE_NUMBER: nRet = 18;break;
274  nRet = 35;
275  if ( pOutSet ) {
276  const SvxLanguageItem& rLang = pOutSet->Get( RES_CHRATR_CJK_LANGUAGE);
277  const LanguageType eLang = rLang.GetLanguage();
278  if (LANGUAGE_CHINESE_SIMPLIFIED ==eLang) {
279  nRet = 39;
280  }
281  }
282  break;
283  case SVX_NUM_NUMBER_UPPER_ZH: nRet = 38; break;
284  case SVX_NUM_NUMBER_UPPER_ZH_TW: nRet = 34;break;
285  case SVX_NUM_TIAN_GAN_ZH: nRet = 30; break;
286  case SVX_NUM_DI_ZI_ZH: nRet = 31; break;
287  case SVX_NUM_NUMBER_TRADITIONAL_JA: nRet = 16; break;
288  case SVX_NUM_AIU_FULLWIDTH_JA: nRet = 20; break;
289  case SVX_NUM_AIU_HALFWIDTH_JA: nRet = 12; break;
290  case SVX_NUM_IROHA_FULLWIDTH_JA: nRet = 21; break;
291  case SVX_NUM_IROHA_HALFWIDTH_JA: nRet = 13; break;
292  case style::NumberingType::HANGUL_SYLLABLE_KO: nRet = 24; break;// ganada
293  case style::NumberingType::HANGUL_JAMO_KO: nRet = 25; break;// chosung
294  case style::NumberingType::HANGUL_CIRCLED_SYLLABLE_KO: nRet = 24; break;
295  case style::NumberingType::HANGUL_CIRCLED_JAMO_KO: nRet = 25; break;
296  case style::NumberingType::NUMBER_HANGUL_KO: nRet = 41; break;
297  case style::NumberingType::NUMBER_UPPER_KO: nRet = 44; break;
298  case SVX_NUM_NUMBER_NONE: nRet = 0xff; break;
299  }
300  return nRet;
301 }
302 
303 
305  sal_uInt16 nStart,
306  sal_uInt16 nNumberingType,
307  SvxAdjust eAdjust,
308  const sal_uInt8 *pNumLvlPos,
309  sal_uInt8 nFollow,
310  const wwFont *pFont,
311  const SfxItemSet *pOutSet,
312  sal_Int16 nIndentAt,
313  sal_Int16 nFirstLineIndex,
314  sal_Int16 nListTabPos,
315  const OUString &rNumberingString,
316  const SvxBrushItem* pBrush //For i120928,to transfer graphic of bullet
317  )
318 {
319  // Start value
320  SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, nStart );
321 
322  // Type
323  m_rWW8Export.pTableStrm->WriteUChar( GetLevelNFC( nNumberingType ,pOutSet) );
324 
325  // Justification
326  sal_uInt8 nAlign;
327  switch ( eAdjust )
328  {
329  case SvxAdjust::Center:
330  nAlign = 1;
331  break;
332  case SvxAdjust::Right:
333  nAlign = 2;
334  break;
335  default:
336  nAlign = 0;
337  break;
338  }
339  m_rWW8Export.pTableStrm->WriteUChar( nAlign );
340 
341  // Write the rgbxchNums[9], positions of placeholders for paragraph
342  // numbers in the text
343  m_rWW8Export.pTableStrm->WriteBytes(pNumLvlPos, WW8ListManager::nMaxLevel);
344 
345  // Type of the character between the bullet and the text
346  m_rWW8Export.pTableStrm->WriteUChar( nFollow );
347 
348  // dxaSoace/dxaIndent (Word 6 compatibility)
349  SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, 0 );
350  SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, 0 );
351 
352  // cbGrpprlChpx
353  std::unique_ptr<ww::bytes> pCharAtrs;
354  if ( pOutSet )
355  {
356  std::unique_ptr<ww::bytes> pOldpO = std::move(m_rWW8Export.pO);
357  m_rWW8Export.pO.reset(new ww::bytes);
358  if ( pFont )
359  {
360  sal_uInt16 nFontID = m_rWW8Export.m_aFontHelper.GetId( *pFont );
361 
362  m_rWW8Export.InsUInt16( NS_sprm::sprmCRgFtc0 );
363  m_rWW8Export.InsUInt16( nFontID );
364  m_rWW8Export.InsUInt16( NS_sprm::sprmCRgFtc2 );
365  m_rWW8Export.InsUInt16( nFontID );
366  }
367 
368  m_rWW8Export.OutputItemSet( *pOutSet, false, true, i18n::ScriptType::LATIN, m_rWW8Export.m_bExportModeRTF );
369  //For i120928,achieve graphic's index of bullet from the bullet bookmark
370  if (SVX_NUM_BITMAP == nNumberingType && pBrush)
371  {
372  int nIndex = m_rWW8Export.GetGrfIndex(*pBrush);
373  if ( nIndex != -1 )
374  {
375  m_rWW8Export.InsUInt16(NS_sprm::sprmCPbiIBullet);
376  m_rWW8Export.InsUInt32(nIndex);
377  m_rWW8Export.InsUInt16(NS_sprm::sprmCPbiGrf);
378  m_rWW8Export.InsUInt16(1);
379  }
380  }
381 
382  pCharAtrs = std::move(m_rWW8Export.pO);
383  m_rWW8Export.pO = std::move(pOldpO);
384  }
385  m_rWW8Export.pTableStrm->WriteUChar(sal_uInt8(pCharAtrs ? pCharAtrs->size() : 0));
386 
387  // cbGrpprlPapx
388  sal_uInt8 aPapSprms [] = {
389  0x5e, 0x84, 0, 0, // sprmPDxaLeft
390  0x60, 0x84, 0, 0, // sprmPDxaLeft1
391  0x15, 0xc6, 0x05, 0x00, 0x01, 0, 0, 0x06
392  };
393  m_rWW8Export.pTableStrm->WriteUChar( sal_uInt8( sizeof( aPapSprms ) ) );
394 
395  // reserved
396  SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, 0 );
397 
398  // pap sprms
399  sal_uInt8* pData = aPapSprms + 2;
400  Set_UInt16( pData, nIndentAt );
401  pData += 2;
402  Set_UInt16( pData, nFirstLineIndex );
403  pData += 5;
404  Set_UInt16( pData, nListTabPos );
405 
406  m_rWW8Export.pTableStrm->WriteBytes(aPapSprms, sizeof(aPapSprms));
407 
408  // write Chpx
409  if (pCharAtrs && !pCharAtrs->empty())
410  m_rWW8Export.pTableStrm->WriteBytes(pCharAtrs->data(), pCharAtrs->size());
411 
412  // write the num string
413  SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, rNumberingString.getLength() );
414  SwWW8Writer::WriteString16( *m_rWW8Export.pTableStrm, rNumberingString, false );
415 }
416 
418 {
419  sal_uInt16 nCount = m_pUsedNumTable->size();
420  sal_uInt16 n;
421 
422  for( n = 0; n < nCount; ++n )
423  {
424  if (nullptr == (*m_pUsedNumTable)[ n ])
425  {
426  continue;
427  }
428 
429  AttrOutput().StartAbstractNumbering( n + 1 );
430 
431  const SwNumRule& rRule = *(*m_pUsedNumTable)[ n ];
432  sal_uInt8 nLvl;
433  sal_uInt8 nLevels = static_cast< sal_uInt8 >(rRule.IsContinusNum() ?
435  for( nLvl = 0; nLvl < nLevels; ++nLvl )
436  {
437  NumberingLevel(rRule, nLvl);
438  }
439 
440  AttrOutput().EndAbstractNumbering();
441  }
442 }
443 
445  SwNumRule const& rRule, sal_uInt8 const nLvl)
446 {
447  // prepare the NodeNum to generate the NumString
448  static const SwNumberTree::tNumberVector aNumVector = [] {
450  std::iota(vec.begin(), vec.end(), 0);
451  return vec;
452  }();
453 
454  // write the static data of the SwNumFormat of this level
455  sal_uInt8 aNumLvlPos[WW8ListManager::nMaxLevel] = { 0,0,0,0,0,0,0,0,0 };
456 
457  const SwNumFormat& rFormat = rRule.Get( nLvl );
458 
459  sal_uInt8 nFollow = 0;
460  // #i86652#
462  {
463  nFollow = 2; // ixchFollow: 0 - tab, 1 - blank, 2 - nothing
464  }
466  {
467  switch (rFormat.GetLabelFollowedBy())
468  {
470  {
471  // 0 (tab) unless there would be no content before the tab, in which case 2 (nothing)
472  nFollow = (SVX_NUM_NUMBER_NONE != rFormat.GetNumberingType()) ? 0 : 2;
473  }
474  break;
476  {
477  // 1 (space) unless there would be no content before the space in which case 2 (nothing)
478  nFollow = (SVX_NUM_NUMBER_NONE != rFormat.GetNumberingType()) ? 1 : 2;
479  }
480  break;
482  {
483  nFollow = 2;
484  }
485  break;
486  default:
487  {
488  nFollow = 0;
489  OSL_FAIL( "unknown GetLabelFollowedBy() return value" );
490  }
491  }
492  }
493 
494  // Build the NumString for this Level
495  OUString sNumStr;
496  OUString sFontName;
497  bool bWriteBullet = false;
498  const vcl::Font* pBulletFont=nullptr;
499  rtl_TextEncoding eChrSet=0;
501  if (SVX_NUM_CHAR_SPECIAL == rFormat.GetNumberingType() ||
502  SVX_NUM_BITMAP == rFormat.GetNumberingType())
503  {
504  sNumStr = OUString(rFormat.GetBulletChar());
505  bWriteBullet = true;
506 
507  pBulletFont = rFormat.GetBulletFont();
508  if (!pBulletFont)
509  {
510  pBulletFont = &numfunc::GetDefBulletFont();
511  }
512 
513  eChrSet = pBulletFont->GetCharSet();
514  sFontName = pBulletFont->GetFamilyName();
515  eFamily = pBulletFont->GetFamilyType();
516 
517  if (IsStarSymbol(sFontName))
518  SubstituteBullet( sNumStr, eChrSet, sFontName );
519 
520  // #i86652#
521  if (rFormat.GetPositionAndSpaceMode() ==
523  {
524  // <nFollow = 2>, if minimum label width equals 0 and
525  // minimum distance between label and text equals 0
526  nFollow = (rFormat.GetFirstLineOffset() == 0 &&
527  rFormat.GetCharTextDistance() == 0)
528  ? 2 : 0; // ixchFollow: 0 - tab, 1 - blank, 2 - nothing
529  }
530  }
531  else
532  {
533  if (SVX_NUM_NUMBER_NONE != rFormat.GetNumberingType())
534  {
535  sal_uInt8* pLvlPos = aNumLvlPos;
536  // the numbering string has to be restrict
537  // to the level currently working on.
538  sNumStr = rRule.MakeNumString(aNumVector, false, true, nLvl);
539 
540  // now search the nums in the string
541  for (sal_uInt8 i = 0; i <= nLvl; ++i)
542  {
543  OUString sSrch( OUString::number( i ));
544  sal_Int32 nFnd = sNumStr.indexOf( sSrch );
545  if( -1 != nFnd )
546  {
547  *pLvlPos = static_cast<sal_uInt8>(nFnd + rFormat.GetPrefix().getLength() + 1 );
548  ++pLvlPos;
549  sNumStr = sNumStr.replaceAt( nFnd, 1, OUString(static_cast<char>(i)) );
550  }
551  }
552  // #i86652#
553  if (rFormat.GetPositionAndSpaceMode() ==
555  {
556  // <nFollow = 2>, if minimum label width equals 0 and
557  // minimum distance between label and text equals 0
558  nFollow = (rFormat.GetFirstLineOffset() == 0 &&
559  rFormat.GetCharTextDistance() == 0)
560  ? 2 : 0; // ixchFollow: 0 - tab, 1 - blank, 2 - nothing
561  }
562  }
563 
564  if (!rFormat.GetPrefix().isEmpty())
565  sNumStr = rFormat.GetPrefix() + sNumStr;
566  sNumStr += rFormat.GetSuffix();
567  }
568 
569  // Attributes of the numbering
570  std::unique_ptr<wwFont> pPseudoFont;
571  const SfxItemSet* pOutSet = nullptr;
572 
573  // cbGrpprlChpx
574  SfxItemSet aSet( m_pDoc->GetAttrPool(), svl::Items<RES_CHRATR_BEGIN,
575  RES_CHRATR_END>{} );
576  if (rFormat.GetCharFormat() || bWriteBullet)
577  {
578  if (bWriteBullet)
579  {
580  pOutSet = &aSet;
581 
582  if (rFormat.GetCharFormat())
583  aSet.Put( rFormat.GetCharFormat()->GetAttrSet() );
584  aSet.ClearItem( RES_CHRATR_CJK_FONT );
585  aSet.ClearItem( RES_CHRATR_FONT );
586 
587  if (sFontName.isEmpty())
588  sFontName = pBulletFont->GetFamilyName();
589 
590  pPseudoFont.reset(new wwFont( sFontName, pBulletFont->GetPitch(),
591  eFamily, eChrSet));
592  }
593  else
594  pOutSet = &rFormat.GetCharFormat()->GetAttrSet();
595  }
596 
597  sal_Int16 nIndentAt = 0;
598  sal_Int16 nFirstLineIndex = 0;
599  sal_Int16 nListTabPos = 0;
600 
601  // #i86652#
603  {
604  nIndentAt = nListTabPos = rFormat.GetAbsLSpace(); //TODO: overflow
605  nFirstLineIndex = GetWordFirstLineOffset(rFormat);
606  }
608  {
609  nIndentAt = static_cast<sal_Int16>(rFormat.GetIndentAt());
610  nFirstLineIndex = static_cast<sal_Int16>(rFormat.GetFirstLineIndent());
611  nListTabPos = rFormat.GetLabelFollowedBy() == SvxNumberFormat::LISTTAB?
612  static_cast<sal_Int16>( rFormat.GetListtabPos() ) : 0;
613  }
614 
615  AttrOutput().NumberingLevel( nLvl,
616  rFormat.GetStart(),
617  rFormat.GetNumberingType(),
618  rFormat.GetNumAdjust(),
619  aNumLvlPos,
620  nFollow,
621  pPseudoFont.get(), pOutSet,
622  nIndentAt, nFirstLineIndex, nListTabPos,
623  sNumStr,
624  rFormat.GetNumberingType()==SVX_NUM_BITMAP ? rFormat.GetBrush() : nullptr);
625 }
626 
628 {
629  if( !m_pUsedNumTable )
630  return ; // no numbering is used
631 
632  // write the "list format override" - LFO
633  sal_uInt16 nCount = m_pUsedNumTable->size();
634  sal_uInt16 n;
635 
636  pFib->m_fcPlfLfo = pTableStrm->Tell();
637  SwWW8Writer::WriteLong( *pTableStrm, nCount );
638 
639  for( n = 0; n < nCount; ++n )
640  {
641  SwWW8Writer::WriteLong( *pTableStrm, n + 1 );
642  SwWW8Writer::FillCount( *pTableStrm, 12 );
643  }
644  for( n = 0; n < nCount; ++n )
645  SwWW8Writer::WriteLong( *pTableStrm, -1 ); // no overwrite
646 
647  // set len to FIB
648  pFib->m_lcbPlfLfo = pTableStrm->Tell() - pFib->m_fcPlfLfo;
649 }
650 
652 {
653  if( !m_pUsedNumTable )
654  return ; // no numbering is used
655 
656  // write the "list format override" - LFO
657  sal_uInt16 nNms = 0, nCount = m_pUsedNumTable->size();
658 
659  pFib->m_fcSttbListNames = pTableStrm->Tell();
660  SwWW8Writer::WriteShort( *pTableStrm, -1 );
661  SwWW8Writer::WriteLong( *pTableStrm, nCount );
662 
663  for( ; nNms < nCount; ++nNms )
664  {
665  const SwNumRule& rRule = *(*m_pUsedNumTable)[ nNms ];
666  OUString sNm;
667  if( !rRule.IsAutoRule() )
668  sNm = rRule.GetName();
669 
670  SwWW8Writer::WriteShort( *pTableStrm, sNm.getLength() );
671  if (!sNm.isEmpty())
672  SwWW8Writer::WriteString16(*pTableStrm, sNm, false);
673  }
674 
675  SwWW8Writer::WriteLong( *pTableStrm, pFib->m_fcSttbListNames + 2, nNms );
676  // set len to FIB
677  pFib->m_lcbSttbListNames = pTableStrm->Tell() - pFib->m_fcSttbListNames;
678 }
679 
680 void MSWordExportBase::SubstituteBullet( OUString& rNumStr,
681  rtl_TextEncoding& rChrSet, OUString& rFontName ) const
682 {
683  if (!m_bSubstituteBullets)
684  return;
685  OUString sFontName = rFontName;
686 
687  // If Bullet char is "", don't change
688  if (rNumStr[0] != u'\0')
689  {
690  rNumStr = rNumStr.replaceAt(0, 1, OUString(
691  msfilter::util::bestFitOpenSymbolToMSFont(rNumStr[0], rChrSet, sFontName)));
692  }
693 
694  rFontName = sFontName;
695 }
696 
697 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 DuplicateNumRule(const SwNumRule *pRule, sal_uInt8 nLevel, sal_uInt16 nVal)
In case of numbering restart.
Definition: wrtw8num.cxx:65
SvxNumType GetNumberingType() const
const sal_uInt16 sprmCPbiIBullet
Definition: sprmids.hxx:350
SVX_NUM_CHARS_UPPER_LETTER_N
#define RES_CHRATR_CJK_LANGUAGE
Definition: hintids.hxx:93
const OUString & GetFamilyName() const
long GetFirstLineIndent() const
sal_Unicode bestFitOpenSymbolToMSFont(sal_Unicode cBullet, rtl_TextEncoding &r_ioChrSet, OUString &r_ioFontName)
OUString MakeNumString(const SwNodeNum &, bool bInclStrings=true) const
Definition: number.cxx:610
SVX_NUM_FULL_WIDTH_ARABIC
const sal_uInt16 sprmCRgFtc0
Definition: sprmids.hxx:308
const SvxBrushItem * GetBrush() const
SVX_NUM_NUMBER_NONE
std::vector< sal_uInt8 > bytes
Definition: types.hxx:29
SVX_NUM_CHARS_UPPER_LETTER
const OUString & GetDefaultListId() const
Definition: numrule.hxx:191
bool IsAutoRule() const
Definition: numrule.hxx:226
SVX_NUM_CIRCLE_NUMBER
#define RES_CHRATR_FONT
Definition: hintids.hxx:76
virtual void WriteNumbering() override
Output the numbering table.
Definition: wrtw8num.cxx:193
const OUString & GetName() const
Definition: numrule.hxx:221
#define RES_CHRATR_CJK_FONT
Definition: hintids.hxx:91
virtual void NumberingDefinition(sal_uInt16 nId, const SwNumRule &rRule) override
Definition of a numbering instance.
Definition: wrtw8num.cxx:215
FontFamily GetFamilyType()
void OutListNamesTab()
Definition: wrtw8num.cxx:651
#define RES_CHRATR_END
Definition: hintids.hxx:115
const sal_uInt16 sprmCPbiGrf
Definition: sprmids.hxx:351
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
short GetCharTextDistance() const
SVX_NUM_ROMAN_UPPER
SVX_NUM_ROMAN_LOWER
SVX_NUM_IROHA_FULLWIDTH_JA
void Set_UInt16(sal_uInt8 *&p, sal_uInt16 n)
Definition: ww8struc.hxx:47
const OUString & GetPrefix() const
const OUString & GetSuffix() const
FAMILY_DECORATIVE
SVX_NUM_DI_ZI_ZH
Collects and outputs fonts.
Definition: wrtww8.hxx:299
sal_uInt16 DuplicateAbsNum(OUString const &rListId, SwNumRule const &rAbstractRule)
check if a new abstractNum is needed for this list
Definition: wrtw8num.cxx:85
bool IsContinusNum() const
Definition: numrule.hxx:232
static void WriteString16(SvStream &rStrm, const OUString &rStr, bool bAddZero)
Definition: wrtww8.cxx:1768
SVX_NUM_BITMAP
SVX_NUM_CHAR_SPECIAL
SwCharFormat * GetCharFormat() const
Definition: numrule.hxx:73
SwNumRule * DuplicateNumRuleImpl(const SwNumRule *pRule)
Definition: wrtw8num.cxx:49
SVX_NUM_IROHA_HALFWIDTH_JA
SVX_NUM_TIAN_GAN_ZH
SVX_NUM_CHARS_LOWER_LETTER
FontPitch GetPitch()
SvxAdjust
void SubstituteBullet(OUString &rNumStr, rtl_TextEncoding &rChrSet, OUString &rFontName) const
Definition: wrtw8num.cxx:680
LabelFollowedBy GetLabelFollowedBy() const
sal_Int32 GetAbsLSpace() const
const vcl::Font & GetDefBulletFont()
retrieve font used for the default bullet list characters
Definition: number.cxx:1257
int i
static void WriteShort(SvStream &rStrm, sal_Int16 nVal)
Definition: wrtww8.hxx:961
const vcl::Font * GetBulletFont() const
static sal_uInt8 GetLevelNFC(sal_uInt16 eNumType, const SfxItemSet *pOutSet)
Definition: wrtw8num.cxx:257
float u
#define RES_CHRATR_BEGIN
Definition: hintids.hxx:69
#define LANGUAGE_CHINESE_SIMPLIFIED
SvxAdjust GetNumAdjust() const
sal_uInt16 GetStart() const
SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const
SVX_NUM_CHARS_LOWER_LETTER_N
sal_Int16 GetWordFirstLineOffset(const SwNumFormat &rFormat)
Definition: wrtw8num.cxx:180
std::vector< tSwNumTreeNumber > tNumberVector
long GetIndentAt() const
const sal_uInt16 sprmCRgFtc2
Definition: sprmids.hxx:310
SVX_NUM_NUMBER_UPPER_ZH_TW
FontFamily
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:77
sal_uInt16 GetNumberingId(const SwNumRule &rNumRule)
Return the numeric id of the numbering rule.
Definition: wrtw8num.cxx:132
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
LanguageType GetLanguage() const
void Set(sal_uInt16 i, const SwNumFormat *)
Definition: number.cxx:585
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
unsigned char sal_uInt8
SVX_NUM_NUMBER_TRADITIONAL_JA
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
SVX_NUM_NUMBER_LOWER_ZH
SVX_NUM_NUMBER_UPPER_ZH
bool IsUsed(const SwModify &) const
Definition: poolfmt.cxx:84
void NumberingDefinitions()
Write static data of SwNumRule - LSTF.
Definition: wrtw8num.cxx:231
sal_uInt16 OverrideNumRule(SwNumRule const &rExistingRule, OUString const &rListId, SwNumRule const &rAbstractRule)
Create a overriding numbering definition (if it does not yet exist)
Definition: wrtw8num.cxx:108
long GetListtabPos() const
sal_Int32 GetFirstLineOffset() const
sal_Unicode GetBulletChar() const
void SetStart(sal_uInt16 nSet)
void OutOverrideListTab()
Definition: wrtw8num.cxx:627
SVX_NUM_AIU_HALFWIDTH_JA
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
bool IsStarSymbol(const OUString &rFontName)
static void WriteLong(SvStream &rStrm, sal_Int32 nVal)
Definition: wrtww8.hxx:964
static void FillCount(SvStream &rStrm, sal_uLong nCount)
Definition: wrtww8.cxx:954
SVX_NUM_AIU_FULLWIDTH_JA
virtual void NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart, sal_uInt16 nNumberingType, SvxAdjust eAdjust, const sal_uInt8 *pNumLvlPos, sal_uInt8 nFollow, const wwFont *pFont, const SfxItemSet *pOutSet, sal_Int16 nIndentAt, sal_Int16 nFirstLineIndex, sal_Int16 nListTabPos, const OUString &rNumberingString, const SvxBrushItem *pBrush) override
All the numbering level information.
Definition: wrtw8num.cxx:304
rtl_TextEncoding GetCharSet() const
void AbstractNumberingDefinitions()
Write all Levels for all SwNumRules - LVLF.
Definition: wrtw8num.cxx:417
void NumberingLevel(SwNumRule const &rRule, sal_uInt8 nLvl)
Write one numbering level.
Definition: wrtw8num.cxx:444
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo