1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlnumi.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <rtl/ustrbuf.hxx>
34 #include <tools/urlobj.hxx>
35 #include <tools/debug.hxx>
36 #include <vcl/vclenum.hxx>
38 #include <xmloff/xmltkmap.hxx>
39 #include <xmloff/nmspmap.hxx>
40 #include "xmlnmspe.hxx"
41 #include <xmloff/xmlimp.hxx>
42 #include <xmloff/XMLBase64ImportContext.hxx>
43 #include <com/sun/star/beans/PropertyValue.hpp>
44 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <com/sun/star/awt/Size.hpp>
46 #include <com/sun/star/awt/FontDescriptor.hpp>
47 #include <com/sun/star/text/HoriOrientation.hpp>
48 #include <com/sun/star/text/VertOrientation.hpp>
49 // --> OD 2008-01-16 #newlistlevelattrs#
50 #include <com/sun/star/text/PositionAndSpaceMode.hpp>
51 #include <com/sun/star/text/LabelFollow.hpp>
53 #include <com/sun/star/container/XNameContainer.hpp>
54 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
55 #include <com/sun/star/style/XStyle.hpp>
56 #include <com/sun/star/io/XOutputStream.hpp>
57 #include <xmloff/xmltoken.hxx>
59 #include "i18nmap.hxx"
60 #include <xmloff/xmluconv.hxx>
61 #ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX
62 #include "fonthdl.hxx"
64 #ifndef _XMLOFF_XMLFONTSTYLESCONTEXT_HXX
65 #include <xmloff/XMLFontStylesContext.hxx>
67 #ifndef _XMLOFF_FAMILIES_HXX
68 #include <xmloff/families.hxx>
70 #include <xmloff/maptype.hxx>
73 #include <xmloff/xmlnumi.hxx>
75 #define _SVSTDARR_USHORTS
76 #include <svtools/svstdarr.hxx>
77 using ::rtl::OUString
;
78 using ::rtl::OUStringBuffer
;
80 using namespace ::com::sun::star
;
81 using namespace ::com::sun::star::uno
;
82 using namespace ::com::sun::star::style
;
83 using namespace ::com::sun::star::text
;
84 using namespace ::com::sun::star::beans
;
85 using namespace ::com::sun::star::container
;
86 using namespace ::com::sun::star::lang
;
87 using namespace ::com::sun::star::frame
;
88 using namespace ::xmloff::token
;
89 using namespace ::com::sun::star::io
;
91 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_SYMBOL_TEXT_DISTANCE
[] =
93 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_PARENT_NUMBERING
[] =
95 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_CHAR_STYLE_NAME
[] =
97 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_BULLET_CHAR
[] ="BulletChar";
98 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_BULLET_RELSIZE
[] = "BulletRelSize";
99 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_GRAPHIC_SIZE
[] =
101 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_VERT_ORIENT
[] ="VertOrient";
103 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_NUMBERINGTYPE
[] = "NumberingType";
104 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_PREFIX
[] = "Prefix";
105 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_SUFFIX
[] = "Suffix";
106 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_ADJUST
[] = "Adjust";
107 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_LEFT_MARGIN
[] = "LeftMargin";
108 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_FIRST_LINE_OFFSET
[] =
110 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_BULLET_FONT
[] = "BulletFont";
111 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_GRAPHICURL
[] = "GraphicURL";
112 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_START_WITH
[] = "StartWith";
113 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_BULLET_COLOR
[] = "BulletColor";
114 // --> OD 2008-01-15 #newlistlevelattrs#
115 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_POSITION_AND_SPACE_MODE
[] = "PositionAndSpaceMode";
116 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_LABEL_FOLLOWED_BY
[] = "LabelFollowedBy";
117 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_LISTTAB_STOP_POSITION
[] = "ListtabStopPosition";
118 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_FIRST_LINE_INDENT
[] = "FirstLineIndent";
119 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_INDENT_AT
[] = "IndentAt";
122 // ---------------------------------------------------------------------
124 class SvxXMLListLevelStyleContext_Impl
;
126 class SvxXMLListLevelStyleAttrContext_Impl
: public SvXMLImportContext
128 SvxXMLListLevelStyleContext_Impl
& rListLevel
;
132 SvxXMLListLevelStyleAttrContext_Impl(
133 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
134 const OUString
& rLName
,
135 const Reference
< xml::sax::XAttributeList
>& xAttrList
,
136 SvxXMLListLevelStyleContext_Impl
& rLLevel
);
137 virtual ~SvxXMLListLevelStyleAttrContext_Impl();
139 // --> OD 2008-01-16 #newlistlevelattrs#
140 virtual SvXMLImportContext
*CreateChildContext(
141 sal_uInt16 nPrefix
, const OUString
& rLocalName
,
142 const Reference
< xml::sax::XAttributeList
> & xAttrList
);
146 // ---------------------------------------------------------------------
148 // --> OD 2008-01-16 #newlistlevelattrs#
149 class SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl
: public SvXMLImportContext
151 SvxXMLListLevelStyleContext_Impl
& rListLevel
;
155 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(
156 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
157 const OUString
& rLName
,
158 const Reference
< xml::sax::XAttributeList
>& xAttrList
,
159 SvxXMLListLevelStyleContext_Impl
& rLLevel
);
160 virtual ~SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl();
164 // ---------------------------------------------------------------------
166 enum SvxXMLTextListLevelStyleAttrTokens
168 XML_TOK_TEXT_LEVEL_ATTR_LEVEL
,
169 XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME
,
170 XML_TOK_TEXT_LEVEL_ATTR_BULLET_CHAR
,
171 XML_TOK_TEXT_LEVEL_ATTR_HREF
,
172 XML_TOK_TEXT_LEVEL_ATTR_TYPE
,
173 XML_TOK_TEXT_LEVEL_ATTR_SHOW
,
174 XML_TOK_TEXT_LEVEL_ATTR_ACTUATE
,
175 XML_TOK_TEXT_LEVEL_ATTR_NUM_FORMAT
,
176 XML_TOK_TEXT_LEVEL_ATTR_NUM_PREFIX
,
177 XML_TOK_TEXT_LEVEL_ATTR_NUM_SUFFIX
,
178 XML_TOK_TEXT_LEVEL_ATTR_NUM_LETTER_SYNC
,
179 XML_TOK_TEXT_LEVEL_ATTR_START_VALUE
,
180 XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS
,
182 XML_TOK_TEXT_LEVEL_ATTR_END
=XML_TOK_UNKNOWN
185 const SvXMLTokenMapEntry
* lcl_getLevelAttrTokenMap()
187 static __FAR_DATA SvXMLTokenMapEntry aLevelAttrTokenMap
[] =
189 { XML_NAMESPACE_TEXT
, XML_LEVEL
, XML_TOK_TEXT_LEVEL_ATTR_LEVEL
},
190 { XML_NAMESPACE_TEXT
, XML_STYLE_NAME
, XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME
},
191 { XML_NAMESPACE_TEXT
, XML_BULLET_CHAR
, XML_TOK_TEXT_LEVEL_ATTR_BULLET_CHAR
},
192 { XML_NAMESPACE_XLINK
, XML_HREF
, XML_TOK_TEXT_LEVEL_ATTR_HREF
},
193 { XML_NAMESPACE_XLINK
, XML_TYPE
, XML_TOK_TEXT_LEVEL_ATTR_TYPE
},
194 { XML_NAMESPACE_XLINK
, XML_SHOW
, XML_TOK_TEXT_LEVEL_ATTR_SHOW
},
195 { XML_NAMESPACE_XLINK
, XML_ACTUATE
, XML_TOK_TEXT_LEVEL_ATTR_ACTUATE
},
197 { XML_NAMESPACE_STYLE
, XML_NUM_FORMAT
, XML_TOK_TEXT_LEVEL_ATTR_NUM_FORMAT
},
198 { XML_NAMESPACE_STYLE
, XML_NUM_PREFIX
, XML_TOK_TEXT_LEVEL_ATTR_NUM_PREFIX
},
199 { XML_NAMESPACE_STYLE
, XML_NUM_SUFFIX
, XML_TOK_TEXT_LEVEL_ATTR_NUM_SUFFIX
},
200 { XML_NAMESPACE_STYLE
, XML_NUM_LETTER_SYNC
, XML_TOK_TEXT_LEVEL_ATTR_NUM_LETTER_SYNC
},
201 { XML_NAMESPACE_TEXT
, XML_START_VALUE
, XML_TOK_TEXT_LEVEL_ATTR_START_VALUE
},
202 { XML_NAMESPACE_TEXT
, XML_DISPLAY_LEVELS
, XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS
},
206 return aLevelAttrTokenMap
;
209 class SvxXMLListLevelStyleContext_Impl
: public SvXMLImportContext
211 friend class SvxXMLListLevelStyleAttrContext_Impl
;
212 const OUString sStarBats
;
213 const OUString sStarMath
;
217 OUString sTextStyleName
;
219 OUString sNumLetterSync
;
220 OUString sBulletFontName
;
221 OUString sBulletFontStyleName
;
224 Reference
< XOutputStream
> xBase64Stream
;
227 sal_Int32 nSpaceBefore
;
228 sal_Int32 nMinLabelWidth
;
229 sal_Int32 nMinLabelDist
;
230 sal_Int32 nImageWidth
;
231 sal_Int32 nImageHeight
;
232 sal_Int16 nNumStartValue
;
233 sal_Int16 nNumDisplayLevels
;
236 sal_Int16 eBulletFontFamily
;
237 sal_Int16 eBulletFontPitch
;
238 rtl_TextEncoding eBulletFontEncoding
;
239 sal_Int16 eImageVertOrient
;
246 // --> OD 2008-01-16 #newlistlevelattrs#
247 sal_Int16 ePosAndSpaceMode
;
248 sal_Int16 eLabelFollowedBy
;
249 sal_Int32 nListtabStopPosition
;
250 sal_Int32 nFirstLineIndent
;
254 sal_Bool bBullet
: 1;
257 sal_Bool bHasColor
: 1;
259 void SetRelSize( sal_Int16 nRel
) { nRelSize
= nRel
; }
260 void SetColor( sal_Int32 _aColor
) { aColor
= _aColor
; bHasColor
= sal_True
; }
261 void SetSpaceBefore( sal_Int32 nSet
) { nSpaceBefore
= nSet
; }
262 void SetMinLabelWidth( sal_Int32 nSet
) { nMinLabelWidth
= nSet
; }
263 void SetMinLabelDist( sal_Int32 nSet
) { nMinLabelDist
= nSet
; }
264 void SetAdjust( sal_Int16 eSet
) { eAdjust
= eSet
; }
266 void SetBulletFontName( const OUString
& rSet
) { sBulletFontName
= rSet
; }
267 void SetBulletFontStyleName( const OUString
& rSet
)
268 { sBulletFontStyleName
= rSet
; }
269 void SetBulletFontFamily( sal_Int16 eSet
) { eBulletFontFamily
= eSet
; }
270 void SetBulletFontPitch( sal_Int16 eSet
) { eBulletFontPitch
= eSet
; }
271 void SetBulletFontEncoding( rtl_TextEncoding eSet
)
272 { eBulletFontEncoding
= eSet
; }
274 void SetImageWidth( sal_Int32 nSet
) { nImageWidth
= nSet
; }
275 void SetImageHeight( sal_Int32 nSet
) { nImageHeight
= nSet
; }
276 void SetImageVertOrient( sal_Int16 eSet
)
277 { eImageVertOrient
= eSet
; }
281 SvxXMLListLevelStyleContext_Impl(
282 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
283 const OUString
& rLName
,
284 const Reference
< xml::sax::XAttributeList
> & xAttrList
);
285 virtual ~SvxXMLListLevelStyleContext_Impl();
287 virtual SvXMLImportContext
*CreateChildContext(
288 sal_uInt16 nPrefix
, const OUString
& rLocalName
,
289 const Reference
< xml::sax::XAttributeList
> & xAttrList
);
291 sal_Int32
GetLevel() const { return nLevel
; }
292 Sequence
<beans::PropertyValue
> GetProperties(
293 const SvI18NMap
*pI18NMap
=0 );
295 // --> OD 2008-01-16 #newlistlevelattrs#
296 inline void SetPosAndSpaceMode( sal_Int16 eValue
)
298 ePosAndSpaceMode
= eValue
;
300 inline void SetLabelFollowedBy( sal_Int16 eValue
)
302 eLabelFollowedBy
= eValue
;
304 inline void SetListtabStopPosition( sal_Int32 nValue
)
306 nListtabStopPosition
= nValue
;
308 inline void SetFirstLineIndent( sal_Int32 nValue
)
310 nFirstLineIndent
= nValue
;
312 inline void SetIndentAt( sal_Int32 nValue
)
319 SvxXMLListLevelStyleContext_Impl::SvxXMLListLevelStyleContext_Impl(
320 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
321 const OUString
& rLName
,
322 const Reference
< xml::sax::XAttributeList
> & xAttrList
)
324 : SvXMLImportContext( rImport
, nPrfx
, rLName
)
325 , sStarBats( RTL_CONSTASCII_USTRINGPARAM( "StarBats" ) )
326 , sStarMath( RTL_CONSTASCII_USTRINGPARAM( "StarMath" ) )
327 , sNumFormat( OUString::createFromAscii( "1" ) )
330 , nMinLabelWidth( 0L )
331 , nMinLabelDist( 0L )
334 , nNumStartValue( 1 )
335 , nNumDisplayLevels( 1 )
336 , eAdjust( HoriOrientation::LEFT
)
337 , eBulletFontFamily( FAMILY_DONTKNOW
)
338 , eBulletFontPitch( PITCH_DONTKNOW
)
339 , eBulletFontEncoding( RTL_TEXTENCODING_DONTKNOW
)
340 , eImageVertOrient(0)
344 // --> OD 2008-01-16 #newlistelevelattrs#
345 , ePosAndSpaceMode( PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION
)
346 , eLabelFollowedBy( LabelFollow::LISTTAB
)
347 , nListtabStopPosition( 0 )
348 , nFirstLineIndent( 0 )
351 , bBullet( sal_False
)
352 , bImage( sal_False
)
354 , bHasColor( sal_False
)
356 if( IsXMLToken( rLName
, XML_LIST_LEVEL_STYLE_NUMBER
) ||
357 IsXMLToken( rLName
, XML_OUTLINE_LEVEL_STYLE
) )
359 else if( IsXMLToken( rLName
, XML_LIST_LEVEL_STYLE_BULLET
) )
361 else if( IsXMLToken( rLName
, XML_LIST_LEVEL_STYLE_IMAGE
) )
364 SvXMLTokenMap
aTokenMap( lcl_getLevelAttrTokenMap() );
365 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
366 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
368 const OUString
& rAttrName
= xAttrList
->getNameByIndex( i
);
371 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName
,
373 const OUString
& rValue
= xAttrList
->getValueByIndex( i
);
375 switch( aTokenMap
.Get( nPrefix
, aLocalName
) )
377 case XML_TOK_TEXT_LEVEL_ATTR_LEVEL
:
378 nLevel
= rValue
.toInt32();
384 case XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME
:
385 sTextStyleName
= rValue
;
387 case XML_TOK_TEXT_LEVEL_ATTR_BULLET_CHAR
:
390 case XML_TOK_TEXT_LEVEL_ATTR_HREF
:
394 case XML_TOK_TEXT_LEVEL_ATTR_TYPE
:
395 case XML_TOK_TEXT_LEVEL_ATTR_SHOW
:
396 case XML_TOK_TEXT_LEVEL_ATTR_ACTUATE
:
397 // This properties will be ignored
399 case XML_TOK_TEXT_LEVEL_ATTR_NUM_FORMAT
:
403 case XML_TOK_TEXT_LEVEL_ATTR_NUM_PREFIX
:
406 case XML_TOK_TEXT_LEVEL_ATTR_NUM_SUFFIX
:
409 case XML_TOK_TEXT_LEVEL_ATTR_NUM_LETTER_SYNC
:
411 sNumLetterSync
= rValue
;
413 case XML_TOK_TEXT_LEVEL_ATTR_START_VALUE
:
416 sal_Int32 nTmp
= rValue
.toInt32();
418 (nTmp
< 0L) ? 1 : ( (nTmp
>SHRT_MAX
) ? SHRT_MAX
422 case XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS
:
425 sal_Int32 nTmp
= rValue
.toInt32();
427 (nTmp
< 1L) ? 1 : ( (nTmp
>SHRT_MAX
) ? SHRT_MAX
435 SvxXMLListLevelStyleContext_Impl::~SvxXMLListLevelStyleContext_Impl()
439 SvXMLImportContext
*SvxXMLListLevelStyleContext_Impl::CreateChildContext(
440 sal_uInt16 nPrefix
, const OUString
& rLocalName
,
441 const Reference
< xml::sax::XAttributeList
> & xAttrList
)
443 SvXMLImportContext
*pContext
= 0;
444 if( XML_NAMESPACE_STYLE
== nPrefix
&&
445 ( IsXMLToken( rLocalName
, XML_LIST_LEVEL_PROPERTIES
) ||
446 IsXMLToken( rLocalName
, XML_TEXT_PROPERTIES
) ) )
448 pContext
= new SvxXMLListLevelStyleAttrContext_Impl( GetImport(),
454 else if( (XML_NAMESPACE_OFFICE
== nPrefix
) && xmloff::token::IsXMLToken( rLocalName
,
455 xmloff::token::XML_BINARY_DATA
) )
457 if( bImage
&& !sImageURL
.getLength() && !xBase64Stream
.is() )
459 xBase64Stream
= GetImport().GetStreamForGraphicObjectURLFromBase64();
460 if( xBase64Stream
.is() )
461 pContext
= new XMLBase64ImportContext( GetImport(), nPrefix
,
462 rLocalName
, xAttrList
,
468 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
474 Sequence
<beans::PropertyValue
> SvxXMLListLevelStyleContext_Impl::GetProperties(
475 const SvI18NMap
*pI18NMap
)
479 sal_Int32 nCount
= 0L;
482 eType
= NumberingType::CHAR_SPECIAL
;
483 nCount
= cBullet
? 15 : 14;
487 eType
= NumberingType::BITMAP
;
490 if( (sImageURL
.getLength() > 0L) || xBase64Stream
.is() )
495 eType
= NumberingType::ARABIC
;
496 GetImport().GetMM100UnitConverter().convertNumFormat(
497 eType
, sNumFormat
, sNumLetterSync
, sal_True
);
501 if( ( bBullet
|| bNum
) && nRelSize
)
504 if( !bImage
&& bHasColor
)
509 Sequence
<beans::PropertyValue
> aPropSeq( nCount
);
512 beans::PropertyValue
*pProps
= aPropSeq
.getArray();
515 OUString::createFromAscii( XML_UNO_NAME_NRULE_NUMBERINGTYPE
);
516 pProps
[nPos
++].Value
<<= (sal_Int16
)eType
;
518 pProps
[nPos
].Name
= OUString::createFromAscii( XML_UNO_NAME_NRULE_PREFIX
);
519 pProps
[nPos
++].Value
<<= sPrefix
;
521 pProps
[nPos
].Name
= OUString::createFromAscii( XML_UNO_NAME_NRULE_SUFFIX
);
522 pProps
[nPos
++].Value
<<= sSuffix
;
524 pProps
[nPos
].Name
= OUString::createFromAscii( XML_UNO_NAME_NRULE_ADJUST
);
525 pProps
[nPos
++].Value
<<= eAdjust
;
527 sal_Int32 nLeftMargin
= nSpaceBefore
+ nMinLabelWidth
;
529 OUString::createFromAscii( XML_UNO_NAME_NRULE_LEFT_MARGIN
);
530 pProps
[nPos
++].Value
<<= (sal_Int32
)nLeftMargin
;
532 sal_Int32 nFirstLineOffset
= -nMinLabelWidth
;
535 OUString::createFromAscii( XML_UNO_NAME_NRULE_FIRST_LINE_OFFSET
);
536 pProps
[nPos
++].Value
<<= (sal_Int32
)nFirstLineOffset
;
539 OUString::createFromAscii(XML_UNO_NAME_NRULE_SYMBOL_TEXT_DISTANCE
);
540 pProps
[nPos
++].Value
<<= (sal_Int16
)nMinLabelDist
;
542 // --> OD 2008-01-16 #newlistlevelattrs#
544 OUString::createFromAscii(XML_UNO_NAME_NRULE_POSITION_AND_SPACE_MODE
);
545 pProps
[nPos
++].Value
<<= (sal_Int16
)ePosAndSpaceMode
;
547 OUString::createFromAscii(XML_UNO_NAME_NRULE_LABEL_FOLLOWED_BY
);
548 pProps
[nPos
++].Value
<<= (sal_Int16
)eLabelFollowedBy
;
550 OUString::createFromAscii(XML_UNO_NAME_NRULE_LISTTAB_STOP_POSITION
);
551 pProps
[nPos
++].Value
<<= (sal_Int32
)nListtabStopPosition
;
553 OUString::createFromAscii(XML_UNO_NAME_NRULE_FIRST_LINE_INDENT
);
554 pProps
[nPos
++].Value
<<= (sal_Int32
)nFirstLineIndent
;
556 OUString::createFromAscii(XML_UNO_NAME_NRULE_INDENT_AT
);
557 pProps
[nPos
++].Value
<<= (sal_Int32
)nIndentAt
;
560 OUString sDisplayTextStyleName
= GetImport().GetStyleDisplayName(
561 XML_STYLE_FAMILY_TEXT_TEXT
, sTextStyleName
);
562 OUString sStyleName
= sDisplayTextStyleName
;
563 if( sStyleName
.getLength() && pI18NMap
)
564 sStyleName
= pI18NMap
->Get( SFX_STYLE_FAMILY_CHAR
, sStyleName
);
566 OUString::createFromAscii( XML_UNO_NAME_NRULE_CHAR_STYLE_NAME
);
567 pProps
[nPos
++].Value
<<= sDisplayTextStyleName
;
571 awt::FontDescriptor aFDesc
;
572 aFDesc
.Name
= sBulletFontName
;
573 if( sBulletFontName
.getLength() )
575 aFDesc
.StyleName
= sBulletFontStyleName
;
576 aFDesc
.Family
= eBulletFontFamily
;
577 aFDesc
.Pitch
= eBulletFontPitch
;
578 aFDesc
.CharSet
= eBulletFontEncoding
;
579 aFDesc
.Weight
= WEIGHT_DONTKNOW
;
580 //aFDesc.Transparant = sal_True;
581 sal_Bool bStarSymbol
= sal_False
;
582 if( aFDesc
.Name
.equalsIgnoreAsciiCase( sStarBats
) )
584 cBullet
= GetImport().ConvStarBatsCharToStarSymbol( cBullet
);
585 bStarSymbol
= sal_True
;
587 else if( aFDesc
.Name
.equalsIgnoreAsciiCase( sStarMath
) )
589 cBullet
= GetImport().ConvStarMathCharToStarSymbol( cBullet
);
590 bStarSymbol
= sal_True
;
594 OUString( RTL_CONSTASCII_USTRINGPARAM("StarSymbol" ) );
599 OUStringBuffer
sTmp(1);
600 sTmp
.append( cBullet
);
602 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_CHAR
);
603 pProps
[nPos
++].Value
<<= sTmp
.makeStringAndClear();
607 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_FONT
);
608 pProps
[nPos
++].Value
<<= aFDesc
;
614 OUString
sStr( sImageURL
);
615 if( sImageURL
.getLength() )
617 sStr
= GetImport().ResolveGraphicObjectURL( sImageURL
,
620 else if( xBase64Stream
.is() )
622 sStr
= GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream
);
623 // xBase64Stream = 0;
626 if( sStr
.getLength() )
629 OUString::createFromAscii( XML_UNO_NAME_NRULE_GRAPHICURL
);
630 pProps
[nPos
++].Value
<<= sStr
;
633 awt::Size
aSize( nImageWidth
, nImageHeight
);
635 OUString::createFromAscii( XML_UNO_NAME_NRULE_GRAPHIC_SIZE
);
636 pProps
[nPos
++].Value
<<= aSize
;
639 OUString::createFromAscii( XML_UNO_NAME_NRULE_VERT_ORIENT
);
640 pProps
[nPos
++].Value
<<= (sal_Int16
)eImageVertOrient
;
646 OUString::createFromAscii( XML_UNO_NAME_NRULE_START_WITH
);
647 pProps
[nPos
++].Value
<<= (sal_Int16
)nNumStartValue
;
650 OUString::createFromAscii(XML_UNO_NAME_NRULE_PARENT_NUMBERING
);
651 pProps
[nPos
++].Value
<<= (sal_Int16
)nNumDisplayLevels
;
654 if( ( bNum
|| bBullet
) && nRelSize
)
657 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_RELSIZE
);
658 pProps
[nPos
++].Value
<<= nRelSize
;
661 if( !bImage
&& bHasColor
)
663 pProps
[nPos
].Name
= OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_COLOR
);
664 pProps
[nPos
++].Value
<<= (sal_Int32
)aColor
.GetColor();
667 DBG_ASSERT( nPos
== nCount
, "array under/overflow" );
673 // ---------------------------------------------------------------------
675 enum SvxXMLStyleAttributesAttrTokens
677 XML_TOK_STYLE_ATTRIBUTES_ATTR_SPACE_BEFORE
,
678 XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_WIDTH
,
679 XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_DIST
,
680 XML_TOK_STYLE_ATTRIBUTES_ATTR_TEXT_ALIGN
,
681 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_NAME
,
682 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY
,
683 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY_GENERIC
,
684 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_STYLENAME
,
685 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_PITCH
,
686 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_CHARSET
,
687 XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_POS
,
688 XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_REL
,
689 XML_TOK_STYLE_ATTRIBUTES_ATTR_WIDTH
,
690 XML_TOK_STYLE_ATTRIBUTES_ATTR_HEIGHT
,
691 XML_TOK_STYLE_ATTRIBUTES_ATTR_COLOR
,
692 XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR
,
693 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE
,
694 // --> OD 2008-01-16 #newlistlevelattrs#
695 XML_TOK_STYLE_ATTRIBUTES_ATTR_POSITION_AND_SPACE_MODE
,
698 XML_TOK_STYLE_ATTRIBUTES_ATTR_END
=XML_TOK_UNKNOWN
700 const SvXMLTokenMapEntry
* lcl_getStyleAttributesAttrTokenMap()
702 static __FAR_DATA SvXMLTokenMapEntry aStyleAttributesAttrTokenMap
[] =
704 { XML_NAMESPACE_TEXT
, XML_SPACE_BEFORE
,
705 XML_TOK_STYLE_ATTRIBUTES_ATTR_SPACE_BEFORE
},
706 { XML_NAMESPACE_TEXT
, XML_MIN_LABEL_WIDTH
,
707 XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_WIDTH
},
708 { XML_NAMESPACE_TEXT
, XML_MIN_LABEL_DISTANCE
,
709 XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_DIST
},
710 { XML_NAMESPACE_FO
, XML_TEXT_ALIGN
,
711 XML_TOK_STYLE_ATTRIBUTES_ATTR_TEXT_ALIGN
},
712 { XML_NAMESPACE_STYLE
, XML_FONT_NAME
,
713 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_NAME
},
714 { XML_NAMESPACE_FO
, XML_FONT_FAMILY
,
715 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY
},
716 { XML_NAMESPACE_STYLE
, XML_FONT_FAMILY_GENERIC
,
717 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY_GENERIC
},
718 { XML_NAMESPACE_STYLE
, XML_FONT_STYLE_NAME
,
719 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_STYLENAME
},
720 { XML_NAMESPACE_STYLE
, XML_FONT_PITCH
,
721 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_PITCH
},
722 { XML_NAMESPACE_STYLE
, XML_FONT_CHARSET
,
723 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_CHARSET
},
724 { XML_NAMESPACE_STYLE
, XML_VERTICAL_POS
,
725 XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_POS
},
726 { XML_NAMESPACE_STYLE
, XML_VERTICAL_REL
,
727 XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_REL
},
728 { XML_NAMESPACE_FO
, XML_WIDTH
,
729 XML_TOK_STYLE_ATTRIBUTES_ATTR_WIDTH
},
730 { XML_NAMESPACE_FO
, XML_HEIGHT
,
731 XML_TOK_STYLE_ATTRIBUTES_ATTR_HEIGHT
},
732 { XML_NAMESPACE_FO
, XML_COLOR
,
733 XML_TOK_STYLE_ATTRIBUTES_ATTR_COLOR
},
734 { XML_NAMESPACE_STYLE
, XML_USE_WINDOW_FONT_COLOR
,
735 XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR
},
736 { XML_NAMESPACE_FO
, XML_FONT_SIZE
,
737 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE
},
738 // --> OD 2008-01-16 #newlistlevelattrs#
739 { XML_NAMESPACE_TEXT
, XML_LIST_LEVEL_POSITION_AND_SPACE_MODE
,
740 XML_TOK_STYLE_ATTRIBUTES_ATTR_POSITION_AND_SPACE_MODE
},
745 return aStyleAttributesAttrTokenMap
;
747 SvxXMLListLevelStyleAttrContext_Impl::SvxXMLListLevelStyleAttrContext_Impl(
748 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
749 const OUString
& rLName
,
750 const Reference
< xml::sax::XAttributeList
> & xAttrList
,
751 SvxXMLListLevelStyleContext_Impl
& rLLevel
) :
752 SvXMLImportContext( rImport
, nPrfx
, rLName
),
753 rListLevel( rLLevel
)
755 SvXMLTokenMap
aTokenMap( lcl_getStyleAttributesAttrTokenMap() );
756 SvXMLUnitConverter
& rUnitConv
= GetImport().GetMM100UnitConverter();
758 OUString sFontName
, sFontFamily
, sFontStyleName
, sFontFamilyGeneric
,
759 sFontPitch
, sFontCharset
;
760 OUString sVerticalPos
, sVerticalRel
;
762 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
763 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
765 const OUString
& rAttrName
= xAttrList
->getNameByIndex( i
);
768 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName
,
770 const OUString
& rValue
= xAttrList
->getValueByIndex( i
);
773 switch( aTokenMap
.Get( nPrefix
, aLocalName
) )
775 case XML_TOK_STYLE_ATTRIBUTES_ATTR_SPACE_BEFORE
:
776 if( rUnitConv
.convertMeasure( nVal
, rValue
, SHRT_MIN
, SHRT_MAX
) )
777 rListLevel
.SetSpaceBefore( nVal
);
779 case XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_WIDTH
:
780 if( rUnitConv
.convertMeasure( nVal
, rValue
, 0, SHRT_MAX
) )
781 rListLevel
.SetMinLabelWidth( nVal
);
783 case XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_DIST
:
784 if( rUnitConv
.convertMeasure( nVal
, rValue
, 0, USHRT_MAX
) )
785 rListLevel
.SetMinLabelDist( nVal
);
787 case XML_TOK_STYLE_ATTRIBUTES_ATTR_TEXT_ALIGN
:
788 if( rValue
.getLength() )
790 sal_Int16 eAdjust
= HoriOrientation::LEFT
;
791 if( IsXMLToken( rValue
, XML_CENTER
) )
792 eAdjust
= HoriOrientation::CENTER
;
793 else if( IsXMLToken( rValue
, XML_END
) )
794 eAdjust
= HoriOrientation::RIGHT
;
795 rListLevel
.SetAdjust( eAdjust
);
798 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_NAME
:
801 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY
:
802 sFontFamily
= rValue
;
804 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY_GENERIC
:
805 sFontFamilyGeneric
= rValue
;
807 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_STYLENAME
:
808 sFontStyleName
= rValue
;
810 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_PITCH
:
813 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_CHARSET
:
814 sFontCharset
= rValue
;
816 case XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_POS
:
817 sVerticalPos
= rValue
;
819 case XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_REL
:
820 sVerticalRel
= rValue
;
822 case XML_TOK_STYLE_ATTRIBUTES_ATTR_WIDTH
:
823 if( rUnitConv
.convertMeasure( nVal
, rValue
, 0, SAL_MAX_INT32
) )
824 rListLevel
.SetImageWidth( nVal
);
826 case XML_TOK_STYLE_ATTRIBUTES_ATTR_HEIGHT
:
827 if( rUnitConv
.convertMeasure( nVal
, rValue
, 0, SAL_MAX_INT32
) )
828 rListLevel
.SetImageHeight( nVal
);
830 case XML_TOK_STYLE_ATTRIBUTES_ATTR_COLOR
:
833 if( SvXMLUnitConverter::convertColor( aColor
, rValue
) )
834 rListLevel
.SetColor( (sal_Int32
)aColor
.GetColor() );
837 case XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR
:
839 if( IsXMLToken( rValue
, XML_TRUE
) )
840 rListLevel
.SetColor( (sal_Int32
)0xffffffff );
843 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE
:
844 if(SvXMLUnitConverter::convertPercent( nVal
, rValue
) )
845 rListLevel
.SetRelSize( (sal_Int16
)nVal
);
847 // --> OD 2008-01-16 #newlistlevelattrs#
848 case XML_TOK_STYLE_ATTRIBUTES_ATTR_POSITION_AND_SPACE_MODE
:
850 sal_Int16 ePosAndSpaceMode
= PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION
;
851 if( IsXMLToken( rValue
, XML_LABEL_ALIGNMENT
) )
852 ePosAndSpaceMode
= PositionAndSpaceMode::LABEL_ALIGNMENT
;
853 rListLevel
.SetPosAndSpaceMode( ePosAndSpaceMode
);
860 if( sFontName
.getLength() )
862 const XMLFontStylesContext
*pFontDecls
=
863 GetImport().GetTextImport()->GetFontDecls();
866 ::std::vector
< XMLPropertyState
> aProps
;
867 if( pFontDecls
->FillProperties( sFontName
, aProps
, 0, 1, 2, 3, 4 ) )
871 ::std::vector
< XMLPropertyState
>::iterator i
;
872 for( i
= aProps
.begin(); i
!= aProps
.end(); i
++ )
878 rListLevel
.SetBulletFontName( sTmp
);
882 rListLevel
.SetBulletFontStyleName( sTmp
);
886 rListLevel
.SetBulletFontFamily( nTmp
);
890 rListLevel
.SetBulletFontPitch( nTmp
);
894 rListLevel
.SetBulletFontEncoding( nTmp
);
901 if( sFontFamily
.getLength() )
906 XMLFontFamilyNamePropHdl aFamilyNameHdl
;
907 if( aFamilyNameHdl
.importXML( sFontFamily
, aAny
, rUnitConv
) )
911 rListLevel
.SetBulletFontName( sTmp
);
914 XMLFontFamilyPropHdl aFamilyHdl
;
915 if( sFontFamilyGeneric
.getLength() &&
916 aFamilyHdl
.importXML( sFontFamilyGeneric
, aAny
, rUnitConv
) )
920 rListLevel
.SetBulletFontFamily( nTmp
);
923 if( sFontStyleName
.getLength() )
924 rListLevel
.SetBulletFontStyleName( sFontStyleName
);
926 XMLFontPitchPropHdl aPitchHdl
;
927 if( sFontPitch
.getLength() &&
928 aPitchHdl
.importXML( sFontPitch
, aAny
, rUnitConv
) )
932 rListLevel
.SetBulletFontPitch( nTmp
);
935 XMLFontEncodingPropHdl aEncHdl
;
936 if( sFontCharset
.getLength() &&
937 aEncHdl
.importXML( sFontCharset
, aAny
, rUnitConv
) )
941 rListLevel
.SetBulletFontEncoding( nTmp
);
945 sal_Int16 eVertOrient
= VertOrientation::LINE_CENTER
;
946 if( sVerticalPos
.getLength() )
948 if( IsXMLToken( sVerticalPos
, XML_TOP
) )
949 eVertOrient
= VertOrientation::LINE_TOP
;
950 else if( IsXMLToken( sVerticalPos
, XML_BOTTOM
) )
951 eVertOrient
= VertOrientation::LINE_BOTTOM
;
953 if( sVerticalRel
.getLength() )
955 if( IsXMLToken( sVerticalRel
, XML_BASELINE
) )
957 // TOP and BOTTOM are exchanged for a baseline relation
958 switch( eVertOrient
)
960 case VertOrientation::LINE_TOP
:
961 eVertOrient
= VertOrientation::BOTTOM
;
963 case VertOrientation::LINE_CENTER
:
964 eVertOrient
= VertOrientation::CENTER
;
966 case VertOrientation::LINE_BOTTOM
:
967 eVertOrient
= VertOrientation::TOP
;
971 else if( IsXMLToken( sVerticalRel
, XML_CHAR
) )
973 switch( eVertOrient
)
975 case VertOrientation::LINE_TOP
:
976 eVertOrient
= VertOrientation::CHAR_TOP
;
978 case VertOrientation::LINE_CENTER
:
979 eVertOrient
= VertOrientation::CHAR_CENTER
;
981 case VertOrientation::LINE_BOTTOM
:
982 eVertOrient
= VertOrientation::CHAR_BOTTOM
;
987 rListLevel
.SetImageVertOrient( eVertOrient
);
990 SvxXMLListLevelStyleAttrContext_Impl::~SvxXMLListLevelStyleAttrContext_Impl()
994 // --> OD 2008-01-16 #newlistlevelattrs#
995 SvXMLImportContext
* SvxXMLListLevelStyleAttrContext_Impl::CreateChildContext(
996 sal_uInt16 nPrefix
, const OUString
& rLocalName
,
997 const Reference
< xml::sax::XAttributeList
> & xAttrList
)
999 SvXMLImportContext
*pContext
= 0;
1000 if ( XML_NAMESPACE_STYLE
== nPrefix
&&
1001 IsXMLToken( rLocalName
, XML_LIST_LEVEL_LABEL_ALIGNMENT
) )
1003 pContext
= new SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl( GetImport(),
1011 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1018 // ---------------------------------------------------------------------
1020 // --> OD 2008-01-16 #newlistlevelattrs#
1021 enum SvxXMLStyleAttributesLabelAlignmentAttrTokens
1023 XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY
,
1024 XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION
,
1025 XML_TOK_STYLE_ATTRIBUTES_ATTR_FIRST_LINE_INDENT
,
1026 XML_TOK_STYLE_ATTRIBUTES_ATTR_INDENT_AT
,
1028 XML_TOK_STYLE_ATTRIBUTES_LABEL_ALIGNMENT_ATTR_END
=XML_TOK_UNKNOWN
1030 const SvXMLTokenMapEntry
* lcl_getStyleAlignmentAttributesAttrTokenMap()
1032 static __FAR_DATA SvXMLTokenMapEntry aStyleAlignmentAttributesAttrTokenMap
[] =
1034 { XML_NAMESPACE_TEXT
, XML_LABEL_FOLLOWED_BY
,
1035 XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY
},
1036 { XML_NAMESPACE_TEXT
, XML_LIST_TAB_STOP_POSITION
,
1037 XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION
},
1038 { XML_NAMESPACE_FO
, XML_TEXT_INDENT
,
1039 XML_TOK_STYLE_ATTRIBUTES_ATTR_FIRST_LINE_INDENT
},
1040 { XML_NAMESPACE_FO
, XML_MARGIN_LEFT
,
1041 XML_TOK_STYLE_ATTRIBUTES_ATTR_INDENT_AT
},
1045 return aStyleAlignmentAttributesAttrTokenMap
;
1047 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(
1048 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
1049 const OUString
& rLName
,
1050 const Reference
< xml::sax::XAttributeList
> & xAttrList
,
1051 SvxXMLListLevelStyleContext_Impl
& rLLevel
) :
1052 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1053 rListLevel( rLLevel
)
1055 SvXMLTokenMap
aTokenMap( lcl_getStyleAlignmentAttributesAttrTokenMap() );
1056 SvXMLUnitConverter
& rUnitConv
= GetImport().GetMM100UnitConverter();
1058 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
1059 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
1061 const OUString
& rAttrName
= xAttrList
->getNameByIndex( i
);
1062 OUString aLocalName
;
1063 sal_uInt16 nPrefix
=
1064 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName
,
1066 const OUString
& rValue
= xAttrList
->getValueByIndex( i
);
1069 switch( aTokenMap
.Get( nPrefix
, aLocalName
) )
1071 case XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY
:
1073 sal_Int16 eLabelFollowedBy
= LabelFollow::LISTTAB
;
1074 if( IsXMLToken( rValue
, XML_SPACE
) )
1075 eLabelFollowedBy
= LabelFollow::SPACE
;
1076 else if( IsXMLToken( rValue
, XML_NOTHING
) )
1077 eLabelFollowedBy
= LabelFollow::NOTHING
;
1078 rListLevel
.SetLabelFollowedBy( eLabelFollowedBy
);
1081 case XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION
:
1082 if( rUnitConv
.convertMeasure( nVal
, rValue
, 0, SHRT_MAX
) )
1083 rListLevel
.SetListtabStopPosition( nVal
);
1085 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FIRST_LINE_INDENT
:
1086 if( rUnitConv
.convertMeasure( nVal
, rValue
, SHRT_MIN
, SHRT_MAX
) )
1087 rListLevel
.SetFirstLineIndent( nVal
);
1089 case XML_TOK_STYLE_ATTRIBUTES_ATTR_INDENT_AT
:
1090 if( rUnitConv
.convertMeasure( nVal
, rValue
, SHRT_MIN
, SHRT_MAX
) )
1091 rListLevel
.SetIndentAt( nVal
);
1097 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::~SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl()
1102 // ---------------------------------------------------------------------
1104 typedef SvxXMLListLevelStyleContext_Impl
*SvxXMLListLevelStyleContext_ImplPtr
;
1105 SV_DECL_PTRARR( SvxXMLListStyle_Impl
, SvxXMLListLevelStyleContext_ImplPtr
,
1108 void SvxXMLListStyleContext::SetAttribute( sal_uInt16 nPrefixKey
,
1109 const OUString
& rLocalName
,
1110 const OUString
& rValue
)
1112 if( XML_NAMESPACE_TEXT
== nPrefixKey
&&
1113 IsXMLToken( rLocalName
, XML_CONSECUTIVE_NUMBERING
) )
1115 bConsecutive
= IsXMLToken( rValue
, XML_TRUE
);
1119 SvXMLStyleContext::SetAttribute( nPrefixKey
, rLocalName
, rValue
);
1124 SvxXMLListStyleContext::SvxXMLListStyleContext( SvXMLImport
& rImport
,
1126 const OUString
& rLName
,
1127 const Reference
< xml::sax::XAttributeList
> & xAttrList
,
1129 : SvXMLStyleContext( rImport
, nPrfx
, rLName
, xAttrList
, bOutl
? XML_STYLE_FAMILY_TEXT_OUTLINE
: XML_STYLE_FAMILY_TEXT_LIST
)
1130 , sIsPhysical( RTL_CONSTASCII_USTRINGPARAM( "IsPhysical" ) )
1131 , sNumberingRules( RTL_CONSTASCII_USTRINGPARAM( "NumberingRules" ) )
1132 , sName( RTL_CONSTASCII_USTRINGPARAM( "Name" ) )
1133 , sIsContinuousNumbering( RTL_CONSTASCII_USTRINGPARAM( "IsContinuousNumbering" ) )
1136 , bConsecutive( sal_False
)
1141 SvxXMLListStyleContext::~SvxXMLListStyleContext()
1145 while( pLevelStyles
->Count() )
1147 sal_uInt16 n
= pLevelStyles
->Count() - 1;
1148 SvxXMLListLevelStyleContext_Impl
*pStyle
= (*pLevelStyles
)[n
];
1149 pLevelStyles
->Remove( n
, 1 );
1150 pStyle
->ReleaseRef();
1154 delete pLevelStyles
;
1157 TYPEINIT1( SvxXMLListStyleContext
, SvXMLStyleContext
);
1159 SvXMLImportContext
*SvxXMLListStyleContext::CreateChildContext(
1161 const OUString
& rLocalName
,
1162 const Reference
< xml::sax::XAttributeList
> & xAttrList
)
1164 SvXMLImportContext
*pContext
= 0;
1166 if( XML_NAMESPACE_TEXT
== nPrefix
&&
1168 ? IsXMLToken( rLocalName
, XML_OUTLINE_LEVEL_STYLE
)
1169 : ( IsXMLToken( rLocalName
, XML_LIST_LEVEL_STYLE_NUMBER
) ||
1170 IsXMLToken( rLocalName
, XML_LIST_LEVEL_STYLE_BULLET
) ||
1171 IsXMLToken( rLocalName
, XML_LIST_LEVEL_STYLE_IMAGE
) ) ) )
1173 SvxXMLListLevelStyleContext_Impl
*pLevelStyle
=
1174 new SvxXMLListLevelStyleContext_Impl( GetImport(), nPrefix
,
1175 rLocalName
, xAttrList
);
1177 pLevelStyles
= new SvxXMLListStyle_Impl
;
1178 pLevelStyles
->Insert( pLevelStyle
, pLevelStyles
->Count() );
1179 pLevelStyle
->AddRef();
1181 pContext
= pLevelStyle
;
1185 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1191 void SvxXMLListStyleContext::FillUnoNumRule(
1192 const Reference
< container::XIndexReplace
> & rNumRule
,
1193 const SvI18NMap
*pI18NMap
) const
1197 if( pLevelStyles
&& rNumRule
.is() )
1199 sal_uInt16 nCount
= pLevelStyles
->Count();
1200 sal_Int32 l_nLevels
= rNumRule
->getCount();
1201 for( sal_uInt16 i
=0; i
< nCount
; i
++ )
1203 SvxXMLListLevelStyleContext_Impl
*pLevelStyle
=
1205 sal_Int32 nLevel
= pLevelStyle
->GetLevel();
1206 if( nLevel
>= 0 && nLevel
< l_nLevels
)
1208 Sequence
<beans::PropertyValue
> aProps
=
1209 pLevelStyle
->GetProperties( pI18NMap
);
1212 rNumRule
->replaceByIndex( nLevel
, aAny
);
1217 Reference
< XPropertySet
> xPropSet( rNumRule
, UNO_QUERY
);
1218 Reference
< XPropertySetInfo
> xPropSetInfo
;
1220 xPropSetInfo
= xPropSet
->getPropertySetInfo();
1221 if( xPropSetInfo
.is() &&
1222 xPropSetInfo
->hasPropertyByName( sIsContinuousNumbering
) )
1225 sal_Bool bTmp
= bConsecutive
;
1226 aAny
.setValue( &bTmp
, ::getBooleanCppuType() );
1227 xPropSet
->setPropertyValue( sIsContinuousNumbering
, aAny
);
1232 DBG_ERROR( "SvxXMLListStyleContext::FillUnoNumRule - Exception catched" );
1236 void SvxXMLListStyleContext::CreateAndInsertLate( sal_Bool bOverwrite
)
1242 const Reference
< XIndexReplace
>& rNumRule
=
1243 GetImport().GetTextImport()->GetChapterNumbering();
1244 // We don't set xNumberingRules here, to avoid using them
1245 // as numbering rules.
1247 FillUnoNumRule( rNumRule
, 0 );
1252 Reference
< XStyle
> xStyle
;
1253 const OUString
& rName
= GetDisplayName();
1254 if( 0 == rName
.getLength() )
1256 SetValid( sal_False
);
1260 const Reference
< XNameContainer
>& rNumStyles
=
1261 GetImport().GetTextImport()->GetNumberingStyles();
1262 if( !rNumStyles
.is() )
1264 SetValid( sal_False
);
1268 sal_Bool bNew
= sal_False
;
1269 if( rNumStyles
->hasByName( rName
) )
1271 Any aAny
= rNumStyles
->getByName( rName
);
1276 Reference
< XMultiServiceFactory
> xFactory( GetImport().GetModel(),
1278 DBG_ASSERT( xFactory
.is(), "no factory" );
1279 if( !xFactory
.is() )
1282 Reference
< XInterface
> xIfc
= xFactory
->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.NumberingStyle")) );
1285 Reference
< XStyle
> xTmp( xIfc
, UNO_QUERY
);
1292 rNumStyles
->insertByName( rName
, aAny
);
1296 Reference
< XPropertySet
> xPropSet( xStyle
, UNO_QUERY
);
1297 Reference
< XPropertySetInfo
> xPropSetInfo
=
1298 xPropSet
->getPropertySetInfo();
1299 if( !bNew
&& xPropSetInfo
->hasPropertyByName( sIsPhysical
) )
1301 Any aAny
= xPropSet
->getPropertyValue( sIsPhysical
);
1302 bNew
= !*(sal_Bool
*)aAny
.getValue();
1304 if( rName
!= GetName() )
1305 GetImport().AddStyleDisplayName( XML_STYLE_FAMILY_TEXT_LIST
,
1308 Any aAny
= xPropSet
->getPropertyValue( sNumberingRules
);
1310 nLevels
= xNumRules
->getCount();
1311 if( bOverwrite
|| bNew
)
1313 FillUnoNumRule( xNumRules
, 0 );
1315 xPropSet
->setPropertyValue( sNumberingRules
, aAny
);
1319 SetValid( sal_False
);
1326 void SvxXMLListStyleContext::CreateAndInsertAuto() const
1328 DBG_ASSERT( !bOutline
, "Outlines cannot be inserted here" );
1329 DBG_ASSERT( !xNumRules
.is(), "Numbering Rule is existing already" );
1331 const OUString
& rName
= GetName();
1332 if( bOutline
|| xNumRules
.is() || 0 == rName
.getLength() )
1334 ((SvxXMLListStyleContext
*)this)->SetValid( sal_False
);
1338 ((SvxXMLListStyleContext
*)this)->xNumRules
= CreateNumRule(
1339 GetImport().GetModel() );
1340 ((SvxXMLListStyleContext
*)this)->nLevels
= xNumRules
->getCount();
1342 FillUnoNumRule( xNumRules
, 0 );
1345 Reference
< XIndexReplace
> SvxXMLListStyleContext::CreateNumRule(
1346 const Reference
< XModel
> & rModel
)
1348 Reference
<XIndexReplace
> xNumRule
;
1350 Reference
< XMultiServiceFactory
> xFactory( rModel
, UNO_QUERY
);
1351 DBG_ASSERT( xFactory
.is(), "no factory" );
1352 if( !xFactory
.is() )
1355 Reference
< XInterface
> xIfc
= xFactory
->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.NumberingRules")) );
1359 xNumRule
= Reference
<XIndexReplace
>( xIfc
, UNO_QUERY
);
1360 DBG_ASSERT( xNumRule
.is(), "go no numbering rule" );
1365 void SvxXMLListStyleContext::SetDefaultStyle(
1366 const Reference
< XIndexReplace
> & rNumRule
,
1370 Sequence
<beans::PropertyValue
> aPropSeq( bOrdered
? 1 : 4 );
1371 beans::PropertyValue
*pProps
= aPropSeq
.getArray();
1374 OUString::createFromAscii( XML_UNO_NAME_NRULE_NUMBERINGTYPE
);
1375 (pProps
++)->Value
<<= (sal_Int16
)(bOrdered
? NumberingType::ARABIC
1376 : NumberingType::CHAR_SPECIAL
);
1379 // TODO: Bullet-Font
1380 //aNumFmt.SetBulletFont( &SwNumRule::GetDefBulletFont() );
1381 awt::FontDescriptor aFDesc
;
1382 aFDesc
.Name
= OUString(
1384 RTL_CONSTASCII_USTRINGPARAM( "starbats" )
1386 RTL_CONSTASCII_USTRINGPARAM( "StarBats" )
1389 aFDesc
.Family
= FAMILY_DONTKNOW
;
1390 aFDesc
.Pitch
= PITCH_DONTKNOW
;
1391 aFDesc
.CharSet
= RTL_TEXTENCODING_SYMBOL
;
1392 aFDesc
.Weight
= WEIGHT_DONTKNOW
;
1393 //aFDesc.Transparant = sal_True;
1395 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_FONT
);
1396 (pProps
++)->Value
<<= aFDesc
;
1398 OUStringBuffer
sTmp(1);
1399 sTmp
.append( (sal_Unicode
)(0xF000 + 149) );
1401 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_CHAR
);
1402 (pProps
++)->Value
<<= sTmp
.makeStringAndClear();
1404 OUString::createFromAscii( XML_UNO_NAME_NRULE_CHAR_STYLE_NAME
);
1405 (pProps
++)->Value
<<=
1406 OUString( RTL_CONSTASCII_USTRINGPARAM( "Numbering Symbols" ) );
1411 rNumRule
->replaceByIndex( nLevel
, aAny
);