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