LibreOffice Module xmloff (master)  1
xmlnumi.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 <com/sun/star/beans/PropertyValue.hpp>
21 #include <com/sun/star/beans/XPropertySet.hpp>
22 #include <com/sun/star/awt/Size.hpp>
23 #include <com/sun/star/frame/XModel.hpp>
24 #include <com/sun/star/graphic/XGraphic.hpp>
25 #include <com/sun/star/awt/FontDescriptor.hpp>
26 #include <com/sun/star/text/HoriOrientation.hpp>
27 #include <com/sun/star/text/VertOrientation.hpp>
28 #include <com/sun/star/text/PositionAndSpaceMode.hpp>
29 #include <com/sun/star/text/LabelFollow.hpp>
30 #include <com/sun/star/container/XNameContainer.hpp>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <com/sun/star/style/XStyle.hpp>
33 #include <com/sun/star/io/XOutputStream.hpp>
34 #include <com/sun/star/awt/XBitmap.hpp>
35 #include <com/sun/star/style/NumberingType.hpp>
36 #include <com/sun/star/container/XIndexReplace.hpp>
37 
38 #include <o3tl/any.hxx>
39 #include <rtl/ustrbuf.hxx>
40 #include <sal/log.hxx>
41 #include <osl/diagnose.h>
42 
43 #include <tools/fontenum.hxx>
44 #include <tools/color.hxx>
45 
46 #include <sax/tools/converter.hxx>
47 
48 #include <xmloff/xmltkmap.hxx>
49 #include <xmloff/nmspmap.hxx>
50 #include <xmloff/xmlnmspe.hxx>
51 #include <xmloff/xmlimp.hxx>
53 #include <xmloff/xmltoken.hxx>
54 
55 #include <xmloff/xmluconv.hxx>
56 #include "fonthdl.hxx"
58 #include <xmloff/families.hxx>
59 #include <xmloff/maptype.hxx>
60 
61 #include <xmloff/xmlnumi.hxx>
62 
63 using namespace ::com::sun::star;
64 using namespace ::com::sun::star::uno;
65 using namespace ::com::sun::star::style;
66 using namespace ::com::sun::star::text;
67 using namespace ::com::sun::star::beans;
68 using namespace ::com::sun::star::container;
69 using namespace ::com::sun::star::lang;
70 using namespace ::com::sun::star::frame;
71 using namespace ::xmloff::token;
72 using namespace ::com::sun::star::io;
73 
75 
76 namespace {
77 
79 {
81 
82 public:
83 
85  SvXMLImport& rImport, sal_uInt16 nPrfx,
86  const OUString& rLName,
87  const Reference< xml::sax::XAttributeList >& xAttrList,
89 
91  sal_uInt16 nPrefix, const OUString& rLocalName,
92  const Reference< xml::sax::XAttributeList > & xAttrList ) override;
93 };
94 
95 class SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl : public SvXMLImportContext
96 {
97 public:
98 
99  SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(
100  SvXMLImport& rImport, sal_uInt16 nPrfx,
101  const OUString& rLName,
102  const Reference< xml::sax::XAttributeList >& xAttrList,
104 };
105 
107 {
108  XML_TOK_TEXT_LEVEL_ATTR_LEVEL,
109  XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME,
110  XML_TOK_TEXT_LEVEL_ATTR_BULLET_CHAR,
111  XML_TOK_TEXT_LEVEL_ATTR_HREF,
112  XML_TOK_TEXT_LEVEL_ATTR_TYPE,
113  XML_TOK_TEXT_LEVEL_ATTR_SHOW,
114  XML_TOK_TEXT_LEVEL_ATTR_ACTUATE,
115  XML_TOK_TEXT_LEVEL_ATTR_NUM_FORMAT,
116  XML_TOK_TEXT_LEVEL_ATTR_NUM_PREFIX,
117  XML_TOK_TEXT_LEVEL_ATTR_NUM_SUFFIX,
118  XML_TOK_TEXT_LEVEL_ATTR_NUM_LETTER_SYNC,
119  XML_TOK_TEXT_LEVEL_ATTR_START_VALUE,
120  XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS
121 };
122 
123 }
124 
126 {
127  static const SvXMLTokenMapEntry aLevelAttrTokenMap[] =
128  {
129  { XML_NAMESPACE_TEXT, XML_LEVEL, XML_TOK_TEXT_LEVEL_ATTR_LEVEL },
130  { XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME },
131  { XML_NAMESPACE_TEXT, XML_BULLET_CHAR, XML_TOK_TEXT_LEVEL_ATTR_BULLET_CHAR },
132  { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TEXT_LEVEL_ATTR_HREF },
133  { XML_NAMESPACE_XLINK, XML_TYPE, XML_TOK_TEXT_LEVEL_ATTR_TYPE },
134  { XML_NAMESPACE_XLINK, XML_SHOW, XML_TOK_TEXT_LEVEL_ATTR_SHOW },
135  { XML_NAMESPACE_XLINK, XML_ACTUATE, XML_TOK_TEXT_LEVEL_ATTR_ACTUATE },
136 
137  { XML_NAMESPACE_STYLE, XML_NUM_FORMAT, XML_TOK_TEXT_LEVEL_ATTR_NUM_FORMAT },
138  { XML_NAMESPACE_STYLE, XML_NUM_PREFIX, XML_TOK_TEXT_LEVEL_ATTR_NUM_PREFIX },
139  { XML_NAMESPACE_STYLE, XML_NUM_SUFFIX, XML_TOK_TEXT_LEVEL_ATTR_NUM_SUFFIX },
140  { XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC, XML_TOK_TEXT_LEVEL_ATTR_NUM_LETTER_SYNC },
141  { XML_NAMESPACE_TEXT, XML_START_VALUE, XML_TOK_TEXT_LEVEL_ATTR_START_VALUE },
142  { XML_NAMESPACE_TEXT, XML_DISPLAY_LEVELS, XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS },
143 
145  };
146  return aLevelAttrTokenMap;
147 }
148 
150 {
152 
153  OUString sPrefix;
154  OUString sSuffix;
155  OUString sTextStyleName;
156  OUString sNumFormat;
157  OUString sNumLetterSync;
158  OUString sBulletFontName;
160  OUString sImageURL;
161 
162  Reference < XOutputStream > xBase64Stream;
163 
164  sal_Int32 nLevel;
165  sal_Int32 nSpaceBefore;
166  sal_Int32 nMinLabelWidth;
167  sal_Int32 nMinLabelDist;
168  sal_Int32 nImageWidth;
169  sal_Int32 nImageHeight;
170  sal_Int16 nNumStartValue;
171  sal_Int16 nNumDisplayLevels;
172 
173  sal_Int16 eAdjust;
174  sal_Int16 eBulletFontFamily;
175  sal_Int16 eBulletFontPitch;
176  rtl_TextEncoding eBulletFontEncoding;
177  sal_Int16 eImageVertOrient;
178 
180 
181  sal_Int16 nRelSize;
183 
184  sal_Int16 ePosAndSpaceMode;
185  sal_Int16 eLabelFollowedBy;
187  sal_Int32 nFirstLineIndent;
188  sal_Int32 nIndentAt;
189 
190  bool bBullet : 1;
191  bool bImage : 1;
192  bool bNum : 1;
193  bool bHasColor : 1;
194 
195  void SetRelSize( sal_Int16 nRel ) { nRelSize = nRel; }
196  void SetColor( Color nColor )
197  { m_nColor = nColor; bHasColor = true; }
198  void SetSpaceBefore( sal_Int32 nSet ) { nSpaceBefore = nSet; }
199  void SetMinLabelWidth( sal_Int32 nSet ) { nMinLabelWidth = nSet; }
200  void SetMinLabelDist( sal_Int32 nSet ) { nMinLabelDist = nSet; }
201  void SetAdjust( sal_Int16 eSet ) { eAdjust = eSet; }
202 
203  void SetBulletFontName( const OUString& rSet ) { sBulletFontName = rSet; }
204  void SetBulletFontStyleName( const OUString& rSet )
205  { sBulletFontStyleName = rSet; }
206  void SetBulletFontFamily( sal_Int16 eSet ) { eBulletFontFamily = eSet; }
207  void SetBulletFontPitch( sal_Int16 eSet ) { eBulletFontPitch = eSet; }
208  void SetBulletFontEncoding( rtl_TextEncoding eSet )
209  { eBulletFontEncoding = eSet; }
210 
211  void SetImageWidth( sal_Int32 nSet ) { nImageWidth = nSet; }
212  void SetImageHeight( sal_Int32 nSet ) { nImageHeight = nSet; }
213  void SetImageVertOrient( sal_Int16 eSet )
214  { eImageVertOrient = eSet; }
215 
216 public:
217 
219  SvXMLImport& rImport, sal_uInt16 nPrfx,
220  const OUString& rLName,
221  const Reference< xml::sax::XAttributeList > & xAttrList );
222 
224  sal_uInt16 nPrefix, const OUString& rLocalName,
225  const Reference< xml::sax::XAttributeList > & xAttrList ) override;
226 
227  sal_Int32 GetLevel() const { return nLevel; }
229 
230  void SetPosAndSpaceMode( sal_Int16 eValue )
231  {
232  ePosAndSpaceMode = eValue;
233  }
234  void SetLabelFollowedBy( sal_Int16 eValue )
235  {
236  eLabelFollowedBy = eValue;
237  }
238  void SetListtabStopPosition( sal_Int32 nValue )
239  {
240  nListtabStopPosition = nValue;
241  }
242  void SetFirstLineIndent( sal_Int32 nValue )
243  {
244  nFirstLineIndent = nValue;
245  }
246  void SetIndentAt( sal_Int32 nValue )
247  {
248  nIndentAt = nValue;
249  }
250 };
251 
252 static const OUStringLiteral gsStarBats( "StarBats" );
253 static const OUStringLiteral gsStarMath( "StarMath" );
254 
256  SvXMLImport& rImport, sal_uInt16 nPrfx,
257  const OUString& rLName,
258  const Reference< xml::sax::XAttributeList > & xAttrList )
259 
260 : SvXMLImportContext( rImport, nPrfx, rLName )
261 , sNumFormat( "1" )
262 , nLevel( -1 )
263 , nSpaceBefore( 0 )
264 , nMinLabelWidth( 0 )
265 , nMinLabelDist( 0 )
266 , nImageWidth( 0 )
267 , nImageHeight( 0 )
268 , nNumStartValue( 1 )
269 , nNumDisplayLevels( 1 )
270 , eAdjust( HoriOrientation::LEFT )
271 , eBulletFontFamily( FAMILY_DONTKNOW )
272 , eBulletFontPitch( PITCH_DONTKNOW )
273 , eBulletFontEncoding( RTL_TEXTENCODING_DONTKNOW )
274 , eImageVertOrient(0)
275 , cBullet( 0 )
276 , nRelSize(0)
277 , m_nColor(0)
278 , ePosAndSpaceMode( PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION )
279 , eLabelFollowedBy( LabelFollow::LISTTAB )
280 , nListtabStopPosition( 0 )
281 , nFirstLineIndent( 0 )
282 , nIndentAt( 0 )
283 , bBullet( false )
284 , bImage( false )
285 , bNum( false )
286 , bHasColor( false )
287 {
288  if( IsXMLToken( rLName, XML_LIST_LEVEL_STYLE_NUMBER ) ||
290  bNum = true;
291  else if( IsXMLToken( rLName, XML_LIST_LEVEL_STYLE_BULLET ) )
292  bBullet = true;
293  else if( IsXMLToken( rLName, XML_LIST_LEVEL_STYLE_IMAGE ) )
294  bImage = true;
295 
297  sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
298  for( sal_Int16 i=0; i < nAttrCount; i++ )
299  {
300  const OUString& rAttrName = xAttrList->getNameByIndex( i );
301  OUString aLocalName;
302  sal_uInt16 nPrefix =
304  &aLocalName );
305  const OUString& rValue = xAttrList->getValueByIndex( i );
306 
307  switch( aTokenMap.Get( nPrefix, aLocalName ) )
308  {
309  case XML_TOK_TEXT_LEVEL_ATTR_LEVEL:
310  nLevel = rValue.toInt32();
311  if( nLevel >= 1 )
312  nLevel--;
313  else
314  nLevel = 0;
315  break;
316  case XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME:
318  break;
319  case XML_TOK_TEXT_LEVEL_ATTR_BULLET_CHAR:
320  if (!rValue.isEmpty())
321  cBullet = rValue[0];
322  break;
323  case XML_TOK_TEXT_LEVEL_ATTR_HREF:
324  if( bImage )
325  sImageURL = rValue;
326  break;
327  case XML_TOK_TEXT_LEVEL_ATTR_TYPE:
328  case XML_TOK_TEXT_LEVEL_ATTR_SHOW:
329  case XML_TOK_TEXT_LEVEL_ATTR_ACTUATE:
330  // This properties will be ignored
331  break;
332  case XML_TOK_TEXT_LEVEL_ATTR_NUM_FORMAT:
333  if( bNum )
334  sNumFormat = rValue;
335  break;
336  case XML_TOK_TEXT_LEVEL_ATTR_NUM_PREFIX:
337  sPrefix = rValue;
338  break;
339  case XML_TOK_TEXT_LEVEL_ATTR_NUM_SUFFIX:
340  sSuffix = rValue;
341  break;
342  case XML_TOK_TEXT_LEVEL_ATTR_NUM_LETTER_SYNC:
343  if( bNum )
345  break;
346  case XML_TOK_TEXT_LEVEL_ATTR_START_VALUE:
347  if( bNum )
348  {
349  sal_Int32 nTmp = rValue.toInt32();
351  (nTmp < 0) ? 1 : ( (nTmp>SHRT_MAX) ? SHRT_MAX
352  : static_cast<sal_Int16>(nTmp) );
353  }
354  break;
355  case XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS:
356  if( bNum )
357  {
358  sal_Int32 nTmp = rValue.toInt32();
360  (nTmp < 1) ? 1 : ( (nTmp>SHRT_MAX) ? SHRT_MAX
361  : static_cast<sal_Int16>(nTmp) );
362  }
363  break;
364  }
365  }
366 }
367 
369  sal_uInt16 nPrefix, const OUString& rLocalName,
370  const Reference< xml::sax::XAttributeList > & xAttrList )
371 {
372  SvXMLImportContext *pContext = nullptr;
373  if( XML_NAMESPACE_STYLE == nPrefix &&
374  ( IsXMLToken( rLocalName, XML_LIST_LEVEL_PROPERTIES ) ||
375  IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) ) )
376  {
378  nPrefix,
379  rLocalName,
380  xAttrList,
381  *this );
382  }
383  else if( (XML_NAMESPACE_OFFICE == nPrefix) && xmloff::token::IsXMLToken( rLocalName,
385  {
386  if( bImage && sImageURL.isEmpty() && !xBase64Stream.is() )
387  {
389  if( xBase64Stream.is() )
390  pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
391  rLocalName, xAttrList,
392  xBase64Stream );
393  }
394  }
395 
396  return pContext;
397 }
398 
400 {
401  sal_Int16 eType = NumberingType::NUMBER_NONE;
402 
403  sal_Int32 nCount = 0;
404  if( bBullet )
405  {
406  eType = NumberingType::CHAR_SPECIAL;
407  nCount = 15; // 'cBullet' will be written anyway if 'bBullet' is true
408  }
409  if( bImage )
410  {
411  eType = NumberingType::BITMAP;
412  nCount = 15;
413 
414  if( !sImageURL.isEmpty() || xBase64Stream.is() )
415  nCount++;
416  }
417  if( bNum )
418  {
419  eType = NumberingType::ARABIC;
421  eType, sNumFormat, sNumLetterSync, true );
422  nCount = 15;
423  }
424 
425  if( ( bBullet || bNum ) && nRelSize )
426  nCount++;
427 
428  if( !bImage && bHasColor )
429  {
430  nCount++;
431  }
432 
433  if (bBullet && !sSuffix.isEmpty())
434  {
435  sal_uInt16 const nVersion(GetImport().getGeneratorVersion());
436  sal_Int32 nUPD;
437  sal_Int32 nBuildId;
438  if (GetImport().getBuildIds(nUPD, nBuildId)
439  && ( (SvXMLImport::OOo_1x == nVersion)
440  || (SvXMLImport::OOo_2x == nVersion)
441  || (310 == nUPD) || (320 == nUPD) || (330 == nUPD)
442  || ((300 == nUPD) && (nBuildId <= 9573))))
443  {
444  // #i93908# OOo < 3.4 wrote a bogus suffix for bullet chars
445  sSuffix.clear(); // clear it
446  }
447  }
448 
449  Sequence<beans::PropertyValue> aPropSeq( nCount );
450  if( nCount > 0 )
451  {
452  beans::PropertyValue *pProps = aPropSeq.getArray();
453  sal_Int32 nPos = 0;
454  pProps[nPos].Name = "NumberingType";
455  pProps[nPos++].Value <<= eType ;
456 
457  pProps[nPos].Name = "Prefix";
458  pProps[nPos++].Value <<= sPrefix;
459 
460  pProps[nPos].Name = "Suffix";
461  pProps[nPos++].Value <<= sSuffix;
462 
463  pProps[nPos].Name = "Adjust";
464  pProps[nPos++].Value <<= eAdjust;
465 
467  pProps[nPos].Name = "LeftMargin";
468  pProps[nPos++].Value <<= nLeftMargin;
469 
470  sal_Int32 nFirstLineOffset = -nMinLabelWidth;
471 
472  pProps[nPos].Name = "FirstLineOffset";
473  pProps[nPos++].Value <<= nFirstLineOffset;
474 
475  pProps[nPos].Name = "SymbolTextDistance";
476  pProps[nPos++].Value <<= static_cast<sal_Int16>(nMinLabelDist);
477 
478  pProps[nPos].Name = "PositionAndSpaceMode";
479  pProps[nPos++].Value <<= ePosAndSpaceMode;
480  pProps[nPos].Name = "LabelFollowedBy";
481  pProps[nPos++].Value <<= eLabelFollowedBy;
482  pProps[nPos].Name = "ListtabStopPosition";
483  pProps[nPos++].Value <<= nListtabStopPosition;
484  pProps[nPos].Name = "FirstLineIndent";
485  pProps[nPos++].Value <<= nFirstLineIndent;
486  pProps[nPos].Name = "IndentAt";
487  pProps[nPos++].Value <<= nIndentAt;
488 
489  OUString sDisplayTextStyleName = GetImport().GetStyleDisplayName(
491  pProps[nPos].Name = "CharStyleName";
492  pProps[nPos++].Value <<= sDisplayTextStyleName;
493 
494  if( bBullet )
495  {
496  awt::FontDescriptor aFDesc;
497  aFDesc.Name = sBulletFontName;
498  if( !sBulletFontName.isEmpty() )
499  {
500  aFDesc.StyleName = sBulletFontStyleName;
501  aFDesc.Family = eBulletFontFamily;
502  aFDesc.Pitch = eBulletFontPitch;
503  aFDesc.CharSet = eBulletFontEncoding;
504  aFDesc.Weight = WEIGHT_DONTKNOW;
505  bool bStarSymbol = false;
506  if( aFDesc.Name.equalsIgnoreAsciiCase( gsStarBats ) )
507  {
509  bStarSymbol = true;
510  }
511  else if( aFDesc.Name.equalsIgnoreAsciiCase( gsStarMath ) )
512  {
514  bStarSymbol = true;
515  }
516  if( bStarSymbol )
517  aFDesc.Name = "StarSymbol" ;
518  }
519 
520  // Must append 'cBullet' even if it is zero
521  // if 'bBullet' is true and 'cBullet' is zero - BulletChar property must be 0.
522  OUString sTmp = OUStringChar( cBullet );
523  pProps[nPos].Name = "BulletChar";
524  pProps[nPos++].Value <<= sTmp;
525 
526  pProps[nPos].Name = "BulletFont";
527  pProps[nPos++].Value <<= aFDesc;
528 
529  }
530 
531  if( bImage )
532  {
533  uno::Reference<graphic::XGraphic> xGraphic;
534  if (!sImageURL.isEmpty())
535  {
536  xGraphic = GetImport().loadGraphicByURL(sImageURL);
537  }
538  else if( xBase64Stream.is() )
539  {
541  }
542 
543  uno::Reference<awt::XBitmap> xBitmap;
544  if (xGraphic.is())
545  xBitmap.set(xGraphic, uno::UNO_QUERY);
546 
547  if (xBitmap.is())
548  {
549  pProps[nPos].Name = "GraphicBitmap";
550  pProps[nPos++].Value <<= xBitmap;
551  }
552 
553  awt::Size aSize(nImageWidth, nImageHeight);
554  pProps[nPos].Name = "GraphicSize";
555  pProps[nPos++].Value <<= aSize;
556 
557  pProps[nPos].Name = "VertOrient";
558  pProps[nPos++].Value <<= eImageVertOrient;
559  }
560 
561  if( bNum )
562  {
563  pProps[nPos].Name = "StartWith";
564  pProps[nPos++].Value <<= nNumStartValue;
565 
566  pProps[nPos].Name = "ParentNumbering";
567  pProps[nPos++].Value <<= nNumDisplayLevels;
568  }
569 
570  if( ( bNum || bBullet ) && nRelSize )
571  {
572  pProps[nPos].Name = "BulletRelSize";
573  pProps[nPos++].Value <<= nRelSize;
574  }
575 
576  if( !bImage && bHasColor )
577  {
578  pProps[nPos].Name = "BulletColor";
579  pProps[nPos++].Value <<= m_nColor;
580  }
581 
582  SAL_WARN_IF( nPos != nCount, "xmloff", "array under/overflow" );
583  }
584 
585  return aPropSeq;
586 }
587 
588 namespace {
589 
591 {
592  XML_TOK_STYLE_ATTRIBUTES_ATTR_SPACE_BEFORE,
593  XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_WIDTH,
594  XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_DIST,
595  XML_TOK_STYLE_ATTRIBUTES_ATTR_TEXT_ALIGN,
596  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_NAME,
597  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY,
598  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY_GENERIC,
599  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_STYLENAME,
600  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_PITCH,
601  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_CHARSET,
602  XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_POS,
603  XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_REL,
604  XML_TOK_STYLE_ATTRIBUTES_ATTR_WIDTH,
605  XML_TOK_STYLE_ATTRIBUTES_ATTR_HEIGHT,
606  XML_TOK_STYLE_ATTRIBUTES_ATTR_COLOR,
607  XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR,
608  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE,
609  XML_TOK_STYLE_ATTRIBUTES_ATTR_POSITION_AND_SPACE_MODE
610 };
611 
612 }
613 
615 {
616  static const SvXMLTokenMapEntry aStyleAttributesAttrTokenMap[] =
617  {
619  XML_TOK_STYLE_ATTRIBUTES_ATTR_SPACE_BEFORE },
621  XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_WIDTH },
623  XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_DIST },
625  XML_TOK_STYLE_ATTRIBUTES_ATTR_TEXT_ALIGN },
627  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_NAME },
629  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY },
631  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY_GENERIC },
633  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_STYLENAME },
635  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_PITCH },
637  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_CHARSET },
639  XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_POS },
641  XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_REL },
643  XML_TOK_STYLE_ATTRIBUTES_ATTR_WIDTH },
645  XML_TOK_STYLE_ATTRIBUTES_ATTR_HEIGHT },
647  XML_TOK_STYLE_ATTRIBUTES_ATTR_COLOR },
649  XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR },
651  XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE },
653  XML_TOK_STYLE_ATTRIBUTES_ATTR_POSITION_AND_SPACE_MODE },
655  };
656  return aStyleAttributesAttrTokenMap;
657 }
658 SvxXMLListLevelStyleAttrContext_Impl::SvxXMLListLevelStyleAttrContext_Impl(
659  SvXMLImport& rImport, sal_uInt16 nPrfx,
660  const OUString& rLName,
661  const Reference< xml::sax::XAttributeList > & xAttrList,
663  SvXMLImportContext( rImport, nPrfx, rLName ),
664  rListLevel( rLLevel )
665 {
667  SvXMLUnitConverter& rUnitConv = GetImport().GetMM100UnitConverter();
668 
669  OUString sFontName, sFontFamily, sFontStyleName, sFontFamilyGeneric,
670  sFontPitch, sFontCharset;
671  OUString sVerticalPos, sVerticalRel;
672 
673  sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
674  for( sal_Int16 i=0; i < nAttrCount; i++ )
675  {
676  const OUString& rAttrName = xAttrList->getNameByIndex( i );
677  OUString aLocalName;
678  sal_uInt16 nPrefix =
679  GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
680  &aLocalName );
681  const OUString& rValue = xAttrList->getValueByIndex( i );
682 
683  sal_Int32 nVal;
684  switch( aTokenMap.Get( nPrefix, aLocalName ) )
685  {
686  case XML_TOK_STYLE_ATTRIBUTES_ATTR_SPACE_BEFORE:
687  if (rUnitConv.convertMeasureToCore(nVal, rValue, SHRT_MIN, SHRT_MAX))
688  rListLevel.SetSpaceBefore( nVal );
689  break;
690  case XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_WIDTH:
691  if (rUnitConv.convertMeasureToCore( nVal, rValue, 0, SHRT_MAX ))
692  rListLevel.SetMinLabelWidth( nVal );
693  break;
694  case XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_DIST:
695  if (rUnitConv.convertMeasureToCore( nVal, rValue, 0, USHRT_MAX ))
696  rListLevel.SetMinLabelDist( nVal );
697  break;
698  case XML_TOK_STYLE_ATTRIBUTES_ATTR_TEXT_ALIGN:
699  if( !rValue.isEmpty() )
700  {
701  sal_Int16 eAdjust = HoriOrientation::LEFT;
702  if( IsXMLToken( rValue, XML_CENTER ) )
703  eAdjust = HoriOrientation::CENTER;
704  else if( IsXMLToken( rValue, XML_END ) )
705  eAdjust = HoriOrientation::RIGHT;
706  rListLevel.SetAdjust( eAdjust );
707  }
708  break;
709  case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_NAME:
710  sFontName = rValue;
711  break;
712  case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY:
713  sFontFamily = rValue;
714  break;
715  case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY_GENERIC:
716  sFontFamilyGeneric = rValue;
717  break;
718  case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_STYLENAME:
719  sFontStyleName = rValue;
720  break;
721  case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_PITCH:
722  sFontPitch = rValue;
723  break;
724  case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_CHARSET:
725  sFontCharset = rValue;
726  break;
727  case XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_POS:
728  sVerticalPos = rValue;
729  break;
730  case XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_REL:
731  sVerticalRel = rValue;
732  break;
733  case XML_TOK_STYLE_ATTRIBUTES_ATTR_WIDTH:
734  if (rUnitConv.convertMeasureToCore(nVal, rValue))
735  rListLevel.SetImageWidth( nVal );
736  break;
737  case XML_TOK_STYLE_ATTRIBUTES_ATTR_HEIGHT:
738  if (rUnitConv.convertMeasureToCore(nVal, rValue))
739  rListLevel.SetImageHeight( nVal );
740  break;
741  case XML_TOK_STYLE_ATTRIBUTES_ATTR_COLOR:
742  {
743  sal_Int32 nColor(0);
744  if (::sax::Converter::convertColor( nColor, rValue ))
745  {
746  rListLevel.SetColor( Color(nColor) );
747  }
748  }
749  break;
750  case XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR:
751  {
752  if( IsXMLToken( rValue, XML_TRUE ) )
753  rListLevel.SetColor( Color(0xffffffff) );
754  }
755  break;
756  case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE:
757  if (::sax::Converter::convertPercent( nVal, rValue ))
758  rListLevel.SetRelSize( static_cast<sal_Int16>(nVal) );
759  break;
760  case XML_TOK_STYLE_ATTRIBUTES_ATTR_POSITION_AND_SPACE_MODE:
761  {
762  sal_Int16 ePosAndSpaceMode = PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION;
763  if( IsXMLToken( rValue, XML_LABEL_ALIGNMENT ) )
764  ePosAndSpaceMode = PositionAndSpaceMode::LABEL_ALIGNMENT;
765  rListLevel.SetPosAndSpaceMode( ePosAndSpaceMode );
766  }
767  break;
768  }
769  }
770 
771  if( !sFontName.isEmpty() )
772  {
773  const XMLFontStylesContext *pFontDecls =
774  GetImport().GetFontDecls();
775  if( pFontDecls )
776  {
777  ::std::vector < XMLPropertyState > aProps;
778  if( pFontDecls->FillProperties( sFontName, aProps, 0, 1, 2, 3, 4 ) )
779  {
780  OUString sTmp;
781  sal_Int16 nTmp = 0;
782  for( const auto& rProp : aProps )
783  {
784  switch( rProp.mnIndex )
785  {
786  case 0:
787  rProp.maValue >>= sTmp;
788  rListLevel.SetBulletFontName( sTmp);
789  break;
790  case 1:
791  rProp.maValue >>= sTmp;
792  rListLevel.SetBulletFontStyleName( sTmp );
793  break;
794  case 2:
795  rProp.maValue >>= nTmp;
796  rListLevel.SetBulletFontFamily( nTmp );
797  break;
798  case 3:
799  rProp.maValue >>= nTmp;
800  rListLevel.SetBulletFontPitch( nTmp );
801  break;
802  case 4:
803  rProp.maValue >>= nTmp;
804  rListLevel.SetBulletFontEncoding( nTmp );
805  break;
806  }
807  }
808  }
809  }
810  }
811  if( !sFontFamily.isEmpty() )
812  {
813  Any aAny;
814 
815  XMLFontFamilyNamePropHdl aFamilyNameHdl;
816  if( aFamilyNameHdl.importXML( sFontFamily, aAny, rUnitConv ) )
817  {
818  OUString sTmp;
819  aAny >>= sTmp;
820  rListLevel.SetBulletFontName( sTmp);
821  }
822 
823  XMLFontFamilyPropHdl aFamilyHdl;
824  if( !sFontFamilyGeneric.isEmpty() &&
825  aFamilyHdl.importXML( sFontFamilyGeneric, aAny, rUnitConv ) )
826  {
827  sal_Int16 nTmp = 0;
828  aAny >>= nTmp;
829  rListLevel.SetBulletFontFamily( nTmp );
830  }
831 
832  if( !sFontStyleName.isEmpty() )
833  rListLevel.SetBulletFontStyleName( sFontStyleName );
834 
835  XMLFontPitchPropHdl aPitchHdl;
836  if( !sFontPitch.isEmpty() &&
837  aPitchHdl.importXML( sFontPitch, aAny, rUnitConv ) )
838  {
839  sal_Int16 nTmp = 0;
840  aAny >>= nTmp;
841  rListLevel.SetBulletFontPitch( nTmp );
842  }
843 
844  XMLFontEncodingPropHdl aEncHdl;
845  if( !sFontCharset.isEmpty() &&
846  aEncHdl.importXML( sFontCharset, aAny, rUnitConv ) )
847  {
848  sal_Int16 nTmp = 0;
849  aAny >>= nTmp;
850  rListLevel.SetBulletFontEncoding( nTmp );
851  }
852  }
853 
854  sal_Int16 eVertOrient = VertOrientation::LINE_CENTER;
855  if( !sVerticalPos.isEmpty() )
856  {
857  if( IsXMLToken( sVerticalPos, XML_TOP ) )
858  eVertOrient = VertOrientation::LINE_TOP;
859  else if( IsXMLToken( sVerticalPos, XML_BOTTOM ) )
860  eVertOrient = VertOrientation::LINE_BOTTOM;
861  }
862  if( !sVerticalRel.isEmpty() )
863  {
864  if( IsXMLToken( sVerticalRel, XML_BASELINE ) )
865  {
866  // TOP and BOTTOM are exchanged for a baseline relation
867  switch( eVertOrient )
868  {
869  case VertOrientation::LINE_TOP:
870  eVertOrient = VertOrientation::BOTTOM;
871  break;
872  case VertOrientation::LINE_CENTER:
873  eVertOrient = VertOrientation::CENTER;
874  break;
875  case VertOrientation::LINE_BOTTOM:
876  eVertOrient = VertOrientation::TOP;
877  break;
878  }
879  }
880  else if( IsXMLToken( sVerticalRel, XML_CHAR ) )
881  {
882  switch( eVertOrient )
883  {
884  case VertOrientation::LINE_TOP:
885  eVertOrient = VertOrientation::CHAR_TOP;
886  break;
887  case VertOrientation::LINE_CENTER:
888  eVertOrient = VertOrientation::CHAR_CENTER;
889  break;
890  case VertOrientation::LINE_BOTTOM:
891  eVertOrient = VertOrientation::CHAR_BOTTOM;
892  break;
893  }
894  }
895  }
896  rListLevel.SetImageVertOrient( eVertOrient );
897 }
898 
899 SvXMLImportContextRef SvxXMLListLevelStyleAttrContext_Impl::CreateChildContext(
900  sal_uInt16 nPrefix, const OUString& rLocalName,
901  const Reference< xml::sax::XAttributeList > & xAttrList )
902 {
903  SvXMLImportContext *pContext = nullptr;
904  if ( XML_NAMESPACE_STYLE == nPrefix &&
906  {
907  pContext = new SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl( GetImport(),
908  nPrefix,
909  rLocalName,
910  xAttrList,
911  rListLevel );
912  }
913 
914  return pContext;
915 }
916 
917 namespace {
918 
920 {
921  XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY,
922  XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION,
923  XML_TOK_STYLE_ATTRIBUTES_ATTR_FIRST_LINE_INDENT,
924  XML_TOK_STYLE_ATTRIBUTES_ATTR_INDENT_AT
925 };
926 
927 }
928 
930 {
931  static const SvXMLTokenMapEntry aStyleAlignmentAttributesAttrTokenMap[] =
932  {
934  XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY },
936  XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY },
938  XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION },
940  XML_TOK_STYLE_ATTRIBUTES_ATTR_FIRST_LINE_INDENT },
942  XML_TOK_STYLE_ATTRIBUTES_ATTR_INDENT_AT },
943 
945  };
946  return aStyleAlignmentAttributesAttrTokenMap;
947 }
948 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(
949  SvXMLImport& rImport, sal_uInt16 nPrfx,
950  const OUString& rLName,
951  const Reference< xml::sax::XAttributeList > & xAttrList,
953  SvXMLImportContext( rImport, nPrfx, rLName )
954 {
956  SvXMLUnitConverter& rUnitConv = GetImport().GetMM100UnitConverter();
957 
958  sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
959  sal_Int16 eLabelFollowedBy = LabelFollow::LISTTAB;
960  for( sal_Int16 i=0; i < nAttrCount; i++ )
961  {
962  const OUString& rAttrName = xAttrList->getNameByIndex( i );
963  OUString aLocalName;
964  sal_uInt16 nPrefix =
965  GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
966  &aLocalName );
967  const OUString& rValue = xAttrList->getValueByIndex( i );
968 
969  sal_Int32 nVal;
970  switch( aTokenMap.Get( nPrefix, aLocalName ) )
971  {
972  case XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY:
973  {
974  if( eLabelFollowedBy == LabelFollow::NEWLINE)
975  //NewLine from LO_EXT has precedence over other values of the Non LO_EXT namespace
976  break;
977  if( IsXMLToken( rValue, XML_SPACE ) )
978  eLabelFollowedBy = LabelFollow::SPACE;
979  else if( IsXMLToken( rValue, XML_NOTHING ) )
980  eLabelFollowedBy = LabelFollow::NOTHING;
981  else if( IsXMLToken( rValue, XML_NEWLINE ) )
982  eLabelFollowedBy = LabelFollow::NEWLINE;
983  }
984  break;
985  case XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION:
986  if (rUnitConv.convertMeasureToCore(nVal, rValue, 0, SHRT_MAX))
987  rLLevel.SetListtabStopPosition( nVal );
988  break;
989  case XML_TOK_STYLE_ATTRIBUTES_ATTR_FIRST_LINE_INDENT:
990  if (rUnitConv.convertMeasureToCore(nVal, rValue, SHRT_MIN, SHRT_MAX))
991  rLLevel.SetFirstLineIndent( nVal );
992  break;
993  case XML_TOK_STYLE_ATTRIBUTES_ATTR_INDENT_AT:
994  if (rUnitConv.convertMeasureToCore(nVal, rValue, SHRT_MIN, SHRT_MAX))
995  rLLevel.SetIndentAt( nVal );
996  break;
997  }
998  }
999  rLLevel.SetLabelFollowedBy( eLabelFollowedBy );
1000 }
1001 
1002 void SvxXMLListStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
1003  const OUString& rLocalName,
1004  const OUString& rValue )
1005 {
1006  if( XML_NAMESPACE_TEXT == nPrefixKey &&
1007  IsXMLToken( rLocalName, XML_CONSECUTIVE_NUMBERING ) )
1008  {
1009  bConsecutive = IsXMLToken( rValue, XML_TRUE );
1010  }
1011  else
1012  {
1013  SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
1014  }
1015 }
1016 
1017 static const OUStringLiteral sIsPhysical( "IsPhysical" );
1018 static const OUStringLiteral sNumberingRules( "NumberingRules" );
1019 static const OUStringLiteral sIsContinuousNumbering( "IsContinuousNumbering" );
1020 
1022  sal_uInt16 nPrfx,
1023  const OUString& rLName,
1024  const Reference< xml::sax::XAttributeList > & xAttrList,
1025  bool bOutl )
1026 : SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList, bOutl ? XmlStyleFamily::TEXT_OUTLINE : XmlStyleFamily::TEXT_LIST )
1027 , bConsecutive( false )
1028 , bOutline( bOutl )
1029 {
1030 }
1031 
1033  sal_Int32 nElement,
1034  const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
1035  bool bOutl )
1036 : SvXMLStyleContext( rImport, nElement, xAttrList, bOutl ? XmlStyleFamily::TEXT_OUTLINE : XmlStyleFamily::TEXT_LIST )
1037 , bConsecutive( false )
1038 , bOutline( bOutl )
1039 {
1040 }
1041 
1043 
1045  sal_uInt16 nPrefix,
1046  const OUString& rLocalName,
1047  const Reference< xml::sax::XAttributeList > & xAttrList )
1048 {
1049  SvXMLImportContextRef xContext;
1050 
1051  if( XML_NAMESPACE_TEXT == nPrefix &&
1052  ( bOutline
1053  ? IsXMLToken( rLocalName, XML_OUTLINE_LEVEL_STYLE )
1054  : ( IsXMLToken( rLocalName, XML_LIST_LEVEL_STYLE_NUMBER ) ||
1055  IsXMLToken( rLocalName, XML_LIST_LEVEL_STYLE_BULLET ) ||
1056  IsXMLToken( rLocalName, XML_LIST_LEVEL_STYLE_IMAGE ) ) ) )
1057  {
1060  rLocalName, xAttrList )};
1061  if( !pLevelStyles )
1062  pLevelStyles = std::make_unique<SvxXMLListStyle_Impl>();
1063  pLevelStyles->push_back( xLevelStyle );
1064 
1065  xContext = xLevelStyle.get();
1066  }
1067 
1068  return xContext;
1069 }
1070 
1072  const Reference<container::XIndexReplace> & rNumRule) const
1073 {
1074  try
1075  {
1076  if( pLevelStyles && rNumRule.is() )
1077  {
1078  sal_Int32 l_nLevels = rNumRule->getCount();
1079  for (const auto& pLevelStyle : *pLevelStyles)
1080  {
1081  sal_Int32 nLevel = pLevelStyle->GetLevel();
1082  if( nLevel >= 0 && nLevel < l_nLevels )
1083  {
1085  pLevelStyle->GetProperties();
1086  rNumRule->replaceByIndex( nLevel, Any(aProps) );
1087  }
1088  }
1089  }
1090 
1091  Reference < XPropertySet > xPropSet( rNumRule, UNO_QUERY );
1092  Reference< XPropertySetInfo > xPropSetInfo;
1093  if (xPropSet.is())
1094  xPropSetInfo = xPropSet->getPropertySetInfo();
1095  if( xPropSetInfo.is() &&
1096  xPropSetInfo->hasPropertyByName( sIsContinuousNumbering ) )
1097  {
1098  xPropSet->setPropertyValue( sIsContinuousNumbering, Any(bConsecutive) );
1099  }
1100  }
1101  catch (const Exception&)
1102  {
1103  OSL_FAIL( "SvxXMLListStyleContext::FillUnoNumRule - Exception caught" );
1104  }
1105 }
1106 
1108 {
1109  if( bOutline )
1110  {
1111  if( bOverwrite )
1112  {
1113  const Reference< XIndexReplace >& rNumRule =
1114  GetImport().GetTextImport()->GetChapterNumbering();
1115  // We don't set xNumberingRules here, to avoid using them
1116  // as numbering rules.
1117  if( rNumRule.is() )
1118  FillUnoNumRule(rNumRule);
1119  }
1120  }
1121  else
1122  {
1123  Reference < XStyle > xStyle;
1124  const OUString& rName = GetDisplayName();
1125  if( rName.isEmpty() )
1126  {
1127  SetValid( false );
1128  return;
1129  }
1130 
1131  const Reference < XNameContainer >& rNumStyles =
1132  GetImport().GetTextImport()->GetNumberingStyles();
1133  if( !rNumStyles.is() )
1134  {
1135  SetValid( false );
1136  return;
1137  }
1138 
1139  bool bNew = false;
1140  if( rNumStyles->hasByName( rName ) )
1141  {
1142  Any aAny = rNumStyles->getByName( rName );
1143  aAny >>= xStyle;
1144  }
1145  else
1146  {
1147  Reference< XMultiServiceFactory > xFactory( GetImport().GetModel(),
1148  UNO_QUERY );
1149  SAL_WARN_IF( !xFactory.is(), "xmloff", "no factory" );
1150  if( !xFactory.is() )
1151  return;
1152 
1153  Reference < XInterface > xIfc = xFactory->createInstance("com.sun.star.style.NumberingStyle");
1154  if( !xIfc.is() )
1155  return;
1156  Reference < XStyle > xTmp( xIfc, UNO_QUERY );
1157  xStyle = xTmp;
1158  if( !xStyle.is() )
1159  return;
1160 
1161  rNumStyles->insertByName( rName, Any(xStyle) );
1162  bNew = true;
1163  }
1164 
1165  Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
1166  Reference< XPropertySetInfo > xPropSetInfo =
1167  xPropSet->getPropertySetInfo();
1168  if( !bNew && xPropSetInfo->hasPropertyByName( sIsPhysical ) )
1169  {
1170  Any aAny = xPropSet->getPropertyValue( sIsPhysical );
1171  bNew = !*o3tl::doAccess<bool>(aAny);
1172  }
1173 
1174  if ( xPropSetInfo->hasPropertyByName( "Hidden" ) )
1175  xPropSet->setPropertyValue( "Hidden", uno::makeAny( IsHidden( ) ) );
1176 
1177  if( rName != GetName() )
1179  GetName(), rName );
1180 
1181  Any aAny = xPropSet->getPropertyValue( sNumberingRules );
1182  aAny >>= xNumRules;
1183  if( bOverwrite || bNew )
1184  {
1186  xPropSet->setPropertyValue( sNumberingRules, Any(xNumRules) );
1187  }
1188  else
1189  {
1190  SetValid( false );
1191  }
1192 
1193  SetNew( bNew );
1194  }
1195 }
1196 
1198 {
1199  SAL_WARN_IF( bOutline, "xmloff", "Outlines cannot be inserted here" );
1200  SAL_WARN_IF( xNumRules.is(), "xmloff", "Numbering Rule is existing already" );
1201 
1202  const OUString& rName = GetName();
1203  if( bOutline || xNumRules.is() || rName.isEmpty() )
1204  {
1205  const_cast<SvxXMLListStyleContext *>(this)->SetValid( false );
1206  return;
1207  }
1208 
1209  const_cast<SvxXMLListStyleContext *>(this)->xNumRules = CreateNumRule(
1210  GetImport().GetModel() );
1211 
1213 }
1214 
1215 Reference < XIndexReplace > SvxXMLListStyleContext::CreateNumRule(
1216  const Reference < XModel > & rModel )
1217 {
1218  Reference<XIndexReplace> xNumRule;
1219 
1220  Reference< XMultiServiceFactory > xFactory( rModel, UNO_QUERY );
1221  SAL_WARN_IF( !xFactory.is(), "xmloff", "no factory" );
1222  if( !xFactory.is() )
1223  return xNumRule;
1224 
1225  Reference < XInterface > xIfc = xFactory->createInstance("com.sun.star.text.NumberingRules");
1226  if( !xIfc.is() )
1227  return xNumRule;
1228 
1229  xNumRule.set( xIfc, UNO_QUERY );
1230  SAL_WARN_IF( !xNumRule.is(), "xmloff", "go no numbering rule" );
1231 
1232  return xNumRule;
1233 }
1234 
1236  const Reference < XIndexReplace > & rNumRule,
1237  sal_Int16 nLevel,
1238  bool bOrdered )
1239 {
1240  Sequence<beans::PropertyValue> aPropSeq( bOrdered ? 1 : 4 );
1241  beans::PropertyValue *pProps = aPropSeq.getArray();
1242 
1243  pProps->Name = "NumberingType";
1244  (pProps++)->Value <<= static_cast<sal_Int16>(bOrdered ? NumberingType::ARABIC
1245  : NumberingType::CHAR_SPECIAL );
1246  if( !bOrdered )
1247  {
1248  // TODO: Bullet-Font
1249  awt::FontDescriptor aFDesc;
1250  aFDesc.Name =
1251 #ifdef _WIN32
1252  "StarBats"
1253 #else
1254  "starbats"
1255 #endif
1256  ;
1257  aFDesc.Family = FAMILY_DONTKNOW ;
1258  aFDesc.Pitch = PITCH_DONTKNOW ;
1259  aFDesc.CharSet = RTL_TEXTENCODING_SYMBOL ;
1260  aFDesc.Weight = WEIGHT_DONTKNOW;
1261  pProps->Name = "BulletFont";
1262  (pProps++)->Value <<= aFDesc;
1263 
1264  OUString sTmp = OUStringChar(sal_Unicode(0xF000 + 149));
1265  pProps->Name = "BulletChar";
1266  (pProps++)->Value <<= sTmp;
1267  pProps->Name = "CharStyleName";
1268  (pProps++)->Value <<= OUString( "Numbering Symbols" );
1269  }
1270 
1271  rNumRule->replaceByIndex( nLevel, Any(aPropSeq) );
1272 }
1273 
1274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
Definition: xmlnmspe.hxx:80
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3422
constexpr sal_uInt16 XML_NAMESPACE_STYLE
Definition: xmlnmspe.hxx:30
css::uno::Reference< css::graphic::XGraphic > loadGraphicFromBase64(css::uno::Reference< css::io::XOutputStream > const &rxOutputStream)
Definition: xmlimp.cxx:1378
static XMLTokenEnum const aTokenMap[]
Definition: Oasis2OOo.cxx:1145
bool FillProperties(const OUString &rName,::std::vector< XMLPropertyState > &rProps, sal_Int32 nFamilyNameIdx, sal_Int32 nStyleNameIdx, sal_Int32 nFamilyIdx, sal_Int32 nPitchIdx, sal_Int32 nCharsetIdx) const
static const OUStringLiteral gsStarMath("StarMath")
void SetRelSize(sal_Int16 nRel)
Definition: xmlnumi.cxx:195
static const SvXMLTokenMapEntry * lcl_getLevelAttrTokenMap()
Definition: xmlnumi.cxx:125
PropertyHandler for the XML-data-type:
Definition: fonthdl.hxx:64
void SetMinLabelWidth(sal_Int32 nSet)
Definition: xmlnumi.cxx:199
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class...
Definition: fonthdl.cxx:197
bool convertNumFormat(sal_Int16 &rType, const OUString &rNumFormat, const OUString &rNumLetterSync, bool bNumberNone=false) const
convert num-format and num-letter-sync values to NumberingType
Definition: xmluconv.cxx:574
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:77
void SetNew(bool b)
Definition: xmlstyle.hxx:118
void FillUnoNumRule(const css::uno::Reference< css::container::XIndexReplace > &rNumRule) const
Definition: xmlnumi.cxx:1071
virtual void CreateAndInsertLate(bool bOverwrite) override
Definition: xmlnumi.cxx:1107
FAMILY_DONTKNOW
sal_Unicode ConvStarMathCharToStarSymbol(sal_Unicode c)
Definition: xmlimp.cxx:1791
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
void SetIndentAt(sal_Int32 nValue)
Definition: xmlnumi.cxx:246
void SetBulletFontStyleName(const OUString &rSet)
Definition: xmlnumi.cxx:204
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:397
void SetSpaceBefore(sal_Int32 nSet)
Definition: xmlnumi.cxx:198
constexpr sal_uInt16 XML_NAMESPACE_TEXT
Definition: xmlnmspe.hxx:31
static const OUStringLiteral sNumberingRules("NumberingRules")
css::uno::Reference< css::graphic::XGraphic > loadGraphicByURL(OUString const &rURL)
Definition: xmlimp.cxx:1356
static const OUStringLiteral gsStarBats("StarBats")
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:594
sal_Int32 nFirstLineOffset
Sequence< beans::PropertyValue > GetProperties()
Definition: xmlnumi.cxx:399
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
Definition: nmspmap.cxx:437
~SvxXMLListStyleContext() override
Definition: xmlnumi.cxx:1042
#define XML_TOKEN_MAP_END
Definition: xmltkmap.hxx:33
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class...
Definition: fonthdl.cxx:264
Value
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
bool convertMeasureToCore(sal_Int32 &rValue, const OUString &rString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32) const
convert string to measure with meCoreMeasureUnit, using optional min and max values ...
Definition: xmluconv.cxx:171
SvxXMLListLevelStyleContext_Impl(SvXMLImport &rImport, sal_uInt16 nPrfx, const OUString &rLName, const Reference< xml::sax::XAttributeList > &xAttrList)
Definition: xmlnumi.cxx:255
XmlStyleFamily
Definition: families.hxx:47
sal_uInt16 sal_Unicode
static const sal_uInt16 OOo_2x
Definition: xmlimp.hxx:537
static const OUStringLiteral sIsContinuousNumbering("IsContinuousNumbering")
void CreateAndInsertAuto() const
Definition: xmlnumi.cxx:1197
int nCount
std::unique_ptr< SvxXMLListStyle_Impl > pLevelStyles
Definition: xmlnumi.hxx:41
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class...
Definition: fonthdl.cxx:231
static const SvXMLTokenMapEntry * lcl_getStyleAttributesAttrTokenMap()
Definition: xmlnumi.cxx:614
css::uno::Reference< css::io::XOutputStream > GetStreamForGraphicObjectURLFromBase64() const
Definition: xmlimp.cxx:1390
sal_Int32 GetLevel() const
Definition: xmlnumi.cxx:227
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const Reference< xml::sax::XAttributeList > &xAttrList) override
Definition: xmlnumi.cxx:368
PropertyHandler for the XML-data-type:
Definition: fonthdl.hxx:28
static css::uno::Reference< css::container::XIndexReplace > CreateNumRule(const css::uno::Reference< css::frame::XModel > &rModel)
Definition: xmlnumi.cxx:1215
DocumentType eType
WEIGHT_DONTKNOW
PropertyHandler for the XML-data-type:
Definition: fonthdl.hxx:52
css::uno::Reference< css::container::XIndexReplace > xNumRules
Definition: xmlnumi.hxx:39
bool IsHidden() const
Definition: xmlstyle.hxx:120
const OUString & GetDisplayName() const
Definition: xmlstyle.hxx:107
void SetBulletFontFamily(sal_Int16 eSet)
Definition: xmlnumi.cxx:206
int i
void SetBulletFontName(const OUString &rSet)
Definition: xmlnumi.cxx:203
sal_Unicode ConvStarBatsCharToStarSymbol(sal_Unicode c)
Definition: xmlimp.cxx:1774
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class...
Definition: fonthdl.cxx:67
void SetLabelFollowedBy(sal_Int16 eValue)
Definition: xmlnumi.cxx:234
void SetBulletFontPitch(sal_Int16 eSet)
Definition: xmlnumi.cxx:207
void SetPosAndSpaceMode(sal_Int16 eValue)
Definition: xmlnumi.cxx:230
SvxXMLStyleAttributesAttrTokens
Definition: xmlnumi.cxx:590
rtl_TextEncoding eBulletFontEncoding
Definition: xmlnumi.cxx:176
void SetListtabStopPosition(sal_Int32 nValue)
Definition: xmlnumi.cxx:238
static const SvXMLTokenMapEntry * lcl_getStyleAlignmentAttributesAttrTokenMap()
Definition: xmlnumi.cxx:929
void SetMinLabelDist(sal_Int32 nSet)
Definition: xmlnumi.cxx:200
PITCH_DONTKNOW
sal_uInt16 Get(sal_uInt16 nPrefix, const OUString &rLName) const
Definition: xmltkmap.cxx:93
SvxXMLStyleAttributesLabelAlignmentAttrTokens
Definition: xmlnumi.cxx:919
sal_Int16 nVersion
void SetValid(bool b)
Definition: xmlstyle.hxx:115
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
constexpr sal_uInt16 XML_NAMESPACE_XLINK
Definition: xmlnmspe.hxx:35
constexpr sal_uInt16 XML_NAMESPACE_FO
Definition: xmlnmspe.hxx:34
static const OUStringLiteral sIsPhysical("IsPhysical")
SvxXMLListStyleContext(SvXMLImport &rImport, sal_uInt16 nPrfx, const OUString &rLName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList, bool bOutl=false)
void SetImageHeight(sal_Int32 nSet)
Definition: xmlnumi.cxx:212
long const nLeftMargin
OUString GetStyleDisplayName(XmlStyleFamily nFamily, const OUString &rName) const
Definition: xmlimp.cxx:1491
#define SAL_WARN_IF(condition, area, stream)
const OUString & GetName() const
Definition: xmlstyle.hxx:106
static bool convertColor(sal_Int32 &rColor, const OUString &rValue)
Handling of tokens in XML:
void SetBulletFontEncoding(rtl_TextEncoding eSet)
Definition: xmlnumi.cxx:208
static const sal_uInt16 OOo_1x
Definition: xmlimp.hxx:536
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
Definition: xmlnumi.cxx:1044
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlimp.hxx:399
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: xmlimp.hxx:403
Reference< XOutputStream > xBase64Stream
Definition: xmlnumi.cxx:162
SvxXMLTextListLevelStyleAttrTokens
Definition: xmlnumi.cxx:106
virtual void SetAttribute(sal_uInt16 nPrefixKey, const OUString &rLocalName, const OUString &rValue)
Definition: xmlstyle.cxx:94
void AddStyleDisplayName(XmlStyleFamily nFamily, const OUString &rName, const OUString &rDisplayName)
Definition: xmlimp.cxx:1460
void SetImageWidth(sal_Int32 nSet)
Definition: xmlnumi.cxx:211
Reference< XSingleServiceFactory > xFactory
virtual SAL_DLLPRIVATE void SetAttribute(sal_uInt16 nPrefixKey, const OUString &rLocalName, const OUString &rValue) override
Definition: xmlnumi.cxx:1002
static void SetDefaultStyle(const css::uno::Reference< css::container::XIndexReplace > &rNumRule, sal_Int16 nLevel, bool bOrdered)
Definition: xmlnumi.cxx:1235
PropertyHandler for the XML-data-type:
Definition: fonthdl.hxx:40
void SetImageVertOrient(sal_Int16 eSet)
Definition: xmlnumi.cxx:213
Reference< XGraphic > xGraphic
void SetFirstLineIndent(sal_Int32 nValue)
Definition: xmlnumi.cxx:242
void SetAdjust(sal_Int16 eSet)
Definition: xmlnumi.cxx:201
sal_uInt16 nPos
void SetColor(Color nColor)
Definition: xmlnumi.cxx:196
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
Definition: xmlnmspe.hxx:29
static bool convertPercent(sal_Int32 &rValue, const OUString &rString)