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 // MARKER(update_precomp.py): autogen include statement, do not remove 23 #include "precompiled_sw.hxx" 24 25 #include <svx/svxids.hrc> 26 #include <hintids.hxx> 27 #include <vos/mutex.hxx> 28 #include <vcl/svapp.hxx> 29 #include <svl/smplhint.hxx> 30 #include <svtools/ctrltool.hxx> 31 #include <svl/style.hxx> 32 #include <svl/itemiter.hxx> 33 #include <svx/pageitem.hxx> 34 #include <editeng/sizeitem.hxx> 35 #include <editeng/ulspitem.hxx> 36 #include <editeng/lrspitem.hxx> 37 #include <editeng/boxitem.hxx> 38 #include <editeng/shaditem.hxx> 39 #include <editeng/brshitem.hxx> 40 #include <editeng/flstitem.hxx> 41 #include <editeng/paperinf.hxx> 42 #include <pagedesc.hxx> 43 #include <doc.hxx> 44 #include <IDocumentUndoRedo.hxx> 45 #include <docary.hxx> 46 #include <charfmt.hxx> 47 #include <cmdid.h> 48 #include <unostyle.hxx> 49 #include <unosett.hxx> 50 #include <docsh.hxx> 51 #include <swstyle.h> 52 #include <paratr.hxx> 53 #include <unoprnms.hxx> 54 #include <shellio.hxx> 55 #include <docstyle.hxx> 56 #include <unotextbodyhf.hxx> 57 #include <fmthdft.hxx> 58 #include <fmtpdsc.hxx> 59 #include <tools/urlobj.hxx> 60 #include <poolfmt.hrc> 61 #include <poolfmt.hxx> 62 #include "unoevent.hxx" 63 #include <fmtruby.hxx> 64 #include <SwStyleNameMapper.hxx> 65 #include <sfx2/printer.hxx> 66 #include <com/sun/star/style/ParagraphStyleCategory.hpp> 67 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 68 #include <com/sun/star/beans/PropertyAttribute.hpp> 69 #include <com/sun/star/beans/NamedValue.hpp> 70 #include <com/sun/star/drawing/BitmapMode.hpp> 71 #include <istyleaccess.hxx> 72 #include <GetMetricVal.hxx> 73 #include <fmtfsize.hxx> 74 #include <numrule.hxx> 75 76 //UUUU 77 #include <svx/unobrushitemhelper.hxx> 78 #include <editeng/unoipset.hxx> 79 #include <editeng/memberids.hrc> 80 #include <svx/unoshape.hxx> 81 #include <svx/xflbstit.hxx> 82 #include <svx/xflbmtit.hxx> 83 #include <swunohelper.hxx> 84 #include <svx/xbtmpit.hxx> 85 86 #include <boost/shared_ptr.hpp> 87 88 #include "ccoll.hxx" 89 #include "unocore.hrc" 90 91 #include <set> 92 93 #define STYLE_FAMILY_COUNT 5 // we have 5 style families 94 #define TYPE_BOOL 0 95 #define TYPE_SIZE 1 96 #define TYPE_BRUSH 2 97 #define TYPE_ULSPACE 3 98 #define TYPE_SHADOW 4 99 #define TYPE_LRSPACE 5 100 #define TYPE_BOX 6 101 102 const unsigned short aStyleByIndex[] = 103 { 104 SFX_STYLE_FAMILY_CHAR, 105 SFX_STYLE_FAMILY_PARA, 106 SFX_STYLE_FAMILY_PAGE , 107 SFX_STYLE_FAMILY_FRAME , 108 SFX_STYLE_FAMILY_PSEUDO 109 }; 110 111 // Already implemented autostyle families: 3 112 #define AUTOSTYLE_FAMILY_COUNT 3 113 const IStyleAccess::SwAutoStyleFamily aAutoStyleByIndex[] = 114 { 115 IStyleAccess::AUTO_STYLE_CHAR, 116 IStyleAccess::AUTO_STYLE_RUBY, 117 IStyleAccess::AUTO_STYLE_PARA 118 }; 119 120 using namespace ::com::sun::star; 121 using ::rtl::OUString; 122 123 /****************************************************************************** 124 * 125 ******************************************************************************/ 126 127 SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum ( SfxStyleFamily eFamily ) 128 { 129 switch ( eFamily ) 130 { 131 case SFX_STYLE_FAMILY_CHAR: 132 return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT; 133 case SFX_STYLE_FAMILY_PARA: 134 return nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL; 135 case SFX_STYLE_FAMILY_FRAME: 136 return nsSwGetPoolIdFromName::GET_POOLID_FRMFMT; 137 case SFX_STYLE_FAMILY_PAGE: 138 return nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC; 139 case SFX_STYLE_FAMILY_PSEUDO: 140 return nsSwGetPoolIdFromName::GET_POOLID_NUMRULE; 141 default: 142 DBG_ASSERT(sal_False, "someone asking for all styles in unostyle.cxx!" ); 143 return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT; 144 } 145 } 146 147 class SwAutoStylesEnumImpl 148 { 149 std::vector<SfxItemSet_Pointer_t> mAutoStyles; 150 std::vector<SfxItemSet_Pointer_t>::iterator aIter; 151 SwDoc* pDoc; 152 IStyleAccess::SwAutoStyleFamily eFamily; 153 public: 154 SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam ); 155 ::sal_Bool hasMoreElements() { return aIter != mAutoStyles.end(); } 156 SfxItemSet_Pointer_t nextElement() { return *(aIter++); } 157 IStyleAccess::SwAutoStyleFamily getFamily() const { return eFamily; } 158 SwDoc* getDoc() const { return pDoc; } 159 }; 160 161 162 /****************************************************************** 163 * SwXStyleFamilies 164 ******************************************************************/ 165 /* -----------------------------06.04.00 11:24-------------------------------- 166 167 ---------------------------------------------------------------------------*/ 168 OUString SwXStyleFamilies::getImplementationName(void) throw( uno::RuntimeException ) 169 { 170 return C2U("SwXStyleFamilies"); 171 } 172 /* -----------------------------06.04.00 11:24-------------------------------- 173 174 ---------------------------------------------------------------------------*/ 175 sal_Bool SwXStyleFamilies::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) 176 { 177 return C2U("com.sun.star.style.StyleFamilies") == rServiceName; 178 } 179 /* -----------------------------06.04.00 11:24-------------------------------- 180 181 ---------------------------------------------------------------------------*/ 182 uno::Sequence< OUString > SwXStyleFamilies::getSupportedServiceNames(void) throw( uno::RuntimeException ) 183 { 184 uno::Sequence< OUString > aRet(1); 185 OUString* pArray = aRet.getArray(); 186 pArray[0] = C2U("com.sun.star.style.StyleFamilies"); 187 return aRet; 188 } 189 /*-- 16.12.98 15:13:26--------------------------------------------------- 190 191 -----------------------------------------------------------------------*/ 192 SwXStyleFamilies::SwXStyleFamilies(SwDocShell& rDocShell) : 193 SwUnoCollection(rDocShell.GetDoc()), 194 pDocShell(&rDocShell), 195 pxCharStyles(0), 196 pxParaStyles(0), 197 pxFrameStyles(0), 198 pxPageStyles(0), 199 pxNumberingStyles(0) 200 { 201 202 } 203 /*-- 16.12.98 15:13:26--------------------------------------------------- 204 205 -----------------------------------------------------------------------*/ 206 SwXStyleFamilies::~SwXStyleFamilies() 207 { 208 delete pxCharStyles; 209 delete pxParaStyles; 210 delete pxFrameStyles; 211 delete pxPageStyles; 212 delete pxNumberingStyles; 213 } 214 /*-- 21.12.98 12:05:22--------------------------------------------------- 215 216 -----------------------------------------------------------------------*/ 217 uno::Any SAL_CALL SwXStyleFamilies::getByName(const OUString& Name) 218 throw( 219 container::NoSuchElementException, 220 lang::WrappedTargetException, 221 uno::RuntimeException ) 222 { 223 vos::OGuard aGuard(Application::GetSolarMutex()); 224 // der Index kommt aus const unsigned short aStyleByIndex[] = 225 uno::Any aRet; 226 if(!IsValid()) 227 throw uno::RuntimeException(); 228 if(Name.compareToAscii("CharacterStyles") == 0 ) 229 aRet = getByIndex(0); 230 else if(Name.compareToAscii("ParagraphStyles") == 0) 231 aRet = getByIndex(1); 232 else if(Name.compareToAscii("FrameStyles") == 0 ) 233 aRet = getByIndex(3); 234 else if(Name.compareToAscii("PageStyles") == 0 ) 235 aRet = getByIndex(2); 236 else if(Name.compareToAscii("NumberingStyles") == 0 ) 237 aRet = getByIndex(4); 238 else 239 throw container::NoSuchElementException(); 240 return aRet; 241 } 242 /*-- 21.12.98 12:05:22--------------------------------------------------- 243 244 -----------------------------------------------------------------------*/ 245 uno::Sequence< OUString > SwXStyleFamilies::getElementNames(void) throw( uno::RuntimeException ) 246 { 247 uno::Sequence< OUString > aNames(STYLE_FAMILY_COUNT); 248 OUString* pNames = aNames.getArray(); 249 pNames[0] = C2U("CharacterStyles"); 250 pNames[1] = C2U("ParagraphStyles"); 251 pNames[2] = C2U("FrameStyles"); 252 pNames[3] = C2U("PageStyles"); 253 pNames[4] = C2U("NumberingStyles"); 254 return aNames; 255 } 256 /*-- 21.12.98 12:05:22--------------------------------------------------- 257 258 -----------------------------------------------------------------------*/ 259 sal_Bool SwXStyleFamilies::hasByName(const OUString& Name) throw( uno::RuntimeException ) 260 { 261 if( Name.compareToAscii("CharacterStyles") == 0 || 262 Name.compareToAscii("ParagraphStyles") == 0 || 263 Name.compareToAscii("FrameStyles") == 0 || 264 Name.compareToAscii("PageStyles") == 0 || 265 Name.compareToAscii("NumberingStyles") == 0 ) 266 return sal_True; 267 else 268 return sal_False; 269 } 270 /*-- 16.12.98 15:13:27--------------------------------------------------- 271 272 -----------------------------------------------------------------------*/ 273 sal_Int32 SwXStyleFamilies::getCount(void) throw( uno::RuntimeException ) 274 { 275 return STYLE_FAMILY_COUNT; 276 } 277 /*-- 16.12.98 15:13:27--------------------------------------------------- 278 279 -----------------------------------------------------------------------*/ 280 uno::Any SwXStyleFamilies::getByIndex(sal_Int32 nIndex) 281 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) 282 { 283 vos::OGuard aGuard(Application::GetSolarMutex()); 284 uno::Any aRet; 285 if(nIndex < 0 || nIndex >= STYLE_FAMILY_COUNT) 286 throw lang::IndexOutOfBoundsException(); 287 if(IsValid()) 288 { 289 uno::Reference< container::XNameContainer > aRef; 290 sal_uInt16 nType = aStyleByIndex[nIndex]; 291 switch( nType ) 292 { 293 case SFX_STYLE_FAMILY_CHAR: 294 { 295 if(!pxCharStyles) 296 { 297 ((SwXStyleFamilies*)this)->pxCharStyles = new uno::Reference< container::XNameContainer > (); 298 *pxCharStyles = new SwXStyleFamily(pDocShell, nType); 299 } 300 aRef = *pxCharStyles; 301 } 302 break; 303 case SFX_STYLE_FAMILY_PARA: 304 { 305 if(!pxParaStyles) 306 { 307 ((SwXStyleFamilies*)this)->pxParaStyles = new uno::Reference< container::XNameContainer > (); 308 *pxParaStyles = new SwXStyleFamily(pDocShell, nType); 309 } 310 aRef = *pxParaStyles; 311 } 312 break; 313 case SFX_STYLE_FAMILY_PAGE : 314 { 315 if(!pxPageStyles) 316 { 317 ((SwXStyleFamilies*)this)->pxPageStyles = new uno::Reference< container::XNameContainer > (); 318 *pxPageStyles = new SwXStyleFamily(pDocShell, nType); 319 } 320 aRef = *pxPageStyles; 321 } 322 break; 323 case SFX_STYLE_FAMILY_FRAME : 324 { 325 if(!pxFrameStyles) 326 { 327 ((SwXStyleFamilies*)this)->pxFrameStyles = new uno::Reference< container::XNameContainer > (); 328 *pxFrameStyles = new SwXStyleFamily(pDocShell, nType); 329 } 330 aRef = *pxFrameStyles; 331 } 332 break; 333 case SFX_STYLE_FAMILY_PSEUDO: 334 { 335 if(!pxNumberingStyles) 336 { 337 ((SwXStyleFamilies*)this)->pxNumberingStyles = new uno::Reference< container::XNameContainer > (); 338 *pxNumberingStyles = new SwXStyleFamily(pDocShell, nType); 339 } 340 aRef = *pxNumberingStyles; 341 } 342 break; 343 } 344 aRet.setValue(&aRef, ::getCppuType((const uno::Reference<container::XNameContainer>*)0)); 345 } 346 else 347 throw uno::RuntimeException(); 348 return aRet; 349 } 350 /*-- 16.12.98 15:13:27--------------------------------------------------- 351 352 -----------------------------------------------------------------------*/ 353 uno::Type SwXStyleFamilies::getElementType(void) 354 throw( uno::RuntimeException ) 355 { 356 return ::getCppuType((const uno::Reference<container::XNameContainer>*)0); 357 358 } 359 /*-- 16.12.98 15:13:28--------------------------------------------------- 360 361 -----------------------------------------------------------------------*/ 362 sal_Bool SwXStyleFamilies::hasElements(void) throw( uno::RuntimeException ) 363 { 364 return sal_True; 365 } 366 /*-- 16.12.98 15:13:28--------------------------------------------------- 367 368 -----------------------------------------------------------------------*/ 369 void SwXStyleFamilies::loadStylesFromURL(const OUString& rURL, 370 const uno::Sequence< beans::PropertyValue >& aOptions) 371 throw( io::IOException, uno::RuntimeException ) 372 { 373 vos::OGuard aGuard(Application::GetSolarMutex()); 374 sal_Bool bLoadStyleText = sal_True; 375 sal_Bool bLoadStylePage = sal_True; 376 sal_Bool bLoadStyleOverwrite = sal_True; 377 sal_Bool bLoadStyleNumbering = sal_True; 378 sal_Bool bLoadStyleFrame = sal_True; 379 if(IsValid() && rURL.getLength()) 380 { 381 const uno::Any* pVal; 382 int nCount = aOptions.getLength(); 383 const beans::PropertyValue* pArray = aOptions.getConstArray(); 384 for(int i = 0; i < nCount; i++) 385 if( ( pVal = &pArray[i].Value)->getValueType() == 386 ::getBooleanCppuType() ) 387 { 388 String sName = pArray[i].Name; 389 sal_Bool bVal = *(sal_Bool*)pVal->getValue(); 390 if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_OVERWRITE_STYLES ))) 391 bLoadStyleOverwrite = bVal; 392 else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_NUMBERING_STYLES ))) 393 bLoadStyleNumbering = bVal; 394 else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_PAGE_STYLES ))) 395 bLoadStylePage = bVal; 396 else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_FRAME_STYLES ))) 397 bLoadStyleFrame = bVal; 398 else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_TEXT_STYLES ))) 399 bLoadStyleText = bVal; 400 } 401 402 SwgReaderOption aOpt; 403 aOpt.SetFrmFmts( bLoadStyleFrame ); 404 aOpt.SetTxtFmts( bLoadStyleText ); 405 aOpt.SetPageDescs( bLoadStylePage ); 406 aOpt.SetNumRules( bLoadStyleNumbering ); 407 aOpt.SetMerge( !bLoadStyleOverwrite ); 408 409 sal_uLong nErr = pDocShell->LoadStylesFromFile( rURL, aOpt, sal_True ); 410 if( nErr ) 411 throw io::IOException(); 412 } 413 else 414 throw uno::RuntimeException(); 415 } 416 /*-- 16.12.98 15:13:28--------------------------------------------------- 417 418 -----------------------------------------------------------------------*/ 419 uno::Sequence< beans::PropertyValue > SwXStyleFamilies::getStyleLoaderOptions(void) 420 throw( uno::RuntimeException ) 421 { 422 vos::OGuard aGuard(Application::GetSolarMutex()); 423 uno::Sequence< beans::PropertyValue > aSeq(5); 424 beans::PropertyValue* pArray = aSeq.getArray(); 425 uno::Any aVal; 426 sal_Bool bTemp = sal_True; 427 aVal.setValue(&bTemp, ::getCppuBooleanType()); 428 pArray[0] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_TEXT_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 429 aVal.setValue(&bTemp, ::getCppuBooleanType()); 430 pArray[1] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_FRAME_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 431 aVal.setValue(&bTemp, ::getCppuBooleanType()); 432 pArray[2] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_PAGE_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 433 aVal.setValue(&bTemp, ::getCppuBooleanType()); 434 pArray[3] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_NUMBERING_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 435 aVal.setValue(&bTemp, ::getCppuBooleanType()); 436 pArray[4] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_OVERWRITE_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 437 return aSeq; 438 } 439 440 /****************************************************************** 441 * SwXStyleFamily 442 ******************************************************************/ 443 /* -----------------------------06.04.00 11:24-------------------------------- 444 445 ---------------------------------------------------------------------------*/ 446 OUString SwXStyleFamily::getImplementationName(void) throw( uno::RuntimeException ) 447 { 448 return C2U("SwXStyleFamily"); 449 } 450 /* -----------------------------06.04.00 11:24-------------------------------- 451 452 ---------------------------------------------------------------------------*/ 453 sal_Bool SwXStyleFamily::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) 454 { 455 return C2U("com.sun.star.style.StyleFamily") == rServiceName; 456 } 457 /* -----------------------------06.04.00 11:24-------------------------------- 458 459 ---------------------------------------------------------------------------*/ 460 uno::Sequence< OUString > SwXStyleFamily::getSupportedServiceNames(void) throw( uno::RuntimeException ) 461 { 462 uno::Sequence< OUString > aRet(1); 463 OUString* pArray = aRet.getArray(); 464 pArray[0] = C2U("com.sun.star.style.StyleFamily"); 465 return aRet; 466 } 467 /*-- 16.12.98 16:03:56--------------------------------------------------- 468 469 -----------------------------------------------------------------------*/ 470 SwXStyleFamily::SwXStyleFamily(SwDocShell* pDocSh, sal_uInt16 nFamily) : 471 eFamily((SfxStyleFamily)nFamily), 472 pBasePool(pDocSh->GetStyleSheetPool()), 473 pDocShell(pDocSh) 474 { 475 /* switch( nFamily ) 476 { 477 case SFX_STYLE_FAMILY_CHAR: 478 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_CHAR_STYLE); 479 break; 480 case SFX_STYLE_FAMILY_PARA: 481 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_PARA_STYLE); 482 break; 483 case SFX_STYLE_FAMILY_PAGE: 484 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_PAGE_STYLE); 485 break; 486 case SFX_STYLE_FAMILY_FRAME: 487 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_FRAME_STYLE); 488 break; 489 case SFX_STYLE_FAMILY_PSEUDO: 490 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_NUM_STYLE); 491 break; 492 }*/ 493 StartListening(*pBasePool); 494 } 495 /*-- 16.12.98 16:03:56--------------------------------------------------- 496 497 -----------------------------------------------------------------------*/ 498 SwXStyleFamily::~SwXStyleFamily() 499 { 500 501 } 502 sal_Int32 lcl_GetCountOrName ( const SwDoc &rDoc, SfxStyleFamily eFamily, String *pString, sal_uInt16 nIndex = USHRT_MAX ) 503 { 504 sal_Int32 nCount = 0; 505 switch( eFamily ) 506 { 507 case SFX_STYLE_FAMILY_CHAR: 508 { 509 sal_uInt16 nBaseCount = RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN + 510 RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN; 511 nIndex = nIndex - nBaseCount; 512 const sal_uInt16 nArrLen = rDoc.GetCharFmts()->Count(); 513 for( sal_uInt16 i = 0; i < nArrLen; i++ ) 514 { 515 SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ]; 516 if( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() ) 517 continue; 518 if ( IsPoolUserFmt ( pFmt->GetPoolFmtId() ) ) 519 { 520 if ( nIndex == nCount ) 521 { 522 // the default character format needs to be set to "Default!" 523 if(rDoc.GetDfltCharFmt() == pFmt) 524 SwStyleNameMapper::FillUIName( 525 RES_POOLCOLL_STANDARD, *pString ); 526 else 527 *pString = pFmt->GetName(); 528 break; 529 } 530 nCount++; 531 } 532 } 533 nCount += nBaseCount; 534 } 535 break; 536 case SFX_STYLE_FAMILY_PARA: 537 { 538 sal_uInt16 nBaseCount = RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN + 539 RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN + 540 RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN + 541 RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN + 542 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN + 543 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN; 544 nIndex = nIndex - nBaseCount; 545 const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->Count(); 546 for ( sal_uInt16 i = 0; i < nArrLen; i++ ) 547 { 548 SwTxtFmtColl * pColl = (*rDoc.GetTxtFmtColls())[i]; 549 if ( pColl->IsDefault() ) 550 continue; 551 if ( IsPoolUserFmt ( pColl->GetPoolFmtId() ) ) 552 { 553 if ( nIndex == nCount ) 554 { 555 *pString = pColl->GetName(); 556 break; 557 } 558 nCount++; 559 } 560 } 561 nCount += nBaseCount; 562 } 563 break; 564 case SFX_STYLE_FAMILY_FRAME: 565 { 566 sal_uInt16 nBaseCount = RES_POOLFRM_END - RES_POOLFRM_BEGIN; 567 nIndex = nIndex - nBaseCount; 568 const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->Count(); 569 for( sal_uInt16 i = 0; i < nArrLen; i++ ) 570 { 571 SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ]; 572 if(pFmt->IsDefault() || pFmt->IsAuto()) 573 continue; 574 if ( IsPoolUserFmt ( pFmt->GetPoolFmtId() ) ) 575 { 576 if ( nIndex == nCount ) 577 { 578 *pString = pFmt->GetName(); 579 break; 580 } 581 nCount++; 582 } 583 } 584 nCount += nBaseCount; 585 } 586 break; 587 case SFX_STYLE_FAMILY_PAGE: 588 { 589 sal_uInt16 nBaseCount = RES_POOLPAGE_END - RES_POOLPAGE_BEGIN; 590 nIndex = nIndex - nBaseCount; 591 const sal_uInt16 nArrLen = rDoc.GetPageDescCnt(); 592 for(sal_uInt16 i = 0; i < nArrLen; ++i) 593 { 594 const SwPageDesc& rDesc = rDoc.GetPageDesc(i); 595 596 /*if(rDesc.IsDefault() || rDesc.IsAuto()) 597 continue;*/ 598 if ( IsPoolUserFmt ( rDesc.GetPoolFmtId() ) ) 599 { 600 if ( nIndex == nCount ) 601 { 602 *pString = rDesc.GetName(); 603 break; 604 } 605 nCount++; 606 } 607 } 608 nCount += nBaseCount; 609 } 610 break; 611 case SFX_STYLE_FAMILY_PSEUDO: 612 { 613 sal_uInt16 nBaseCount = RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN; 614 nIndex = nIndex - nBaseCount; 615 const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl(); 616 for(sal_uInt16 i = 0; i < rNumTbl.Count(); ++i) 617 { 618 const SwNumRule& rRule = *rNumTbl[ i ]; 619 if( rRule.IsAutoRule() ) 620 continue; 621 if ( IsPoolUserFmt ( rRule.GetPoolFmtId() ) ) 622 { 623 if ( nIndex == nCount ) 624 { 625 *pString = rRule.GetName(); 626 break; 627 } 628 nCount++; 629 } 630 } 631 nCount += nBaseCount; 632 } 633 break; 634 635 default: 636 ; 637 } 638 return nCount; 639 } 640 /*-- 16.12.98 16:03:57--------------------------------------------------- 641 642 -----------------------------------------------------------------------*/ 643 sal_Int32 SwXStyleFamily::getCount(void) throw( uno::RuntimeException ) 644 { 645 vos::OGuard aGuard(Application::GetSolarMutex()); 646 return lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, NULL ); 647 } 648 /*-- 16.12.98 16:03:57--------------------------------------------------- 649 650 -----------------------------------------------------------------------*/ 651 uno::Any SwXStyleFamily::getByIndex(sal_Int32 nTempIndex) 652 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) 653 { 654 vos::OGuard aGuard(Application::GetSolarMutex()); 655 uno::Any aRet; 656 if ( nTempIndex >= 0 && nTempIndex < USHRT_MAX ) 657 { 658 sal_uInt16 nIndex = static_cast < sal_uInt16 > ( nTempIndex ); 659 if(pBasePool) 660 { 661 String sStyleName; 662 switch( eFamily ) 663 { 664 case SFX_STYLE_FAMILY_CHAR: 665 { 666 if ( nIndex < ( RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) ) 667 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCHR_NORMAL_BEGIN + nIndex), sStyleName ); 668 else if ( nIndex < ( RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN + 669 RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) ) 670 SwStyleNameMapper::FillUIName ( RES_POOLCHR_HTML_BEGIN 671 - RES_POOLCHR_NORMAL_END + RES_POOLCHR_NORMAL_BEGIN 672 + nIndex, sStyleName ); 673 } 674 break; 675 case SFX_STYLE_FAMILY_PARA: 676 { 677 if ( nIndex < ( RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) ) 678 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_TEXT_BEGIN + nIndex), sStyleName ); 679 else if ( nIndex < ( RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN + 680 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) ) 681 SwStyleNameMapper::FillUIName ( RES_POOLCOLL_LISTS_BEGIN 682 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN 683 + nIndex, sStyleName ); 684 else if ( nIndex < ( RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN + 685 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN + 686 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) ) 687 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_EXTRA_BEGIN 688 - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN 689 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN 690 + nIndex), sStyleName ); 691 else if ( nIndex < ( RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN + 692 RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN + 693 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN + 694 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) ) 695 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_REGISTER_BEGIN 696 - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN 697 - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN 698 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN 699 + nIndex), sStyleName ); 700 else if ( nIndex < ( RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN + 701 RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN + 702 RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN + 703 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN + 704 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) ) 705 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_DOC_BEGIN 706 - RES_POOLCOLL_REGISTER_END + RES_POOLCOLL_REGISTER_BEGIN 707 - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN 708 - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN 709 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN 710 + nIndex), sStyleName ); 711 else if ( nIndex < ( RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN + 712 RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN + 713 RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN + 714 RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN + 715 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN + 716 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) ) 717 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_HTML_BEGIN 718 - RES_POOLCOLL_DOC_END + RES_POOLCOLL_DOC_BEGIN 719 - RES_POOLCOLL_REGISTER_END + RES_POOLCOLL_REGISTER_BEGIN 720 - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN 721 - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN 722 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN 723 + nIndex), sStyleName ); 724 } 725 break; 726 case SFX_STYLE_FAMILY_FRAME: 727 { 728 if ( nIndex < ( RES_POOLFRM_END - RES_POOLFRM_BEGIN ) ) 729 { 730 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLFRM_BEGIN + nIndex), sStyleName ); 731 } 732 } 733 break; 734 case SFX_STYLE_FAMILY_PAGE: 735 { 736 if ( nIndex < ( RES_POOLPAGE_END - RES_POOLPAGE_BEGIN ) ) 737 { 738 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + nIndex), sStyleName ); 739 } 740 } 741 break; 742 case SFX_STYLE_FAMILY_PSEUDO: 743 { 744 if ( nIndex < ( RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN ) ) 745 { 746 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLNUMRULE_BEGIN + nIndex), sStyleName ); 747 } 748 } 749 break; 750 751 default: 752 ; 753 } 754 if ( !sStyleName.Len() ) 755 lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, &sStyleName, nIndex ); 756 757 if ( sStyleName.Len() ) 758 { 759 SfxStyleSheetBase* pBase = pBasePool->Find( sStyleName, eFamily ); 760 if(pBase) 761 { 762 uno::Reference< style::XStyle > xStyle = _FindStyle(sStyleName); 763 if(!xStyle.is()) 764 { 765 xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ? 766 new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) : 767 eFamily == SFX_STYLE_FAMILY_FRAME ? 768 new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()): 769 new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName); 770 } 771 aRet.setValue(&xStyle, ::getCppuType((uno::Reference<style::XStyle>*)0)); 772 } 773 else 774 throw container::NoSuchElementException(); 775 } 776 else 777 throw lang::IndexOutOfBoundsException(); 778 } 779 else 780 throw uno::RuntimeException(); 781 } 782 else 783 throw lang::IndexOutOfBoundsException(); 784 785 return aRet; 786 } 787 /*-- 16.12.98 16:03:57--------------------------------------------------- 788 789 -----------------------------------------------------------------------*/ 790 uno::Any SwXStyleFamily::getByName(const OUString& rName) 791 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) 792 { 793 vos::OGuard aGuard(Application::GetSolarMutex()); 794 uno::Any aRet; 795 String sStyleName; 796 SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ); 797 if(pBasePool) 798 { 799 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL ); 800 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 801 if(pBase) 802 { 803 uno::Reference< style::XStyle > xStyle = _FindStyle(sStyleName); 804 if(!xStyle.is()) 805 { 806 xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ? 807 new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) : 808 eFamily == SFX_STYLE_FAMILY_FRAME ? 809 new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()): 810 new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName); 811 } 812 aRet.setValue(&xStyle, ::getCppuType((uno::Reference<style::XStyle>*)0)); 813 } 814 else 815 throw container::NoSuchElementException(); 816 } 817 else 818 throw uno::RuntimeException(); 819 return aRet; 820 821 } 822 /*-- 16.12.98 16:03:57--------------------------------------------------- 823 824 -----------------------------------------------------------------------*/ 825 uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::RuntimeException ) 826 { 827 vos::OGuard aGuard(Application::GetSolarMutex()); 828 uno::Sequence< OUString > aRet; 829 if(pBasePool) 830 { 831 SfxStyleSheetIteratorPtr pIterator = pBasePool->CreateIterator(eFamily, 0xffff); 832 sal_uInt16 nCount = pIterator->Count(); 833 aRet.realloc(nCount); 834 OUString* pArray = aRet.getArray(); 835 String aString; 836 for(sal_uInt16 i = 0; i < nCount; i++) 837 { 838 SwStyleNameMapper::FillProgName((*pIterator)[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ); 839 pArray[i] = OUString ( aString ); 840 } 841 } 842 else 843 throw uno::RuntimeException(); 844 return aRet; 845 } 846 /*-- 16.12.98 16:03:57--------------------------------------------------- 847 848 -----------------------------------------------------------------------*/ 849 sal_Bool SwXStyleFamily::hasByName(const OUString& rName) throw( uno::RuntimeException ) 850 { 851 vos::OGuard aGuard(Application::GetSolarMutex()); 852 sal_Bool bRet = sal_False; 853 if(pBasePool) 854 { 855 String sStyleName; 856 SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ); 857 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL ); 858 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 859 bRet = 0 != pBase; 860 } 861 else 862 throw uno::RuntimeException(); 863 return bRet; 864 865 } 866 /*-- 16.12.98 16:03:58--------------------------------------------------- 867 868 -----------------------------------------------------------------------*/ 869 uno::Type SwXStyleFamily::getElementType(void) throw( uno::RuntimeException ) 870 { 871 return ::getCppuType((const uno::Reference<style::XStyle>*)0); 872 873 } 874 /*-- 16.12.98 16:03:58--------------------------------------------------- 875 876 -----------------------------------------------------------------------*/ 877 sal_Bool SwXStyleFamily::hasElements(void) throw( uno::RuntimeException ) 878 { 879 if(!pBasePool) 880 throw uno::RuntimeException(); 881 return sal_True; 882 } 883 /*-- 16.12.98 16:03:58--------------------------------------------------- 884 885 -----------------------------------------------------------------------*/ 886 void SwXStyleFamily::insertByName(const OUString& rName, const uno::Any& rElement) 887 throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException ) 888 { 889 vos::OGuard aGuard(Application::GetSolarMutex()); 890 if(pBasePool) 891 { 892 String sStyleName; 893 SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True); 894 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL ); 895 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 896 SfxStyleSheetBase* pUINameBase = pBasePool->Find( sStyleName ); 897 if(pBase || pUINameBase) 898 throw container::ElementExistException(); 899 else 900 { 901 if(rElement.getValueType().getTypeClass() == 902 uno::TypeClass_INTERFACE) 903 { 904 uno::Reference< uno::XInterface > * pxRef = 905 (uno::Reference< uno::XInterface > *)rElement.getValue(); 906 907 uno::Reference<lang::XUnoTunnel> xStyleTunnel( *pxRef, uno::UNO_QUERY); 908 909 SwXStyle* pNewStyle = 0; 910 if(xStyleTunnel.is()) 911 { 912 pNewStyle = reinterpret_cast< SwXStyle * >( 913 sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId()) )); 914 } 915 if(!pNewStyle || !pNewStyle->IsDescriptor() || 916 pNewStyle->GetFamily() != eFamily) 917 throw lang::IllegalArgumentException(); 918 if(pNewStyle) 919 { 920 sal_uInt16 nMask = 0xffff; 921 if(eFamily == SFX_STYLE_FAMILY_PARA && !pNewStyle->IsConditional()) 922 nMask &= ~SWSTYLEBIT_CONDCOLL; 923 #if OSL_DEBUG_LEVEL > 1 924 SfxStyleSheetBase& rNewBase = 925 #endif 926 pBasePool->Make(sStyleName, eFamily, nMask); 927 pNewStyle->SetDoc(pDocShell->GetDoc(), pBasePool); 928 pNewStyle->SetStyleName(sStyleName); 929 String sParentStyleName(pNewStyle->GetParentStyleName()); 930 if(sParentStyleName.Len()) 931 { 932 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL ); 933 SfxStyleSheetBase* pParentBase = pBasePool->Find(sParentStyleName); 934 if(pParentBase && pParentBase->GetFamily() == eFamily && 935 &pParentBase->GetPool() == pBasePool) 936 pBasePool->SetParent( eFamily, sStyleName, sParentStyleName ); 937 938 } 939 #if OSL_DEBUG_LEVEL > 1 940 (void)rNewBase; 941 #endif 942 //so, jetzt sollten noch die Properties des Descriptors angewandt werden 943 pNewStyle->ApplyDescriptorProperties(); 944 } 945 else 946 throw lang::IllegalArgumentException(); 947 } 948 else 949 throw lang::IllegalArgumentException(); 950 } 951 } 952 else 953 throw uno::RuntimeException(); 954 } 955 /*-- 16.12.98 16:03:59--------------------------------------------------- 956 957 -----------------------------------------------------------------------*/ 958 void SwXStyleFamily::replaceByName(const OUString& rName, const uno::Any& rElement) 959 throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) 960 { 961 vos::OGuard aGuard(Application::GetSolarMutex()); 962 if(pBasePool) 963 { 964 pBasePool->SetSearchMask(eFamily); 965 SfxStyleSheetBase* pBase = pBasePool->Find(rName); 966 //Ersetzung geht nur fuer benutzerdefinierte Styles 967 if(!pBase) 968 throw container::NoSuchElementException(); 969 if(!pBase->IsUserDefined()) 970 throw lang::IllegalArgumentException(); 971 //if theres an object available to this style then it must be invalidated 972 uno::Reference< style::XStyle > xStyle = _FindStyle(pBase->GetName()); 973 if(xStyle.is()) 974 { 975 uno::Reference<lang::XUnoTunnel> xTunnel( xStyle, uno::UNO_QUERY); 976 if(xTunnel.is()) 977 { 978 SwXStyle* pStyle = reinterpret_cast< SwXStyle * >( 979 sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( SwXStyle::getUnoTunnelId()) )); 980 pStyle->Invalidate(); 981 } 982 } 983 984 pBasePool->Remove(pBase); 985 insertByName(rName, rElement); 986 } 987 else 988 throw uno::RuntimeException(); 989 } 990 /*-- 16.12.98 16:03:59--------------------------------------------------- 991 992 -----------------------------------------------------------------------*/ 993 void SwXStyleFamily::removeByName(const OUString& rName) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) 994 { 995 vos::OGuard aGuard(Application::GetSolarMutex()); 996 if(pBasePool) 997 { 998 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL ); 999 String aString; 1000 SwStyleNameMapper::FillUIName(rName, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ); 1001 1002 SfxStyleSheetBase* pBase = pBasePool->Find( aString ); 1003 if(pBase) 1004 pBasePool->Remove(pBase); 1005 else 1006 throw container::NoSuchElementException(); 1007 } 1008 else 1009 throw uno::RuntimeException(); 1010 } 1011 1012 uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXStyleFamily::getPropertySetInfo( ) throw (uno::RuntimeException) 1013 { 1014 OSL_ENSURE( 0, "###unexpected!" ); 1015 return uno::Reference< beans::XPropertySetInfo >(); 1016 } 1017 1018 void SAL_CALL SwXStyleFamily::setPropertyValue( const ::rtl::OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 1019 { 1020 OSL_ENSURE( 0, "###unexpected!" ); 1021 } 1022 1023 uno::Any SAL_CALL SwXStyleFamily::getPropertyValue( const ::rtl::OUString& sPropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1024 { 1025 uno::Any aRet; 1026 1027 if ( sPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DisplayName") ) ) 1028 { 1029 vos::OGuard aGuard(Application::GetSolarMutex()); 1030 sal_uInt32 nResId = 0; 1031 switch ( eFamily ) 1032 { 1033 case SFX_STYLE_FAMILY_CHAR: 1034 nResId = STR_STYLE_FAMILY_CHARACTER; break; 1035 case SFX_STYLE_FAMILY_PARA: 1036 nResId = STR_STYLE_FAMILY_PARAGRAPH; break; 1037 case SFX_STYLE_FAMILY_FRAME: 1038 nResId = STR_STYLE_FAMILY_FRAME; break; 1039 case SFX_STYLE_FAMILY_PAGE: 1040 nResId = STR_STYLE_FAMILY_PAGE; break; 1041 case SFX_STYLE_FAMILY_PSEUDO: 1042 nResId = STR_STYLE_FAMILY_NUMBERING; break; 1043 default: 1044 OSL_ENSURE( 0, "SwXStyleFamily::getPropertyValue(): invalid family" ); 1045 } 1046 if ( nResId > 0 ) 1047 { 1048 OUString sDisplayName( String( SW_RES( nResId ) ) ); 1049 aRet = uno::makeAny( sDisplayName ); 1050 } 1051 } 1052 else 1053 { 1054 throw beans::UnknownPropertyException( OUString( RTL_CONSTASCII_USTRINGPARAM("unknown property: ") ) + sPropertyName, static_cast<OWeakObject *>(this) ); 1055 } 1056 1057 return aRet; 1058 } 1059 1060 void SAL_CALL SwXStyleFamily::addPropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1061 { 1062 OSL_ENSURE( 0, "###unexpected!" ); 1063 } 1064 1065 void SAL_CALL SwXStyleFamily::removePropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1066 { 1067 OSL_ENSURE( 0, "###unexpected!" ); 1068 } 1069 1070 void SAL_CALL SwXStyleFamily::addVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1071 { 1072 OSL_ENSURE( 0, "###unexpected!" ); 1073 } 1074 1075 void SAL_CALL SwXStyleFamily::removeVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1076 { 1077 OSL_ENSURE( 0, "###unexpected!" ); 1078 } 1079 1080 1081 /*-- 16.12.98 16:03:59--------------------------------------------------- 1082 1083 -----------------------------------------------------------------------*/ 1084 void SwXStyleFamily::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 1085 { 1086 SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint ); 1087 if( pHint && ( pHint->GetId() & SFX_HINT_DYING ) ) 1088 { 1089 pBasePool = 0; 1090 pDocShell = 0; 1091 EndListening(rBC); 1092 } 1093 } 1094 /*-- 16.12.98 16:03:59--------------------------------------------------- 1095 1096 -----------------------------------------------------------------------*/ 1097 SwXStyle* SwXStyleFamily::_FindStyle(const String& rStyleName)const 1098 { 1099 sal_uInt16 nLCount = pBasePool->GetListenerCount(); 1100 SfxListener* pListener = 0; 1101 for( sal_uInt16 i = 0; i < nLCount; i++) 1102 { 1103 pListener = pBasePool->GetListener( i ); 1104 SwXStyle* pTempStyle = dynamic_cast<SwXStyle*>( pListener ); 1105 if(pTempStyle && pTempStyle->GetFamily() == eFamily && pTempStyle->GetStyleName() == rStyleName) 1106 { 1107 return pTempStyle; 1108 } 1109 } 1110 return 0; 1111 } 1112 /****************************************************************** 1113 * 1114 ******************************************************************/ 1115 class SwStyleProperties_Impl 1116 { 1117 const PropertyEntryVector_t aPropertyEntries; 1118 uno::Any** pAnyArr; 1119 sal_uInt32 nArrLen; 1120 1121 public: 1122 SwStyleProperties_Impl(const SfxItemPropertyMap* _pMap); 1123 ~SwStyleProperties_Impl(); 1124 1125 sal_Bool SetProperty(const ::rtl::OUString& rName, uno::Any aVal); 1126 sal_Bool GetProperty(const ::rtl::OUString& rName, uno::Any*& rpAny); 1127 sal_Bool ClearProperty( const ::rtl::OUString& rPropertyName ); 1128 void ClearAllProperties( ); 1129 void GetProperty(const ::rtl::OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any& rAny ); 1130 1131 const PropertyEntryVector_t& GetPropertyVector() const {return aPropertyEntries; } 1132 1133 }; 1134 //-------------------------------------------------------------------- 1135 //-------------------------------------------------------------------- 1136 SwStyleProperties_Impl::SwStyleProperties_Impl(const SfxItemPropertyMap* pMap) : 1137 // _pMap(pMap), 1138 aPropertyEntries( pMap->getPropertyEntries() ), 1139 nArrLen(0) 1140 { 1141 nArrLen = aPropertyEntries.size(); 1142 //const SfxItemPropertyMap* pTmp = _pMap; 1143 1144 pAnyArr = new uno::Any* [nArrLen]; 1145 for ( sal_uInt32 i =0 ; i < nArrLen; i++ ) 1146 pAnyArr[i] = 0; 1147 } 1148 //-------------------------------------------------------------------- 1149 //-------------------------------------------------------------------- 1150 SwStyleProperties_Impl::~SwStyleProperties_Impl() 1151 { 1152 for ( sal_uInt16 i =0 ; i < nArrLen; i++ ) 1153 delete pAnyArr[i]; 1154 delete[] pAnyArr; 1155 } 1156 1157 //-------------------------------------------------------------------- 1158 //-------------------------------------------------------------------- 1159 sal_Bool SwStyleProperties_Impl::SetProperty(const ::rtl::OUString& rName, uno::Any aVal) 1160 { 1161 sal_uInt16 nPos = 0; 1162 sal_Bool bRet = sal_False; 1163 PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin(); 1164 while( aIt != aPropertyEntries.end() ) 1165 { 1166 if(rName == aIt->sName) 1167 { 1168 delete pAnyArr[nPos]; 1169 pAnyArr[nPos] = new uno::Any ( aVal ); 1170 bRet = sal_True; 1171 break; 1172 } 1173 ++nPos; 1174 ++aIt; 1175 } 1176 return bRet; 1177 } 1178 1179 sal_Bool SwStyleProperties_Impl::ClearProperty( const OUString& rName ) 1180 { 1181 sal_Bool bRet = sal_False; 1182 sal_uInt16 nPos = 0; 1183 PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin(); 1184 while( aIt != aPropertyEntries.end() ) 1185 { 1186 if( rName == aIt->sName ) 1187 { 1188 delete pAnyArr[nPos]; 1189 pAnyArr[ nPos ] = 0; 1190 bRet = sal_True; 1191 break; 1192 } 1193 ++nPos; 1194 ++aIt; 1195 } 1196 return bRet; 1197 } 1198 void SwStyleProperties_Impl::ClearAllProperties( ) 1199 { 1200 for ( sal_uInt16 i = 0; i < nArrLen; i++ ) 1201 { 1202 delete pAnyArr[i]; 1203 pAnyArr[ i ] = 0; 1204 } 1205 } 1206 //-------------------------------------------------------------------- 1207 //-------------------------------------------------------------------- 1208 sal_Bool SwStyleProperties_Impl::GetProperty(const ::rtl::OUString& rName, uno::Any*& rpAny ) 1209 { 1210 sal_Bool bRet = sal_False; 1211 sal_uInt16 nPos = 0; 1212 PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin(); 1213 while( aIt != aPropertyEntries.end() ) 1214 { 1215 if( rName == aIt->sName ) 1216 { 1217 rpAny = pAnyArr[nPos]; 1218 bRet = sal_True; 1219 break; 1220 } 1221 ++nPos; 1222 ++aIt; 1223 } 1224 1225 return bRet; 1226 } 1227 1228 void SwStyleProperties_Impl::GetProperty( const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any & rAny ) 1229 { 1230 rAny = rxPropertySet->getPropertyValue( rPropertyName ); 1231 } 1232 1233 /****************************************************************** 1234 * 1235 ******************************************************************/ 1236 /* -----------------------------10.03.00 18:02-------------------------------- 1237 1238 ---------------------------------------------------------------------------*/ 1239 const uno::Sequence< sal_Int8 > & SwXStyle::getUnoTunnelId() 1240 { 1241 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); 1242 return aSeq; 1243 } 1244 /* -----------------------------10.03.00 18:04-------------------------------- 1245 1246 ---------------------------------------------------------------------------*/ 1247 sal_Int64 SAL_CALL SwXStyle::getSomething( const uno::Sequence< sal_Int8 >& rId ) 1248 throw(uno::RuntimeException) 1249 { 1250 if( rId.getLength() == 16 1251 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 1252 rId.getConstArray(), 16 ) ) 1253 { 1254 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); 1255 } 1256 return 0; 1257 } 1258 1259 TYPEINIT1(SwXStyle, SfxListener); 1260 /* -----------------------------06.04.00 11:24-------------------------------- 1261 1262 ---------------------------------------------------------------------------*/ 1263 OUString SwXStyle::getImplementationName(void) throw( uno::RuntimeException ) 1264 { 1265 return C2U("SwXStyle"); 1266 } 1267 /* -----------------------------06.04.00 11:24-------------------------------- 1268 1269 ---------------------------------------------------------------------------*/ 1270 sal_Bool SwXStyle::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) 1271 { 1272 sal_Bool bRet = C2U("com.sun.star.style.Style") == rServiceName; 1273 if(!bRet && SFX_STYLE_FAMILY_CHAR == eFamily) 1274 bRet = !rServiceName.compareToAscii("com.sun.star.style.CharacterStyle")|| 1275 !rServiceName.compareToAscii("com.sun.star.style.CharacterProperties")|| 1276 !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesAsian")|| 1277 !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesComplex"); 1278 if(!bRet && SFX_STYLE_FAMILY_PARA == eFamily) 1279 bRet = (C2U("com.sun.star.style.ParagraphStyle") == rServiceName)|| 1280 (C2U("com.sun.star.style.ParagraphProperties") == rServiceName) || 1281 (C2U("com.sun.star.style.ParagraphPropertiesAsian") == rServiceName) || 1282 (C2U("com.sun.star.style.ParagraphPropertiesComplex") == rServiceName); 1283 if(!bRet && SFX_STYLE_FAMILY_PAGE == eFamily) 1284 bRet = (C2U("com.sun.star.style.PageStyle") == rServiceName)|| 1285 (C2U("com.sun.star.style.PageProperties") == rServiceName); 1286 1287 return bRet; 1288 } 1289 /* -----------------------------06.04.00 11:24-------------------------------- 1290 1291 ---------------------------------------------------------------------------*/ 1292 uno::Sequence< OUString > SwXStyle::getSupportedServiceNames(void) throw( uno::RuntimeException ) 1293 { 1294 long nCount = 1; 1295 if(SFX_STYLE_FAMILY_PARA == eFamily) 1296 { 1297 nCount = 5; 1298 if(bIsConditional) 1299 nCount++; 1300 } 1301 else if(SFX_STYLE_FAMILY_CHAR == eFamily) 1302 nCount = 5; 1303 else if(SFX_STYLE_FAMILY_PAGE == eFamily) 1304 nCount = 3; 1305 uno::Sequence< OUString > aRet(nCount); 1306 OUString* pArray = aRet.getArray(); 1307 pArray[0] = C2U("com.sun.star.style.Style"); 1308 switch(eFamily) 1309 { 1310 case SFX_STYLE_FAMILY_CHAR: 1311 pArray[1] = C2U("com.sun.star.style.CharacterStyle"); 1312 pArray[2] = C2U("com.sun.star.style.CharacterProperties"); 1313 pArray[3] = C2U("com.sun.star.style.CharacterPropertiesAsian"); 1314 pArray[4] = C2U("com.sun.star.style.CharacterPropertiesComplex"); 1315 break; 1316 case SFX_STYLE_FAMILY_PAGE: 1317 pArray[1] = C2U("com.sun.star.style.PageStyle"); 1318 pArray[2] = C2U("com.sun.star.style.PageProperties"); 1319 break; 1320 case SFX_STYLE_FAMILY_PARA: 1321 pArray[1] = C2U("com.sun.star.style.ParagraphStyle"); 1322 pArray[2] = C2U("com.sun.star.style.ParagraphProperties"); 1323 pArray[3] = C2U("com.sun.star.style.ParagraphPropertiesAsian"); 1324 pArray[4] = C2U("com.sun.star.style.ParagraphPropertiesComplex"); 1325 if(bIsConditional) 1326 pArray[5] = C2U("com.sun.star.style.ConditionalParagraphStyle"); 1327 break; 1328 1329 default: 1330 ; 1331 } 1332 return aRet; 1333 } 1334 /*-- 17.12.98 08:26:49--------------------------------------------------- 1335 1336 -----------------------------------------------------------------------*/ 1337 SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFam, sal_Bool bConditional) : 1338 m_pDoc( pDoc ), 1339 pBasePool(0), 1340 eFamily(eFam), 1341 bIsDescriptor(sal_True), 1342 bIsConditional(bConditional) 1343 { 1344 // Register ourselves as a listener to the document (via the page descriptor) 1345 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); 1346 // get the property set for the default style data 1347 // First get the model 1348 uno::Reference < frame::XModel > xModel = pDoc->GetDocShell()->GetBaseModel(); 1349 // Ask the model for it's family supplier interface 1350 uno::Reference < style::XStyleFamiliesSupplier > xFamilySupplier ( xModel, uno::UNO_QUERY ); 1351 // Get the style families 1352 uno::Reference < container::XNameAccess > xFamilies = xFamilySupplier->getStyleFamilies(); 1353 1354 uno::Any aAny; 1355 sal_uInt16 nMapId = PROPERTY_MAP_NUM_STYLE; 1356 switch( eFamily ) 1357 { 1358 case SFX_STYLE_FAMILY_CHAR: 1359 { 1360 nMapId = PROPERTY_MAP_CHAR_STYLE; 1361 aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "CharacterStyles" ) ) ); 1362 // Get the Frame family (and keep it for later) 1363 aAny >>= mxStyleFamily; 1364 //aAny = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Standard" ) ) ); 1365 //aAny >>= mxStyleData; 1366 } 1367 break; 1368 case SFX_STYLE_FAMILY_PARA: 1369 { 1370 nMapId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; 1371 aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ParagraphStyles" ) ) ); 1372 // Get the Frame family (and keep it for later) 1373 aAny >>= mxStyleFamily; 1374 aAny = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Standard" ) ) ); 1375 aAny >>= mxStyleData; 1376 } 1377 break; 1378 case SFX_STYLE_FAMILY_PAGE: 1379 { 1380 nMapId = PROPERTY_MAP_PAGE_STYLE; 1381 aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "PageStyles" ) ) ); 1382 // Get the Frame family (and keep it for later) 1383 aAny >>= mxStyleFamily; 1384 aAny = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Standard" ) ) ); 1385 aAny >>= mxStyleData; 1386 } 1387 break; 1388 case SFX_STYLE_FAMILY_FRAME : 1389 { 1390 nMapId = PROPERTY_MAP_FRAME_STYLE; 1391 } 1392 break; 1393 case SFX_STYLE_FAMILY_PSEUDO: 1394 { 1395 nMapId = PROPERTY_MAP_NUM_STYLE; 1396 } 1397 break; 1398 1399 default: 1400 ; 1401 } 1402 pPropImpl = new SwStyleProperties_Impl(aSwMapProvider.GetPropertySet(nMapId)->getPropertyMap()); 1403 } 1404 1405 1406 SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam, 1407 SwDoc* pDoc, const String& rStyleName) : 1408 m_pDoc(pDoc), 1409 sStyleName(rStyleName), 1410 pBasePool(&rPool), 1411 eFamily(eFam), 1412 bIsDescriptor(sal_False), 1413 bIsConditional(sal_False), 1414 pPropImpl(0) 1415 { 1416 StartListening(rPool); 1417 if(eFam == SFX_STYLE_FAMILY_PARA) 1418 { 1419 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL ); 1420 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 1421 DBG_ASSERT(pBase, "where is the style?" ); 1422 if(pBase) 1423 { 1424 const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(sStyleName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL); 1425 if(nId != USHRT_MAX) 1426 bIsConditional = ::IsConditionalByPoolId( nId ); 1427 else 1428 bIsConditional = RES_CONDTXTFMTCOLL == ((SwDocStyleSheet*)pBase)->GetCollection()->Which(); 1429 } 1430 } 1431 } 1432 /*-- 17.12.98 08:26:50--------------------------------------------------- 1433 1434 -----------------------------------------------------------------------*/ 1435 SwXStyle::~SwXStyle() 1436 { 1437 if(pBasePool) 1438 EndListening(*pBasePool); 1439 delete pPropImpl; 1440 } 1441 /*-- 17.12.98 08:26:51--------------------------------------------------- 1442 1443 -----------------------------------------------------------------------*/ 1444 void SwXStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) 1445 { 1446 ClientModify(this, pOld, pNew); 1447 if(!GetRegisteredIn()) 1448 { 1449 m_pDoc = 0; 1450 mxStyleData.clear(); 1451 mxStyleFamily.clear(); 1452 } 1453 } 1454 OUString SwXStyle::getName(void) throw( uno::RuntimeException ) 1455 { 1456 vos::OGuard aGuard(Application::GetSolarMutex()); 1457 String aString; 1458 if(pBasePool) 1459 { 1460 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL ); 1461 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 1462 DBG_ASSERT(pBase, "where is the style?" ); 1463 if(!pBase) 1464 throw uno::RuntimeException(); 1465 SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True); 1466 } 1467 else 1468 aString = sStyleName; 1469 return OUString (aString); 1470 } 1471 /*-- 17.12.98 08:26:51--------------------------------------------------- 1472 1473 -----------------------------------------------------------------------*/ 1474 void SwXStyle::setName(const OUString& rName) throw( uno::RuntimeException ) 1475 { 1476 vos::OGuard aGuard(Application::GetSolarMutex()); 1477 if(pBasePool) 1478 { 1479 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL ); 1480 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 1481 DBG_ASSERT(pBase, "where is the style?" ); 1482 sal_Bool bExcept = sal_True; 1483 if(pBase && pBase->IsUserDefined()) 1484 { 1485 rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 1486 bExcept = !xTmp->SetName(rName); 1487 if(!bExcept) 1488 sStyleName = String(rName); 1489 } 1490 if(bExcept) 1491 throw uno::RuntimeException(); 1492 } 1493 else 1494 sStyleName = String(rName); 1495 } 1496 /*-- 17.12.98 08:26:51--------------------------------------------------- 1497 1498 -----------------------------------------------------------------------*/ 1499 sal_Bool SwXStyle::isUserDefined(void) throw( uno::RuntimeException ) 1500 { 1501 vos::OGuard aGuard(Application::GetSolarMutex()); 1502 sal_Bool bRet = sal_False; 1503 if(pBasePool) 1504 { 1505 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL ); 1506 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 1507 //if it is not found it must be non user defined 1508 if(pBase) 1509 bRet = pBase->IsUserDefined(); 1510 } 1511 else 1512 throw uno::RuntimeException(); 1513 return bRet; 1514 } 1515 /*-- 17.12.98 08:26:51--------------------------------------------------- 1516 1517 -----------------------------------------------------------------------*/ 1518 sal_Bool SwXStyle::isInUse(void) throw( uno::RuntimeException ) 1519 { 1520 vos::OGuard aGuard(Application::GetSolarMutex()); 1521 sal_Bool bRet = sal_False; 1522 if(pBasePool) 1523 { 1524 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_USED); 1525 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 1526 if(pBase) 1527 bRet = pBase->IsUsed(); 1528 } 1529 else 1530 throw uno::RuntimeException(); 1531 return bRet; 1532 } 1533 /*-- 17.12.98 08:26:52--------------------------------------------------- 1534 1535 -----------------------------------------------------------------------*/ 1536 OUString SwXStyle::getParentStyle(void) throw( uno::RuntimeException ) 1537 { 1538 vos::OGuard aGuard(Application::GetSolarMutex()); 1539 String aString; 1540 if(pBasePool) 1541 { 1542 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL); 1543 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 1544 if(pBase) 1545 aString = pBase->GetParent(); 1546 } 1547 else if(bIsDescriptor) 1548 aString = sParentStyleName; 1549 else 1550 throw uno::RuntimeException(); 1551 SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ); 1552 return OUString ( aString ); 1553 } 1554 /*-- 17.12.98 08:26:52--------------------------------------------------- 1555 1556 -----------------------------------------------------------------------*/ 1557 void SwXStyle::setParentStyle(const OUString& rParentStyle) 1558 throw( container::NoSuchElementException, uno::RuntimeException ) 1559 { 1560 vos::OGuard aGuard(Application::GetSolarMutex()); 1561 String sParentStyle; 1562 SwStyleNameMapper::FillUIName(rParentStyle, sParentStyle, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ); 1563 if(pBasePool) 1564 { 1565 pBasePool->SetSearchMask(eFamily); 1566 sal_Bool bExcept = sal_False; 1567 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 1568 if(pBase) 1569 { 1570 rtl::Reference< SwDocStyleSheet > xBase( new SwDocStyleSheet(*(SwDocStyleSheet*)pBase) ); 1571 //make it a 'real' style - necessary for pooled styles 1572 xBase->GetItemSet(); 1573 if(xBase->GetParent() != sParentStyle) 1574 { 1575 bExcept = !xBase->SetParent(sParentStyle); 1576 } 1577 } 1578 else 1579 bExcept = sal_True; 1580 if(bExcept) 1581 throw uno::RuntimeException(); 1582 } 1583 else if(bIsDescriptor) 1584 { 1585 sParentStyleName = String(sParentStyle); 1586 try 1587 { 1588 uno::Any aAny = mxStyleFamily->getByName ( sParentStyle ); 1589 aAny >>= mxStyleData; 1590 } 1591 catch ( container::NoSuchElementException& ) 1592 { 1593 } 1594 catch ( lang::WrappedTargetException& ) 1595 { 1596 } 1597 catch ( uno::RuntimeException& ) 1598 { 1599 } 1600 } 1601 else 1602 throw uno::RuntimeException(); 1603 } 1604 /*-- 17.12.98 08:26:52--------------------------------------------------- 1605 1606 -----------------------------------------------------------------------*/ 1607 1608 uno::Reference< beans::XPropertySetInfo > lcl_getPropertySetInfo( SfxStyleFamily eFamily, sal_Bool bIsConditional ) 1609 { 1610 uno::Reference< beans::XPropertySetInfo > xRet; 1611 switch( eFamily ) 1612 { 1613 case SFX_STYLE_FAMILY_CHAR: 1614 { 1615 static uno::Reference< beans::XPropertySetInfo > xCharRef; 1616 if(!xCharRef.is()) 1617 { 1618 xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_STYLE)->getPropertySetInfo(); 1619 } 1620 xRet = xCharRef; 1621 } 1622 break; 1623 case SFX_STYLE_FAMILY_PARA: 1624 { 1625 static uno::Reference< beans::XPropertySetInfo > xParaRef; 1626 if(!xParaRef.is()) 1627 { 1628 sal_uInt16 nMapId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; 1629 xParaRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo(); 1630 } 1631 xRet = xParaRef; 1632 } 1633 break; 1634 case SFX_STYLE_FAMILY_PAGE : 1635 { 1636 static uno::Reference< beans::XPropertySetInfo > xPageRef; 1637 if(!xPageRef.is()) 1638 { 1639 xPageRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE)->getPropertySetInfo(); 1640 } 1641 xRet = xPageRef; 1642 } 1643 break; 1644 case SFX_STYLE_FAMILY_FRAME : 1645 { 1646 static uno::Reference< beans::XPropertySetInfo > xFrameRef; 1647 if(!xFrameRef.is()) 1648 { 1649 xFrameRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_FRAME_STYLE)->getPropertySetInfo(); 1650 } 1651 xRet = xFrameRef; 1652 } 1653 break; 1654 case SFX_STYLE_FAMILY_PSEUDO: 1655 { 1656 static uno::Reference< beans::XPropertySetInfo > xNumRef; 1657 if(!xNumRef.is()) 1658 { 1659 xNumRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_NUM_STYLE)->getPropertySetInfo(); 1660 } 1661 xRet = xNumRef; 1662 } 1663 break; 1664 1665 default: 1666 ; 1667 } 1668 return xRet; 1669 } 1670 1671 uno::Reference< beans::XPropertySetInfo > SwXStyle::getPropertySetInfo(void) 1672 throw( uno::RuntimeException ) 1673 { 1674 return lcl_getPropertySetInfo( eFamily, bIsConditional ); 1675 } 1676 /* -----------------23.04.99 13:28------------------- 1677 * 1678 * --------------------------------------------------*/ 1679 void SwXStyle::ApplyDescriptorProperties() 1680 { 1681 bIsDescriptor = sal_False; 1682 mxStyleData.clear(); 1683 mxStyleFamily.clear(); 1684 1685 const PropertyEntryVector_t& rPropertyVector = pPropImpl->GetPropertyVector(); 1686 PropertyEntryVector_t::const_iterator aIt = rPropertyVector.begin(); 1687 while(aIt != rPropertyVector.end()) 1688 { 1689 uno::Any* pAny; 1690 pPropImpl->GetProperty(aIt->sName, pAny); 1691 if(pAny) 1692 setPropertyValue(aIt->sName, *pAny); 1693 ++aIt; 1694 } 1695 } 1696 1697 /*-- 18.04.01 13:07:27--------------------------------------------------- 1698 1699 -----------------------------------------------------------------------*/ 1700 class SwStyleBase_Impl 1701 { 1702 private: 1703 SwDoc& mrDoc; 1704 const SwPageDesc* mpOldPageDesc; 1705 rtl::Reference< SwDocStyleSheet > mxNewBase; 1706 SfxItemSet* mpItemSet; 1707 const String& mrStyleName; 1708 sal_uInt16 mnPDescPos; 1709 const SwAttrSet* mpParentStyle; 1710 1711 public: 1712 SwStyleBase_Impl( 1713 SwDoc& rSwDoc, 1714 const String& rName, 1715 const SwAttrSet* pParentStyle) 1716 : mrDoc(rSwDoc), 1717 mpOldPageDesc(0), 1718 mxNewBase(), 1719 mpItemSet(0), 1720 mrStyleName(rName), 1721 mnPDescPos(0xffff), 1722 mpParentStyle(pParentStyle) 1723 { 1724 } 1725 1726 ~SwStyleBase_Impl() 1727 { 1728 delete mpItemSet; 1729 } 1730 1731 rtl::Reference< SwDocStyleSheet >& getNewBase() 1732 { 1733 return mxNewBase; 1734 } 1735 1736 void setNewBase(SwDocStyleSheet* pNew) 1737 { 1738 mxNewBase = pNew; 1739 } 1740 1741 sal_Bool HasItemSet() 1742 { 1743 return mxNewBase.is(); 1744 } 1745 1746 SfxItemSet* replaceItemSet(SfxItemSet* pNew) 1747 { 1748 SfxItemSet* pRetval = mpItemSet; 1749 mpItemSet = pNew; 1750 return pRetval; 1751 } 1752 1753 SfxItemSet& GetItemSet() 1754 { 1755 DBG_ASSERT(mxNewBase.is(), "no SwDocStyleSheet available"); 1756 1757 if(!mpItemSet) 1758 { 1759 mpItemSet = new SfxItemSet(mxNewBase->GetItemSet()); 1760 1761 //UUUU set parent style to have the correct XFillStyle setting as XFILL_NONE 1762 if(!mpItemSet->GetParent() && mpParentStyle) 1763 { 1764 mpItemSet->SetParent(mpParentStyle); 1765 } 1766 } 1767 1768 return *mpItemSet; 1769 } 1770 1771 const SwPageDesc& GetOldPageDesc(); 1772 }; 1773 /* -----------------------------25.04.01 12:44-------------------------------- 1774 1775 ---------------------------------------------------------------------------*/ 1776 const SwPageDesc& SwStyleBase_Impl::GetOldPageDesc() 1777 { 1778 if(!mpOldPageDesc) 1779 { 1780 sal_uInt16 i; 1781 sal_uInt16 nPDescCount = mrDoc.GetPageDescCnt(); 1782 for(i = 0; i < nPDescCount; i++) 1783 { 1784 const SwPageDesc& rDesc = 1785 const_cast<const SwDoc &>(mrDoc).GetPageDesc( i ); 1786 if(rDesc.GetName() == mrStyleName) 1787 { 1788 mpOldPageDesc = & rDesc; 1789 mnPDescPos = i; 1790 break; 1791 } 1792 } 1793 if(!mpOldPageDesc) 1794 { 1795 for(i = RC_POOLPAGEDESC_BEGIN; i <= STR_POOLPAGE_LANDSCAPE; ++i) 1796 { 1797 const String aFmtName(SW_RES(i)); 1798 if(aFmtName == mrStyleName) 1799 { 1800 mpOldPageDesc = mrDoc.GetPageDescFromPool( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) ); 1801 break; 1802 } 1803 } 1804 for(i = 0; i < nPDescCount + 1; i++) 1805 { 1806 const SwPageDesc& rDesc = 1807 const_cast<const SwDoc &>(mrDoc).GetPageDesc( i ); 1808 if(rDesc.GetName() == mrStyleName) 1809 { 1810 mnPDescPos = i; 1811 break; 1812 } 1813 } 1814 } 1815 } 1816 return *mpOldPageDesc; 1817 } 1818 1819 /* -----------------------------19.04.01 09:44-------------------------------- 1820 1821 ---------------------------------------------------------------------------*/ 1822 1823 void lcl_SetStyleProperty( 1824 const SfxItemPropertySimpleEntry& rEntry, 1825 const SfxItemPropertySet& rPropSet, 1826 const uno::Any& rValue, 1827 SwStyleBase_Impl& rBase, 1828 SfxStyleSheetBasePool* pBasePool, 1829 SwDoc* pDoc, 1830 SfxStyleFamily eFamily) 1831 throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 1832 { 1833 //UUUU adapted switch logic to a more readable state; removed goto's and made 1834 // execution of standard setting of proerty in ItemSet dependent of this variable 1835 bool bDone(false); 1836 1837 //UUUU 1838 const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM)); 1839 uno::Any aValue(rValue); 1840 1841 //UUUU check for needed metric translation 1842 if(rEntry.nMemberId & SFX_METRIC_ITEM) 1843 { 1844 bool bDoIt(true); 1845 1846 if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID) 1847 { 1848 // exception: If these ItemTypes are used, do not convert when these are negative 1849 // since this means they are intended as percent values 1850 sal_Int32 nValue = 0; 1851 1852 if(aValue >>= nValue) 1853 { 1854 bDoIt = nValue > 0; 1855 } 1856 } 1857 1858 if(bDoIt && pDoc) 1859 { 1860 const SfxItemPool& rPool = pDoc->GetAttrPool(); 1861 const SfxMapUnit eMapUnit(rPool.GetMetric(rEntry.nWID)); 1862 1863 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 1864 { 1865 SvxUnoConvertFromMM(eMapUnit, aValue); 1866 } 1867 } 1868 } 1869 1870 switch(rEntry.nWID) 1871 { 1872 case XATTR_FILLGRADIENT: 1873 case XATTR_FILLHATCH: 1874 case XATTR_FILLBITMAP: 1875 case XATTR_FILLFLOATTRANSPARENCE: 1876 // not yet needed; activate when LineStyle support may be added 1877 // case XATTR_LINESTART: 1878 // case XATTR_LINEEND: 1879 // case XATTR_LINEDASH: 1880 { 1881 if(MID_NAME == nMemberId) 1882 { 1883 //UUUU add set commands for FillName items 1884 OUString aTempName; 1885 SfxItemSet& rStyleSet = rBase.GetItemSet(); 1886 1887 if(!(aValue >>= aTempName)) 1888 { 1889 throw lang::IllegalArgumentException(); 1890 } 1891 1892 SvxShape::SetFillAttribute(rEntry.nWID, aTempName, rStyleSet); 1893 bDone = true; 1894 } 1895 else if(MID_GRAFURL == nMemberId) 1896 { 1897 if(XATTR_FILLBITMAP == rEntry.nWID) 1898 { 1899 //UUUU Bitmap also has the MID_GRAFURL mode where a Bitmap URL is used 1900 const Graphic aNullGraphic; 1901 SfxItemSet& rStyleSet = rBase.GetItemSet(); 1902 XFillBitmapItem aXFillBitmapItem(rStyleSet.GetPool(), aNullGraphic); 1903 1904 aXFillBitmapItem.PutValue(aValue, nMemberId); 1905 rStyleSet.Put(aXFillBitmapItem); 1906 bDone = true; 1907 } 1908 } 1909 1910 break; 1911 } 1912 case RES_BACKGROUND: 1913 { 1914 //UUUU 1915 SfxItemSet& rStyleSet = rBase.GetItemSet(); 1916 const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rStyleSet, RES_BACKGROUND)); 1917 SvxBrushItem aChangedBrushItem(aOriginalBrushItem); 1918 1919 aChangedBrushItem.PutValue(aValue, nMemberId); 1920 1921 if(!(aChangedBrushItem == aOriginalBrushItem)) 1922 { 1923 setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, rStyleSet); 1924 } 1925 1926 bDone = true; 1927 break; 1928 } 1929 case OWN_ATTR_FILLBMP_MODE: 1930 { 1931 //UUUU 1932 drawing::BitmapMode eMode; 1933 1934 if(!(aValue >>= eMode)) 1935 { 1936 sal_Int32 nMode = 0; 1937 1938 if(!(aValue >>= nMode)) 1939 { 1940 throw lang::IllegalArgumentException(); 1941 } 1942 1943 eMode = (drawing::BitmapMode)nMode; 1944 } 1945 1946 SfxItemSet& rStyleSet = rBase.GetItemSet(); 1947 1948 rStyleSet.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH == eMode)); 1949 rStyleSet.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT == eMode)); 1950 1951 bDone = true; 1952 break; 1953 } 1954 case RES_PAPER_BIN: 1955 { 1956 SfxPrinter *pPrinter = pDoc->getPrinter( true ); 1957 OUString sTmp; 1958 sal_uInt16 nBin = USHRT_MAX; 1959 if ( !( aValue >>= sTmp ) ) 1960 throw lang::IllegalArgumentException(); 1961 if ( sTmp.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "[From printer settings]" ) ) ) 1962 nBin = USHRT_MAX-1; 1963 else if ( pPrinter ) 1964 { 1965 for (sal_uInt16 i=0, nEnd = pPrinter->GetPaperBinCount(); i < nEnd; i++ ) 1966 { 1967 if (sTmp == OUString ( pPrinter->GetPaperBinName ( i ) ) ) 1968 { 1969 nBin = i; 1970 break; 1971 } 1972 } 1973 } 1974 if ( nBin == USHRT_MAX ) 1975 throw lang::IllegalArgumentException(); 1976 else 1977 { 1978 SfxItemSet& rStyleSet = rBase.GetItemSet(); 1979 SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID); 1980 aSet.SetParent(&rStyleSet); 1981 rPropSet.setPropertyValue(rEntry, uno::makeAny ( static_cast < sal_Int8 > ( nBin == USHRT_MAX-1 ? -1 : nBin ) ), aSet); 1982 rStyleSet.Put(aSet); 1983 } 1984 1985 bDone = true; 1986 break; 1987 } 1988 case FN_UNO_NUM_RULES: //Sonderbehandlung fuer das SvxNumRuleItem: 1989 { 1990 if(aValue.getValueType() == ::getCppuType((uno::Reference< container::XIndexReplace>*)0) ) 1991 { 1992 uno::Reference< container::XIndexReplace > * pxRulesRef = 1993 (uno::Reference< container::XIndexReplace > *)aValue.getValue(); 1994 1995 uno::Reference<lang::XUnoTunnel> xNumberTunnel( *pxRulesRef, uno::UNO_QUERY); 1996 1997 SwXNumberingRules* pSwXRules = 0; 1998 if(xNumberTunnel.is()) 1999 { 2000 pSwXRules = reinterpret_cast< SwXNumberingRules * >( 2001 sal::static_int_cast< sal_IntPtr >(xNumberTunnel->getSomething( SwXNumberingRules::getUnoTunnelId()) )); 2002 } 2003 if(pSwXRules) 2004 { 2005 const String* pCharStyleNames = pSwXRules->GetNewCharStyleNames(); 2006 const String* pBulletFontNames = pSwXRules->GetBulletFontNames(); 2007 2008 SwNumRule aSetRule(*pSwXRules->GetNumRule()); 2009 const SwCharFmts* pFmts = pDoc->GetCharFmts(); 2010 sal_uInt16 nChCount = pFmts->Count(); 2011 for(sal_uInt16 i = 0; i < MAXLEVEL; i++) 2012 { 2013 2014 const SwNumFmt* pFmt = aSetRule.GetNumFmt( i ); 2015 if(pFmt) 2016 { 2017 SwNumFmt aFmt(*pFmt); 2018 if( 2019 pCharStyleNames[i] != SwXNumberingRules::GetInvalidStyle() && 2020 ((pCharStyleNames[i].Len() && !pFmt->GetCharFmt()) || 2021 (pCharStyleNames[i].Len() && 2022 pFmt->GetCharFmt()->GetName() != pCharStyleNames[i]) )) 2023 { 2024 2025 SwCharFmt* pCharFmt = 0; 2026 if(pCharStyleNames[i].Len()) 2027 { 2028 for(sal_uInt16 j = 0; j< nChCount; j++) 2029 { 2030 SwCharFmt* pTmp = (*pFmts)[j]; 2031 if(pTmp->GetName() == pCharStyleNames[i]) 2032 { 2033 pCharFmt = pTmp; 2034 break; 2035 } 2036 } 2037 if(!pCharFmt) 2038 { 2039 2040 SfxStyleSheetBase* pBase; 2041 pBase = ((SfxStyleSheetBasePool*)pBasePool)->Find(pCharStyleNames[i], SFX_STYLE_FAMILY_CHAR); 2042 if(!pBase) 2043 pBase = &pBasePool->Make(pCharStyleNames[i], SFX_STYLE_FAMILY_CHAR); 2044 pCharFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt(); 2045 2046 } 2047 2048 aFmt.SetCharFmt( pCharFmt ); 2049 } 2050 } 2051 //jetzt nochmal fuer Fonts 2052 if(pBulletFontNames[i] != SwXNumberingRules::GetInvalidStyle() && 2053 ((pBulletFontNames[i].Len() && !pFmt->GetBulletFont()) || 2054 (pBulletFontNames[i].Len() && 2055 pFmt->GetBulletFont()->GetName() != pBulletFontNames[i]) )) 2056 { 2057 const SvxFontListItem* pFontListItem = 2058 (const SvxFontListItem* )pDoc->GetDocShell() 2059 ->GetItem( SID_ATTR_CHAR_FONTLIST ); 2060 const FontList* pList = pFontListItem->GetFontList(); 2061 FontInfo aInfo = pList->Get( 2062 pBulletFontNames[i],WEIGHT_NORMAL, ITALIC_NONE); 2063 Font aFont(aInfo); 2064 aFmt.SetBulletFont(&aFont); 2065 } 2066 aSetRule.Set( i, &aFmt ); 2067 } 2068 } 2069 rBase.getNewBase()->SetNumRule(aSetRule); 2070 } 2071 } 2072 else 2073 throw lang::IllegalArgumentException(); 2074 2075 bDone = true; 2076 break; 2077 } 2078 2079 case RES_PARATR_OUTLINELEVEL: 2080 { 2081 sal_Int16 nLevel = 0; 2082 aValue >>= nLevel; 2083 if( 0 <= nLevel && nLevel <= MAXLEVEL) 2084 rBase.getNewBase()->GetCollection()->SetAttrOutlineLevel( nLevel ); 2085 2086 bDone = true; 2087 break; 2088 } 2089 2090 case FN_UNO_FOLLOW_STYLE: 2091 { 2092 OUString sTmp; 2093 aValue >>= sTmp; 2094 String aString; 2095 SwStyleNameMapper::FillUIName(sTmp, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ) ; 2096 rBase.getNewBase()->SetFollow( aString ); 2097 2098 bDone = true; 2099 break; 2100 } 2101 case RES_PAGEDESC : 2102 { 2103 if( MID_PAGEDESC_PAGEDESCNAME == nMemberId) 2104 { 2105 // Sonderbehandlung RES_PAGEDESC 2106 if(aValue.getValueType() != ::getCppuType((const OUString*)0)) 2107 throw lang::IllegalArgumentException(); 2108 SfxItemSet& rStyleSet = rBase.GetItemSet(); 2109 2110 SwFmtPageDesc* pNewDesc = 0; 2111 const SfxPoolItem* pItem; 2112 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) ) 2113 { 2114 pNewDesc = new SwFmtPageDesc(*((SwFmtPageDesc*)pItem)); 2115 } 2116 if(!pNewDesc) 2117 pNewDesc = new SwFmtPageDesc(); 2118 OUString uDescName; 2119 aValue >>= uDescName; 2120 String sDescName; 2121 SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True ); 2122 if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName) 2123 { 2124 //sal_uInt16 nCount = pDoc->GetPageDescCnt(); 2125 sal_Bool bPut = sal_False; 2126 if(sDescName.Len()) 2127 { 2128 SwPageDesc* pPageDesc = ::GetPageDescByName_Impl(*pDoc, sDescName); 2129 if(pPageDesc) 2130 { 2131 pNewDesc->RegisterToPageDesc( *pPageDesc ); 2132 bPut = sal_True; 2133 } 2134 else 2135 { 2136 throw lang::IllegalArgumentException(); 2137 } 2138 } 2139 if(!bPut) 2140 { 2141 rStyleSet.ClearItem(RES_BREAK); 2142 rStyleSet.Put(SwFmtPageDesc()); 2143 } 2144 else 2145 rStyleSet.Put(*pNewDesc); 2146 } 2147 2148 delete pNewDesc; 2149 bDone = true; 2150 } 2151 2152 break; 2153 } 2154 case FN_UNO_IS_AUTO_UPDATE: 2155 { 2156 sal_Bool bAuto = *(sal_Bool*)aValue.getValue(); 2157 if(SFX_STYLE_FAMILY_PARA == eFamily) 2158 rBase.getNewBase()->GetCollection()->SetAutoUpdateFmt(bAuto); 2159 else if(SFX_STYLE_FAMILY_FRAME == eFamily) 2160 rBase.getNewBase()->GetFrmFmt()->SetAutoUpdateFmt(bAuto); 2161 2162 bDone = true; 2163 break; 2164 } 2165 case FN_UNO_PARA_STYLE_CONDITIONS: 2166 { 2167 uno::Sequence< beans::NamedValue > aSeq; 2168 if (!(aValue >>= aSeq)) 2169 throw lang::IllegalArgumentException(); 2170 2171 DBG_ASSERT(COND_COMMAND_COUNT == 28, 2172 "invalid size of comman count?"); 2173 const beans::NamedValue *pSeq = aSeq.getConstArray(); 2174 sal_Int32 nLen = aSeq.getLength(); 2175 2176 sal_Bool bFailed = sal_False; 2177 SwCondCollItem aCondItem; 2178 for(sal_uInt16 i = 0; i < nLen; i++) 2179 { 2180 OUString aTmp; 2181 if ((pSeq[i].Value >>= aTmp)) 2182 { 2183 // get UI style name from programmatic style name 2184 String aStyleName; 2185 SwStyleNameMapper::FillUIName( aTmp, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ); 2186 2187 // 2188 // check for correct context and style name 2189 // 2190 sal_Int16 nIdx = GetCommandContextIndex( pSeq[i].Name ); 2191 // 2192 pBasePool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL ); 2193 sal_Bool bStyleFound = sal_False; 2194 const SfxStyleSheetBase* pBase = pBasePool->First(); 2195 while (pBase && !bStyleFound) 2196 { 2197 if(pBase->GetName() == aStyleName) 2198 bStyleFound = sal_True; 2199 pBase = pBasePool->Next(); 2200 } 2201 // 2202 if (nIdx == -1 || !bStyleFound) 2203 { 2204 bFailed = sal_True; 2205 break; 2206 } 2207 2208 aCondItem.SetStyle( &aStyleName, nIdx); 2209 } 2210 else 2211 bFailed = sal_True; 2212 } 2213 if (bFailed) 2214 throw lang::IllegalArgumentException(); 2215 rBase.GetItemSet().Put( aCondItem ); 2216 bDone = true; 2217 break; 2218 } 2219 case FN_UNO_CATEGORY: 2220 { 2221 if(!rBase.getNewBase()->IsUserDefined()) 2222 throw lang::IllegalArgumentException(); 2223 short nSet = 0; 2224 aValue >>= nSet; 2225 2226 sal_uInt16 nId; 2227 switch( nSet ) 2228 { 2229 case style::ParagraphStyleCategory::TEXT: 2230 nId = SWSTYLEBIT_TEXT; 2231 break; 2232 case style::ParagraphStyleCategory::CHAPTER: 2233 nId = SWSTYLEBIT_CHAPTER; 2234 break; 2235 case style::ParagraphStyleCategory::LIST: 2236 nId = SWSTYLEBIT_LIST; 2237 break; 2238 case style::ParagraphStyleCategory::INDEX: 2239 nId = SWSTYLEBIT_IDX; 2240 break; 2241 case style::ParagraphStyleCategory::EXTRA: 2242 nId = SWSTYLEBIT_EXTRA; 2243 break; 2244 case style::ParagraphStyleCategory::HTML: 2245 nId = SWSTYLEBIT_HTML; 2246 break; 2247 default: throw lang::IllegalArgumentException(); 2248 } 2249 2250 rBase.getNewBase()->SetMask( nId|SFXSTYLEBIT_USERDEF ); 2251 bDone = true; 2252 break; 2253 } 2254 case SID_SWREGISTER_COLLECTION: 2255 { 2256 OUString sName; 2257 aValue >>= sName; 2258 SwRegisterItem aReg( sName.getLength() != 0); 2259 aReg.SetWhich(SID_SWREGISTER_MODE); 2260 rBase.GetItemSet().Put(aReg); 2261 String aString; 2262 SwStyleNameMapper::FillUIName(sName, aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); 2263 2264 rBase.GetItemSet().Put(SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) ); 2265 bDone = true; 2266 break; 2267 } 2268 case RES_TXTATR_CJK_RUBY: 2269 { 2270 if(MID_RUBY_CHARSTYLE == nMemberId ) 2271 { 2272 OUString sTmp; 2273 if(aValue >>= sTmp) 2274 { 2275 SfxItemSet& rStyleSet = rBase.GetItemSet(); 2276 SwFmtRuby* pRuby = 0; 2277 const SfxPoolItem* pItem; 2278 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_TXTATR_CJK_RUBY, sal_True, &pItem ) ) 2279 pRuby = new SwFmtRuby(*((SwFmtRuby*)pItem)); 2280 if(!pRuby) 2281 pRuby = new SwFmtRuby(aEmptyStr); 2282 String sStyle; 2283 SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); 2284 pRuby->SetCharFmtName( sTmp ); 2285 pRuby->SetCharFmtId( 0 ); 2286 if(sTmp.getLength()) 2287 { 2288 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sTmp, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); 2289 pRuby->SetCharFmtId(nId); 2290 } 2291 rStyleSet.Put(*pRuby); 2292 delete pRuby; 2293 } 2294 else 2295 throw lang::IllegalArgumentException(); 2296 } 2297 break; 2298 } 2299 case RES_PARATR_DROP: 2300 { 2301 if( MID_DROPCAP_CHAR_STYLE_NAME == nMemberId) 2302 { 2303 if(aValue.getValueType() == ::getCppuType((const OUString*)0)) 2304 { 2305 SfxItemSet& rStyleSet = rBase.GetItemSet(); 2306 2307 SwFmtDrop* pDrop = 0; 2308 const SfxPoolItem* pItem; 2309 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PARATR_DROP, sal_True, &pItem ) ) 2310 pDrop = new SwFmtDrop(*((SwFmtDrop*)pItem)); 2311 if(!pDrop) 2312 pDrop = new SwFmtDrop(); 2313 OUString uStyle; 2314 aValue >>= uStyle; 2315 String sStyle; 2316 SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); 2317 SwDocStyleSheet* pStyle = 2318 (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR); 2319 if(pStyle) 2320 pDrop->SetCharFmt(pStyle->GetCharFmt()); 2321 else 2322 throw lang::IllegalArgumentException(); 2323 rStyleSet.Put(*pDrop); 2324 delete pDrop; 2325 } 2326 else 2327 throw lang::IllegalArgumentException(); 2328 2329 bDone = true; 2330 } 2331 break; 2332 } 2333 default: 2334 { 2335 // nothing to do 2336 break; 2337 } 2338 } 2339 2340 if(!bDone) 2341 { 2342 // default ItemSet handling 2343 SfxItemSet& rStyleSet = rBase.GetItemSet(); 2344 SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID); 2345 aSet.SetParent(&rStyleSet); 2346 rPropSet.setPropertyValue(rEntry, aValue, aSet); 2347 rStyleSet.Put(aSet); 2348 2349 // --> OD 2006-10-18 #i70223# 2350 if ( SFX_STYLE_FAMILY_PARA == eFamily && 2351 rEntry.nWID == RES_PARATR_NUMRULE && 2352 rBase.getNewBase().is() && rBase.getNewBase()->GetCollection() && 2353 //rBase.getNewBase()->GetCollection()->GetOutlineLevel() < MAXLEVEL /* assigned to list level of outline style */) //#outline level,removed by zhaojianwei 2354 rBase.getNewBase()->GetCollection()->IsAssignedToListLevelOfOutlineStyle() ) ////<-end,add by zhaojianwei 2355 { 2356 OUString sNewNumberingRuleName; 2357 aValue >>= sNewNumberingRuleName; 2358 String sTmp( sNewNumberingRuleName ); 2359 if ( sNewNumberingRuleName.getLength() == 0 || sTmp != pDoc->GetOutlineNumRule()->GetName() ) 2360 { 2361 // delete assignment to list level of outline style. 2362 //rBase.getNewBase()->GetCollection()->SetOutlineLevel( NO_NUMBERING ); //#outline level,removed by zhaojianwei 2363 rBase.getNewBase()->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end,adde by zhaojianwei 2364 } 2365 } 2366 } 2367 } 2368 /* -----------------------------18.04.01 13:29-------------------------------- 2369 2370 ---------------------------------------------------------------------------*/ 2371 void SAL_CALL SwXStyle::SetPropertyValues_Impl( 2372 const uno::Sequence< OUString >& rPropertyNames, 2373 const uno::Sequence< uno::Any >& rValues ) 2374 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 2375 { 2376 if ( !m_pDoc ) 2377 throw uno::RuntimeException(); 2378 2379 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 2380 2381 switch(eFamily) 2382 { 2383 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 2384 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break; 2385 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break; 2386 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break; 2387 default: ; 2388 } 2389 2390 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 2391 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 2392 2393 if(rPropertyNames.getLength() != rValues.getLength()) 2394 { 2395 throw lang::IllegalArgumentException(); 2396 } 2397 2398 const OUString* pNames = rPropertyNames.getConstArray(); 2399 const uno::Any* pValues = rValues.getConstArray(); 2400 SwStyleBase_Impl aBaseImpl(*m_pDoc, sStyleName, &GetDoc()->GetDfltTxtFmtColl()->GetAttrSet()); //UUUU add pDfltTxtFmtColl as parent 2401 2402 if(pBasePool) 2403 { 2404 sal_uInt16 nSaveMask = pBasePool->GetSearchMask(); 2405 pBasePool->SetSearchMask(eFamily); 2406 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 2407 pBasePool->SetSearchMask(eFamily, nSaveMask ); 2408 DBG_ASSERT(pBase, "where is the style?" ); 2409 2410 if(pBase) 2411 aBaseImpl.setNewBase(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase)); 2412 else 2413 throw uno::RuntimeException(); 2414 } 2415 2416 for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) 2417 { 2418 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(pNames[nProp]); 2419 2420 if(!pEntry || 2421 (!bIsConditional && pNames[nProp].equalsAsciiL(SW_PROP_NAME(UNO_NAME_PARA_STYLE_CONDITIONS)))) 2422 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 2423 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) 2424 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 2425 2426 if(aBaseImpl.getNewBase().is()) 2427 { 2428 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, pBasePool, m_pDoc, eFamily); 2429 } 2430 else if(bIsDescriptor) 2431 { 2432 if(!pPropImpl->SetProperty(pNames[nProp], pValues[nProp])) 2433 { 2434 throw lang::IllegalArgumentException(); 2435 } 2436 } 2437 else 2438 { 2439 throw uno::RuntimeException(); 2440 } 2441 } 2442 2443 if(aBaseImpl.HasItemSet()) 2444 { 2445 aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet()); 2446 } 2447 } 2448 2449 void SwXStyle::setPropertyValues( 2450 const uno::Sequence< OUString >& rPropertyNames, 2451 const uno::Sequence< uno::Any >& rValues ) 2452 throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 2453 { 2454 vos::OGuard aGuard(Application::GetSolarMutex()); 2455 2456 // workaround for bad designed API 2457 try 2458 { 2459 SetPropertyValues_Impl( rPropertyNames, rValues ); 2460 } 2461 catch (beans::UnknownPropertyException &rException) 2462 { 2463 // wrap the original (here not allowed) exception in 2464 // a lang::WrappedTargetException that gets thrown instead. 2465 lang::WrappedTargetException aWExc; 2466 aWExc.TargetException <<= rException; 2467 throw aWExc; 2468 } 2469 } 2470 2471 2472 uno::Any lcl_GetStyleProperty( 2473 const SfxItemPropertySimpleEntry& rEntry, 2474 const SfxItemPropertySet& rPropSet, 2475 SwStyleBase_Impl& rBase, 2476 SfxStyleSheetBase* pBase, 2477 SfxStyleFamily eFamily, 2478 SwDoc *pDoc) 2479 throw(uno::RuntimeException) 2480 { 2481 uno::Any aRet; 2482 2483 if(FN_UNO_IS_PHYSICAL == rEntry.nWID) 2484 { 2485 sal_Bool bPhys = pBase != 0; 2486 if(pBase) 2487 { 2488 bPhys = ((SwDocStyleSheet*)pBase)->IsPhysical(); 2489 // The standard character format is not existing physically 2490 if( bPhys && SFX_STYLE_FAMILY_CHAR == eFamily && 2491 ((SwDocStyleSheet*)pBase)->GetCharFmt() && 2492 ((SwDocStyleSheet*)pBase)->GetCharFmt()->IsDefault() ) 2493 bPhys = sal_False; 2494 } 2495 aRet.setValue(&bPhys, ::getBooleanCppuType()); 2496 } 2497 else if(pBase) 2498 { 2499 if(!rBase.getNewBase().is()) 2500 { 2501 rBase.setNewBase(new SwDocStyleSheet( *(SwDocStyleSheet*)pBase )); 2502 } 2503 2504 //UUUU 2505 const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM)); 2506 2507 //UUUU adapted switch logic to a more readable state; removed goto's and made 2508 // execution of standard setting of proerty in ItemSet dependent of this variable 2509 bool bDone(false); 2510 2511 switch(rEntry.nWID) 2512 { 2513 case RES_PAPER_BIN: 2514 { 2515 SfxItemSet& rSet = rBase.GetItemSet(); 2516 rPropSet.getPropertyValue(rEntry, rSet, aRet); 2517 sal_Int8 nBin = 0; 2518 aRet >>= nBin; 2519 if ( nBin == -1 ) 2520 aRet <<= OUString ( RTL_CONSTASCII_USTRINGPARAM ( "[From printer settings]" ) ); 2521 else 2522 { 2523 SfxPrinter *pPrinter = pDoc->getPrinter( false ); 2524 OUString sTmp; 2525 if (pPrinter ) 2526 sTmp = pPrinter->GetPaperBinName ( nBin ); 2527 aRet <<= sTmp; 2528 } 2529 2530 bDone = true; 2531 break; 2532 } 2533 case FN_UNO_NUM_RULES: //Sonderbehandlung fuer das SvxNumRuleItem: 2534 { 2535 const SwNumRule* pRule = rBase.getNewBase()->GetNumRule(); 2536 DBG_ASSERT(pRule, "Wo ist die NumRule?"); 2537 uno::Reference< container::XIndexReplace > xRules = new SwXNumberingRules(*pRule); 2538 2539 aRet.setValue(&xRules, ::getCppuType((uno::Reference<container::XIndexReplace>*)0)); 2540 bDone = true; 2541 break; 2542 } 2543 break; 2544 //case FN_UNO_DEFAULT_OUTLINE_LEVEL: //#outline level,removed by zahojianwei 2545 //{ 2546 // DBG_ASSERT( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" ); 2547 // sal_uInt8 nLevel = rBase.getNewBase()->GetCollection()->GetOutlineLevel(); 2548 // if( nLevel != NO_NUMBERING ) 2549 // aRet <<= static_cast<sal_Int8>( nLevel ); 2550 // bDone = true; 2551 // break; 2552 //} 2553 case RES_PARATR_OUTLINELEVEL: //add by zahojianwei 2554 { 2555 DBG_ASSERT( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" ); 2556 int nLevel = rBase.getNewBase()->GetCollection()->GetAttrOutlineLevel(); 2557 2558 aRet <<= static_cast<sal_Int16>( nLevel ); 2559 bDone = true; 2560 break; 2561 } //<-end,zhaojianwei 2562 case FN_UNO_FOLLOW_STYLE: 2563 { 2564 String aString; 2565 2566 SwStyleNameMapper::FillProgName(rBase.getNewBase()->GetFollow(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True); 2567 aRet <<= OUString( aString ); 2568 bDone = true; 2569 break; 2570 } 2571 case RES_PAGEDESC : 2572 { 2573 if( MID_PAGEDESC_PAGEDESCNAME == nMemberId) 2574 { 2575 // Sonderbehandlung RES_PAGEDESC 2576 const SfxPoolItem* pItem; 2577 if(SFX_ITEM_SET == rBase.GetItemSet().GetItemState( RES_PAGEDESC, sal_True, &pItem ) ) 2578 { 2579 const SwPageDesc* pDesc = ((const SwFmtPageDesc*)pItem)->GetPageDesc(); 2580 if(pDesc) 2581 { 2582 String aString; 2583 SwStyleNameMapper::FillProgName(pDesc->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True ); 2584 aRet <<= OUString( aString ); 2585 } 2586 } 2587 2588 bDone = true; 2589 } 2590 2591 break; 2592 } 2593 case FN_UNO_IS_AUTO_UPDATE: 2594 { 2595 sal_Bool bAuto = sal_False; 2596 if(SFX_STYLE_FAMILY_PARA == eFamily) 2597 bAuto = rBase.getNewBase()->GetCollection()->IsAutoUpdateFmt(); 2598 else if(SFX_STYLE_FAMILY_FRAME == eFamily) 2599 bAuto = rBase.getNewBase()->GetFrmFmt()->IsAutoUpdateFmt(); 2600 aRet.setValue(&bAuto, ::getBooleanCppuType()); 2601 2602 bDone = true; 2603 break; 2604 } 2605 case FN_UNO_DISPLAY_NAME: 2606 { 2607 OUString sName(rBase.getNewBase()->GetDisplayName()); 2608 aRet <<= sName; 2609 2610 bDone = true; 2611 break; 2612 } 2613 case FN_UNO_PARA_STYLE_CONDITIONS: 2614 { 2615 DBG_ASSERT(COND_COMMAND_COUNT == 28, 2616 "invalid size of comman count?"); 2617 //SfxItemSet& rStyleSet = rBase.GetItemSet(); 2618 uno::Sequence< beans::NamedValue > aSeq(COND_COMMAND_COUNT); 2619 beans::NamedValue *pSeq = aSeq.getArray(); 2620 2621 SwFmt *pFmt = ((SwDocStyleSheet*)pBase)->GetCollection(); 2622 const CommandStruct *pCmds = SwCondCollItem::GetCmds(); 2623 for (sal_uInt16 n = 0; n < COND_COMMAND_COUNT; ++n) 2624 { 2625 String aStyleName; 2626 2627 const SwCollCondition* pCond = 0; 2628 if( pFmt && RES_CONDTXTFMTCOLL == pFmt->Which() && 2629 0 != ( pCond = ((SwConditionTxtFmtColl*)pFmt)-> 2630 HasCondition( SwCollCondition( 0, pCmds[n].nCnd, pCmds[n].nSubCond ) ) ) 2631 && pCond->GetTxtFmtColl() ) 2632 { 2633 // get programmatic style name from UI style name 2634 aStyleName = pCond->GetTxtFmtColl()->GetName(); 2635 SwStyleNameMapper::FillProgName(aStyleName, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True); 2636 } 2637 2638 pSeq[n].Name = GetCommandContextByIndex(n); 2639 pSeq[n].Value <<= rtl::OUString( aStyleName ); 2640 } 2641 aRet <<= aSeq; 2642 2643 bDone = true; 2644 break; 2645 } 2646 case FN_UNO_CATEGORY: 2647 { 2648 sal_uInt16 nPoolId = rBase.getNewBase()->GetCollection()->GetPoolFmtId(); 2649 short nRet = -1; 2650 2651 switch ( COLL_GET_RANGE_BITS & nPoolId ) 2652 { 2653 case COLL_TEXT_BITS: 2654 nRet = style::ParagraphStyleCategory::TEXT; 2655 break; 2656 case COLL_DOC_BITS: 2657 nRet = style::ParagraphStyleCategory::CHAPTER; 2658 break; 2659 case COLL_LISTS_BITS: 2660 nRet = style::ParagraphStyleCategory::LIST; 2661 break; 2662 case COLL_REGISTER_BITS: 2663 nRet = style::ParagraphStyleCategory::INDEX; 2664 break; 2665 case COLL_EXTRA_BITS: 2666 nRet = style::ParagraphStyleCategory::EXTRA; 2667 break; 2668 case COLL_HTML_BITS: 2669 nRet = style::ParagraphStyleCategory::HTML; 2670 break; 2671 } 2672 2673 aRet <<= nRet; 2674 bDone = true; 2675 break; 2676 } 2677 case SID_SWREGISTER_COLLECTION: 2678 { 2679 const SwPageDesc *pPageDesc = rBase.getNewBase()->GetPageDesc(); 2680 const SwTxtFmtColl* pCol = 0; 2681 String aString; 2682 if( pPageDesc ) 2683 pCol = pPageDesc->GetRegisterFmtColl(); 2684 if( pCol ) 2685 SwStyleNameMapper::FillProgName( 2686 pCol->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); 2687 2688 aRet <<= OUString ( aString ); 2689 bDone = true; 2690 break; 2691 } 2692 case RES_BACKGROUND: 2693 { 2694 //UUUU 2695 const SfxItemSet& rSet = rBase.GetItemSet(); 2696 const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND)); 2697 2698 if(!aOriginalBrushItem.QueryValue(aRet, nMemberId)) 2699 { 2700 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)"); 2701 } 2702 2703 bDone = true; 2704 break; 2705 } 2706 case OWN_ATTR_FILLBMP_MODE: 2707 { 2708 //UUUU 2709 const SfxItemSet& rSet = rBase.GetItemSet(); 2710 const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&rSet.Get(XATTR_FILLBMP_STRETCH)); 2711 const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&rSet.Get(XATTR_FILLBMP_TILE)); 2712 2713 if( pTileItem && pTileItem->GetValue() ) 2714 { 2715 aRet <<= drawing::BitmapMode_REPEAT; 2716 } 2717 else if( pStretchItem && pStretchItem->GetValue() ) 2718 { 2719 aRet <<= drawing::BitmapMode_STRETCH; 2720 } 2721 else 2722 { 2723 aRet <<= drawing::BitmapMode_NO_REPEAT; 2724 } 2725 2726 bDone = true; 2727 break; 2728 } 2729 default: 2730 { 2731 // nothing to do as default 2732 break; 2733 } 2734 } 2735 2736 if(!bDone) 2737 { 2738 SfxItemSet& rSet = rBase.GetItemSet(); 2739 rPropSet.getPropertyValue(rEntry, rSet, aRet); 2740 2741 //UUUU 2742 if(rEntry.pType && *(rEntry.pType) == ::getCppuType((const sal_Int16*)0) && *(rEntry.pType) != aRet.getValueType()) 2743 { 2744 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here 2745 sal_Int32 nValue = 0; 2746 aRet >>= nValue; 2747 aRet <<= (sal_Int16)nValue; 2748 } 2749 2750 //UUUU check for needed metric translation 2751 if(rEntry.nMemberId & SFX_METRIC_ITEM) 2752 { 2753 bool bDoIt(true); 2754 2755 if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID) 2756 { 2757 // exception: If these ItemTypes are used, do not convert when these are negative 2758 // since this means they are intended as percent values 2759 sal_Int32 nValue = 0; 2760 2761 if(aRet >>= nValue) 2762 { 2763 bDoIt = nValue > 0; 2764 } 2765 } 2766 2767 if(bDoIt && pDoc) 2768 { 2769 const SfxItemPool& rPool = pDoc->GetAttrPool(); 2770 const SfxMapUnit eMapUnit(rPool.GetMetric(rEntry.nWID)); 2771 2772 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 2773 { 2774 SvxUnoConvertToMM(eMapUnit, aRet); 2775 } 2776 } 2777 } 2778 } 2779 } 2780 else 2781 { 2782 throw uno::RuntimeException(); 2783 } 2784 2785 return aRet; 2786 } 2787 /* -----------------------------19.04.01 09:26-------------------------------- 2788 2789 ---------------------------------------------------------------------------*/ 2790 uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl( 2791 const uno::Sequence< OUString > & rPropertyNames ) 2792 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2793 { 2794 if ( !m_pDoc ) 2795 throw uno::RuntimeException(); 2796 2797 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 2798 2799 switch(eFamily) 2800 { 2801 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 2802 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break; 2803 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break; 2804 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break; 2805 default: ; 2806 } 2807 2808 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 2809 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 2810 const OUString* pNames = rPropertyNames.getConstArray(); 2811 uno::Sequence< uno::Any > aRet(rPropertyNames.getLength()); 2812 uno::Any* pRet = aRet.getArray(); 2813 SwStyleBase_Impl aBase(*m_pDoc, sStyleName, &GetDoc()->GetDfltTxtFmtColl()->GetAttrSet()); //UUUU add pDfltTxtFmtColl as parent 2814 SfxStyleSheetBase* pBase = 0; 2815 2816 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) 2817 { 2818 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp]); 2819 if(!pEntry || 2820 (!bIsConditional && pNames[nProp].equalsAsciiL(SW_PROP_NAME(UNO_NAME_PARA_STYLE_CONDITIONS)))) 2821 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 2822 2823 if(pBasePool) 2824 { 2825 if(!pBase) 2826 { 2827 sal_uInt16 nSaveMask = pBasePool->GetSearchMask(); 2828 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL ); 2829 pBase = pBasePool->Find(sStyleName); 2830 pBasePool->SetSearchMask(eFamily, nSaveMask ); 2831 } 2832 2833 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, eFamily, GetDoc() ); 2834 } 2835 else if(bIsDescriptor) 2836 { 2837 uno::Any *pAny = 0; 2838 pPropImpl->GetProperty ( pNames[nProp], pAny ); 2839 if( !pAny ) 2840 { 2841 sal_Bool bExcept = sal_False; 2842 switch( eFamily ) 2843 { 2844 case SFX_STYLE_FAMILY_PSEUDO: 2845 bExcept = sal_True; 2846 break; 2847 case SFX_STYLE_FAMILY_PARA: 2848 case SFX_STYLE_FAMILY_PAGE: 2849 pPropImpl->GetProperty ( pNames[nProp], mxStyleData, pRet[ nProp ] ); 2850 break; 2851 case SFX_STYLE_FAMILY_CHAR: 2852 case SFX_STYLE_FAMILY_FRAME : 2853 { 2854 if (pEntry->nWID >= POOLATTR_BEGIN && pEntry->nWID < RES_UNKNOWNATR_END ) 2855 { 2856 SwFmt * pFmt; 2857 if ( eFamily == SFX_STYLE_FAMILY_CHAR ) 2858 pFmt = m_pDoc->GetDfltCharFmt(); 2859 else 2860 pFmt = m_pDoc->GetDfltFrmFmt(); 2861 const SwAttrPool * pPool = pFmt->GetAttrSet().GetPool(); 2862 const SfxPoolItem & rItem = pPool->GetDefaultItem ( pEntry->nWID ); 2863 rItem.QueryValue ( pRet[nProp], pEntry->nMemberId ); 2864 } 2865 else 2866 bExcept = sal_True; 2867 } 2868 break; 2869 2870 default: 2871 ; 2872 } 2873 if (bExcept ) 2874 { 2875 uno::RuntimeException aExcept; 2876 aExcept.Message = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "No default value for: " ) ) + pNames[nProp]; 2877 throw aExcept; 2878 } 2879 } 2880 else 2881 pRet [ nProp ] = *pAny; 2882 } 2883 else 2884 throw uno::RuntimeException(); 2885 } 2886 return aRet; 2887 } 2888 /* -----------------------------04.11.03 09:26-------------------------------- 2889 2890 ---------------------------------------------------------------------------*/ 2891 uno::Sequence< uno::Any > SwXStyle::getPropertyValues( 2892 const uno::Sequence< OUString >& rPropertyNames ) 2893 throw(uno::RuntimeException) 2894 { 2895 vos::OGuard aGuard(Application::GetSolarMutex()); 2896 uno::Sequence< uno::Any > aValues; 2897 2898 // workaround for bad designed API 2899 try 2900 { 2901 aValues = GetPropertyValues_Impl( rPropertyNames ); 2902 } 2903 catch (beans::UnknownPropertyException &) 2904 { 2905 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 2906 } 2907 catch (lang::WrappedTargetException &) 2908 { 2909 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 2910 } 2911 2912 return aValues; 2913 } 2914 /*-- 18.04.01 13:07:29--------------------------------------------------- 2915 -----------------------------------------------------------------------*/ 2916 void SwXStyle::addPropertiesChangeListener( 2917 const uno::Sequence< OUString >& /*aPropertyNames*/, 2918 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 2919 throw(uno::RuntimeException) 2920 { 2921 } 2922 /*-- 18.04.01 13:07:30--------------------------------------------------- 2923 2924 -----------------------------------------------------------------------*/ 2925 void SwXStyle::removePropertiesChangeListener( 2926 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 2927 throw(uno::RuntimeException) 2928 { 2929 } 2930 /*-- 18.04.01 13:07:30--------------------------------------------------- 2931 2932 -----------------------------------------------------------------------*/ 2933 void SwXStyle::firePropertiesChangeEvent( 2934 const uno::Sequence< OUString >& /*aPropertyNames*/, 2935 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 2936 throw(uno::RuntimeException) 2937 { 2938 } 2939 /*-- 17.12.98 08:26:53--------------------------------------------------- 2940 2941 -----------------------------------------------------------------------*/ 2942 void SwXStyle::setPropertyValue( 2943 const OUString& rPropertyName, 2944 const uno::Any& rValue) 2945 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 2946 { 2947 vos::OGuard aGuard(Application::GetSolarMutex()); 2948 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 2949 const uno::Sequence<uno::Any> aValues(&rValue, 1); 2950 2951 SetPropertyValues_Impl( aProperties, aValues ); 2952 } 2953 /*-- 17.12.98 08:26:53--------------------------------------------------- 2954 2955 -----------------------------------------------------------------------*/ 2956 uno::Any SwXStyle::getPropertyValue( 2957 const OUString& rPropertyName) 2958 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2959 { 2960 vos::OGuard aGuard(Application::GetSolarMutex()); 2961 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 2962 return GetPropertyValues_Impl(aProperties).getConstArray()[0]; 2963 2964 } 2965 /*-- 17.12.98 08:26:53--------------------------------------------------- 2966 2967 -----------------------------------------------------------------------*/ 2968 void SwXStyle::addPropertyChangeListener( 2969 const OUString& /*rPropertyName*/, 2970 const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) 2971 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2972 { 2973 DBG_WARNING("not implemented"); 2974 } 2975 /*-- 17.12.98 08:26:54--------------------------------------------------- 2976 2977 -----------------------------------------------------------------------*/ 2978 void SwXStyle::removePropertyChangeListener( 2979 const OUString& /*rPropertyName*/, 2980 const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) 2981 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2982 { 2983 DBG_WARNING("not implemented"); 2984 } 2985 /*-- 17.12.98 08:26:54--------------------------------------------------- 2986 2987 -----------------------------------------------------------------------*/ 2988 void SwXStyle::addVetoableChangeListener( 2989 const OUString& /*rPropertyName*/, 2990 const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) 2991 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2992 { 2993 DBG_WARNING("not implemented"); 2994 } 2995 /*-- 17.12.98 08:26:54--------------------------------------------------- 2996 2997 -----------------------------------------------------------------------*/ 2998 void SwXStyle::removeVetoableChangeListener( 2999 const OUString& /*rPropertyName*/, 3000 const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) 3001 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 3002 { 3003 DBG_WARNING("not implemented"); 3004 } 3005 3006 /*-- 08.03.99 10:50:26--------------------------------------------------- 3007 3008 -----------------------------------------------------------------------*/ 3009 beans::PropertyState SwXStyle::getPropertyState( 3010 const OUString& rPropertyName) 3011 throw( beans::UnknownPropertyException, uno::RuntimeException ) 3012 { 3013 vos::OGuard aGuard(Application::GetSolarMutex()); 3014 uno::Sequence< OUString > aNames(1); 3015 OUString* pNames = aNames.getArray(); 3016 pNames[0] = rPropertyName; 3017 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames); 3018 return aStates.getConstArray()[0]; 3019 } 3020 /*-- 08.03.99 10:50:27--------------------------------------------------- 3021 3022 -----------------------------------------------------------------------*/ 3023 3024 uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates( 3025 const uno::Sequence< OUString >& rPropertyNames) 3026 throw( beans::UnknownPropertyException, uno::RuntimeException ) 3027 { 3028 vos::OGuard aGuard(Application::GetSolarMutex()); 3029 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength()); 3030 beans::PropertyState* pStates = aRet.getArray(); 3031 3032 if(pBasePool) 3033 { 3034 pBasePool->SetSearchMask(eFamily ); 3035 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 3036 DBG_ASSERT(pBase, "where is the style?" ); 3037 3038 if(pBase) 3039 { 3040 const OUString* pNames = rPropertyNames.getConstArray(); 3041 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 3042 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 3043 3044 switch(eFamily) 3045 { 3046 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 3047 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break; 3048 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break; 3049 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break; 3050 default: ; 3051 } 3052 3053 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 3054 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 3055 const SfxItemSet& rSet = xStyle->GetItemSet(); 3056 3057 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) 3058 { 3059 const String& rPropName = pNames[i]; 3060 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rPropName); 3061 bool bDone(false); 3062 3063 if(!pEntry) 3064 { 3065 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 3066 } 3067 3068 if( FN_UNO_NUM_RULES == pEntry->nWID || FN_UNO_FOLLOW_STYLE == pEntry->nWID ) 3069 { 3070 // handle NumRules first, done 3071 pStates[i] = beans::PropertyState_DIRECT_VALUE; 3072 bDone = true; 3073 } 3074 3075 // allow to retarget the SfxItemSet working on, default correctly. Only 3076 // use pSourceSet below this point (except in header/footer processing) 3077 const SfxItemSet* pSourceSet = &rSet; 3078 3079 if(!bDone) 3080 { 3081 // check for Header/Footer entry 3082 const bool bHeader(SFX_STYLE_FAMILY_PAGE == eFamily && rPropName.EqualsAscii("Header", 0, 6)); 3083 const bool bFooter(SFX_STYLE_FAMILY_PAGE == eFamily && rPropName.EqualsAscii("Footer", 0, 6)); 3084 3085 if(bHeader || bFooter) 3086 { 3087 const SvxSetItem* pSetItem; 3088 3089 if(SFX_ITEM_SET == rSet.GetItemState( 3090 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, 3091 sal_False, 3092 (const SfxPoolItem**)&pSetItem)) 3093 { 3094 // retarget the SfxItemSet to the HeaderFooter SfxSetItem's SfxItenSet 3095 pSourceSet = &pSetItem->GetItemSet(); 3096 } 3097 else 3098 { 3099 // if no SetItem, value is ambigous and we are done 3100 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE; 3101 bDone = true; 3102 } 3103 } 3104 } 3105 3106 if(!bDone && OWN_ATTR_FILLBMP_MODE == pEntry->nWID) 3107 { 3108 //UUUU 3109 if(SFX_ITEM_SET == pSourceSet->GetItemState(XATTR_FILLBMP_STRETCH, false) 3110 || SFX_ITEM_SET == pSourceSet->GetItemState(XATTR_FILLBMP_TILE, false)) 3111 { 3112 pStates[i] = beans::PropertyState_DIRECT_VALUE; 3113 } 3114 else 3115 { 3116 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE; 3117 } 3118 3119 bDone = true; 3120 } 3121 3122 //UUUU for FlyFrames we need to mark all properties from type RES_BACKGROUND 3123 // as beans::PropertyState_DIRECT_VALUE to let users of this property call 3124 // getPropertyValue where the member properties will be mapped from the 3125 // fill attributes to the according SvxBrushItem entries 3126 if(!bDone && RES_BACKGROUND == pEntry->nWID 3127 && SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*pSourceSet)) 3128 { 3129 pStates[i] = beans::PropertyState_DIRECT_VALUE; 3130 bDone = true; 3131 } 3132 3133 if(!bDone) 3134 { 3135 pStates[i] = pPropSet->getPropertyState(*pEntry, *pSourceSet); 3136 3137 if(SFX_STYLE_FAMILY_PAGE == eFamily && SID_ATTR_PAGE_SIZE == pEntry->nWID && beans::PropertyState_DIRECT_VALUE == pStates[i]) 3138 { 3139 const SvxSizeItem& rSize = static_cast <const SvxSizeItem&>( rSet.Get(SID_ATTR_PAGE_SIZE)); 3140 sal_uInt8 nMemberId = pEntry->nMemberId & 0x7f; 3141 3142 if((LONG_MAX == rSize.GetSize().Width() && 3143 (MID_SIZE_WIDTH == nMemberId || 3144 MID_SIZE_SIZE == nMemberId)) || 3145 (LONG_MAX == rSize.GetSize().Height() && 3146 MID_SIZE_HEIGHT == nMemberId)) 3147 { 3148 pStates[i] = beans::PropertyState_DEFAULT_VALUE; 3149 } 3150 } 3151 } 3152 } 3153 } 3154 else 3155 { 3156 throw uno::RuntimeException(); 3157 } 3158 } 3159 else 3160 { 3161 throw uno::RuntimeException(); 3162 } 3163 3164 return aRet; 3165 } 3166 /*-- 08.03.99 10:50:27--------------------------------------------------- 3167 3168 -----------------------------------------------------------------------*/ 3169 void SwXStyle::setPropertyToDefault( 3170 const OUString& rPropertyName) 3171 throw( beans::UnknownPropertyException, uno::RuntimeException ) 3172 { 3173 const uno::Sequence < OUString > aSequence(&rPropertyName,1); 3174 setPropertiesToDefault(aSequence); 3175 } 3176 3177 void SAL_CALL SwXStyle::setPropertiesToDefault( 3178 const uno::Sequence< OUString >& aPropertyNames ) 3179 throw (beans::UnknownPropertyException, uno::RuntimeException) 3180 { 3181 vos::OGuard aGuard(Application::GetSolarMutex()); 3182 SwFmt *pTargetFmt = 0; 3183 3184 if(pBasePool) 3185 { 3186 pBasePool->SetSearchMask(eFamily); 3187 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 3188 DBG_ASSERT(pBase, "Where is the style?"); 3189 3190 if(pBase) 3191 { 3192 rtl::Reference< SwDocStyleSheet > xStyle(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase)); 3193 switch(eFamily) 3194 { 3195 case SFX_STYLE_FAMILY_CHAR: 3196 pTargetFmt = xStyle->GetCharFmt(); 3197 break; 3198 3199 case SFX_STYLE_FAMILY_PARA: 3200 pTargetFmt = xStyle->GetCollection(); 3201 break; 3202 3203 case SFX_STYLE_FAMILY_FRAME: 3204 pTargetFmt = xStyle->GetFrmFmt(); 3205 break; 3206 3207 case SFX_STYLE_FAMILY_PAGE: 3208 { 3209 sal_uInt16 nPgDscPos = USHRT_MAX; 3210 SwPageDesc *pDesc = m_pDoc->FindPageDescByName(xStyle->GetPageDesc()->GetName(),&nPgDscPos); 3211 3212 if(pDesc) 3213 { 3214 pTargetFmt = &pDesc->GetMaster(); 3215 } 3216 break; 3217 } 3218 case SFX_STYLE_FAMILY_PSEUDO: 3219 break; 3220 default: ; 3221 } 3222 } 3223 } 3224 3225 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 3226 3227 switch(eFamily) 3228 { 3229 case SFX_STYLE_FAMILY_PARA: nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 3230 case SFX_STYLE_FAMILY_FRAME: nPropSetId = PROPERTY_MAP_FRAME_STYLE; break; 3231 case SFX_STYLE_FAMILY_PAGE: nPropSetId = PROPERTY_MAP_PAGE_STYLE; break; 3232 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break; 3233 default: ; 3234 } 3235 3236 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 3237 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 3238 const OUString* pNames = aPropertyNames.getConstArray(); 3239 3240 if(pTargetFmt) 3241 { 3242 for(sal_Int32 nProp = 0,nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++) 3243 { 3244 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(pNames[nProp]); 3245 3246 if(!pEntry) 3247 { 3248 throw beans::UnknownPropertyException(OUString(RTL_CONSTASCII_USTRINGPARAM("Property is unknown: ")) + pNames[nProp],static_cast <cppu::OWeakObject *> (this)); 3249 } 3250 3251 if(pEntry->nWID == FN_UNO_FOLLOW_STYLE || pEntry->nWID == FN_UNO_NUM_RULES) 3252 { 3253 throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot reset: ")) + pNames[nProp],static_cast <cppu::OWeakObject *> (this)); 3254 } 3255 3256 if(pEntry->nFlags & beans::PropertyAttribute::READONLY) 3257 { 3258 throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("setPropertiesToDefault: property is read-only: ")) + pNames[nProp],static_cast <cppu::OWeakObject *> (this)); 3259 } 3260 3261 if(pEntry->nWID == RES_PARATR_OUTLINELEVEL) 3262 { 3263 static_cast<SwTxtFmtColl*>(pTargetFmt)->DeleteAssignmentToListLevelOfOutlineStyle(); 3264 } 3265 else 3266 { 3267 pTargetFmt->ResetFmtAttr(pEntry->nWID); 3268 } 3269 3270 if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID) 3271 { 3272 //UUUU 3273 SwDoc* pDoc = pTargetFmt->GetDoc(); 3274 SfxItemSet aSet(pDoc->GetAttrPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 3275 aSet.SetParent(&pTargetFmt->GetAttrSet()); 3276 3277 aSet.ClearItem(XATTR_FILLBMP_STRETCH); 3278 aSet.ClearItem(XATTR_FILLBMP_TILE); 3279 3280 pTargetFmt->SetFmtAttr(aSet); 3281 } 3282 } 3283 } 3284 else if(bIsDescriptor) 3285 { 3286 for(sal_Int32 nProp = 0,nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++) 3287 { 3288 pPropImpl->ClearProperty(pNames[nProp]); 3289 } 3290 } 3291 } 3292 3293 void SAL_CALL SwXStyle::setAllPropertiesToDefault() 3294 throw (uno::RuntimeException) 3295 { 3296 vos::OGuard aGuard(Application::GetSolarMutex()); 3297 3298 if(pBasePool) 3299 { 3300 pBasePool->SetSearchMask(eFamily); 3301 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 3302 DBG_ASSERT(pBase, "where is the style, you fiend!?"); 3303 3304 if(pBase) 3305 { 3306 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 3307 SwFmt *pTargetFmt = 0; 3308 sal_uInt16 nPgDscPos = USHRT_MAX; 3309 3310 switch(eFamily) 3311 { 3312 case SFX_STYLE_FAMILY_CHAR: 3313 pTargetFmt = xStyle->GetCharFmt(); 3314 break; 3315 3316 case SFX_STYLE_FAMILY_PARA: 3317 { 3318 pTargetFmt = xStyle->GetCollection(); 3319 3320 if(xStyle->GetCollection()) 3321 { 3322 // xStyle->GetCollection()->SetOutlineLevel( NO_NUMBERING ); //#outline level,removed by zhaojianwei 3323 xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end,add by zhaojianwei 3324 } 3325 break; 3326 } 3327 3328 case SFX_STYLE_FAMILY_FRAME: 3329 pTargetFmt = xStyle->GetFrmFmt(); 3330 break; 3331 3332 case SFX_STYLE_FAMILY_PAGE: 3333 { 3334 SwPageDesc *pDesc = m_pDoc->FindPageDescByName(xStyle->GetPageDesc()->GetName(),&nPgDscPos); 3335 3336 if(pDesc) 3337 { 3338 pTargetFmt = &pDesc->GetMaster(); 3339 pDesc->SetUseOn(nsUseOnPage::PD_ALL); 3340 } 3341 break; 3342 } 3343 3344 case SFX_STYLE_FAMILY_PSEUDO: 3345 break; 3346 3347 default: ; 3348 } 3349 3350 if(pTargetFmt) 3351 { 3352 if(USHRT_MAX != nPgDscPos) 3353 { 3354 SwPageDesc& rPageDesc = m_pDoc->_GetPageDesc(nPgDscPos); 3355 rPageDesc.ResetAllMasterAttr(); 3356 3357 SvxLRSpaceItem aLR(RES_LR_SPACE); 3358 sal_Int32 nSize = GetMetricVal(CM_1) * 2; 3359 aLR.SetLeft(nSize); 3360 aLR.SetLeft(nSize); 3361 SvxULSpaceItem aUL(RES_UL_SPACE); 3362 aUL.SetUpper(static_cast <sal_uInt16> (nSize)); 3363 aUL.SetLower(static_cast <sal_uInt16> (nSize)); 3364 pTargetFmt->SetFmtAttr(aLR); 3365 pTargetFmt->SetFmtAttr(aUL); 3366 SwPageDesc* pStdPgDsc = m_pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD); 3367 SwFmtFrmSize aFrmSz(ATT_FIX_SIZE); 3368 3369 if(RES_POOLPAGE_STANDARD == rPageDesc.GetPoolFmtId()) 3370 { 3371 if(m_pDoc->getPrinter(false)) 3372 { 3373 const Size aPhysSize(SvxPaperInfo::GetPaperSize( 3374 static_cast<Printer*>(m_pDoc->getPrinter(false)))); 3375 aFrmSz.SetSize(aPhysSize); 3376 } 3377 else 3378 { 3379 // --> OD 2008-07-25 #i91928# 3380 // aFrmSz.SetWidth( LONG_MAX ); 3381 // aFrmSz.SetHeight( LONG_MAX ); 3382 aFrmSz.SetSize(SvxPaperInfo::GetDefaultPaperSize()); 3383 // <-- 3384 } 3385 3386 } 3387 else 3388 { 3389 aFrmSz = pStdPgDsc->GetMaster().GetFrmSize(); 3390 } 3391 3392 if(pStdPgDsc->GetLandscape()) 3393 { 3394 SwTwips nTmp = aFrmSz.GetHeight(); 3395 aFrmSz.SetHeight(aFrmSz.GetWidth()); 3396 aFrmSz.SetWidth(nTmp); 3397 } 3398 3399 pTargetFmt->SetFmtAttr(aFrmSz); 3400 } 3401 else 3402 { 3403 // --> OD 2007-01-25 #i73790# - method renamed 3404 pTargetFmt->ResetAllFmtAttr(); 3405 // <-- 3406 } 3407 3408 if(USHRT_MAX != nPgDscPos) 3409 { 3410 m_pDoc->ChgPageDesc(nPgDscPos, const_cast<const SwDoc *>(m_pDoc)->GetPageDesc(nPgDscPos)); 3411 } 3412 } 3413 3414 } 3415 else 3416 { 3417 throw uno::RuntimeException(); 3418 } 3419 } 3420 else if(bIsDescriptor) 3421 { 3422 pPropImpl->ClearAllProperties(); 3423 } 3424 else 3425 { 3426 throw uno::RuntimeException(); 3427 } 3428 } 3429 3430 uno::Sequence< uno::Any > SAL_CALL SwXStyle::getPropertyDefaults( 3431 const uno::Sequence< OUString >& aPropertyNames ) 3432 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 3433 { 3434 vos::OGuard aGuard(Application::GetSolarMutex()); 3435 sal_Int32 nCount = aPropertyNames.getLength(); 3436 uno::Sequence < uno::Any > aRet(nCount); 3437 3438 if(nCount) 3439 { 3440 if(pBasePool) 3441 { 3442 pBasePool->SetSearchMask(eFamily); 3443 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 3444 DBG_ASSERT(pBase,"Doesn't seem to be a style!"); 3445 3446 if(pBase) 3447 { 3448 rtl::Reference< SwDocStyleSheet > xStyle(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase)); 3449 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 3450 3451 switch(eFamily) 3452 { 3453 case SFX_STYLE_FAMILY_PARA: nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 3454 case SFX_STYLE_FAMILY_FRAME: nPropSetId = PROPERTY_MAP_FRAME_STYLE; break; 3455 case SFX_STYLE_FAMILY_PAGE: nPropSetId = PROPERTY_MAP_PAGE_STYLE; break; 3456 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break; 3457 default: ; 3458 } 3459 3460 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 3461 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap(); 3462 const SfxItemSet &rSet = xStyle->GetItemSet(),*pParentSet = rSet.GetParent(); 3463 const OUString *pNames = aPropertyNames.getConstArray(); 3464 uno::Any *pRet = aRet.getArray(); 3465 3466 for(sal_Int32 i = 0; i < nCount; i++) 3467 { 3468 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(pNames[i]); 3469 3470 if(!pEntry) 3471 { 3472 throw beans::UnknownPropertyException(OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + pNames[i],static_cast <cppu::OWeakObject *> (this)); 3473 } 3474 3475 if(pParentSet) 3476 { 3477 aSwMapProvider.GetPropertySet(nPropSetId)->getPropertyValue(pNames[i],*pParentSet,pRet[i]); 3478 } 3479 else if(pEntry->nWID != rSet.GetPool()->GetSlotId(pEntry->nWID)) 3480 { 3481 const SfxPoolItem& rItem = rSet.GetPool()->GetDefaultItem(pEntry->nWID); 3482 3483 rItem.QueryValue(pRet[i], pEntry->nMemberId); 3484 } 3485 } 3486 } 3487 else 3488 { 3489 throw uno::RuntimeException(); 3490 } 3491 } 3492 else 3493 { 3494 throw uno::RuntimeException(); 3495 } 3496 } 3497 return aRet; 3498 } 3499 /*-- 08.03.99 10:50:27--------------------------------------------------- 3500 3501 -----------------------------------------------------------------------*/ 3502 uno::Any SwXStyle::getPropertyDefault( 3503 const OUString& rPropertyName) 3504 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 3505 { 3506 const uno::Sequence < OUString > aSequence(&rPropertyName,1); 3507 return getPropertyDefaults(aSequence).getConstArray()[0]; 3508 } 3509 /* -----------------21.01.99 13:08------------------- 3510 * 3511 * --------------------------------------------------*/ 3512 void SwXStyle::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 3513 { 3514 SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint ); 3515 if( pHint ) 3516 { 3517 if(( pHint->GetId() & SFX_HINT_DYING ) || ( pHint->GetId() & SFX_STYLESHEET_ERASED)) 3518 { 3519 pBasePool = 0; 3520 EndListening(rBC); 3521 } 3522 else if( pHint->GetId() &(SFX_STYLESHEET_CHANGED|SFX_STYLESHEET_ERASED) ) 3523 { 3524 ((SfxStyleSheetBasePool&)rBC).SetSearchMask(eFamily); 3525 SfxStyleSheetBase* pOwnBase = ((SfxStyleSheetBasePool&)rBC).Find(sStyleName); 3526 if(!pOwnBase) 3527 { 3528 EndListening(rBC); 3529 Invalidate(); 3530 } 3531 } 3532 } 3533 } 3534 /* -----------------------------15.08.00 11:35-------------------------------- 3535 3536 ---------------------------------------------------------------------------*/ 3537 void SwXStyle::Invalidate() 3538 { 3539 sStyleName.Erase(); 3540 pBasePool = 0; 3541 m_pDoc = 0; 3542 mxStyleData.clear(); 3543 mxStyleFamily.clear(); 3544 } 3545 3546 3547 /****************************************************************** 3548 * SwXPageStyle 3549 ******************************************************************/ 3550 /*-- 17.12.98 08:43:35--------------------------------------------------- 3551 3552 -----------------------------------------------------------------------*/ 3553 SwXPageStyle::SwXPageStyle( 3554 SfxStyleSheetBasePool& rPool, 3555 SwDocShell* pDocSh, SfxStyleFamily eFam, 3556 const String& rStyleName) 3557 : SwXStyle(rPool, eFam, pDocSh->GetDoc(), rStyleName), 3558 pDocShell(pDocSh) 3559 { 3560 } 3561 /* -----------------23.08.99 15:52------------------- 3562 3563 --------------------------------------------------*/ 3564 SwXPageStyle::SwXPageStyle(SwDocShell* pDocSh) 3565 : SwXStyle(pDocSh->GetDoc(), SFX_STYLE_FAMILY_PAGE), 3566 pDocShell(pDocSh) 3567 { 3568 } 3569 3570 /*-- 17.12.98 08:43:35--------------------------------------------------- 3571 3572 -----------------------------------------------------------------------*/ 3573 SwXPageStyle::~SwXPageStyle() 3574 { 3575 3576 } 3577 /* -----------------------------18.04.01 13:50-------------------------------- 3578 3579 ---------------------------------------------------------------------------*/ 3580 void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( 3581 const uno::Sequence< OUString >& rPropertyNames, 3582 const uno::Sequence< uno::Any >& rValues ) 3583 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 3584 { 3585 if(!GetDoc()) 3586 throw uno::RuntimeException(); 3587 3588 if(rPropertyNames.getLength() != rValues.getLength()) 3589 throw lang::IllegalArgumentException(); 3590 3591 const OUString* pNames = rPropertyNames.getConstArray(); 3592 const uno::Any* pValues = rValues.getConstArray(); 3593 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE); 3594 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap(); 3595 SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrmFmt()->GetAttrSet()); //UUUU add pDfltFrmFmt as parent 3596 3597 if(GetBasePool()) 3598 { 3599 sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask(); 3600 GetBasePool()->SetSearchMask(GetFamily()); 3601 SfxStyleSheetBase* pBase = GetBasePool()->Find(GetStyleName()); 3602 GetBasePool()->SetSearchMask(GetFamily(), nSaveMask ); 3603 DBG_ASSERT(pBase, "where is the style?" ); 3604 3605 if(pBase) 3606 { 3607 aBaseImpl.setNewBase(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase)); 3608 } 3609 else 3610 { 3611 throw uno::RuntimeException(); 3612 } 3613 } 3614 3615 for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) 3616 { 3617 const String& rPropName = pNames[nProp]; 3618 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rPropName ); 3619 3620 if (!pEntry) 3621 { 3622 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 3623 } 3624 3625 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) 3626 { 3627 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 3628 } 3629 3630 if(GetBasePool()) 3631 { 3632 switch(pEntry->nWID) 3633 { 3634 case SID_ATTR_PAGE_ON: 3635 case RES_BACKGROUND: 3636 case RES_BOX: 3637 case RES_LR_SPACE: 3638 case RES_SHADOW: 3639 case RES_UL_SPACE: 3640 case SID_ATTR_PAGE_DYNAMIC: 3641 case SID_ATTR_PAGE_SHARED: 3642 case SID_ATTR_PAGE_SIZE: 3643 case RES_HEADER_FOOTER_EAT_SPACING: 3644 { 3645 // these entries are used in Header, Footer and (partially) in the PageStyle itself. 3646 // Check for Header/Footer entry 3647 const bool bHeader(rPropName.EqualsAscii("Header", 0, 6)); 3648 const bool bFooter(rPropName.EqualsAscii("Footer", 0, 6)); 3649 3650 if(bHeader || bFooter) 3651 { 3652 // it is a Header/Footer entry, access the SvxSetItem containing it's information 3653 const SvxSetItem* pSetItem = 0; 3654 3655 if(SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, sal_False, (const SfxPoolItem**)&pSetItem)) 3656 { 3657 // create a new SvxSetItem and get it's ItemSet as new target 3658 SvxSetItem* pNewSetItem = static_cast< SvxSetItem* >(pSetItem->Clone()); 3659 SfxItemSet& rSetSet = pNewSetItem->GetItemSet(); 3660 3661 // set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem 3662 rSetSet.SetParent(&GetDoc()->GetDfltFrmFmt()->GetAttrSet()); 3663 3664 // replace the used SfxItemSet at the SwStyleBase_Impl temporarily and use the 3665 // default method to set the property 3666 SfxItemSet* pRememberItemSet = aBaseImpl.replaceItemSet(&rSetSet); 3667 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); 3668 aBaseImpl.replaceItemSet(pRememberItemSet); 3669 3670 // reset paret at ItemSet from SetItem 3671 rSetSet.SetParent(0); 3672 3673 // set the new SvxSetItem at the real target and delete it 3674 aBaseImpl.GetItemSet().Put(*pNewSetItem); 3675 delete pNewSetItem; 3676 } 3677 else if(pEntry->nWID == SID_ATTR_PAGE_ON) 3678 { 3679 sal_Bool bVal = *(sal_Bool*)pValues[nProp].getValue(); 3680 3681 if(bVal) 3682 { 3683 // Header/footer gets switched on, create defauts and the needed SfxSetItem 3684 SfxItemSet aTempSet(*aBaseImpl.GetItemSet().GetPool(), 3685 RES_FRMATR_BEGIN,RES_FRMATR_END - 1, // [82 3686 3687 //UUUU FillAttribute support 3688 XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014 3689 3690 SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER, // [10023 3691 SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE, // [10051 3692 SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED, // [10060 3693 0); 3694 3695 //UUUU set correct parent to get the XFILL_NONE FillStyle as needed 3696 aTempSet.SetParent(&GetDoc()->GetDfltFrmFmt()->GetAttrSet()); 3697 3698 aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_ON, sal_True)); 3699 aTempSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(MM50, MM50))); 3700 aTempSet.Put(SvxLRSpaceItem(RES_LR_SPACE)); 3701 aTempSet.Put(SvxULSpaceItem(RES_UL_SPACE)); 3702 aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED, sal_True)); 3703 aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_DYNAMIC, sal_True)); 3704 3705 SvxSetItem aNewSetItem(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, aTempSet); 3706 aBaseImpl.GetItemSet().Put(aNewSetItem); 3707 } 3708 } 3709 } 3710 else 3711 { 3712 switch(pEntry->nWID) 3713 { 3714 case SID_ATTR_PAGE_DYNAMIC: 3715 case SID_ATTR_PAGE_SHARED: 3716 case SID_ATTR_PAGE_ON: 3717 case RES_HEADER_FOOTER_EAT_SPACING: 3718 { 3719 // these slots are exclusive to Header/Footer, thus this is an error 3720 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 3721 break; 3722 } 3723 default: 3724 { 3725 // part of PageStyle, fallback to default 3726 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); 3727 } 3728 } 3729 } 3730 3731 break; 3732 } 3733 3734 case XATTR_FILLBMP_SIZELOG: 3735 case XATTR_FILLBMP_TILEOFFSETX: 3736 case XATTR_FILLBMP_TILEOFFSETY: 3737 case XATTR_FILLBMP_POSOFFSETX: 3738 case XATTR_FILLBMP_POSOFFSETY: 3739 case XATTR_FILLBMP_POS: 3740 case XATTR_FILLBMP_SIZEX: 3741 case XATTR_FILLBMP_SIZEY: 3742 case XATTR_FILLBMP_STRETCH: 3743 case XATTR_FILLBMP_TILE: 3744 case OWN_ATTR_FILLBMP_MODE: 3745 case XATTR_FILLCOLOR: 3746 case XATTR_FILLBACKGROUND: 3747 case XATTR_FILLBITMAP: 3748 case XATTR_GRADIENTSTEPCOUNT: 3749 case XATTR_FILLGRADIENT: 3750 case XATTR_FILLHATCH: 3751 case XATTR_FILLSTYLE: 3752 case XATTR_FILLTRANSPARENCE: 3753 case XATTR_FILLFLOATTRANSPARENCE: 3754 case XATTR_SECONDARYFILLCOLOR: 3755 { 3756 // This DrawingLayer FillStyle attributes can be part of Header, Footer and PageStyle 3757 // itself, so decide what to do using the name 3758 const bool bHeader(rPropName.EqualsAscii("Header", 0, 6)); 3759 const bool bFooter(rPropName.EqualsAscii("Footer", 0, 6)); 3760 3761 if(bHeader || bFooter) 3762 { 3763 const SvxSetItem* pSetItem = 0; 3764 3765 if(SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, sal_False, (const SfxPoolItem**)&pSetItem)) 3766 { 3767 // create a new SvxSetItem and get it's ItemSet as new target 3768 SvxSetItem* pNewSetItem = static_cast< SvxSetItem* >(pSetItem->Clone()); 3769 SfxItemSet& rSetSet = pNewSetItem->GetItemSet(); 3770 3771 // set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem 3772 rSetSet.SetParent(&GetDoc()->GetDfltFrmFmt()->GetAttrSet()); 3773 3774 // replace the used SfxItemSet at the SwStyleBase_Impl temporarily and use the 3775 // default method to set the property 3776 SfxItemSet* pRememberItemSet = aBaseImpl.replaceItemSet(&rSetSet); 3777 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); 3778 aBaseImpl.replaceItemSet(pRememberItemSet); 3779 3780 // reset paret at ItemSet from SetItem 3781 rSetSet.SetParent(0); 3782 3783 // set the new SvxSetItem at the real target and delete it 3784 aBaseImpl.GetItemSet().Put(*pNewSetItem); 3785 delete pNewSetItem; 3786 } 3787 } 3788 else 3789 { 3790 // part of PageStyle, fallback to default 3791 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); 3792 } 3793 3794 break; 3795 } 3796 3797 case FN_PARAM_FTN_INFO : 3798 { 3799 const SfxPoolItem& rItem = aBaseImpl.GetItemSet().Get(FN_PARAM_FTN_INFO); 3800 SfxPoolItem* pNewFtnItem = rItem.Clone(); 3801 sal_Bool bPut = pNewFtnItem->PutValue(pValues[nProp], pEntry->nMemberId); 3802 aBaseImpl.GetItemSet().Put(*pNewFtnItem); 3803 delete pNewFtnItem; 3804 if(!bPut) 3805 throw lang::IllegalArgumentException(); 3806 3807 break; 3808 } 3809 3810 case FN_UNO_HEADER : 3811 case FN_UNO_HEADER_LEFT : 3812 case FN_UNO_HEADER_RIGHT : 3813 case FN_UNO_FOOTER : 3814 case FN_UNO_FOOTER_LEFT : 3815 case FN_UNO_FOOTER_RIGHT : 3816 { 3817 throw lang::IllegalArgumentException(); 3818 break; 3819 } 3820 3821 default: 3822 { 3823 //UUUU 3824 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); 3825 break; 3826 } 3827 } 3828 } 3829 else if(IsDescriptor()) 3830 { 3831 if(!GetPropImpl()->SetProperty(rPropName, pValues[nProp])) 3832 throw lang::IllegalArgumentException(); 3833 } 3834 else 3835 { 3836 throw uno::RuntimeException(); 3837 } 3838 } 3839 3840 if(aBaseImpl.HasItemSet()) 3841 { 3842 ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo()); 3843 3844 if (undoGuard.UndoWasEnabled()) 3845 { 3846 // Fix i64460: as long as Undo of page styles with header/footer causes trouble... 3847 GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj(); 3848 } 3849 3850 aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet()); 3851 } 3852 } 3853 3854 void SwXPageStyle::setPropertyValues( 3855 const uno::Sequence< OUString >& rPropertyNames, 3856 const uno::Sequence< uno::Any >& rValues ) 3857 throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 3858 { 3859 vos::OGuard aGuard(Application::GetSolarMutex()); 3860 3861 // workaround for bad designed API 3862 try 3863 { 3864 SetPropertyValues_Impl( rPropertyNames, rValues ); 3865 } 3866 catch (beans::UnknownPropertyException &rException) 3867 { 3868 // wrap the original (here not allowed) exception in 3869 // a lang::WrappedTargetException that gets thrown instead. 3870 lang::WrappedTargetException aWExc; 3871 aWExc.TargetException <<= rException; 3872 throw aWExc; 3873 } 3874 } 3875 /* -----------------------------04.11.03 13:50-------------------------------- 3876 3877 ---------------------------------------------------------------------------*/ 3878 static uno::Reference<text::XText> lcl_makeHeaderFooter( 3879 const sal_uInt16 nRes, 3880 const bool bHeader, 3881 SwFrmFmt const*const pFrmFmt) 3882 { 3883 if (!pFrmFmt) { return 0; } 3884 3885 const SfxItemSet& rSet = pFrmFmt->GetAttrSet(); 3886 const SfxPoolItem* pItem; 3887 if (SFX_ITEM_SET == rSet.GetItemState(nRes, sal_True, &pItem)) 3888 { 3889 SwFrmFmt *const pHeadFootFmt = (bHeader) 3890 ? static_cast<SwFmtHeader*>(const_cast<SfxPoolItem*>(pItem))-> 3891 GetHeaderFmt() 3892 : static_cast<SwFmtFooter*>(const_cast<SfxPoolItem*>(pItem))-> 3893 GetFooterFmt(); 3894 if (pHeadFootFmt) 3895 { 3896 return SwXHeadFootText::CreateXHeadFootText(*pHeadFootFmt, bHeader); 3897 } 3898 } 3899 return 0; 3900 } 3901 3902 uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( 3903 const uno::Sequence< OUString >& rPropertyNames ) 3904 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 3905 { 3906 if(!GetDoc()) 3907 throw uno::RuntimeException(); 3908 3909 sal_Int32 nLength = rPropertyNames.getLength(); 3910 const OUString* pNames = rPropertyNames.getConstArray(); 3911 uno::Sequence< uno::Any > aRet ( nLength ); 3912 uno::Any* pRet = aRet.getArray(); 3913 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE); 3914 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap(); 3915 SwStyleBase_Impl aBase(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrmFmt()->GetAttrSet()); //UUUU add pDfltFrmFmt as parent 3916 SfxStyleSheetBase* pBase = 0; 3917 3918 for(sal_Int32 nProp = 0; nProp < nLength; nProp++) 3919 { 3920 const String& rPropName = pNames[nProp]; 3921 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rPropName ); 3922 3923 if (!pEntry) 3924 { 3925 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 3926 } 3927 3928 if(GetBasePool()) 3929 { 3930 if(!pBase) 3931 { 3932 sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask(); 3933 GetBasePool()->SetSearchMask(GetFamily(), SFXSTYLEBIT_ALL ); 3934 pBase = GetBasePool()->Find(GetStyleName()); 3935 GetBasePool()->SetSearchMask(GetFamily(), nSaveMask ); 3936 } 3937 3938 sal_uInt16 nRes = 0; 3939 sal_Bool bAll = sal_False, bLeft = sal_False, bRight = sal_False; 3940 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM)); 3941 3942 switch(pEntry->nWID) 3943 { 3944 case SID_ATTR_PAGE_ON: 3945 case RES_BACKGROUND: 3946 case RES_BOX: 3947 case RES_LR_SPACE: 3948 case RES_SHADOW: 3949 case RES_UL_SPACE: 3950 case SID_ATTR_PAGE_DYNAMIC: 3951 case SID_ATTR_PAGE_SHARED: 3952 case SID_ATTR_PAGE_SIZE: 3953 case RES_HEADER_FOOTER_EAT_SPACING: 3954 { 3955 // These slots are used for Header, Footer and (partially) for PageStyle directly. 3956 // Check for Header/Footer entry 3957 const bool bHeader(rPropName.EqualsAscii("Header", 0, 6)); 3958 const bool bFooter(rPropName.EqualsAscii("Footer", 0, 6)); 3959 3960 if(bHeader || bFooter) 3961 { 3962 // slot is a Header/Footer slot 3963 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 3964 const SfxItemSet& rSet = xStyle->GetItemSet(); 3965 const SvxSetItem* pSetItem; 3966 3967 if(SFX_ITEM_SET == rSet.GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, sal_False, (const SfxPoolItem**)&pSetItem)) 3968 { 3969 // get from SfxItemSet of the corresponding SfxSetItem 3970 const SfxItemSet& rSetSet = pSetItem->GetItemSet(); 3971 SfxItemSet* pRememberItemSet = aBase.replaceItemSet(&const_cast< SfxItemSet& >(rSetSet)); 3972 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() ); 3973 aBase.replaceItemSet(pRememberItemSet); 3974 } 3975 else if(pEntry->nWID == SID_ATTR_PAGE_ON) 3976 { 3977 // header/footer is not available, thus off. Default is sal_False, though 3978 sal_Bool bRet = sal_False; 3979 pRet[nProp].setValue(&bRet, ::getCppuBooleanType()); 3980 } 3981 } 3982 else 3983 { 3984 switch(pEntry->nWID) 3985 { 3986 case SID_ATTR_PAGE_DYNAMIC: 3987 case SID_ATTR_PAGE_SHARED: 3988 case SID_ATTR_PAGE_ON: 3989 case RES_HEADER_FOOTER_EAT_SPACING: 3990 { 3991 // these slots are exclusive to Header/Footer, thus this is an error 3992 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 3993 break; 3994 } 3995 default: 3996 { 3997 // part of PageStyle, fallback to default 3998 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() ); 3999 } 4000 } 4001 } 4002 4003 break; 4004 } 4005 4006 case XATTR_FILLBMP_SIZELOG: 4007 case XATTR_FILLBMP_TILEOFFSETX: 4008 case XATTR_FILLBMP_TILEOFFSETY: 4009 case XATTR_FILLBMP_POSOFFSETX: 4010 case XATTR_FILLBMP_POSOFFSETY: 4011 case XATTR_FILLBMP_POS: 4012 case XATTR_FILLBMP_SIZEX: 4013 case XATTR_FILLBMP_SIZEY: 4014 case XATTR_FILLBMP_STRETCH: 4015 case XATTR_FILLBMP_TILE: 4016 case OWN_ATTR_FILLBMP_MODE: 4017 case XATTR_FILLCOLOR: 4018 case XATTR_FILLBACKGROUND: 4019 case XATTR_FILLBITMAP: 4020 case XATTR_GRADIENTSTEPCOUNT: 4021 case XATTR_FILLGRADIENT: 4022 case XATTR_FILLHATCH: 4023 case XATTR_FILLSTYLE: 4024 case XATTR_FILLTRANSPARENCE: 4025 case XATTR_FILLFLOATTRANSPARENCE: 4026 case XATTR_SECONDARYFILLCOLOR: 4027 { 4028 // This DrawingLayer FillStyle attributes can be part of Header, Footer and PageStyle 4029 // itself, so decide what to do using the name 4030 const bool bHeader(rPropName.EqualsAscii("Header", 0, 6)); 4031 const bool bFooter(rPropName.EqualsAscii("Footer", 0, 6)); 4032 4033 if(bHeader || bFooter) 4034 { 4035 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 4036 const SfxItemSet& rSet = xStyle->GetItemSet(); 4037 const SvxSetItem* pSetItem; 4038 4039 if(SFX_ITEM_SET == rSet.GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, sal_False, (const SfxPoolItem**)&pSetItem)) 4040 { 4041 // set at SfxItemSet of the corresponding SfxSetItem 4042 const SfxItemSet& rSetSet = pSetItem->GetItemSet(); 4043 SfxItemSet* pRememberItemSet = aBase.replaceItemSet(&const_cast< SfxItemSet& >(rSetSet)); 4044 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() ); 4045 aBase.replaceItemSet(pRememberItemSet); 4046 } 4047 } 4048 else 4049 { 4050 // part of PageStyle, fallback to default 4051 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() ); 4052 } 4053 4054 break; 4055 } 4056 4057 case FN_UNO_HEADER: 4058 case FN_UNO_HEADER_LEFT: 4059 case FN_UNO_HEADER_RIGHT: 4060 case FN_UNO_FOOTER: 4061 case FN_UNO_FOOTER_LEFT: 4062 case FN_UNO_FOOTER_RIGHT: 4063 { 4064 //UUUU cleanups for readability (undos removed, rearranged) 4065 bool bHeader(false); 4066 4067 switch(pEntry->nWID) 4068 { 4069 case FN_UNO_HEADER: bHeader = true; nRes = RES_HEADER; bAll = sal_True; break; 4070 case FN_UNO_HEADER_LEFT: bHeader = true; nRes = RES_HEADER; bLeft = sal_True; break; 4071 case FN_UNO_HEADER_RIGHT: bHeader = true; nRes = RES_HEADER; bRight = sal_True; break; 4072 case FN_UNO_FOOTER: bHeader = false; nRes = RES_FOOTER; bAll = sal_True; break; 4073 case FN_UNO_FOOTER_LEFT: bHeader = false; nRes = RES_FOOTER; bLeft = sal_True; break; 4074 case FN_UNO_FOOTER_RIGHT: bHeader = false; nRes = RES_FOOTER; bRight = sal_True; break; 4075 default: break; 4076 } 4077 4078 const SwPageDesc& rDesc = aBase.GetOldPageDesc(); 4079 const SwFrmFmt* pFrmFmt = 0; 4080 sal_Bool bShare = (bHeader && rDesc.IsHeaderShared()) || (!bHeader && rDesc.IsFooterShared()); 4081 // TextLeft returns the left content if there is one, 4082 // Text and TextRight return the master content. 4083 // TextRight does the same as Text and is for 4084 // comptability only. 4085 if( bLeft && !bShare ) 4086 { 4087 pFrmFmt = &rDesc.GetLeft(); 4088 } 4089 else 4090 { 4091 pFrmFmt = &rDesc.GetMaster(); 4092 } 4093 const uno::Reference< text::XText > xRet = 4094 lcl_makeHeaderFooter(nRes, bHeader, pFrmFmt); 4095 if (xRet.is()) 4096 { 4097 pRet[nProp] <<= xRet; 4098 } 4099 4100 break; 4101 } 4102 4103 case FN_PARAM_FTN_INFO : 4104 { 4105 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 4106 const SfxItemSet& rSet = xStyle->GetItemSet(); 4107 const SfxPoolItem& rItem = rSet.Get(FN_PARAM_FTN_INFO); 4108 rItem.QueryValue(pRet[nProp], nMemberId); 4109 break; 4110 } 4111 4112 default: 4113 { 4114 //UUUU 4115 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() ); 4116 break; 4117 } 4118 } 4119 } 4120 else if(IsDescriptor()) 4121 { 4122 uno::Any* pAny = 0; 4123 GetPropImpl()->GetProperty(rPropName, pAny); 4124 4125 if ( !pAny ) 4126 { 4127 GetPropImpl()->GetProperty ( rPropName, mxStyleData, pRet[ nProp ] ); 4128 } 4129 else 4130 { 4131 pRet[nProp] = *pAny; 4132 } 4133 } 4134 else 4135 { 4136 throw uno::RuntimeException(); 4137 } 4138 } 4139 4140 return aRet; 4141 } 4142 /* -----------------------------18.04.01 13:50-------------------------------- 4143 4144 ---------------------------------------------------------------------------*/ 4145 uno::Sequence< uno::Any > SwXPageStyle::getPropertyValues( 4146 const uno::Sequence< OUString >& rPropertyNames ) 4147 throw(uno::RuntimeException) 4148 { 4149 vos::OGuard aGuard(Application::GetSolarMutex()); 4150 uno::Sequence< uno::Any > aValues; 4151 4152 // workaround for bad designed API 4153 try 4154 { 4155 aValues = GetPropertyValues_Impl( rPropertyNames ); 4156 } 4157 catch (beans::UnknownPropertyException &) 4158 { 4159 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 4160 } 4161 catch (lang::WrappedTargetException &) 4162 { 4163 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 4164 } 4165 4166 return aValues; 4167 } 4168 /*-- 17.12.98 08:43:36--------------------------------------------------- 4169 4170 -----------------------------------------------------------------------*/ 4171 uno::Any SwXPageStyle::getPropertyValue( 4172 const OUString& rPropertyName) 4173 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 4174 { 4175 vos::OGuard aGuard(Application::GetSolarMutex()); 4176 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 4177 4178 return GetPropertyValues_Impl(aProperties).getConstArray()[0]; 4179 } 4180 /*-- 17.12.98 08:43:36--------------------------------------------------- 4181 4182 -----------------------------------------------------------------------*/ 4183 void SwXPageStyle::setPropertyValue( 4184 const OUString& rPropertyName, 4185 const uno::Any& rValue) 4186 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 4187 { 4188 vos::OGuard aGuard(Application::GetSolarMutex()); 4189 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 4190 const uno::Sequence<uno::Any> aValues(&rValue, 1); 4191 4192 SetPropertyValues_Impl( aProperties, aValues ); 4193 } 4194 4195 SwXFrameStyle::SwXFrameStyle ( SwDoc *pDoc ) 4196 : SwXStyle ( pDoc, SFX_STYLE_FAMILY_FRAME, sal_False) 4197 { 4198 } 4199 /* -----------------------------15.12.00 15:45-------------------------------- 4200 4201 ---------------------------------------------------------------------------*/ 4202 SwXFrameStyle::~SwXFrameStyle() 4203 { 4204 } 4205 /* -----------------------------15.12.00 14:30-------------------------------- 4206 4207 ---------------------------------------------------------------------------*/ 4208 uno::Sequence< uno::Type > SwXFrameStyle::getTypes( ) throw(uno::RuntimeException) 4209 { 4210 uno::Sequence< uno::Type > aTypes = SwXStyle::getTypes(); 4211 sal_Int32 nLen = aTypes.getLength(); 4212 aTypes.realloc(nLen + 1); 4213 aTypes.getArray()[nLen] = ::getCppuType((uno::Reference<XEventsSupplier>*)0); 4214 return aTypes; 4215 } 4216 /* -----------------------------15.12.00 14:30-------------------------------- 4217 4218 ---------------------------------------------------------------------------*/ 4219 uno::Any SwXFrameStyle::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException) 4220 { 4221 uno::Any aRet; 4222 if(rType == ::getCppuType((uno::Reference<XEventsSupplier>*)0)) 4223 aRet <<= uno::Reference<XEventsSupplier>(this); 4224 else 4225 aRet = SwXStyle::queryInterface(rType); 4226 return aRet; 4227 } 4228 /* -----------------------------15.12.00 14:30-------------------------------- 4229 4230 ---------------------------------------------------------------------------*/ 4231 uno::Reference< container::XNameReplace > SwXFrameStyle::getEvents( ) throw(uno::RuntimeException) 4232 { 4233 return new SwFrameStyleEventDescriptor( *this ); 4234 } 4235 /*-- 19.05.2006 11:23:55--------------------------------------------------- 4236 4237 -----------------------------------------------------------------------*/ 4238 SwXAutoStyles::SwXAutoStyles(SwDocShell& rDocShell) : 4239 SwUnoCollection(rDocShell.GetDoc()), pDocShell( &rDocShell ) 4240 { 4241 } 4242 /*-- 19.05.2006 11:23:56--------------------------------------------------- 4243 4244 -----------------------------------------------------------------------*/ 4245 SwXAutoStyles::~SwXAutoStyles() 4246 { 4247 } 4248 /*-- 19.05.2006 11:23:57--------------------------------------------------- 4249 4250 -----------------------------------------------------------------------*/ 4251 sal_Int32 SwXAutoStyles::getCount(void) throw( uno::RuntimeException ) 4252 { 4253 return AUTOSTYLE_FAMILY_COUNT; 4254 } 4255 /*-- 19.05.2006 11:23:57--------------------------------------------------- 4256 4257 -----------------------------------------------------------------------*/ 4258 uno::Any SwXAutoStyles::getByIndex(sal_Int32 nIndex) 4259 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, 4260 uno::RuntimeException ) 4261 { 4262 vos::OGuard aGuard(Application::GetSolarMutex()); 4263 uno::Any aRet; 4264 if(nIndex < 0 || nIndex >= AUTOSTYLE_FAMILY_COUNT) 4265 throw lang::IndexOutOfBoundsException(); 4266 if(IsValid()) 4267 { 4268 uno::Reference< style::XAutoStyleFamily > aRef; 4269 IStyleAccess::SwAutoStyleFamily nType = aAutoStyleByIndex[nIndex]; 4270 switch( nType ) 4271 { 4272 case IStyleAccess::AUTO_STYLE_CHAR: 4273 { 4274 if(!xAutoCharStyles.is()) 4275 xAutoCharStyles = new SwXAutoStyleFamily(pDocShell, nType); 4276 aRef = xAutoCharStyles; 4277 } 4278 break; 4279 case IStyleAccess::AUTO_STYLE_RUBY: 4280 { 4281 if(!xAutoRubyStyles.is()) 4282 xAutoRubyStyles = new SwXAutoStyleFamily(pDocShell, nType ); 4283 aRef = xAutoRubyStyles; 4284 } 4285 break; 4286 case IStyleAccess::AUTO_STYLE_PARA: 4287 { 4288 if(!xAutoParaStyles.is()) 4289 xAutoParaStyles = new SwXAutoStyleFamily(pDocShell, nType ); 4290 aRef = xAutoParaStyles; 4291 } 4292 break; 4293 4294 default: 4295 ; 4296 } 4297 aRet.setValue(&aRef, ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0)); 4298 } 4299 else 4300 throw uno::RuntimeException(); 4301 return aRet; 4302 } 4303 /*-- 19.05.2006 11:23:57--------------------------------------------------- 4304 4305 -----------------------------------------------------------------------*/ 4306 uno::Type SwXAutoStyles::getElementType( ) throw(uno::RuntimeException) 4307 { 4308 return ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0); 4309 } 4310 /*-- 19.05.2006 11:23:58--------------------------------------------------- 4311 4312 -----------------------------------------------------------------------*/ 4313 sal_Bool SwXAutoStyles::hasElements( ) throw(uno::RuntimeException) 4314 { 4315 return sal_True; 4316 } 4317 /*-- 19.05.2006 11:23:58--------------------------------------------------- 4318 4319 -----------------------------------------------------------------------*/ 4320 uno::Any SwXAutoStyles::getByName(const rtl::OUString& Name) 4321 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) 4322 { 4323 uno::Any aRet; 4324 if(Name.compareToAscii("CharacterStyles") == 0 ) 4325 aRet = getByIndex(0); 4326 else if(Name.compareToAscii("RubyStyles") == 0 ) 4327 aRet = getByIndex(1); 4328 else if(Name.compareToAscii("ParagraphStyles") == 0 ) 4329 aRet = getByIndex(2); 4330 else 4331 throw container::NoSuchElementException(); 4332 return aRet; 4333 } 4334 /*-- 19.05.2006 11:23:59--------------------------------------------------- 4335 4336 -----------------------------------------------------------------------*/ 4337 uno::Sequence< rtl::OUString > SwXAutoStyles::getElementNames(void) 4338 throw( uno::RuntimeException ) 4339 { 4340 uno::Sequence< OUString > aNames(AUTOSTYLE_FAMILY_COUNT); 4341 OUString* pNames = aNames.getArray(); 4342 pNames[0] = C2U("CharacterStyles"); 4343 pNames[1] = C2U("RubyStyles"); 4344 pNames[2] = C2U("ParagraphStyles"); 4345 return aNames; 4346 } 4347 /*-- 19.05.2006 11:24:00--------------------------------------------------- 4348 4349 -----------------------------------------------------------------------*/ 4350 sal_Bool SwXAutoStyles::hasByName(const rtl::OUString& Name) 4351 throw( uno::RuntimeException ) 4352 { 4353 if( Name.compareToAscii("CharacterStyles") == 0 || 4354 Name.compareToAscii("RubyStyles") == 0 || 4355 Name.compareToAscii("ParagraphStyles") == 0 ) 4356 return sal_True; 4357 else 4358 return sal_False; 4359 } 4360 4361 /*-- 19.05.2006 11:24:02--------------------------------------------------- 4362 4363 -----------------------------------------------------------------------*/ 4364 SwXAutoStyleFamily::SwXAutoStyleFamily(SwDocShell* pDocSh, IStyleAccess::SwAutoStyleFamily nFamily) : 4365 pDocShell( pDocSh ), eFamily(nFamily) 4366 { 4367 // Register ourselves as a listener to the document (via the page descriptor) 4368 pDocSh->GetDoc()->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); 4369 } 4370 /*-- 19.05.2006 11:24:02--------------------------------------------------- 4371 4372 -----------------------------------------------------------------------*/ 4373 SwXAutoStyleFamily::~SwXAutoStyleFamily() 4374 { 4375 } 4376 4377 void SwXAutoStyleFamily::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) 4378 { 4379 ClientModify(this, pOld, pNew); 4380 if(!GetRegisteredIn()) 4381 pDocShell = 0; 4382 } 4383 4384 /*-- 31.05.2006 11:24:02--------------------------------------------------- 4385 4386 -----------------------------------------------------------------------*/ 4387 uno::Reference< style::XAutoStyle > SwXAutoStyleFamily::insertStyle( 4388 const uno::Sequence< beans::PropertyValue >& Values ) 4389 throw (uno::RuntimeException) 4390 { 4391 if( !pDocShell ) 4392 { 4393 throw uno::RuntimeException(); 4394 } 4395 4396 const sal_uInt16* pRange = 0; 4397 const SfxItemPropertySet* pPropSet = 0; 4398 4399 switch( eFamily ) 4400 { 4401 case IStyleAccess::AUTO_STYLE_CHAR: 4402 { 4403 pRange = aCharAutoFmtSetRange; 4404 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE); 4405 break; 4406 } 4407 case IStyleAccess::AUTO_STYLE_RUBY: 4408 { 4409 pRange = 0;//aTxtNodeSetRange; 4410 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_RUBY_AUTO_STYLE); 4411 break; 4412 } 4413 case IStyleAccess::AUTO_STYLE_PARA: 4414 { 4415 pRange = aTxtNodeSetRange; //UUUU checked, already added support for [XATTR_FILL_FIRST, XATTR_FILL_LAST] 4416 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARA_AUTO_STYLE); 4417 break; 4418 } 4419 4420 default: break; 4421 } 4422 4423 SwAttrSet aSet( pDocShell->GetDoc()->GetAttrPool(), pRange ); 4424 const beans::PropertyValue* pSeq = Values.getConstArray(); 4425 sal_Int32 nLen = Values.getLength(); 4426 const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == eFamily); 4427 4428 if(!bTakeCareOfDrawingLayerFillStyle) 4429 { 4430 for( sal_Int32 i = 0; i < nLen; ++i ) 4431 { 4432 try 4433 { 4434 pPropSet->setPropertyValue( pSeq[i].Name, pSeq[i].Value, aSet ); 4435 } 4436 catch (beans::UnknownPropertyException &) 4437 { 4438 ASSERT( false, "Unknown property" ); 4439 } 4440 catch (lang::IllegalArgumentException &) 4441 { 4442 ASSERT( false, "Illegal argument" ); 4443 } 4444 } 4445 } 4446 else 4447 { 4448 //UUUU set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem 4449 // to make cases in RES_BACKGROUND work correct; target *is* a style 4450 // where this is the case 4451 aSet.SetParent(&pDocShell->GetDoc()->GetDfltTxtFmtColl()->GetAttrSet()); 4452 4453 //UUUU here the used DrawingLayer FillStyles are imported when family is 4454 // equal to IStyleAccess::AUTO_STYLE_PARA, thus we will need to serve the 4455 // used slots functionality here to do this correctly 4456 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 4457 4458 for( sal_Int32 i = 0; i < nLen; ++i ) 4459 { 4460 const OUString& rPropName = pSeq[i].Name; 4461 uno::Any aValue(pSeq[i].Value); 4462 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName); 4463 4464 if(!pEntry) 4465 { 4466 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 4467 } 4468 4469 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM)); 4470 bool bDone(false); 4471 4472 // check for needed metric translation 4473 if(pEntry->nMemberId & SFX_METRIC_ITEM) 4474 { 4475 bool bDoIt(true); 4476 4477 if(XATTR_FILLBMP_SIZEX == pEntry->nWID || XATTR_FILLBMP_SIZEY == pEntry->nWID) 4478 { 4479 // exception: If these ItemTypes are used, do not convert when these are negative 4480 // since this means they are intended as percent values 4481 sal_Int32 nValue = 0; 4482 4483 if(aValue >>= nValue) 4484 { 4485 bDoIt = nValue > 0; 4486 } 4487 } 4488 4489 if(bDoIt) 4490 { 4491 const SfxItemPool& rPool = pDocShell->GetDoc()->GetAttrPool(); 4492 const SfxMapUnit eMapUnit(rPool.GetMetric(pEntry->nWID)); 4493 4494 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 4495 { 4496 SvxUnoConvertFromMM(eMapUnit, aValue); 4497 } 4498 } 4499 } 4500 4501 switch(pEntry->nWID) 4502 { 4503 case XATTR_FILLGRADIENT: 4504 case XATTR_FILLHATCH: 4505 case XATTR_FILLBITMAP: 4506 case XATTR_FILLFLOATTRANSPARENCE: 4507 // not yet needed; activate when LineStyle support may be added 4508 // case XATTR_LINESTART: 4509 // case XATTR_LINEEND: 4510 // case XATTR_LINEDASH: 4511 { 4512 if(MID_NAME == nMemberId) 4513 { 4514 //UUUU add set commands for FillName items 4515 OUString aTempName; 4516 4517 if(!(aValue >>= aTempName)) 4518 { 4519 throw lang::IllegalArgumentException(); 4520 } 4521 4522 SvxShape::SetFillAttribute(pEntry->nWID, aTempName, aSet); 4523 bDone = true; 4524 } 4525 else if(MID_GRAFURL == nMemberId) 4526 { 4527 if(XATTR_FILLBITMAP == pEntry->nWID) 4528 { 4529 //UUUU Bitmap also has the MID_GRAFURL mode where a Bitmap URL is used 4530 const Graphic aNullGraphic; 4531 XFillBitmapItem aXFillBitmapItem(aSet.GetPool(), aNullGraphic); 4532 4533 aXFillBitmapItem.PutValue(aValue, nMemberId); 4534 aSet.Put(aXFillBitmapItem); 4535 bDone = true; 4536 } 4537 } 4538 4539 break; 4540 } 4541 case RES_BACKGROUND: 4542 { 4543 //UUUU 4544 const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND)); 4545 SvxBrushItem aChangedBrushItem(aOriginalBrushItem); 4546 4547 aChangedBrushItem.PutValue(aValue, nMemberId); 4548 4549 if(!(aChangedBrushItem == aOriginalBrushItem)) 4550 { 4551 setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, aSet); 4552 } 4553 4554 bDone = true; 4555 break; 4556 } 4557 case OWN_ATTR_FILLBMP_MODE: 4558 { 4559 //UUUU 4560 drawing::BitmapMode eMode; 4561 4562 if(!(aValue >>= eMode)) 4563 { 4564 sal_Int32 nMode = 0; 4565 4566 if(!(aValue >>= nMode)) 4567 { 4568 throw lang::IllegalArgumentException(); 4569 } 4570 4571 eMode = (drawing::BitmapMode)nMode; 4572 } 4573 4574 aSet.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH == eMode)); 4575 aSet.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT == eMode)); 4576 4577 bDone = true; 4578 break; 4579 } 4580 default: break; 4581 } 4582 4583 if(!bDone) 4584 { 4585 pPropSet->setPropertyValue( rPropName, aValue, aSet ); 4586 } 4587 } 4588 4589 //UUUU clear parent again 4590 aSet.SetParent(0); 4591 } 4592 4593 //UUUU need to ensure uniqueness of evtl. added NameOrIndex items 4594 // currently in principle only needed when bTakeCareOfDrawingLayerFillStyle, 4595 // but does not hurt and is easily forgotten later eventually, so keep it 4596 // as common case 4597 pDocShell->GetDoc()->CheckForUniqueItemForLineFillNameOrIndex(aSet); 4598 4599 // AutomaticStyle creation 4600 SfxItemSet_Pointer_t pSet = pDocShell->GetDoc()->GetIStyleAccess().cacheAutomaticStyle( aSet, eFamily ); 4601 uno::Reference<style::XAutoStyle> xRet = new SwXAutoStyle(pDocShell->GetDoc(), pSet, eFamily); 4602 4603 return xRet; 4604 } 4605 /*-- 31.05.2006 11:24:02--------------------------------------------------- 4606 4607 -----------------------------------------------------------------------*/ 4608 uno::Reference< container::XEnumeration > SwXAutoStyleFamily::createEnumeration( ) 4609 throw (uno::RuntimeException) 4610 { 4611 if( !pDocShell ) 4612 throw uno::RuntimeException(); 4613 return uno::Reference< container::XEnumeration > 4614 (new SwXAutoStylesEnumerator( pDocShell->GetDoc(), eFamily )); 4615 } 4616 /*-- 19.05.2006 11:24:03--------------------------------------------------- 4617 4618 -----------------------------------------------------------------------*/ 4619 uno::Type SwXAutoStyleFamily::getElementType( ) throw(uno::RuntimeException) 4620 { 4621 return ::getCppuType((const uno::Reference<style::XAutoStyle>*)0); 4622 } 4623 /*-- 19.05.2006 11:24:04--------------------------------------------------- 4624 4625 -----------------------------------------------------------------------*/ 4626 sal_Bool SwXAutoStyleFamily::hasElements( ) throw(uno::RuntimeException) 4627 { 4628 return sal_False; 4629 } 4630 4631 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4632 4633 -----------------------------------------------------------------------*/ 4634 SwAutoStylesEnumImpl::SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam ) 4635 : pDoc( pInitDoc ), eFamily( eFam ) 4636 { 4637 // special case for ruby auto styles: 4638 if ( IStyleAccess::AUTO_STYLE_RUBY == eFam ) 4639 { 4640 std::set< std::pair< sal_uInt16, sal_uInt16 > > aRubyMap; 4641 SwAttrPool& rAttrPool = pDoc->GetAttrPool(); 4642 sal_uInt32 nCount = rAttrPool.GetItemCount2( RES_TXTATR_CJK_RUBY ); 4643 4644 for ( sal_uInt32 nI = 0; nI < nCount; ++nI ) 4645 { 4646 const SwFmtRuby* pItem = static_cast<const SwFmtRuby*>(rAttrPool.GetItem2( RES_TXTATR_CJK_RUBY, nI )); 4647 if ( pItem && pItem->GetTxtRuby() ) 4648 { 4649 std::pair< sal_uInt16, sal_uInt16 > aPair( pItem->GetPosition(), pItem->GetAdjustment() ); 4650 if ( aRubyMap.find( aPair ) == aRubyMap.end() ) 4651 { 4652 aRubyMap.insert( aPair ); 4653 SfxItemSet_Pointer_t pItemSet( new SfxItemSet( rAttrPool, RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY ) ); 4654 pItemSet->Put( *pItem ); 4655 mAutoStyles.push_back( pItemSet ); 4656 } 4657 } 4658 } 4659 } 4660 else 4661 { 4662 pDoc->GetIStyleAccess().getAllStyles( mAutoStyles, eFamily ); 4663 } 4664 4665 aIter = mAutoStyles.begin(); 4666 } 4667 4668 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4669 4670 -----------------------------------------------------------------------*/ 4671 SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwAutoStyleFamily eFam ) 4672 : pImpl( new SwAutoStylesEnumImpl( pDoc, eFam ) ) 4673 { 4674 // Register ourselves as a listener to the document (via the page descriptor) 4675 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); 4676 } 4677 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4678 4679 -----------------------------------------------------------------------*/ 4680 SwXAutoStylesEnumerator::~SwXAutoStylesEnumerator() 4681 { 4682 delete pImpl; 4683 } 4684 4685 void SwXAutoStylesEnumerator::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) 4686 { 4687 ClientModify(this, pOld, pNew); 4688 if(!GetRegisteredIn()) 4689 { 4690 delete pImpl; 4691 pImpl = 0; 4692 } 4693 } 4694 4695 4696 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4697 4698 -----------------------------------------------------------------------*/ 4699 ::sal_Bool SwXAutoStylesEnumerator::hasMoreElements( ) 4700 throw (uno::RuntimeException) 4701 { 4702 if( !pImpl ) 4703 throw uno::RuntimeException(); 4704 return pImpl->hasMoreElements(); 4705 } 4706 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4707 4708 -----------------------------------------------------------------------*/ 4709 uno::Any SwXAutoStylesEnumerator::nextElement( ) 4710 throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 4711 { 4712 if( !pImpl ) 4713 throw uno::RuntimeException(); 4714 uno::Any aRet; 4715 if( pImpl->hasMoreElements() ) 4716 { 4717 SfxItemSet_Pointer_t pNextSet = pImpl->nextElement(); 4718 uno::Reference< style::XAutoStyle > xAutoStyle = new SwXAutoStyle(pImpl->getDoc(), 4719 pNextSet, pImpl->getFamily()); 4720 aRet.setValue(&xAutoStyle, ::getCppuType((uno::Reference<style::XAutoStyle>*)0)); 4721 } 4722 return aRet; 4723 } 4724 4725 ////////////////////////////////////////////////////////////////////////////// 4726 //UUUU SwXAutoStyle with the family IStyleAccess::AUTO_STYLE_PARA (or 4727 // PROPERTY_MAP_PARA_AUTO_STYLE) now uses DrawingLayer FillStyles to allow 4728 // unified paragraph background fill, thus the UNO API implementation has to 4729 // support the needed slots for these. This seems to be used only for reading 4730 // (no setPropertyValue implementation here), so maybe specialized for saving 4731 // the Writer Doc to ODF 4732 4733 SwXAutoStyle::SwXAutoStyle( 4734 SwDoc* pDoc, 4735 SfxItemSet_Pointer_t pInitSet, 4736 IStyleAccess::SwAutoStyleFamily eFam) 4737 : mpSet(pInitSet), 4738 meFamily(eFam), 4739 mrDoc(*pDoc) 4740 { 4741 // Register ourselves as a listener to the document (via the page descriptor) 4742 mrDoc.GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); 4743 } 4744 4745 SwXAutoStyle::~SwXAutoStyle() 4746 { 4747 } 4748 4749 void SwXAutoStyle::Modify( 4750 const SfxPoolItem* pOld, 4751 const SfxPoolItem *pNew) 4752 { 4753 ClientModify(this, pOld, pNew); 4754 4755 if(!GetRegisteredIn()) 4756 { 4757 mpSet.reset(); 4758 } 4759 } 4760 4761 uno::Reference< beans::XPropertySetInfo > SwXAutoStyle::getPropertySetInfo() 4762 throw (uno::RuntimeException) 4763 { 4764 uno::Reference< beans::XPropertySetInfo > xRet; 4765 switch( meFamily ) 4766 { 4767 case IStyleAccess::AUTO_STYLE_CHAR: 4768 { 4769 static uno::Reference< beans::XPropertySetInfo > xCharRef; 4770 if(!xCharRef.is()) 4771 { 4772 xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE)->getPropertySetInfo(); 4773 } 4774 xRet = xCharRef; 4775 } 4776 break; 4777 case IStyleAccess::AUTO_STYLE_RUBY: 4778 { 4779 static uno::Reference< beans::XPropertySetInfo > xRubyRef; 4780 if(!xRubyRef.is()) 4781 { 4782 sal_uInt16 nMapId = PROPERTY_MAP_RUBY_AUTO_STYLE; 4783 xRubyRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo(); 4784 } 4785 xRet = xRubyRef; 4786 } 4787 break; 4788 case IStyleAccess::AUTO_STYLE_PARA: 4789 { 4790 static uno::Reference< beans::XPropertySetInfo > xParaRef; 4791 if(!xParaRef.is()) 4792 { 4793 sal_uInt16 nMapId = PROPERTY_MAP_PARA_AUTO_STYLE; 4794 xParaRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo(); 4795 } 4796 xRet = xParaRef; 4797 } 4798 break; 4799 4800 default: 4801 ; 4802 } 4803 4804 return xRet; 4805 } 4806 4807 void SwXAutoStyle::setPropertyValue( 4808 const OUString& /*rPropertyName*/, 4809 const uno::Any& /*rValue*/ ) 4810 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 4811 { 4812 } 4813 4814 uno::Any SwXAutoStyle::getPropertyValue( 4815 const OUString& rPropertyName ) 4816 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 4817 { 4818 vos::OGuard aGuard(Application::GetSolarMutex()); 4819 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 4820 4821 return GetPropertyValues_Impl(aProperties).getConstArray()[0]; 4822 } 4823 4824 void SwXAutoStyle::addPropertyChangeListener( 4825 const OUString& /*aPropertyName*/, 4826 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) 4827 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 4828 { 4829 } 4830 4831 void SwXAutoStyle::removePropertyChangeListener( 4832 const OUString& /*aPropertyName*/, 4833 const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) 4834 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 4835 { 4836 } 4837 4838 void SwXAutoStyle::addVetoableChangeListener( 4839 const OUString& /*PropertyName*/, 4840 const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) 4841 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 4842 { 4843 } 4844 4845 void SwXAutoStyle::removeVetoableChangeListener( 4846 const OUString& /*PropertyName*/, 4847 const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) 4848 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 4849 { 4850 } 4851 4852 void SwXAutoStyle::setPropertyValues( 4853 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, 4854 const uno::Sequence< uno::Any >& /*aValues*/ ) 4855 throw (beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 4856 { 4857 } 4858 4859 uno::Sequence< uno::Any > SwXAutoStyle::GetPropertyValues_Impl( 4860 const uno::Sequence< OUString > & rPropertyNames ) 4861 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 4862 { 4863 if( !mpSet.get() ) 4864 { 4865 throw uno::RuntimeException(); 4866 } 4867 4868 // query_item 4869 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; 4870 4871 switch(meFamily) 4872 { 4873 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break; 4874 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break; 4875 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break; 4876 default: ; 4877 } 4878 4879 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 4880 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 4881 const OUString* pNames = rPropertyNames.getConstArray(); 4882 const sal_Int32 nLen(rPropertyNames.getLength()); 4883 uno::Sequence< uno::Any > aRet( nLen ); 4884 uno::Any* pValues = aRet.getArray(); 4885 const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == meFamily); 4886 4887 for( sal_Int32 i = 0; i < nLen; ++i ) 4888 { 4889 const OUString& rPropName = pNames[i]; 4890 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName); 4891 4892 if(!pEntry) 4893 { 4894 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 4895 } 4896 4897 uno::Any aTarget; 4898 bool bDone(false); 4899 4900 if ( RES_TXTATR_AUTOFMT == pEntry->nWID || RES_AUTO_STYLE == pEntry->nWID ) 4901 { 4902 OUString sName(StylePool::nameOf( mpSet )); 4903 aTarget <<= sName; 4904 bDone = true; 4905 } 4906 else if(bTakeCareOfDrawingLayerFillStyle) 4907 { 4908 //UUUU add support for DrawingLayer FillStyle slots 4909 switch(pEntry->nWID) 4910 { 4911 case RES_BACKGROUND: 4912 { 4913 const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(*mpSet, RES_BACKGROUND)); 4914 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM)); 4915 4916 if(!aOriginalBrushItem.QueryValue(aTarget, nMemberId)) 4917 { 4918 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)"); 4919 } 4920 4921 bDone = true; 4922 break; 4923 } 4924 case OWN_ATTR_FILLBMP_MODE: 4925 { 4926 const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&mpSet->Get(XATTR_FILLBMP_STRETCH)); 4927 const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&mpSet->Get(XATTR_FILLBMP_TILE)); 4928 4929 if( pTileItem && pTileItem->GetValue() ) 4930 { 4931 aTarget <<= drawing::BitmapMode_REPEAT; 4932 } 4933 else if( pStretchItem && pStretchItem->GetValue() ) 4934 { 4935 aTarget <<= drawing::BitmapMode_STRETCH; 4936 } 4937 else 4938 { 4939 aTarget <<= drawing::BitmapMode_NO_REPEAT; 4940 } 4941 4942 bDone = true; 4943 break; 4944 } 4945 } 4946 } 4947 4948 if(!bDone) 4949 { 4950 pPropSet->getPropertyValue( *pEntry, *mpSet, aTarget ); 4951 } 4952 4953 if(bTakeCareOfDrawingLayerFillStyle) 4954 { 4955 if(pEntry->pType && *(pEntry->pType) == ::getCppuType((const sal_Int16*)0) && *(pEntry->pType) != aTarget.getValueType()) 4956 { 4957 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here 4958 sal_Int32 nValue = 0; 4959 aTarget >>= nValue; 4960 aTarget <<= (sal_Int16)nValue; 4961 } 4962 4963 // check for needed metric translation 4964 if(pEntry->nMemberId & SFX_METRIC_ITEM) 4965 { 4966 bool bDoIt(true); 4967 4968 if(XATTR_FILLBMP_SIZEX == pEntry->nWID || XATTR_FILLBMP_SIZEY == pEntry->nWID) 4969 { 4970 // exception: If these ItemTypes are used, do not convert when these are negative 4971 // since this means they are intended as percent values 4972 sal_Int32 nValue = 0; 4973 4974 if(aTarget >>= nValue) 4975 { 4976 bDoIt = nValue > 0; 4977 } 4978 } 4979 4980 if(bDoIt) 4981 { 4982 const SfxItemPool& rPool = mrDoc.GetAttrPool(); 4983 const SfxMapUnit eMapUnit(rPool.GetMetric(pEntry->nWID)); 4984 4985 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 4986 { 4987 SvxUnoConvertToMM(eMapUnit, aTarget); 4988 } 4989 } 4990 } 4991 } 4992 4993 // add value 4994 pValues[i] = aTarget; 4995 } 4996 4997 return aRet; 4998 } 4999 5000 uno::Sequence< uno::Any > SwXAutoStyle::getPropertyValues ( 5001 const uno::Sequence< ::rtl::OUString >& rPropertyNames ) 5002 throw (uno::RuntimeException) 5003 { 5004 vos::OGuard aGuard(Application::GetSolarMutex()); 5005 uno::Sequence< uno::Any > aValues; 5006 5007 // workaround for bad designed API 5008 try 5009 { 5010 aValues = GetPropertyValues_Impl( rPropertyNames ); 5011 } 5012 catch (beans::UnknownPropertyException &) 5013 { 5014 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 5015 } 5016 catch (lang::WrappedTargetException &) 5017 { 5018 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 5019 } 5020 5021 return aValues; 5022 } 5023 5024 void SwXAutoStyle::addPropertiesChangeListener( 5025 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, 5026 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 5027 throw (uno::RuntimeException) 5028 { 5029 } 5030 5031 void SwXAutoStyle::removePropertiesChangeListener( 5032 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 5033 throw (uno::RuntimeException) 5034 { 5035 } 5036 5037 void SwXAutoStyle::firePropertiesChangeEvent( 5038 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, 5039 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 5040 throw (uno::RuntimeException) 5041 { 5042 } 5043 5044 beans::PropertyState SwXAutoStyle::getPropertyState( 5045 const OUString& rPropertyName ) 5046 throw( beans::UnknownPropertyException, uno::RuntimeException) 5047 { 5048 vos::OGuard aGuard(Application::GetSolarMutex()); 5049 5050 uno::Sequence< OUString > aNames(1); 5051 OUString* pNames = aNames.getArray(); 5052 pNames[0] = rPropertyName; 5053 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames); 5054 return aStates.getConstArray()[0]; 5055 } 5056 5057 void SwXAutoStyle::setPropertyToDefault( 5058 const OUString& /*PropertyName*/ ) 5059 throw( beans::UnknownPropertyException, uno::RuntimeException ) 5060 { 5061 } 5062 5063 uno::Any SwXAutoStyle::getPropertyDefault( 5064 const OUString& rPropertyName ) 5065 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 5066 { 5067 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 ); 5068 5069 return getPropertyDefaults ( aSequence ).getConstArray()[0]; 5070 } 5071 5072 uno::Sequence< beans::PropertyState > SwXAutoStyle::getPropertyStates( 5073 const uno::Sequence< ::rtl::OUString >& rPropertyNames ) 5074 throw (beans::UnknownPropertyException, uno::RuntimeException) 5075 { 5076 if( !mpSet.get() ) 5077 { 5078 throw uno::RuntimeException(); 5079 } 5080 5081 vos::OGuard aGuard(Application::GetSolarMutex()); 5082 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength()); 5083 beans::PropertyState* pStates = aRet.getArray(); 5084 const OUString* pNames = rPropertyNames.getConstArray(); 5085 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; 5086 5087 switch(meFamily) 5088 { 5089 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break; 5090 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break; 5091 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break; 5092 default: ; 5093 } 5094 5095 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 5096 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 5097 const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == meFamily); 5098 5099 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) 5100 { 5101 const OUString& rPropName = pNames[i]; 5102 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName); 5103 5104 if(!pEntry) 5105 { 5106 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 5107 } 5108 5109 bool bDone(false); 5110 5111 if(bTakeCareOfDrawingLayerFillStyle) 5112 { 5113 //UUUU DrawingLayer PropertyStyle support 5114 switch(pEntry->nWID) 5115 { 5116 case OWN_ATTR_FILLBMP_MODE: 5117 { 5118 if(SFX_ITEM_SET == mpSet->GetItemState(XATTR_FILLBMP_STRETCH, false) 5119 || SFX_ITEM_SET == mpSet->GetItemState(XATTR_FILLBMP_TILE, false)) 5120 { 5121 pStates[i] = beans::PropertyState_DIRECT_VALUE; 5122 } 5123 else 5124 { 5125 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE; 5126 } 5127 5128 bDone = true; 5129 break; 5130 } 5131 case RES_BACKGROUND: 5132 { 5133 if(SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*mpSet)) 5134 { 5135 pStates[i] = beans::PropertyState_DIRECT_VALUE; 5136 bDone = true; 5137 } 5138 5139 break; 5140 } 5141 } 5142 } 5143 5144 if(!bDone) 5145 { 5146 pStates[i] = pPropSet->getPropertyState(*pEntry, *mpSet ); 5147 } 5148 } 5149 5150 return aRet; 5151 } 5152 5153 void SwXAutoStyle::setAllPropertiesToDefault( ) 5154 throw (uno::RuntimeException) 5155 { 5156 } 5157 5158 void SwXAutoStyle::setPropertiesToDefault( 5159 const uno::Sequence< ::rtl::OUString >& rPropertyNames ) 5160 throw (beans::UnknownPropertyException, uno::RuntimeException) 5161 { 5162 if( !mpSet.get() ) 5163 { 5164 throw uno::RuntimeException(); 5165 } 5166 5167 const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == meFamily); 5168 5169 if(!bTakeCareOfDrawingLayerFillStyle) 5170 { 5171 return; 5172 } 5173 5174 //UUUU support DrawingLayer FillStyle slots from here on 5175 vos::OGuard aGuard(Application::GetSolarMutex()); 5176 const OUString* pNames = rPropertyNames.getConstArray(); 5177 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; 5178 5179 switch(meFamily) 5180 { 5181 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break; 5182 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break; 5183 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break; 5184 default: ; 5185 } 5186 5187 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 5188 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 5189 5190 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) 5191 { 5192 const OUString& rPropName = pNames[i]; 5193 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName); 5194 5195 if(!pEntry) 5196 { 5197 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 5198 } 5199 5200 switch(pEntry->nWID) 5201 { 5202 case OWN_ATTR_FILLBMP_MODE: 5203 { 5204 mpSet->ClearItem(XATTR_FILLBMP_STRETCH); 5205 mpSet->ClearItem(XATTR_FILLBMP_TILE); 5206 } 5207 } 5208 } 5209 } 5210 5211 uno::Sequence< uno::Any > SwXAutoStyle::getPropertyDefaults( 5212 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/ ) 5213 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 5214 { 5215 uno::Sequence< uno::Any > aRet(0); 5216 5217 return aRet; 5218 } 5219 5220 uno::Sequence< beans::PropertyValue > SwXAutoStyle::getProperties() 5221 throw (uno::RuntimeException) 5222 { 5223 if( !mpSet.get() ) 5224 throw uno::RuntimeException(); 5225 vos::OGuard aGuard(Application::GetSolarMutex()); 5226 std::vector< beans::PropertyValue > aPropertyVector; 5227 5228 sal_Int8 nPropSetId = 0; 5229 switch(meFamily) 5230 { 5231 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break; 5232 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break; 5233 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break; 5234 default: 5235 ; 5236 } 5237 5238 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 5239 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 5240 PropertyEntryVector_t aPropVector = pMap->getPropertyEntries(); 5241 // struct compareWhichIds 5242 // { 5243 // bool operator()(const sal_uInt16 w1, const sal_uInt16 w2) const 5244 // { 5245 // return w1 < w2; 5246 // } 5247 // }; 5248 // typedef std::map<const sal_uInt16, SfxItemPropertyNamedEntry, compareWhichIds> PropertyMap_t; 5249 // PropertyMap_t aPropMap; 5250 // aPropMap.reserve( aPropVector.size() ); 5251 // PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin(); 5252 // while( aIt != aPropertyEntries.end() ) 5253 // { 5254 // aPropMap[aIt->nWID] = *aIt; 5255 // ++aIt; 5256 // } 5257 5258 SfxItemSet& rSet = *mpSet.get(); 5259 SfxItemIter aIter(rSet); 5260 const SfxPoolItem* pItem = aIter.FirstItem(); 5261 5262 while ( pItem ) 5263 { 5264 const sal_uInt16 nWID = pItem->Which(); 5265 5266 // PropertyMap_t::const_iterator aMapIt = aPropMap[nWID]; 5267 // if( aMapIt != aPropMap.getEnd() ) 5268 // { 5269 // beans::PropertyValue aPropertyValue; 5270 // aPropertyValue.Name = aIt->sName; 5271 // pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId ); 5272 // aPropertyVector.push_back( aPropertyValue ); 5273 // } 5274 // TODO: Optimize - and fix! the old iteration filled each WhichId 5275 // only once but there are more properties than WhichIds 5276 PropertyEntryVector_t::const_iterator aIt = aPropVector.begin(); 5277 while( aIt != aPropVector.end() ) 5278 { 5279 if ( aIt->nWID == nWID ) 5280 { 5281 beans::PropertyValue aPropertyValue; 5282 aPropertyValue.Name = aIt->sName; 5283 pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId ); 5284 aPropertyVector.push_back( aPropertyValue ); 5285 } 5286 ++aIt; 5287 } 5288 /* int i = 0; 5289 while ( pMap[i].nWID != 0 ) 5290 { 5291 if ( pMap[i].nWID == nWID ) 5292 { 5293 beans::PropertyValue aPropertyValue; 5294 String sString( OUString::createFromAscii( pMap[i].pName ) ); 5295 aPropertyValue.Name = sString; 5296 pItem->QueryValue( aPropertyValue.Value, pMap[i].nMemberId ); 5297 aPropertyVector.push_back( aPropertyValue ); 5298 break; 5299 } 5300 ++i; 5301 }*/ 5302 pItem = aIter.NextItem(); 5303 } 5304 5305 const sal_Int32 nCount = aPropertyVector.size(); 5306 uno::Sequence< beans::PropertyValue > aRet( nCount ); 5307 beans::PropertyValue* pProps = aRet.getArray(); 5308 5309 for ( int i = 0; i < nCount; ++i, pProps++ ) 5310 { 5311 *pProps = aPropertyVector[i]; 5312 } 5313 5314 return aRet; 5315 } 5316 5317 ////////////////////////////////////////////////////////////////////////////// 5318 //eof 5319