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