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_editeng.hxx" 26 27 #define PROPERTY_NONE 0 28 29 #include <com/sun/star/text/HoriOrientation.hpp> 30 #include <com/sun/star/awt/XBitmap.hpp> 31 32 #include <vcl/svapp.hxx> 33 #include <vos/mutex.hxx> 34 #include <vcl/graph.hxx> 35 #include <svtools/grfmgr.hxx> 36 #include <toolkit/unohlp.hxx> 37 #include <rtl/uuid.h> 38 #include <rtl/memory.h> 39 40 #include <editeng/brshitem.hxx> 41 #include <editeng/unoprnms.hxx> 42 #include <editeng/numitem.hxx> 43 #include <editeng/eeitem.hxx> 44 #include <editeng/unotext.hxx> 45 #include <editeng/numitem.hxx> 46 #include <editeng/unofdesc.hxx> 47 #include <editeng/unonrule.hxx> 48 #include <editeng/editids.hrc> 49 50 using ::rtl::OUString; 51 using ::com::sun::star::util::XCloneable; 52 using ::com::sun::star::ucb::XAnyCompare; 53 54 55 using namespace ::vos; 56 using namespace ::std; 57 using namespace ::com::sun::star; 58 using namespace ::com::sun::star::uno; 59 using namespace ::com::sun::star::lang; 60 using namespace ::com::sun::star::container; 61 62 const SvxAdjust aUnoToSvxAdjust[] = 63 { 64 SVX_ADJUST_LEFT, 65 SVX_ADJUST_RIGHT, 66 SVX_ADJUST_CENTER, 67 SVX_ADJUST_LEFT, 68 SVX_ADJUST_LEFT, 69 SVX_ADJUST_LEFT, 70 SVX_ADJUST_BLOCK 71 }; 72 73 const unsigned short aSvxToUnoAdjust[] = 74 { 75 text::HoriOrientation::LEFT, 76 text::HoriOrientation::RIGHT, 77 text::HoriOrientation::FULL, 78 text::HoriOrientation::CENTER, 79 text::HoriOrientation::FULL, 80 text::HoriOrientation::LEFT 81 }; 82 83 SvxAdjust ConvertUnoAdjust( unsigned short nAdjust ) 84 { 85 DBG_ASSERT( nAdjust <= 7, "Enum hat sich geaendert! [CL]" ); 86 return aUnoToSvxAdjust[nAdjust]; 87 } 88 89 unsigned short ConvertUnoAdjust( SvxAdjust eAdjust ) 90 { 91 DBG_ASSERT( eAdjust <= 6, "Enum hat sich geaendert! [CL]" ); 92 return aSvxToUnoAdjust[eAdjust]; 93 } 94 95 /****************************************************************** 96 * SvxUnoNumberingRules 97 ******************************************************************/ 98 99 UNO3_GETIMPLEMENTATION_IMPL( SvxUnoNumberingRules ); 100 101 SvxUnoNumberingRules::SvxUnoNumberingRules( const SvxNumRule& rRule ) throw() 102 : maRule( rRule ) 103 { 104 } 105 106 SvxUnoNumberingRules::~SvxUnoNumberingRules() throw() 107 { 108 } 109 110 //XIndexReplace 111 void SAL_CALL SvxUnoNumberingRules::replaceByIndex( sal_Int32 Index, const uno::Any& Element ) 112 throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) 113 { 114 OGuard aGuard( Application::GetSolarMutex() ); 115 116 if( Index < 0 || Index >= maRule.GetLevelCount() ) 117 throw IndexOutOfBoundsException(); 118 119 Sequence< beans::PropertyValue > aSeq; 120 121 if( !( Element >>= aSeq) ) 122 throw IllegalArgumentException(); 123 setNumberingRuleByIndex( aSeq, Index ); 124 } 125 126 // XIndexAccess 127 sal_Int32 SAL_CALL SvxUnoNumberingRules::getCount() throw( RuntimeException ) 128 { 129 OGuard aGuard( Application::GetSolarMutex() ); 130 131 return maRule.GetLevelCount(); 132 } 133 134 Any SAL_CALL SvxUnoNumberingRules::getByIndex( sal_Int32 Index ) 135 throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) 136 { 137 OGuard aGuard( Application::GetSolarMutex() ); 138 139 if( Index < 0 || Index >= maRule.GetLevelCount() ) 140 throw IndexOutOfBoundsException(); 141 142 return Any( getNumberingRuleByIndex(Index) ); 143 } 144 145 //XElementAccess 146 Type SAL_CALL SvxUnoNumberingRules::getElementType() 147 throw( RuntimeException ) 148 { 149 return ::getCppuType(( const Sequence< beans::PropertyValue >*)0); 150 } 151 152 sal_Bool SAL_CALL SvxUnoNumberingRules::hasElements() throw( RuntimeException ) 153 { 154 return sal_True; 155 } 156 157 // XAnyCompare 158 sal_Int16 SAL_CALL SvxUnoNumberingRules::compare( const Any& rAny1, const Any& rAny2 ) throw(RuntimeException) 159 { 160 return SvxUnoNumberingRules::Compare( rAny1, rAny2 ); 161 } 162 163 // XCloneable 164 Reference< XCloneable > SAL_CALL SvxUnoNumberingRules::createClone( ) throw (RuntimeException) 165 { 166 return new SvxUnoNumberingRules(maRule); 167 } 168 169 // XServiceInfo 170 sal_Char pSvxUnoNumberingRulesService[sizeof("com.sun.star.text.NumberingRules")] = "com.sun.star.text.NumberingRules"; 171 172 OUString SAL_CALL SvxUnoNumberingRules::getImplementationName( ) throw(RuntimeException) 173 { 174 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoNumberingRules" ) ); 175 } 176 177 sal_Bool SAL_CALL SvxUnoNumberingRules::supportsService( const OUString& ServiceName ) throw(RuntimeException) 178 { 179 return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSvxUnoNumberingRulesService ) ); 180 } 181 182 Sequence< OUString > SAL_CALL SvxUnoNumberingRules::getSupportedServiceNames( ) throw(RuntimeException) 183 { 184 OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSvxUnoNumberingRulesService ) ); 185 Sequence< OUString > aSeq( &aService, 1 ); 186 return aSeq; 187 } 188 189 Sequence<beans::PropertyValue> SvxUnoNumberingRules::getNumberingRuleByIndex( sal_Int32 nIndex) const throw() 190 { 191 // NumberingRule aRule; 192 const SvxNumberFormat& rFmt = maRule.GetLevel((sal_uInt16) nIndex); 193 sal_uInt16 nIdx = 0; 194 195 const int nProps = 15; 196 beans::PropertyValue* pArray = new beans::PropertyValue[nProps]; 197 198 Any aVal; 199 { 200 aVal <<= rFmt.GetNumberingType(); 201 beans::PropertyValue aAlignProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_NUMBERINGTYPE)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 202 pArray[nIdx++] = aAlignProp; 203 } 204 205 { 206 SvxAdjust eAdj = rFmt.GetNumAdjust(); 207 aVal <<= ConvertUnoAdjust(eAdj); 208 pArray[nIdx++] = beans::PropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_ADJUST)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 209 } 210 211 { 212 aVal <<= OUString(rFmt.GetPrefix()); 213 beans::PropertyValue aPrefixProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_PREFIX)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 214 pArray[nIdx++] = aPrefixProp; 215 } 216 217 { 218 aVal <<= OUString(rFmt.GetSuffix()); 219 beans::PropertyValue aSuffixProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_SUFFIX)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 220 pArray[nIdx++] = aSuffixProp; 221 } 222 223 { 224 //IAccessibility2 Implementation 2009----- 225 if(SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType()) 226 //-----IAccessibility2 Implementation 2009 227 { 228 sal_Unicode nCode = rFmt.GetBulletChar(); 229 OUString aStr( &nCode, 1 ); 230 aVal <<= aStr; 231 beans::PropertyValue aBulletProp( OUString(RTL_CONSTASCII_USTRINGPARAM("BulletChar")), -1, aVal, beans::PropertyState_DIRECT_VALUE); 232 pArray[nIdx++] = aBulletProp; 233 } 234 } 235 236 if( rFmt.GetBulletFont() ) 237 { 238 awt::FontDescriptor aDesc; 239 SvxUnoFontDescriptor::ConvertFromFont( *rFmt.GetBulletFont(), aDesc ); 240 aVal.setValue(&aDesc, ::getCppuType((const awt::FontDescriptor*)0)); 241 pArray[nIdx++] = beans::PropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_FONT)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 242 } 243 244 { 245 const SvxBrushItem* pBrush = rFmt.GetBrush(); 246 if(pBrush && pBrush->GetGraphicObject()) 247 { 248 const GraphicObject* pGrafObj = pBrush->GetGraphicObject(); 249 OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX)); 250 aURL += OUString::createFromAscii( pGrafObj->GetUniqueID().GetBuffer() ); 251 252 aVal <<= aURL; 253 const beans::PropertyValue aGraphicProp( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")), -1, aVal, beans::PropertyState_DIRECT_VALUE); 254 pArray[nIdx++] = aGraphicProp; 255 } 256 } 257 258 { 259 const Size aSize( rFmt.GetGraphicSize() ); 260 const awt::Size aUnoSize( aSize.Width(), aSize.Height() ); 261 aVal <<= aUnoSize; 262 const beans::PropertyValue aGraphicSizeProp(OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicSize")), -1, aVal, beans::PropertyState_DIRECT_VALUE ); 263 pArray[nIdx++] = aGraphicSizeProp; 264 } 265 266 aVal <<= (sal_Int16)rFmt.GetStart(); 267 pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_START_WITH)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 268 269 aVal <<= (sal_Int32)rFmt.GetAbsLSpace(); 270 pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_LEFT_MARGIN)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 271 272 aVal <<= (sal_Int32)rFmt.GetFirstLineOffset(); 273 pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_FIRST_LINE_OFFSET)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 274 275 pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolTextDistance")), -1, aVal, beans::PropertyState_DIRECT_VALUE); 276 277 aVal <<= (sal_Int32)rFmt.GetBulletColor().GetColor(); 278 pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_COLOR)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 279 280 aVal <<= (sal_Int16)rFmt.GetBulletRelSize(); 281 pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_RELSIZE)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 282 283 DBG_ASSERT( nIdx <= nProps, "FixMe: Array uebergelaufen!!!! [CL]" ); 284 Sequence< beans::PropertyValue> aSeq(pArray, nIdx); 285 286 delete [] pArray; 287 return aSeq; 288 } 289 290 void SvxUnoNumberingRules::setNumberingRuleByIndex( const Sequence< beans::PropertyValue >& rProperties, sal_Int32 nIndex) 291 throw( RuntimeException, IllegalArgumentException ) 292 { 293 SvxNumberFormat aFmt(maRule.GetLevel( (sal_uInt16)nIndex )); 294 const beans::PropertyValue* pPropArray = rProperties.getConstArray(); 295 for(int i = 0; i < rProperties.getLength(); i++) 296 { 297 const beans::PropertyValue& rProp = pPropArray[i]; 298 const OUString& rPropName = rProp.Name; 299 const Any& aVal = rProp.Value; 300 301 if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_NUMBERINGTYPE))) 302 { 303 sal_Int16 nSet = sal_Int16(); 304 aVal >>= nSet; 305 306 // There is no reason to limit numbering types. 307 if ( nSet>=0 ) 308 { 309 aFmt.SetNumberingType(nSet); 310 continue; 311 } 312 } 313 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_PREFIX))) 314 { 315 OUString aPrefix; 316 if( aVal >>= aPrefix ) 317 { 318 aFmt.SetPrefix(aPrefix); 319 continue; 320 } 321 } 322 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_SUFFIX))) 323 { 324 OUString aSuffix; 325 if( aVal >>= aSuffix ) 326 { 327 aFmt.SetSuffix(aSuffix); 328 continue; 329 } 330 } 331 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLETID))) 332 { 333 sal_Int16 nSet = sal_Int16(); 334 if( aVal >>= nSet ) 335 { 336 if(nSet < 0x100) 337 { 338 aFmt.SetBulletChar(nSet); 339 continue; 340 } 341 } 342 } 343 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("BulletChar"))) 344 { 345 OUString aStr; 346 if( aVal >>= aStr ) 347 { 348 if(aStr.getLength()) 349 { 350 aFmt.SetBulletChar(aStr[0]); 351 } 352 else 353 { 354 aFmt.SetBulletChar(0); 355 } 356 continue; 357 } 358 } 359 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_ADJUST))) 360 { 361 sal_Int16 nAdjust = sal_Int16(); 362 if( aVal >>= nAdjust ) 363 { 364 aFmt.SetNumAdjust(ConvertUnoAdjust( (unsigned short)nAdjust )); 365 continue; 366 } 367 } 368 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_FONT))) 369 { 370 awt::FontDescriptor aDesc; 371 if( aVal >>= aDesc ) 372 { 373 Font aFont; 374 SvxUnoFontDescriptor::ConvertToFont( aDesc, aFont ); 375 aFmt.SetBulletFont(&aFont); 376 continue; 377 } 378 } 379 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Graphic"))) 380 { 381 Reference< awt::XBitmap > xBmp; 382 if( aVal >>= xBmp ) 383 { 384 Graphic aGraf( VCLUnoHelper::GetBitmap( xBmp ) ); 385 SvxBrushItem aBrushItem(aGraf, GPOS_AREA, SID_ATTR_BRUSH); 386 aFmt.SetGraphicBrush( &aBrushItem ); 387 continue; 388 } 389 } 390 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("GraphicURL"))) 391 { 392 OUString aURL; 393 if( aVal >>= aURL ) 394 { 395 GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) ); 396 SvxBrushItem aBrushItem( aGrafObj, GPOS_AREA, SID_ATTR_BRUSH ); 397 aFmt.SetGraphicBrush( &aBrushItem ); 398 continue; 399 } 400 } 401 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("GraphicSize"))) 402 { 403 awt::Size aUnoSize; 404 if( aVal >>= aUnoSize ) 405 { 406 aFmt.SetGraphicSize( Size( aUnoSize.Width, aUnoSize.Height ) ); 407 continue; 408 } 409 } 410 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_START_WITH))) 411 { 412 sal_Int16 nStart = sal_Int16(); 413 if( aVal >>= nStart ) 414 { 415 aFmt.SetStart( nStart ); 416 continue; 417 } 418 } 419 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_LEFT_MARGIN))) 420 { 421 sal_Int32 nMargin = 0; 422 if( aVal >>= nMargin ) 423 { 424 aFmt.SetAbsLSpace((sal_uInt16)nMargin); 425 continue; 426 } 427 } 428 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_FIRST_LINE_OFFSET))) 429 { 430 sal_Int32 nMargin = 0; 431 if( aVal >>= nMargin ) 432 { 433 aFmt.SetFirstLineOffset((sal_uInt16)nMargin); 434 continue; 435 } 436 } 437 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("SymbolTextDistance"))) 438 { 439 sal_Int32 nTextDistance = 0; 440 if( aVal >>= nTextDistance ) 441 { 442 aFmt.SetCharTextDistance((sal_uInt16)nTextDistance); 443 continue; 444 } 445 } 446 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_COLOR))) 447 { 448 sal_Int32 nColor = 0; 449 if( aVal >>= nColor ) 450 { 451 aFmt.SetBulletColor( (Color) nColor ); 452 continue; 453 } 454 } 455 else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_RELSIZE))) 456 { 457 sal_Int16 nSize = sal_Int16(); 458 if( aVal >>= nSize ) 459 { 460 // [Bug 120650] the slide content corrupt when open in Aoo 461 if ((nSize>250)||(nSize<=0)) 462 { 463 nSize = 100; 464 } 465 466 aFmt.SetBulletRelSize( (short)nSize ); 467 continue; 468 } 469 } 470 else 471 { 472 continue; 473 } 474 475 throw IllegalArgumentException(); 476 } 477 478 // check that we always have a brush item for bitmap numbering 479 if( aFmt.GetNumberingType() == SVX_NUM_BITMAP ) 480 { 481 if( NULL == aFmt.GetBrush() ) 482 { 483 GraphicObject aGrafObj; 484 SvxBrushItem aBrushItem( aGrafObj, GPOS_AREA, SID_ATTR_BRUSH ); 485 aFmt.SetGraphicBrush( &aBrushItem ); 486 } 487 } 488 maRule.SetLevel( (sal_uInt16)nIndex, aFmt ); 489 } 490 491 /////////////////////////////////////////////////////////////////////// 492 493 const SvxNumRule& SvxGetNumRule( Reference< XIndexReplace > xRule ) throw( IllegalArgumentException ) 494 { 495 SvxUnoNumberingRules* pRule = SvxUnoNumberingRules::getImplementation( xRule ); 496 if( pRule == NULL ) 497 throw IllegalArgumentException(); 498 499 return pRule->getNumRule(); 500 } 501 502 bool SvxGetNumRule( Reference< XIndexReplace > xRule, SvxNumRule& rNumRule ) 503 { 504 SvxUnoNumberingRules* pRule = SvxUnoNumberingRules::getImplementation( xRule ); 505 if( pRule ) 506 { 507 rNumRule = pRule->getNumRule(); 508 } 509 else if( xRule.is() ) 510 { 511 try 512 { 513 pRule = new SvxUnoNumberingRules( rNumRule ); 514 515 Reference< XIndexReplace > xDestRule( pRule ); 516 517 const sal_Int32 nCount = min( xRule->getCount(), xDestRule->getCount() ); 518 sal_Int32 nLevel; 519 for( nLevel = 0; nLevel < nCount; nLevel++ ) 520 { 521 xDestRule->replaceByIndex( nLevel, xRule->getByIndex( nLevel ) ); 522 } 523 524 rNumRule = pRule->getNumRule(); 525 } 526 catch( Exception& ) 527 { 528 return false; 529 } 530 } 531 else 532 { 533 return false; 534 } 535 536 return true; 537 } 538 539 /////////////////////////////////////////////////////////////////////// 540 com::sun::star::uno::Reference< com::sun::star::container::XIndexReplace > SvxCreateNumRule( const SvxNumRule* pRule ) throw() 541 { 542 DBG_ASSERT( pRule, "No default SvxNumRule!" ); 543 if( pRule ) 544 { 545 return new SvxUnoNumberingRules( *pRule ); 546 } 547 else 548 { 549 SvxNumRule aDefaultRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE, 10 , sal_False); 550 return new SvxUnoNumberingRules( aDefaultRule ); 551 } 552 } 553 554 555 /////////////////////////////////////////////////////////////////////// 556 557 class SvxUnoNumberingRulesCompare : public ::cppu::WeakAggImplHelper1< XAnyCompare > 558 { 559 public: 560 virtual sal_Int16 SAL_CALL compare( const Any& Any1, const Any& Any2 ) throw(RuntimeException); 561 }; 562 563 sal_Int16 SAL_CALL SvxUnoNumberingRulesCompare::compare( const Any& Any1, const Any& Any2 ) throw(RuntimeException) 564 { 565 return SvxUnoNumberingRules::Compare( Any1, Any2 ); 566 } 567 568 sal_Int16 SvxUnoNumberingRules::Compare( const Any& Any1, const Any& Any2 ) 569 { 570 Reference< XIndexReplace > x1( Any1, UNO_QUERY ), x2( Any2, UNO_QUERY ); 571 if( x1.is() && x2.is() ) 572 { 573 if( x1.get() == x2.get() ) 574 return 0; 575 576 SvxUnoNumberingRules* pRule1 = SvxUnoNumberingRules::getImplementation( x1 ); 577 if( pRule1 ) 578 { 579 SvxUnoNumberingRules* pRule2 = SvxUnoNumberingRules::getImplementation( x2 ); 580 if( pRule2 ) 581 { 582 const SvxNumRule& rRule1 = pRule1->getNumRule(); 583 const SvxNumRule& rRule2 = pRule2->getNumRule(); 584 585 const sal_uInt16 nLevelCount1 = rRule1.GetLevelCount(); 586 const sal_uInt16 nLevelCount2 = rRule2.GetLevelCount(); 587 588 if( nLevelCount1 == 0 || nLevelCount2 == 0 ) 589 return -1; 590 591 for( sal_uInt16 i = 0; (i < nLevelCount1) && (i < nLevelCount2); i++ ) 592 { 593 if( rRule1.GetLevel(i) != rRule2.GetLevel(i) ) 594 return -1; 595 } 596 return 0; 597 } 598 } 599 } 600 601 return -1; 602 } 603 604 Reference< XAnyCompare > SvxCreateNumRuleCompare() throw() 605 { 606 return new SvxUnoNumberingRulesCompare(); 607 } 608 609 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace > SvxCreateNumRule() throw() 610 { 611 SvxNumRule aTempRule( 0, 10, false ); 612 return SvxCreateNumRule( &aTempRule ); 613 } 614