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 // case FN_UNO_DEFAULT_OUTLINE_LEVEL: //#outline level,removed by zahojianwei 2079 //{ 2080 // sal_Int8 nLevel = 0; 2081 // if( aValue >>= nLevel ) 2082 // rBase.getNewBase()->GetCollection()->SetOutlineLevel( nLevel ); 2083 // else 2084 // rBase.getNewBase()->GetCollection()->SetOutlineLevel( NO_NUMBERING ); 2085 // 2086 // bDone = true; 2087 // break; 2088 //} 2089 case RES_PARATR_OUTLINELEVEL: //add by zahojianwei 2090 { 2091 sal_Int16 nLevel = 0; 2092 aValue >>= nLevel; 2093 if( 0 <= nLevel && nLevel <= MAXLEVEL) 2094 rBase.getNewBase()->GetCollection()->SetAttrOutlineLevel( nLevel ); 2095 2096 bDone = true; 2097 break; //<-end,zhaojianwei 2098 } 2099 case FN_UNO_FOLLOW_STYLE: 2100 { 2101 OUString sTmp; 2102 aValue >>= sTmp; 2103 String aString; 2104 SwStyleNameMapper::FillUIName(sTmp, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ) ; 2105 rBase.getNewBase()->SetFollow( aString ); 2106 2107 bDone = true; 2108 break; 2109 } 2110 case RES_PAGEDESC : 2111 { 2112 if( MID_PAGEDESC_PAGEDESCNAME == nMemberId) 2113 { 2114 // Sonderbehandlung RES_PAGEDESC 2115 if(aValue.getValueType() != ::getCppuType((const OUString*)0)) 2116 throw lang::IllegalArgumentException(); 2117 SfxItemSet& rStyleSet = rBase.GetItemSet(); 2118 2119 SwFmtPageDesc* pNewDesc = 0; 2120 const SfxPoolItem* pItem; 2121 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) ) 2122 { 2123 pNewDesc = new SwFmtPageDesc(*((SwFmtPageDesc*)pItem)); 2124 } 2125 if(!pNewDesc) 2126 pNewDesc = new SwFmtPageDesc(); 2127 OUString uDescName; 2128 aValue >>= uDescName; 2129 String sDescName; 2130 SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True ); 2131 if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName) 2132 { 2133 //sal_uInt16 nCount = pDoc->GetPageDescCnt(); 2134 sal_Bool bPut = sal_False; 2135 if(sDescName.Len()) 2136 { 2137 SwPageDesc* pPageDesc = ::GetPageDescByName_Impl(*pDoc, sDescName); 2138 if(pPageDesc) 2139 { 2140 pNewDesc->RegisterToPageDesc( *pPageDesc ); 2141 bPut = sal_True; 2142 } 2143 else 2144 { 2145 throw lang::IllegalArgumentException(); 2146 } 2147 } 2148 if(!bPut) 2149 { 2150 rStyleSet.ClearItem(RES_BREAK); 2151 rStyleSet.Put(SwFmtPageDesc()); 2152 } 2153 else 2154 rStyleSet.Put(*pNewDesc); 2155 } 2156 2157 delete pNewDesc; 2158 bDone = true; 2159 } 2160 2161 break; 2162 } 2163 case FN_UNO_IS_AUTO_UPDATE: 2164 { 2165 sal_Bool bAuto = *(sal_Bool*)aValue.getValue(); 2166 if(SFX_STYLE_FAMILY_PARA == eFamily) 2167 rBase.getNewBase()->GetCollection()->SetAutoUpdateFmt(bAuto); 2168 else if(SFX_STYLE_FAMILY_FRAME == eFamily) 2169 rBase.getNewBase()->GetFrmFmt()->SetAutoUpdateFmt(bAuto); 2170 2171 bDone = true; 2172 break; 2173 } 2174 case FN_UNO_PARA_STYLE_CONDITIONS: 2175 { 2176 uno::Sequence< beans::NamedValue > aSeq; 2177 if (!(aValue >>= aSeq)) 2178 throw lang::IllegalArgumentException(); 2179 2180 DBG_ASSERT(COND_COMMAND_COUNT == 28, 2181 "invalid size of comman count?"); 2182 const beans::NamedValue *pSeq = aSeq.getConstArray(); 2183 sal_Int32 nLen = aSeq.getLength(); 2184 2185 sal_Bool bFailed = sal_False; 2186 SwCondCollItem aCondItem; 2187 for(sal_uInt16 i = 0; i < nLen; i++) 2188 { 2189 OUString aTmp; 2190 if ((pSeq[i].Value >>= aTmp)) 2191 { 2192 // get UI style name from programmatic style name 2193 String aStyleName; 2194 SwStyleNameMapper::FillUIName( aTmp, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ); 2195 2196 // 2197 // check for correct context and style name 2198 // 2199 sal_Int16 nIdx = GetCommandContextIndex( pSeq[i].Name ); 2200 // 2201 pBasePool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL ); 2202 sal_Bool bStyleFound = sal_False; 2203 const SfxStyleSheetBase* pBase = pBasePool->First(); 2204 while (pBase && !bStyleFound) 2205 { 2206 if(pBase->GetName() == aStyleName) 2207 bStyleFound = sal_True; 2208 pBase = pBasePool->Next(); 2209 } 2210 // 2211 if (nIdx == -1 || !bStyleFound) 2212 { 2213 bFailed = sal_True; 2214 break; 2215 } 2216 2217 aCondItem.SetStyle( &aStyleName, nIdx); 2218 } 2219 else 2220 bFailed = sal_True; 2221 } 2222 if (bFailed) 2223 throw lang::IllegalArgumentException(); 2224 rBase.GetItemSet().Put( aCondItem ); 2225 bDone = true; 2226 break; 2227 } 2228 case FN_UNO_CATEGORY: 2229 { 2230 if(!rBase.getNewBase()->IsUserDefined()) 2231 throw lang::IllegalArgumentException(); 2232 short nSet = 0; 2233 aValue >>= nSet; 2234 2235 sal_uInt16 nId; 2236 switch( nSet ) 2237 { 2238 case style::ParagraphStyleCategory::TEXT: 2239 nId = SWSTYLEBIT_TEXT; 2240 break; 2241 case style::ParagraphStyleCategory::CHAPTER: 2242 nId = SWSTYLEBIT_CHAPTER; 2243 break; 2244 case style::ParagraphStyleCategory::LIST: 2245 nId = SWSTYLEBIT_LIST; 2246 break; 2247 case style::ParagraphStyleCategory::INDEX: 2248 nId = SWSTYLEBIT_IDX; 2249 break; 2250 case style::ParagraphStyleCategory::EXTRA: 2251 nId = SWSTYLEBIT_EXTRA; 2252 break; 2253 case style::ParagraphStyleCategory::HTML: 2254 nId = SWSTYLEBIT_HTML; 2255 break; 2256 default: throw lang::IllegalArgumentException(); 2257 } 2258 2259 rBase.getNewBase()->SetMask( nId|SFXSTYLEBIT_USERDEF ); 2260 bDone = true; 2261 break; 2262 } 2263 case SID_SWREGISTER_COLLECTION: 2264 { 2265 OUString sName; 2266 aValue >>= sName; 2267 SwRegisterItem aReg( sName.getLength() != 0); 2268 aReg.SetWhich(SID_SWREGISTER_MODE); 2269 rBase.GetItemSet().Put(aReg); 2270 String aString; 2271 SwStyleNameMapper::FillUIName(sName, aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); 2272 2273 rBase.GetItemSet().Put(SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) ); 2274 bDone = true; 2275 break; 2276 } 2277 case RES_TXTATR_CJK_RUBY: 2278 { 2279 if(MID_RUBY_CHARSTYLE == nMemberId ) 2280 { 2281 OUString sTmp; 2282 if(aValue >>= sTmp) 2283 { 2284 SfxItemSet& rStyleSet = rBase.GetItemSet(); 2285 SwFmtRuby* pRuby = 0; 2286 const SfxPoolItem* pItem; 2287 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_TXTATR_CJK_RUBY, sal_True, &pItem ) ) 2288 pRuby = new SwFmtRuby(*((SwFmtRuby*)pItem)); 2289 if(!pRuby) 2290 pRuby = new SwFmtRuby(aEmptyStr); 2291 String sStyle; 2292 SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); 2293 pRuby->SetCharFmtName( sTmp ); 2294 pRuby->SetCharFmtId( 0 ); 2295 if(sTmp.getLength()) 2296 { 2297 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sTmp, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); 2298 pRuby->SetCharFmtId(nId); 2299 } 2300 rStyleSet.Put(*pRuby); 2301 delete pRuby; 2302 } 2303 else 2304 throw lang::IllegalArgumentException(); 2305 } 2306 break; 2307 } 2308 case RES_PARATR_DROP: 2309 { 2310 if( MID_DROPCAP_CHAR_STYLE_NAME == nMemberId) 2311 { 2312 if(aValue.getValueType() == ::getCppuType((const OUString*)0)) 2313 { 2314 SfxItemSet& rStyleSet = rBase.GetItemSet(); 2315 2316 SwFmtDrop* pDrop = 0; 2317 const SfxPoolItem* pItem; 2318 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PARATR_DROP, sal_True, &pItem ) ) 2319 pDrop = new SwFmtDrop(*((SwFmtDrop*)pItem)); 2320 if(!pDrop) 2321 pDrop = new SwFmtDrop(); 2322 OUString uStyle; 2323 aValue >>= uStyle; 2324 String sStyle; 2325 SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); 2326 SwDocStyleSheet* pStyle = 2327 (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR); 2328 if(pStyle) 2329 pDrop->SetCharFmt(pStyle->GetCharFmt()); 2330 else 2331 throw lang::IllegalArgumentException(); 2332 rStyleSet.Put(*pDrop); 2333 delete pDrop; 2334 } 2335 else 2336 throw lang::IllegalArgumentException(); 2337 2338 bDone = true; 2339 } 2340 break; 2341 } 2342 default: 2343 { 2344 // nothing to do 2345 break; 2346 } 2347 } 2348 2349 if(!bDone) 2350 { 2351 // default ItemSet handling 2352 SfxItemSet& rStyleSet = rBase.GetItemSet(); 2353 SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID); 2354 aSet.SetParent(&rStyleSet); 2355 rPropSet.setPropertyValue(rEntry, aValue, aSet); 2356 rStyleSet.Put(aSet); 2357 2358 // --> OD 2006-10-18 #i70223# 2359 if ( SFX_STYLE_FAMILY_PARA == eFamily && 2360 rEntry.nWID == RES_PARATR_NUMRULE && 2361 rBase.getNewBase().is() && rBase.getNewBase()->GetCollection() && 2362 //rBase.getNewBase()->GetCollection()->GetOutlineLevel() < MAXLEVEL /* assigned to list level of outline style */) //#outline level,removed by zhaojianwei 2363 rBase.getNewBase()->GetCollection()->IsAssignedToListLevelOfOutlineStyle() ) ////<-end,add by zhaojianwei 2364 { 2365 OUString sNewNumberingRuleName; 2366 aValue >>= sNewNumberingRuleName; 2367 String sTmp( sNewNumberingRuleName ); 2368 if ( sNewNumberingRuleName.getLength() == 0 || sTmp != pDoc->GetOutlineNumRule()->GetName() ) 2369 { 2370 // delete assignment to list level of outline style. 2371 //rBase.getNewBase()->GetCollection()->SetOutlineLevel( NO_NUMBERING ); //#outline level,removed by zhaojianwei 2372 rBase.getNewBase()->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end,adde by zhaojianwei 2373 } 2374 } 2375 } 2376 } 2377 /* -----------------------------18.04.01 13:29-------------------------------- 2378 2379 ---------------------------------------------------------------------------*/ 2380 void SAL_CALL SwXStyle::SetPropertyValues_Impl( 2381 const uno::Sequence< OUString >& rPropertyNames, 2382 const uno::Sequence< uno::Any >& rValues ) 2383 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 2384 { 2385 if ( !m_pDoc ) 2386 throw uno::RuntimeException(); 2387 2388 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 2389 2390 switch(eFamily) 2391 { 2392 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 2393 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break; 2394 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break; 2395 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break; 2396 default: ; 2397 } 2398 2399 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 2400 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 2401 2402 if(rPropertyNames.getLength() != rValues.getLength()) 2403 { 2404 throw lang::IllegalArgumentException(); 2405 } 2406 2407 const OUString* pNames = rPropertyNames.getConstArray(); 2408 const uno::Any* pValues = rValues.getConstArray(); 2409 SwStyleBase_Impl aBaseImpl(*m_pDoc, sStyleName, &GetDoc()->GetDfltTxtFmtColl()->GetAttrSet()); //UUUU add pDfltTxtFmtColl as parent 2410 2411 if(pBasePool) 2412 { 2413 sal_uInt16 nSaveMask = pBasePool->GetSearchMask(); 2414 pBasePool->SetSearchMask(eFamily); 2415 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 2416 pBasePool->SetSearchMask(eFamily, nSaveMask ); 2417 DBG_ASSERT(pBase, "where is the style?" ); 2418 2419 if(pBase) 2420 aBaseImpl.setNewBase(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase)); 2421 else 2422 throw uno::RuntimeException(); 2423 } 2424 2425 for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) 2426 { 2427 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(pNames[nProp]); 2428 2429 if(!pEntry || 2430 (!bIsConditional && pNames[nProp].equalsAsciiL(SW_PROP_NAME(UNO_NAME_PARA_STYLE_CONDITIONS)))) 2431 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 2432 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) 2433 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 2434 2435 if(aBaseImpl.getNewBase().is()) 2436 { 2437 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, pBasePool, m_pDoc, eFamily); 2438 } 2439 else if(bIsDescriptor) 2440 { 2441 if(!pPropImpl->SetProperty(pNames[nProp], pValues[nProp])) 2442 { 2443 throw lang::IllegalArgumentException(); 2444 } 2445 } 2446 else 2447 { 2448 throw uno::RuntimeException(); 2449 } 2450 } 2451 2452 if(aBaseImpl.HasItemSet()) 2453 { 2454 aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet()); 2455 } 2456 } 2457 2458 void SwXStyle::setPropertyValues( 2459 const uno::Sequence< OUString >& rPropertyNames, 2460 const uno::Sequence< uno::Any >& rValues ) 2461 throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 2462 { 2463 vos::OGuard aGuard(Application::GetSolarMutex()); 2464 2465 // workaround for bad designed API 2466 try 2467 { 2468 SetPropertyValues_Impl( rPropertyNames, rValues ); 2469 } 2470 catch (beans::UnknownPropertyException &rException) 2471 { 2472 // wrap the original (here not allowed) exception in 2473 // a lang::WrappedTargetException that gets thrown instead. 2474 lang::WrappedTargetException aWExc; 2475 aWExc.TargetException <<= rException; 2476 throw aWExc; 2477 } 2478 } 2479 2480 2481 uno::Any lcl_GetStyleProperty( 2482 const SfxItemPropertySimpleEntry& rEntry, 2483 const SfxItemPropertySet& rPropSet, 2484 SwStyleBase_Impl& rBase, 2485 SfxStyleSheetBase* pBase, 2486 SfxStyleFamily eFamily, 2487 SwDoc *pDoc) 2488 throw(uno::RuntimeException) 2489 { 2490 uno::Any aRet; 2491 2492 if(FN_UNO_IS_PHYSICAL == rEntry.nWID) 2493 { 2494 sal_Bool bPhys = pBase != 0; 2495 if(pBase) 2496 { 2497 bPhys = ((SwDocStyleSheet*)pBase)->IsPhysical(); 2498 // The standard character format is not existing physically 2499 if( bPhys && SFX_STYLE_FAMILY_CHAR == eFamily && 2500 ((SwDocStyleSheet*)pBase)->GetCharFmt() && 2501 ((SwDocStyleSheet*)pBase)->GetCharFmt()->IsDefault() ) 2502 bPhys = sal_False; 2503 } 2504 aRet.setValue(&bPhys, ::getBooleanCppuType()); 2505 } 2506 else if(pBase) 2507 { 2508 if(!rBase.getNewBase().is()) 2509 { 2510 rBase.setNewBase(new SwDocStyleSheet( *(SwDocStyleSheet*)pBase )); 2511 } 2512 2513 //UUUU 2514 const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM)); 2515 2516 //UUUU adapted switch logic to a more readable state; removed goto's and made 2517 // execution of standard setting of proerty in ItemSet dependent of this variable 2518 bool bDone(false); 2519 2520 switch(rEntry.nWID) 2521 { 2522 case RES_PAPER_BIN: 2523 { 2524 SfxItemSet& rSet = rBase.GetItemSet(); 2525 rPropSet.getPropertyValue(rEntry, rSet, aRet); 2526 sal_Int8 nBin = 0; 2527 aRet >>= nBin; 2528 if ( nBin == -1 ) 2529 aRet <<= OUString ( RTL_CONSTASCII_USTRINGPARAM ( "[From printer settings]" ) ); 2530 else 2531 { 2532 SfxPrinter *pPrinter = pDoc->getPrinter( false ); 2533 OUString sTmp; 2534 if (pPrinter ) 2535 sTmp = pPrinter->GetPaperBinName ( nBin ); 2536 aRet <<= sTmp; 2537 } 2538 2539 bDone = true; 2540 break; 2541 } 2542 case FN_UNO_NUM_RULES: //Sonderbehandlung fuer das SvxNumRuleItem: 2543 { 2544 const SwNumRule* pRule = rBase.getNewBase()->GetNumRule(); 2545 DBG_ASSERT(pRule, "Wo ist die NumRule?"); 2546 uno::Reference< container::XIndexReplace > xRules = new SwXNumberingRules(*pRule); 2547 2548 aRet.setValue(&xRules, ::getCppuType((uno::Reference<container::XIndexReplace>*)0)); 2549 bDone = true; 2550 break; 2551 } 2552 break; 2553 //case FN_UNO_DEFAULT_OUTLINE_LEVEL: //#outline level,removed by zahojianwei 2554 //{ 2555 // DBG_ASSERT( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" ); 2556 // sal_uInt8 nLevel = rBase.getNewBase()->GetCollection()->GetOutlineLevel(); 2557 // if( nLevel != NO_NUMBERING ) 2558 // aRet <<= static_cast<sal_Int8>( nLevel ); 2559 // bDone = true; 2560 // break; 2561 //} 2562 case RES_PARATR_OUTLINELEVEL: //add by zahojianwei 2563 { 2564 DBG_ASSERT( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" ); 2565 int nLevel = rBase.getNewBase()->GetCollection()->GetAttrOutlineLevel(); 2566 2567 aRet <<= static_cast<sal_Int16>( nLevel ); 2568 bDone = true; 2569 break; 2570 } //<-end,zhaojianwei 2571 case FN_UNO_FOLLOW_STYLE: 2572 { 2573 String aString; 2574 2575 SwStyleNameMapper::FillProgName(rBase.getNewBase()->GetFollow(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True); 2576 aRet <<= OUString( aString ); 2577 bDone = true; 2578 break; 2579 } 2580 case RES_PAGEDESC : 2581 { 2582 if( MID_PAGEDESC_PAGEDESCNAME == nMemberId) 2583 { 2584 // Sonderbehandlung RES_PAGEDESC 2585 const SfxPoolItem* pItem; 2586 if(SFX_ITEM_SET == rBase.GetItemSet().GetItemState( RES_PAGEDESC, sal_True, &pItem ) ) 2587 { 2588 const SwPageDesc* pDesc = ((const SwFmtPageDesc*)pItem)->GetPageDesc(); 2589 if(pDesc) 2590 { 2591 String aString; 2592 SwStyleNameMapper::FillProgName(pDesc->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True ); 2593 aRet <<= OUString( aString ); 2594 } 2595 } 2596 2597 bDone = true; 2598 } 2599 2600 break; 2601 } 2602 case FN_UNO_IS_AUTO_UPDATE: 2603 { 2604 sal_Bool bAuto = sal_False; 2605 if(SFX_STYLE_FAMILY_PARA == eFamily) 2606 bAuto = rBase.getNewBase()->GetCollection()->IsAutoUpdateFmt(); 2607 else if(SFX_STYLE_FAMILY_FRAME == eFamily) 2608 bAuto = rBase.getNewBase()->GetFrmFmt()->IsAutoUpdateFmt(); 2609 aRet.setValue(&bAuto, ::getBooleanCppuType()); 2610 2611 bDone = true; 2612 break; 2613 } 2614 case FN_UNO_DISPLAY_NAME: 2615 { 2616 OUString sName(rBase.getNewBase()->GetDisplayName()); 2617 aRet <<= sName; 2618 2619 bDone = true; 2620 break; 2621 } 2622 case FN_UNO_PARA_STYLE_CONDITIONS: 2623 { 2624 DBG_ASSERT(COND_COMMAND_COUNT == 28, 2625 "invalid size of comman count?"); 2626 //SfxItemSet& rStyleSet = rBase.GetItemSet(); 2627 uno::Sequence< beans::NamedValue > aSeq(COND_COMMAND_COUNT); 2628 beans::NamedValue *pSeq = aSeq.getArray(); 2629 2630 SwFmt *pFmt = ((SwDocStyleSheet*)pBase)->GetCollection(); 2631 const CommandStruct *pCmds = SwCondCollItem::GetCmds(); 2632 for (sal_uInt16 n = 0; n < COND_COMMAND_COUNT; ++n) 2633 { 2634 String aStyleName; 2635 2636 const SwCollCondition* pCond = 0; 2637 if( pFmt && RES_CONDTXTFMTCOLL == pFmt->Which() && 2638 0 != ( pCond = ((SwConditionTxtFmtColl*)pFmt)-> 2639 HasCondition( SwCollCondition( 0, pCmds[n].nCnd, pCmds[n].nSubCond ) ) ) 2640 && pCond->GetTxtFmtColl() ) 2641 { 2642 // get programmatic style name from UI style name 2643 aStyleName = pCond->GetTxtFmtColl()->GetName(); 2644 SwStyleNameMapper::FillProgName(aStyleName, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True); 2645 } 2646 2647 pSeq[n].Name = GetCommandContextByIndex(n); 2648 pSeq[n].Value <<= rtl::OUString( aStyleName ); 2649 } 2650 aRet <<= aSeq; 2651 2652 bDone = true; 2653 break; 2654 } 2655 case FN_UNO_CATEGORY: 2656 { 2657 sal_uInt16 nPoolId = rBase.getNewBase()->GetCollection()->GetPoolFmtId(); 2658 short nRet = -1; 2659 2660 switch ( COLL_GET_RANGE_BITS & nPoolId ) 2661 { 2662 case COLL_TEXT_BITS: 2663 nRet = style::ParagraphStyleCategory::TEXT; 2664 break; 2665 case COLL_DOC_BITS: 2666 nRet = style::ParagraphStyleCategory::CHAPTER; 2667 break; 2668 case COLL_LISTS_BITS: 2669 nRet = style::ParagraphStyleCategory::LIST; 2670 break; 2671 case COLL_REGISTER_BITS: 2672 nRet = style::ParagraphStyleCategory::INDEX; 2673 break; 2674 case COLL_EXTRA_BITS: 2675 nRet = style::ParagraphStyleCategory::EXTRA; 2676 break; 2677 case COLL_HTML_BITS: 2678 nRet = style::ParagraphStyleCategory::HTML; 2679 break; 2680 } 2681 2682 aRet <<= nRet; 2683 bDone = true; 2684 break; 2685 } 2686 case SID_SWREGISTER_COLLECTION: 2687 { 2688 const SwPageDesc *pPageDesc = rBase.getNewBase()->GetPageDesc(); 2689 const SwTxtFmtColl* pCol = 0; 2690 String aString; 2691 if( pPageDesc ) 2692 pCol = pPageDesc->GetRegisterFmtColl(); 2693 if( pCol ) 2694 SwStyleNameMapper::FillProgName( 2695 pCol->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); 2696 2697 aRet <<= OUString ( aString ); 2698 bDone = true; 2699 break; 2700 } 2701 case RES_BACKGROUND: 2702 { 2703 //UUUU 2704 const SfxItemSet& rSet = rBase.GetItemSet(); 2705 const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND)); 2706 2707 if(!aOriginalBrushItem.QueryValue(aRet, nMemberId)) 2708 { 2709 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)"); 2710 } 2711 2712 bDone = true; 2713 break; 2714 } 2715 case OWN_ATTR_FILLBMP_MODE: 2716 { 2717 //UUUU 2718 const SfxItemSet& rSet = rBase.GetItemSet(); 2719 const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&rSet.Get(XATTR_FILLBMP_STRETCH)); 2720 const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&rSet.Get(XATTR_FILLBMP_TILE)); 2721 2722 if( pTileItem && pTileItem->GetValue() ) 2723 { 2724 aRet <<= drawing::BitmapMode_REPEAT; 2725 } 2726 else if( pStretchItem && pStretchItem->GetValue() ) 2727 { 2728 aRet <<= drawing::BitmapMode_STRETCH; 2729 } 2730 else 2731 { 2732 aRet <<= drawing::BitmapMode_NO_REPEAT; 2733 } 2734 2735 bDone = true; 2736 break; 2737 } 2738 default: 2739 { 2740 // nothing to do as default 2741 break; 2742 } 2743 } 2744 2745 if(!bDone) 2746 { 2747 SfxItemSet& rSet = rBase.GetItemSet(); 2748 rPropSet.getPropertyValue(rEntry, rSet, aRet); 2749 2750 //UUUU 2751 if(rEntry.pType && *(rEntry.pType) == ::getCppuType((const sal_Int16*)0) && *(rEntry.pType) != aRet.getValueType()) 2752 { 2753 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here 2754 sal_Int32 nValue = 0; 2755 aRet >>= nValue; 2756 aRet <<= (sal_Int16)nValue; 2757 } 2758 2759 //UUUU check for needed metric translation 2760 if(rEntry.nMemberId & SFX_METRIC_ITEM) 2761 { 2762 bool bDoIt(true); 2763 2764 if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID) 2765 { 2766 // exception: If these ItemTypes are used, do not convert when these are negative 2767 // since this means they are intended as percent values 2768 sal_Int32 nValue = 0; 2769 2770 if(aRet >>= nValue) 2771 { 2772 bDoIt = nValue > 0; 2773 } 2774 } 2775 2776 if(bDoIt && pDoc) 2777 { 2778 const SfxItemPool& rPool = pDoc->GetAttrPool(); 2779 const SfxMapUnit eMapUnit(rPool.GetMetric(rEntry.nWID)); 2780 2781 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 2782 { 2783 SvxUnoConvertToMM(eMapUnit, aRet); 2784 } 2785 } 2786 } 2787 } 2788 } 2789 else 2790 { 2791 throw uno::RuntimeException(); 2792 } 2793 2794 return aRet; 2795 } 2796 /* -----------------------------19.04.01 09:26-------------------------------- 2797 2798 ---------------------------------------------------------------------------*/ 2799 uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl( 2800 const uno::Sequence< OUString > & rPropertyNames ) 2801 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2802 { 2803 if ( !m_pDoc ) 2804 throw uno::RuntimeException(); 2805 2806 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 2807 2808 switch(eFamily) 2809 { 2810 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 2811 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break; 2812 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break; 2813 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break; 2814 default: ; 2815 } 2816 2817 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 2818 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 2819 const OUString* pNames = rPropertyNames.getConstArray(); 2820 uno::Sequence< uno::Any > aRet(rPropertyNames.getLength()); 2821 uno::Any* pRet = aRet.getArray(); 2822 SwStyleBase_Impl aBase(*m_pDoc, sStyleName, &GetDoc()->GetDfltTxtFmtColl()->GetAttrSet()); //UUUU add pDfltTxtFmtColl as parent 2823 SfxStyleSheetBase* pBase = 0; 2824 2825 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) 2826 { 2827 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp]); 2828 if(!pEntry || 2829 (!bIsConditional && pNames[nProp].equalsAsciiL(SW_PROP_NAME(UNO_NAME_PARA_STYLE_CONDITIONS)))) 2830 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 2831 2832 if(pBasePool) 2833 { 2834 if(!pBase) 2835 { 2836 sal_uInt16 nSaveMask = pBasePool->GetSearchMask(); 2837 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL ); 2838 pBase = pBasePool->Find(sStyleName); 2839 pBasePool->SetSearchMask(eFamily, nSaveMask ); 2840 } 2841 2842 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, eFamily, GetDoc() ); 2843 } 2844 else if(bIsDescriptor) 2845 { 2846 uno::Any *pAny = 0; 2847 pPropImpl->GetProperty ( pNames[nProp], pAny ); 2848 if( !pAny ) 2849 { 2850 sal_Bool bExcept = sal_False; 2851 switch( eFamily ) 2852 { 2853 case SFX_STYLE_FAMILY_PSEUDO: 2854 bExcept = sal_True; 2855 break; 2856 case SFX_STYLE_FAMILY_PARA: 2857 case SFX_STYLE_FAMILY_PAGE: 2858 pPropImpl->GetProperty ( pNames[nProp], mxStyleData, pRet[ nProp ] ); 2859 break; 2860 case SFX_STYLE_FAMILY_CHAR: 2861 case SFX_STYLE_FAMILY_FRAME : 2862 { 2863 if (pEntry->nWID >= POOLATTR_BEGIN && pEntry->nWID < RES_UNKNOWNATR_END ) 2864 { 2865 SwFmt * pFmt; 2866 if ( eFamily == SFX_STYLE_FAMILY_CHAR ) 2867 pFmt = m_pDoc->GetDfltCharFmt(); 2868 else 2869 pFmt = m_pDoc->GetDfltFrmFmt(); 2870 const SwAttrPool * pPool = pFmt->GetAttrSet().GetPool(); 2871 const SfxPoolItem & rItem = pPool->GetDefaultItem ( pEntry->nWID ); 2872 rItem.QueryValue ( pRet[nProp], pEntry->nMemberId ); 2873 } 2874 else 2875 bExcept = sal_True; 2876 } 2877 break; 2878 2879 default: 2880 ; 2881 } 2882 if (bExcept ) 2883 { 2884 uno::RuntimeException aExcept; 2885 aExcept.Message = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "No default value for: " ) ) + pNames[nProp]; 2886 throw aExcept; 2887 } 2888 } 2889 else 2890 pRet [ nProp ] = *pAny; 2891 } 2892 else 2893 throw uno::RuntimeException(); 2894 } 2895 return aRet; 2896 } 2897 /* -----------------------------04.11.03 09:26-------------------------------- 2898 2899 ---------------------------------------------------------------------------*/ 2900 uno::Sequence< uno::Any > SwXStyle::getPropertyValues( 2901 const uno::Sequence< OUString >& rPropertyNames ) 2902 throw(uno::RuntimeException) 2903 { 2904 vos::OGuard aGuard(Application::GetSolarMutex()); 2905 uno::Sequence< uno::Any > aValues; 2906 2907 // workaround for bad designed API 2908 try 2909 { 2910 aValues = GetPropertyValues_Impl( rPropertyNames ); 2911 } 2912 catch (beans::UnknownPropertyException &) 2913 { 2914 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 2915 } 2916 catch (lang::WrappedTargetException &) 2917 { 2918 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 2919 } 2920 2921 return aValues; 2922 } 2923 /*-- 18.04.01 13:07:29--------------------------------------------------- 2924 -----------------------------------------------------------------------*/ 2925 void SwXStyle::addPropertiesChangeListener( 2926 const uno::Sequence< OUString >& /*aPropertyNames*/, 2927 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 2928 throw(uno::RuntimeException) 2929 { 2930 } 2931 /*-- 18.04.01 13:07:30--------------------------------------------------- 2932 2933 -----------------------------------------------------------------------*/ 2934 void SwXStyle::removePropertiesChangeListener( 2935 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 2936 throw(uno::RuntimeException) 2937 { 2938 } 2939 /*-- 18.04.01 13:07:30--------------------------------------------------- 2940 2941 -----------------------------------------------------------------------*/ 2942 void SwXStyle::firePropertiesChangeEvent( 2943 const uno::Sequence< OUString >& /*aPropertyNames*/, 2944 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 2945 throw(uno::RuntimeException) 2946 { 2947 } 2948 /*-- 17.12.98 08:26:53--------------------------------------------------- 2949 2950 -----------------------------------------------------------------------*/ 2951 void SwXStyle::setPropertyValue( 2952 const OUString& rPropertyName, 2953 const uno::Any& rValue) 2954 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 2955 { 2956 vos::OGuard aGuard(Application::GetSolarMutex()); 2957 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 2958 const uno::Sequence<uno::Any> aValues(&rValue, 1); 2959 2960 SetPropertyValues_Impl( aProperties, aValues ); 2961 } 2962 /*-- 17.12.98 08:26:53--------------------------------------------------- 2963 2964 -----------------------------------------------------------------------*/ 2965 uno::Any SwXStyle::getPropertyValue( 2966 const OUString& rPropertyName) 2967 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2968 { 2969 vos::OGuard aGuard(Application::GetSolarMutex()); 2970 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 2971 return GetPropertyValues_Impl(aProperties).getConstArray()[0]; 2972 2973 } 2974 /*-- 17.12.98 08:26:53--------------------------------------------------- 2975 2976 -----------------------------------------------------------------------*/ 2977 void SwXStyle::addPropertyChangeListener( 2978 const OUString& /*rPropertyName*/, 2979 const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) 2980 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2981 { 2982 DBG_WARNING("not implemented"); 2983 } 2984 /*-- 17.12.98 08:26:54--------------------------------------------------- 2985 2986 -----------------------------------------------------------------------*/ 2987 void SwXStyle::removePropertyChangeListener( 2988 const OUString& /*rPropertyName*/, 2989 const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) 2990 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2991 { 2992 DBG_WARNING("not implemented"); 2993 } 2994 /*-- 17.12.98 08:26:54--------------------------------------------------- 2995 2996 -----------------------------------------------------------------------*/ 2997 void SwXStyle::addVetoableChangeListener( 2998 const OUString& /*rPropertyName*/, 2999 const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) 3000 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 3001 { 3002 DBG_WARNING("not implemented"); 3003 } 3004 /*-- 17.12.98 08:26:54--------------------------------------------------- 3005 3006 -----------------------------------------------------------------------*/ 3007 void SwXStyle::removeVetoableChangeListener( 3008 const OUString& /*rPropertyName*/, 3009 const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) 3010 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 3011 { 3012 DBG_WARNING("not implemented"); 3013 } 3014 3015 /*-- 08.03.99 10:50:26--------------------------------------------------- 3016 3017 -----------------------------------------------------------------------*/ 3018 beans::PropertyState SwXStyle::getPropertyState( 3019 const OUString& rPropertyName) 3020 throw( beans::UnknownPropertyException, uno::RuntimeException ) 3021 { 3022 vos::OGuard aGuard(Application::GetSolarMutex()); 3023 uno::Sequence< OUString > aNames(1); 3024 OUString* pNames = aNames.getArray(); 3025 pNames[0] = rPropertyName; 3026 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames); 3027 return aStates.getConstArray()[0]; 3028 } 3029 /*-- 08.03.99 10:50:27--------------------------------------------------- 3030 3031 -----------------------------------------------------------------------*/ 3032 3033 uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates( 3034 const uno::Sequence< OUString >& rPropertyNames) 3035 throw( beans::UnknownPropertyException, uno::RuntimeException ) 3036 { 3037 vos::OGuard aGuard(Application::GetSolarMutex()); 3038 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength()); 3039 beans::PropertyState* pStates = aRet.getArray(); 3040 3041 if(pBasePool) 3042 { 3043 pBasePool->SetSearchMask(eFamily ); 3044 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 3045 DBG_ASSERT(pBase, "where is the style?" ); 3046 3047 if(pBase) 3048 { 3049 const OUString* pNames = rPropertyNames.getConstArray(); 3050 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 3051 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 3052 3053 switch(eFamily) 3054 { 3055 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 3056 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break; 3057 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break; 3058 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break; 3059 default: ; 3060 } 3061 3062 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 3063 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 3064 const SfxItemSet& rSet = xStyle->GetItemSet(); 3065 3066 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) 3067 { 3068 const String& rPropName = pNames[i]; 3069 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rPropName); 3070 bool bDone(false); 3071 3072 if(!pEntry) 3073 { 3074 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 3075 } 3076 3077 if( FN_UNO_NUM_RULES == pEntry->nWID || FN_UNO_FOLLOW_STYLE == pEntry->nWID ) 3078 { 3079 // handle NumRules first, done 3080 pStates[i] = beans::PropertyState_DIRECT_VALUE; 3081 bDone = true; 3082 } 3083 3084 // allow to retarget the SfxItemSet working on, default correctly. Only 3085 // use pSourceSet below this point (except in header/footer processing) 3086 const SfxItemSet* pSourceSet = &rSet; 3087 3088 if(!bDone) 3089 { 3090 // check for Header/Footer entry 3091 const bool bHeader(SFX_STYLE_FAMILY_PAGE == eFamily && rPropName.EqualsAscii("Header", 0, 6)); 3092 const bool bFooter(SFX_STYLE_FAMILY_PAGE == eFamily && rPropName.EqualsAscii("Footer", 0, 6)); 3093 3094 if(bHeader || bFooter) 3095 { 3096 const SvxSetItem* pSetItem; 3097 3098 if(SFX_ITEM_SET == rSet.GetItemState( 3099 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, 3100 sal_False, 3101 (const SfxPoolItem**)&pSetItem)) 3102 { 3103 // retarget the SfxItemSet to the HeaderFooter SfxSetItem's SfxItenSet 3104 pSourceSet = &pSetItem->GetItemSet(); 3105 } 3106 else 3107 { 3108 // if no SetItem, value is ambigous and we are done 3109 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE; 3110 bDone = true; 3111 } 3112 } 3113 } 3114 3115 if(!bDone && OWN_ATTR_FILLBMP_MODE == pEntry->nWID) 3116 { 3117 //UUUU 3118 if(SFX_ITEM_SET == pSourceSet->GetItemState(XATTR_FILLBMP_STRETCH, false) 3119 || SFX_ITEM_SET == pSourceSet->GetItemState(XATTR_FILLBMP_TILE, false)) 3120 { 3121 pStates[i] = beans::PropertyState_DIRECT_VALUE; 3122 } 3123 else 3124 { 3125 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE; 3126 } 3127 3128 bDone = true; 3129 } 3130 3131 //UUUU for FlyFrames we need to mark all properties from type RES_BACKGROUND 3132 // as beans::PropertyState_DIRECT_VALUE to let users of this property call 3133 // getPropertyValue where the member properties will be mapped from the 3134 // fill attributes to the according SvxBrushItem entries 3135 if(!bDone && RES_BACKGROUND == pEntry->nWID 3136 && SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*pSourceSet)) 3137 { 3138 pStates[i] = beans::PropertyState_DIRECT_VALUE; 3139 bDone = true; 3140 } 3141 3142 if(!bDone) 3143 { 3144 pStates[i] = pPropSet->getPropertyState(*pEntry, *pSourceSet); 3145 3146 if(SFX_STYLE_FAMILY_PAGE == eFamily && SID_ATTR_PAGE_SIZE == pEntry->nWID && beans::PropertyState_DIRECT_VALUE == pStates[i]) 3147 { 3148 const SvxSizeItem& rSize = static_cast <const SvxSizeItem&>( rSet.Get(SID_ATTR_PAGE_SIZE)); 3149 sal_uInt8 nMemberId = pEntry->nMemberId & 0x7f; 3150 3151 if((LONG_MAX == rSize.GetSize().Width() && 3152 (MID_SIZE_WIDTH == nMemberId || 3153 MID_SIZE_SIZE == nMemberId)) || 3154 (LONG_MAX == rSize.GetSize().Height() && 3155 MID_SIZE_HEIGHT == nMemberId)) 3156 { 3157 pStates[i] = beans::PropertyState_DEFAULT_VALUE; 3158 } 3159 } 3160 } 3161 } 3162 } 3163 else 3164 { 3165 throw uno::RuntimeException(); 3166 } 3167 } 3168 else 3169 { 3170 throw uno::RuntimeException(); 3171 } 3172 3173 return aRet; 3174 } 3175 /*-- 08.03.99 10:50:27--------------------------------------------------- 3176 3177 -----------------------------------------------------------------------*/ 3178 void SwXStyle::setPropertyToDefault( 3179 const OUString& rPropertyName) 3180 throw( beans::UnknownPropertyException, uno::RuntimeException ) 3181 { 3182 const uno::Sequence < OUString > aSequence(&rPropertyName,1); 3183 setPropertiesToDefault(aSequence); 3184 } 3185 3186 void SAL_CALL SwXStyle::setPropertiesToDefault( 3187 const uno::Sequence< OUString >& aPropertyNames ) 3188 throw (beans::UnknownPropertyException, uno::RuntimeException) 3189 { 3190 vos::OGuard aGuard(Application::GetSolarMutex()); 3191 SwFmt *pTargetFmt = 0; 3192 3193 if(pBasePool) 3194 { 3195 pBasePool->SetSearchMask(eFamily); 3196 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 3197 DBG_ASSERT(pBase, "Where is the style?"); 3198 3199 if(pBase) 3200 { 3201 rtl::Reference< SwDocStyleSheet > xStyle(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase)); 3202 switch(eFamily) 3203 { 3204 case SFX_STYLE_FAMILY_CHAR: 3205 pTargetFmt = xStyle->GetCharFmt(); 3206 break; 3207 3208 case SFX_STYLE_FAMILY_PARA: 3209 pTargetFmt = xStyle->GetCollection(); 3210 break; 3211 3212 case SFX_STYLE_FAMILY_FRAME: 3213 pTargetFmt = xStyle->GetFrmFmt(); 3214 break; 3215 3216 case SFX_STYLE_FAMILY_PAGE: 3217 { 3218 sal_uInt16 nPgDscPos = USHRT_MAX; 3219 SwPageDesc *pDesc = m_pDoc->FindPageDescByName(xStyle->GetPageDesc()->GetName(),&nPgDscPos); 3220 3221 if(pDesc) 3222 { 3223 pTargetFmt = &pDesc->GetMaster(); 3224 } 3225 break; 3226 } 3227 case SFX_STYLE_FAMILY_PSEUDO: 3228 break; 3229 default: ; 3230 } 3231 } 3232 } 3233 3234 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 3235 3236 switch(eFamily) 3237 { 3238 case SFX_STYLE_FAMILY_PARA: nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 3239 case SFX_STYLE_FAMILY_FRAME: nPropSetId = PROPERTY_MAP_FRAME_STYLE; break; 3240 case SFX_STYLE_FAMILY_PAGE: nPropSetId = PROPERTY_MAP_PAGE_STYLE; break; 3241 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break; 3242 default: ; 3243 } 3244 3245 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 3246 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 3247 const OUString* pNames = aPropertyNames.getConstArray(); 3248 3249 if(pTargetFmt) 3250 { 3251 for(sal_Int32 nProp = 0,nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++) 3252 { 3253 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(pNames[nProp]); 3254 3255 if(!pEntry) 3256 { 3257 throw beans::UnknownPropertyException(OUString(RTL_CONSTASCII_USTRINGPARAM("Property is unknown: ")) + pNames[nProp],static_cast <cppu::OWeakObject *> (this)); 3258 } 3259 3260 if(pEntry->nWID == FN_UNO_FOLLOW_STYLE || pEntry->nWID == FN_UNO_NUM_RULES) 3261 { 3262 throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot reset: ")) + pNames[nProp],static_cast <cppu::OWeakObject *> (this)); 3263 } 3264 3265 if(pEntry->nFlags & beans::PropertyAttribute::READONLY) 3266 { 3267 throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("setPropertiesToDefault: property is read-only: ")) + pNames[nProp],static_cast <cppu::OWeakObject *> (this)); 3268 } 3269 3270 if(pEntry->nWID == RES_PARATR_OUTLINELEVEL) 3271 { 3272 static_cast<SwTxtFmtColl*>(pTargetFmt)->DeleteAssignmentToListLevelOfOutlineStyle(); 3273 } 3274 else 3275 { 3276 pTargetFmt->ResetFmtAttr(pEntry->nWID); 3277 } 3278 3279 if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID) 3280 { 3281 //UUUU 3282 SwDoc* pDoc = pTargetFmt->GetDoc(); 3283 SfxItemSet aSet(pDoc->GetAttrPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 3284 aSet.SetParent(&pTargetFmt->GetAttrSet()); 3285 3286 aSet.ClearItem(XATTR_FILLBMP_STRETCH); 3287 aSet.ClearItem(XATTR_FILLBMP_TILE); 3288 3289 pTargetFmt->SetFmtAttr(aSet); 3290 } 3291 } 3292 } 3293 else if(bIsDescriptor) 3294 { 3295 for(sal_Int32 nProp = 0,nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++) 3296 { 3297 pPropImpl->ClearProperty(pNames[nProp]); 3298 } 3299 } 3300 } 3301 3302 void SAL_CALL SwXStyle::setAllPropertiesToDefault() 3303 throw (uno::RuntimeException) 3304 { 3305 vos::OGuard aGuard(Application::GetSolarMutex()); 3306 3307 if(pBasePool) 3308 { 3309 pBasePool->SetSearchMask(eFamily); 3310 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 3311 DBG_ASSERT(pBase, "where is the style, you fiend!?"); 3312 3313 if(pBase) 3314 { 3315 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 3316 SwFmt *pTargetFmt = 0; 3317 sal_uInt16 nPgDscPos = USHRT_MAX; 3318 3319 switch(eFamily) 3320 { 3321 case SFX_STYLE_FAMILY_CHAR: 3322 pTargetFmt = xStyle->GetCharFmt(); 3323 break; 3324 3325 case SFX_STYLE_FAMILY_PARA: 3326 { 3327 pTargetFmt = xStyle->GetCollection(); 3328 3329 if(xStyle->GetCollection()) 3330 { 3331 // xStyle->GetCollection()->SetOutlineLevel( NO_NUMBERING ); //#outline level,removed by zhaojianwei 3332 xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end,add by zhaojianwei 3333 } 3334 break; 3335 } 3336 3337 case SFX_STYLE_FAMILY_FRAME: 3338 pTargetFmt = xStyle->GetFrmFmt(); 3339 break; 3340 3341 case SFX_STYLE_FAMILY_PAGE: 3342 { 3343 SwPageDesc *pDesc = m_pDoc->FindPageDescByName(xStyle->GetPageDesc()->GetName(),&nPgDscPos); 3344 3345 if(pDesc) 3346 { 3347 pTargetFmt = &pDesc->GetMaster(); 3348 pDesc->SetUseOn(nsUseOnPage::PD_ALL); 3349 } 3350 break; 3351 } 3352 3353 case SFX_STYLE_FAMILY_PSEUDO: 3354 break; 3355 3356 default: ; 3357 } 3358 3359 if(pTargetFmt) 3360 { 3361 if(USHRT_MAX != nPgDscPos) 3362 { 3363 SwPageDesc& rPageDesc = m_pDoc->_GetPageDesc(nPgDscPos); 3364 rPageDesc.ResetAllMasterAttr(); 3365 3366 SvxLRSpaceItem aLR(RES_LR_SPACE); 3367 sal_Int32 nSize = GetMetricVal(CM_1) * 2; 3368 aLR.SetLeft(nSize); 3369 aLR.SetLeft(nSize); 3370 SvxULSpaceItem aUL(RES_UL_SPACE); 3371 aUL.SetUpper(static_cast <sal_uInt16> (nSize)); 3372 aUL.SetLower(static_cast <sal_uInt16> (nSize)); 3373 pTargetFmt->SetFmtAttr(aLR); 3374 pTargetFmt->SetFmtAttr(aUL); 3375 SwPageDesc* pStdPgDsc = m_pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD); 3376 SwFmtFrmSize aFrmSz(ATT_FIX_SIZE); 3377 3378 if(RES_POOLPAGE_STANDARD == rPageDesc.GetPoolFmtId()) 3379 { 3380 if(m_pDoc->getPrinter(false)) 3381 { 3382 const Size aPhysSize(SvxPaperInfo::GetPaperSize( 3383 static_cast<Printer*>(m_pDoc->getPrinter(false)))); 3384 aFrmSz.SetSize(aPhysSize); 3385 } 3386 else 3387 { 3388 // --> OD 2008-07-25 #i91928# 3389 // aFrmSz.SetWidth( LONG_MAX ); 3390 // aFrmSz.SetHeight( LONG_MAX ); 3391 aFrmSz.SetSize(SvxPaperInfo::GetDefaultPaperSize()); 3392 // <-- 3393 } 3394 3395 } 3396 else 3397 { 3398 aFrmSz = pStdPgDsc->GetMaster().GetFrmSize(); 3399 } 3400 3401 if(pStdPgDsc->GetLandscape()) 3402 { 3403 SwTwips nTmp = aFrmSz.GetHeight(); 3404 aFrmSz.SetHeight(aFrmSz.GetWidth()); 3405 aFrmSz.SetWidth(nTmp); 3406 } 3407 3408 pTargetFmt->SetFmtAttr(aFrmSz); 3409 } 3410 else 3411 { 3412 // --> OD 2007-01-25 #i73790# - method renamed 3413 pTargetFmt->ResetAllFmtAttr(); 3414 // <-- 3415 } 3416 3417 if(USHRT_MAX != nPgDscPos) 3418 { 3419 m_pDoc->ChgPageDesc(nPgDscPos, const_cast<const SwDoc *>(m_pDoc)->GetPageDesc(nPgDscPos)); 3420 } 3421 } 3422 3423 } 3424 else 3425 { 3426 throw uno::RuntimeException(); 3427 } 3428 } 3429 else if(bIsDescriptor) 3430 { 3431 pPropImpl->ClearAllProperties(); 3432 } 3433 else 3434 { 3435 throw uno::RuntimeException(); 3436 } 3437 } 3438 3439 uno::Sequence< uno::Any > SAL_CALL SwXStyle::getPropertyDefaults( 3440 const uno::Sequence< OUString >& aPropertyNames ) 3441 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 3442 { 3443 vos::OGuard aGuard(Application::GetSolarMutex()); 3444 sal_Int32 nCount = aPropertyNames.getLength(); 3445 uno::Sequence < uno::Any > aRet(nCount); 3446 3447 if(nCount) 3448 { 3449 if(pBasePool) 3450 { 3451 pBasePool->SetSearchMask(eFamily); 3452 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 3453 DBG_ASSERT(pBase,"Doesn't seem to be a style!"); 3454 3455 if(pBase) 3456 { 3457 rtl::Reference< SwDocStyleSheet > xStyle(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase)); 3458 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 3459 3460 switch(eFamily) 3461 { 3462 case SFX_STYLE_FAMILY_PARA: nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 3463 case SFX_STYLE_FAMILY_FRAME: nPropSetId = PROPERTY_MAP_FRAME_STYLE; break; 3464 case SFX_STYLE_FAMILY_PAGE: nPropSetId = PROPERTY_MAP_PAGE_STYLE; break; 3465 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break; 3466 default: ; 3467 } 3468 3469 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 3470 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap(); 3471 const SfxItemSet &rSet = xStyle->GetItemSet(),*pParentSet = rSet.GetParent(); 3472 const OUString *pNames = aPropertyNames.getConstArray(); 3473 uno::Any *pRet = aRet.getArray(); 3474 3475 for(sal_Int32 i = 0; i < nCount; i++) 3476 { 3477 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(pNames[i]); 3478 3479 if(!pEntry) 3480 { 3481 throw beans::UnknownPropertyException(OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + pNames[i],static_cast <cppu::OWeakObject *> (this)); 3482 } 3483 3484 if(pParentSet) 3485 { 3486 aSwMapProvider.GetPropertySet(nPropSetId)->getPropertyValue(pNames[i],*pParentSet,pRet[i]); 3487 } 3488 else if(pEntry->nWID != rSet.GetPool()->GetSlotId(pEntry->nWID)) 3489 { 3490 const SfxPoolItem& rItem = rSet.GetPool()->GetDefaultItem(pEntry->nWID); 3491 3492 rItem.QueryValue(pRet[i], pEntry->nMemberId); 3493 } 3494 } 3495 } 3496 else 3497 { 3498 throw uno::RuntimeException(); 3499 } 3500 } 3501 else 3502 { 3503 throw uno::RuntimeException(); 3504 } 3505 } 3506 return aRet; 3507 } 3508 /*-- 08.03.99 10:50:27--------------------------------------------------- 3509 3510 -----------------------------------------------------------------------*/ 3511 uno::Any SwXStyle::getPropertyDefault( 3512 const OUString& rPropertyName) 3513 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 3514 { 3515 const uno::Sequence < OUString > aSequence(&rPropertyName,1); 3516 return getPropertyDefaults(aSequence).getConstArray()[0]; 3517 } 3518 /* -----------------21.01.99 13:08------------------- 3519 * 3520 * --------------------------------------------------*/ 3521 void SwXStyle::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 3522 { 3523 SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint ); 3524 if( pHint ) 3525 { 3526 if(( pHint->GetId() & SFX_HINT_DYING ) || ( pHint->GetId() & SFX_STYLESHEET_ERASED)) 3527 { 3528 pBasePool = 0; 3529 EndListening(rBC); 3530 } 3531 else if( pHint->GetId() &(SFX_STYLESHEET_CHANGED|SFX_STYLESHEET_ERASED) ) 3532 { 3533 ((SfxStyleSheetBasePool&)rBC).SetSearchMask(eFamily); 3534 SfxStyleSheetBase* pOwnBase = ((SfxStyleSheetBasePool&)rBC).Find(sStyleName); 3535 if(!pOwnBase) 3536 { 3537 EndListening(rBC); 3538 Invalidate(); 3539 } 3540 } 3541 } 3542 } 3543 /* -----------------------------15.08.00 11:35-------------------------------- 3544 3545 ---------------------------------------------------------------------------*/ 3546 void SwXStyle::Invalidate() 3547 { 3548 sStyleName.Erase(); 3549 pBasePool = 0; 3550 m_pDoc = 0; 3551 mxStyleData.clear(); 3552 mxStyleFamily.clear(); 3553 } 3554 3555 3556 /****************************************************************** 3557 * SwXPageStyle 3558 ******************************************************************/ 3559 /*-- 17.12.98 08:43:35--------------------------------------------------- 3560 3561 -----------------------------------------------------------------------*/ 3562 SwXPageStyle::SwXPageStyle( 3563 SfxStyleSheetBasePool& rPool, 3564 SwDocShell* pDocSh, SfxStyleFamily eFam, 3565 const String& rStyleName) 3566 : SwXStyle(rPool, eFam, pDocSh->GetDoc(), rStyleName), 3567 pDocShell(pDocSh) 3568 { 3569 } 3570 /* -----------------23.08.99 15:52------------------- 3571 3572 --------------------------------------------------*/ 3573 SwXPageStyle::SwXPageStyle(SwDocShell* pDocSh) 3574 : SwXStyle(pDocSh->GetDoc(), SFX_STYLE_FAMILY_PAGE), 3575 pDocShell(pDocSh) 3576 { 3577 } 3578 3579 /*-- 17.12.98 08:43:35--------------------------------------------------- 3580 3581 -----------------------------------------------------------------------*/ 3582 SwXPageStyle::~SwXPageStyle() 3583 { 3584 3585 } 3586 /* -----------------------------18.04.01 13:50-------------------------------- 3587 3588 ---------------------------------------------------------------------------*/ 3589 void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( 3590 const uno::Sequence< OUString >& rPropertyNames, 3591 const uno::Sequence< uno::Any >& rValues ) 3592 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 3593 { 3594 if(!GetDoc()) 3595 throw uno::RuntimeException(); 3596 3597 if(rPropertyNames.getLength() != rValues.getLength()) 3598 throw lang::IllegalArgumentException(); 3599 3600 const OUString* pNames = rPropertyNames.getConstArray(); 3601 const uno::Any* pValues = rValues.getConstArray(); 3602 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE); 3603 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap(); 3604 SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrmFmt()->GetAttrSet()); //UUUU add pDfltFrmFmt as parent 3605 3606 if(GetBasePool()) 3607 { 3608 sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask(); 3609 GetBasePool()->SetSearchMask(GetFamily()); 3610 SfxStyleSheetBase* pBase = GetBasePool()->Find(GetStyleName()); 3611 GetBasePool()->SetSearchMask(GetFamily(), nSaveMask ); 3612 DBG_ASSERT(pBase, "where is the style?" ); 3613 3614 if(pBase) 3615 { 3616 aBaseImpl.setNewBase(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase)); 3617 } 3618 else 3619 { 3620 throw uno::RuntimeException(); 3621 } 3622 } 3623 3624 for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) 3625 { 3626 const String& rPropName = pNames[nProp]; 3627 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rPropName ); 3628 3629 if (!pEntry) 3630 { 3631 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 3632 } 3633 3634 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) 3635 { 3636 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 3637 } 3638 3639 if(GetBasePool()) 3640 { 3641 switch(pEntry->nWID) 3642 { 3643 case SID_ATTR_PAGE_ON: 3644 case RES_BACKGROUND: 3645 case RES_BOX: 3646 case RES_LR_SPACE: 3647 case RES_SHADOW: 3648 case RES_UL_SPACE: 3649 case SID_ATTR_PAGE_DYNAMIC: 3650 case SID_ATTR_PAGE_SHARED: 3651 case SID_ATTR_PAGE_SIZE: 3652 case RES_HEADER_FOOTER_EAT_SPACING: 3653 { 3654 // these entries are used in Header, Footer and (partially) in the PageStyle itself. 3655 // Check for Header/Footer entry 3656 const bool bHeader(rPropName.EqualsAscii("Header", 0, 6)); 3657 const bool bFooter(rPropName.EqualsAscii("Footer", 0, 6)); 3658 3659 if(bHeader || bFooter) 3660 { 3661 // it is a Header/Footer entry, access the SvxSetItem containing it's information 3662 const SvxSetItem* pSetItem = 0; 3663 3664 if(SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, sal_False, (const SfxPoolItem**)&pSetItem)) 3665 { 3666 // create a new SvxSetItem and get it's ItemSet as new target 3667 SvxSetItem* pNewSetItem = static_cast< SvxSetItem* >(pSetItem->Clone()); 3668 SfxItemSet& rSetSet = pNewSetItem->GetItemSet(); 3669 3670 // set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem 3671 rSetSet.SetParent(&GetDoc()->GetDfltFrmFmt()->GetAttrSet()); 3672 3673 // replace the used SfxItemSet at the SwStyleBase_Impl temporarily and use the 3674 // default method to set the property 3675 SfxItemSet* pRememberItemSet = aBaseImpl.replaceItemSet(&rSetSet); 3676 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); 3677 aBaseImpl.replaceItemSet(pRememberItemSet); 3678 3679 // reset paret at ItemSet from SetItem 3680 rSetSet.SetParent(0); 3681 3682 // set the new SvxSetItem at the real target and delete it 3683 aBaseImpl.GetItemSet().Put(*pNewSetItem); 3684 delete pNewSetItem; 3685 } 3686 else if(pEntry->nWID == SID_ATTR_PAGE_ON) 3687 { 3688 sal_Bool bVal = *(sal_Bool*)pValues[nProp].getValue(); 3689 3690 if(bVal) 3691 { 3692 // Header/footer gets switched on, create defauts and the needed SfxSetItem 3693 SfxItemSet aTempSet(*aBaseImpl.GetItemSet().GetPool(), 3694 RES_FRMATR_BEGIN,RES_FRMATR_END - 1, // [82 3695 3696 //UUUU FillAttribute support 3697 XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014 3698 3699 SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER, // [10023 3700 SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE, // [10051 3701 SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED, // [10060 3702 0); 3703 3704 //UUUU set correct parent to get the XFILL_NONE FillStyle as needed 3705 aTempSet.SetParent(&GetDoc()->GetDfltFrmFmt()->GetAttrSet()); 3706 3707 aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_ON, sal_True)); 3708 aTempSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(MM50, MM50))); 3709 aTempSet.Put(SvxLRSpaceItem(RES_LR_SPACE)); 3710 aTempSet.Put(SvxULSpaceItem(RES_UL_SPACE)); 3711 aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED, sal_True)); 3712 aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_DYNAMIC, sal_True)); 3713 3714 SvxSetItem aNewSetItem(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, aTempSet); 3715 aBaseImpl.GetItemSet().Put(aNewSetItem); 3716 } 3717 } 3718 } 3719 else 3720 { 3721 switch(pEntry->nWID) 3722 { 3723 case SID_ATTR_PAGE_DYNAMIC: 3724 case SID_ATTR_PAGE_SHARED: 3725 case SID_ATTR_PAGE_ON: 3726 case RES_HEADER_FOOTER_EAT_SPACING: 3727 { 3728 // these slots are exclusive to Header/Footer, thus this is an error 3729 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 3730 break; 3731 } 3732 default: 3733 { 3734 // part of PageStyle, fallback to default 3735 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); 3736 } 3737 } 3738 } 3739 3740 break; 3741 } 3742 3743 case XATTR_FILLBMP_SIZELOG: 3744 case XATTR_FILLBMP_TILEOFFSETX: 3745 case XATTR_FILLBMP_TILEOFFSETY: 3746 case XATTR_FILLBMP_POSOFFSETX: 3747 case XATTR_FILLBMP_POSOFFSETY: 3748 case XATTR_FILLBMP_POS: 3749 case XATTR_FILLBMP_SIZEX: 3750 case XATTR_FILLBMP_SIZEY: 3751 case XATTR_FILLBMP_STRETCH: 3752 case XATTR_FILLBMP_TILE: 3753 case OWN_ATTR_FILLBMP_MODE: 3754 case XATTR_FILLCOLOR: 3755 case XATTR_FILLBACKGROUND: 3756 case XATTR_FILLBITMAP: 3757 case XATTR_GRADIENTSTEPCOUNT: 3758 case XATTR_FILLGRADIENT: 3759 case XATTR_FILLHATCH: 3760 case XATTR_FILLSTYLE: 3761 case XATTR_FILLTRANSPARENCE: 3762 case XATTR_FILLFLOATTRANSPARENCE: 3763 case XATTR_SECONDARYFILLCOLOR: 3764 { 3765 // This DrawingLayer FillStyle attributes can be part of Header, Footer and PageStyle 3766 // itself, so decide what to do using the name 3767 const bool bHeader(rPropName.EqualsAscii("Header", 0, 6)); 3768 const bool bFooter(rPropName.EqualsAscii("Footer", 0, 6)); 3769 3770 if(bHeader || bFooter) 3771 { 3772 const SvxSetItem* pSetItem = 0; 3773 3774 if(SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, sal_False, (const SfxPoolItem**)&pSetItem)) 3775 { 3776 // create a new SvxSetItem and get it's ItemSet as new target 3777 SvxSetItem* pNewSetItem = static_cast< SvxSetItem* >(pSetItem->Clone()); 3778 SfxItemSet& rSetSet = pNewSetItem->GetItemSet(); 3779 3780 // set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem 3781 rSetSet.SetParent(&GetDoc()->GetDfltFrmFmt()->GetAttrSet()); 3782 3783 // replace the used SfxItemSet at the SwStyleBase_Impl temporarily and use the 3784 // default method to set the property 3785 SfxItemSet* pRememberItemSet = aBaseImpl.replaceItemSet(&rSetSet); 3786 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); 3787 aBaseImpl.replaceItemSet(pRememberItemSet); 3788 3789 // reset paret at ItemSet from SetItem 3790 rSetSet.SetParent(0); 3791 3792 // set the new SvxSetItem at the real target and delete it 3793 aBaseImpl.GetItemSet().Put(*pNewSetItem); 3794 delete pNewSetItem; 3795 } 3796 } 3797 else 3798 { 3799 // part of PageStyle, fallback to default 3800 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); 3801 } 3802 3803 break; 3804 } 3805 3806 case FN_PARAM_FTN_INFO : 3807 { 3808 const SfxPoolItem& rItem = aBaseImpl.GetItemSet().Get(FN_PARAM_FTN_INFO); 3809 SfxPoolItem* pNewFtnItem = rItem.Clone(); 3810 sal_Bool bPut = pNewFtnItem->PutValue(pValues[nProp], pEntry->nMemberId); 3811 aBaseImpl.GetItemSet().Put(*pNewFtnItem); 3812 delete pNewFtnItem; 3813 if(!bPut) 3814 throw lang::IllegalArgumentException(); 3815 3816 break; 3817 } 3818 3819 case FN_UNO_HEADER : 3820 case FN_UNO_HEADER_LEFT : 3821 case FN_UNO_HEADER_RIGHT : 3822 case FN_UNO_FOOTER : 3823 case FN_UNO_FOOTER_LEFT : 3824 case FN_UNO_FOOTER_RIGHT : 3825 { 3826 throw lang::IllegalArgumentException(); 3827 break; 3828 } 3829 3830 default: 3831 { 3832 //UUUU 3833 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); 3834 break; 3835 } 3836 } 3837 } 3838 else if(IsDescriptor()) 3839 { 3840 if(!GetPropImpl()->SetProperty(rPropName, pValues[nProp])) 3841 throw lang::IllegalArgumentException(); 3842 } 3843 else 3844 { 3845 throw uno::RuntimeException(); 3846 } 3847 } 3848 3849 if(aBaseImpl.HasItemSet()) 3850 { 3851 ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo()); 3852 3853 if (undoGuard.UndoWasEnabled()) 3854 { 3855 // Fix i64460: as long as Undo of page styles with header/footer causes trouble... 3856 GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj(); 3857 } 3858 3859 aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet()); 3860 } 3861 } 3862 3863 void SwXPageStyle::setPropertyValues( 3864 const uno::Sequence< OUString >& rPropertyNames, 3865 const uno::Sequence< uno::Any >& rValues ) 3866 throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 3867 { 3868 vos::OGuard aGuard(Application::GetSolarMutex()); 3869 3870 // workaround for bad designed API 3871 try 3872 { 3873 SetPropertyValues_Impl( rPropertyNames, rValues ); 3874 } 3875 catch (beans::UnknownPropertyException &rException) 3876 { 3877 // wrap the original (here not allowed) exception in 3878 // a lang::WrappedTargetException that gets thrown instead. 3879 lang::WrappedTargetException aWExc; 3880 aWExc.TargetException <<= rException; 3881 throw aWExc; 3882 } 3883 } 3884 /* -----------------------------04.11.03 13:50-------------------------------- 3885 3886 ---------------------------------------------------------------------------*/ 3887 static uno::Reference<text::XText> lcl_makeHeaderFooter( 3888 const sal_uInt16 nRes, 3889 const bool bHeader, 3890 SwFrmFmt const*const pFrmFmt) 3891 { 3892 if (!pFrmFmt) { return 0; } 3893 3894 const SfxItemSet& rSet = pFrmFmt->GetAttrSet(); 3895 const SfxPoolItem* pItem; 3896 if (SFX_ITEM_SET == rSet.GetItemState(nRes, sal_True, &pItem)) 3897 { 3898 SwFrmFmt *const pHeadFootFmt = (bHeader) 3899 ? static_cast<SwFmtHeader*>(const_cast<SfxPoolItem*>(pItem))-> 3900 GetHeaderFmt() 3901 : static_cast<SwFmtFooter*>(const_cast<SfxPoolItem*>(pItem))-> 3902 GetFooterFmt(); 3903 if (pHeadFootFmt) 3904 { 3905 return SwXHeadFootText::CreateXHeadFootText(*pHeadFootFmt, bHeader); 3906 } 3907 } 3908 return 0; 3909 } 3910 3911 uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( 3912 const uno::Sequence< OUString >& rPropertyNames ) 3913 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 3914 { 3915 if(!GetDoc()) 3916 throw uno::RuntimeException(); 3917 3918 sal_Int32 nLength = rPropertyNames.getLength(); 3919 const OUString* pNames = rPropertyNames.getConstArray(); 3920 uno::Sequence< uno::Any > aRet ( nLength ); 3921 uno::Any* pRet = aRet.getArray(); 3922 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE); 3923 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap(); 3924 SwStyleBase_Impl aBase(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrmFmt()->GetAttrSet()); //UUUU add pDfltFrmFmt as parent 3925 SfxStyleSheetBase* pBase = 0; 3926 3927 for(sal_Int32 nProp = 0; nProp < nLength; nProp++) 3928 { 3929 const String& rPropName = pNames[nProp]; 3930 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rPropName ); 3931 3932 if (!pEntry) 3933 { 3934 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 3935 } 3936 3937 if(GetBasePool()) 3938 { 3939 if(!pBase) 3940 { 3941 sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask(); 3942 GetBasePool()->SetSearchMask(GetFamily(), SFXSTYLEBIT_ALL ); 3943 pBase = GetBasePool()->Find(GetStyleName()); 3944 GetBasePool()->SetSearchMask(GetFamily(), nSaveMask ); 3945 } 3946 3947 sal_uInt16 nRes = 0; 3948 sal_Bool bAll = sal_False, bLeft = sal_False, bRight = sal_False; 3949 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM)); 3950 3951 switch(pEntry->nWID) 3952 { 3953 case SID_ATTR_PAGE_ON: 3954 case RES_BACKGROUND: 3955 case RES_BOX: 3956 case RES_LR_SPACE: 3957 case RES_SHADOW: 3958 case RES_UL_SPACE: 3959 case SID_ATTR_PAGE_DYNAMIC: 3960 case SID_ATTR_PAGE_SHARED: 3961 case SID_ATTR_PAGE_SIZE: 3962 case RES_HEADER_FOOTER_EAT_SPACING: 3963 { 3964 // These slots are used for Header, Footer and (partially) for PageStyle directly. 3965 // Check for Header/Footer entry 3966 const bool bHeader(rPropName.EqualsAscii("Header", 0, 6)); 3967 const bool bFooter(rPropName.EqualsAscii("Footer", 0, 6)); 3968 3969 if(bHeader || bFooter) 3970 { 3971 // slot is a Header/Footer slot 3972 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 3973 const SfxItemSet& rSet = xStyle->GetItemSet(); 3974 const SvxSetItem* pSetItem; 3975 3976 if(SFX_ITEM_SET == rSet.GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, sal_False, (const SfxPoolItem**)&pSetItem)) 3977 { 3978 // get from SfxItemSet of the corresponding SfxSetItem 3979 const SfxItemSet& rSetSet = pSetItem->GetItemSet(); 3980 SfxItemSet* pRememberItemSet = aBase.replaceItemSet(&const_cast< SfxItemSet& >(rSetSet)); 3981 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() ); 3982 aBase.replaceItemSet(pRememberItemSet); 3983 } 3984 else if(pEntry->nWID == SID_ATTR_PAGE_ON) 3985 { 3986 // header/footer is not available, thus off. Default is sal_False, though 3987 sal_Bool bRet = sal_False; 3988 pRet[nProp].setValue(&bRet, ::getCppuBooleanType()); 3989 } 3990 } 3991 else 3992 { 3993 switch(pEntry->nWID) 3994 { 3995 case SID_ATTR_PAGE_DYNAMIC: 3996 case SID_ATTR_PAGE_SHARED: 3997 case SID_ATTR_PAGE_ON: 3998 case RES_HEADER_FOOTER_EAT_SPACING: 3999 { 4000 // these slots are exclusive to Header/Footer, thus this is an error 4001 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 4002 break; 4003 } 4004 default: 4005 { 4006 // part of PageStyle, fallback to default 4007 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() ); 4008 } 4009 } 4010 } 4011 4012 break; 4013 } 4014 4015 case XATTR_FILLBMP_SIZELOG: 4016 case XATTR_FILLBMP_TILEOFFSETX: 4017 case XATTR_FILLBMP_TILEOFFSETY: 4018 case XATTR_FILLBMP_POSOFFSETX: 4019 case XATTR_FILLBMP_POSOFFSETY: 4020 case XATTR_FILLBMP_POS: 4021 case XATTR_FILLBMP_SIZEX: 4022 case XATTR_FILLBMP_SIZEY: 4023 case XATTR_FILLBMP_STRETCH: 4024 case XATTR_FILLBMP_TILE: 4025 case OWN_ATTR_FILLBMP_MODE: 4026 case XATTR_FILLCOLOR: 4027 case XATTR_FILLBACKGROUND: 4028 case XATTR_FILLBITMAP: 4029 case XATTR_GRADIENTSTEPCOUNT: 4030 case XATTR_FILLGRADIENT: 4031 case XATTR_FILLHATCH: 4032 case XATTR_FILLSTYLE: 4033 case XATTR_FILLTRANSPARENCE: 4034 case XATTR_FILLFLOATTRANSPARENCE: 4035 case XATTR_SECONDARYFILLCOLOR: 4036 { 4037 // This DrawingLayer FillStyle attributes can be part of Header, Footer and PageStyle 4038 // itself, so decide what to do using the name 4039 const bool bHeader(rPropName.EqualsAscii("Header", 0, 6)); 4040 const bool bFooter(rPropName.EqualsAscii("Footer", 0, 6)); 4041 4042 if(bHeader || bFooter) 4043 { 4044 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 4045 const SfxItemSet& rSet = xStyle->GetItemSet(); 4046 const SvxSetItem* pSetItem; 4047 4048 if(SFX_ITEM_SET == rSet.GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, sal_False, (const SfxPoolItem**)&pSetItem)) 4049 { 4050 // set at SfxItemSet of the corresponding SfxSetItem 4051 const SfxItemSet& rSetSet = pSetItem->GetItemSet(); 4052 SfxItemSet* pRememberItemSet = aBase.replaceItemSet(&const_cast< SfxItemSet& >(rSetSet)); 4053 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() ); 4054 aBase.replaceItemSet(pRememberItemSet); 4055 } 4056 } 4057 else 4058 { 4059 // part of PageStyle, fallback to default 4060 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() ); 4061 } 4062 4063 break; 4064 } 4065 4066 case FN_UNO_HEADER: 4067 case FN_UNO_HEADER_LEFT: 4068 case FN_UNO_HEADER_RIGHT: 4069 case FN_UNO_FOOTER: 4070 case FN_UNO_FOOTER_LEFT: 4071 case FN_UNO_FOOTER_RIGHT: 4072 { 4073 //UUUU cleanups for readability (undos removed, rearranged) 4074 bool bHeader(false); 4075 4076 switch(pEntry->nWID) 4077 { 4078 case FN_UNO_HEADER: bHeader = true; nRes = RES_HEADER; bAll = sal_True; break; 4079 case FN_UNO_HEADER_LEFT: bHeader = true; nRes = RES_HEADER; bLeft = sal_True; break; 4080 case FN_UNO_HEADER_RIGHT: bHeader = true; nRes = RES_HEADER; bRight = sal_True; break; 4081 case FN_UNO_FOOTER: bHeader = false; nRes = RES_FOOTER; bAll = sal_True; break; 4082 case FN_UNO_FOOTER_LEFT: bHeader = false; nRes = RES_FOOTER; bLeft = sal_True; break; 4083 case FN_UNO_FOOTER_RIGHT: bHeader = false; nRes = RES_FOOTER; bRight = sal_True; break; 4084 default: break; 4085 } 4086 4087 const SwPageDesc& rDesc = aBase.GetOldPageDesc(); 4088 const SwFrmFmt* pFrmFmt = 0; 4089 sal_Bool bShare = (bHeader && rDesc.IsHeaderShared()) || (!bHeader && rDesc.IsFooterShared()); 4090 // TextLeft returns the left content if there is one, 4091 // Text and TextRight return the master content. 4092 // TextRight does the same as Text and is for 4093 // comptability only. 4094 if( bLeft && !bShare ) 4095 { 4096 pFrmFmt = &rDesc.GetLeft(); 4097 } 4098 else 4099 { 4100 pFrmFmt = &rDesc.GetMaster(); 4101 } 4102 const uno::Reference< text::XText > xRet = 4103 lcl_makeHeaderFooter(nRes, bHeader, pFrmFmt); 4104 if (xRet.is()) 4105 { 4106 pRet[nProp] <<= xRet; 4107 } 4108 4109 break; 4110 } 4111 4112 case FN_PARAM_FTN_INFO : 4113 { 4114 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 4115 const SfxItemSet& rSet = xStyle->GetItemSet(); 4116 const SfxPoolItem& rItem = rSet.Get(FN_PARAM_FTN_INFO); 4117 rItem.QueryValue(pRet[nProp], nMemberId); 4118 break; 4119 } 4120 4121 default: 4122 { 4123 //UUUU 4124 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() ); 4125 break; 4126 } 4127 } 4128 } 4129 else if(IsDescriptor()) 4130 { 4131 uno::Any* pAny = 0; 4132 GetPropImpl()->GetProperty(rPropName, pAny); 4133 4134 if ( !pAny ) 4135 { 4136 GetPropImpl()->GetProperty ( rPropName, mxStyleData, pRet[ nProp ] ); 4137 } 4138 else 4139 { 4140 pRet[nProp] = *pAny; 4141 } 4142 } 4143 else 4144 { 4145 throw uno::RuntimeException(); 4146 } 4147 } 4148 4149 return aRet; 4150 } 4151 /* -----------------------------18.04.01 13:50-------------------------------- 4152 4153 ---------------------------------------------------------------------------*/ 4154 uno::Sequence< uno::Any > SwXPageStyle::getPropertyValues( 4155 const uno::Sequence< OUString >& rPropertyNames ) 4156 throw(uno::RuntimeException) 4157 { 4158 vos::OGuard aGuard(Application::GetSolarMutex()); 4159 uno::Sequence< uno::Any > aValues; 4160 4161 // workaround for bad designed API 4162 try 4163 { 4164 aValues = GetPropertyValues_Impl( rPropertyNames ); 4165 } 4166 catch (beans::UnknownPropertyException &) 4167 { 4168 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 4169 } 4170 catch (lang::WrappedTargetException &) 4171 { 4172 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 4173 } 4174 4175 return aValues; 4176 } 4177 /*-- 17.12.98 08:43:36--------------------------------------------------- 4178 4179 -----------------------------------------------------------------------*/ 4180 uno::Any SwXPageStyle::getPropertyValue( 4181 const OUString& rPropertyName) 4182 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 4183 { 4184 vos::OGuard aGuard(Application::GetSolarMutex()); 4185 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 4186 4187 return GetPropertyValues_Impl(aProperties).getConstArray()[0]; 4188 } 4189 /*-- 17.12.98 08:43:36--------------------------------------------------- 4190 4191 -----------------------------------------------------------------------*/ 4192 void SwXPageStyle::setPropertyValue( 4193 const OUString& rPropertyName, 4194 const uno::Any& rValue) 4195 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 4196 { 4197 vos::OGuard aGuard(Application::GetSolarMutex()); 4198 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 4199 const uno::Sequence<uno::Any> aValues(&rValue, 1); 4200 4201 SetPropertyValues_Impl( aProperties, aValues ); 4202 } 4203 4204 SwXFrameStyle::SwXFrameStyle ( SwDoc *pDoc ) 4205 : SwXStyle ( pDoc, SFX_STYLE_FAMILY_FRAME, sal_False) 4206 { 4207 } 4208 /* -----------------------------15.12.00 15:45-------------------------------- 4209 4210 ---------------------------------------------------------------------------*/ 4211 SwXFrameStyle::~SwXFrameStyle() 4212 { 4213 } 4214 /* -----------------------------15.12.00 14:30-------------------------------- 4215 4216 ---------------------------------------------------------------------------*/ 4217 uno::Sequence< uno::Type > SwXFrameStyle::getTypes( ) throw(uno::RuntimeException) 4218 { 4219 uno::Sequence< uno::Type > aTypes = SwXStyle::getTypes(); 4220 sal_Int32 nLen = aTypes.getLength(); 4221 aTypes.realloc(nLen + 1); 4222 aTypes.getArray()[nLen] = ::getCppuType((uno::Reference<XEventsSupplier>*)0); 4223 return aTypes; 4224 } 4225 /* -----------------------------15.12.00 14:30-------------------------------- 4226 4227 ---------------------------------------------------------------------------*/ 4228 uno::Any SwXFrameStyle::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException) 4229 { 4230 uno::Any aRet; 4231 if(rType == ::getCppuType((uno::Reference<XEventsSupplier>*)0)) 4232 aRet <<= uno::Reference<XEventsSupplier>(this); 4233 else 4234 aRet = SwXStyle::queryInterface(rType); 4235 return aRet; 4236 } 4237 /* -----------------------------15.12.00 14:30-------------------------------- 4238 4239 ---------------------------------------------------------------------------*/ 4240 uno::Reference< container::XNameReplace > SwXFrameStyle::getEvents( ) throw(uno::RuntimeException) 4241 { 4242 return new SwFrameStyleEventDescriptor( *this ); 4243 } 4244 /*-- 19.05.2006 11:23:55--------------------------------------------------- 4245 4246 -----------------------------------------------------------------------*/ 4247 SwXAutoStyles::SwXAutoStyles(SwDocShell& rDocShell) : 4248 SwUnoCollection(rDocShell.GetDoc()), pDocShell( &rDocShell ) 4249 { 4250 } 4251 /*-- 19.05.2006 11:23:56--------------------------------------------------- 4252 4253 -----------------------------------------------------------------------*/ 4254 SwXAutoStyles::~SwXAutoStyles() 4255 { 4256 } 4257 /*-- 19.05.2006 11:23:57--------------------------------------------------- 4258 4259 -----------------------------------------------------------------------*/ 4260 sal_Int32 SwXAutoStyles::getCount(void) throw( uno::RuntimeException ) 4261 { 4262 return AUTOSTYLE_FAMILY_COUNT; 4263 } 4264 /*-- 19.05.2006 11:23:57--------------------------------------------------- 4265 4266 -----------------------------------------------------------------------*/ 4267 uno::Any SwXAutoStyles::getByIndex(sal_Int32 nIndex) 4268 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, 4269 uno::RuntimeException ) 4270 { 4271 vos::OGuard aGuard(Application::GetSolarMutex()); 4272 uno::Any aRet; 4273 if(nIndex < 0 || nIndex >= AUTOSTYLE_FAMILY_COUNT) 4274 throw lang::IndexOutOfBoundsException(); 4275 if(IsValid()) 4276 { 4277 uno::Reference< style::XAutoStyleFamily > aRef; 4278 IStyleAccess::SwAutoStyleFamily nType = aAutoStyleByIndex[nIndex]; 4279 switch( nType ) 4280 { 4281 case IStyleAccess::AUTO_STYLE_CHAR: 4282 { 4283 if(!xAutoCharStyles.is()) 4284 xAutoCharStyles = new SwXAutoStyleFamily(pDocShell, nType); 4285 aRef = xAutoCharStyles; 4286 } 4287 break; 4288 case IStyleAccess::AUTO_STYLE_RUBY: 4289 { 4290 if(!xAutoRubyStyles.is()) 4291 xAutoRubyStyles = new SwXAutoStyleFamily(pDocShell, nType ); 4292 aRef = xAutoRubyStyles; 4293 } 4294 break; 4295 case IStyleAccess::AUTO_STYLE_PARA: 4296 { 4297 if(!xAutoParaStyles.is()) 4298 xAutoParaStyles = new SwXAutoStyleFamily(pDocShell, nType ); 4299 aRef = xAutoParaStyles; 4300 } 4301 break; 4302 4303 default: 4304 ; 4305 } 4306 aRet.setValue(&aRef, ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0)); 4307 } 4308 else 4309 throw uno::RuntimeException(); 4310 return aRet; 4311 } 4312 /*-- 19.05.2006 11:23:57--------------------------------------------------- 4313 4314 -----------------------------------------------------------------------*/ 4315 uno::Type SwXAutoStyles::getElementType( ) throw(uno::RuntimeException) 4316 { 4317 return ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0); 4318 } 4319 /*-- 19.05.2006 11:23:58--------------------------------------------------- 4320 4321 -----------------------------------------------------------------------*/ 4322 sal_Bool SwXAutoStyles::hasElements( ) throw(uno::RuntimeException) 4323 { 4324 return sal_True; 4325 } 4326 /*-- 19.05.2006 11:23:58--------------------------------------------------- 4327 4328 -----------------------------------------------------------------------*/ 4329 uno::Any SwXAutoStyles::getByName(const rtl::OUString& Name) 4330 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) 4331 { 4332 uno::Any aRet; 4333 if(Name.compareToAscii("CharacterStyles") == 0 ) 4334 aRet = getByIndex(0); 4335 else if(Name.compareToAscii("RubyStyles") == 0 ) 4336 aRet = getByIndex(1); 4337 else if(Name.compareToAscii("ParagraphStyles") == 0 ) 4338 aRet = getByIndex(2); 4339 else 4340 throw container::NoSuchElementException(); 4341 return aRet; 4342 } 4343 /*-- 19.05.2006 11:23:59--------------------------------------------------- 4344 4345 -----------------------------------------------------------------------*/ 4346 uno::Sequence< rtl::OUString > SwXAutoStyles::getElementNames(void) 4347 throw( uno::RuntimeException ) 4348 { 4349 uno::Sequence< OUString > aNames(AUTOSTYLE_FAMILY_COUNT); 4350 OUString* pNames = aNames.getArray(); 4351 pNames[0] = C2U("CharacterStyles"); 4352 pNames[1] = C2U("RubyStyles"); 4353 pNames[2] = C2U("ParagraphStyles"); 4354 return aNames; 4355 } 4356 /*-- 19.05.2006 11:24:00--------------------------------------------------- 4357 4358 -----------------------------------------------------------------------*/ 4359 sal_Bool SwXAutoStyles::hasByName(const rtl::OUString& Name) 4360 throw( uno::RuntimeException ) 4361 { 4362 if( Name.compareToAscii("CharacterStyles") == 0 || 4363 Name.compareToAscii("RubyStyles") == 0 || 4364 Name.compareToAscii("ParagraphStyles") == 0 ) 4365 return sal_True; 4366 else 4367 return sal_False; 4368 } 4369 4370 /*-- 19.05.2006 11:24:02--------------------------------------------------- 4371 4372 -----------------------------------------------------------------------*/ 4373 SwXAutoStyleFamily::SwXAutoStyleFamily(SwDocShell* pDocSh, IStyleAccess::SwAutoStyleFamily nFamily) : 4374 pDocShell( pDocSh ), eFamily(nFamily) 4375 { 4376 // Register ourselves as a listener to the document (via the page descriptor) 4377 pDocSh->GetDoc()->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); 4378 } 4379 /*-- 19.05.2006 11:24:02--------------------------------------------------- 4380 4381 -----------------------------------------------------------------------*/ 4382 SwXAutoStyleFamily::~SwXAutoStyleFamily() 4383 { 4384 } 4385 4386 void SwXAutoStyleFamily::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) 4387 { 4388 ClientModify(this, pOld, pNew); 4389 if(!GetRegisteredIn()) 4390 pDocShell = 0; 4391 } 4392 4393 /*-- 31.05.2006 11:24:02--------------------------------------------------- 4394 4395 -----------------------------------------------------------------------*/ 4396 uno::Reference< style::XAutoStyle > SwXAutoStyleFamily::insertStyle( 4397 const uno::Sequence< beans::PropertyValue >& Values ) 4398 throw (uno::RuntimeException) 4399 { 4400 if( !pDocShell ) 4401 { 4402 throw uno::RuntimeException(); 4403 } 4404 4405 const sal_uInt16* pRange = 0; 4406 const SfxItemPropertySet* pPropSet = 0; 4407 4408 switch( eFamily ) 4409 { 4410 case IStyleAccess::AUTO_STYLE_CHAR: 4411 { 4412 pRange = aCharAutoFmtSetRange; 4413 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE); 4414 break; 4415 } 4416 case IStyleAccess::AUTO_STYLE_RUBY: 4417 { 4418 pRange = 0;//aTxtNodeSetRange; 4419 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_RUBY_AUTO_STYLE); 4420 break; 4421 } 4422 case IStyleAccess::AUTO_STYLE_PARA: 4423 { 4424 pRange = aTxtNodeSetRange; //UUUU checked, already added support for [XATTR_FILL_FIRST, XATTR_FILL_LAST] 4425 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARA_AUTO_STYLE); 4426 break; 4427 } 4428 4429 default: break; 4430 } 4431 4432 SwAttrSet aSet( pDocShell->GetDoc()->GetAttrPool(), pRange ); 4433 const beans::PropertyValue* pSeq = Values.getConstArray(); 4434 sal_Int32 nLen = Values.getLength(); 4435 const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == eFamily); 4436 4437 if(!bTakeCareOfDrawingLayerFillStyle) 4438 { 4439 for( sal_Int32 i = 0; i < nLen; ++i ) 4440 { 4441 try 4442 { 4443 pPropSet->setPropertyValue( pSeq[i].Name, pSeq[i].Value, aSet ); 4444 } 4445 catch (beans::UnknownPropertyException &) 4446 { 4447 ASSERT( false, "Unknown property" ); 4448 } 4449 catch (lang::IllegalArgumentException &) 4450 { 4451 ASSERT( false, "Illegal argument" ); 4452 } 4453 } 4454 } 4455 else 4456 { 4457 //UUUU set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem 4458 // to make cases in RES_BACKGROUND work correct; target *is* a style 4459 // where this is the case 4460 aSet.SetParent(&pDocShell->GetDoc()->GetDfltTxtFmtColl()->GetAttrSet()); 4461 4462 //UUUU here the used DrawingLayer FillStyles are imported when family is 4463 // equal to IStyleAccess::AUTO_STYLE_PARA, thus we will need to serve the 4464 // used slots functionality here to do this correctly 4465 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 4466 4467 for( sal_Int32 i = 0; i < nLen; ++i ) 4468 { 4469 const OUString& rPropName = pSeq[i].Name; 4470 uno::Any aValue(pSeq[i].Value); 4471 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName); 4472 4473 if(!pEntry) 4474 { 4475 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 4476 } 4477 4478 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM)); 4479 bool bDone(false); 4480 4481 // check for needed metric translation 4482 if(pEntry->nMemberId & SFX_METRIC_ITEM) 4483 { 4484 bool bDoIt(true); 4485 4486 if(XATTR_FILLBMP_SIZEX == pEntry->nWID || XATTR_FILLBMP_SIZEY == pEntry->nWID) 4487 { 4488 // exception: If these ItemTypes are used, do not convert when these are negative 4489 // since this means they are intended as percent values 4490 sal_Int32 nValue = 0; 4491 4492 if(aValue >>= nValue) 4493 { 4494 bDoIt = nValue > 0; 4495 } 4496 } 4497 4498 if(bDoIt) 4499 { 4500 const SfxItemPool& rPool = pDocShell->GetDoc()->GetAttrPool(); 4501 const SfxMapUnit eMapUnit(rPool.GetMetric(pEntry->nWID)); 4502 4503 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 4504 { 4505 SvxUnoConvertFromMM(eMapUnit, aValue); 4506 } 4507 } 4508 } 4509 4510 switch(pEntry->nWID) 4511 { 4512 case XATTR_FILLGRADIENT: 4513 case XATTR_FILLHATCH: 4514 case XATTR_FILLBITMAP: 4515 case XATTR_FILLFLOATTRANSPARENCE: 4516 // not yet needed; activate when LineStyle support may be added 4517 // case XATTR_LINESTART: 4518 // case XATTR_LINEEND: 4519 // case XATTR_LINEDASH: 4520 { 4521 if(MID_NAME == nMemberId) 4522 { 4523 //UUUU add set commands for FillName items 4524 OUString aTempName; 4525 4526 if(!(aValue >>= aTempName)) 4527 { 4528 throw lang::IllegalArgumentException(); 4529 } 4530 4531 SvxShape::SetFillAttribute(pEntry->nWID, aTempName, aSet); 4532 bDone = true; 4533 } 4534 else if(MID_GRAFURL == nMemberId) 4535 { 4536 if(XATTR_FILLBITMAP == pEntry->nWID) 4537 { 4538 //UUUU Bitmap also has the MID_GRAFURL mode where a Bitmap URL is used 4539 const Graphic aNullGraphic; 4540 XFillBitmapItem aXFillBitmapItem(aSet.GetPool(), aNullGraphic); 4541 4542 aXFillBitmapItem.PutValue(aValue, nMemberId); 4543 aSet.Put(aXFillBitmapItem); 4544 bDone = true; 4545 } 4546 } 4547 4548 break; 4549 } 4550 case RES_BACKGROUND: 4551 { 4552 //UUUU 4553 const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND)); 4554 SvxBrushItem aChangedBrushItem(aOriginalBrushItem); 4555 4556 aChangedBrushItem.PutValue(aValue, nMemberId); 4557 4558 if(!(aChangedBrushItem == aOriginalBrushItem)) 4559 { 4560 setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, aSet); 4561 } 4562 4563 bDone = true; 4564 break; 4565 } 4566 case OWN_ATTR_FILLBMP_MODE: 4567 { 4568 //UUUU 4569 drawing::BitmapMode eMode; 4570 4571 if(!(aValue >>= eMode)) 4572 { 4573 sal_Int32 nMode = 0; 4574 4575 if(!(aValue >>= nMode)) 4576 { 4577 throw lang::IllegalArgumentException(); 4578 } 4579 4580 eMode = (drawing::BitmapMode)nMode; 4581 } 4582 4583 aSet.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH == eMode)); 4584 aSet.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT == eMode)); 4585 4586 bDone = true; 4587 break; 4588 } 4589 default: break; 4590 } 4591 4592 if(!bDone) 4593 { 4594 pPropSet->setPropertyValue( rPropName, aValue, aSet ); 4595 } 4596 } 4597 4598 //UUUU clear parent again 4599 aSet.SetParent(0); 4600 } 4601 4602 //UUUU need to ensure uniqueness of evtl. added NameOrIndex items 4603 // currently in principle only needed when bTakeCareOfDrawingLayerFillStyle, 4604 // but does not hurt and is easily forgotten later eventually, so keep it 4605 // as common case 4606 pDocShell->GetDoc()->CheckForUniqueItemForLineFillNameOrIndex(aSet); 4607 4608 // AutomaticStyle creation 4609 SfxItemSet_Pointer_t pSet = pDocShell->GetDoc()->GetIStyleAccess().cacheAutomaticStyle( aSet, eFamily ); 4610 uno::Reference<style::XAutoStyle> xRet = new SwXAutoStyle(pDocShell->GetDoc(), pSet, eFamily); 4611 4612 return xRet; 4613 } 4614 /*-- 31.05.2006 11:24:02--------------------------------------------------- 4615 4616 -----------------------------------------------------------------------*/ 4617 uno::Reference< container::XEnumeration > SwXAutoStyleFamily::createEnumeration( ) 4618 throw (uno::RuntimeException) 4619 { 4620 if( !pDocShell ) 4621 throw uno::RuntimeException(); 4622 return uno::Reference< container::XEnumeration > 4623 (new SwXAutoStylesEnumerator( pDocShell->GetDoc(), eFamily )); 4624 } 4625 /*-- 19.05.2006 11:24:03--------------------------------------------------- 4626 4627 -----------------------------------------------------------------------*/ 4628 uno::Type SwXAutoStyleFamily::getElementType( ) throw(uno::RuntimeException) 4629 { 4630 return ::getCppuType((const uno::Reference<style::XAutoStyle>*)0); 4631 } 4632 /*-- 19.05.2006 11:24:04--------------------------------------------------- 4633 4634 -----------------------------------------------------------------------*/ 4635 sal_Bool SwXAutoStyleFamily::hasElements( ) throw(uno::RuntimeException) 4636 { 4637 return sal_False; 4638 } 4639 4640 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4641 4642 -----------------------------------------------------------------------*/ 4643 SwAutoStylesEnumImpl::SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam ) 4644 : pDoc( pInitDoc ), eFamily( eFam ) 4645 { 4646 // special case for ruby auto styles: 4647 if ( IStyleAccess::AUTO_STYLE_RUBY == eFam ) 4648 { 4649 std::set< std::pair< sal_uInt16, sal_uInt16 > > aRubyMap; 4650 SwAttrPool& rAttrPool = pDoc->GetAttrPool(); 4651 sal_uInt32 nCount = rAttrPool.GetItemCount2( RES_TXTATR_CJK_RUBY ); 4652 4653 for ( sal_uInt32 nI = 0; nI < nCount; ++nI ) 4654 { 4655 const SwFmtRuby* pItem = static_cast<const SwFmtRuby*>(rAttrPool.GetItem2( RES_TXTATR_CJK_RUBY, nI )); 4656 if ( pItem && pItem->GetTxtRuby() ) 4657 { 4658 std::pair< sal_uInt16, sal_uInt16 > aPair( pItem->GetPosition(), pItem->GetAdjustment() ); 4659 if ( aRubyMap.find( aPair ) == aRubyMap.end() ) 4660 { 4661 aRubyMap.insert( aPair ); 4662 SfxItemSet_Pointer_t pItemSet( new SfxItemSet( rAttrPool, RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY ) ); 4663 pItemSet->Put( *pItem ); 4664 mAutoStyles.push_back( pItemSet ); 4665 } 4666 } 4667 } 4668 } 4669 else 4670 { 4671 pDoc->GetIStyleAccess().getAllStyles( mAutoStyles, eFamily ); 4672 } 4673 4674 aIter = mAutoStyles.begin(); 4675 } 4676 4677 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4678 4679 -----------------------------------------------------------------------*/ 4680 SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwAutoStyleFamily eFam ) 4681 : pImpl( new SwAutoStylesEnumImpl( pDoc, eFam ) ) 4682 { 4683 // Register ourselves as a listener to the document (via the page descriptor) 4684 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); 4685 } 4686 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4687 4688 -----------------------------------------------------------------------*/ 4689 SwXAutoStylesEnumerator::~SwXAutoStylesEnumerator() 4690 { 4691 delete pImpl; 4692 } 4693 4694 void SwXAutoStylesEnumerator::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) 4695 { 4696 ClientModify(this, pOld, pNew); 4697 if(!GetRegisteredIn()) 4698 { 4699 delete pImpl; 4700 pImpl = 0; 4701 } 4702 } 4703 4704 4705 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4706 4707 -----------------------------------------------------------------------*/ 4708 ::sal_Bool SwXAutoStylesEnumerator::hasMoreElements( ) 4709 throw (uno::RuntimeException) 4710 { 4711 if( !pImpl ) 4712 throw uno::RuntimeException(); 4713 return pImpl->hasMoreElements(); 4714 } 4715 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4716 4717 -----------------------------------------------------------------------*/ 4718 uno::Any SwXAutoStylesEnumerator::nextElement( ) 4719 throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 4720 { 4721 if( !pImpl ) 4722 throw uno::RuntimeException(); 4723 uno::Any aRet; 4724 if( pImpl->hasMoreElements() ) 4725 { 4726 SfxItemSet_Pointer_t pNextSet = pImpl->nextElement(); 4727 uno::Reference< style::XAutoStyle > xAutoStyle = new SwXAutoStyle(pImpl->getDoc(), 4728 pNextSet, pImpl->getFamily()); 4729 aRet.setValue(&xAutoStyle, ::getCppuType((uno::Reference<style::XAutoStyle>*)0)); 4730 } 4731 return aRet; 4732 } 4733 4734 ////////////////////////////////////////////////////////////////////////////// 4735 //UUUU SwXAutoStyle with the family IStyleAccess::AUTO_STYLE_PARA (or 4736 // PROPERTY_MAP_PARA_AUTO_STYLE) now uses DrawingLayer FillStyles to allow 4737 // unified paragraph background fill, thus the UNO API implementation has to 4738 // support the needed slots for these. This seems to be used only for reading 4739 // (no setPropertyValue implementation here), so maybe specialized for saving 4740 // the Writer Doc to ODF 4741 4742 SwXAutoStyle::SwXAutoStyle( 4743 SwDoc* pDoc, 4744 SfxItemSet_Pointer_t pInitSet, 4745 IStyleAccess::SwAutoStyleFamily eFam) 4746 : mpSet(pInitSet), 4747 meFamily(eFam), 4748 mrDoc(*pDoc) 4749 { 4750 // Register ourselves as a listener to the document (via the page descriptor) 4751 mrDoc.GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); 4752 } 4753 4754 SwXAutoStyle::~SwXAutoStyle() 4755 { 4756 } 4757 4758 void SwXAutoStyle::Modify( 4759 const SfxPoolItem* pOld, 4760 const SfxPoolItem *pNew) 4761 { 4762 ClientModify(this, pOld, pNew); 4763 4764 if(!GetRegisteredIn()) 4765 { 4766 mpSet.reset(); 4767 } 4768 } 4769 4770 uno::Reference< beans::XPropertySetInfo > SwXAutoStyle::getPropertySetInfo() 4771 throw (uno::RuntimeException) 4772 { 4773 uno::Reference< beans::XPropertySetInfo > xRet; 4774 switch( meFamily ) 4775 { 4776 case IStyleAccess::AUTO_STYLE_CHAR: 4777 { 4778 static uno::Reference< beans::XPropertySetInfo > xCharRef; 4779 if(!xCharRef.is()) 4780 { 4781 xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE)->getPropertySetInfo(); 4782 } 4783 xRet = xCharRef; 4784 } 4785 break; 4786 case IStyleAccess::AUTO_STYLE_RUBY: 4787 { 4788 static uno::Reference< beans::XPropertySetInfo > xRubyRef; 4789 if(!xRubyRef.is()) 4790 { 4791 sal_uInt16 nMapId = PROPERTY_MAP_RUBY_AUTO_STYLE; 4792 xRubyRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo(); 4793 } 4794 xRet = xRubyRef; 4795 } 4796 break; 4797 case IStyleAccess::AUTO_STYLE_PARA: 4798 { 4799 static uno::Reference< beans::XPropertySetInfo > xParaRef; 4800 if(!xParaRef.is()) 4801 { 4802 sal_uInt16 nMapId = PROPERTY_MAP_PARA_AUTO_STYLE; 4803 xParaRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo(); 4804 } 4805 xRet = xParaRef; 4806 } 4807 break; 4808 4809 default: 4810 ; 4811 } 4812 4813 return xRet; 4814 } 4815 4816 void SwXAutoStyle::setPropertyValue( 4817 const OUString& /*rPropertyName*/, 4818 const uno::Any& /*rValue*/ ) 4819 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 4820 { 4821 } 4822 4823 uno::Any SwXAutoStyle::getPropertyValue( 4824 const OUString& rPropertyName ) 4825 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 4826 { 4827 vos::OGuard aGuard(Application::GetSolarMutex()); 4828 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 4829 4830 return GetPropertyValues_Impl(aProperties).getConstArray()[0]; 4831 } 4832 4833 void SwXAutoStyle::addPropertyChangeListener( 4834 const OUString& /*aPropertyName*/, 4835 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) 4836 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 4837 { 4838 } 4839 4840 void SwXAutoStyle::removePropertyChangeListener( 4841 const OUString& /*aPropertyName*/, 4842 const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) 4843 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 4844 { 4845 } 4846 4847 void SwXAutoStyle::addVetoableChangeListener( 4848 const OUString& /*PropertyName*/, 4849 const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) 4850 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 4851 { 4852 } 4853 4854 void SwXAutoStyle::removeVetoableChangeListener( 4855 const OUString& /*PropertyName*/, 4856 const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) 4857 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 4858 { 4859 } 4860 4861 void SwXAutoStyle::setPropertyValues( 4862 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, 4863 const uno::Sequence< uno::Any >& /*aValues*/ ) 4864 throw (beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 4865 { 4866 } 4867 4868 uno::Sequence< uno::Any > SwXAutoStyle::GetPropertyValues_Impl( 4869 const uno::Sequence< OUString > & rPropertyNames ) 4870 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 4871 { 4872 if( !mpSet.get() ) 4873 { 4874 throw uno::RuntimeException(); 4875 } 4876 4877 // query_item 4878 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; 4879 4880 switch(meFamily) 4881 { 4882 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break; 4883 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break; 4884 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break; 4885 default: ; 4886 } 4887 4888 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 4889 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 4890 const OUString* pNames = rPropertyNames.getConstArray(); 4891 const sal_Int32 nLen(rPropertyNames.getLength()); 4892 uno::Sequence< uno::Any > aRet( nLen ); 4893 uno::Any* pValues = aRet.getArray(); 4894 const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == meFamily); 4895 4896 for( sal_Int32 i = 0; i < nLen; ++i ) 4897 { 4898 const OUString& rPropName = pNames[i]; 4899 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName); 4900 4901 if(!pEntry) 4902 { 4903 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 4904 } 4905 4906 uno::Any aTarget; 4907 bool bDone(false); 4908 4909 if ( RES_TXTATR_AUTOFMT == pEntry->nWID || RES_AUTO_STYLE == pEntry->nWID ) 4910 { 4911 OUString sName(StylePool::nameOf( mpSet )); 4912 aTarget <<= sName; 4913 bDone = true; 4914 } 4915 else if(bTakeCareOfDrawingLayerFillStyle) 4916 { 4917 //UUUU add support for DrawingLayer FillStyle slots 4918 switch(pEntry->nWID) 4919 { 4920 case RES_BACKGROUND: 4921 { 4922 const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(*mpSet, RES_BACKGROUND)); 4923 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM)); 4924 4925 if(!aOriginalBrushItem.QueryValue(aTarget, nMemberId)) 4926 { 4927 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)"); 4928 } 4929 4930 bDone = true; 4931 break; 4932 } 4933 case OWN_ATTR_FILLBMP_MODE: 4934 { 4935 const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&mpSet->Get(XATTR_FILLBMP_STRETCH)); 4936 const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&mpSet->Get(XATTR_FILLBMP_TILE)); 4937 4938 if( pTileItem && pTileItem->GetValue() ) 4939 { 4940 aTarget <<= drawing::BitmapMode_REPEAT; 4941 } 4942 else if( pStretchItem && pStretchItem->GetValue() ) 4943 { 4944 aTarget <<= drawing::BitmapMode_STRETCH; 4945 } 4946 else 4947 { 4948 aTarget <<= drawing::BitmapMode_NO_REPEAT; 4949 } 4950 4951 bDone = true; 4952 break; 4953 } 4954 } 4955 } 4956 4957 if(!bDone) 4958 { 4959 pPropSet->getPropertyValue( *pEntry, *mpSet, aTarget ); 4960 } 4961 4962 if(bTakeCareOfDrawingLayerFillStyle) 4963 { 4964 if(pEntry->pType && *(pEntry->pType) == ::getCppuType((const sal_Int16*)0) && *(pEntry->pType) != aTarget.getValueType()) 4965 { 4966 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here 4967 sal_Int32 nValue = 0; 4968 aTarget >>= nValue; 4969 aTarget <<= (sal_Int16)nValue; 4970 } 4971 4972 // check for needed metric translation 4973 if(pEntry->nMemberId & SFX_METRIC_ITEM) 4974 { 4975 bool bDoIt(true); 4976 4977 if(XATTR_FILLBMP_SIZEX == pEntry->nWID || XATTR_FILLBMP_SIZEY == pEntry->nWID) 4978 { 4979 // exception: If these ItemTypes are used, do not convert when these are negative 4980 // since this means they are intended as percent values 4981 sal_Int32 nValue = 0; 4982 4983 if(aTarget >>= nValue) 4984 { 4985 bDoIt = nValue > 0; 4986 } 4987 } 4988 4989 if(bDoIt) 4990 { 4991 const SfxItemPool& rPool = mrDoc.GetAttrPool(); 4992 const SfxMapUnit eMapUnit(rPool.GetMetric(pEntry->nWID)); 4993 4994 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 4995 { 4996 SvxUnoConvertToMM(eMapUnit, aTarget); 4997 } 4998 } 4999 } 5000 } 5001 5002 // add value 5003 pValues[i] = aTarget; 5004 } 5005 5006 return aRet; 5007 } 5008 5009 uno::Sequence< uno::Any > SwXAutoStyle::getPropertyValues ( 5010 const uno::Sequence< ::rtl::OUString >& rPropertyNames ) 5011 throw (uno::RuntimeException) 5012 { 5013 vos::OGuard aGuard(Application::GetSolarMutex()); 5014 uno::Sequence< uno::Any > aValues; 5015 5016 // workaround for bad designed API 5017 try 5018 { 5019 aValues = GetPropertyValues_Impl( rPropertyNames ); 5020 } 5021 catch (beans::UnknownPropertyException &) 5022 { 5023 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 5024 } 5025 catch (lang::WrappedTargetException &) 5026 { 5027 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 5028 } 5029 5030 return aValues; 5031 } 5032 5033 void SwXAutoStyle::addPropertiesChangeListener( 5034 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, 5035 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 5036 throw (uno::RuntimeException) 5037 { 5038 } 5039 5040 void SwXAutoStyle::removePropertiesChangeListener( 5041 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 5042 throw (uno::RuntimeException) 5043 { 5044 } 5045 5046 void SwXAutoStyle::firePropertiesChangeEvent( 5047 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, 5048 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 5049 throw (uno::RuntimeException) 5050 { 5051 } 5052 5053 beans::PropertyState SwXAutoStyle::getPropertyState( 5054 const OUString& rPropertyName ) 5055 throw( beans::UnknownPropertyException, uno::RuntimeException) 5056 { 5057 vos::OGuard aGuard(Application::GetSolarMutex()); 5058 5059 uno::Sequence< OUString > aNames(1); 5060 OUString* pNames = aNames.getArray(); 5061 pNames[0] = rPropertyName; 5062 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames); 5063 return aStates.getConstArray()[0]; 5064 } 5065 5066 void SwXAutoStyle::setPropertyToDefault( 5067 const OUString& /*PropertyName*/ ) 5068 throw( beans::UnknownPropertyException, uno::RuntimeException ) 5069 { 5070 } 5071 5072 uno::Any SwXAutoStyle::getPropertyDefault( 5073 const OUString& rPropertyName ) 5074 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 5075 { 5076 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 ); 5077 5078 return getPropertyDefaults ( aSequence ).getConstArray()[0]; 5079 } 5080 5081 uno::Sequence< beans::PropertyState > SwXAutoStyle::getPropertyStates( 5082 const uno::Sequence< ::rtl::OUString >& rPropertyNames ) 5083 throw (beans::UnknownPropertyException, uno::RuntimeException) 5084 { 5085 if( !mpSet.get() ) 5086 { 5087 throw uno::RuntimeException(); 5088 } 5089 5090 vos::OGuard aGuard(Application::GetSolarMutex()); 5091 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength()); 5092 beans::PropertyState* pStates = aRet.getArray(); 5093 const OUString* pNames = rPropertyNames.getConstArray(); 5094 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; 5095 5096 switch(meFamily) 5097 { 5098 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break; 5099 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break; 5100 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break; 5101 default: ; 5102 } 5103 5104 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 5105 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 5106 const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == meFamily); 5107 5108 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) 5109 { 5110 const OUString& rPropName = pNames[i]; 5111 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName); 5112 5113 if(!pEntry) 5114 { 5115 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 5116 } 5117 5118 bool bDone(false); 5119 5120 if(bTakeCareOfDrawingLayerFillStyle) 5121 { 5122 //UUUU DrawingLayer PropertyStyle support 5123 switch(pEntry->nWID) 5124 { 5125 case OWN_ATTR_FILLBMP_MODE: 5126 { 5127 if(SFX_ITEM_SET == mpSet->GetItemState(XATTR_FILLBMP_STRETCH, false) 5128 || SFX_ITEM_SET == mpSet->GetItemState(XATTR_FILLBMP_TILE, false)) 5129 { 5130 pStates[i] = beans::PropertyState_DIRECT_VALUE; 5131 } 5132 else 5133 { 5134 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE; 5135 } 5136 5137 bDone = true; 5138 break; 5139 } 5140 case RES_BACKGROUND: 5141 { 5142 if(SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*mpSet)) 5143 { 5144 pStates[i] = beans::PropertyState_DIRECT_VALUE; 5145 bDone = true; 5146 } 5147 5148 break; 5149 } 5150 } 5151 } 5152 5153 if(!bDone) 5154 { 5155 pStates[i] = pPropSet->getPropertyState(*pEntry, *mpSet ); 5156 } 5157 } 5158 5159 return aRet; 5160 } 5161 5162 void SwXAutoStyle::setAllPropertiesToDefault( ) 5163 throw (uno::RuntimeException) 5164 { 5165 } 5166 5167 void SwXAutoStyle::setPropertiesToDefault( 5168 const uno::Sequence< ::rtl::OUString >& rPropertyNames ) 5169 throw (beans::UnknownPropertyException, uno::RuntimeException) 5170 { 5171 if( !mpSet.get() ) 5172 { 5173 throw uno::RuntimeException(); 5174 } 5175 5176 const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == meFamily); 5177 5178 if(!bTakeCareOfDrawingLayerFillStyle) 5179 { 5180 return; 5181 } 5182 5183 //UUUU support DrawingLayer FillStyle slots from here on 5184 vos::OGuard aGuard(Application::GetSolarMutex()); 5185 const OUString* pNames = rPropertyNames.getConstArray(); 5186 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; 5187 5188 switch(meFamily) 5189 { 5190 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break; 5191 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break; 5192 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break; 5193 default: ; 5194 } 5195 5196 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 5197 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 5198 5199 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) 5200 { 5201 const OUString& rPropName = pNames[i]; 5202 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName); 5203 5204 if(!pEntry) 5205 { 5206 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 5207 } 5208 5209 switch(pEntry->nWID) 5210 { 5211 case OWN_ATTR_FILLBMP_MODE: 5212 { 5213 mpSet->ClearItem(XATTR_FILLBMP_STRETCH); 5214 mpSet->ClearItem(XATTR_FILLBMP_TILE); 5215 } 5216 } 5217 } 5218 } 5219 5220 uno::Sequence< uno::Any > SwXAutoStyle::getPropertyDefaults( 5221 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/ ) 5222 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 5223 { 5224 uno::Sequence< uno::Any > aRet(0); 5225 5226 return aRet; 5227 } 5228 5229 uno::Sequence< beans::PropertyValue > SwXAutoStyle::getProperties() 5230 throw (uno::RuntimeException) 5231 { 5232 if( !mpSet.get() ) 5233 throw uno::RuntimeException(); 5234 vos::OGuard aGuard(Application::GetSolarMutex()); 5235 std::vector< beans::PropertyValue > aPropertyVector; 5236 5237 sal_Int8 nPropSetId = 0; 5238 switch(meFamily) 5239 { 5240 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break; 5241 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break; 5242 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break; 5243 default: 5244 ; 5245 } 5246 5247 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 5248 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 5249 PropertyEntryVector_t aPropVector = pMap->getPropertyEntries(); 5250 // struct compareWhichIds 5251 // { 5252 // bool operator()(const sal_uInt16 w1, const sal_uInt16 w2) const 5253 // { 5254 // return w1 < w2; 5255 // } 5256 // }; 5257 // typedef std::map<const sal_uInt16, SfxItemPropertyNamedEntry, compareWhichIds> PropertyMap_t; 5258 // PropertyMap_t aPropMap; 5259 // aPropMap.reserve( aPropVector.size() ); 5260 // PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin(); 5261 // while( aIt != aPropertyEntries.end() ) 5262 // { 5263 // aPropMap[aIt->nWID] = *aIt; 5264 // ++aIt; 5265 // } 5266 5267 SfxItemSet& rSet = *mpSet.get(); 5268 SfxItemIter aIter(rSet); 5269 const SfxPoolItem* pItem = aIter.FirstItem(); 5270 5271 while ( pItem ) 5272 { 5273 const sal_uInt16 nWID = pItem->Which(); 5274 5275 // PropertyMap_t::const_iterator aMapIt = aPropMap[nWID]; 5276 // if( aMapIt != aPropMap.getEnd() ) 5277 // { 5278 // beans::PropertyValue aPropertyValue; 5279 // aPropertyValue.Name = aIt->sName; 5280 // pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId ); 5281 // aPropertyVector.push_back( aPropertyValue ); 5282 // } 5283 // TODO: Optimize - and fix! the old iteration filled each WhichId 5284 // only once but there are more properties than WhichIds 5285 PropertyEntryVector_t::const_iterator aIt = aPropVector.begin(); 5286 while( aIt != aPropVector.end() ) 5287 { 5288 if ( aIt->nWID == nWID ) 5289 { 5290 beans::PropertyValue aPropertyValue; 5291 aPropertyValue.Name = aIt->sName; 5292 pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId ); 5293 aPropertyVector.push_back( aPropertyValue ); 5294 } 5295 ++aIt; 5296 } 5297 /* int i = 0; 5298 while ( pMap[i].nWID != 0 ) 5299 { 5300 if ( pMap[i].nWID == nWID ) 5301 { 5302 beans::PropertyValue aPropertyValue; 5303 String sString( OUString::createFromAscii( pMap[i].pName ) ); 5304 aPropertyValue.Name = sString; 5305 pItem->QueryValue( aPropertyValue.Value, pMap[i].nMemberId ); 5306 aPropertyVector.push_back( aPropertyValue ); 5307 break; 5308 } 5309 ++i; 5310 }*/ 5311 pItem = aIter.NextItem(); 5312 } 5313 5314 const sal_Int32 nCount = aPropertyVector.size(); 5315 uno::Sequence< beans::PropertyValue > aRet( nCount ); 5316 beans::PropertyValue* pProps = aRet.getArray(); 5317 5318 for ( int i = 0; i < nCount; ++i, pProps++ ) 5319 { 5320 *pProps = aPropertyVector[i]; 5321 } 5322 5323 return aRet; 5324 } 5325 5326 ////////////////////////////////////////////////////////////////////////////// 5327 //eof 5328