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 .
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/awt/FontDescriptor.hpp>
24 #include <com/sun/star/text/HoriOrientation.hpp>
25 #include <com/sun/star/text/VertOrientation.hpp>
26 #include <com/sun/star/text/PositionAndSpaceMode.hpp>
27 #include <com/sun/star/text/LabelFollow.hpp>
28 #include <com/sun/star/container/XNameContainer.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/style/XStyle.hpp>
31 #include <com/sun/star/io/XOutputStream.hpp>
33 #include <rtl/ustrbuf.hxx>
34 #include <osl/diagnose.h>
36 #include <tools/debug.hxx>
37 #include <tools/fontenum.hxx>
39 #include <sax/tools/converter.hxx>
41 #include <xmloff/xmltkmap.hxx>
42 #include <xmloff/nmspmap.hxx>
43 #include <xmloff/xmlnmspe.hxx>
44 #include <xmloff/xmlimp.hxx>
45 #include <xmloff/XMLBase64ImportContext.hxx>
46 #include <xmloff/xmltoken.hxx>
48 #include <xmloff/xmluconv.hxx>
49 #include "fonthdl.hxx"
50 #include <xmloff/XMLFontStylesContext.hxx>
51 #include <xmloff/families.hxx>
52 #include <xmloff/maptype.hxx>
54 #include <xmloff/xmlnumi.hxx>
56 using namespace ::com::sun::star
;
57 using namespace ::com::sun::star::uno
;
58 using namespace ::com::sun::star::style
;
59 using namespace ::com::sun::star::text
;
60 using namespace ::com::sun::star::beans
;
61 using namespace ::com::sun::star::container
;
62 using namespace ::com::sun::star::lang
;
63 using namespace ::com::sun::star::frame
;
64 using namespace ::xmloff::token
;
65 using namespace ::com::sun::star::io
;
67 class SvxXMLListLevelStyleContext_Impl
;
69 class SvxXMLListLevelStyleAttrContext_Impl
: public SvXMLImportContext
71 SvxXMLListLevelStyleContext_Impl
& rListLevel
;
75 SvxXMLListLevelStyleAttrContext_Impl(
76 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
77 const OUString
& rLName
,
78 const Reference
< xml::sax::XAttributeList
>& xAttrList
,
79 SvxXMLListLevelStyleContext_Impl
& rLLevel
);
80 virtual ~SvxXMLListLevelStyleAttrContext_Impl();
82 virtual SvXMLImportContext
*CreateChildContext(
83 sal_uInt16 nPrefix
, const OUString
& rLocalName
,
84 const Reference
< xml::sax::XAttributeList
> & xAttrList
) SAL_OVERRIDE
;
87 class SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl
: public SvXMLImportContext
89 SvxXMLListLevelStyleContext_Impl
& rListLevel
;
93 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(
94 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
95 const OUString
& rLName
,
96 const Reference
< xml::sax::XAttributeList
>& xAttrList
,
97 SvxXMLListLevelStyleContext_Impl
& rLLevel
);
98 virtual ~SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl();
101 enum SvxXMLTextListLevelStyleAttrTokens
103 XML_TOK_TEXT_LEVEL_ATTR_LEVEL
,
104 XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME
,
105 XML_TOK_TEXT_LEVEL_ATTR_BULLET_CHAR
,
106 XML_TOK_TEXT_LEVEL_ATTR_HREF
,
107 XML_TOK_TEXT_LEVEL_ATTR_TYPE
,
108 XML_TOK_TEXT_LEVEL_ATTR_SHOW
,
109 XML_TOK_TEXT_LEVEL_ATTR_ACTUATE
,
110 XML_TOK_TEXT_LEVEL_ATTR_NUM_FORMAT
,
111 XML_TOK_TEXT_LEVEL_ATTR_NUM_PREFIX
,
112 XML_TOK_TEXT_LEVEL_ATTR_NUM_SUFFIX
,
113 XML_TOK_TEXT_LEVEL_ATTR_NUM_LETTER_SYNC
,
114 XML_TOK_TEXT_LEVEL_ATTR_START_VALUE
,
115 XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS
,
117 XML_TOK_TEXT_LEVEL_ATTR_END
=XML_TOK_UNKNOWN
120 static const SvXMLTokenMapEntry
* lcl_getLevelAttrTokenMap()
122 static const SvXMLTokenMapEntry aLevelAttrTokenMap
[] =
124 { XML_NAMESPACE_TEXT
, XML_LEVEL
, XML_TOK_TEXT_LEVEL_ATTR_LEVEL
},
125 { XML_NAMESPACE_TEXT
, XML_STYLE_NAME
, XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME
},
126 { XML_NAMESPACE_TEXT
, XML_BULLET_CHAR
, XML_TOK_TEXT_LEVEL_ATTR_BULLET_CHAR
},
127 { XML_NAMESPACE_XLINK
, XML_HREF
, XML_TOK_TEXT_LEVEL_ATTR_HREF
},
128 { XML_NAMESPACE_XLINK
, XML_TYPE
, XML_TOK_TEXT_LEVEL_ATTR_TYPE
},
129 { XML_NAMESPACE_XLINK
, XML_SHOW
, XML_TOK_TEXT_LEVEL_ATTR_SHOW
},
130 { XML_NAMESPACE_XLINK
, XML_ACTUATE
, XML_TOK_TEXT_LEVEL_ATTR_ACTUATE
},
132 { XML_NAMESPACE_STYLE
, XML_NUM_FORMAT
, XML_TOK_TEXT_LEVEL_ATTR_NUM_FORMAT
},
133 { XML_NAMESPACE_STYLE
, XML_NUM_PREFIX
, XML_TOK_TEXT_LEVEL_ATTR_NUM_PREFIX
},
134 { XML_NAMESPACE_STYLE
, XML_NUM_SUFFIX
, XML_TOK_TEXT_LEVEL_ATTR_NUM_SUFFIX
},
135 { XML_NAMESPACE_STYLE
, XML_NUM_LETTER_SYNC
, XML_TOK_TEXT_LEVEL_ATTR_NUM_LETTER_SYNC
},
136 { XML_NAMESPACE_TEXT
, XML_START_VALUE
, XML_TOK_TEXT_LEVEL_ATTR_START_VALUE
},
137 { XML_NAMESPACE_TEXT
, XML_DISPLAY_LEVELS
, XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS
},
141 return aLevelAttrTokenMap
;
144 class SvxXMLListLevelStyleContext_Impl
: public SvXMLImportContext
146 friend class SvxXMLListLevelStyleAttrContext_Impl
;
147 const OUString sStarBats
;
148 const OUString sStarMath
;
152 OUString sTextStyleName
;
154 OUString sNumLetterSync
;
155 OUString sBulletFontName
;
156 OUString sBulletFontStyleName
;
159 Reference
< XOutputStream
> xBase64Stream
;
162 sal_Int32 nSpaceBefore
;
163 sal_Int32 nMinLabelWidth
;
164 sal_Int32 nMinLabelDist
;
165 sal_Int32 nImageWidth
;
166 sal_Int32 nImageHeight
;
167 sal_Int16 nNumStartValue
;
168 sal_Int16 nNumDisplayLevels
;
171 sal_Int16 eBulletFontFamily
;
172 sal_Int16 eBulletFontPitch
;
173 rtl_TextEncoding eBulletFontEncoding
;
174 sal_Int16 eImageVertOrient
;
181 sal_Int16 ePosAndSpaceMode
;
182 sal_Int16 eLabelFollowedBy
;
183 sal_Int32 nListtabStopPosition
;
184 sal_Int32 nFirstLineIndent
;
192 void SetRelSize( sal_Int16 nRel
) { nRelSize
= nRel
; }
193 void SetColor( sal_Int32 nColor
)
194 { m_nColor
= nColor
; bHasColor
= true; }
195 void SetSpaceBefore( sal_Int32 nSet
) { nSpaceBefore
= nSet
; }
196 void SetMinLabelWidth( sal_Int32 nSet
) { nMinLabelWidth
= nSet
; }
197 void SetMinLabelDist( sal_Int32 nSet
) { nMinLabelDist
= nSet
; }
198 void SetAdjust( sal_Int16 eSet
) { eAdjust
= eSet
; }
200 void SetBulletFontName( const OUString
& rSet
) { sBulletFontName
= rSet
; }
201 void SetBulletFontStyleName( const OUString
& rSet
)
202 { sBulletFontStyleName
= rSet
; }
203 void SetBulletFontFamily( sal_Int16 eSet
) { eBulletFontFamily
= eSet
; }
204 void SetBulletFontPitch( sal_Int16 eSet
) { eBulletFontPitch
= eSet
; }
205 void SetBulletFontEncoding( rtl_TextEncoding eSet
)
206 { eBulletFontEncoding
= eSet
; }
208 void SetImageWidth( sal_Int32 nSet
) { nImageWidth
= nSet
; }
209 void SetImageHeight( sal_Int32 nSet
) { nImageHeight
= nSet
; }
210 void SetImageVertOrient( sal_Int16 eSet
)
211 { eImageVertOrient
= eSet
; }
215 SvxXMLListLevelStyleContext_Impl(
216 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
217 const OUString
& rLName
,
218 const Reference
< xml::sax::XAttributeList
> & xAttrList
);
219 virtual ~SvxXMLListLevelStyleContext_Impl();
221 virtual SvXMLImportContext
*CreateChildContext(
222 sal_uInt16 nPrefix
, const OUString
& rLocalName
,
223 const Reference
< xml::sax::XAttributeList
> & xAttrList
) SAL_OVERRIDE
;
225 sal_Int32
GetLevel() const { return nLevel
; }
226 Sequence
<beans::PropertyValue
> GetProperties();
228 inline void SetPosAndSpaceMode( sal_Int16 eValue
)
230 ePosAndSpaceMode
= eValue
;
232 inline void SetLabelFollowedBy( sal_Int16 eValue
)
234 eLabelFollowedBy
= eValue
;
236 inline void SetListtabStopPosition( sal_Int32 nValue
)
238 nListtabStopPosition
= nValue
;
240 inline void SetFirstLineIndent( sal_Int32 nValue
)
242 nFirstLineIndent
= nValue
;
244 inline void SetIndentAt( sal_Int32 nValue
)
250 SvxXMLListLevelStyleContext_Impl::SvxXMLListLevelStyleContext_Impl(
251 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
252 const OUString
& rLName
,
253 const Reference
< xml::sax::XAttributeList
> & xAttrList
)
255 : SvXMLImportContext( rImport
, nPrfx
, rLName
)
256 , sStarBats( "StarBats" )
257 , sStarMath( "StarMath" )
258 , sNumFormat( OUString("1") )
261 , nMinLabelWidth( 0L )
262 , nMinLabelDist( 0L )
265 , nNumStartValue( 1 )
266 , nNumDisplayLevels( 1 )
267 , eAdjust( HoriOrientation::LEFT
)
268 , eBulletFontFamily( FAMILY_DONTKNOW
)
269 , eBulletFontPitch( PITCH_DONTKNOW
)
270 , eBulletFontEncoding( RTL_TEXTENCODING_DONTKNOW
)
271 , eImageVertOrient(0)
275 , ePosAndSpaceMode( PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION
)
276 , eLabelFollowedBy( LabelFollow::LISTTAB
)
277 , nListtabStopPosition( 0 )
278 , nFirstLineIndent( 0 )
285 if( IsXMLToken( rLName
, XML_LIST_LEVEL_STYLE_NUMBER
) ||
286 IsXMLToken( rLName
, XML_OUTLINE_LEVEL_STYLE
) )
288 else if( IsXMLToken( rLName
, XML_LIST_LEVEL_STYLE_BULLET
) )
290 else if( IsXMLToken( rLName
, XML_LIST_LEVEL_STYLE_IMAGE
) )
293 static const SvXMLTokenMap
aTokenMap( lcl_getLevelAttrTokenMap() );
294 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
295 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
297 const OUString
& rAttrName
= xAttrList
->getNameByIndex( i
);
300 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName
,
302 const OUString
& rValue
= xAttrList
->getValueByIndex( i
);
304 switch( aTokenMap
.Get( nPrefix
, aLocalName
) )
306 case XML_TOK_TEXT_LEVEL_ATTR_LEVEL
:
307 nLevel
= rValue
.toInt32();
313 case XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME
:
314 sTextStyleName
= rValue
;
316 case XML_TOK_TEXT_LEVEL_ATTR_BULLET_CHAR
:
317 if (!rValue
.isEmpty())
320 case XML_TOK_TEXT_LEVEL_ATTR_HREF
:
324 case XML_TOK_TEXT_LEVEL_ATTR_TYPE
:
325 case XML_TOK_TEXT_LEVEL_ATTR_SHOW
:
326 case XML_TOK_TEXT_LEVEL_ATTR_ACTUATE
:
327 // This properties will be ignored
329 case XML_TOK_TEXT_LEVEL_ATTR_NUM_FORMAT
:
333 case XML_TOK_TEXT_LEVEL_ATTR_NUM_PREFIX
:
336 case XML_TOK_TEXT_LEVEL_ATTR_NUM_SUFFIX
:
339 case XML_TOK_TEXT_LEVEL_ATTR_NUM_LETTER_SYNC
:
341 sNumLetterSync
= rValue
;
343 case XML_TOK_TEXT_LEVEL_ATTR_START_VALUE
:
346 sal_Int32 nTmp
= rValue
.toInt32();
348 (nTmp
< 0L) ? 1 : ( (nTmp
>SHRT_MAX
) ? SHRT_MAX
352 case XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS
:
355 sal_Int32 nTmp
= rValue
.toInt32();
357 (nTmp
< 1L) ? 1 : ( (nTmp
>SHRT_MAX
) ? SHRT_MAX
365 SvxXMLListLevelStyleContext_Impl::~SvxXMLListLevelStyleContext_Impl()
369 SvXMLImportContext
*SvxXMLListLevelStyleContext_Impl::CreateChildContext(
370 sal_uInt16 nPrefix
, const OUString
& rLocalName
,
371 const Reference
< xml::sax::XAttributeList
> & xAttrList
)
373 SvXMLImportContext
*pContext
= 0;
374 if( XML_NAMESPACE_STYLE
== nPrefix
&&
375 ( IsXMLToken( rLocalName
, XML_LIST_LEVEL_PROPERTIES
) ||
376 IsXMLToken( rLocalName
, XML_TEXT_PROPERTIES
) ) )
378 pContext
= new SvxXMLListLevelStyleAttrContext_Impl( GetImport(),
384 else if( (XML_NAMESPACE_OFFICE
== nPrefix
) && xmloff::token::IsXMLToken( rLocalName
,
385 xmloff::token::XML_BINARY_DATA
) )
387 if( bImage
&& sImageURL
.isEmpty() && !xBase64Stream
.is() )
389 xBase64Stream
= GetImport().GetStreamForGraphicObjectURLFromBase64();
390 if( xBase64Stream
.is() )
391 pContext
= new XMLBase64ImportContext( GetImport(), nPrefix
,
392 rLocalName
, xAttrList
,
398 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
404 Sequence
<beans::PropertyValue
> SvxXMLListLevelStyleContext_Impl::GetProperties()
406 sal_Int16 eType
= NumberingType::NUMBER_NONE
;
408 sal_Int32 nCount
= 0;
411 eType
= NumberingType::CHAR_SPECIAL
;
412 nCount
= 15; // 'cBullet' will be written anyway if 'bBullet' is true
416 eType
= NumberingType::BITMAP
;
419 if( !sImageURL
.isEmpty() || xBase64Stream
.is() )
424 eType
= NumberingType::ARABIC
;
425 GetImport().GetMM100UnitConverter().convertNumFormat(
426 eType
, sNumFormat
, sNumLetterSync
, true );
430 if( ( bBullet
|| bNum
) && nRelSize
)
433 if( !bImage
&& bHasColor
)
438 if (bBullet
&& !sSuffix
.isEmpty())
440 sal_uInt16
const nVersion(GetImport().getGeneratorVersion());
443 if (GetImport().getBuildIds(nUPD
, nBuildId
)
444 && ( (SvXMLImport::OOo_1x
== nVersion
)
445 || (SvXMLImport::OOo_2x
== nVersion
)
446 || (310 == nUPD
) || (320 == nUPD
) || (330 == nUPD
)
447 || ((300 == nUPD
) && (nBuildId
<= 9573))))
449 // #i93908# OOo < 3.4 wrote a bogus suffix for bullet chars
450 sSuffix
.clear(); // clear it
454 Sequence
<beans::PropertyValue
> aPropSeq( nCount
);
457 beans::PropertyValue
*pProps
= aPropSeq
.getArray();
459 pProps
[nPos
].Name
= "NumberingType";
460 pProps
[nPos
++].Value
<<= (sal_Int16
)eType
;
462 pProps
[nPos
].Name
= "Prefix";
463 pProps
[nPos
++].Value
<<= sPrefix
;
465 pProps
[nPos
].Name
= "Suffix";
466 pProps
[nPos
++].Value
<<= sSuffix
;
468 pProps
[nPos
].Name
= "Adjust";
469 pProps
[nPos
++].Value
<<= eAdjust
;
471 sal_Int32 nLeftMargin
= nSpaceBefore
+ nMinLabelWidth
;
472 pProps
[nPos
].Name
= "LeftMargin";
473 pProps
[nPos
++].Value
<<= (sal_Int32
)nLeftMargin
;
475 sal_Int32 nFirstLineOffset
= -nMinLabelWidth
;
477 pProps
[nPos
].Name
= "FirstLineOffset";
478 pProps
[nPos
++].Value
<<= (sal_Int32
)nFirstLineOffset
;
480 pProps
[nPos
].Name
= "SymbolTextDistance";
481 pProps
[nPos
++].Value
<<= (sal_Int16
)nMinLabelDist
;
483 pProps
[nPos
].Name
= "PositionAndSpaceMode";
484 pProps
[nPos
++].Value
<<= (sal_Int16
)ePosAndSpaceMode
;
485 pProps
[nPos
].Name
= "LabelFollowedBy";
486 pProps
[nPos
++].Value
<<= (sal_Int16
)eLabelFollowedBy
;
487 pProps
[nPos
].Name
= "ListtabStopPosition";
488 pProps
[nPos
++].Value
<<= (sal_Int32
)nListtabStopPosition
;
489 pProps
[nPos
].Name
= "FirstLineIndent";
490 pProps
[nPos
++].Value
<<= (sal_Int32
)nFirstLineIndent
;
491 pProps
[nPos
].Name
= "IndentAt";
492 pProps
[nPos
++].Value
<<= (sal_Int32
)nIndentAt
;
494 OUString sDisplayTextStyleName
= GetImport().GetStyleDisplayName(
495 XML_STYLE_FAMILY_TEXT_TEXT
, sTextStyleName
);
496 pProps
[nPos
].Name
= "CharStyleName";
497 pProps
[nPos
++].Value
<<= sDisplayTextStyleName
;
501 awt::FontDescriptor aFDesc
;
502 aFDesc
.Name
= sBulletFontName
;
503 if( !sBulletFontName
.isEmpty() )
505 aFDesc
.StyleName
= sBulletFontStyleName
;
506 aFDesc
.Family
= eBulletFontFamily
;
507 aFDesc
.Pitch
= eBulletFontPitch
;
508 aFDesc
.CharSet
= eBulletFontEncoding
;
509 aFDesc
.Weight
= WEIGHT_DONTKNOW
;
510 bool bStarSymbol
= false;
511 if( aFDesc
.Name
.equalsIgnoreAsciiCase( sStarBats
) )
513 cBullet
= GetImport().ConvStarBatsCharToStarSymbol( cBullet
);
516 else if( aFDesc
.Name
.equalsIgnoreAsciiCase( sStarMath
) )
518 cBullet
= GetImport().ConvStarMathCharToStarSymbol( cBullet
);
522 aFDesc
.Name
= "StarSymbol" ;
525 // Must append 'cBullet' even if it is zero
526 // if 'bBullet' is true and 'cBullet' is zero - BulletChar property must be 0.
527 OUStringBuffer
sTmp(1);
528 sTmp
.append( cBullet
);
529 pProps
[nPos
].Name
= "BulletChar";
530 pProps
[nPos
++].Value
<<= sTmp
.makeStringAndClear();
532 pProps
[nPos
].Name
= "BulletFont";
533 pProps
[nPos
++].Value
<<= aFDesc
;
539 OUString
sStr( sImageURL
);
540 if( !sImageURL
.isEmpty() )
542 sStr
= GetImport().ResolveGraphicObjectURL( sImageURL
, false );
544 else if( xBase64Stream
.is() )
546 sStr
= GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream
);
549 if( !sStr
.isEmpty() )
551 pProps
[nPos
].Name
= "GraphicURL";
552 pProps
[nPos
++].Value
<<= sStr
;
555 awt::Size
aSize( nImageWidth
, nImageHeight
);
556 pProps
[nPos
].Name
= "GraphicSize";
557 pProps
[nPos
++].Value
<<= aSize
;
559 pProps
[nPos
].Name
= "VertOrient";
560 pProps
[nPos
++].Value
<<= (sal_Int16
)eImageVertOrient
;
565 pProps
[nPos
].Name
= "StartWith";
566 pProps
[nPos
++].Value
<<= (sal_Int16
)nNumStartValue
;
568 pProps
[nPos
].Name
= "ParentNumbering";
569 pProps
[nPos
++].Value
<<= (sal_Int16
)nNumDisplayLevels
;
572 if( ( bNum
|| bBullet
) && nRelSize
)
574 pProps
[nPos
].Name
= "BulletRelSize";
575 pProps
[nPos
++].Value
<<= nRelSize
;
578 if( !bImage
&& bHasColor
)
580 pProps
[nPos
].Name
= "BulletColor";
581 pProps
[nPos
++].Value
<<= m_nColor
;
584 DBG_ASSERT( nPos
== nCount
, "array under/overflow" );
590 enum SvxXMLStyleAttributesAttrTokens
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 XML_TOK_STYLE_ATTRIBUTES_ATTR_END
=XML_TOK_UNKNOWN
612 static const SvXMLTokenMapEntry
* lcl_getStyleAttributesAttrTokenMap()
614 static const SvXMLTokenMapEntry aStyleAttributesAttrTokenMap
[] =
616 { XML_NAMESPACE_TEXT
, XML_SPACE_BEFORE
,
617 XML_TOK_STYLE_ATTRIBUTES_ATTR_SPACE_BEFORE
},
618 { XML_NAMESPACE_TEXT
, XML_MIN_LABEL_WIDTH
,
619 XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_WIDTH
},
620 { XML_NAMESPACE_TEXT
, XML_MIN_LABEL_DISTANCE
,
621 XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_DIST
},
622 { XML_NAMESPACE_FO
, XML_TEXT_ALIGN
,
623 XML_TOK_STYLE_ATTRIBUTES_ATTR_TEXT_ALIGN
},
624 { XML_NAMESPACE_STYLE
, XML_FONT_NAME
,
625 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_NAME
},
626 { XML_NAMESPACE_FO
, XML_FONT_FAMILY
,
627 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY
},
628 { XML_NAMESPACE_STYLE
, XML_FONT_FAMILY_GENERIC
,
629 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY_GENERIC
},
630 { XML_NAMESPACE_STYLE
, XML_FONT_STYLE_NAME
,
631 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_STYLENAME
},
632 { XML_NAMESPACE_STYLE
, XML_FONT_PITCH
,
633 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_PITCH
},
634 { XML_NAMESPACE_STYLE
, XML_FONT_CHARSET
,
635 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_CHARSET
},
636 { XML_NAMESPACE_STYLE
, XML_VERTICAL_POS
,
637 XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_POS
},
638 { XML_NAMESPACE_STYLE
, XML_VERTICAL_REL
,
639 XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_REL
},
640 { XML_NAMESPACE_FO
, XML_WIDTH
,
641 XML_TOK_STYLE_ATTRIBUTES_ATTR_WIDTH
},
642 { XML_NAMESPACE_FO
, XML_HEIGHT
,
643 XML_TOK_STYLE_ATTRIBUTES_ATTR_HEIGHT
},
644 { XML_NAMESPACE_FO
, XML_COLOR
,
645 XML_TOK_STYLE_ATTRIBUTES_ATTR_COLOR
},
646 { XML_NAMESPACE_STYLE
, XML_USE_WINDOW_FONT_COLOR
,
647 XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR
},
648 { XML_NAMESPACE_FO
, XML_FONT_SIZE
,
649 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE
},
650 { XML_NAMESPACE_TEXT
, XML_LIST_LEVEL_POSITION_AND_SPACE_MODE
,
651 XML_TOK_STYLE_ATTRIBUTES_ATTR_POSITION_AND_SPACE_MODE
},
654 return aStyleAttributesAttrTokenMap
;
656 SvxXMLListLevelStyleAttrContext_Impl::SvxXMLListLevelStyleAttrContext_Impl(
657 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
658 const OUString
& rLName
,
659 const Reference
< xml::sax::XAttributeList
> & xAttrList
,
660 SvxXMLListLevelStyleContext_Impl
& rLLevel
) :
661 SvXMLImportContext( rImport
, nPrfx
, rLName
),
662 rListLevel( rLLevel
)
664 static const SvXMLTokenMap
aTokenMap( lcl_getStyleAttributesAttrTokenMap() );
665 SvXMLUnitConverter
& rUnitConv
= GetImport().GetMM100UnitConverter();
667 OUString sFontName
, sFontFamily
, sFontStyleName
, sFontFamilyGeneric
,
668 sFontPitch
, sFontCharset
;
669 OUString sVerticalPos
, sVerticalRel
;
671 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
672 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
674 const OUString
& rAttrName
= xAttrList
->getNameByIndex( i
);
677 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName
,
679 const OUString
& rValue
= xAttrList
->getValueByIndex( i
);
682 switch( aTokenMap
.Get( nPrefix
, aLocalName
) )
684 case XML_TOK_STYLE_ATTRIBUTES_ATTR_SPACE_BEFORE
:
685 if (rUnitConv
.convertMeasureToCore(nVal
, rValue
, SHRT_MIN
, SHRT_MAX
))
686 rListLevel
.SetSpaceBefore( nVal
);
688 case XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_WIDTH
:
689 if (rUnitConv
.convertMeasureToCore( nVal
, rValue
, 0, SHRT_MAX
))
690 rListLevel
.SetMinLabelWidth( nVal
);
692 case XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_DIST
:
693 if (rUnitConv
.convertMeasureToCore( nVal
, rValue
, 0, USHRT_MAX
))
694 rListLevel
.SetMinLabelDist( nVal
);
696 case XML_TOK_STYLE_ATTRIBUTES_ATTR_TEXT_ALIGN
:
697 if( !rValue
.isEmpty() )
699 sal_Int16 eAdjust
= HoriOrientation::LEFT
;
700 if( IsXMLToken( rValue
, XML_CENTER
) )
701 eAdjust
= HoriOrientation::CENTER
;
702 else if( IsXMLToken( rValue
, XML_END
) )
703 eAdjust
= HoriOrientation::RIGHT
;
704 rListLevel
.SetAdjust( eAdjust
);
707 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_NAME
:
710 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY
:
711 sFontFamily
= rValue
;
713 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY_GENERIC
:
714 sFontFamilyGeneric
= rValue
;
716 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_STYLENAME
:
717 sFontStyleName
= rValue
;
719 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_PITCH
:
722 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_CHARSET
:
723 sFontCharset
= rValue
;
725 case XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_POS
:
726 sVerticalPos
= rValue
;
728 case XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_REL
:
729 sVerticalRel
= rValue
;
731 case XML_TOK_STYLE_ATTRIBUTES_ATTR_WIDTH
:
732 if (rUnitConv
.convertMeasureToCore(nVal
, rValue
, 0, SAL_MAX_INT32
))
733 rListLevel
.SetImageWidth( nVal
);
735 case XML_TOK_STYLE_ATTRIBUTES_ATTR_HEIGHT
:
736 if (rUnitConv
.convertMeasureToCore(nVal
, rValue
, 0, SAL_MAX_INT32
))
737 rListLevel
.SetImageHeight( nVal
);
739 case XML_TOK_STYLE_ATTRIBUTES_ATTR_COLOR
:
742 if (::sax::Converter::convertColor( nColor
, rValue
))
744 rListLevel
.SetColor( nColor
);
748 case XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR
:
750 if( IsXMLToken( rValue
, XML_TRUE
) )
751 rListLevel
.SetColor( (sal_Int32
)0xffffffff );
754 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE
:
755 if (::sax::Converter::convertPercent( nVal
, rValue
))
756 rListLevel
.SetRelSize( (sal_Int16
)nVal
);
758 case XML_TOK_STYLE_ATTRIBUTES_ATTR_POSITION_AND_SPACE_MODE
:
760 sal_Int16 ePosAndSpaceMode
= PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION
;
761 if( IsXMLToken( rValue
, XML_LABEL_ALIGNMENT
) )
762 ePosAndSpaceMode
= PositionAndSpaceMode::LABEL_ALIGNMENT
;
763 rListLevel
.SetPosAndSpaceMode( ePosAndSpaceMode
);
769 if( !sFontName
.isEmpty() )
771 const XMLFontStylesContext
*pFontDecls
=
772 GetImport().GetFontDecls();
775 ::std::vector
< XMLPropertyState
> aProps
;
776 if( pFontDecls
->FillProperties( sFontName
, aProps
, 0, 1, 2, 3, 4 ) )
780 ::std::vector
< XMLPropertyState
>::iterator i
;
781 for( i
= aProps
.begin(); i
!= aProps
.end(); ++i
)
787 rListLevel
.SetBulletFontName( sTmp
);
791 rListLevel
.SetBulletFontStyleName( sTmp
);
795 rListLevel
.SetBulletFontFamily( nTmp
);
799 rListLevel
.SetBulletFontPitch( nTmp
);
803 rListLevel
.SetBulletFontEncoding( nTmp
);
810 if( !sFontFamily
.isEmpty() )
814 XMLFontFamilyNamePropHdl aFamilyNameHdl
;
815 if( aFamilyNameHdl
.importXML( sFontFamily
, aAny
, rUnitConv
) )
819 rListLevel
.SetBulletFontName( sTmp
);
822 XMLFontFamilyPropHdl aFamilyHdl
;
823 if( !sFontFamilyGeneric
.isEmpty() &&
824 aFamilyHdl
.importXML( sFontFamilyGeneric
, aAny
, rUnitConv
) )
828 rListLevel
.SetBulletFontFamily( nTmp
);
831 if( !sFontStyleName
.isEmpty() )
832 rListLevel
.SetBulletFontStyleName( sFontStyleName
);
834 XMLFontPitchPropHdl aPitchHdl
;
835 if( !sFontPitch
.isEmpty() &&
836 aPitchHdl
.importXML( sFontPitch
, aAny
, rUnitConv
) )
840 rListLevel
.SetBulletFontPitch( nTmp
);
843 XMLFontEncodingPropHdl aEncHdl
;
844 if( !sFontCharset
.isEmpty() &&
845 aEncHdl
.importXML( sFontCharset
, aAny
, rUnitConv
) )
849 rListLevel
.SetBulletFontEncoding( nTmp
);
853 sal_Int16 eVertOrient
= VertOrientation::LINE_CENTER
;
854 if( !sVerticalPos
.isEmpty() )
856 if( IsXMLToken( sVerticalPos
, XML_TOP
) )
857 eVertOrient
= VertOrientation::LINE_TOP
;
858 else if( IsXMLToken( sVerticalPos
, XML_BOTTOM
) )
859 eVertOrient
= VertOrientation::LINE_BOTTOM
;
861 if( !sVerticalRel
.isEmpty() )
863 if( IsXMLToken( sVerticalRel
, XML_BASELINE
) )
865 // TOP and BOTTOM are exchanged for a baseline relation
866 switch( eVertOrient
)
868 case VertOrientation::LINE_TOP
:
869 eVertOrient
= VertOrientation::BOTTOM
;
871 case VertOrientation::LINE_CENTER
:
872 eVertOrient
= VertOrientation::CENTER
;
874 case VertOrientation::LINE_BOTTOM
:
875 eVertOrient
= VertOrientation::TOP
;
879 else if( IsXMLToken( sVerticalRel
, XML_CHAR
) )
881 switch( eVertOrient
)
883 case VertOrientation::LINE_TOP
:
884 eVertOrient
= VertOrientation::CHAR_TOP
;
886 case VertOrientation::LINE_CENTER
:
887 eVertOrient
= VertOrientation::CHAR_CENTER
;
889 case VertOrientation::LINE_BOTTOM
:
890 eVertOrient
= VertOrientation::CHAR_BOTTOM
;
895 rListLevel
.SetImageVertOrient( eVertOrient
);
898 SvxXMLListLevelStyleAttrContext_Impl::~SvxXMLListLevelStyleAttrContext_Impl()
902 SvXMLImportContext
* SvxXMLListLevelStyleAttrContext_Impl::CreateChildContext(
903 sal_uInt16 nPrefix
, const OUString
& rLocalName
,
904 const Reference
< xml::sax::XAttributeList
> & xAttrList
)
906 SvXMLImportContext
*pContext
= 0;
907 if ( XML_NAMESPACE_STYLE
== nPrefix
&&
908 IsXMLToken( rLocalName
, XML_LIST_LEVEL_LABEL_ALIGNMENT
) )
910 pContext
= new SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl( GetImport(),
918 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
924 enum SvxXMLStyleAttributesLabelAlignmentAttrTokens
926 XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY
,
927 XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION
,
928 XML_TOK_STYLE_ATTRIBUTES_ATTR_FIRST_LINE_INDENT
,
929 XML_TOK_STYLE_ATTRIBUTES_ATTR_INDENT_AT
,
931 XML_TOK_STYLE_ATTRIBUTES_LABEL_ALIGNMENT_ATTR_END
=XML_TOK_UNKNOWN
933 static const SvXMLTokenMapEntry
* lcl_getStyleAlignmentAttributesAttrTokenMap()
935 static const SvXMLTokenMapEntry aStyleAlignmentAttributesAttrTokenMap
[] =
937 { XML_NAMESPACE_TEXT
, XML_LABEL_FOLLOWED_BY
,
938 XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY
},
939 { XML_NAMESPACE_TEXT
, XML_LIST_TAB_STOP_POSITION
,
940 XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION
},
941 { XML_NAMESPACE_FO
, XML_TEXT_INDENT
,
942 XML_TOK_STYLE_ATTRIBUTES_ATTR_FIRST_LINE_INDENT
},
943 { XML_NAMESPACE_FO
, XML_MARGIN_LEFT
,
944 XML_TOK_STYLE_ATTRIBUTES_ATTR_INDENT_AT
},
948 return aStyleAlignmentAttributesAttrTokenMap
;
950 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(
951 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
952 const OUString
& rLName
,
953 const Reference
< xml::sax::XAttributeList
> & xAttrList
,
954 SvxXMLListLevelStyleContext_Impl
& rLLevel
) :
955 SvXMLImportContext( rImport
, nPrfx
, rLName
),
956 rListLevel( rLLevel
)
958 static const SvXMLTokenMap
aTokenMap( lcl_getStyleAlignmentAttributesAttrTokenMap() );
959 SvXMLUnitConverter
& rUnitConv
= GetImport().GetMM100UnitConverter();
961 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
962 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
964 const OUString
& rAttrName
= xAttrList
->getNameByIndex( i
);
967 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName
,
969 const OUString
& rValue
= xAttrList
->getValueByIndex( i
);
972 switch( aTokenMap
.Get( nPrefix
, aLocalName
) )
974 case XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY
:
976 sal_Int16 eLabelFollowedBy
= LabelFollow::LISTTAB
;
977 if( IsXMLToken( rValue
, XML_SPACE
) )
978 eLabelFollowedBy
= LabelFollow::SPACE
;
979 else if( IsXMLToken( rValue
, XML_NOTHING
) )
980 eLabelFollowedBy
= LabelFollow::NOTHING
;
981 rListLevel
.SetLabelFollowedBy( eLabelFollowedBy
);
984 case XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION
:
985 if (rUnitConv
.convertMeasureToCore(nVal
, rValue
, 0, SHRT_MAX
))
986 rListLevel
.SetListtabStopPosition( nVal
);
988 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FIRST_LINE_INDENT
:
989 if (rUnitConv
.convertMeasureToCore(nVal
, rValue
, SHRT_MIN
, SHRT_MAX
))
990 rListLevel
.SetFirstLineIndent( nVal
);
992 case XML_TOK_STYLE_ATTRIBUTES_ATTR_INDENT_AT
:
993 if (rUnitConv
.convertMeasureToCore(nVal
, rValue
, SHRT_MIN
, SHRT_MAX
))
994 rListLevel
.SetIndentAt( nVal
);
1000 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::~SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl()
1004 void SvxXMLListStyleContext::SetAttribute( sal_uInt16 nPrefixKey
,
1005 const OUString
& rLocalName
,
1006 const OUString
& rValue
)
1008 if( XML_NAMESPACE_TEXT
== nPrefixKey
&&
1009 IsXMLToken( rLocalName
, XML_CONSECUTIVE_NUMBERING
) )
1011 bConsecutive
= IsXMLToken( rValue
, XML_TRUE
);
1015 SvXMLStyleContext::SetAttribute( nPrefixKey
, rLocalName
, rValue
);
1019 SvxXMLListStyleContext::SvxXMLListStyleContext( SvXMLImport
& rImport
,
1021 const OUString
& rLName
,
1022 const Reference
< xml::sax::XAttributeList
> & xAttrList
,
1024 : SvXMLStyleContext( rImport
, nPrfx
, rLName
, xAttrList
, bOutl
? XML_STYLE_FAMILY_TEXT_OUTLINE
: XML_STYLE_FAMILY_TEXT_LIST
)
1025 , sIsPhysical( "IsPhysical" )
1026 , sNumberingRules( "NumberingRules" )
1027 , sIsContinuousNumbering( "IsContinuousNumbering" )
1030 , bConsecutive( false )
1035 SvxXMLListStyleContext::~SvxXMLListStyleContext()
1039 while( !pLevelStyles
->empty() )
1041 SvxXMLListLevelStyleContext_Impl
*pStyle
= pLevelStyles
->back();
1042 pLevelStyles
->pop_back();
1043 pStyle
->ReleaseRef();
1047 delete pLevelStyles
;
1050 TYPEINIT1( SvxXMLListStyleContext
, SvXMLStyleContext
);
1052 SvXMLImportContext
*SvxXMLListStyleContext::CreateChildContext(
1054 const OUString
& rLocalName
,
1055 const Reference
< xml::sax::XAttributeList
> & xAttrList
)
1057 SvXMLImportContext
*pContext
= 0;
1059 if( XML_NAMESPACE_TEXT
== nPrefix
&&
1061 ? IsXMLToken( rLocalName
, XML_OUTLINE_LEVEL_STYLE
)
1062 : ( IsXMLToken( rLocalName
, XML_LIST_LEVEL_STYLE_NUMBER
) ||
1063 IsXMLToken( rLocalName
, XML_LIST_LEVEL_STYLE_BULLET
) ||
1064 IsXMLToken( rLocalName
, XML_LIST_LEVEL_STYLE_IMAGE
) ) ) )
1066 SvxXMLListLevelStyleContext_Impl
*pLevelStyle
=
1067 new SvxXMLListLevelStyleContext_Impl( GetImport(), nPrefix
,
1068 rLocalName
, xAttrList
);
1070 pLevelStyles
= new SvxXMLListStyle_Impl
;
1071 pLevelStyles
->push_back( pLevelStyle
);
1072 pLevelStyle
->AddFirstRef();
1074 pContext
= pLevelStyle
;
1078 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1084 void SvxXMLListStyleContext::FillUnoNumRule(
1085 const Reference
<container::XIndexReplace
> & rNumRule
) const
1089 if( pLevelStyles
&& rNumRule
.is() )
1091 sal_uInt16 nCount
= pLevelStyles
->size();
1092 sal_Int32 l_nLevels
= rNumRule
->getCount();
1093 for( sal_uInt16 i
=0; i
< nCount
; i
++ )
1095 SvxXMLListLevelStyleContext_Impl
*pLevelStyle
=
1097 sal_Int32 nLevel
= pLevelStyle
->GetLevel();
1098 if( nLevel
>= 0 && nLevel
< l_nLevels
)
1100 Sequence
<beans::PropertyValue
> aProps
=
1101 pLevelStyle
->GetProperties();
1104 rNumRule
->replaceByIndex( nLevel
, aAny
);
1109 Reference
< XPropertySet
> xPropSet( rNumRule
, UNO_QUERY
);
1110 Reference
< XPropertySetInfo
> xPropSetInfo
;
1112 xPropSetInfo
= xPropSet
->getPropertySetInfo();
1113 if( xPropSetInfo
.is() &&
1114 xPropSetInfo
->hasPropertyByName( sIsContinuousNumbering
) )
1117 sal_Bool bTmp
= bConsecutive
;
1118 aAny
.setValue( &bTmp
, cppu::UnoType
<bool>::get() );
1119 xPropSet
->setPropertyValue( sIsContinuousNumbering
, aAny
);
1122 catch (const Exception
&)
1124 OSL_FAIL( "SvxXMLListStyleContext::FillUnoNumRule - Exception caught" );
1128 void SvxXMLListStyleContext::CreateAndInsertLate( bool bOverwrite
)
1134 const Reference
< XIndexReplace
>& rNumRule
=
1135 GetImport().GetTextImport()->GetChapterNumbering();
1136 // We don't set xNumberingRules here, to avoid using them
1137 // as numbering rules.
1139 FillUnoNumRule(rNumRule
);
1144 Reference
< XStyle
> xStyle
;
1145 const OUString
& rName
= GetDisplayName();
1146 if( rName
.isEmpty() )
1152 const Reference
< XNameContainer
>& rNumStyles
=
1153 GetImport().GetTextImport()->GetNumberingStyles();
1154 if( !rNumStyles
.is() )
1161 if( rNumStyles
->hasByName( rName
) )
1163 Any aAny
= rNumStyles
->getByName( rName
);
1168 Reference
< XMultiServiceFactory
> xFactory( GetImport().GetModel(),
1170 DBG_ASSERT( xFactory
.is(), "no factory" );
1171 if( !xFactory
.is() )
1174 Reference
< XInterface
> xIfc
= xFactory
->createInstance("com.sun.star.style.NumberingStyle");
1177 Reference
< XStyle
> xTmp( xIfc
, UNO_QUERY
);
1184 rNumStyles
->insertByName( rName
, aAny
);
1188 Reference
< XPropertySet
> xPropSet( xStyle
, UNO_QUERY
);
1189 Reference
< XPropertySetInfo
> xPropSetInfo
=
1190 xPropSet
->getPropertySetInfo();
1191 if( !bNew
&& xPropSetInfo
->hasPropertyByName( sIsPhysical
) )
1193 Any aAny
= xPropSet
->getPropertyValue( sIsPhysical
);
1194 bNew
= !*static_cast<sal_Bool
const *>(aAny
.getValue());
1197 if ( xPropSetInfo
->hasPropertyByName( "Hidden" ) )
1198 xPropSet
->setPropertyValue( "Hidden", uno::makeAny( IsHidden( ) ) );
1200 if( rName
!= GetName() )
1201 GetImport().AddStyleDisplayName( XML_STYLE_FAMILY_TEXT_LIST
,
1204 Any aAny
= xPropSet
->getPropertyValue( sNumberingRules
);
1206 nLevels
= xNumRules
->getCount();
1207 if( bOverwrite
|| bNew
)
1209 FillUnoNumRule(xNumRules
);
1211 xPropSet
->setPropertyValue( sNumberingRules
, aAny
);
1222 void SvxXMLListStyleContext::CreateAndInsertAuto() const
1224 DBG_ASSERT( !bOutline
, "Outlines cannot be inserted here" );
1225 DBG_ASSERT( !xNumRules
.is(), "Numbering Rule is existing already" );
1227 const OUString
& rName
= GetName();
1228 if( bOutline
|| xNumRules
.is() || rName
.isEmpty() )
1230 const_cast<SvxXMLListStyleContext
*>(this)->SetValid( false );
1234 const_cast<SvxXMLListStyleContext
*>(this)->xNumRules
= CreateNumRule(
1235 GetImport().GetModel() );
1236 const_cast<SvxXMLListStyleContext
*>(this)->nLevels
= xNumRules
->getCount();
1238 FillUnoNumRule(xNumRules
);
1241 Reference
< XIndexReplace
> SvxXMLListStyleContext::CreateNumRule(
1242 const Reference
< XModel
> & rModel
)
1244 Reference
<XIndexReplace
> xNumRule
;
1246 Reference
< XMultiServiceFactory
> xFactory( rModel
, UNO_QUERY
);
1247 DBG_ASSERT( xFactory
.is(), "no factory" );
1248 if( !xFactory
.is() )
1251 Reference
< XInterface
> xIfc
= xFactory
->createInstance("com.sun.star.text.NumberingRules");
1255 xNumRule
= Reference
<XIndexReplace
>( xIfc
, UNO_QUERY
);
1256 DBG_ASSERT( xNumRule
.is(), "go no numbering rule" );
1261 void SvxXMLListStyleContext::SetDefaultStyle(
1262 const Reference
< XIndexReplace
> & rNumRule
,
1266 Sequence
<beans::PropertyValue
> aPropSeq( bOrdered
? 1 : 4 );
1267 beans::PropertyValue
*pProps
= aPropSeq
.getArray();
1269 pProps
->Name
= "NumberingType";
1270 (pProps
++)->Value
<<= (sal_Int16
)(bOrdered
? NumberingType::ARABIC
1271 : NumberingType::CHAR_SPECIAL
);
1274 // TODO: Bullet-Font
1275 awt::FontDescriptor aFDesc
;
1283 aFDesc
.Family
= FAMILY_DONTKNOW
;
1284 aFDesc
.Pitch
= PITCH_DONTKNOW
;
1285 aFDesc
.CharSet
= RTL_TEXTENCODING_SYMBOL
;
1286 aFDesc
.Weight
= WEIGHT_DONTKNOW
;
1287 pProps
->Name
= "BulletFont";
1288 (pProps
++)->Value
<<= aFDesc
;
1290 OUStringBuffer
sTmp(1);
1291 sTmp
.append( (sal_Unicode
)(0xF000 + 149) );
1292 pProps
->Name
= "BulletChar";
1293 (pProps
++)->Value
<<= sTmp
.makeStringAndClear();
1294 pProps
->Name
= "CharStyleName";
1295 (pProps
++)->Value
<<= OUString( "Numbering Symbols" );
1300 rNumRule
->replaceByIndex( nLevel
, aAny
);
1303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */