1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
31 #include <com/sun/star/style/NumberingType.hpp>
32 #include <com/sun/star/style/XStyle.hpp>
33 #include <com/sun/star/container/XNameContainer.hpp>
34 #include <com/sun/star/container/XIndexReplace.hpp>
35 #include <com/sun/star/awt/XBitmap.hpp>
36 #include <com/sun/star/awt/FontDescriptor.hpp>
37 #include <com/sun/star/text/HoriOrientation.hpp>
38 #include <com/sun/star/text/VertOrientation.hpp>
39 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
40 #include <com/sun/star/text/PositionAndSpaceMode.hpp>
41 #include <com/sun/star/text/LabelFollow.hpp>
42 #include <com/sun/star/beans/PropertyValue.hpp>
43 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <rtl/ustrbuf.hxx>
47 #include <tools/debug.hxx>
49 #include <sax/tools/converter.hxx>
51 #include <xmloff/nmspmap.hxx>
52 #include "xmloff/xmlnmspe.hxx"
53 #include <xmloff/xmltoken.hxx>
54 #include <xmloff/xmluconv.hxx>
55 #include "fonthdl.hxx"
56 #include "xmloff/XMLTextListAutoStylePool.hxx"
57 #include <xmloff/xmlnume.hxx>
58 #include <xmloff/xmlexp.hxx>
59 #include <tools/fontenum.hxx>
62 using ::rtl::OUString
;
63 using ::rtl::OUStringBuffer
;
65 using namespace ::com::sun::star
;
66 using namespace ::com::sun::star::uno
;
67 using namespace ::com::sun::star::style
;
68 using namespace ::com::sun::star::text
;
69 using namespace ::com::sun::star::container
;
70 using namespace ::com::sun::star::beans
;
71 using namespace ::xmloff::token
;
73 static sal_Char
const XML_UNO_NAME_NRULE_SYMBOL_TEXT_DISTANCE
[] = "SymbolTextDistance";
74 static sal_Char
const XML_UNO_NAME_NRULE_PARENT_NUMBERING
[] = "ParentNumbering";
75 static sal_Char
const XML_UNO_NAME_NRULE_CHAR_STYLE_NAME
[] = "CharStyleName";
76 static sal_Char
const XML_UNO_NAME_NRULE_BULLET_CHAR
[] = "BulletChar";
77 static sal_Char
const XML_UNO_NAME_NRULE_BULLET_RELSIZE
[] = "BulletRelSize";
78 static sal_Char
const XML_UNO_NAME_NRULE_BULLET_COLOR
[] = "BulletColor";
79 static sal_Char
const XML_UNO_NAME_NRULE_GRAPHIC_BITMAP
[] = "GraphicBitmap";
80 static sal_Char
const XML_UNO_NAME_NRULE_GRAPHIC_SIZE
[] = "GraphicSize";
81 static sal_Char
const XML_UNO_NAME_NRULE_VERT_ORIENT
[] = "VertOrient";
82 static sal_Char
const XML_UNO_NAME_NRULE_NUMBERINGTYPE
[] = "NumberingType";
83 static sal_Char
const XML_UNO_NAME_NRULE_HEADING_STYLE_NAME
[] = "HeadingStyleName";
84 static sal_Char
const XML_UNO_NAME_NRULE_PREFIX
[] = "Prefix";
85 static sal_Char
const XML_UNO_NAME_NRULE_SUFFIX
[] = "Suffix";
86 static sal_Char
const XML_UNO_NAME_NRULE_ADJUST
[] = "Adjust";
87 static sal_Char
const XML_UNO_NAME_NRULE_LEFT_MARGIN
[] = "LeftMargin";
88 static sal_Char
const XML_UNO_NAME_NRULE_FIRST_LINE_OFFSET
[] = "FirstLineOffset";
89 static sal_Char
const XML_UNO_NAME_NRULE_BULLET_FONT
[] = "BulletFont";
90 static sal_Char
const XML_UNO_NAME_NRULE_GRAPHICURL
[] = "GraphicURL";
91 static sal_Char
const XML_UNO_NAME_NRULE_START_WITH
[] = "StartWith";
92 static sal_Char
const XML_UNO_NAME_NRULE_POSITION_AND_SPACE_MODE
[] = "PositionAndSpaceMode";
93 static sal_Char
const XML_UNO_NAME_NRULE_LABEL_FOLLOWED_BY
[] = "LabelFollowedBy";
94 static sal_Char
const XML_UNO_NAME_NRULE_LISTTAB_STOP_POSITION
[] = "ListtabStopPosition";
95 static sal_Char
const XML_UNO_NAME_NRULE_FIRST_LINE_INDENT
[] = "FirstLineIndent";
96 static sal_Char
const XML_UNO_NAME_NRULE_INDENT_AT
[] = "IndentAt";
98 void SvxXMLNumRuleExport::exportLevelStyles( const uno::Reference
< ::com::sun::star::container::XIndexReplace
> & xNumRule
,
101 sal_Int32 nCount
= xNumRule
->getCount();
102 for( sal_Int32 i
=0; i
<nCount
; i
++ )
104 uno::Any
aEntry( xNumRule
->getByIndex( i
) );
105 uno::Sequence
<beans::PropertyValue
> aSeq
;
106 if( aEntry
>>= aSeq
)
108 exportLevelStyle( i
, aSeq
, bOutline
);
113 void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel
,
114 const uno::Sequence
<beans::PropertyValue
>& rProps
,
117 sal_Int16 eType
= NumberingType::CHAR_SPECIAL
;
119 sal_Int16 eAdjust
= HoriOrientation::LEFT
;
120 OUString sPrefix
, sSuffix
;
121 OUString sTextStyleName
;
122 sal_Bool bHasColor
= sal_False
;
123 sal_Int32 nColor
= 0;
124 sal_Int32 nSpaceBefore
= 0, nMinLabelWidth
= 0, nMinLabelDist
= 0;
126 sal_Int16 nStartValue
= 1, nDisplayLevels
= 1, nBullRelSize
= 0;
128 sal_Unicode cBullet
= 0xf095;
129 OUString sBulletFontName
, sBulletFontStyleName
;
130 sal_Int16 eBulletFontFamily
= FAMILY_DONTKNOW
;
131 sal_Int16 eBulletFontPitch
= PITCH_DONTKNOW
;
132 rtl_TextEncoding eBulletFontEncoding
= RTL_TEXTENCODING_DONTKNOW
;
135 uno::Reference
< ::com::sun::star::awt::XBitmap
> xBitmap
;
136 sal_Int32 nImageWidth
= 0, nImageHeight
= 0;
137 sal_Int16 eImageVertOrient
= VertOrientation::LINE_CENTER
;
139 sal_Int16 ePosAndSpaceMode
= PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION
;
140 sal_Int16 eLabelFollowedBy
= LabelFollow::LISTTAB
;
141 sal_Int32
nListtabStopPosition( 0 );
142 sal_Int32
nFirstLineIndent( 0 );
143 sal_Int32
nIndentAt( 0 );
145 const sal_Int32 nCount
= rProps
.getLength();
146 const beans::PropertyValue
* pPropArray
= rProps
.getConstArray();
147 for( sal_Int32 i
=0; i
<nCount
; i
++ )
149 const beans::PropertyValue
& rProp
= pPropArray
[i
];
151 if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_NUMBERINGTYPE
, sizeof(XML_UNO_NAME_NRULE_NUMBERINGTYPE
)-1 ) )
153 rProp
.Value
>>= eType
;
155 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_PREFIX
, sizeof(XML_UNO_NAME_NRULE_PREFIX
)-1 ) )
157 rProp
.Value
>>= sPrefix
;
159 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_SUFFIX
, sizeof(XML_UNO_NAME_NRULE_SUFFIX
)-1 ) )
161 rProp
.Value
>>= sSuffix
;
163 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_BULLET_CHAR
, sizeof(XML_UNO_NAME_NRULE_BULLET_CHAR
)-1 ) )
166 rProp
.Value
>>= sValue
;
167 if( !sValue
.isEmpty() )
169 cBullet
= (sal_Unicode
)sValue
[0];
172 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_BULLET_RELSIZE
, sizeof(XML_UNO_NAME_NRULE_BULLET_RELSIZE
)-1 ) )
174 rProp
.Value
>>= nBullRelSize
;
176 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_ADJUST
, sizeof(XML_UNO_NAME_NRULE_ADJUST
)-1 ) )
178 sal_Int16 nValue
= 0;
179 rProp
.Value
>>= nValue
;
182 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_BULLET_FONT
, sizeof(XML_UNO_NAME_NRULE_BULLET_FONT
)-1 ) )
184 awt::FontDescriptor rFDesc
;
185 if( rProp
.Value
>>= rFDesc
)
187 sBulletFontName
= rFDesc
.Name
;
188 sBulletFontStyleName
= rFDesc
.StyleName
;
189 eBulletFontFamily
= (sal_Int16
)rFDesc
.Family
;
190 eBulletFontPitch
= (sal_Int16
)rFDesc
.Pitch
;
191 eBulletFontEncoding
= (rtl_TextEncoding
)rFDesc
.CharSet
;
194 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_GRAPHICURL
, sizeof(XML_UNO_NAME_NRULE_GRAPHICURL
)-1 ) )
196 rProp
.Value
>>= sImageURL
;
198 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_GRAPHIC_BITMAP
, sizeof(XML_UNO_NAME_NRULE_GRAPHIC_BITMAP
)-1 ) )
200 rProp
.Value
>>= xBitmap
;
202 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_BULLET_COLOR
, sizeof(XML_UNO_NAME_NRULE_BULLET_COLOR
)-1 ) )
204 rProp
.Value
>>= nColor
;
205 bHasColor
= sal_True
;
207 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_START_WITH
, sizeof(XML_UNO_NAME_NRULE_START_WITH
)-1 ) )
209 rProp
.Value
>>= nStartValue
;
211 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_LEFT_MARGIN
, sizeof(XML_UNO_NAME_NRULE_LEFT_MARGIN
)-1 ) )
213 rProp
.Value
>>= nSpaceBefore
;
215 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_FIRST_LINE_OFFSET
, sizeof(XML_UNO_NAME_NRULE_FIRST_LINE_OFFSET
)-1 ) )
217 rProp
.Value
>>= nMinLabelWidth
;
219 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_SYMBOL_TEXT_DISTANCE
, sizeof(XML_UNO_NAME_NRULE_SYMBOL_TEXT_DISTANCE
)-1 ) )
221 rProp
.Value
>>= nMinLabelDist
;
223 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_PARENT_NUMBERING
, sizeof(XML_UNO_NAME_NRULE_PARENT_NUMBERING
)-1 ) )
225 rProp
.Value
>>= nDisplayLevels
;
226 if( nDisplayLevels
> nLevel
+1 )
227 nDisplayLevels
= static_cast<sal_Int16
>( nLevel
)+1;
229 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_CHAR_STYLE_NAME
, sizeof(XML_UNO_NAME_NRULE_CHAR_STYLE_NAME
)-1 ) )
231 rProp
.Value
>>= sTextStyleName
;
233 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_GRAPHIC_SIZE
, sizeof(XML_UNO_NAME_NRULE_GRAPHIC_SIZE
)-1 ) )
236 if( rProp
.Value
>>= aSize
)
238 nImageWidth
= aSize
.Width
;
239 nImageHeight
= aSize
.Height
;
242 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_VERT_ORIENT
, sizeof(XML_UNO_NAME_NRULE_VERT_ORIENT
)-1 ) )
244 sal_Int16 nValue
= 0;
245 rProp
.Value
>>= nValue
;
246 eImageVertOrient
= nValue
;
248 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_POSITION_AND_SPACE_MODE
,
249 sizeof(XML_UNO_NAME_NRULE_POSITION_AND_SPACE_MODE
)-1 ) )
251 sal_Int16 nValue
= 0;
252 rProp
.Value
>>= nValue
;
253 ePosAndSpaceMode
= nValue
;
255 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_LABEL_FOLLOWED_BY
,
256 sizeof(XML_UNO_NAME_NRULE_LABEL_FOLLOWED_BY
)-1 ) )
258 sal_Int16 nValue
= 0;
259 rProp
.Value
>>= nValue
;
260 eLabelFollowedBy
= nValue
;
262 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_LISTTAB_STOP_POSITION
,
263 sizeof(XML_UNO_NAME_NRULE_LISTTAB_STOP_POSITION
)-1 ) )
265 rProp
.Value
>>= nListtabStopPosition
;
267 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_FIRST_LINE_INDENT
,
268 sizeof(XML_UNO_NAME_NRULE_FIRST_LINE_INDENT
)-1 ) )
270 rProp
.Value
>>= nFirstLineIndent
;
272 else if( rProp
.Name
.equalsAsciiL( XML_UNO_NAME_NRULE_INDENT_AT
,
273 sizeof(XML_UNO_NAME_NRULE_INDENT_AT
)-1 ) )
275 rProp
.Value
>>= nIndentAt
;
279 if( bOutline
&& (NumberingType::CHAR_SPECIAL
== eType
||
280 NumberingType::BITMAP
== eType
) )
282 DBG_ASSERT( !bOutline
,
283 "SvxXMLNumRuleExport::exportLevelStyle: invalid style for outline" );
287 GetExport().CheckAttrList();
291 sTmp
.append( nLevel
+ 1 );
292 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_LEVEL
, sTmp
.makeStringAndClear() );
293 // #i110694#: no style-name on list-level-style-image
294 // #i116149#: neither prefix/suffix
295 if (NumberingType::BITMAP
!= eType
)
297 if (!sTextStyleName
.isEmpty())
299 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
300 GetExport().EncodeStyleName( sTextStyleName
) );
302 if (!sPrefix
.isEmpty())
304 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_NUM_PREFIX
,
307 if (!sSuffix
.isEmpty())
309 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_NUM_SUFFIX
,
314 enum XMLTokenEnum eElem
= XML_LIST_LEVEL_STYLE_NUMBER
;
315 if( NumberingType::CHAR_SPECIAL
== eType
)
317 // <text:list-level-style-bullet>
318 eElem
= XML_LIST_LEVEL_STYLE_BULLET
;
324 cBullet
= 0xF000 + 149;
326 // text:bullet-char="..."
327 sTmp
.append( cBullet
);
328 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_BULLET_CHAR
,
329 sTmp
.makeStringAndClear() );
333 else if( NumberingType::BITMAP
== eType
)
335 // <text:list-level-style-image>
337 eElem
= XML_LIST_LEVEL_STYLE_IMAGE
;
340 if( !sImageURL
.isEmpty() )
342 OUString
sURL( GetExport().AddEmbeddedGraphicObject( sImageURL
) );
343 if( !sURL
.isEmpty() )
345 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
, sURL
);
347 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
348 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_SHOW
, XML_EMBED
);
349 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_ACTUATE
, XML_ONLOAD
);
354 DBG_ASSERT( !xBitmap
.is(),
355 "embedded images are not supported by now" );
360 // <text:list-level-style-number> or <text:outline-level-style>
362 eElem
= XML_OUTLINE_LEVEL_STYLE
;
364 eElem
= XML_LIST_LEVEL_STYLE_NUMBER
;
366 GetExport().GetMM100UnitConverter().convertNumFormat( sTmp
, eType
);
367 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_NUM_FORMAT
,
368 sTmp
.makeStringAndClear() );
369 GetExport().GetMM100UnitConverter().convertNumLetterSync( sTmp
, eType
);
370 if( sTmp
.getLength() )
371 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
373 sTmp
.makeStringAndClear() );
375 if( nStartValue
!= 1 )
377 sTmp
.append( (sal_Int32
)nStartValue
);
378 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_START_VALUE
,
379 sTmp
.makeStringAndClear() );
381 if( nDisplayLevels
> 1 && NumberingType::NUMBER_NONE
!= eType
)
383 sTmp
.append( (sal_Int32
)nDisplayLevels
);
384 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_DISPLAY_LEVELS
,
385 sTmp
.makeStringAndClear() );
390 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
, eElem
,
391 sal_True
, sal_True
);
393 OUStringBuffer sBuffer
;
394 if ( ePosAndSpaceMode
== PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION
)
396 nSpaceBefore
+= nMinLabelWidth
;
397 nMinLabelWidth
= -nMinLabelWidth
;
398 if( nSpaceBefore
!= 0 )
400 GetExport().GetMM100UnitConverter().convertMeasureToXML(
401 sBuffer
, nSpaceBefore
);
402 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_SPACE_BEFORE
,
403 sBuffer
.makeStringAndClear() );
405 if( nMinLabelWidth
!= 0 )
407 GetExport().GetMM100UnitConverter().convertMeasureToXML(
408 sBuffer
, nMinLabelWidth
);
409 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_MIN_LABEL_WIDTH
,
410 sBuffer
.makeStringAndClear() );
412 if( nMinLabelDist
> 0 )
414 GetExport().GetMM100UnitConverter().convertMeasureToXML(
415 sBuffer
, nMinLabelDist
);
416 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_MIN_LABEL_DISTANCE
,
417 sBuffer
.makeStringAndClear() );
420 /* Check, if properties for position-and-space-mode LABEL_ALIGNMENT
421 are allowed to be exported. (#i89178#)
423 else if ( ePosAndSpaceMode
== PositionAndSpaceMode::LABEL_ALIGNMENT
&&
424 mbExportPositionAndSpaceModeLabelAlignment
)
426 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
427 XML_LIST_LEVEL_POSITION_AND_SPACE_MODE
,
428 XML_LABEL_ALIGNMENT
);
430 if( HoriOrientation::LEFT
!= eAdjust
)
432 enum XMLTokenEnum eValue
= XML_TOKEN_INVALID
;
435 case HoriOrientation::RIGHT
: eValue
= XML_END
; break;
436 case HoriOrientation::CENTER
: eValue
= XML_CENTER
; break;
438 if( eValue
!= XML_TOKEN_INVALID
)
439 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_TEXT_ALIGN
, eValue
);
442 if( NumberingType::BITMAP
== eType
)
444 enum XMLTokenEnum eValue
= XML_TOKEN_INVALID
;
445 switch( eImageVertOrient
)
447 case VertOrientation::BOTTOM
: // yes, its OK: BOTTOM means that the baseline
448 // hits the frame at its topmost position
449 case VertOrientation::LINE_TOP
:
450 case VertOrientation::CHAR_TOP
:
453 case VertOrientation::CENTER
:
454 case VertOrientation::LINE_CENTER
:
455 case VertOrientation::CHAR_CENTER
:
458 case VertOrientation::TOP
: // yes, its OK: TOP means that the baseline
459 // hits the frame at its bottommost position
460 case VertOrientation::LINE_BOTTOM
:
461 case VertOrientation::CHAR_BOTTOM
:
465 if( eValue
!= XML_TOKEN_INVALID
)
466 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_VERTICAL_POS
, eValue
);
468 eValue
= XML_TOKEN_INVALID
;
469 switch( eImageVertOrient
)
471 case VertOrientation::TOP
:
472 case VertOrientation::CENTER
:
473 case VertOrientation::BOTTOM
:
474 eValue
= XML_BASELINE
;
476 case VertOrientation::LINE_TOP
:
477 case VertOrientation::LINE_CENTER
:
478 case VertOrientation::LINE_BOTTOM
:
481 case VertOrientation::CHAR_TOP
:
482 case VertOrientation::CHAR_CENTER
:
483 case VertOrientation::CHAR_BOTTOM
:
487 if( eValue
!= XML_TOKEN_INVALID
)
488 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_VERTICAL_REL
, eValue
);
490 if( nImageWidth
> 0 )
492 GetExport().GetMM100UnitConverter().convertMeasureToXML(
493 sBuffer
, nImageWidth
);
494 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_WIDTH
,
495 sBuffer
.makeStringAndClear() );
498 if( nImageHeight
> 0 )
500 GetExport().GetMM100UnitConverter().convertMeasureToXML(
501 sBuffer
, nImageHeight
);
502 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_HEIGHT
,
503 sBuffer
.makeStringAndClear() );
508 SvXMLElementExport
aElement( GetExport(), XML_NAMESPACE_STYLE
,
509 XML_LIST_LEVEL_PROPERTIES
, sal_True
, sal_True
);
511 /* Check, if properties for position-and-space-mode LABEL_ALIGNMENT
512 are allowed to be exported. (#i89178#)
514 if ( ePosAndSpaceMode
== PositionAndSpaceMode::LABEL_ALIGNMENT
&&
515 mbExportPositionAndSpaceModeLabelAlignment
)
517 enum XMLTokenEnum eValue
= XML_LISTTAB
;
518 if ( eLabelFollowedBy
== LabelFollow::SPACE
)
522 else if ( eLabelFollowedBy
== LabelFollow::NOTHING
)
524 eValue
= XML_NOTHING
;
526 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
527 XML_LABEL_FOLLOWED_BY
, eValue
);
529 if ( eLabelFollowedBy
== LabelFollow::LISTTAB
&&
530 nListtabStopPosition
> 0 )
532 GetExport().GetMM100UnitConverter().convertMeasureToXML(
533 sBuffer
, nListtabStopPosition
);
534 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
535 XML_LIST_TAB_STOP_POSITION
,
536 sBuffer
.makeStringAndClear() );
539 if ( nFirstLineIndent
!= 0 )
541 GetExport().GetMM100UnitConverter().convertMeasureToXML(
542 sBuffer
, nFirstLineIndent
);
543 GetExport().AddAttribute( XML_NAMESPACE_FO
,
545 sBuffer
.makeStringAndClear() );
548 if ( nIndentAt
!= 0 )
550 GetExport().GetMM100UnitConverter().convertMeasureToXML(
551 sBuffer
, nIndentAt
);
552 GetExport().AddAttribute( XML_NAMESPACE_FO
,
554 sBuffer
.makeStringAndClear() );
557 SvXMLElementExport
aLabelAlignmentElement( GetExport(), XML_NAMESPACE_STYLE
,
558 XML_LIST_LEVEL_LABEL_ALIGNMENT
,
559 sal_True
, sal_True
);
563 if( NumberingType::CHAR_SPECIAL
== eType
)
565 if( !sBulletFontName
.isEmpty() )
567 OUString sStyleName
=
568 GetExport().GetFontAutoStylePool()->Find(
569 sBulletFontName
, sBulletFontStyleName
,
570 eBulletFontFamily
, eBulletFontPitch
,
571 eBulletFontEncoding
);
573 if( !sStyleName
.isEmpty() )
575 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
584 const SvXMLUnitConverter
& rUnitConv
=
585 GetExport().GetMM100UnitConverter();
586 XMLFontFamilyNamePropHdl aFamilyNameHdl
;
587 aAny
<<= sBulletFontName
;
588 if( aFamilyNameHdl
.exportXML( sTemp
, aAny
, rUnitConv
) )
589 GetExport().AddAttribute( XML_NAMESPACE_FO
,
590 XML_FONT_FAMILY
, sTemp
);
592 if( !sBulletFontStyleName
.isEmpty() )
593 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
595 sBulletFontStyleName
);
597 XMLFontFamilyPropHdl aFamilyHdl
;
598 aAny
<<= (sal_Int16
)eBulletFontFamily
;
599 if( aFamilyHdl
.exportXML( sTemp
, aAny
, rUnitConv
) )
600 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
601 XML_FONT_FAMILY_GENERIC
,
604 XMLFontPitchPropHdl aPitchHdl
;
605 aAny
<<= (sal_Int16
)eBulletFontPitch
;
606 if( aPitchHdl
.exportXML( sTemp
, aAny
, rUnitConv
) )
607 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
608 XML_FONT_PITCH
, sTemp
);
610 XMLFontEncodingPropHdl aEncHdl
;
611 aAny
<<= (sal_Int16
)eBulletFontEncoding
;
612 if( aEncHdl
.exportXML( sTemp
, aAny
, rUnitConv
) )
613 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
614 XML_FONT_CHARSET
, sTemp
);
618 if( NumberingType::BITMAP
!= eType
)
623 if (0xffffffff == static_cast<sal_uInt32
>(nColor
))
625 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_USE_WINDOW_FONT_COLOR
, XML_TRUE
);
629 ::sax::Converter::convertColor( sBuffer
, nColor
);
630 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_COLOR
,
631 sBuffer
.makeStringAndClear() );
637 ::sax::Converter::convertPercent( sTmp
, nBullRelSize
);
638 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_FONT_SIZE
,
639 sTmp
.makeStringAndClear() );
642 if( GetExport().GetAttrList().getLength() > 0 )
644 SvXMLElementExport
aElement( GetExport(), XML_NAMESPACE_STYLE
,
645 XML_TEXT_PROPERTIES
, sal_True
, sal_True
);
647 if( NumberingType::BITMAP
== eType
&& !sImageURL
.isEmpty() )
649 // optional office:binary-data
650 GetExport().AddEmbeddedGraphicObjectAsBase64( sImageURL
);
656 uno::Reference
< ::com::sun::star::container::XIndexReplace
> SvxXMLNumRuleExport::GetUNONumRule() const
658 return uno::Reference
< ::com::sun::star::container::XIndexReplace
> ();
661 void SvxXMLNumRuleExport::AddListStyleAttributes()
666 SvxXMLNumRuleExport::SvxXMLNumRuleExport( SvXMLExport
& rExp
) :
668 sNumberingRules( RTL_CONSTASCII_USTRINGPARAM( "NumberingRules" ) ),
669 sIsPhysical( RTL_CONSTASCII_USTRINGPARAM( "IsPhysical" ) ),
670 sIsContinuousNumbering( RTL_CONSTASCII_USTRINGPARAM( "IsContinuousNumbering" ) ),
671 // Let list style creation depend on Load/Save option "ODF format version" (#i89178#)
672 mbExportPositionAndSpaceModeLabelAlignment( true )
674 switch ( GetExport().getDefaultVersion() )
676 case SvtSaveOptions::ODFVER_010
:
677 case SvtSaveOptions::ODFVER_011
:
679 mbExportPositionAndSpaceModeLabelAlignment
= false;
682 default: // ODFVER_UNKNOWN or ODFVER_012
684 mbExportPositionAndSpaceModeLabelAlignment
= true;
689 SvxXMLNumRuleExport::~SvxXMLNumRuleExport()
693 void SvxXMLNumRuleExport::exportNumberingRule(
694 const OUString
& rName
,
695 const Reference
< XIndexReplace
>& rNumRule
)
697 Reference
< XPropertySet
> xPropSet( rNumRule
, UNO_QUERY
);
698 Reference
< XPropertySetInfo
> xPropSetInfo
;
700 xPropSetInfo
= xPropSet
->getPropertySetInfo();
702 GetExport().CheckAttrList();
705 if( !rName
.isEmpty() )
707 sal_Bool bEncoded
= sal_False
;
708 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_NAME
,
709 GetExport().EncodeStyleName( rName
, &bEncoded
) );
711 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_DISPLAY_NAME
,
715 // text:consecutive-numbering="..."
716 sal_Bool bContNumbering
= sal_False
;
717 if( xPropSetInfo
.is() &&
718 xPropSetInfo
->hasPropertyByName( sIsContinuousNumbering
) )
720 Any
aAny( xPropSet
->getPropertyValue( sIsContinuousNumbering
) );
721 bContNumbering
= *(sal_Bool
*)aAny
.getValue();
724 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
725 XML_CONSECUTIVE_NUMBERING
, XML_TRUE
);
727 // other application specific attributes
728 AddListStyleAttributes();
731 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
, XML_LIST_STYLE
,
732 sal_True
, sal_True
);
733 exportLevelStyles( rNumRule
);
737 sal_Bool
SvxXMLNumRuleExport::exportStyle( const Reference
< XStyle
>& rStyle
)
739 Reference
< XPropertySet
> xPropSet( rStyle
, UNO_QUERY
);
740 Reference
< XPropertySetInfo
> xPropSetInfo
= xPropSet
->getPropertySetInfo();
744 // Don't export styles that aren't existing really. This may be the
745 // case for StarOffice Writer's pool styles.
746 if( xPropSetInfo
->hasPropertyByName( sIsPhysical
) )
748 aAny
= xPropSet
->getPropertyValue( sIsPhysical
);
749 if( !*(sal_Bool
*)aAny
.getValue() )
753 aAny
= xPropSet
->getPropertyValue( sNumberingRules
);
754 Reference
<XIndexReplace
> xNumRule
;
757 OUString sName
= rStyle
->getName();
759 exportNumberingRule( sName
, xNumRule
);
764 void SvxXMLNumRuleExport::exportOutline()
766 Reference
< XChapterNumberingSupplier
> xCNSupplier( GetExport().GetModel(),
768 DBG_ASSERT( xCNSupplier
.is(), "no chapter numbering supplier" );
770 if( xCNSupplier
.is() )
772 Reference
< XIndexReplace
> xNumRule( xCNSupplier
->getChapterNumberingRules() );
773 DBG_ASSERT( xNumRule
.is(), "no chapter numbering rules" );
777 /* Outline style has property style:name since ODF 1.2
778 Thus, export this property and adjust fix for issue #i69627# (#i90780#)
780 OUString sOutlineStyleName
;
782 Reference
<XPropertySet
> xNumRulePropSet(
783 xCNSupplier
->getChapterNumberingRules(), UNO_QUERY
);
784 if (xNumRulePropSet
.is())
786 const OUString
sName( RTL_CONSTASCII_USTRINGPARAM("Name") );
787 xNumRulePropSet
->getPropertyValue( sName
) >>= sOutlineStyleName
;
790 const SvtSaveOptions::ODFDefaultVersion nODFVersion
=
791 GetExport().getDefaultVersion();
792 if ( ( nODFVersion
== SvtSaveOptions::ODFVER_010
||
793 nODFVersion
== SvtSaveOptions::ODFVER_011
) &&
794 GetExport().writeOutlineStyleAsNormalListStyle() )
796 exportNumberingRule( sOutlineStyleName
, xNumRule
);
800 if ( nODFVersion
!= SvtSaveOptions::ODFVER_010
&&
801 nODFVersion
!= SvtSaveOptions::ODFVER_011
)
804 GetExport().CheckAttrList();
805 if ( !sOutlineStyleName
.isEmpty() )
807 sal_Bool bEncoded
= sal_False
;
808 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_NAME
,
809 GetExport().EncodeStyleName( sOutlineStyleName
,
812 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
817 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
818 XML_OUTLINE_STYLE
, sal_True
, sal_True
);
819 exportLevelStyles( xNumRule
, sal_True
);
825 void SvxXMLNumRuleExport::exportStyles( sal_Bool bUsed
,
826 XMLTextListAutoStylePool
*pPool
,
827 sal_Bool bExportChapterNumbering
)
829 if( bExportChapterNumbering
)
832 Reference
< XStyleFamiliesSupplier
> xFamiliesSupp( GetExport().GetModel(), UNO_QUERY
);
833 DBG_ASSERT( xFamiliesSupp
.is(), "No XStyleFamiliesSupplier from XModel for export!" );
834 if( xFamiliesSupp
.is() )
836 Reference
< XNameAccess
> xFamilies( xFamiliesSupp
->getStyleFamilies() );
837 DBG_ASSERT( xFamiliesSupp
.is(), "getStyleFamilies() from XModel failed for export!" );
841 const OUString
aNumberStyleName( RTL_CONSTASCII_USTRINGPARAM( "NumberingStyles" ));
843 Reference
< XIndexAccess
> xStyles
;
844 if( xFamilies
->hasByName( aNumberStyleName
) )
846 xFamilies
->getByName( aNumberStyleName
) >>= xStyles
;
848 DBG_ASSERT( xStyles
.is(), "Style not found for export!" );
852 const sal_Int32 nStyles
= xStyles
->getCount();
854 for( sal_Int32 i
=0; i
< nStyles
; i
++ )
856 Reference
< XStyle
> xStyle
;
857 xStyles
->getByIndex( i
) >>= xStyle
;
859 if( !bUsed
|| xStyle
->isInUse() )
861 exportStyle( xStyle
);
863 pPool
->RegisterName( xStyle
->getName() );
872 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */