merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / style / xmlnumi.cxx
blobb96c7e9bb8ccbb0be760eb5f24dc014071bab496
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 $
10 * $Revision: 1.44 $
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>
52 // <--
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"
63 #endif
64 #ifndef _XMLOFF_XMLFONTSTYLESCONTEXT_HXX
65 #include <xmloff/XMLFontStylesContext.hxx>
66 #endif
67 #ifndef _XMLOFF_FAMILIES_HXX
68 #include <xmloff/families.hxx>
69 #endif
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[] =
92 "SymbolTextDistance";
93 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_PARENT_NUMBERING[] =
94 "ParentNumbering";
95 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_CHAR_STYLE_NAME[] =
96 "CharStyleName";
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[] =
100 "GraphicSize";
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[] =
109 "FirstLineOffset";
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";
120 // <--
122 // ---------------------------------------------------------------------
124 class SvxXMLListLevelStyleContext_Impl;
126 class SvxXMLListLevelStyleAttrContext_Impl : public SvXMLImportContext
128 SvxXMLListLevelStyleContext_Impl& rListLevel;
130 public:
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 );
143 // <--
146 // ---------------------------------------------------------------------
148 // --> OD 2008-01-16 #newlistlevelattrs#
149 class SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl : public SvXMLImportContext
151 SvxXMLListLevelStyleContext_Impl& rListLevel;
153 public:
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();
162 // <--
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 },
204 XML_TOKEN_MAP_END
206 return aLevelAttrTokenMap;
209 class SvxXMLListLevelStyleContext_Impl : public SvXMLImportContext
211 friend class SvxXMLListLevelStyleAttrContext_Impl;
212 const OUString sStarBats;
213 const OUString sStarMath;
215 OUString sPrefix;
216 OUString sSuffix;
217 OUString sTextStyleName;
218 OUString sNumFormat;
219 OUString sNumLetterSync;
220 OUString sBulletFontName;
221 OUString sBulletFontStyleName;
222 OUString sImageURL;
224 Reference < XOutputStream > xBase64Stream;
226 sal_Int32 nLevel;
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;
235 sal_Int16 eAdjust;
236 sal_Int16 eBulletFontFamily;
237 sal_Int16 eBulletFontPitch;
238 rtl_TextEncoding eBulletFontEncoding;
239 sal_Int16 eImageVertOrient;
241 sal_Unicode cBullet;
243 sal_Int16 nRelSize;
244 Color aColor;
246 // --> OD 2008-01-16 #newlistlevelattrs#
247 sal_Int16 ePosAndSpaceMode;
248 sal_Int16 eLabelFollowedBy;
249 sal_Int32 nListtabStopPosition;
250 sal_Int32 nFirstLineIndent;
251 sal_Int32 nIndentAt;
252 // <--
254 sal_Bool bBullet : 1;
255 sal_Bool bImage : 1;
256 sal_Bool bNum : 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; }
279 public:
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 )
314 nIndentAt = nValue;
316 // <--
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" ) )
328 , nLevel( -1L )
329 , nSpaceBefore( 0L )
330 , nMinLabelWidth( 0L )
331 , nMinLabelDist( 0L )
332 , nImageWidth( 0L )
333 , nImageHeight( 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)
341 , cBullet( 0 )
342 , nRelSize(0)
343 , aColor( 0 )
344 // --> OD 2008-01-16 #newlistelevelattrs#
345 , ePosAndSpaceMode( PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION )
346 , eLabelFollowedBy( LabelFollow::LISTTAB )
347 , nListtabStopPosition( 0 )
348 , nFirstLineIndent( 0 )
349 , nIndentAt( 0 )
350 // <--
351 , bBullet( sal_False )
352 , bImage( sal_False )
353 , bNum( sal_False )
354 , bHasColor( sal_False )
356 if( IsXMLToken( rLName, XML_LIST_LEVEL_STYLE_NUMBER ) ||
357 IsXMLToken( rLName, XML_OUTLINE_LEVEL_STYLE ) )
358 bNum = sal_True;
359 else if( IsXMLToken( rLName, XML_LIST_LEVEL_STYLE_BULLET ) )
360 bBullet = sal_True;
361 else if( IsXMLToken( rLName, XML_LIST_LEVEL_STYLE_IMAGE ) )
362 bImage = sal_True;
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 );
369 OUString aLocalName;
370 sal_uInt16 nPrefix =
371 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
372 &aLocalName );
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();
379 if( nLevel >= 1L )
380 nLevel--;
381 else
382 nLevel = 0L;
383 break;
384 case XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME:
385 sTextStyleName = rValue;
386 break;
387 case XML_TOK_TEXT_LEVEL_ATTR_BULLET_CHAR:
388 cBullet = rValue[0];
389 break;
390 case XML_TOK_TEXT_LEVEL_ATTR_HREF:
391 if( bImage )
392 sImageURL = rValue;
393 break;
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
398 break;
399 case XML_TOK_TEXT_LEVEL_ATTR_NUM_FORMAT:
400 if( bNum )
401 sNumFormat = rValue;
402 break;
403 case XML_TOK_TEXT_LEVEL_ATTR_NUM_PREFIX:
404 sPrefix = rValue;
405 break;
406 case XML_TOK_TEXT_LEVEL_ATTR_NUM_SUFFIX:
407 sSuffix = rValue;
408 break;
409 case XML_TOK_TEXT_LEVEL_ATTR_NUM_LETTER_SYNC:
410 if( bNum )
411 sNumLetterSync = rValue;
412 break;
413 case XML_TOK_TEXT_LEVEL_ATTR_START_VALUE:
414 if( bNum )
416 sal_Int32 nTmp = rValue.toInt32();
417 nNumStartValue =
418 (nTmp < 0L) ? 1 : ( (nTmp>SHRT_MAX) ? SHRT_MAX
419 : (sal_Int16)nTmp );
421 break;
422 case XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS:
423 if( bNum )
425 sal_Int32 nTmp = rValue.toInt32();
426 nNumDisplayLevels =
427 (nTmp < 1L) ? 1 : ( (nTmp>SHRT_MAX) ? SHRT_MAX
428 : (sal_Int16)nTmp );
430 break;
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(),
449 nPrefix,
450 rLocalName,
451 xAttrList,
452 *this );
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,
463 xBase64Stream );
466 if( !pContext )
468 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
471 return pContext;
474 Sequence<beans::PropertyValue> SvxXMLListLevelStyleContext_Impl::GetProperties(
475 const SvI18NMap *pI18NMap )
477 sal_Int16 eType;
479 sal_Int32 nCount = 0L;
480 if( bBullet )
482 eType = NumberingType::CHAR_SPECIAL;
483 nCount = cBullet ? 15 : 14;
485 if( bImage )
487 eType = NumberingType::BITMAP;
488 nCount = 15L;
490 if( (sImageURL.getLength() > 0L) || xBase64Stream.is() )
491 nCount++;
493 if( bNum )
495 eType = NumberingType::ARABIC;
496 GetImport().GetMM100UnitConverter().convertNumFormat(
497 eType, sNumFormat, sNumLetterSync, sal_True );
498 nCount = 15L;
501 if( ( bBullet || bNum ) && nRelSize )
502 nCount++;
504 if( !bImage && bHasColor )
506 nCount++;
509 Sequence<beans::PropertyValue> aPropSeq( nCount );
510 if( nCount > 0 )
512 beans::PropertyValue *pProps = aPropSeq.getArray();
513 sal_Int32 nPos = 0L;
514 pProps[nPos].Name =
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;
528 pProps[nPos].Name =
529 OUString::createFromAscii( XML_UNO_NAME_NRULE_LEFT_MARGIN );
530 pProps[nPos++].Value <<= (sal_Int32)nLeftMargin;
532 sal_Int32 nFirstLineOffset = -nMinLabelWidth;
534 pProps[nPos].Name =
535 OUString::createFromAscii( XML_UNO_NAME_NRULE_FIRST_LINE_OFFSET );
536 pProps[nPos++].Value <<= (sal_Int32)nFirstLineOffset;
538 pProps[nPos].Name =
539 OUString::createFromAscii(XML_UNO_NAME_NRULE_SYMBOL_TEXT_DISTANCE);
540 pProps[nPos++].Value <<= (sal_Int16)nMinLabelDist;
542 // --> OD 2008-01-16 #newlistlevelattrs#
543 pProps[nPos].Name =
544 OUString::createFromAscii(XML_UNO_NAME_NRULE_POSITION_AND_SPACE_MODE);
545 pProps[nPos++].Value <<= (sal_Int16)ePosAndSpaceMode;
546 pProps[nPos].Name =
547 OUString::createFromAscii(XML_UNO_NAME_NRULE_LABEL_FOLLOWED_BY);
548 pProps[nPos++].Value <<= (sal_Int16)eLabelFollowedBy;
549 pProps[nPos].Name =
550 OUString::createFromAscii(XML_UNO_NAME_NRULE_LISTTAB_STOP_POSITION);
551 pProps[nPos++].Value <<= (sal_Int32)nListtabStopPosition;
552 pProps[nPos].Name =
553 OUString::createFromAscii(XML_UNO_NAME_NRULE_FIRST_LINE_INDENT);
554 pProps[nPos++].Value <<= (sal_Int32)nFirstLineIndent;
555 pProps[nPos].Name =
556 OUString::createFromAscii(XML_UNO_NAME_NRULE_INDENT_AT);
557 pProps[nPos++].Value <<= (sal_Int32)nIndentAt;
558 // <--
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 );
565 pProps[nPos].Name =
566 OUString::createFromAscii( XML_UNO_NAME_NRULE_CHAR_STYLE_NAME );
567 pProps[nPos++].Value <<= sDisplayTextStyleName;
569 if( bBullet )
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;
592 if( bStarSymbol )
593 aFDesc.Name =
594 OUString( RTL_CONSTASCII_USTRINGPARAM("StarSymbol" ) );
597 if( cBullet )
599 OUStringBuffer sTmp(1);
600 sTmp.append( cBullet );
601 pProps[nPos].Name =
602 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_CHAR );
603 pProps[nPos++].Value <<= sTmp.makeStringAndClear();
606 pProps[nPos].Name =
607 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_FONT );
608 pProps[nPos++].Value <<= aFDesc;
612 if( bImage )
614 OUString sStr( sImageURL );
615 if( sImageURL.getLength() )
617 sStr = GetImport().ResolveGraphicObjectURL( sImageURL,
618 sal_False );
620 else if( xBase64Stream.is() )
622 sStr = GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream );
623 // xBase64Stream = 0;
626 if( sStr.getLength() )
628 pProps[nPos].Name =
629 OUString::createFromAscii( XML_UNO_NAME_NRULE_GRAPHICURL );
630 pProps[nPos++].Value <<= sStr;
633 awt::Size aSize( nImageWidth, nImageHeight );
634 pProps[nPos].Name =
635 OUString::createFromAscii( XML_UNO_NAME_NRULE_GRAPHIC_SIZE );
636 pProps[nPos++].Value <<= aSize;
638 pProps[nPos].Name =
639 OUString::createFromAscii( XML_UNO_NAME_NRULE_VERT_ORIENT );
640 pProps[nPos++].Value <<= (sal_Int16)eImageVertOrient;
643 if( bNum )
645 pProps[nPos].Name =
646 OUString::createFromAscii( XML_UNO_NAME_NRULE_START_WITH );
647 pProps[nPos++].Value <<= (sal_Int16)nNumStartValue;
649 pProps[nPos].Name =
650 OUString::createFromAscii(XML_UNO_NAME_NRULE_PARENT_NUMBERING);
651 pProps[nPos++].Value <<= (sal_Int16)nNumDisplayLevels;
654 if( ( bNum || bBullet ) && nRelSize )
656 pProps[nPos].Name =
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" );
670 return aPropSeq;
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,
696 // <--
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 },
741 // <--
743 XML_TOKEN_MAP_END
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 );
766 OUString aLocalName;
767 sal_uInt16 nPrefix =
768 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
769 &aLocalName );
770 const OUString& rValue = xAttrList->getValueByIndex( i );
772 sal_Int32 nVal;
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 );
778 break;
779 case XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_WIDTH:
780 if( rUnitConv.convertMeasure( nVal, rValue, 0, SHRT_MAX ) )
781 rListLevel.SetMinLabelWidth( nVal );
782 break;
783 case XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_DIST:
784 if( rUnitConv.convertMeasure( nVal, rValue, 0, USHRT_MAX ) )
785 rListLevel.SetMinLabelDist( nVal );
786 break;
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 );
797 break;
798 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_NAME:
799 sFontName = rValue;
800 break;
801 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY:
802 sFontFamily = rValue;
803 break;
804 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY_GENERIC:
805 sFontFamilyGeneric = rValue;
806 break;
807 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_STYLENAME:
808 sFontStyleName = rValue;
809 break;
810 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_PITCH:
811 sFontPitch = rValue;
812 break;
813 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_CHARSET:
814 sFontCharset = rValue;
815 break;
816 case XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_POS:
817 sVerticalPos = rValue;
818 break;
819 case XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_REL:
820 sVerticalRel = rValue;
821 break;
822 case XML_TOK_STYLE_ATTRIBUTES_ATTR_WIDTH:
823 if( rUnitConv.convertMeasure( nVal, rValue, 0, SAL_MAX_INT32) )
824 rListLevel.SetImageWidth( nVal );
825 break;
826 case XML_TOK_STYLE_ATTRIBUTES_ATTR_HEIGHT:
827 if( rUnitConv.convertMeasure( nVal, rValue, 0, SAL_MAX_INT32) )
828 rListLevel.SetImageHeight( nVal );
829 break;
830 case XML_TOK_STYLE_ATTRIBUTES_ATTR_COLOR:
832 Color aColor;
833 if( SvXMLUnitConverter::convertColor( aColor, rValue ) )
834 rListLevel.SetColor( (sal_Int32)aColor.GetColor() );
836 break;
837 case XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR:
839 if( IsXMLToken( rValue, XML_TRUE ) )
840 rListLevel.SetColor( (sal_Int32)0xffffffff );
842 break;
843 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE:
844 if(SvXMLUnitConverter::convertPercent( nVal, rValue ) )
845 rListLevel.SetRelSize( (sal_Int16)nVal );
846 break;
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 );
855 break;
856 // <--
860 if( sFontName.getLength() )
862 const XMLFontStylesContext *pFontDecls =
863 GetImport().GetTextImport()->GetFontDecls();
864 if( pFontDecls )
866 ::std::vector < XMLPropertyState > aProps;
867 if( pFontDecls->FillProperties( sFontName, aProps, 0, 1, 2, 3, 4 ) )
869 OUString sTmp;
870 sal_Int16 nTmp = 0;
871 ::std::vector< XMLPropertyState >::iterator i;
872 for( i = aProps.begin(); i != aProps.end(); i++ )
874 switch( i->mnIndex )
876 case 0:
877 i->maValue >>= sTmp;
878 rListLevel.SetBulletFontName( sTmp);
879 break;
880 case 1:
881 i->maValue >>= sTmp;
882 rListLevel.SetBulletFontStyleName( sTmp );
883 break;
884 case 2:
885 i->maValue >>= nTmp;
886 rListLevel.SetBulletFontFamily( nTmp );
887 break;
888 case 3:
889 i->maValue >>= nTmp;
890 rListLevel.SetBulletFontPitch( nTmp );
891 break;
892 case 4:
893 i->maValue >>= nTmp;
894 rListLevel.SetBulletFontEncoding( nTmp );
895 break;
901 if( sFontFamily.getLength() )
903 String sEmpty;
904 Any aAny;
906 XMLFontFamilyNamePropHdl aFamilyNameHdl;
907 if( aFamilyNameHdl.importXML( sFontFamily, aAny, rUnitConv ) )
909 OUString sTmp;
910 aAny >>= sTmp;
911 rListLevel.SetBulletFontName( sTmp);
914 XMLFontFamilyPropHdl aFamilyHdl;
915 if( sFontFamilyGeneric.getLength() &&
916 aFamilyHdl.importXML( sFontFamilyGeneric, aAny, rUnitConv ) )
918 sal_Int16 nTmp = 0;
919 aAny >>= nTmp;
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 ) )
930 sal_Int16 nTmp = 0;
931 aAny >>= nTmp;
932 rListLevel.SetBulletFontPitch( nTmp );
935 XMLFontEncodingPropHdl aEncHdl;
936 if( sFontCharset.getLength() &&
937 aEncHdl.importXML( sFontCharset, aAny, rUnitConv ) )
939 sal_Int16 nTmp = 0;
940 aAny >>= nTmp;
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;
962 break;
963 case VertOrientation::LINE_CENTER:
964 eVertOrient = VertOrientation::CENTER;
965 break;
966 case VertOrientation::LINE_BOTTOM:
967 eVertOrient = VertOrientation::TOP;
968 break;
971 else if( IsXMLToken( sVerticalRel, XML_CHAR ) )
973 switch( eVertOrient )
975 case VertOrientation::LINE_TOP:
976 eVertOrient = VertOrientation::CHAR_TOP;
977 break;
978 case VertOrientation::LINE_CENTER:
979 eVertOrient = VertOrientation::CHAR_CENTER;
980 break;
981 case VertOrientation::LINE_BOTTOM:
982 eVertOrient = VertOrientation::CHAR_BOTTOM;
983 break;
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(),
1004 nPrefix,
1005 rLocalName,
1006 xAttrList,
1007 rListLevel );
1009 if( !pContext )
1011 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1014 return pContext;
1016 // <--
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 },
1043 XML_TOKEN_MAP_END
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,
1065 &aLocalName );
1066 const OUString& rValue = xAttrList->getValueByIndex( i );
1068 sal_Int32 nVal;
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 );
1080 break;
1081 case XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION:
1082 if( rUnitConv.convertMeasure( nVal, rValue, 0, SHRT_MAX ) )
1083 rListLevel.SetListtabStopPosition( nVal );
1084 break;
1085 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FIRST_LINE_INDENT:
1086 if( rUnitConv.convertMeasure( nVal, rValue, SHRT_MIN, SHRT_MAX ) )
1087 rListLevel.SetFirstLineIndent( nVal );
1088 break;
1089 case XML_TOK_STYLE_ATTRIBUTES_ATTR_INDENT_AT:
1090 if( rUnitConv.convertMeasure( nVal, rValue, SHRT_MIN, SHRT_MAX ) )
1091 rListLevel.SetIndentAt( nVal );
1092 break;
1097 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::~SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl()
1100 // <--
1102 // ---------------------------------------------------------------------
1104 typedef SvxXMLListLevelStyleContext_Impl *SvxXMLListLevelStyleContext_ImplPtr;
1105 SV_DECL_PTRARR( SvxXMLListStyle_Impl, SvxXMLListLevelStyleContext_ImplPtr,
1106 10, 5 )
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 );
1117 else
1119 SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
1124 SvxXMLListStyleContext::SvxXMLListStyleContext( SvXMLImport& rImport,
1125 sal_uInt16 nPrfx,
1126 const OUString& rLName,
1127 const Reference< xml::sax::XAttributeList > & xAttrList,
1128 sal_Bool bOutl )
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" ) )
1134 , pLevelStyles( 0 )
1135 , nLevels( 0 )
1136 , bConsecutive( sal_False )
1137 , bOutline( bOutl )
1141 SvxXMLListStyleContext::~SvxXMLListStyleContext()
1143 if( pLevelStyles )
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(
1160 sal_uInt16 nPrefix,
1161 const OUString& rLocalName,
1162 const Reference< xml::sax::XAttributeList > & xAttrList )
1164 SvXMLImportContext *pContext = 0;
1166 if( XML_NAMESPACE_TEXT == nPrefix &&
1167 ( bOutline
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 );
1176 if( !pLevelStyles )
1177 pLevelStyles = new SvxXMLListStyle_Impl;
1178 pLevelStyles->Insert( pLevelStyle, pLevelStyles->Count() );
1179 pLevelStyle->AddRef();
1181 pContext = pLevelStyle;
1183 else
1185 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1188 return pContext;
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 =
1204 (*pLevelStyles)[i];
1205 sal_Int32 nLevel = pLevelStyle->GetLevel();
1206 if( nLevel >= 0 && nLevel < l_nLevels )
1208 Sequence<beans::PropertyValue> aProps =
1209 pLevelStyle->GetProperties( pI18NMap );
1210 Any aAny;
1211 aAny <<= aProps;
1212 rNumRule->replaceByIndex( nLevel, aAny );
1217 Reference < XPropertySet > xPropSet( rNumRule, UNO_QUERY );
1218 Reference< XPropertySetInfo > xPropSetInfo;
1219 if (xPropSet.is())
1220 xPropSetInfo = xPropSet->getPropertySetInfo();
1221 if( xPropSetInfo.is() &&
1222 xPropSetInfo->hasPropertyByName( sIsContinuousNumbering ) )
1224 Any aAny;
1225 sal_Bool bTmp = bConsecutive;
1226 aAny.setValue( &bTmp, ::getBooleanCppuType() );
1227 xPropSet->setPropertyValue( sIsContinuousNumbering, aAny );
1230 catch( Exception& )
1232 DBG_ERROR( "SvxXMLListStyleContext::FillUnoNumRule - Exception catched" );
1236 void SvxXMLListStyleContext::CreateAndInsertLate( sal_Bool bOverwrite )
1238 if( bOutline )
1240 if( 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.
1246 if( rNumRule.is() )
1247 FillUnoNumRule( rNumRule, 0 );
1250 else
1252 Reference < XStyle > xStyle;
1253 const OUString& rName = GetDisplayName();
1254 if( 0 == rName.getLength() )
1256 SetValid( sal_False );
1257 return;
1260 const Reference < XNameContainer >& rNumStyles =
1261 GetImport().GetTextImport()->GetNumberingStyles();
1262 if( !rNumStyles.is() )
1264 SetValid( sal_False );
1265 return;
1268 sal_Bool bNew = sal_False;
1269 if( rNumStyles->hasByName( rName ) )
1271 Any aAny = rNumStyles->getByName( rName );
1272 aAny >>= xStyle;
1274 else
1276 Reference< XMultiServiceFactory > xFactory( GetImport().GetModel(),
1277 UNO_QUERY );
1278 DBG_ASSERT( xFactory.is(), "no factory" );
1279 if( !xFactory.is() )
1280 return;
1282 Reference < XInterface > xIfc = xFactory->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.NumberingStyle")) );
1283 if( !xIfc.is() )
1284 return;
1285 Reference < XStyle > xTmp( xIfc, UNO_QUERY );
1286 xStyle = xTmp;
1287 if( !xStyle.is() )
1288 return;
1290 Any aAny;
1291 aAny <<= xStyle;
1292 rNumStyles->insertByName( rName, aAny );
1293 bNew = sal_True;
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,
1306 GetName(), rName );
1308 Any aAny = xPropSet->getPropertyValue( sNumberingRules );
1309 aAny >>= xNumRules;
1310 nLevels = xNumRules->getCount();
1311 if( bOverwrite || bNew )
1313 FillUnoNumRule( xNumRules, 0 );
1314 aAny <<= xNumRules;
1315 xPropSet->setPropertyValue( sNumberingRules, aAny );
1317 else
1319 SetValid( sal_False );
1322 SetNew( bNew );
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 );
1335 return;
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() )
1353 return xNumRule;
1355 Reference < XInterface > xIfc = xFactory->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.NumberingRules")) );
1356 if( !xIfc.is() )
1357 return xNumRule;
1359 xNumRule = Reference<XIndexReplace>( xIfc, UNO_QUERY );
1360 DBG_ASSERT( xNumRule.is(), "go no numbering rule" );
1362 return xNumRule;
1365 void SvxXMLListStyleContext::SetDefaultStyle(
1366 const Reference < XIndexReplace > & rNumRule,
1367 sal_Int16 nLevel,
1368 sal_Bool bOrdered )
1370 Sequence<beans::PropertyValue> aPropSeq( bOrdered ? 1 : 4 );
1371 beans::PropertyValue *pProps = aPropSeq.getArray();
1373 pProps->Name =
1374 OUString::createFromAscii( XML_UNO_NAME_NRULE_NUMBERINGTYPE );
1375 (pProps++)->Value <<= (sal_Int16)(bOrdered ? NumberingType::ARABIC
1376 : NumberingType::CHAR_SPECIAL );
1377 if( !bOrdered )
1379 // TODO: Bullet-Font
1380 //aNumFmt.SetBulletFont( &SwNumRule::GetDefBulletFont() );
1381 awt::FontDescriptor aFDesc;
1382 aFDesc.Name = OUString(
1383 #if defined UNX
1384 RTL_CONSTASCII_USTRINGPARAM( "starbats" )
1385 #else
1386 RTL_CONSTASCII_USTRINGPARAM( "StarBats" )
1387 #endif
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;
1394 pProps->Name =
1395 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_FONT );
1396 (pProps++)->Value <<= aFDesc;
1398 OUStringBuffer sTmp(1);
1399 sTmp.append( (sal_Unicode)(0xF000 + 149) );
1400 pProps->Name =
1401 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_CHAR );
1402 (pProps++)->Value <<= sTmp.makeStringAndClear();
1403 pProps->Name =
1404 OUString::createFromAscii( XML_UNO_NAME_NRULE_CHAR_STYLE_NAME );
1405 (pProps++)->Value <<=
1406 OUString( RTL_CONSTASCII_USTRINGPARAM( "Numbering Symbols" ) );
1409 Any aAny;
1410 aAny <<= aPropSeq;
1411 rNumRule->replaceByIndex( nLevel, aAny );