1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_xmloff.hxx" 30 31 #include <com/sun/star/beans/PropertyValue.hpp> 32 #include <com/sun/star/beans/XPropertySet.hpp> 33 #include <com/sun/star/awt/Size.hpp> 34 #include <com/sun/star/awt/FontDescriptor.hpp> 35 #include <com/sun/star/text/HoriOrientation.hpp> 36 #include <com/sun/star/text/VertOrientation.hpp> 37 // --> OD 2008-01-16 #newlistlevelattrs# 38 #include <com/sun/star/text/PositionAndSpaceMode.hpp> 39 #include <com/sun/star/text/LabelFollow.hpp> 40 // <-- 41 #include <com/sun/star/container/XNameContainer.hpp> 42 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 43 #include <com/sun/star/style/XStyle.hpp> 44 #include <com/sun/star/io/XOutputStream.hpp> 45 46 #include <rtl/ustrbuf.hxx> 47 48 #include <tools/urlobj.hxx> 49 #include <tools/debug.hxx> 50 #include <tools/fontenum.hxx> 51 52 #include <xmloff/xmltkmap.hxx> 53 #include <xmloff/nmspmap.hxx> 54 #include "xmloff/xmlnmspe.hxx" 55 #include <xmloff/xmlimp.hxx> 56 #include <xmloff/XMLBase64ImportContext.hxx> 57 #include <xmloff/xmltoken.hxx> 58 59 #include <xmloff/i18nmap.hxx> 60 #include <xmloff/xmluconv.hxx> 61 #include "fonthdl.hxx" 62 #include <xmloff/XMLFontStylesContext.hxx> 63 #include <xmloff/families.hxx> 64 #include <xmloff/maptype.hxx> 65 66 #include <xmloff/xmlnumi.hxx> 67 68 #define _SVSTDARR_USHORTS 69 #include <svl/svstdarr.hxx> 70 71 72 using ::rtl::OUString; 73 using ::rtl::OUStringBuffer; 74 75 using namespace ::com::sun::star; 76 using namespace ::com::sun::star::uno; 77 using namespace ::com::sun::star::style; 78 using namespace ::com::sun::star::text; 79 using namespace ::com::sun::star::beans; 80 using namespace ::com::sun::star::container; 81 using namespace ::com::sun::star::lang; 82 using namespace ::com::sun::star::frame; 83 using namespace ::xmloff::token; 84 using namespace ::com::sun::star::io; 85 86 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_SYMBOL_TEXT_DISTANCE[] = 87 "SymbolTextDistance"; 88 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_PARENT_NUMBERING[] = 89 "ParentNumbering"; 90 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_CHAR_STYLE_NAME[] = 91 "CharStyleName"; 92 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_BULLET_CHAR[] ="BulletChar"; 93 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_BULLET_RELSIZE[] = "BulletRelSize"; 94 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_GRAPHIC_SIZE[] = 95 "GraphicSize"; 96 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_VERT_ORIENT[] ="VertOrient"; 97 98 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_NUMBERINGTYPE[] = "NumberingType"; 99 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_PREFIX[] = "Prefix"; 100 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_SUFFIX[] = "Suffix"; 101 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_ADJUST[] = "Adjust"; 102 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_LEFT_MARGIN[] = "LeftMargin"; 103 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_FIRST_LINE_OFFSET[] = 104 "FirstLineOffset"; 105 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_BULLET_FONT[] = "BulletFont"; 106 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_GRAPHICURL[] = "GraphicURL"; 107 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_START_WITH[] = "StartWith"; 108 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_BULLET_COLOR[] = "BulletColor"; 109 // --> OD 2008-01-15 #newlistlevelattrs# 110 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_POSITION_AND_SPACE_MODE[] = "PositionAndSpaceMode"; 111 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_LABEL_FOLLOWED_BY[] = "LabelFollowedBy"; 112 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_LISTTAB_STOP_POSITION[] = "ListtabStopPosition"; 113 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_FIRST_LINE_INDENT[] = "FirstLineIndent"; 114 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_INDENT_AT[] = "IndentAt"; 115 // <-- 116 117 // --------------------------------------------------------------------- 118 119 class SvxXMLListLevelStyleContext_Impl; 120 121 class SvxXMLListLevelStyleAttrContext_Impl : public SvXMLImportContext 122 { 123 SvxXMLListLevelStyleContext_Impl& rListLevel; 124 125 public: 126 127 SvxXMLListLevelStyleAttrContext_Impl( 128 SvXMLImport& rImport, sal_uInt16 nPrfx, 129 const OUString& rLName, 130 const Reference< xml::sax::XAttributeList >& xAttrList, 131 SvxXMLListLevelStyleContext_Impl& rLLevel ); 132 virtual ~SvxXMLListLevelStyleAttrContext_Impl(); 133 134 // --> OD 2008-01-16 #newlistlevelattrs# 135 virtual SvXMLImportContext *CreateChildContext( 136 sal_uInt16 nPrefix, const OUString& rLocalName, 137 const Reference< xml::sax::XAttributeList > & xAttrList ); 138 // <-- 139 }; 140 141 // --------------------------------------------------------------------- 142 143 // --> OD 2008-01-16 #newlistlevelattrs# 144 class SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl : public SvXMLImportContext 145 { 146 SvxXMLListLevelStyleContext_Impl& rListLevel; 147 148 public: 149 150 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl( 151 SvXMLImport& rImport, sal_uInt16 nPrfx, 152 const OUString& rLName, 153 const Reference< xml::sax::XAttributeList >& xAttrList, 154 SvxXMLListLevelStyleContext_Impl& rLLevel ); 155 virtual ~SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(); 156 }; 157 // <-- 158 159 // --------------------------------------------------------------------- 160 161 enum SvxXMLTextListLevelStyleAttrTokens 162 { 163 XML_TOK_TEXT_LEVEL_ATTR_LEVEL, 164 XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME, 165 XML_TOK_TEXT_LEVEL_ATTR_BULLET_CHAR, 166 XML_TOK_TEXT_LEVEL_ATTR_HREF, 167 XML_TOK_TEXT_LEVEL_ATTR_TYPE, 168 XML_TOK_TEXT_LEVEL_ATTR_SHOW, 169 XML_TOK_TEXT_LEVEL_ATTR_ACTUATE, 170 XML_TOK_TEXT_LEVEL_ATTR_NUM_FORMAT, 171 XML_TOK_TEXT_LEVEL_ATTR_NUM_PREFIX, 172 XML_TOK_TEXT_LEVEL_ATTR_NUM_SUFFIX, 173 XML_TOK_TEXT_LEVEL_ATTR_NUM_LETTER_SYNC, 174 XML_TOK_TEXT_LEVEL_ATTR_START_VALUE, 175 XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS, 176 177 XML_TOK_TEXT_LEVEL_ATTR_END=XML_TOK_UNKNOWN 178 }; 179 180 const SvXMLTokenMapEntry* lcl_getLevelAttrTokenMap() 181 { 182 static __FAR_DATA SvXMLTokenMapEntry aLevelAttrTokenMap[] = 183 { 184 { XML_NAMESPACE_TEXT, XML_LEVEL, XML_TOK_TEXT_LEVEL_ATTR_LEVEL }, 185 { XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME }, 186 { XML_NAMESPACE_TEXT, XML_BULLET_CHAR, XML_TOK_TEXT_LEVEL_ATTR_BULLET_CHAR }, 187 { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TEXT_LEVEL_ATTR_HREF }, 188 { XML_NAMESPACE_XLINK, XML_TYPE, XML_TOK_TEXT_LEVEL_ATTR_TYPE }, 189 { XML_NAMESPACE_XLINK, XML_SHOW, XML_TOK_TEXT_LEVEL_ATTR_SHOW }, 190 { XML_NAMESPACE_XLINK, XML_ACTUATE, XML_TOK_TEXT_LEVEL_ATTR_ACTUATE }, 191 192 { XML_NAMESPACE_STYLE, XML_NUM_FORMAT, XML_TOK_TEXT_LEVEL_ATTR_NUM_FORMAT }, 193 { XML_NAMESPACE_STYLE, XML_NUM_PREFIX, XML_TOK_TEXT_LEVEL_ATTR_NUM_PREFIX }, 194 { XML_NAMESPACE_STYLE, XML_NUM_SUFFIX, XML_TOK_TEXT_LEVEL_ATTR_NUM_SUFFIX }, 195 { XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC, XML_TOK_TEXT_LEVEL_ATTR_NUM_LETTER_SYNC }, 196 { XML_NAMESPACE_TEXT, XML_START_VALUE, XML_TOK_TEXT_LEVEL_ATTR_START_VALUE }, 197 { XML_NAMESPACE_TEXT, XML_DISPLAY_LEVELS, XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS }, 198 199 XML_TOKEN_MAP_END 200 }; 201 return aLevelAttrTokenMap; 202 } 203 204 class SvxXMLListLevelStyleContext_Impl : public SvXMLImportContext 205 { 206 friend class SvxXMLListLevelStyleAttrContext_Impl; 207 const OUString sStarBats; 208 const OUString sStarMath; 209 210 OUString sPrefix; 211 OUString sSuffix; 212 OUString sTextStyleName; 213 OUString sNumFormat; 214 OUString sNumLetterSync; 215 OUString sBulletFontName; 216 OUString sBulletFontStyleName; 217 OUString sImageURL; 218 219 Reference < XOutputStream > xBase64Stream; 220 221 sal_Int32 nLevel; 222 sal_Int32 nSpaceBefore; 223 sal_Int32 nMinLabelWidth; 224 sal_Int32 nMinLabelDist; 225 sal_Int32 nImageWidth; 226 sal_Int32 nImageHeight; 227 sal_Int16 nNumStartValue; 228 sal_Int16 nNumDisplayLevels; 229 230 sal_Int16 eAdjust; 231 sal_Int16 eBulletFontFamily; 232 sal_Int16 eBulletFontPitch; 233 rtl_TextEncoding eBulletFontEncoding; 234 sal_Int16 eImageVertOrient; 235 236 sal_Unicode cBullet; 237 238 sal_Int16 nRelSize; 239 Color aColor; 240 241 // --> OD 2008-01-16 #newlistlevelattrs# 242 sal_Int16 ePosAndSpaceMode; 243 sal_Int16 eLabelFollowedBy; 244 sal_Int32 nListtabStopPosition; 245 sal_Int32 nFirstLineIndent; 246 sal_Int32 nIndentAt; 247 // <-- 248 249 sal_Bool bBullet : 1; 250 sal_Bool bImage : 1; 251 sal_Bool bNum : 1; 252 sal_Bool bHasColor : 1; 253 254 void SetRelSize( sal_Int16 nRel ) { nRelSize = nRel; } 255 void SetColor( sal_Int32 _aColor ) { aColor = _aColor; bHasColor = sal_True; } 256 void SetSpaceBefore( sal_Int32 nSet ) { nSpaceBefore = nSet; } 257 void SetMinLabelWidth( sal_Int32 nSet ) { nMinLabelWidth = nSet; } 258 void SetMinLabelDist( sal_Int32 nSet ) { nMinLabelDist = nSet; } 259 void SetAdjust( sal_Int16 eSet ) { eAdjust = eSet; } 260 261 void SetBulletFontName( const OUString& rSet ) { sBulletFontName = rSet; } 262 void SetBulletFontStyleName( const OUString& rSet ) 263 { sBulletFontStyleName = rSet; } 264 void SetBulletFontFamily( sal_Int16 eSet ) { eBulletFontFamily = eSet; } 265 void SetBulletFontPitch( sal_Int16 eSet ) { eBulletFontPitch = eSet; } 266 void SetBulletFontEncoding( rtl_TextEncoding eSet ) 267 { eBulletFontEncoding = eSet; } 268 269 void SetImageWidth( sal_Int32 nSet ) { nImageWidth = nSet; } 270 void SetImageHeight( sal_Int32 nSet ) { nImageHeight = nSet; } 271 void SetImageVertOrient( sal_Int16 eSet ) 272 { eImageVertOrient = eSet; } 273 274 public: 275 276 SvxXMLListLevelStyleContext_Impl( 277 SvXMLImport& rImport, sal_uInt16 nPrfx, 278 const OUString& rLName, 279 const Reference< xml::sax::XAttributeList > & xAttrList ); 280 virtual ~SvxXMLListLevelStyleContext_Impl(); 281 282 virtual SvXMLImportContext *CreateChildContext( 283 sal_uInt16 nPrefix, const OUString& rLocalName, 284 const Reference< xml::sax::XAttributeList > & xAttrList ); 285 286 sal_Int32 GetLevel() const { return nLevel; } 287 Sequence<beans::PropertyValue> GetProperties( 288 const SvI18NMap *pI18NMap=0 ); 289 290 // --> OD 2008-01-16 #newlistlevelattrs# 291 inline void SetPosAndSpaceMode( sal_Int16 eValue ) 292 { 293 ePosAndSpaceMode = eValue; 294 } 295 inline void SetLabelFollowedBy( sal_Int16 eValue ) 296 { 297 eLabelFollowedBy = eValue; 298 } 299 inline void SetListtabStopPosition( sal_Int32 nValue ) 300 { 301 nListtabStopPosition = nValue; 302 } 303 inline void SetFirstLineIndent( sal_Int32 nValue ) 304 { 305 nFirstLineIndent = nValue; 306 } 307 inline void SetIndentAt( sal_Int32 nValue ) 308 { 309 nIndentAt = nValue; 310 } 311 // <-- 312 }; 313 314 SvxXMLListLevelStyleContext_Impl::SvxXMLListLevelStyleContext_Impl( 315 SvXMLImport& rImport, sal_uInt16 nPrfx, 316 const OUString& rLName, 317 const Reference< xml::sax::XAttributeList > & xAttrList ) 318 319 : SvXMLImportContext( rImport, nPrfx, rLName ) 320 , sStarBats( RTL_CONSTASCII_USTRINGPARAM( "StarBats" ) ) 321 , sStarMath( RTL_CONSTASCII_USTRINGPARAM( "StarMath" ) ) 322 , sNumFormat( OUString::createFromAscii( "1" ) ) 323 , nLevel( -1L ) 324 , nSpaceBefore( 0L ) 325 , nMinLabelWidth( 0L ) 326 , nMinLabelDist( 0L ) 327 , nImageWidth( 0L ) 328 , nImageHeight( 0L ) 329 , nNumStartValue( 1 ) 330 , nNumDisplayLevels( 1 ) 331 , eAdjust( HoriOrientation::LEFT ) 332 , eBulletFontFamily( FAMILY_DONTKNOW ) 333 , eBulletFontPitch( PITCH_DONTKNOW ) 334 , eBulletFontEncoding( RTL_TEXTENCODING_DONTKNOW ) 335 , eImageVertOrient(0) 336 , cBullet( 0 ) 337 , nRelSize(0) 338 , aColor( 0 ) 339 // --> OD 2008-01-16 #newlistelevelattrs# 340 , ePosAndSpaceMode( PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION ) 341 , eLabelFollowedBy( LabelFollow::LISTTAB ) 342 , nListtabStopPosition( 0 ) 343 , nFirstLineIndent( 0 ) 344 , nIndentAt( 0 ) 345 // <-- 346 , bBullet( sal_False ) 347 , bImage( sal_False ) 348 , bNum( sal_False ) 349 , bHasColor( sal_False ) 350 { 351 if( IsXMLToken( rLName, XML_LIST_LEVEL_STYLE_NUMBER ) || 352 IsXMLToken( rLName, XML_OUTLINE_LEVEL_STYLE ) ) 353 bNum = sal_True; 354 else if( IsXMLToken( rLName, XML_LIST_LEVEL_STYLE_BULLET ) ) 355 bBullet = sal_True; 356 else if( IsXMLToken( rLName, XML_LIST_LEVEL_STYLE_IMAGE ) ) 357 bImage = sal_True; 358 359 SvXMLTokenMap aTokenMap( lcl_getLevelAttrTokenMap() ); 360 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 361 for( sal_Int16 i=0; i < nAttrCount; i++ ) 362 { 363 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 364 OUString aLocalName; 365 sal_uInt16 nPrefix = 366 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 367 &aLocalName ); 368 const OUString& rValue = xAttrList->getValueByIndex( i ); 369 370 switch( aTokenMap.Get( nPrefix, aLocalName ) ) 371 { 372 case XML_TOK_TEXT_LEVEL_ATTR_LEVEL: 373 nLevel = rValue.toInt32(); 374 if( nLevel >= 1L ) 375 nLevel--; 376 else 377 nLevel = 0; 378 break; 379 case XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME: 380 sTextStyleName = rValue; 381 break; 382 case XML_TOK_TEXT_LEVEL_ATTR_BULLET_CHAR: 383 cBullet = rValue[0]; 384 break; 385 case XML_TOK_TEXT_LEVEL_ATTR_HREF: 386 if( bImage ) 387 sImageURL = rValue; 388 break; 389 case XML_TOK_TEXT_LEVEL_ATTR_TYPE: 390 case XML_TOK_TEXT_LEVEL_ATTR_SHOW: 391 case XML_TOK_TEXT_LEVEL_ATTR_ACTUATE: 392 // This properties will be ignored 393 break; 394 case XML_TOK_TEXT_LEVEL_ATTR_NUM_FORMAT: 395 if( bNum ) 396 sNumFormat = rValue; 397 break; 398 case XML_TOK_TEXT_LEVEL_ATTR_NUM_PREFIX: 399 sPrefix = rValue; 400 break; 401 case XML_TOK_TEXT_LEVEL_ATTR_NUM_SUFFIX: 402 sSuffix = rValue; 403 break; 404 case XML_TOK_TEXT_LEVEL_ATTR_NUM_LETTER_SYNC: 405 if( bNum ) 406 sNumLetterSync = rValue; 407 break; 408 case XML_TOK_TEXT_LEVEL_ATTR_START_VALUE: 409 if( bNum ) 410 { 411 sal_Int32 nTmp = rValue.toInt32(); 412 nNumStartValue = 413 (nTmp < 0L) ? 1 : ( (nTmp>SHRT_MAX) ? SHRT_MAX 414 : (sal_Int16)nTmp ); 415 } 416 break; 417 case XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS: 418 if( bNum ) 419 { 420 sal_Int32 nTmp = rValue.toInt32(); 421 nNumDisplayLevels = 422 (nTmp < 1L) ? 1 : ( (nTmp>SHRT_MAX) ? SHRT_MAX 423 : (sal_Int16)nTmp ); 424 } 425 break; 426 } 427 } 428 } 429 430 SvxXMLListLevelStyleContext_Impl::~SvxXMLListLevelStyleContext_Impl() 431 { 432 } 433 434 SvXMLImportContext *SvxXMLListLevelStyleContext_Impl::CreateChildContext( 435 sal_uInt16 nPrefix, const OUString& rLocalName, 436 const Reference< xml::sax::XAttributeList > & xAttrList ) 437 { 438 SvXMLImportContext *pContext = 0; 439 if( XML_NAMESPACE_STYLE == nPrefix && 440 ( IsXMLToken( rLocalName, XML_LIST_LEVEL_PROPERTIES ) || 441 IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) ) ) 442 { 443 pContext = new SvxXMLListLevelStyleAttrContext_Impl( GetImport(), 444 nPrefix, 445 rLocalName, 446 xAttrList, 447 *this ); 448 } 449 else if( (XML_NAMESPACE_OFFICE == nPrefix) && xmloff::token::IsXMLToken( rLocalName, 450 xmloff::token::XML_BINARY_DATA ) ) 451 { 452 if( bImage && !sImageURL.getLength() && !xBase64Stream.is() ) 453 { 454 xBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64(); 455 if( xBase64Stream.is() ) 456 pContext = new XMLBase64ImportContext( GetImport(), nPrefix, 457 rLocalName, xAttrList, 458 xBase64Stream ); 459 } 460 } 461 if( !pContext ) 462 { 463 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); 464 } 465 466 return pContext; 467 } 468 469 Sequence<beans::PropertyValue> SvxXMLListLevelStyleContext_Impl::GetProperties( 470 const SvI18NMap *pI18NMap ) 471 { 472 sal_Int16 eType; 473 474 sal_Int32 nCount = 0; 475 if( bBullet ) 476 { 477 eType = NumberingType::CHAR_SPECIAL; 478 nCount = cBullet ? 15 : 14; 479 } 480 if( bImage ) 481 { 482 eType = NumberingType::BITMAP; 483 nCount = 15; 484 485 if( (sImageURL.getLength() > 0L) || xBase64Stream.is() ) 486 nCount++; 487 } 488 if( bNum ) 489 { 490 eType = NumberingType::ARABIC; 491 GetImport().GetMM100UnitConverter().convertNumFormat( 492 eType, sNumFormat, sNumLetterSync, sal_True ); 493 nCount = 15; 494 } 495 496 if( ( bBullet || bNum ) && nRelSize ) 497 nCount++; 498 499 if( !bImage && bHasColor ) 500 { 501 nCount++; 502 } 503 504 if (bBullet && sSuffix.getLength()) 505 { 506 sal_uInt16 const nVersion(GetImport().getGeneratorVersion()); 507 sal_Int32 nUPD; 508 sal_Int32 nBuildId; 509 if (GetImport().getBuildIds(nUPD, nBuildId) 510 && ( (SvXMLImport::OOo_1x == nVersion) 511 || (SvXMLImport::OOo_2x == nVersion) 512 || (310 == nUPD) || (320 == nUPD) || (330 == nUPD) 513 || ((300 == nUPD) && (nBuildId <= 9573)))) 514 { 515 // #i93908# OOo < 3.4 wrote a bogus suffix for bullet chars 516 sSuffix = ::rtl::OUString(); // clear it 517 } 518 } 519 520 Sequence<beans::PropertyValue> aPropSeq( nCount ); 521 if( nCount > 0 ) 522 { 523 beans::PropertyValue *pProps = aPropSeq.getArray(); 524 sal_Int32 nPos = 0; 525 pProps[nPos].Name = 526 OUString::createFromAscii( XML_UNO_NAME_NRULE_NUMBERINGTYPE ); 527 pProps[nPos++].Value <<= (sal_Int16)eType ; 528 529 pProps[nPos].Name = OUString::createFromAscii( XML_UNO_NAME_NRULE_PREFIX ); 530 pProps[nPos++].Value <<= sPrefix; 531 532 pProps[nPos].Name = OUString::createFromAscii( XML_UNO_NAME_NRULE_SUFFIX ); 533 pProps[nPos++].Value <<= sSuffix; 534 535 pProps[nPos].Name = OUString::createFromAscii( XML_UNO_NAME_NRULE_ADJUST ); 536 pProps[nPos++].Value <<= eAdjust; 537 538 sal_Int32 nLeftMargin = nSpaceBefore + nMinLabelWidth; 539 pProps[nPos].Name = 540 OUString::createFromAscii( XML_UNO_NAME_NRULE_LEFT_MARGIN ); 541 pProps[nPos++].Value <<= (sal_Int32)nLeftMargin; 542 543 sal_Int32 nFirstLineOffset = -nMinLabelWidth; 544 545 pProps[nPos].Name = 546 OUString::createFromAscii( XML_UNO_NAME_NRULE_FIRST_LINE_OFFSET ); 547 pProps[nPos++].Value <<= (sal_Int32)nFirstLineOffset; 548 549 pProps[nPos].Name = 550 OUString::createFromAscii(XML_UNO_NAME_NRULE_SYMBOL_TEXT_DISTANCE); 551 pProps[nPos++].Value <<= (sal_Int16)nMinLabelDist; 552 553 // --> OD 2008-01-16 #newlistlevelattrs# 554 pProps[nPos].Name = 555 OUString::createFromAscii(XML_UNO_NAME_NRULE_POSITION_AND_SPACE_MODE); 556 pProps[nPos++].Value <<= (sal_Int16)ePosAndSpaceMode; 557 pProps[nPos].Name = 558 OUString::createFromAscii(XML_UNO_NAME_NRULE_LABEL_FOLLOWED_BY); 559 pProps[nPos++].Value <<= (sal_Int16)eLabelFollowedBy; 560 pProps[nPos].Name = 561 OUString::createFromAscii(XML_UNO_NAME_NRULE_LISTTAB_STOP_POSITION); 562 pProps[nPos++].Value <<= (sal_Int32)nListtabStopPosition; 563 pProps[nPos].Name = 564 OUString::createFromAscii(XML_UNO_NAME_NRULE_FIRST_LINE_INDENT); 565 pProps[nPos++].Value <<= (sal_Int32)nFirstLineIndent; 566 pProps[nPos].Name = 567 OUString::createFromAscii(XML_UNO_NAME_NRULE_INDENT_AT); 568 pProps[nPos++].Value <<= (sal_Int32)nIndentAt; 569 // <-- 570 571 OUString sDisplayTextStyleName = GetImport().GetStyleDisplayName( 572 XML_STYLE_FAMILY_TEXT_TEXT, sTextStyleName ); 573 OUString sStyleName = sDisplayTextStyleName; 574 if( sStyleName.getLength() && pI18NMap ) 575 sStyleName = pI18NMap->Get( SFX_STYLE_FAMILY_CHAR, sStyleName ); 576 pProps[nPos].Name = 577 OUString::createFromAscii( XML_UNO_NAME_NRULE_CHAR_STYLE_NAME ); 578 pProps[nPos++].Value <<= sDisplayTextStyleName; 579 580 if( bBullet ) 581 { 582 awt::FontDescriptor aFDesc; 583 aFDesc.Name = sBulletFontName; 584 if( sBulletFontName.getLength() ) 585 { 586 aFDesc.StyleName = sBulletFontStyleName; 587 aFDesc.Family = eBulletFontFamily; 588 aFDesc.Pitch = eBulletFontPitch; 589 aFDesc.CharSet = eBulletFontEncoding; 590 aFDesc.Weight = WEIGHT_DONTKNOW; 591 //aFDesc.Transparant = sal_True; 592 sal_Bool bStarSymbol = sal_False; 593 if( aFDesc.Name.equalsIgnoreAsciiCase( sStarBats ) ) 594 { 595 cBullet = GetImport().ConvStarBatsCharToStarSymbol( cBullet ); 596 bStarSymbol = sal_True; 597 } 598 else if( aFDesc.Name.equalsIgnoreAsciiCase( sStarMath ) ) 599 { 600 cBullet = GetImport().ConvStarMathCharToStarSymbol( cBullet ); 601 bStarSymbol = sal_True; 602 } 603 if( bStarSymbol ) 604 aFDesc.Name = 605 OUString( RTL_CONSTASCII_USTRINGPARAM("StarSymbol" ) ); 606 } 607 608 if( cBullet ) 609 { 610 OUStringBuffer sTmp(1); 611 sTmp.append( cBullet ); 612 pProps[nPos].Name = 613 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_CHAR ); 614 pProps[nPos++].Value <<= sTmp.makeStringAndClear(); 615 } 616 617 pProps[nPos].Name = 618 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_FONT ); 619 pProps[nPos++].Value <<= aFDesc; 620 621 } 622 623 if( bImage ) 624 { 625 OUString sStr( sImageURL ); 626 if( sImageURL.getLength() ) 627 { 628 sStr = GetImport().ResolveGraphicObjectURL( sImageURL, 629 sal_False ); 630 } 631 else if( xBase64Stream.is() ) 632 { 633 sStr = GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream ); 634 // xBase64Stream = 0; 635 } 636 637 if( sStr.getLength() ) 638 { 639 pProps[nPos].Name = 640 OUString::createFromAscii( XML_UNO_NAME_NRULE_GRAPHICURL ); 641 pProps[nPos++].Value <<= sStr; 642 } 643 644 awt::Size aSize( nImageWidth, nImageHeight ); 645 pProps[nPos].Name = 646 OUString::createFromAscii( XML_UNO_NAME_NRULE_GRAPHIC_SIZE ); 647 pProps[nPos++].Value <<= aSize; 648 649 pProps[nPos].Name = 650 OUString::createFromAscii( XML_UNO_NAME_NRULE_VERT_ORIENT ); 651 pProps[nPos++].Value <<= (sal_Int16)eImageVertOrient; 652 } 653 654 if( bNum ) 655 { 656 pProps[nPos].Name = 657 OUString::createFromAscii( XML_UNO_NAME_NRULE_START_WITH ); 658 pProps[nPos++].Value <<= (sal_Int16)nNumStartValue; 659 660 pProps[nPos].Name = 661 OUString::createFromAscii(XML_UNO_NAME_NRULE_PARENT_NUMBERING); 662 pProps[nPos++].Value <<= (sal_Int16)nNumDisplayLevels; 663 } 664 665 if( ( bNum || bBullet ) && nRelSize ) 666 { 667 pProps[nPos].Name = 668 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_RELSIZE ); 669 pProps[nPos++].Value <<= nRelSize; 670 } 671 672 if( !bImage && bHasColor ) 673 { 674 pProps[nPos].Name = OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_COLOR ); 675 pProps[nPos++].Value <<= (sal_Int32)aColor.GetColor(); 676 } 677 678 DBG_ASSERT( nPos == nCount, "array under/overflow" ); 679 } 680 681 return aPropSeq; 682 } 683 684 // --------------------------------------------------------------------- 685 686 enum SvxXMLStyleAttributesAttrTokens 687 { 688 XML_TOK_STYLE_ATTRIBUTES_ATTR_SPACE_BEFORE, 689 XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_WIDTH, 690 XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_DIST, 691 XML_TOK_STYLE_ATTRIBUTES_ATTR_TEXT_ALIGN, 692 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_NAME, 693 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY, 694 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY_GENERIC, 695 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_STYLENAME, 696 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_PITCH, 697 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_CHARSET, 698 XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_POS, 699 XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_REL, 700 XML_TOK_STYLE_ATTRIBUTES_ATTR_WIDTH, 701 XML_TOK_STYLE_ATTRIBUTES_ATTR_HEIGHT, 702 XML_TOK_STYLE_ATTRIBUTES_ATTR_COLOR, 703 XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR, 704 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE, 705 // --> OD 2008-01-16 #newlistlevelattrs# 706 XML_TOK_STYLE_ATTRIBUTES_ATTR_POSITION_AND_SPACE_MODE, 707 // <-- 708 709 XML_TOK_STYLE_ATTRIBUTES_ATTR_END=XML_TOK_UNKNOWN 710 }; 711 const SvXMLTokenMapEntry* lcl_getStyleAttributesAttrTokenMap() 712 { 713 static __FAR_DATA SvXMLTokenMapEntry aStyleAttributesAttrTokenMap[] = 714 { 715 { XML_NAMESPACE_TEXT, XML_SPACE_BEFORE, 716 XML_TOK_STYLE_ATTRIBUTES_ATTR_SPACE_BEFORE }, 717 { XML_NAMESPACE_TEXT, XML_MIN_LABEL_WIDTH, 718 XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_WIDTH }, 719 { XML_NAMESPACE_TEXT, XML_MIN_LABEL_DISTANCE, 720 XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_DIST }, 721 { XML_NAMESPACE_FO, XML_TEXT_ALIGN, 722 XML_TOK_STYLE_ATTRIBUTES_ATTR_TEXT_ALIGN }, 723 { XML_NAMESPACE_STYLE, XML_FONT_NAME, 724 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_NAME }, 725 { XML_NAMESPACE_FO, XML_FONT_FAMILY, 726 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY }, 727 { XML_NAMESPACE_STYLE, XML_FONT_FAMILY_GENERIC, 728 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY_GENERIC }, 729 { XML_NAMESPACE_STYLE, XML_FONT_STYLE_NAME, 730 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_STYLENAME }, 731 { XML_NAMESPACE_STYLE, XML_FONT_PITCH, 732 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_PITCH }, 733 { XML_NAMESPACE_STYLE, XML_FONT_CHARSET, 734 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_CHARSET }, 735 { XML_NAMESPACE_STYLE, XML_VERTICAL_POS, 736 XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_POS }, 737 { XML_NAMESPACE_STYLE, XML_VERTICAL_REL, 738 XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_REL }, 739 { XML_NAMESPACE_FO, XML_WIDTH, 740 XML_TOK_STYLE_ATTRIBUTES_ATTR_WIDTH }, 741 { XML_NAMESPACE_FO, XML_HEIGHT, 742 XML_TOK_STYLE_ATTRIBUTES_ATTR_HEIGHT }, 743 { XML_NAMESPACE_FO, XML_COLOR, 744 XML_TOK_STYLE_ATTRIBUTES_ATTR_COLOR }, 745 { XML_NAMESPACE_STYLE, XML_USE_WINDOW_FONT_COLOR, 746 XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR }, 747 { XML_NAMESPACE_FO, XML_FONT_SIZE, 748 XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE }, 749 // --> OD 2008-01-16 #newlistlevelattrs# 750 { XML_NAMESPACE_TEXT, XML_LIST_LEVEL_POSITION_AND_SPACE_MODE, 751 XML_TOK_STYLE_ATTRIBUTES_ATTR_POSITION_AND_SPACE_MODE }, 752 // <-- 753 754 XML_TOKEN_MAP_END 755 }; 756 return aStyleAttributesAttrTokenMap; 757 } 758 SvxXMLListLevelStyleAttrContext_Impl::SvxXMLListLevelStyleAttrContext_Impl( 759 SvXMLImport& rImport, sal_uInt16 nPrfx, 760 const OUString& rLName, 761 const Reference< xml::sax::XAttributeList > & xAttrList, 762 SvxXMLListLevelStyleContext_Impl& rLLevel ) : 763 SvXMLImportContext( rImport, nPrfx, rLName ), 764 rListLevel( rLLevel ) 765 { 766 SvXMLTokenMap aTokenMap( lcl_getStyleAttributesAttrTokenMap() ); 767 SvXMLUnitConverter& rUnitConv = GetImport().GetMM100UnitConverter(); 768 769 OUString sFontName, sFontFamily, sFontStyleName, sFontFamilyGeneric, 770 sFontPitch, sFontCharset; 771 OUString sVerticalPos, sVerticalRel; 772 773 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 774 for( sal_Int16 i=0; i < nAttrCount; i++ ) 775 { 776 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 777 OUString aLocalName; 778 sal_uInt16 nPrefix = 779 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 780 &aLocalName ); 781 const OUString& rValue = xAttrList->getValueByIndex( i ); 782 783 sal_Int32 nVal; 784 switch( aTokenMap.Get( nPrefix, aLocalName ) ) 785 { 786 case XML_TOK_STYLE_ATTRIBUTES_ATTR_SPACE_BEFORE: 787 if( rUnitConv.convertMeasure( nVal, rValue, SHRT_MIN, SHRT_MAX ) ) 788 rListLevel.SetSpaceBefore( nVal ); 789 break; 790 case XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_WIDTH: 791 if( rUnitConv.convertMeasure( nVal, rValue, 0, SHRT_MAX ) ) 792 rListLevel.SetMinLabelWidth( nVal ); 793 break; 794 case XML_TOK_STYLE_ATTRIBUTES_ATTR_MIN_LABEL_DIST: 795 if( rUnitConv.convertMeasure( nVal, rValue, 0, USHRT_MAX ) ) 796 rListLevel.SetMinLabelDist( nVal ); 797 break; 798 case XML_TOK_STYLE_ATTRIBUTES_ATTR_TEXT_ALIGN: 799 if( rValue.getLength() ) 800 { 801 sal_Int16 eAdjust = HoriOrientation::LEFT; 802 if( IsXMLToken( rValue, XML_CENTER ) ) 803 eAdjust = HoriOrientation::CENTER; 804 else if( IsXMLToken( rValue, XML_END ) ) 805 eAdjust = HoriOrientation::RIGHT; 806 rListLevel.SetAdjust( eAdjust ); 807 } 808 break; 809 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_NAME: 810 sFontName = rValue; 811 break; 812 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY: 813 sFontFamily = rValue; 814 break; 815 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_FAMILY_GENERIC: 816 sFontFamilyGeneric = rValue; 817 break; 818 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_STYLENAME: 819 sFontStyleName = rValue; 820 break; 821 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_PITCH: 822 sFontPitch = rValue; 823 break; 824 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_CHARSET: 825 sFontCharset = rValue; 826 break; 827 case XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_POS: 828 sVerticalPos = rValue; 829 break; 830 case XML_TOK_STYLE_ATTRIBUTES_ATTR_VERTICAL_REL: 831 sVerticalRel = rValue; 832 break; 833 case XML_TOK_STYLE_ATTRIBUTES_ATTR_WIDTH: 834 if( rUnitConv.convertMeasure( nVal, rValue, 0, SAL_MAX_INT32) ) 835 rListLevel.SetImageWidth( nVal ); 836 break; 837 case XML_TOK_STYLE_ATTRIBUTES_ATTR_HEIGHT: 838 if( rUnitConv.convertMeasure( nVal, rValue, 0, SAL_MAX_INT32) ) 839 rListLevel.SetImageHeight( nVal ); 840 break; 841 case XML_TOK_STYLE_ATTRIBUTES_ATTR_COLOR: 842 { 843 Color aColor; 844 if( SvXMLUnitConverter::convertColor( aColor, rValue ) ) 845 rListLevel.SetColor( (sal_Int32)aColor.GetColor() ); 846 } 847 break; 848 case XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR: 849 { 850 if( IsXMLToken( rValue, XML_TRUE ) ) 851 rListLevel.SetColor( (sal_Int32)0xffffffff ); 852 } 853 break; 854 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE: 855 if(SvXMLUnitConverter::convertPercent( nVal, rValue ) ) 856 rListLevel.SetRelSize( (sal_Int16)nVal ); 857 break; 858 // --> OD 2008-01-16 #newlistlevelattrs# 859 case XML_TOK_STYLE_ATTRIBUTES_ATTR_POSITION_AND_SPACE_MODE: 860 { 861 sal_Int16 ePosAndSpaceMode = PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION; 862 if( IsXMLToken( rValue, XML_LABEL_ALIGNMENT ) ) 863 ePosAndSpaceMode = PositionAndSpaceMode::LABEL_ALIGNMENT; 864 rListLevel.SetPosAndSpaceMode( ePosAndSpaceMode ); 865 } 866 break; 867 // <-- 868 } 869 } 870 871 if( sFontName.getLength() ) 872 { 873 const XMLFontStylesContext *pFontDecls = 874 GetImport().GetTextImport()->GetFontDecls(); 875 if( pFontDecls ) 876 { 877 ::std::vector < XMLPropertyState > aProps; 878 if( pFontDecls->FillProperties( sFontName, aProps, 0, 1, 2, 3, 4 ) ) 879 { 880 OUString sTmp; 881 sal_Int16 nTmp = 0; 882 ::std::vector< XMLPropertyState >::iterator i; 883 for( i = aProps.begin(); i != aProps.end(); i++ ) 884 { 885 switch( i->mnIndex ) 886 { 887 case 0: 888 i->maValue >>= sTmp; 889 rListLevel.SetBulletFontName( sTmp); 890 break; 891 case 1: 892 i->maValue >>= sTmp; 893 rListLevel.SetBulletFontStyleName( sTmp ); 894 break; 895 case 2: 896 i->maValue >>= nTmp; 897 rListLevel.SetBulletFontFamily( nTmp ); 898 break; 899 case 3: 900 i->maValue >>= nTmp; 901 rListLevel.SetBulletFontPitch( nTmp ); 902 break; 903 case 4: 904 i->maValue >>= nTmp; 905 rListLevel.SetBulletFontEncoding( nTmp ); 906 break; 907 } 908 } 909 } 910 } 911 } 912 if( sFontFamily.getLength() ) 913 { 914 String sEmpty; 915 Any aAny; 916 917 XMLFontFamilyNamePropHdl aFamilyNameHdl; 918 if( aFamilyNameHdl.importXML( sFontFamily, aAny, rUnitConv ) ) 919 { 920 OUString sTmp; 921 aAny >>= sTmp; 922 rListLevel.SetBulletFontName( sTmp); 923 } 924 925 XMLFontFamilyPropHdl aFamilyHdl; 926 if( sFontFamilyGeneric.getLength() && 927 aFamilyHdl.importXML( sFontFamilyGeneric, aAny, rUnitConv ) ) 928 { 929 sal_Int16 nTmp = 0; 930 aAny >>= nTmp; 931 rListLevel.SetBulletFontFamily( nTmp ); 932 } 933 934 if( sFontStyleName.getLength() ) 935 rListLevel.SetBulletFontStyleName( sFontStyleName ); 936 937 XMLFontPitchPropHdl aPitchHdl; 938 if( sFontPitch.getLength() && 939 aPitchHdl.importXML( sFontPitch, aAny, rUnitConv ) ) 940 { 941 sal_Int16 nTmp = 0; 942 aAny >>= nTmp; 943 rListLevel.SetBulletFontPitch( nTmp ); 944 } 945 946 XMLFontEncodingPropHdl aEncHdl; 947 if( sFontCharset.getLength() && 948 aEncHdl.importXML( sFontCharset, aAny, rUnitConv ) ) 949 { 950 sal_Int16 nTmp = 0; 951 aAny >>= nTmp; 952 rListLevel.SetBulletFontEncoding( nTmp ); 953 } 954 } 955 956 sal_Int16 eVertOrient = VertOrientation::LINE_CENTER; 957 if( sVerticalPos.getLength() ) 958 { 959 if( IsXMLToken( sVerticalPos, XML_TOP ) ) 960 eVertOrient = VertOrientation::LINE_TOP; 961 else if( IsXMLToken( sVerticalPos, XML_BOTTOM ) ) 962 eVertOrient = VertOrientation::LINE_BOTTOM; 963 } 964 if( sVerticalRel.getLength() ) 965 { 966 if( IsXMLToken( sVerticalRel, XML_BASELINE ) ) 967 { 968 // TOP and BOTTOM are exchanged for a baseline relation 969 switch( eVertOrient ) 970 { 971 case VertOrientation::LINE_TOP: 972 eVertOrient = VertOrientation::BOTTOM; 973 break; 974 case VertOrientation::LINE_CENTER: 975 eVertOrient = VertOrientation::CENTER; 976 break; 977 case VertOrientation::LINE_BOTTOM: 978 eVertOrient = VertOrientation::TOP; 979 break; 980 } 981 } 982 else if( IsXMLToken( sVerticalRel, XML_CHAR ) ) 983 { 984 switch( eVertOrient ) 985 { 986 case VertOrientation::LINE_TOP: 987 eVertOrient = VertOrientation::CHAR_TOP; 988 break; 989 case VertOrientation::LINE_CENTER: 990 eVertOrient = VertOrientation::CHAR_CENTER; 991 break; 992 case VertOrientation::LINE_BOTTOM: 993 eVertOrient = VertOrientation::CHAR_BOTTOM; 994 break; 995 } 996 } 997 } 998 rListLevel.SetImageVertOrient( eVertOrient ); 999 } 1000 1001 SvxXMLListLevelStyleAttrContext_Impl::~SvxXMLListLevelStyleAttrContext_Impl() 1002 { 1003 } 1004 1005 // --> OD 2008-01-16 #newlistlevelattrs# 1006 SvXMLImportContext* SvxXMLListLevelStyleAttrContext_Impl::CreateChildContext( 1007 sal_uInt16 nPrefix, const OUString& rLocalName, 1008 const Reference< xml::sax::XAttributeList > & xAttrList ) 1009 { 1010 SvXMLImportContext *pContext = 0; 1011 if ( XML_NAMESPACE_STYLE == nPrefix && 1012 IsXMLToken( rLocalName, XML_LIST_LEVEL_LABEL_ALIGNMENT ) ) 1013 { 1014 pContext = new SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl( GetImport(), 1015 nPrefix, 1016 rLocalName, 1017 xAttrList, 1018 rListLevel ); 1019 } 1020 if( !pContext ) 1021 { 1022 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); 1023 } 1024 1025 return pContext; 1026 } 1027 // <-- 1028 1029 // --------------------------------------------------------------------- 1030 1031 // --> OD 2008-01-16 #newlistlevelattrs# 1032 enum SvxXMLStyleAttributesLabelAlignmentAttrTokens 1033 { 1034 XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY, 1035 XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION, 1036 XML_TOK_STYLE_ATTRIBUTES_ATTR_FIRST_LINE_INDENT, 1037 XML_TOK_STYLE_ATTRIBUTES_ATTR_INDENT_AT, 1038 1039 XML_TOK_STYLE_ATTRIBUTES_LABEL_ALIGNMENT_ATTR_END=XML_TOK_UNKNOWN 1040 }; 1041 const SvXMLTokenMapEntry* lcl_getStyleAlignmentAttributesAttrTokenMap() 1042 { 1043 static __FAR_DATA SvXMLTokenMapEntry aStyleAlignmentAttributesAttrTokenMap[] = 1044 { 1045 { XML_NAMESPACE_TEXT, XML_LABEL_FOLLOWED_BY, 1046 XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY }, 1047 { XML_NAMESPACE_TEXT, XML_LIST_TAB_STOP_POSITION, 1048 XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION }, 1049 { XML_NAMESPACE_FO, XML_TEXT_INDENT, 1050 XML_TOK_STYLE_ATTRIBUTES_ATTR_FIRST_LINE_INDENT }, 1051 { XML_NAMESPACE_FO, XML_MARGIN_LEFT, 1052 XML_TOK_STYLE_ATTRIBUTES_ATTR_INDENT_AT }, 1053 1054 XML_TOKEN_MAP_END 1055 }; 1056 return aStyleAlignmentAttributesAttrTokenMap; 1057 } 1058 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl( 1059 SvXMLImport& rImport, sal_uInt16 nPrfx, 1060 const OUString& rLName, 1061 const Reference< xml::sax::XAttributeList > & xAttrList, 1062 SvxXMLListLevelStyleContext_Impl& rLLevel ) : 1063 SvXMLImportContext( rImport, nPrfx, rLName ), 1064 rListLevel( rLLevel ) 1065 { 1066 SvXMLTokenMap aTokenMap( lcl_getStyleAlignmentAttributesAttrTokenMap() ); 1067 SvXMLUnitConverter& rUnitConv = GetImport().GetMM100UnitConverter(); 1068 1069 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 1070 for( sal_Int16 i=0; i < nAttrCount; i++ ) 1071 { 1072 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 1073 OUString aLocalName; 1074 sal_uInt16 nPrefix = 1075 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 1076 &aLocalName ); 1077 const OUString& rValue = xAttrList->getValueByIndex( i ); 1078 1079 sal_Int32 nVal; 1080 switch( aTokenMap.Get( nPrefix, aLocalName ) ) 1081 { 1082 case XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY: 1083 { 1084 sal_Int16 eLabelFollowedBy = LabelFollow::LISTTAB; 1085 if( IsXMLToken( rValue, XML_SPACE ) ) 1086 eLabelFollowedBy = LabelFollow::SPACE; 1087 else if( IsXMLToken( rValue, XML_NOTHING ) ) 1088 eLabelFollowedBy = LabelFollow::NOTHING; 1089 rListLevel.SetLabelFollowedBy( eLabelFollowedBy ); 1090 } 1091 break; 1092 case XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION: 1093 if( rUnitConv.convertMeasure( nVal, rValue, 0, SHRT_MAX ) ) 1094 rListLevel.SetListtabStopPosition( nVal ); 1095 break; 1096 case XML_TOK_STYLE_ATTRIBUTES_ATTR_FIRST_LINE_INDENT: 1097 if( rUnitConv.convertMeasure( nVal, rValue, SHRT_MIN, SHRT_MAX ) ) 1098 rListLevel.SetFirstLineIndent( nVal ); 1099 break; 1100 case XML_TOK_STYLE_ATTRIBUTES_ATTR_INDENT_AT: 1101 if( rUnitConv.convertMeasure( nVal, rValue, SHRT_MIN, SHRT_MAX ) ) 1102 rListLevel.SetIndentAt( nVal ); 1103 break; 1104 } 1105 } 1106 } 1107 1108 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::~SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl() 1109 { 1110 } 1111 // <-- 1112 1113 // --------------------------------------------------------------------- 1114 1115 typedef SvxXMLListLevelStyleContext_Impl *SvxXMLListLevelStyleContext_ImplPtr; 1116 SV_DECL_PTRARR( SvxXMLListStyle_Impl, SvxXMLListLevelStyleContext_ImplPtr, 1117 10, 5 ) 1118 1119 void SvxXMLListStyleContext::SetAttribute( sal_uInt16 nPrefixKey, 1120 const OUString& rLocalName, 1121 const OUString& rValue ) 1122 { 1123 if( XML_NAMESPACE_TEXT == nPrefixKey && 1124 IsXMLToken( rLocalName, XML_CONSECUTIVE_NUMBERING ) ) 1125 { 1126 bConsecutive = IsXMLToken( rValue, XML_TRUE ); 1127 } 1128 else 1129 { 1130 SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue ); 1131 } 1132 } 1133 1134 1135 SvxXMLListStyleContext::SvxXMLListStyleContext( SvXMLImport& rImport, 1136 sal_uInt16 nPrfx, 1137 const OUString& rLName, 1138 const Reference< xml::sax::XAttributeList > & xAttrList, 1139 sal_Bool bOutl ) 1140 : SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList, bOutl ? XML_STYLE_FAMILY_TEXT_OUTLINE : XML_STYLE_FAMILY_TEXT_LIST ) 1141 , sIsPhysical( RTL_CONSTASCII_USTRINGPARAM( "IsPhysical" ) ) 1142 , sNumberingRules( RTL_CONSTASCII_USTRINGPARAM( "NumberingRules" ) ) 1143 , sName( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) 1144 , sIsContinuousNumbering( RTL_CONSTASCII_USTRINGPARAM( "IsContinuousNumbering" ) ) 1145 , pLevelStyles( 0 ) 1146 , nLevels( 0 ) 1147 , bConsecutive( sal_False ) 1148 , bOutline( bOutl ) 1149 { 1150 } 1151 1152 SvxXMLListStyleContext::~SvxXMLListStyleContext() 1153 { 1154 if( pLevelStyles ) 1155 { 1156 while( pLevelStyles->Count() ) 1157 { 1158 sal_uInt16 n = pLevelStyles->Count() - 1; 1159 SvxXMLListLevelStyleContext_Impl *pStyle = (*pLevelStyles)[n]; 1160 pLevelStyles->Remove( n, 1 ); 1161 pStyle->ReleaseRef(); 1162 } 1163 } 1164 1165 delete pLevelStyles; 1166 } 1167 1168 TYPEINIT1( SvxXMLListStyleContext, SvXMLStyleContext ); 1169 1170 SvXMLImportContext *SvxXMLListStyleContext::CreateChildContext( 1171 sal_uInt16 nPrefix, 1172 const OUString& rLocalName, 1173 const Reference< xml::sax::XAttributeList > & xAttrList ) 1174 { 1175 SvXMLImportContext *pContext = 0; 1176 1177 if( XML_NAMESPACE_TEXT == nPrefix && 1178 ( bOutline 1179 ? IsXMLToken( rLocalName, XML_OUTLINE_LEVEL_STYLE ) 1180 : ( IsXMLToken( rLocalName, XML_LIST_LEVEL_STYLE_NUMBER ) || 1181 IsXMLToken( rLocalName, XML_LIST_LEVEL_STYLE_BULLET ) || 1182 IsXMLToken( rLocalName, XML_LIST_LEVEL_STYLE_IMAGE ) ) ) ) 1183 { 1184 SvxXMLListLevelStyleContext_Impl *pLevelStyle = 1185 new SvxXMLListLevelStyleContext_Impl( GetImport(), nPrefix, 1186 rLocalName, xAttrList ); 1187 if( !pLevelStyles ) 1188 pLevelStyles = new SvxXMLListStyle_Impl; 1189 pLevelStyles->Insert( pLevelStyle, pLevelStyles->Count() ); 1190 pLevelStyle->AddRef(); 1191 1192 pContext = pLevelStyle; 1193 } 1194 else 1195 { 1196 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); 1197 } 1198 1199 return pContext; 1200 } 1201 1202 void SvxXMLListStyleContext::FillUnoNumRule( 1203 const Reference< container::XIndexReplace > & rNumRule, 1204 const SvI18NMap *pI18NMap ) const 1205 { 1206 try 1207 { 1208 if( pLevelStyles && rNumRule.is() ) 1209 { 1210 sal_uInt16 nCount = pLevelStyles->Count(); 1211 sal_Int32 l_nLevels = rNumRule->getCount(); 1212 for( sal_uInt16 i=0; i < nCount; i++ ) 1213 { 1214 SvxXMLListLevelStyleContext_Impl *pLevelStyle = 1215 (*pLevelStyles)[i]; 1216 sal_Int32 nLevel = pLevelStyle->GetLevel(); 1217 if( nLevel >= 0 && nLevel < l_nLevels ) 1218 { 1219 Sequence<beans::PropertyValue> aProps = 1220 pLevelStyle->GetProperties( pI18NMap ); 1221 Any aAny; 1222 aAny <<= aProps; 1223 rNumRule->replaceByIndex( nLevel, aAny ); 1224 } 1225 } 1226 } 1227 1228 Reference < XPropertySet > xPropSet( rNumRule, UNO_QUERY ); 1229 Reference< XPropertySetInfo > xPropSetInfo; 1230 if (xPropSet.is()) 1231 xPropSetInfo = xPropSet->getPropertySetInfo(); 1232 if( xPropSetInfo.is() && 1233 xPropSetInfo->hasPropertyByName( sIsContinuousNumbering ) ) 1234 { 1235 Any aAny; 1236 sal_Bool bTmp = bConsecutive; 1237 aAny.setValue( &bTmp, ::getBooleanCppuType() ); 1238 xPropSet->setPropertyValue( sIsContinuousNumbering, aAny ); 1239 } 1240 } 1241 catch( Exception& ) 1242 { 1243 DBG_ERROR( "SvxXMLListStyleContext::FillUnoNumRule - Exception catched" ); 1244 } 1245 } 1246 1247 void SvxXMLListStyleContext::CreateAndInsertLate( sal_Bool bOverwrite ) 1248 { 1249 if( bOutline ) 1250 { 1251 if( bOverwrite ) 1252 { 1253 const Reference< XIndexReplace >& rNumRule = 1254 GetImport().GetTextImport()->GetChapterNumbering(); 1255 // We don't set xNumberingRules here, to avoid using them 1256 // as numbering rules. 1257 if( rNumRule.is() ) 1258 FillUnoNumRule( rNumRule, 0 ); 1259 } 1260 } 1261 else 1262 { 1263 Reference < XStyle > xStyle; 1264 const OUString& rName = GetDisplayName(); 1265 if( 0 == rName.getLength() ) 1266 { 1267 SetValid( sal_False ); 1268 return; 1269 } 1270 1271 const Reference < XNameContainer >& rNumStyles = 1272 GetImport().GetTextImport()->GetNumberingStyles(); 1273 if( !rNumStyles.is() ) 1274 { 1275 SetValid( sal_False ); 1276 return; 1277 } 1278 1279 sal_Bool bNew = sal_False; 1280 if( rNumStyles->hasByName( rName ) ) 1281 { 1282 Any aAny = rNumStyles->getByName( rName ); 1283 aAny >>= xStyle; 1284 } 1285 else 1286 { 1287 Reference< XMultiServiceFactory > xFactory( GetImport().GetModel(), 1288 UNO_QUERY ); 1289 DBG_ASSERT( xFactory.is(), "no factory" ); 1290 if( !xFactory.is() ) 1291 return; 1292 1293 Reference < XInterface > xIfc = xFactory->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.NumberingStyle")) ); 1294 if( !xIfc.is() ) 1295 return; 1296 Reference < XStyle > xTmp( xIfc, UNO_QUERY ); 1297 xStyle = xTmp; 1298 if( !xStyle.is() ) 1299 return; 1300 1301 Any aAny; 1302 aAny <<= xStyle; 1303 rNumStyles->insertByName( rName, aAny ); 1304 bNew = sal_True; 1305 } 1306 1307 Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY ); 1308 Reference< XPropertySetInfo > xPropSetInfo = 1309 xPropSet->getPropertySetInfo(); 1310 if( !bNew && xPropSetInfo->hasPropertyByName( sIsPhysical ) ) 1311 { 1312 Any aAny = xPropSet->getPropertyValue( sIsPhysical ); 1313 bNew = !*(sal_Bool *)aAny.getValue(); 1314 } 1315 if( rName != GetName() ) 1316 GetImport().AddStyleDisplayName( XML_STYLE_FAMILY_TEXT_LIST, 1317 GetName(), rName ); 1318 1319 Any aAny = xPropSet->getPropertyValue( sNumberingRules ); 1320 aAny >>= xNumRules; 1321 nLevels = xNumRules->getCount(); 1322 if( bOverwrite || bNew ) 1323 { 1324 FillUnoNumRule( xNumRules, 0 ); 1325 aAny <<= xNumRules; 1326 xPropSet->setPropertyValue( sNumberingRules, aAny ); 1327 } 1328 else 1329 { 1330 SetValid( sal_False ); 1331 } 1332 1333 SetNew( bNew ); 1334 } 1335 } 1336 1337 void SvxXMLListStyleContext::CreateAndInsertAuto() const 1338 { 1339 DBG_ASSERT( !bOutline, "Outlines cannot be inserted here" ); 1340 DBG_ASSERT( !xNumRules.is(), "Numbering Rule is existing already" ); 1341 1342 const OUString& rName = GetName(); 1343 if( bOutline || xNumRules.is() || 0 == rName.getLength() ) 1344 { 1345 ((SvxXMLListStyleContext *)this)->SetValid( sal_False ); 1346 return; 1347 } 1348 1349 ((SvxXMLListStyleContext *)this)->xNumRules = CreateNumRule( 1350 GetImport().GetModel() ); 1351 ((SvxXMLListStyleContext *)this)->nLevels = xNumRules->getCount(); 1352 1353 FillUnoNumRule( xNumRules, 0 ); 1354 } 1355 1356 Reference < XIndexReplace > SvxXMLListStyleContext::CreateNumRule( 1357 const Reference < XModel > & rModel ) 1358 { 1359 Reference<XIndexReplace> xNumRule; 1360 1361 Reference< XMultiServiceFactory > xFactory( rModel, UNO_QUERY ); 1362 DBG_ASSERT( xFactory.is(), "no factory" ); 1363 if( !xFactory.is() ) 1364 return xNumRule; 1365 1366 Reference < XInterface > xIfc = xFactory->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.NumberingRules")) ); 1367 if( !xIfc.is() ) 1368 return xNumRule; 1369 1370 xNumRule = Reference<XIndexReplace>( xIfc, UNO_QUERY ); 1371 DBG_ASSERT( xNumRule.is(), "go no numbering rule" ); 1372 1373 return xNumRule; 1374 } 1375 1376 void SvxXMLListStyleContext::SetDefaultStyle( 1377 const Reference < XIndexReplace > & rNumRule, 1378 sal_Int16 nLevel, 1379 sal_Bool bOrdered ) 1380 { 1381 Sequence<beans::PropertyValue> aPropSeq( bOrdered ? 1 : 4 ); 1382 beans::PropertyValue *pProps = aPropSeq.getArray(); 1383 1384 pProps->Name = 1385 OUString::createFromAscii( XML_UNO_NAME_NRULE_NUMBERINGTYPE ); 1386 (pProps++)->Value <<= (sal_Int16)(bOrdered ? NumberingType::ARABIC 1387 : NumberingType::CHAR_SPECIAL ); 1388 if( !bOrdered ) 1389 { 1390 // TODO: Bullet-Font 1391 //aNumFmt.SetBulletFont( &SwNumRule::GetDefBulletFont() ); 1392 awt::FontDescriptor aFDesc; 1393 aFDesc.Name = OUString( 1394 #if defined UNX 1395 RTL_CONSTASCII_USTRINGPARAM( "starbats" ) 1396 #else 1397 RTL_CONSTASCII_USTRINGPARAM( "StarBats" ) 1398 #endif 1399 ); 1400 aFDesc.Family = FAMILY_DONTKNOW ; 1401 aFDesc.Pitch = PITCH_DONTKNOW ; 1402 aFDesc.CharSet = RTL_TEXTENCODING_SYMBOL ; 1403 aFDesc.Weight = WEIGHT_DONTKNOW; 1404 //aFDesc.Transparant = sal_True; 1405 pProps->Name = 1406 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_FONT ); 1407 (pProps++)->Value <<= aFDesc; 1408 1409 OUStringBuffer sTmp(1); 1410 sTmp.append( (sal_Unicode)(0xF000 + 149) ); 1411 pProps->Name = 1412 OUString::createFromAscii( XML_UNO_NAME_NRULE_BULLET_CHAR ); 1413 (pProps++)->Value <<= sTmp.makeStringAndClear(); 1414 pProps->Name = 1415 OUString::createFromAscii( XML_UNO_NAME_NRULE_CHAR_STYLE_NAME ); 1416 (pProps++)->Value <<= 1417 OUString( RTL_CONSTASCII_USTRINGPARAM( "Numbering Symbols" ) ); 1418 } 1419 1420 Any aAny; 1421 aAny <<= aPropSeq; 1422 rNumRule->replaceByIndex( nLevel, aAny ); 1423 } 1424 1425