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