1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
22 #include <com/sun/star/style/NumberingType.hpp>
23 #include <com/sun/star/style/XStyle.hpp>
24 #include <com/sun/star/container/XNameContainer.hpp>
25 #include <com/sun/star/container/XIndexReplace.hpp>
26 #include <com/sun/star/awt/XBitmap.hpp>
27 #include <com/sun/star/awt/FontDescriptor.hpp>
28 #include <com/sun/star/text/HoriOrientation.hpp>
29 #include <com/sun/star/text/VertOrientation.hpp>
30 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
31 #include <com/sun/star/text/PositionAndSpaceMode.hpp>
32 #include <com/sun/star/text/LabelFollow.hpp>
33 #include <com/sun/star/beans/PropertyValue.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <rtl/ustrbuf.hxx>
38 #include <tools/debug.hxx>
40 #include <sax/tools/converter.hxx>
42 #include <xmloff/nmspmap.hxx>
43 #include <xmloff/xmlnmspe.hxx>
44 #include <xmloff/xmltoken.hxx>
45 #include <xmloff/xmluconv.hxx>
46 #include "fonthdl.hxx"
47 #include <xmloff/XMLTextListAutoStylePool.hxx>
48 #include <xmloff/xmlnume.hxx>
49 #include <xmloff/xmlexp.hxx>
50 #include <tools/fontenum.hxx>
54 using namespace ::com::sun::star
;
55 using namespace ::com::sun::star::uno
;
56 using namespace ::com::sun::star::style
;
57 using namespace ::com::sun::star::text
;
58 using namespace ::com::sun::star::container
;
59 using namespace ::com::sun::star::beans
;
60 using namespace ::xmloff::token
;
62 void SvxXMLNumRuleExport::exportLevelStyles( const uno::Reference
< ::com::sun::star::container::XIndexReplace
> & xNumRule
,
65 sal_Int32 nCount
= xNumRule
->getCount();
66 for( sal_Int32 i
=0; i
<nCount
; i
++ )
68 uno::Any
aEntry( xNumRule
->getByIndex( i
) );
69 uno::Sequence
<beans::PropertyValue
> aSeq
;
72 exportLevelStyle( i
, aSeq
, bOutline
);
77 void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel
,
78 const uno::Sequence
<beans::PropertyValue
>& rProps
,
81 sal_Int16 eType
= NumberingType::CHAR_SPECIAL
;
83 sal_Int16 eAdjust
= HoriOrientation::LEFT
;
84 OUString sPrefix
, sSuffix
;
85 OUString sTextStyleName
;
86 bool bHasColor
= false;
88 sal_Int32 nSpaceBefore
= 0, nMinLabelWidth
= 0, nMinLabelDist
= 0;
90 sal_Int16 nStartValue
= 1, nDisplayLevels
= 1, nBullRelSize
= 0;
92 sal_Unicode cBullet
= 0xf095;
93 OUString sBulletFontName
, sBulletFontStyleName
;
94 FontFamily eBulletFontFamily
= FAMILY_DONTKNOW
;
95 FontPitch eBulletFontPitch
= PITCH_DONTKNOW
;
96 rtl_TextEncoding eBulletFontEncoding
= RTL_TEXTENCODING_DONTKNOW
;
99 uno::Reference
< ::com::sun::star::awt::XBitmap
> xBitmap
;
100 sal_Int32 nImageWidth
= 0, nImageHeight
= 0;
101 sal_Int16 eImageVertOrient
= VertOrientation::LINE_CENTER
;
103 sal_Int16 ePosAndSpaceMode
= PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION
;
104 sal_Int16 eLabelFollowedBy
= LabelFollow::LISTTAB
;
105 sal_Int32
nListtabStopPosition( 0 );
106 sal_Int32
nFirstLineIndent( 0 );
107 sal_Int32
nIndentAt( 0 );
109 const sal_Int32 nCount
= rProps
.getLength();
110 const beans::PropertyValue
* pPropArray
= rProps
.getConstArray();
111 for( sal_Int32 i
=0; i
<nCount
; i
++ )
113 const beans::PropertyValue
& rProp
= pPropArray
[i
];
115 if( rProp
.Name
== "NumberingType" )
117 rProp
.Value
>>= eType
;
119 else if( rProp
.Name
== "Prefix" )
121 rProp
.Value
>>= sPrefix
;
123 else if( rProp
.Name
== "Suffix" )
125 rProp
.Value
>>= sSuffix
;
127 else if( rProp
.Name
== "BulletChar" )
130 rProp
.Value
>>= sValue
;
131 if( !sValue
.isEmpty() )
133 cBullet
= (sal_Unicode
)sValue
[0];
136 else if( rProp
.Name
== "BulletRelSize" )
138 rProp
.Value
>>= nBullRelSize
;
140 else if( rProp
.Name
== "Adjust" )
142 sal_Int16 nValue
= 0;
143 rProp
.Value
>>= nValue
;
146 else if( rProp
.Name
== "BulletFont" )
148 awt::FontDescriptor rFDesc
;
149 if( rProp
.Value
>>= rFDesc
)
151 sBulletFontName
= rFDesc
.Name
;
152 sBulletFontStyleName
= rFDesc
.StyleName
;
153 eBulletFontFamily
= static_cast< FontFamily
>( rFDesc
.Family
);
154 eBulletFontPitch
= static_cast< FontPitch
>( rFDesc
.Pitch
);
155 eBulletFontEncoding
= (rtl_TextEncoding
)rFDesc
.CharSet
;
158 else if( rProp
.Name
== "GraphicURL" )
160 rProp
.Value
>>= sImageURL
;
162 else if( rProp
.Name
== "GraphicBitmap" )
164 rProp
.Value
>>= xBitmap
;
166 else if( rProp
.Name
== "BulletColor" )
168 rProp
.Value
>>= nColor
;
171 else if( rProp
.Name
== "StartWith" )
173 rProp
.Value
>>= nStartValue
;
175 else if( rProp
.Name
== "LeftMargin" )
177 rProp
.Value
>>= nSpaceBefore
;
179 else if( rProp
.Name
== "FirstLineOffset" )
181 rProp
.Value
>>= nMinLabelWidth
;
183 else if( rProp
.Name
== "SymbolTextDistance" )
185 rProp
.Value
>>= nMinLabelDist
;
187 else if( rProp
.Name
== "ParentNumbering" )
189 rProp
.Value
>>= nDisplayLevels
;
190 if( nDisplayLevels
> nLevel
+1 )
191 nDisplayLevels
= static_cast<sal_Int16
>( nLevel
)+1;
193 else if( rProp
.Name
== "CharStyleName" )
195 rProp
.Value
>>= sTextStyleName
;
197 else if( rProp
.Name
== "GraphicSize" )
200 if( rProp
.Value
>>= aSize
)
202 nImageWidth
= aSize
.Width
;
203 nImageHeight
= aSize
.Height
;
206 else if( rProp
.Name
== "VertOrient" )
208 sal_Int16 nValue
= 0;
209 rProp
.Value
>>= nValue
;
210 eImageVertOrient
= nValue
;
212 else if( rProp
.Name
== "PositionAndSpaceMode" )
214 sal_Int16 nValue
= 0;
215 rProp
.Value
>>= nValue
;
216 ePosAndSpaceMode
= nValue
;
218 else if( rProp
.Name
== "LabelFollowedBy" )
220 sal_Int16 nValue
= 0;
221 rProp
.Value
>>= nValue
;
222 eLabelFollowedBy
= nValue
;
224 else if( rProp
.Name
== "ListtabStopPosition" )
226 rProp
.Value
>>= nListtabStopPosition
;
228 else if( rProp
.Name
== "FirstLineIndent" )
230 rProp
.Value
>>= nFirstLineIndent
;
232 else if( rProp
.Name
== "IndentAt" )
234 rProp
.Value
>>= nIndentAt
;
238 if( bOutline
&& (NumberingType::CHAR_SPECIAL
== eType
||
239 NumberingType::BITMAP
== eType
) )
241 DBG_ASSERT( !bOutline
,
242 "SvxXMLNumRuleExport::exportLevelStyle: invalid style for outline" );
246 GetExport().CheckAttrList();
250 sTmp
.append( nLevel
+ 1 );
251 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_LEVEL
, sTmp
.makeStringAndClear() );
252 // #i110694#: no style-name on list-level-style-image
253 // #i116149#: neither prefix/suffix
254 if (NumberingType::BITMAP
!= eType
)
256 if (!sTextStyleName
.isEmpty())
258 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
259 GetExport().EncodeStyleName( sTextStyleName
) );
261 if (!sPrefix
.isEmpty())
263 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_NUM_PREFIX
,
266 if (!sSuffix
.isEmpty())
268 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_NUM_SUFFIX
,
273 enum XMLTokenEnum eElem
= XML_LIST_LEVEL_STYLE_NUMBER
;
274 if( NumberingType::CHAR_SPECIAL
== eType
)
276 // <text:list-level-style-bullet>
277 eElem
= XML_LIST_LEVEL_STYLE_BULLET
;
283 cBullet
= 0xF000 + 149;
285 // text:bullet-char="..."
286 sTmp
.append( cBullet
);
287 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_BULLET_CHAR
,
288 sTmp
.makeStringAndClear() );
292 // If 'cBullet' is zero, XML_BULLET_CHAR must exist with blank.
293 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_BULLET_CHAR
, "");
296 else if( NumberingType::BITMAP
== eType
)
298 // <text:list-level-style-image>
300 eElem
= XML_LIST_LEVEL_STYLE_IMAGE
;
303 if( !sImageURL
.isEmpty() )
305 OUString
sURL( GetExport().AddEmbeddedGraphicObject( sImageURL
) );
306 if( !sURL
.isEmpty() )
308 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
, sURL
);
310 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
311 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_SHOW
, XML_EMBED
);
312 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_ACTUATE
, XML_ONLOAD
);
317 DBG_ASSERT( !xBitmap
.is(),
318 "embedded images are not supported by now" );
323 // <text:list-level-style-number> or <text:outline-level-style>
325 eElem
= XML_OUTLINE_LEVEL_STYLE
;
327 eElem
= XML_LIST_LEVEL_STYLE_NUMBER
;
329 GetExport().GetMM100UnitConverter().convertNumFormat( sTmp
, eType
);
330 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_NUM_FORMAT
,
331 sTmp
.makeStringAndClear() );
332 SvXMLUnitConverter::convertNumLetterSync( sTmp
, eType
);
333 if( !sTmp
.isEmpty() )
334 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
336 sTmp
.makeStringAndClear() );
338 if( nStartValue
!= 1 )
340 sTmp
.append( (sal_Int32
)nStartValue
);
341 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_START_VALUE
,
342 sTmp
.makeStringAndClear() );
344 if( nDisplayLevels
> 1 && NumberingType::NUMBER_NONE
!= eType
)
346 sTmp
.append( (sal_Int32
)nDisplayLevels
);
347 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_DISPLAY_LEVELS
,
348 sTmp
.makeStringAndClear() );
353 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
, eElem
,
356 OUStringBuffer sBuffer
;
357 if ( ePosAndSpaceMode
== PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION
)
359 nSpaceBefore
+= nMinLabelWidth
;
360 nMinLabelWidth
= -nMinLabelWidth
;
361 if( nSpaceBefore
!= 0 )
363 GetExport().GetMM100UnitConverter().convertMeasureToXML(
364 sBuffer
, nSpaceBefore
);
365 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_SPACE_BEFORE
,
366 sBuffer
.makeStringAndClear() );
368 if( nMinLabelWidth
!= 0 )
370 GetExport().GetMM100UnitConverter().convertMeasureToXML(
371 sBuffer
, nMinLabelWidth
);
372 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_MIN_LABEL_WIDTH
,
373 sBuffer
.makeStringAndClear() );
375 if( nMinLabelDist
> 0 )
377 GetExport().GetMM100UnitConverter().convertMeasureToXML(
378 sBuffer
, nMinLabelDist
);
379 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_MIN_LABEL_DISTANCE
,
380 sBuffer
.makeStringAndClear() );
383 /* Check, if properties for position-and-space-mode LABEL_ALIGNMENT
384 are allowed to be exported. (#i89178#)
386 else if ( ePosAndSpaceMode
== PositionAndSpaceMode::LABEL_ALIGNMENT
&&
387 mbExportPositionAndSpaceModeLabelAlignment
)
389 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
390 XML_LIST_LEVEL_POSITION_AND_SPACE_MODE
,
391 XML_LABEL_ALIGNMENT
);
393 if( HoriOrientation::LEFT
!= eAdjust
)
395 enum XMLTokenEnum eValue
= XML_TOKEN_INVALID
;
398 case HoriOrientation::RIGHT
: eValue
= XML_END
; break;
399 case HoriOrientation::CENTER
: eValue
= XML_CENTER
; break;
401 if( eValue
!= XML_TOKEN_INVALID
)
402 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_TEXT_ALIGN
, eValue
);
405 if( NumberingType::BITMAP
== eType
)
407 enum XMLTokenEnum eValue
= XML_TOKEN_INVALID
;
408 switch( eImageVertOrient
)
410 case VertOrientation::BOTTOM
: // yes, its OK: BOTTOM means that the baseline
411 // hits the frame at its topmost position
412 case VertOrientation::LINE_TOP
:
413 case VertOrientation::CHAR_TOP
:
416 case VertOrientation::CENTER
:
417 case VertOrientation::LINE_CENTER
:
418 case VertOrientation::CHAR_CENTER
:
421 case VertOrientation::TOP
: // yes, its OK: TOP means that the baseline
422 // hits the frame at its bottommost position
423 case VertOrientation::LINE_BOTTOM
:
424 case VertOrientation::CHAR_BOTTOM
:
428 if( eValue
!= XML_TOKEN_INVALID
)
429 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_VERTICAL_POS
, eValue
);
431 eValue
= XML_TOKEN_INVALID
;
432 switch( eImageVertOrient
)
434 case VertOrientation::TOP
:
435 case VertOrientation::CENTER
:
436 case VertOrientation::BOTTOM
:
437 eValue
= XML_BASELINE
;
439 case VertOrientation::LINE_TOP
:
440 case VertOrientation::LINE_CENTER
:
441 case VertOrientation::LINE_BOTTOM
:
444 case VertOrientation::CHAR_TOP
:
445 case VertOrientation::CHAR_CENTER
:
446 case VertOrientation::CHAR_BOTTOM
:
450 if( eValue
!= XML_TOKEN_INVALID
)
451 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_VERTICAL_REL
, eValue
);
453 if( nImageWidth
> 0 )
455 GetExport().GetMM100UnitConverter().convertMeasureToXML(
456 sBuffer
, nImageWidth
);
457 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_WIDTH
,
458 sBuffer
.makeStringAndClear() );
461 if( nImageHeight
> 0 )
463 GetExport().GetMM100UnitConverter().convertMeasureToXML(
464 sBuffer
, nImageHeight
);
465 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_HEIGHT
,
466 sBuffer
.makeStringAndClear() );
471 SvXMLElementExport
aElement( GetExport(), XML_NAMESPACE_STYLE
,
472 XML_LIST_LEVEL_PROPERTIES
, true, true );
474 /* Check, if properties for position-and-space-mode LABEL_ALIGNMENT
475 are allowed to be exported. (#i89178#)
477 if ( ePosAndSpaceMode
== PositionAndSpaceMode::LABEL_ALIGNMENT
&&
478 mbExportPositionAndSpaceModeLabelAlignment
)
480 enum XMLTokenEnum eValue
= XML_LISTTAB
;
481 if ( eLabelFollowedBy
== LabelFollow::SPACE
)
485 else if ( eLabelFollowedBy
== LabelFollow::NOTHING
)
487 eValue
= XML_NOTHING
;
489 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
490 XML_LABEL_FOLLOWED_BY
, eValue
);
492 if ( eLabelFollowedBy
== LabelFollow::LISTTAB
&&
493 nListtabStopPosition
> 0 )
495 GetExport().GetMM100UnitConverter().convertMeasureToXML(
496 sBuffer
, nListtabStopPosition
);
497 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
498 XML_LIST_TAB_STOP_POSITION
,
499 sBuffer
.makeStringAndClear() );
502 if ( nFirstLineIndent
!= 0 )
504 GetExport().GetMM100UnitConverter().convertMeasureToXML(
505 sBuffer
, nFirstLineIndent
);
506 GetExport().AddAttribute( XML_NAMESPACE_FO
,
508 sBuffer
.makeStringAndClear() );
511 if ( nIndentAt
!= 0 )
513 GetExport().GetMM100UnitConverter().convertMeasureToXML(
514 sBuffer
, nIndentAt
);
515 GetExport().AddAttribute( XML_NAMESPACE_FO
,
517 sBuffer
.makeStringAndClear() );
520 SvXMLElementExport
aLabelAlignmentElement( GetExport(), XML_NAMESPACE_STYLE
,
521 XML_LIST_LEVEL_LABEL_ALIGNMENT
,
526 if( NumberingType::CHAR_SPECIAL
== eType
)
528 if( !sBulletFontName
.isEmpty() )
530 OUString sStyleName
=
531 GetExport().GetFontAutoStylePool()->Find(
532 sBulletFontName
, sBulletFontStyleName
,
533 eBulletFontFamily
, eBulletFontPitch
,
534 eBulletFontEncoding
);
536 if( !sStyleName
.isEmpty() )
538 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
547 const SvXMLUnitConverter
& rUnitConv
=
548 GetExport().GetMM100UnitConverter();
549 XMLFontFamilyNamePropHdl aFamilyNameHdl
;
550 aAny
<<= sBulletFontName
;
551 if( aFamilyNameHdl
.exportXML( sTemp
, aAny
, rUnitConv
) )
552 GetExport().AddAttribute( XML_NAMESPACE_FO
,
553 XML_FONT_FAMILY
, sTemp
);
555 if( !sBulletFontStyleName
.isEmpty() )
556 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
558 sBulletFontStyleName
);
560 XMLFontFamilyPropHdl aFamilyHdl
;
561 aAny
<<= (sal_Int16
)eBulletFontFamily
;
562 if( aFamilyHdl
.exportXML( sTemp
, aAny
, rUnitConv
) )
563 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
564 XML_FONT_FAMILY_GENERIC
,
567 XMLFontPitchPropHdl aPitchHdl
;
568 aAny
<<= (sal_Int16
)eBulletFontPitch
;
569 if( aPitchHdl
.exportXML( sTemp
, aAny
, rUnitConv
) )
570 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
571 XML_FONT_PITCH
, sTemp
);
573 XMLFontEncodingPropHdl aEncHdl
;
574 aAny
<<= (sal_Int16
)eBulletFontEncoding
;
575 if( aEncHdl
.exportXML( sTemp
, aAny
, rUnitConv
) )
576 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
577 XML_FONT_CHARSET
, sTemp
);
581 if( NumberingType::BITMAP
!= eType
)
586 if (0xffffffff == static_cast<sal_uInt32
>(nColor
))
588 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_USE_WINDOW_FONT_COLOR
, XML_TRUE
);
592 ::sax::Converter::convertColor( sBuffer
, nColor
);
593 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_COLOR
,
594 sBuffer
.makeStringAndClear() );
600 ::sax::Converter::convertPercent( sTmp
, nBullRelSize
);
601 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_FONT_SIZE
,
602 sTmp
.makeStringAndClear() );
605 if( GetExport().GetAttrList().getLength() > 0 )
607 SvXMLElementExport
aElement( GetExport(), XML_NAMESPACE_STYLE
,
608 XML_TEXT_PROPERTIES
, true, true );
610 if( NumberingType::BITMAP
== eType
&& !sImageURL
.isEmpty() )
612 // optional office:binary-data
613 GetExport().AddEmbeddedGraphicObjectAsBase64( sImageURL
);
619 void SvxXMLNumRuleExport::AddListStyleAttributes()
624 SvxXMLNumRuleExport::SvxXMLNumRuleExport( SvXMLExport
& rExp
) :
626 sNumberingRules( "NumberingRules" ),
627 sIsPhysical( "IsPhysical" ),
628 sIsContinuousNumbering( "IsContinuousNumbering" ),
629 // Let list style creation depend on Load/Save option "ODF format version" (#i89178#)
630 mbExportPositionAndSpaceModeLabelAlignment( true )
632 switch ( GetExport().getDefaultVersion() )
634 case SvtSaveOptions::ODFVER_010
:
635 case SvtSaveOptions::ODFVER_011
:
637 mbExportPositionAndSpaceModeLabelAlignment
= false;
640 default: // ODFVER_UNKNOWN or ODFVER_012
642 mbExportPositionAndSpaceModeLabelAlignment
= true;
647 SvxXMLNumRuleExport::~SvxXMLNumRuleExport()
651 void SvxXMLNumRuleExport::exportNumberingRule(
652 const OUString
& rName
, bool bIsHidden
,
653 const Reference
< XIndexReplace
>& rNumRule
)
655 Reference
< XPropertySet
> xPropSet( rNumRule
, UNO_QUERY
);
656 Reference
< XPropertySetInfo
> xPropSetInfo
;
658 xPropSetInfo
= xPropSet
->getPropertySetInfo();
660 GetExport().CheckAttrList();
663 if( !rName
.isEmpty() )
665 bool bEncoded
= false;
666 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_NAME
,
667 GetExport().EncodeStyleName( rName
, &bEncoded
) );
669 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_DISPLAY_NAME
,
673 // style:hidden="..."
674 if ( bIsHidden
&& GetExport( ).getDefaultVersion( ) == SvtSaveOptions::ODFVER_LATEST
)
675 GetExport( ).AddAttribute( XML_NAMESPACE_STYLE
, XML_HIDDEN
, "true" );
677 // text:consecutive-numbering="..."
678 bool bContNumbering
= false;
679 if( xPropSetInfo
.is() &&
680 xPropSetInfo
->hasPropertyByName( sIsContinuousNumbering
) )
682 Any
aAny( xPropSet
->getPropertyValue( sIsContinuousNumbering
) );
683 bContNumbering
= *static_cast<sal_Bool
const *>(aAny
.getValue());
686 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
687 XML_CONSECUTIVE_NUMBERING
, XML_TRUE
);
689 // other application specific attributes
690 AddListStyleAttributes();
693 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
, XML_LIST_STYLE
,
695 exportLevelStyles( rNumRule
);
699 bool SvxXMLNumRuleExport::exportStyle( const Reference
< XStyle
>& rStyle
)
701 Reference
< XPropertySet
> xPropSet( rStyle
, UNO_QUERY
);
702 Reference
< XPropertySetInfo
> xPropSetInfo
= xPropSet
->getPropertySetInfo();
706 // Don't export styles that aren't existing really. This may be the
707 // case for StarOffice Writer's pool styles.
708 if( xPropSetInfo
->hasPropertyByName( sIsPhysical
) )
710 aAny
= xPropSet
->getPropertyValue( sIsPhysical
);
711 if( !*static_cast<sal_Bool
const *>(aAny
.getValue()) )
715 aAny
= xPropSet
->getPropertyValue( sNumberingRules
);
716 Reference
<XIndexReplace
> xNumRule
;
719 OUString sName
= rStyle
->getName();
721 bool bHidden
= false;
722 if ( xPropSetInfo
->hasPropertyByName( "Hidden" ) )
724 aAny
= xPropSet
->getPropertyValue( "Hidden" );
728 exportNumberingRule( sName
, bHidden
, xNumRule
);
733 void SvxXMLNumRuleExport::exportOutline()
735 Reference
< XChapterNumberingSupplier
> xCNSupplier( GetExport().GetModel(),
737 DBG_ASSERT( xCNSupplier
.is(), "no chapter numbering supplier" );
739 if( xCNSupplier
.is() )
741 Reference
< XIndexReplace
> xNumRule( xCNSupplier
->getChapterNumberingRules() );
742 DBG_ASSERT( xNumRule
.is(), "no chapter numbering rules" );
746 /* Outline style has property style:name since ODF 1.2
747 Thus, export this property and adjust fix for issue #i69627# (#i90780#)
749 OUString sOutlineStyleName
;
751 Reference
<XPropertySet
> xNumRulePropSet(
752 xCNSupplier
->getChapterNumberingRules(), UNO_QUERY
);
753 if (xNumRulePropSet
.is())
755 const OUString
sName( "Name" );
756 xNumRulePropSet
->getPropertyValue( sName
) >>= sOutlineStyleName
;
759 const SvtSaveOptions::ODFDefaultVersion nODFVersion
=
760 GetExport().getDefaultVersion();
761 if ( ( nODFVersion
== SvtSaveOptions::ODFVER_010
||
762 nODFVersion
== SvtSaveOptions::ODFVER_011
) &&
763 GetExport().writeOutlineStyleAsNormalListStyle() )
765 exportNumberingRule( sOutlineStyleName
, false, xNumRule
);
769 if ( nODFVersion
!= SvtSaveOptions::ODFVER_010
&&
770 nODFVersion
!= SvtSaveOptions::ODFVER_011
)
773 GetExport().CheckAttrList();
774 if ( !sOutlineStyleName
.isEmpty() )
776 bool bEncoded
= false;
777 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_NAME
,
778 GetExport().EncodeStyleName( sOutlineStyleName
,
781 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
786 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
787 XML_OUTLINE_STYLE
, true, true );
788 exportLevelStyles( xNumRule
, true );
794 void SvxXMLNumRuleExport::exportStyles( bool bUsed
,
795 XMLTextListAutoStylePool
*pPool
,
796 bool bExportChapterNumbering
)
798 if( bExportChapterNumbering
)
801 Reference
< XStyleFamiliesSupplier
> xFamiliesSupp( GetExport().GetModel(), UNO_QUERY
);
802 DBG_ASSERT( xFamiliesSupp
.is(), "No XStyleFamiliesSupplier from XModel for export!" );
803 if( xFamiliesSupp
.is() )
805 Reference
< XNameAccess
> xFamilies( xFamiliesSupp
->getStyleFamilies() );
806 DBG_ASSERT( xFamiliesSupp
.is(), "getStyleFamilies() from XModel failed for export!" );
810 const OUString
aNumberStyleName( "NumberingStyles" );
812 Reference
< XIndexAccess
> xStyles
;
813 if( xFamilies
->hasByName( aNumberStyleName
) )
815 xFamilies
->getByName( aNumberStyleName
) >>= xStyles
;
817 DBG_ASSERT( xStyles
.is(), "Style not found for export!" );
821 const sal_Int32 nStyles
= xStyles
->getCount();
823 for( sal_Int32 i
=0; i
< nStyles
; i
++ )
825 Reference
< XStyle
> xStyle
;
826 xStyles
->getByIndex( i
) >>= xStyle
;
828 if( !bUsed
|| xStyle
->isInUse() )
830 exportStyle( xStyle
);
832 pPool
->RegisterName( xStyle
->getName() );
841 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */