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