LibreOffice Module xmloff (master)  1
xmlnume.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 <sal/config.h>
21 
22 #include <com/sun/star/frame/XModel.hpp>
23 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
24 #include <com/sun/star/style/NumberingType.hpp>
25 #include <com/sun/star/style/XStyle.hpp>
26 #include <com/sun/star/container/XIndexReplace.hpp>
27 #include <com/sun/star/awt/XBitmap.hpp>
28 #include <com/sun/star/graphic/XGraphic.hpp>
29 #include <com/sun/star/awt/FontDescriptor.hpp>
30 #include <com/sun/star/text/HoriOrientation.hpp>
31 #include <com/sun/star/text/VertOrientation.hpp>
32 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
33 #include <com/sun/star/text/PositionAndSpaceMode.hpp>
34 #include <com/sun/star/text/LabelFollow.hpp>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 
38 #include <o3tl/any.hxx>
39 #include <o3tl/temporary.hxx>
40 #include <rtl/ustrbuf.hxx>
41 #include <sal/log.hxx>
42 
43 #include <sax/tools/converter.hxx>
44 
45 #include <xmloff/xmlnamespace.hxx>
46 #include <xmloff/xmltoken.hxx>
47 #include <xmloff/xmluconv.hxx>
48 #include "fonthdl.hxx"
50 #include <xmloff/xmlnume.hxx>
51 #include <xmloff/xmlexp.hxx>
52 #include <tools/fontenum.hxx>
53 #include <vcl/vclenum.hxx>
54 
55 using namespace ::com::sun::star;
56 using namespace ::com::sun::star::uno;
57 using namespace ::com::sun::star::style;
58 using namespace ::com::sun::star::text;
59 using namespace ::com::sun::star::container;
60 using namespace ::com::sun::star::beans;
61 using namespace ::xmloff::token;
62 
63 void SvxXMLNumRuleExport::exportLevelStyles( const uno::Reference< css::container::XIndexReplace > & xNumRule,
64  bool bOutline )
65 {
66  sal_Int32 nCount = xNumRule ->getCount();
67  for( sal_Int32 i=0; i<nCount; i++ )
68  {
69  uno::Any aEntry( xNumRule->getByIndex( i ) );
70  uno::Sequence<beans::PropertyValue> aSeq;
71  if( aEntry >>= aSeq )
72  {
73  exportLevelStyle( i, aSeq, bOutline );
74  }
75  }
76 }
77 
79  const uno::Sequence<beans::PropertyValue>& rProps,
80  bool bOutline )
81 {
82  sal_Int16 eType = NumberingType::CHAR_SPECIAL;
83 
84  sal_Int16 eAdjust = HoriOrientation::LEFT;
85  OUString sPrefix, sSuffix, sListFormat;
86  OUString sTextStyleName;
87  bool bHasColor = false;
88  sal_Int32 nColor = 0;
89  sal_Int32 nSpaceBefore = 0, nMinLabelWidth = 0, nMinLabelDist = 0;
90 
91  sal_Int16 nStartValue = 1, nDisplayLevels = 1, nBullRelSize = 0;
92 
93  sal_UCS4 cBullet = 0xf095;
94  OUString sBulletFontName, sBulletFontStyleName ;
95  FontFamily eBulletFontFamily = FAMILY_DONTKNOW;
96  FontPitch eBulletFontPitch = PITCH_DONTKNOW;
97  rtl_TextEncoding eBulletFontEncoding = RTL_TEXTENCODING_DONTKNOW;
98 
99  uno::Reference<graphic::XGraphic> xGraphic;
100 
101  sal_Int32 nImageWidth = 0, nImageHeight = 0;
102  sal_Int16 eImageVertOrient = VertOrientation::LINE_CENTER;
103 
104  sal_Int16 ePosAndSpaceMode = PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION;
105  sal_Int16 eLabelFollowedBy = LabelFollow::LISTTAB;
106  sal_Int32 nListtabStopPosition( 0 );
107  sal_Int32 nFirstLineIndent( 0 );
108  sal_Int32 nIndentAt( 0 );
109 
110  for( const beans::PropertyValue& rProp : rProps )
111  {
112  if( rProp.Name == "NumberingType" )
113  {
114  rProp.Value >>= eType;
115  }
116  else if( rProp.Name == "Prefix" )
117  {
118  rProp.Value >>= sPrefix;
119  }
120  else if( rProp.Name == "Suffix" )
121  {
122  rProp.Value >>= sSuffix;
123  }
124  else if (rProp.Name == "ListFormat")
125  {
126  rProp.Value >>= sListFormat;
127  }
128  else if (rProp.Name == "BulletChar")
129  {
130  OUString sValue;
131  rProp.Value >>= sValue;
132  if( !sValue.isEmpty() )
133  {
134  cBullet = sValue.iterateCodePoints(&o3tl::temporary(sal_Int32(0)));
135  }
136  }
137  else if( rProp.Name == "BulletRelSize" )
138  {
139  rProp.Value >>= nBullRelSize;
140  }
141  else if( rProp.Name == "Adjust" )
142  {
143  sal_Int16 nValue = 0;
144  rProp.Value >>= nValue;
145  eAdjust = nValue;
146  }
147  else if( rProp.Name == "BulletFont" )
148  {
149  awt::FontDescriptor rFDesc;
150  if( rProp.Value >>= rFDesc )
151  {
152  sBulletFontName = rFDesc.Name;
153  sBulletFontStyleName = rFDesc.StyleName;
154  eBulletFontFamily = static_cast< FontFamily >( rFDesc.Family );
155  eBulletFontPitch = static_cast< FontPitch >( rFDesc.Pitch );
156  eBulletFontEncoding = static_cast<rtl_TextEncoding>(rFDesc.CharSet);
157  }
158  }
159  else if( rProp.Name == "GraphicBitmap" )
160  {
161  uno::Reference<awt::XBitmap> xBitmap;
162  rProp.Value >>= xBitmap;
163  xGraphic.set(xBitmap, uno::UNO_QUERY);
164  }
165  else if( rProp.Name == "BulletColor" )
166  {
167  rProp.Value >>= nColor;
168  bHasColor = true;
169  }
170  else if( rProp.Name == "StartWith" )
171  {
172  rProp.Value >>= nStartValue;
173  }
174  else if( rProp.Name == "LeftMargin" )
175  {
176  rProp.Value >>= nSpaceBefore;
177  }
178  else if( rProp.Name == "FirstLineOffset" )
179  {
180  rProp.Value >>= nMinLabelWidth;
181  }
182  else if( rProp.Name == "SymbolTextDistance" )
183  {
184  rProp.Value >>= nMinLabelDist;
185  }
186  else if( rProp.Name == "ParentNumbering" )
187  {
188  rProp.Value >>= nDisplayLevels;
189  if( nDisplayLevels > nLevel+1 )
190  nDisplayLevels = static_cast<sal_Int16>( nLevel )+1;
191  }
192  else if( rProp.Name == "CharStyleName" )
193  {
194  rProp.Value >>= sTextStyleName;
195  }
196  else if( rProp.Name == "GraphicSize" )
197  {
198  awt::Size aSize;
199  if( rProp.Value >>= aSize )
200  {
201  nImageWidth = aSize.Width;
202  nImageHeight = aSize.Height;
203  }
204  }
205  else if( rProp.Name == "VertOrient" )
206  {
207  sal_Int16 nValue = 0;
208  rProp.Value >>= nValue;
209  eImageVertOrient = nValue;
210  }
211  else if( rProp.Name == "PositionAndSpaceMode" )
212  {
213  sal_Int16 nValue = 0;
214  rProp.Value >>= nValue;
215  ePosAndSpaceMode = nValue;
216  }
217  else if( rProp.Name == "LabelFollowedBy" )
218  {
219  sal_Int16 nValue = 0;
220  rProp.Value >>= nValue;
221  eLabelFollowedBy = nValue;
222  }
223  else if( rProp.Name == "ListtabStopPosition" )
224  {
225  rProp.Value >>= nListtabStopPosition;
226  }
227  else if( rProp.Name == "FirstLineIndent" )
228  {
229  rProp.Value >>= nFirstLineIndent;
230  }
231  else if( rProp.Name == "IndentAt" )
232  {
233  rProp.Value >>= nIndentAt;
234  }
235  }
236 
237  if( bOutline && (NumberingType::CHAR_SPECIAL == eType ||
238  NumberingType::BITMAP == eType) )
239  {
240  SAL_WARN_IF( bOutline, "xmloff",
241  "SvxXMLNumRuleExport::exportLevelStyle: invalid style for outline" );
242  return;
243  }
244 
246 
247  // text:level
248  OUStringBuffer sTmp;
249  GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_LEVEL, OUString::number( nLevel + 1 ) );
250  // #i110694#: no style-name on list-level-style-image
251  // #i116149#: neither prefix/suffix
252  if (NumberingType::BITMAP != eType)
253  {
254  if (!sTextStyleName.isEmpty())
255  {
257  GetExport().EncodeStyleName( sTextStyleName ) );
258  }
259  if (!sListFormat.isEmpty())
260  {
262  {
263  // Write only in extended mode: in ODF 1.3 we write only prefix/suffix,
264  // no list format yet available. Praying we did not lost some formatting.
266  }
267  }
268  if (!sPrefix.isEmpty())
269  {
271  sPrefix );
272  }
273  if (!sSuffix.isEmpty())
274  {
276  sSuffix );
277  }
278  }
279 
281  if( NumberingType::CHAR_SPECIAL == eType )
282  {
283  // <text:list-level-style-bullet>
285 
286  if( cBullet )
287  {
288  if( cBullet < ' ' )
289  {
290  cBullet = 0xF000 + 149;
291  }
292  // text:bullet-char="..."
293  sTmp.append(OUString(&cBullet, 1));
295  sTmp.makeStringAndClear() );
296  }
297  else
298  {
299  // If 'cBullet' is zero, XML_BULLET_CHAR must exist with blank.
301  }
302  }
303  else if( NumberingType::BITMAP == eType )
304  {
305  // <text:list-level-style-image>
306 
308 
309  if (xGraphic.is())
310  {
311  OUString sUsedMimeType;
312  OUString sInternalURL = GetExport().AddEmbeddedXGraphic(xGraphic, sUsedMimeType);
313  if (!sInternalURL.isEmpty())
314  {
319  }
320  }
321  else
322  {
323  SAL_WARN_IF(xGraphic.is(), "xmloff", "embedded images are not supported by now");
324  }
325  }
326  else
327  {
328  // <text:list-level-style-number> or <text:outline-level-style>
329  if( bOutline )
330  eElem = XML_OUTLINE_LEVEL_STYLE;
331  else
333 
336  sTmp.makeStringAndClear() );
338  if( !sTmp.isEmpty() )
341  sTmp.makeStringAndClear() );
342 
343  if( nStartValue != 1 )
344  {
345  sTmp.append( static_cast<sal_Int32>(nStartValue) );
347  sTmp.makeStringAndClear() );
348  }
349  if( nDisplayLevels > 1 && NumberingType::NUMBER_NONE != eType )
350  {
351  sTmp.append( static_cast<sal_Int32>(nDisplayLevels) );
353  sTmp.makeStringAndClear() );
354  }
355  }
356 
357  {
359  true, true );
360 
361  if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION )
362  {
363  nSpaceBefore += nMinLabelWidth;
364  nMinLabelWidth = -nMinLabelWidth;
365  if( nSpaceBefore != 0 )
366  {
368  nSpaceBefore );
370  }
371  if( nMinLabelWidth != 0 )
372  {
373  OUString s = GetExport().GetMM100UnitConverter().convertMeasureToXML( nMinLabelWidth );
375  }
376  if( nMinLabelDist > 0 )
377  {
379  nMinLabelDist );
381  }
382  }
383  /* Check, if properties for position-and-space-mode LABEL_ALIGNMENT
384  are allowed to be exported. (#i89178#)
385  */
386  else if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_ALIGNMENT &&
388  {
392  }
393  if( HoriOrientation::LEFT != eAdjust )
394  {
395  enum XMLTokenEnum eValue = XML_TOKEN_INVALID;
396  switch( eAdjust )
397  {
398  case HoriOrientation::RIGHT: eValue = XML_END; break;
399  case HoriOrientation::CENTER: eValue = XML_CENTER; break;
400  }
401  if( eValue != XML_TOKEN_INVALID )
403  }
404 
405  if( NumberingType::BITMAP == eType )
406  {
407  enum XMLTokenEnum eValue = XML_TOKEN_INVALID;
408  switch( eImageVertOrient )
409  {
410  case VertOrientation::BOTTOM: // yes, it's OK: BOTTOM means that the baseline
411  // hits the frame at its topmost position
412  case VertOrientation::LINE_TOP:
413  case VertOrientation::CHAR_TOP:
414  eValue = XML_TOP;
415  break;
416  case VertOrientation::CENTER:
417  case VertOrientation::LINE_CENTER:
418  case VertOrientation::CHAR_CENTER:
419  eValue = XML_MIDDLE;
420  break;
421  case VertOrientation::TOP: // yes, it's OK: TOP means that the baseline
422  // hits the frame at its bottommost position
423  case VertOrientation::LINE_BOTTOM:
424  case VertOrientation::CHAR_BOTTOM:
425  eValue = XML_BOTTOM;
426  break;
427  }
428  if( eValue != XML_TOKEN_INVALID )
430 
431  eValue = XML_TOKEN_INVALID;
432  switch( eImageVertOrient )
433  {
434  case VertOrientation::TOP:
435  case VertOrientation::CENTER:
436  case VertOrientation::BOTTOM:
437  eValue = XML_BASELINE;
438  break;
439  case VertOrientation::LINE_TOP:
440  case VertOrientation::LINE_CENTER:
441  case VertOrientation::LINE_BOTTOM:
442  eValue = XML_LINE;
443  break;
444  case VertOrientation::CHAR_TOP:
445  case VertOrientation::CHAR_CENTER:
446  case VertOrientation::CHAR_BOTTOM:
447  eValue = XML_CHAR;
448  break;
449  }
450  if( eValue != XML_TOKEN_INVALID )
452 
453  if( nImageWidth > 0 )
454  {
456  nImageWidth );
458  }
459 
460  if( nImageHeight > 0 )
461  {
463  nImageHeight );
465  }
466  }
467 
468  {
470  XML_LIST_LEVEL_PROPERTIES, true, true );
471 
472  /* Check, if properties for position-and-space-mode LABEL_ALIGNMENT
473  are allowed to be exported. (#i89178#)
474  */
475  if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_ALIGNMENT &&
477  {
478  enum XMLTokenEnum eValue = XML_LISTTAB;
479  if ( eLabelFollowedBy == LabelFollow::SPACE )
480  {
481  eValue = XML_SPACE;
482  }
483  else if ( eLabelFollowedBy == LabelFollow::NOTHING )
484  {
485  eValue = XML_NOTHING;
486  }
488  XML_LABEL_FOLLOWED_BY, eValue );
489 
490  if (eLabelFollowedBy == LabelFollow::NEWLINE)
491  {
492  eValue = XML_NEWLINE;
494  XML_LABEL_FOLLOWED_BY, eValue );
495  }
496 
497  if ( eLabelFollowedBy == LabelFollow::LISTTAB &&
498  nListtabStopPosition > 0 )
499  {
501  nListtabStopPosition );
504  sAttr );
505  }
506 
507  if ( nFirstLineIndent != 0 )
508  {
510  nFirstLineIndent );
513  sAttr );
514  }
515 
516  if ( nIndentAt != 0 )
517  {
519  nIndentAt );
522  sAttr );
523  }
524 
525  SvXMLElementExport aLabelAlignmentElement( GetExport(), XML_NAMESPACE_STYLE,
527  true, true );
528  }
529  }
530 
531  if( NumberingType::CHAR_SPECIAL == eType )
532  {
533  if( !sBulletFontName.isEmpty() )
534  {
535  OUString sStyleName =
537  sBulletFontName, sBulletFontStyleName,
538  eBulletFontFamily, eBulletFontPitch,
539  eBulletFontEncoding );
540 
541  if( !sStyleName.isEmpty() )
542  {
545  sStyleName );
546  }
547  else
548  {
549  OUString sTemp;
550 
551  const SvXMLUnitConverter& rUnitConv =
553  XMLFontFamilyNamePropHdl aFamilyNameHdl;
554  if( aFamilyNameHdl.exportXML( sTemp, Any(sBulletFontName), rUnitConv ) )
556  XML_FONT_FAMILY, sTemp );
557 
558  if( !sBulletFontStyleName.isEmpty() )
561  sBulletFontStyleName );
562 
563  XMLFontFamilyPropHdl aFamilyHdl;
564  if( aFamilyHdl.exportXML( sTemp, Any(static_cast<sal_Int16>(eBulletFontFamily)), rUnitConv ) )
567  sTemp );
568 
569  XMLFontPitchPropHdl aPitchHdl;
570  if( aPitchHdl.exportXML( sTemp, Any(static_cast<sal_Int16>(eBulletFontPitch)), rUnitConv ) )
572  XML_FONT_PITCH, sTemp );
573 
574  XMLFontEncodingPropHdl aEncHdl;
575  if( aEncHdl.exportXML( sTemp, Any(static_cast<sal_Int16>(eBulletFontEncoding)), rUnitConv ) )
577  XML_FONT_CHARSET, sTemp );
578  }
579  }
580  }
581  if( NumberingType::BITMAP != eType )
582  {
583  // fo:color = "#..."
584  if( bHasColor )
585  {
586  if (0xffffffff == static_cast<sal_uInt32>(nColor))
587  {
589  }
590  else
591  {
592  OUStringBuffer sBuffer;
593  ::sax::Converter::convertColor( sBuffer, nColor );
595  sBuffer.makeStringAndClear() );
596  }
597  }
598  // fo:height="...%"
599  if( nBullRelSize )
600  {
601  ::sax::Converter::convertPercent( sTmp, nBullRelSize );
603  sTmp.makeStringAndClear() );
604  }
605  }
606  if( GetExport().GetAttrList().getLength() > 0 )
607  {
609  XML_TEXT_PROPERTIES, true, true );
610  }
611  if (xGraphic.is() && NumberingType::BITMAP == eType)
612  {
613  // optional office:binary-data
615  }
616  }
617 }
618 
619 
620 constexpr OUStringLiteral gsNumberingRules( u"NumberingRules" );
621 constexpr OUStringLiteral gsIsPhysical( u"IsPhysical" );
622 constexpr OUStringLiteral gsIsContinuousNumbering( u"IsContinuousNumbering" );
623 
625  rExport( rExp ),
626  // Let list style creation depend on Load/Save option "ODF format version" (#i89178#)
627  mbExportPositionAndSpaceModeLabelAlignment( true )
628 {
629  switch (GetExport().getSaneDefaultVersion())
630  {
633  {
635  }
636  break;
637  default: // >= ODFSVER_012
638  {
640  }
641  }
642 }
643 
645 {
646 }
647 
649  const OUString& rName, bool bIsHidden,
650  const Reference< XIndexReplace >& rNumRule )
651 {
652  Reference< XPropertySet > xPropSet( rNumRule, UNO_QUERY );
653  Reference< XPropertySetInfo > xPropSetInfo;
654  if( xPropSet.is() )
655  xPropSetInfo = xPropSet->getPropertySetInfo();
656 
658 
659  // style:name="..."
660  if( !rName.isEmpty() )
661  {
662  bool bEncoded = false;
664  GetExport().EncodeStyleName( rName, &bEncoded ) );
665  if( bEncoded )
667  rName);
668  }
669 
670  // style:hidden="..."
671  if (bIsHidden
672  && GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
673  {
675  GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_HIDDEN, "true"); // FIXME for compatibility
676  }
677 
678  // text:consecutive-numbering="..."
679  bool bContNumbering = false;
680  if( xPropSetInfo.is() &&
681  xPropSetInfo->hasPropertyByName( gsIsContinuousNumbering ) )
682  {
683  Any aAny( xPropSet->getPropertyValue( gsIsContinuousNumbering ) );
684  bContNumbering = *o3tl::doAccess<bool>(aAny);
685  }
686  if( bContNumbering )
689 
690  {
692  true, true );
693  exportLevelStyles( rNumRule );
694  }
695 }
696 
697 void SvxXMLNumRuleExport::exportStyle( const Reference< XStyle >& rStyle )
698 {
699  Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
700  Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
701 
702  Any aAny;
703 
704  // Don't export styles that aren't existing really. This may be the
705  // case for StarOffice Writer's pool styles.
706  if( xPropSetInfo->hasPropertyByName( gsIsPhysical ) )
707  {
708  aAny = xPropSet->getPropertyValue( gsIsPhysical );
709  if( !*o3tl::doAccess<bool>(aAny) )
710  return;
711  }
712 
713  aAny = xPropSet->getPropertyValue( gsNumberingRules );
714  Reference<XIndexReplace> xNumRule;
715  aAny >>= xNumRule;
716 
717  OUString sName = rStyle->getName();
718 
719  bool bHidden = false;
720  if ( xPropSetInfo->hasPropertyByName( "Hidden" ) )
721  {
722  aAny = xPropSet->getPropertyValue( "Hidden" );
723  aAny >>= bHidden;
724  }
725 
726  exportNumberingRule( sName, bHidden, xNumRule );
727 }
728 
730 {
731  Reference< XChapterNumberingSupplier > xCNSupplier( GetExport().GetModel(),
732  UNO_QUERY );
733  SAL_WARN_IF( !xCNSupplier.is(), "xmloff", "no chapter numbering supplier" );
734 
735  if( !xCNSupplier.is() )
736  return;
737 
738  Reference< XIndexReplace > xNumRule( xCNSupplier->getChapterNumberingRules() );
739  SAL_WARN_IF( !xNumRule.is(), "xmloff", "no chapter numbering rules" );
740 
741  if( !xNumRule.is() )
742  return;
743 
744  /* Outline style has property style:name since ODF 1.2
745  Thus, export this property and adjust fix for issue #i69627# (#i90780#)
746  */
747  OUString sOutlineStyleName;
748  {
749  Reference<XPropertySet> xNumRulePropSet(
750  xCNSupplier->getChapterNumberingRules(), UNO_QUERY );
751  if (xNumRulePropSet.is())
752  {
753  xNumRulePropSet->getPropertyValue( "Name" ) >>= sOutlineStyleName;
754  }
755  }
756  const SvtSaveOptions::ODFSaneDefaultVersion nODFVersion =
758  if ((nODFVersion == SvtSaveOptions::ODFSVER_010 ||
759  nODFVersion == SvtSaveOptions::ODFSVER_011)
760  && GetExport().writeOutlineStyleAsNormalListStyle())
761  {
762  exportNumberingRule( sOutlineStyleName, false, xNumRule );
763  }
764  else
765  {
766  if (nODFVersion != SvtSaveOptions::ODFSVER_010 &&
767  nODFVersion != SvtSaveOptions::ODFSVER_011)
768  {
769  // style:name="..."
771  if ( !sOutlineStyleName.isEmpty() )
772  {
773  bool bEncoded = false;
775  GetExport().EncodeStyleName( sOutlineStyleName,
776  &bEncoded ) );
777  if( bEncoded )
780  sOutlineStyleName );
781  }
782  }
784  XML_OUTLINE_STYLE, true, true );
785  exportLevelStyles( xNumRule, true );
786  }
787 }
788 
791  bool bExportChapterNumbering )
792 {
793  if( bExportChapterNumbering )
794  exportOutline();
795 
796  Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetExport().GetModel(), UNO_QUERY );
797  SAL_WARN_IF( !xFamiliesSupp.is(), "xmloff", "No XStyleFamiliesSupplier from XModel for export!" );
798  if( !xFamiliesSupp.is() )
799  return;
800 
801  Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
802  SAL_WARN_IF( !xFamiliesSupp.is(), "xmloff", "getStyleFamilies() from XModel failed for export!" );
803 
804  if( !xFamilies.is() )
805  return;
806 
807  static const OUStringLiteral aNumberStyleName( u"NumberingStyles" );
808 
809  Reference< XIndexAccess > xStyles;
810  if( !xFamilies->hasByName( aNumberStyleName ) )
811  return;
812 
813  xFamilies->getByName( aNumberStyleName ) >>= xStyles;
814 
815  SAL_WARN_IF( !xStyles.is(), "xmloff", "Style not found for export!" );
816 
817  if( !xStyles.is() )
818  return;
819 
820  const sal_Int32 nStyles = xStyles->getCount();
821 
822  for( sal_Int32 i=0; i < nStyles; i++ )
823  {
824  Reference< XStyle > xStyle;
825  xStyles->getByIndex( i ) >>= xStyle;
826 
827  if( !bUsed || xStyle->isInUse() )
828  {
829  exportStyle( xStyle );
830  if( pPool )
831  pPool->RegisterName( xStyle->getName() );
832  }
833  }
834 }
835 
836 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvxXMLNumRuleExport(SvXMLExport &rExport)
Definition: xmlnume.cxx:624
SvXMLExport & GetExport()
Definition: xmlnume.hxx:55
sal_uInt32 sal_UCS4
PropertyHandler for the XML-data-type:
Definition: fonthdl.hxx:63
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:82
SAL_DLLPRIVATE void exportOutline()
Definition: xmlnume.cxx:729
SAL_DLLPRIVATE void exportStyle(const css::uno::Reference< css::style::XStyle > &rStyle)
Definition: xmlnume.cxx:697
constexpr OUStringLiteral gsNumberingRules(u"NumberingRules")
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:400
void CheckAttrList()
Definition: xmlexp.cxx:1059
FAMILY_DONTKNOW
constexpr sal_uInt16 XML_NAMESPACE_XLINK
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class...
Definition: fonthdl.cxx:272
SvXMLAttributeList & GetAttrList()
Definition: xmlexp.hxx:383
OUString sSuffix
int nCount
void AddAttribute(sal_uInt16 nPrefix, const char *pName, const OUString &rValue)
Definition: xmlexp.cxx:938
OUString AddEmbeddedXGraphic(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutMimeType, OUString const &rRequestedName=OUString())
Definition: xmlexp.cxx:1885
const char * sName
bool convertNumFormat(sal_Int16 &rType, const OUString &rNumFormat, std::u16string_view rNumLetterSync, bool bNumberNone=false) const
convert num-format and num-letter-sync values to NumberingType
Definition: xmluconv.cxx:701
PropertyHandler for the XML-data-type:
Definition: fonthdl.hxx:27
DocumentType eType
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
returns the deterministic version for odf export
Definition: xmlexp.cxx:2323
OUString sPrefix
PropertyHandler for the XML-data-type:
Definition: fonthdl.hxx:51
constexpr sal_uInt16 XML_NAMESPACE_FO
int i
void RegisterName(const OUString &rName)
constexpr sal_uInt16 XML_NAMESPACE_TEXT
void exportStyles(bool bUsed, XMLTextListAutoStylePool *pPool, bool bExportChapterNumbering)
Definition: xmlnume.cxx:789
virtual sal_Int16 SAL_CALL getLength() override
Definition: attrlist.cxx:34
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class...
Definition: fonthdl.cxx:239
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class...
Definition: fonthdl.cxx:207
float u
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
PITCH_DONTKNOW
constexpr OUStringLiteral gsIsPhysical(u"IsPhysical")
OUString sBulletFontName
FontPitch
constexpr T & temporary(T &&x)
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
bool mbExportPositionAndSpaceModeLabelAlignment
Definition: xmlnume.hxx:45
FontFamily
static void convertNumLetterSync(OUStringBuffer &rBuffer, sal_Int16 nType)
Definition: xmluconv.cxx:798
#define SAL_WARN_IF(condition, area, stream)
rtl::Reference< XMLFontAutoStylePool > const & GetFontAutoStylePool()
Definition: xmlexp.hxx:606
void exportLevelStyles(const css::uno::Reference< css::container::XIndexReplace > &xNumRule, bool bOutline=false)
Definition: xmlnume.cxx:63
Handling of tokens in XML:
void exportNumberingRule(const OUString &rName, bool bIsHidden, const css::uno::Reference< css::container::XIndexReplace > &xNumRule)
Definition: xmlnume.cxx:648
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class...
Definition: fonthdl.cxx:117
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
Sequence< sal_Int8 > aSeq
bool AddEmbeddedXGraphicAsBase64(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic)
Definition: xmlexp.cxx:1922
PropertyHandler for the XML-data-type:
Definition: fonthdl.hxx:39
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
convert measure to string: from meCoreMeasureUnit to meXMLMeasureUnit
Definition: xmluconv.cxx:206
constexpr sal_uInt16 XML_NAMESPACE_STYLE
constexpr OUStringLiteral gsIsContinuousNumbering(u"IsContinuousNumbering")
sal_Int16 nValue
SAL_DLLPRIVATE void exportLevelStyle(sal_Int32 nLevel, const css::uno::Sequence< css::beans::PropertyValue > &rProps, bool bOutline)
Definition: xmlnume.cxx:78