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 break; 1948 // case FN_UNO_DEFAULT_OUTLINE_LEVEL: //#outline level,removed by zahojianwei 1949 //{ 1950 // sal_Int8 nLevel = 0; 1951 // if( rValue >>= nLevel ) 1952 // rBase.mxNewBase->GetCollection()->SetOutlineLevel( nLevel ); 1953 // else 1954 // rBase.mxNewBase->GetCollection()->SetOutlineLevel( NO_NUMBERING ); 1955 //} 1956 //break; 1957 case RES_PARATR_OUTLINELEVEL: //add by zahojianwei 1958 { 1959 sal_Int16 nLevel = 0; 1960 rValue >>= nLevel; 1961 if( 0 <= nLevel && nLevel <= MAXLEVEL) 1962 rBase.mxNewBase->GetCollection()->SetAttrOutlineLevel( nLevel ); 1963 } 1964 break; //<-end,zhaojianwei 1965 case FN_UNO_FOLLOW_STYLE: 1966 { 1967 OUString sTmp; 1968 rValue >>= sTmp; 1969 String aString; 1970 SwStyleNameMapper::FillUIName(sTmp, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ) ; 1971 rBase.mxNewBase->SetFollow( aString ); 1972 } 1973 break; 1974 case RES_PAGEDESC : 1975 if( MID_PAGEDESC_PAGEDESCNAME != rEntry.nMemberId) 1976 goto put_itemset; 1977 { 1978 // Sonderbehandlung RES_PAGEDESC 1979 if(rValue.getValueType() != ::getCppuType((const OUString*)0)) 1980 throw lang::IllegalArgumentException(); 1981 SfxItemSet& rStyleSet = rBase.GetItemSet(); 1982 1983 SwFmtPageDesc* pNewDesc = 0; 1984 const SfxPoolItem* pItem; 1985 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) ) 1986 { 1987 pNewDesc = new SwFmtPageDesc(*((SwFmtPageDesc*)pItem)); 1988 } 1989 if(!pNewDesc) 1990 pNewDesc = new SwFmtPageDesc(); 1991 OUString uDescName; 1992 rValue >>= uDescName; 1993 String sDescName; 1994 SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True ); 1995 if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName) 1996 { 1997 //sal_uInt16 nCount = pDoc->GetPageDescCnt(); 1998 sal_Bool bPut = sal_False; 1999 if(sDescName.Len()) 2000 { 2001 SwPageDesc* pPageDesc = ::GetPageDescByName_Impl(*pDoc, sDescName); 2002 if(pPageDesc) 2003 { 2004 pNewDesc->RegisterToPageDesc( *pPageDesc ); 2005 bPut = sal_True; 2006 } 2007 else 2008 { 2009 throw lang::IllegalArgumentException(); 2010 } 2011 } 2012 if(!bPut) 2013 { 2014 rStyleSet.ClearItem(RES_BREAK); 2015 rStyleSet.Put(SwFmtPageDesc()); 2016 } 2017 else 2018 rStyleSet.Put(*pNewDesc); 2019 } 2020 delete pNewDesc; 2021 } 2022 break; 2023 case FN_UNO_IS_AUTO_UPDATE: 2024 { 2025 sal_Bool bAuto = *(sal_Bool*)rValue.getValue(); 2026 if(SFX_STYLE_FAMILY_PARA == eFamily) 2027 rBase.mxNewBase->GetCollection()->SetAutoUpdateFmt(bAuto); 2028 else if(SFX_STYLE_FAMILY_FRAME == eFamily) 2029 rBase.mxNewBase->GetFrmFmt()->SetAutoUpdateFmt(bAuto); 2030 } 2031 break; 2032 case FN_UNO_PARA_STYLE_CONDITIONS: 2033 { 2034 uno::Sequence< beans::NamedValue > aSeq; 2035 if (!(rValue >>= aSeq)) 2036 throw lang::IllegalArgumentException(); 2037 2038 DBG_ASSERT(COND_COMMAND_COUNT == 28, 2039 "invalid size of comman count?"); 2040 const beans::NamedValue *pSeq = aSeq.getConstArray(); 2041 sal_Int32 nLen = aSeq.getLength(); 2042 2043 sal_Bool bFailed = sal_False; 2044 SwCondCollItem aCondItem; 2045 for(sal_uInt16 i = 0; i < nLen; i++) 2046 { 2047 OUString aTmp; 2048 if ((pSeq[i].Value >>= aTmp)) 2049 { 2050 // get UI style name from programmatic style name 2051 String aStyleName; 2052 SwStyleNameMapper::FillUIName( aTmp, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ); 2053 2054 // 2055 // check for correct context and style name 2056 // 2057 sal_Int16 nIdx = GetCommandContextIndex( pSeq[i].Name ); 2058 // 2059 pBasePool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL ); 2060 sal_Bool bStyleFound = sal_False; 2061 const SfxStyleSheetBase* pBase = pBasePool->First(); 2062 while (pBase && !bStyleFound) 2063 { 2064 if(pBase->GetName() == aStyleName) 2065 bStyleFound = sal_True; 2066 pBase = pBasePool->Next(); 2067 } 2068 // 2069 if (nIdx == -1 || !bStyleFound) 2070 { 2071 bFailed = sal_True; 2072 break; 2073 } 2074 2075 aCondItem.SetStyle( &aStyleName, nIdx); 2076 } 2077 else 2078 bFailed = sal_True; 2079 } 2080 if (bFailed) 2081 throw lang::IllegalArgumentException(); 2082 rBase.GetItemSet().Put( aCondItem ); 2083 } 2084 break; 2085 case FN_UNO_CATEGORY: 2086 { 2087 if(!rBase.mxNewBase->IsUserDefined()) 2088 throw lang::IllegalArgumentException(); 2089 short nSet = 0; 2090 rValue >>= nSet; 2091 2092 sal_uInt16 nId; 2093 switch( nSet ) 2094 { 2095 case style::ParagraphStyleCategory::TEXT: 2096 nId = SWSTYLEBIT_TEXT; 2097 break; 2098 case style::ParagraphStyleCategory::CHAPTER: 2099 nId = SWSTYLEBIT_CHAPTER; 2100 break; 2101 case style::ParagraphStyleCategory::LIST: 2102 nId = SWSTYLEBIT_LIST; 2103 break; 2104 case style::ParagraphStyleCategory::INDEX: 2105 nId = SWSTYLEBIT_IDX; 2106 break; 2107 case style::ParagraphStyleCategory::EXTRA: 2108 nId = SWSTYLEBIT_EXTRA; 2109 break; 2110 case style::ParagraphStyleCategory::HTML: 2111 nId = SWSTYLEBIT_HTML; 2112 break; 2113 default: throw lang::IllegalArgumentException(); 2114 } 2115 rBase.mxNewBase->SetMask( nId|SFXSTYLEBIT_USERDEF ); 2116 } 2117 break; 2118 case SID_SWREGISTER_COLLECTION: 2119 { 2120 OUString sName; 2121 rValue >>= sName; 2122 SwRegisterItem aReg( sName.getLength() != 0); 2123 aReg.SetWhich(SID_SWREGISTER_MODE); 2124 rBase.GetItemSet().Put(aReg); 2125 String aString; 2126 SwStyleNameMapper::FillUIName(sName, aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); 2127 2128 rBase.GetItemSet().Put(SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) ); 2129 } 2130 break; 2131 case RES_TXTATR_CJK_RUBY: 2132 if(MID_RUBY_CHARSTYLE == rEntry.nMemberId ) 2133 { 2134 OUString sTmp; 2135 if(rValue >>= sTmp) 2136 { 2137 SfxItemSet& rStyleSet = rBase.GetItemSet(); 2138 SwFmtRuby* pRuby = 0; 2139 const SfxPoolItem* pItem; 2140 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_TXTATR_CJK_RUBY, sal_True, &pItem ) ) 2141 pRuby = new SwFmtRuby(*((SwFmtRuby*)pItem)); 2142 if(!pRuby) 2143 pRuby = new SwFmtRuby(aEmptyStr); 2144 String sStyle; 2145 SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); 2146 pRuby->SetCharFmtName( sTmp ); 2147 pRuby->SetCharFmtId( 0 ); 2148 if(sTmp.getLength()) 2149 { 2150 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sTmp, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); 2151 pRuby->SetCharFmtId(nId); 2152 } 2153 rStyleSet.Put(*pRuby); 2154 delete pRuby; 2155 } 2156 else 2157 throw lang::IllegalArgumentException(); 2158 } 2159 goto put_itemset; 2160 //break; 2161 case RES_PARATR_DROP: 2162 { 2163 if( MID_DROPCAP_CHAR_STYLE_NAME == rEntry.nMemberId) 2164 { 2165 if(rValue.getValueType() == ::getCppuType((const OUString*)0)) 2166 { 2167 SfxItemSet& rStyleSet = rBase.GetItemSet(); 2168 2169 SwFmtDrop* pDrop = 0; 2170 const SfxPoolItem* pItem; 2171 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PARATR_DROP, sal_True, &pItem ) ) 2172 pDrop = new SwFmtDrop(*((SwFmtDrop*)pItem)); 2173 if(!pDrop) 2174 pDrop = new SwFmtDrop(); 2175 OUString uStyle; 2176 rValue >>= uStyle; 2177 String sStyle; 2178 SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); 2179 SwDocStyleSheet* pStyle = 2180 (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR); 2181 if(pStyle) 2182 pDrop->SetCharFmt(pStyle->GetCharFmt()); 2183 else 2184 throw lang::IllegalArgumentException(); 2185 rStyleSet.Put(*pDrop); 2186 delete pDrop; 2187 } 2188 else 2189 throw lang::IllegalArgumentException(); 2190 break; 2191 } 2192 } 2193 //no break! 2194 default: 2195 put_itemset: 2196 { 2197 SfxItemSet& rStyleSet = rBase.GetItemSet(); 2198 SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID); 2199 aSet.SetParent(&rStyleSet); 2200 rPropSet.setPropertyValue(rEntry, rValue, aSet); 2201 rStyleSet.Put(aSet); 2202 // --> OD 2006-10-18 #i70223# 2203 if ( SFX_STYLE_FAMILY_PARA == eFamily && 2204 rEntry.nWID == RES_PARATR_NUMRULE && 2205 rBase.mxNewBase.is() && rBase.mxNewBase->GetCollection() && 2206 //rBase.mxNewBase->GetCollection()->GetOutlineLevel() < MAXLEVEL /* assigned to list level of outline style */) //#outline level,removed by zhaojianwei 2207 rBase.mxNewBase->GetCollection()->IsAssignedToListLevelOfOutlineStyle() ) ////<-end,add by zhaojianwei 2208 2209 { 2210 OUString sNewNumberingRuleName; 2211 rValue >>= sNewNumberingRuleName; 2212 String sTmp( sNewNumberingRuleName ); 2213 if ( sNewNumberingRuleName.getLength() == 0 || 2214 sTmp != pDoc->GetOutlineNumRule()->GetName() ) 2215 { 2216 // delete assignment to list level of outline style. 2217 //rBase.mxNewBase->GetCollection()->SetOutlineLevel( NO_NUMBERING ); //#outline level,removed by zhaojianwei 2218 rBase.mxNewBase->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end,adde by zhaojianwei 2219 } 2220 } 2221 } 2222 } 2223 } 2224 /* -----------------------------18.04.01 13:29-------------------------------- 2225 2226 ---------------------------------------------------------------------------*/ 2227 void SAL_CALL SwXStyle::SetPropertyValues_Impl( 2228 const uno::Sequence< OUString >& rPropertyNames, 2229 const uno::Sequence< uno::Any >& rValues ) 2230 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, 2231 lang::WrappedTargetException, uno::RuntimeException) 2232 { 2233 if ( !m_pDoc ) 2234 throw uno::RuntimeException(); 2235 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 2236 switch(eFamily) 2237 { 2238 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 2239 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break; 2240 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break; 2241 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break; 2242 default: 2243 ; 2244 } 2245 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 2246 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 2247 2248 if(rPropertyNames.getLength() != rValues.getLength()) 2249 throw lang::IllegalArgumentException(); 2250 2251 const OUString* pNames = rPropertyNames.getConstArray(); 2252 const uno::Any* pValues = rValues.getConstArray(); 2253 2254 SwStyleBase_Impl aBaseImpl(*m_pDoc, sStyleName); 2255 if(pBasePool) 2256 { 2257 sal_uInt16 nSaveMask = pBasePool->GetSearchMask(); 2258 pBasePool->SetSearchMask(eFamily); 2259 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 2260 pBasePool->SetSearchMask(eFamily, nSaveMask ); 2261 DBG_ASSERT(pBase, "where is the style?" ); 2262 if(pBase) 2263 aBaseImpl.mxNewBase = new SwDocStyleSheet(*(SwDocStyleSheet*)pBase); 2264 else 2265 throw uno::RuntimeException(); 2266 } 2267 2268 for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) 2269 { 2270 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp]); 2271 2272 if(!pEntry || 2273 (!bIsConditional && pNames[nProp].equalsAsciiL(SW_PROP_NAME(UNO_NAME_PARA_STYLE_CONDITIONS)))) 2274 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 2275 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) 2276 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 2277 if(aBaseImpl.mxNewBase.is()) 2278 { 2279 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, 2280 pBasePool, m_pDoc, eFamily); 2281 } 2282 else if(bIsDescriptor) 2283 { 2284 if(!pPropImpl->SetProperty(pNames[nProp], pValues[nProp])) 2285 throw lang::IllegalArgumentException(); 2286 } 2287 else 2288 throw uno::RuntimeException(); 2289 } 2290 if(aBaseImpl.HasItemSet()) 2291 aBaseImpl.mxNewBase->SetItemSet(aBaseImpl.GetItemSet()); 2292 } 2293 2294 void SwXStyle::setPropertyValues( 2295 const uno::Sequence< OUString >& rPropertyNames, 2296 const uno::Sequence< uno::Any >& rValues ) 2297 throw(beans::PropertyVetoException, lang::IllegalArgumentException, 2298 lang::WrappedTargetException, uno::RuntimeException) 2299 { 2300 vos::OGuard aGuard(Application::GetSolarMutex()); 2301 2302 // workaround for bad designed API 2303 try 2304 { 2305 SetPropertyValues_Impl( rPropertyNames, rValues ); 2306 } 2307 catch (beans::UnknownPropertyException &rException) 2308 { 2309 // wrap the original (here not allowed) exception in 2310 // a lang::WrappedTargetException that gets thrown instead. 2311 lang::WrappedTargetException aWExc; 2312 aWExc.TargetException <<= rException; 2313 throw aWExc; 2314 } 2315 } 2316 2317 2318 uno::Any lcl_GetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, 2319 const SfxItemPropertySet& rPropSet, 2320 SwStyleBase_Impl& rBase, 2321 SfxStyleSheetBase* pBase, 2322 SfxStyleFamily eFamily, 2323 SwDoc *pDoc) throw(uno::RuntimeException) 2324 { 2325 uno::Any aRet; 2326 if(FN_UNO_IS_PHYSICAL == rEntry.nWID) 2327 { 2328 sal_Bool bPhys = pBase != 0; 2329 if(pBase) 2330 { 2331 bPhys = ((SwDocStyleSheet*)pBase)->IsPhysical(); 2332 // The standard character format is not existing physically 2333 if( bPhys && SFX_STYLE_FAMILY_CHAR == eFamily && 2334 ((SwDocStyleSheet*)pBase)->GetCharFmt() && 2335 ((SwDocStyleSheet*)pBase)->GetCharFmt()->IsDefault() ) 2336 bPhys = sal_False; 2337 } 2338 aRet.setValue(&bPhys, ::getBooleanCppuType()); 2339 } 2340 else if(pBase) 2341 { 2342 if(!rBase.mxNewBase.is()) 2343 rBase.mxNewBase = new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ); 2344 switch(rEntry.nWID) 2345 { 2346 case RES_PAPER_BIN: 2347 { 2348 SfxItemSet& rSet = rBase.GetItemSet(); 2349 rPropSet.getPropertyValue(rEntry, rSet, aRet); 2350 sal_Int8 nBin = 0; 2351 aRet >>= nBin; 2352 if ( nBin == -1 ) 2353 aRet <<= OUString ( RTL_CONSTASCII_USTRINGPARAM ( "[From printer settings]" ) ); 2354 else 2355 { 2356 SfxPrinter *pPrinter = pDoc->getPrinter( false ); 2357 OUString sTmp; 2358 if (pPrinter ) 2359 sTmp = pPrinter->GetPaperBinName ( nBin ); 2360 aRet <<= sTmp; 2361 } 2362 } 2363 break; 2364 case FN_UNO_NUM_RULES: //Sonderbehandlung fuer das SvxNumRuleItem: 2365 { 2366 const SwNumRule* pRule = rBase.mxNewBase->GetNumRule(); 2367 DBG_ASSERT(pRule, "Wo ist die NumRule?"); 2368 uno::Reference< container::XIndexReplace > xRules = new SwXNumberingRules(*pRule); 2369 aRet.setValue(&xRules, ::getCppuType((uno::Reference<container::XIndexReplace>*)0)); 2370 } 2371 break; 2372 //case FN_UNO_DEFAULT_OUTLINE_LEVEL: //#outline level,removed by zahojianwei 2373 //{ 2374 // DBG_ASSERT( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" ); 2375 // sal_uInt8 nLevel = rBase.mxNewBase->GetCollection()->GetOutlineLevel(); 2376 // if( nLevel != NO_NUMBERING ) 2377 // aRet <<= static_cast<sal_Int8>( nLevel ); 2378 //} 2379 //break; 2380 case RES_PARATR_OUTLINELEVEL: //add by zahojianwei 2381 { 2382 DBG_ASSERT( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" ); 2383 int nLevel = rBase.mxNewBase->GetCollection()->GetAttrOutlineLevel(); 2384 aRet <<= static_cast<sal_Int16>( nLevel ); 2385 } 2386 break; //<-end,zhaojianwei 2387 case FN_UNO_FOLLOW_STYLE: 2388 { 2389 String aString; 2390 SwStyleNameMapper::FillProgName(rBase.mxNewBase->GetFollow(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True); 2391 aRet <<= OUString( aString ); 2392 } 2393 break; 2394 case RES_PAGEDESC : 2395 if( MID_PAGEDESC_PAGEDESCNAME != rEntry.nMemberId) 2396 goto query_itemset; 2397 { 2398 // Sonderbehandlung RES_PAGEDESC 2399 const SfxPoolItem* pItem; 2400 if(SFX_ITEM_SET == rBase.GetItemSet().GetItemState( RES_PAGEDESC, sal_True, &pItem ) ) 2401 { 2402 const SwPageDesc* pDesc = ((const SwFmtPageDesc*)pItem)->GetPageDesc(); 2403 if(pDesc) 2404 { 2405 String aString; 2406 SwStyleNameMapper::FillProgName(pDesc->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True ); 2407 aRet <<= OUString( aString ); 2408 } 2409 } 2410 } 2411 break; 2412 case FN_UNO_IS_AUTO_UPDATE: 2413 { 2414 sal_Bool bAuto = sal_False; 2415 if(SFX_STYLE_FAMILY_PARA == eFamily) 2416 bAuto = rBase.mxNewBase->GetCollection()->IsAutoUpdateFmt(); 2417 else if(SFX_STYLE_FAMILY_FRAME == eFamily) 2418 bAuto = rBase.mxNewBase->GetFrmFmt()->IsAutoUpdateFmt(); 2419 aRet.setValue(&bAuto, ::getBooleanCppuType()); 2420 } 2421 break; 2422 case FN_UNO_DISPLAY_NAME: 2423 { 2424 OUString sName(rBase.mxNewBase->GetDisplayName()); 2425 aRet <<= sName; 2426 } 2427 break; 2428 case FN_UNO_PARA_STYLE_CONDITIONS: 2429 { 2430 DBG_ASSERT(COND_COMMAND_COUNT == 28, 2431 "invalid size of comman count?"); 2432 //SfxItemSet& rStyleSet = rBase.GetItemSet(); 2433 uno::Sequence< beans::NamedValue > aSeq(COND_COMMAND_COUNT); 2434 beans::NamedValue *pSeq = aSeq.getArray(); 2435 2436 SwFmt *pFmt = ((SwDocStyleSheet*)pBase)->GetCollection(); 2437 const CommandStruct *pCmds = SwCondCollItem::GetCmds(); 2438 for (sal_uInt16 n = 0; n < COND_COMMAND_COUNT; ++n) 2439 { 2440 String aStyleName; 2441 2442 const SwCollCondition* pCond = 0; 2443 if( pFmt && RES_CONDTXTFMTCOLL == pFmt->Which() && 2444 0 != ( pCond = ((SwConditionTxtFmtColl*)pFmt)-> 2445 HasCondition( SwCollCondition( 0, pCmds[n].nCnd, pCmds[n].nSubCond ) ) ) 2446 && pCond->GetTxtFmtColl() ) 2447 { 2448 // get programmatic style name from UI style name 2449 aStyleName = pCond->GetTxtFmtColl()->GetName(); 2450 SwStyleNameMapper::FillProgName(aStyleName, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True); 2451 } 2452 2453 pSeq[n].Name = GetCommandContextByIndex(n); 2454 pSeq[n].Value <<= rtl::OUString( aStyleName ); 2455 } 2456 aRet <<= aSeq; 2457 } 2458 break; 2459 case FN_UNO_CATEGORY: 2460 { 2461 sal_uInt16 nPoolId = rBase.mxNewBase->GetCollection()->GetPoolFmtId(); 2462 short nRet = -1; 2463 switch ( COLL_GET_RANGE_BITS & nPoolId ) 2464 { 2465 case COLL_TEXT_BITS: 2466 nRet = style::ParagraphStyleCategory::TEXT; 2467 break; 2468 case COLL_DOC_BITS: 2469 nRet = style::ParagraphStyleCategory::CHAPTER; 2470 break; 2471 case COLL_LISTS_BITS: 2472 nRet = style::ParagraphStyleCategory::LIST; 2473 break; 2474 case COLL_REGISTER_BITS: 2475 nRet = style::ParagraphStyleCategory::INDEX; 2476 break; 2477 case COLL_EXTRA_BITS: 2478 nRet = style::ParagraphStyleCategory::EXTRA; 2479 break; 2480 case COLL_HTML_BITS: 2481 nRet = style::ParagraphStyleCategory::HTML; 2482 break; 2483 } 2484 aRet <<= nRet; 2485 } 2486 break; 2487 case SID_SWREGISTER_COLLECTION: 2488 { 2489 const SwPageDesc *pPageDesc = rBase.mxNewBase->GetPageDesc(); 2490 const SwTxtFmtColl* pCol = 0; 2491 String aString; 2492 if( pPageDesc ) 2493 pCol = pPageDesc->GetRegisterFmtColl(); 2494 if( pCol ) 2495 SwStyleNameMapper::FillProgName( 2496 pCol->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); 2497 aRet <<= OUString ( aString ); 2498 } 2499 break; 2500 default: 2501 query_itemset: 2502 { 2503 SfxItemSet& rSet = rBase.GetItemSet(); 2504 rPropSet.getPropertyValue(rEntry, rSet, aRet); 2505 } 2506 } 2507 } 2508 else 2509 throw uno::RuntimeException(); 2510 return aRet; 2511 } 2512 /* -----------------------------19.04.01 09:26-------------------------------- 2513 2514 ---------------------------------------------------------------------------*/ 2515 uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl( 2516 const uno::Sequence< OUString > & rPropertyNames ) 2517 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2518 { 2519 if ( !m_pDoc ) 2520 throw uno::RuntimeException(); 2521 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 2522 switch(eFamily) 2523 { 2524 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 2525 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break; 2526 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break; 2527 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break; 2528 default: 2529 ; 2530 } 2531 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 2532 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 2533 2534 const OUString* pNames = rPropertyNames.getConstArray(); 2535 uno::Sequence< uno::Any > aRet(rPropertyNames.getLength()); 2536 uno::Any* pRet = aRet.getArray(); 2537 SwStyleBase_Impl aBase(*m_pDoc, sStyleName); 2538 SfxStyleSheetBase* pBase = 0; 2539 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) 2540 { 2541 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp]); 2542 if(!pEntry || 2543 (!bIsConditional && pNames[nProp].equalsAsciiL(SW_PROP_NAME(UNO_NAME_PARA_STYLE_CONDITIONS)))) 2544 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 2545 if(pBasePool) 2546 { 2547 if(!pBase) 2548 { 2549 sal_uInt16 nSaveMask = pBasePool->GetSearchMask(); 2550 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL ); 2551 pBase = pBasePool->Find(sStyleName); 2552 pBasePool->SetSearchMask(eFamily, nSaveMask ); 2553 } 2554 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, eFamily, GetDoc() ); 2555 } 2556 else if(bIsDescriptor) 2557 { 2558 uno::Any *pAny = 0; 2559 pPropImpl->GetProperty ( pNames[nProp], pAny ); 2560 if( !pAny ) 2561 { 2562 sal_Bool bExcept = sal_False; 2563 switch( eFamily ) 2564 { 2565 case SFX_STYLE_FAMILY_PSEUDO: 2566 bExcept = sal_True; 2567 break; 2568 case SFX_STYLE_FAMILY_PARA: 2569 case SFX_STYLE_FAMILY_PAGE: 2570 pPropImpl->GetProperty ( pNames[nProp], mxStyleData, pRet[ nProp ] ); 2571 break; 2572 case SFX_STYLE_FAMILY_CHAR: 2573 case SFX_STYLE_FAMILY_FRAME : 2574 { 2575 if (pEntry->nWID >= POOLATTR_BEGIN && pEntry->nWID < RES_UNKNOWNATR_END ) 2576 { 2577 SwFmt * pFmt; 2578 if ( eFamily == SFX_STYLE_FAMILY_CHAR ) 2579 pFmt = m_pDoc->GetDfltCharFmt(); 2580 else 2581 pFmt = m_pDoc->GetDfltFrmFmt(); 2582 const SwAttrPool * pPool = pFmt->GetAttrSet().GetPool(); 2583 const SfxPoolItem & rItem = pPool->GetDefaultItem ( pEntry->nWID ); 2584 rItem.QueryValue ( pRet[nProp], pEntry->nMemberId ); 2585 } 2586 else 2587 bExcept = sal_True; 2588 } 2589 break; 2590 2591 default: 2592 ; 2593 } 2594 if (bExcept ) 2595 { 2596 uno::RuntimeException aExcept; 2597 aExcept.Message = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "No default value for: " ) ) + pNames[nProp]; 2598 throw aExcept; 2599 } 2600 } 2601 else 2602 pRet [ nProp ] = *pAny; 2603 } 2604 else 2605 throw uno::RuntimeException(); 2606 } 2607 return aRet; 2608 } 2609 /* -----------------------------04.11.03 09:26-------------------------------- 2610 2611 ---------------------------------------------------------------------------*/ 2612 uno::Sequence< uno::Any > SwXStyle::getPropertyValues( 2613 const uno::Sequence< OUString >& rPropertyNames ) throw(uno::RuntimeException) 2614 { 2615 vos::OGuard aGuard(Application::GetSolarMutex()); 2616 uno::Sequence< uno::Any > aValues; 2617 2618 // workaround for bad designed API 2619 try 2620 { 2621 aValues = GetPropertyValues_Impl( rPropertyNames ); 2622 } 2623 catch (beans::UnknownPropertyException &) 2624 { 2625 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 2626 } 2627 catch (lang::WrappedTargetException &) 2628 { 2629 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 2630 } 2631 2632 return aValues; 2633 } 2634 /*-- 18.04.01 13:07:29--------------------------------------------------- 2635 -----------------------------------------------------------------------*/ 2636 void SwXStyle::addPropertiesChangeListener( 2637 const uno::Sequence< OUString >& /*aPropertyNames*/, 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::removePropertiesChangeListener( 2646 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 2647 throw(uno::RuntimeException) 2648 { 2649 } 2650 /*-- 18.04.01 13:07:30--------------------------------------------------- 2651 2652 -----------------------------------------------------------------------*/ 2653 void SwXStyle::firePropertiesChangeEvent( 2654 const uno::Sequence< OUString >& /*aPropertyNames*/, 2655 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 2656 throw(uno::RuntimeException) 2657 { 2658 } 2659 /*-- 17.12.98 08:26:53--------------------------------------------------- 2660 2661 -----------------------------------------------------------------------*/ 2662 void SwXStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue) 2663 throw( beans::UnknownPropertyException, 2664 beans::PropertyVetoException, 2665 lang::IllegalArgumentException, 2666 lang::WrappedTargetException, 2667 uno::RuntimeException) 2668 { 2669 vos::OGuard aGuard(Application::GetSolarMutex()); 2670 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 2671 const uno::Sequence<uno::Any> aValues(&rValue, 1); 2672 SetPropertyValues_Impl( aProperties, aValues ); 2673 } 2674 /*-- 17.12.98 08:26:53--------------------------------------------------- 2675 2676 -----------------------------------------------------------------------*/ 2677 uno::Any SwXStyle::getPropertyValue(const OUString& rPropertyName) 2678 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2679 { 2680 vos::OGuard aGuard(Application::GetSolarMutex()); 2681 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 2682 return GetPropertyValues_Impl(aProperties).getConstArray()[0]; 2683 2684 } 2685 /*-- 17.12.98 08:26:53--------------------------------------------------- 2686 2687 -----------------------------------------------------------------------*/ 2688 void SwXStyle::addPropertyChangeListener(const OUString& /*rPropertyName*/, 2689 const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) 2690 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2691 { 2692 DBG_WARNING("not implemented"); 2693 } 2694 /*-- 17.12.98 08:26:54--------------------------------------------------- 2695 2696 -----------------------------------------------------------------------*/ 2697 void SwXStyle::removePropertyChangeListener(const OUString& /*rPropertyName*/, 2698 const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) 2699 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2700 { 2701 DBG_WARNING("not implemented"); 2702 } 2703 /*-- 17.12.98 08:26:54--------------------------------------------------- 2704 2705 -----------------------------------------------------------------------*/ 2706 void SwXStyle::addVetoableChangeListener(const OUString& /*rPropertyName*/, 2707 const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) 2708 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2709 { 2710 DBG_WARNING("not implemented"); 2711 } 2712 /*-- 17.12.98 08:26:54--------------------------------------------------- 2713 2714 -----------------------------------------------------------------------*/ 2715 void SwXStyle::removeVetoableChangeListener(const OUString& /*rPropertyName*/, 2716 const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) 2717 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2718 { 2719 DBG_WARNING("not implemented"); 2720 } 2721 2722 /*-- 08.03.99 10:50:26--------------------------------------------------- 2723 2724 -----------------------------------------------------------------------*/ 2725 beans::PropertyState SwXStyle::getPropertyState(const OUString& rPropertyName) 2726 throw( beans::UnknownPropertyException, uno::RuntimeException ) 2727 { 2728 vos::OGuard aGuard(Application::GetSolarMutex()); 2729 2730 uno::Sequence< OUString > aNames(1); 2731 OUString* pNames = aNames.getArray(); 2732 pNames[0] = rPropertyName; 2733 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames); 2734 return aStates.getConstArray()[0]; 2735 } 2736 /*-- 08.03.99 10:50:27--------------------------------------------------- 2737 2738 -----------------------------------------------------------------------*/ 2739 uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates( 2740 const uno::Sequence< OUString >& rPropertyNames) 2741 throw( beans::UnknownPropertyException, uno::RuntimeException ) 2742 { 2743 vos::OGuard aGuard(Application::GetSolarMutex()); 2744 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength()); 2745 beans::PropertyState* pStates = aRet.getArray(); 2746 if(pBasePool) 2747 { 2748 pBasePool->SetSearchMask(eFamily ); 2749 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 2750 DBG_ASSERT(pBase, "where is the style?" ); 2751 2752 if(pBase) 2753 { 2754 const OUString* pNames = rPropertyNames.getConstArray(); 2755 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 2756 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 2757 switch(eFamily) 2758 { 2759 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 2760 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break; 2761 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break; 2762 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break; 2763 default: 2764 ; 2765 } 2766 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 2767 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 2768 2769 SfxItemSet aSet = xStyle->GetItemSet(); 2770 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) 2771 { 2772 const String& rPropName = pNames[i]; 2773 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rPropName); 2774 if(!pEntry) 2775 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 2776 if( FN_UNO_NUM_RULES == pEntry->nWID || 2777 FN_UNO_FOLLOW_STYLE == pEntry->nWID ) 2778 { 2779 pStates[i] = beans::PropertyState_DIRECT_VALUE; 2780 } 2781 // else if( FN_UNO_DEFAULT_OUTLINE_LEVEL == pEntry->nWID ) //#outline level,removed by zahojianwei 2782 // { 2783 // pStates[i] = 2784 // ( xStyle->GetCollection()->GetOutlineLevel() 2785 // == NO_NUMBERING ) 2786 // ? beans::PropertyState_DEFAULT_VALUE 2787 // : beans::PropertyState_DIRECT_VALUE; 2788 // } //<-end,zhaojianwei 2789 else if(SFX_STYLE_FAMILY_PAGE == eFamily && 2790 (rPropName.EqualsAscii("Header", 0, 6) 2791 || rPropName.EqualsAscii("Footer", 0, 6))) 2792 { 2793 sal_uInt16 nResId = lcl_ConvertFNToRES(pEntry->nWID); 2794 sal_Bool bFooter = rPropName.EqualsAscii("Footer", 0, 6); 2795 const SvxSetItem* pSetItem; 2796 if(SFX_ITEM_SET == aSet.GetItemState( 2797 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, 2798 sal_False, (const SfxPoolItem**)&pSetItem)) 2799 { 2800 const SfxItemSet& rSet = pSetItem->GetItemSet(); 2801 SfxItemState eState = rSet.GetItemState(nResId, sal_False); 2802 if(SFX_ITEM_SET == eState) 2803 pStates[i] = beans::PropertyState_DIRECT_VALUE; 2804 else 2805 pStates[i] = beans::PropertyState_DEFAULT_VALUE; 2806 } 2807 else 2808 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE; 2809 } 2810 else 2811 { 2812 pStates[i] = pPropSet->getPropertyState(*pEntry, aSet); 2813 if( SFX_STYLE_FAMILY_PAGE == eFamily && 2814 SID_ATTR_PAGE_SIZE == pEntry->nWID && 2815 beans::PropertyState_DIRECT_VALUE == pStates[i] ) 2816 { 2817 const SvxSizeItem& rSize = 2818 static_cast < const SvxSizeItem& >( 2819 aSet.Get(SID_ATTR_PAGE_SIZE) ); 2820 sal_uInt8 nMemberId = pEntry->nMemberId & 0x7f; 2821 if( ( LONG_MAX == rSize.GetSize().Width() && 2822 (MID_SIZE_WIDTH == nMemberId || 2823 MID_SIZE_SIZE == nMemberId ) ) || 2824 ( LONG_MAX == rSize.GetSize().Height() && 2825 MID_SIZE_HEIGHT == nMemberId ) ) 2826 { 2827 pStates[i] = beans::PropertyState_DEFAULT_VALUE; 2828 } 2829 } 2830 } 2831 } 2832 } 2833 else 2834 throw uno::RuntimeException(); 2835 } 2836 else 2837 throw uno::RuntimeException(); 2838 return aRet; 2839 } 2840 /*-- 08.03.99 10:50:27--------------------------------------------------- 2841 2842 -----------------------------------------------------------------------*/ 2843 void SwXStyle::setPropertyToDefault(const OUString& rPropertyName) 2844 throw( beans::UnknownPropertyException, uno::RuntimeException ) 2845 { 2846 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 ); 2847 setPropertiesToDefault ( aSequence ); 2848 } 2849 2850 void SAL_CALL SwXStyle::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames ) 2851 throw (beans::UnknownPropertyException, uno::RuntimeException) 2852 { 2853 vos::OGuard aGuard(Application::GetSolarMutex()); 2854 SwFmt *pTargetFmt = 0; 2855 2856 if(pBasePool) 2857 { 2858 pBasePool->SetSearchMask(eFamily); 2859 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 2860 DBG_ASSERT(pBase, "Where is the style?"); 2861 2862 if(pBase) 2863 { 2864 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 2865 switch(eFamily) 2866 { 2867 case SFX_STYLE_FAMILY_CHAR: pTargetFmt = xStyle->GetCharFmt(); break; 2868 case SFX_STYLE_FAMILY_PARA: pTargetFmt = xStyle->GetCollection(); break; 2869 case SFX_STYLE_FAMILY_FRAME: pTargetFmt = xStyle->GetFrmFmt(); break; 2870 case SFX_STYLE_FAMILY_PAGE: 2871 { 2872 sal_uInt16 nPgDscPos = USHRT_MAX; 2873 SwPageDesc *pDesc = m_pDoc->FindPageDescByName( xStyle->GetPageDesc()->GetName(), &nPgDscPos ); 2874 if( pDesc ) 2875 pTargetFmt = &pDesc->GetMaster(); 2876 } 2877 break; 2878 case SFX_STYLE_FAMILY_PSEUDO: 2879 break; 2880 default: 2881 ; 2882 } 2883 } 2884 } 2885 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 2886 switch(eFamily) 2887 { 2888 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 2889 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE; break; 2890 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break; 2891 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break; 2892 default: 2893 ; 2894 } 2895 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 2896 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 2897 2898 const OUString* pNames = aPropertyNames.getConstArray(); 2899 2900 if ( pTargetFmt ) 2901 { 2902 for( sal_Int32 nProp = 0, nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++ ) 2903 { 2904 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp] ); 2905 if( !pEntry ) 2906 throw beans::UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is unknown: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 2907 if ( pEntry->nWID == FN_UNO_FOLLOW_STYLE || pEntry->nWID == FN_UNO_NUM_RULES ) 2908 throw uno::RuntimeException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Cannot reset: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 2909 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY ) 2910 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertiesToDefault: property is read-only: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 2911 2912 //if( pEntry->nWID == FN_UNO_DEFAULT_OUTLINE_LEVEL ) //#outline level, removed by zhaojianwei 2913 // static_cast<SwTxtFmtColl*>(pTargetFmt)->SetOutlineLevel( NO_NUMBERING ); 2914 //else 2915 // pTargetFmt->ResetFmtAttr( pEntry->nWID ); 2916 if( pEntry->nWID == RES_PARATR_OUTLINELEVEL ) //add by zhaojianwei 2917 static_cast<SwTxtFmtColl*>(pTargetFmt)->DeleteAssignmentToListLevelOfOutlineStyle(); 2918 else 2919 pTargetFmt->ResetFmtAttr( pEntry->nWID ); //<-end,zhaojianwei 2920 } 2921 } 2922 else if ( bIsDescriptor ) 2923 { 2924 for( sal_Int32 nProp = 0, nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++ ) 2925 pPropImpl->ClearProperty ( pNames[ nProp ] ); 2926 } 2927 } 2928 2929 void SAL_CALL SwXStyle::setAllPropertiesToDefault( ) 2930 throw (uno::RuntimeException) 2931 { 2932 vos::OGuard aGuard(Application::GetSolarMutex()); 2933 if(pBasePool) 2934 { 2935 pBasePool->SetSearchMask(eFamily); 2936 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 2937 DBG_ASSERT(pBase, "where is the style, you fiend!?"); 2938 2939 if(pBase) 2940 { 2941 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 2942 2943 SwFmt *pTargetFmt = 0; 2944 sal_uInt16 nPgDscPos = USHRT_MAX; 2945 switch( eFamily ) 2946 { 2947 case SFX_STYLE_FAMILY_CHAR : 2948 pTargetFmt = xStyle->GetCharFmt(); 2949 break; 2950 case SFX_STYLE_FAMILY_PARA : 2951 { 2952 pTargetFmt = xStyle->GetCollection(); 2953 // --> OD 2007-07-25 #132402# - make code robust 2954 if ( xStyle->GetCollection() ) 2955 { 2956 // xStyle->GetCollection()->SetOutlineLevel( NO_NUMBERING ); //#outline level,removed by zhaojianwei 2957 xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end,add by zhaojianwei 2958 } 2959 // <-- 2960 } 2961 break; 2962 case SFX_STYLE_FAMILY_FRAME: 2963 pTargetFmt = xStyle->GetFrmFmt(); 2964 break; 2965 case SFX_STYLE_FAMILY_PAGE: 2966 { 2967 SwPageDesc *pDesc = m_pDoc->FindPageDescByName( xStyle->GetPageDesc()->GetName(), &nPgDscPos ); 2968 if( pDesc ) 2969 { 2970 pTargetFmt = &pDesc->GetMaster(); 2971 pDesc->SetUseOn ( nsUseOnPage::PD_ALL ); 2972 } 2973 } 2974 break; 2975 case SFX_STYLE_FAMILY_PSEUDO: 2976 break; 2977 2978 default: 2979 ; 2980 } 2981 if( pTargetFmt ) 2982 { 2983 if( USHRT_MAX != nPgDscPos ) 2984 { 2985 SwPageDesc& rPageDesc = m_pDoc->_GetPageDesc(nPgDscPos); 2986 rPageDesc.ResetAllMasterAttr(); 2987 2988 SvxLRSpaceItem aLR(RES_LR_SPACE); 2989 sal_Int32 nSize = GetMetricVal ( CM_1) * 2; 2990 aLR.SetLeft ( nSize ); 2991 aLR.SetLeft ( nSize ); 2992 SvxULSpaceItem aUL( RES_UL_SPACE ); 2993 aUL.SetUpper ( static_cast < sal_uInt16 > ( nSize ) ); 2994 aUL.SetLower ( static_cast < sal_uInt16 > ( nSize ) ); 2995 pTargetFmt->SetFmtAttr( aLR ); 2996 pTargetFmt->SetFmtAttr( aUL ); 2997 2998 SwPageDesc* pStdPgDsc = m_pDoc->GetPageDescFromPool( RES_POOLPAGE_STANDARD ); 2999 SwFmtFrmSize aFrmSz( ATT_FIX_SIZE ); 3000 if( RES_POOLPAGE_STANDARD == rPageDesc.GetPoolFmtId() ) 3001 { 3002 if( m_pDoc->getPrinter( false ) ) 3003 { 3004 const Size aPhysSize( SvxPaperInfo::GetPaperSize( 3005 static_cast<Printer*>( m_pDoc->getPrinter( false ) )) ); 3006 aFrmSz.SetSize( aPhysSize ); 3007 } 3008 else 3009 { 3010 // --> OD 2008-07-25 #i91928# 3011 // aFrmSz.SetWidth( LONG_MAX ); 3012 // aFrmSz.SetHeight( LONG_MAX ); 3013 aFrmSz.SetSize( SvxPaperInfo::GetDefaultPaperSize() ); 3014 // <-- 3015 } 3016 3017 } 3018 else 3019 { 3020 aFrmSz = pStdPgDsc->GetMaster().GetFrmSize(); 3021 } 3022 if( pStdPgDsc->GetLandscape() ) 3023 { 3024 SwTwips nTmp = aFrmSz.GetHeight(); 3025 aFrmSz.SetHeight( aFrmSz.GetWidth() ); 3026 aFrmSz.SetWidth( nTmp ); 3027 } 3028 pTargetFmt->SetFmtAttr( aFrmSz ); 3029 } 3030 else 3031 { 3032 // --> OD 2007-01-25 #i73790# - method renamed 3033 pTargetFmt->ResetAllFmtAttr(); 3034 // <-- 3035 } 3036 3037 if( USHRT_MAX != nPgDscPos ) 3038 m_pDoc->ChgPageDesc( nPgDscPos, 3039 const_cast<const SwDoc *>(m_pDoc) 3040 ->GetPageDesc(nPgDscPos) ); 3041 } 3042 3043 } 3044 else 3045 throw uno::RuntimeException(); 3046 } 3047 else if ( bIsDescriptor ) 3048 pPropImpl->ClearAllProperties(); 3049 else 3050 throw uno::RuntimeException(); 3051 } 3052 3053 uno::Sequence< uno::Any > SAL_CALL SwXStyle::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames ) 3054 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 3055 { 3056 vos::OGuard aGuard(Application::GetSolarMutex()); 3057 sal_Int32 nCount = aPropertyNames.getLength(); 3058 uno::Sequence < uno::Any > aRet ( nCount ); 3059 if ( nCount ) 3060 { 3061 if( pBasePool) 3062 { 3063 pBasePool->SetSearchMask(eFamily); 3064 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); 3065 DBG_ASSERT(pBase, "Doesn't seem to be a style!"); 3066 3067 if(pBase) 3068 { 3069 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 3070 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; 3071 switch(eFamily) 3072 { 3073 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; 3074 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE; break; 3075 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break; 3076 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break; 3077 default: 3078 ; 3079 } 3080 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 3081 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap(); 3082 3083 const SfxItemSet &rSet = xStyle->GetItemSet(), *pParentSet = rSet.GetParent(); 3084 const OUString *pNames = aPropertyNames.getConstArray(); 3085 uno::Any *pRet = aRet.getArray(); 3086 for ( sal_Int32 i = 0 ; i < nCount; i++) 3087 { 3088 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[i] ); 3089 if ( !pEntry ) 3090 throw beans::UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) ); 3091 3092 if( pParentSet ) 3093 aSwMapProvider.GetPropertySet(nPropSetId)->getPropertyValue(pNames[i], *pParentSet, pRet[i]); 3094 else if( pEntry->nWID != rSet.GetPool()->GetSlotId(pEntry->nWID) ) 3095 { 3096 const SfxPoolItem& rItem = rSet.GetPool()->GetDefaultItem(pEntry->nWID); 3097 rItem.QueryValue(pRet[i], pEntry->nMemberId); 3098 } 3099 } 3100 } 3101 else 3102 throw uno::RuntimeException(); 3103 } 3104 else 3105 throw uno::RuntimeException(); 3106 } 3107 return aRet; 3108 } 3109 /*-- 08.03.99 10:50:27--------------------------------------------------- 3110 3111 -----------------------------------------------------------------------*/ 3112 uno::Any SwXStyle::getPropertyDefault(const OUString& rPropertyName) 3113 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 3114 { 3115 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 ); 3116 return getPropertyDefaults ( aSequence ).getConstArray()[0]; 3117 } 3118 /* -----------------21.01.99 13:08------------------- 3119 * 3120 * --------------------------------------------------*/ 3121 void SwXStyle::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 3122 { 3123 SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint ); 3124 if( pHint ) 3125 { 3126 if(( pHint->GetId() & SFX_HINT_DYING ) || ( pHint->GetId() & SFX_STYLESHEET_ERASED)) 3127 { 3128 pBasePool = 0; 3129 EndListening(rBC); 3130 } 3131 else if( pHint->GetId() &(SFX_STYLESHEET_CHANGED|SFX_STYLESHEET_ERASED) ) 3132 { 3133 ((SfxStyleSheetBasePool&)rBC).SetSearchMask(eFamily); 3134 SfxStyleSheetBase* pOwnBase = ((SfxStyleSheetBasePool&)rBC).Find(sStyleName); 3135 if(!pOwnBase) 3136 { 3137 EndListening(rBC); 3138 Invalidate(); 3139 } 3140 } 3141 } 3142 } 3143 /* -----------------------------15.08.00 11:35-------------------------------- 3144 3145 ---------------------------------------------------------------------------*/ 3146 void SwXStyle::Invalidate() 3147 { 3148 sStyleName.Erase(); 3149 pBasePool = 0; 3150 m_pDoc = 0; 3151 mxStyleData.clear(); 3152 mxStyleFamily.clear(); 3153 } 3154 3155 3156 /****************************************************************** 3157 * SwXPageStyle 3158 ******************************************************************/ 3159 /*-- 17.12.98 08:43:35--------------------------------------------------- 3160 3161 -----------------------------------------------------------------------*/ 3162 SwXPageStyle::SwXPageStyle(SfxStyleSheetBasePool& rPool, 3163 SwDocShell* pDocSh, SfxStyleFamily eFam, 3164 const String& rStyleName)://, const SfxItemPropertyMap* _pMap) : 3165 SwXStyle(rPool, eFam, pDocSh->GetDoc(), rStyleName),//, _pMap), 3166 pDocShell(pDocSh) 3167 { 3168 3169 } 3170 /* -----------------23.08.99 15:52------------------- 3171 3172 --------------------------------------------------*/ 3173 SwXPageStyle::SwXPageStyle(SwDocShell* pDocSh) : 3174 SwXStyle(pDocSh->GetDoc(), SFX_STYLE_FAMILY_PAGE), 3175 pDocShell(pDocSh) 3176 { 3177 } 3178 3179 /*-- 17.12.98 08:43:35--------------------------------------------------- 3180 3181 -----------------------------------------------------------------------*/ 3182 SwXPageStyle::~SwXPageStyle() 3183 { 3184 3185 } 3186 /* -----------------------------18.04.01 13:50-------------------------------- 3187 3188 ---------------------------------------------------------------------------*/ 3189 void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( 3190 const uno::Sequence< OUString >& rPropertyNames, 3191 const uno::Sequence< uno::Any >& rValues ) 3192 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, 3193 lang::WrappedTargetException, uno::RuntimeException) 3194 { 3195 if(!GetDoc()) 3196 throw uno::RuntimeException(); 3197 3198 if(rPropertyNames.getLength() != rValues.getLength()) 3199 throw lang::IllegalArgumentException(); 3200 3201 const OUString* pNames = rPropertyNames.getConstArray(); 3202 const uno::Any* pValues = rValues.getConstArray(); 3203 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE); 3204 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap(); 3205 SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName()); 3206 if(GetBasePool()) 3207 { 3208 sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask(); 3209 GetBasePool()->SetSearchMask(GetFamily()); 3210 SfxStyleSheetBase* pBase = GetBasePool()->Find(GetStyleName()); 3211 GetBasePool()->SetSearchMask(GetFamily(), nSaveMask ); 3212 DBG_ASSERT(pBase, "where is the style?" ); 3213 if(pBase) 3214 aBaseImpl.mxNewBase = new SwDocStyleSheet(*(SwDocStyleSheet*)pBase); 3215 else 3216 throw uno::RuntimeException(); 3217 } 3218 3219 for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) 3220 { 3221 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp] ); 3222 if (!pEntry) 3223 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 3224 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) 3225 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 3226 3227 if(GetBasePool()) 3228 { 3229 switch(pEntry->nWID) 3230 { 3231 case FN_UNO_HEADER_ON: 3232 case FN_UNO_HEADER_BACKGROUND: 3233 case FN_UNO_HEADER_BOX: 3234 case FN_UNO_HEADER_LR_SPACE: 3235 case FN_UNO_HEADER_SHADOW: 3236 case FN_UNO_HEADER_BODY_DISTANCE: 3237 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: 3238 case FN_UNO_HEADER_SHARE_CONTENT: 3239 case FN_UNO_HEADER_HEIGHT: 3240 case FN_UNO_HEADER_EAT_SPACING: 3241 3242 case FN_UNO_FOOTER_ON: 3243 case FN_UNO_FOOTER_BACKGROUND: 3244 case FN_UNO_FOOTER_BOX: 3245 case FN_UNO_FOOTER_LR_SPACE: 3246 case FN_UNO_FOOTER_SHADOW: 3247 case FN_UNO_FOOTER_BODY_DISTANCE: 3248 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE: 3249 case FN_UNO_FOOTER_SHARE_CONTENT: 3250 case FN_UNO_FOOTER_HEIGHT: 3251 case FN_UNO_FOOTER_EAT_SPACING: 3252 { 3253 sal_Bool bSetItem = sal_False; 3254 sal_Bool bFooter = sal_False; 3255 sal_uInt16 nItemType = TYPE_BOOL; 3256 sal_uInt16 nRes = 0; 3257 switch(pEntry->nWID) 3258 { 3259 case FN_UNO_FOOTER_ON: bFooter = sal_True; 3260 //kein break; 3261 case FN_UNO_HEADER_ON: nRes = SID_ATTR_PAGE_ON; 3262 break; 3263 case FN_UNO_FOOTER_BACKGROUND: bFooter = sal_True; 3264 // kein break; 3265 case FN_UNO_HEADER_BACKGROUND: nRes = RES_BACKGROUND; nItemType = TYPE_BRUSH; 3266 break; 3267 case FN_UNO_FOOTER_BOX: bFooter = sal_True; 3268 // kein break; 3269 case FN_UNO_HEADER_BOX: nRes = RES_BOX; nItemType = TYPE_BOX; 3270 break; 3271 case FN_UNO_FOOTER_LR_SPACE: bFooter = sal_True; 3272 // kein break; 3273 case FN_UNO_HEADER_LR_SPACE: nRes = RES_LR_SPACE;nItemType = TYPE_LRSPACE; 3274 break; 3275 case FN_UNO_FOOTER_SHADOW: bFooter = sal_True; 3276 // kein break; 3277 case FN_UNO_HEADER_SHADOW: nRes = RES_SHADOW;nItemType = TYPE_SHADOW; 3278 break; 3279 case FN_UNO_FOOTER_BODY_DISTANCE: bFooter = sal_True; 3280 // kein break; 3281 case FN_UNO_HEADER_BODY_DISTANCE: nRes = RES_UL_SPACE;nItemType = TYPE_ULSPACE; 3282 break; 3283 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE: bFooter = sal_True; 3284 // kein break; 3285 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC; 3286 break; 3287 case FN_UNO_FOOTER_SHARE_CONTENT: bFooter = sal_True; 3288 // kein break; 3289 case FN_UNO_HEADER_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED; 3290 break; 3291 case FN_UNO_FOOTER_HEIGHT: bFooter = sal_True; 3292 // kein break; 3293 case FN_UNO_HEADER_HEIGHT: nRes = SID_ATTR_PAGE_SIZE;nItemType = TYPE_SIZE; 3294 break; 3295 case FN_UNO_FOOTER_EAT_SPACING: bFooter = sal_True; 3296 // kein break; 3297 case FN_UNO_HEADER_EAT_SPACING: nRes = RES_HEADER_FOOTER_EAT_SPACING;nItemType = TYPE_SIZE; 3298 break; 3299 } 3300 const SvxSetItem* pSetItem; 3301 if(SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState( 3302 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, 3303 sal_False, (const SfxPoolItem**)&pSetItem)) 3304 { 3305 SvxSetItem* pNewSetItem = (SvxSetItem*)pSetItem->Clone(); 3306 SfxItemSet& rSetSet = pNewSetItem->GetItemSet(); 3307 const SfxPoolItem* pItem = 0; 3308 SfxPoolItem* pNewItem = 0; 3309 rSetSet.GetItemState(nRes, sal_True, &pItem); 3310 if(!pItem && nRes != rSetSet.GetPool()->GetSlotId(nRes)) 3311 pItem = &rSetSet.GetPool()->GetDefaultItem(nRes); 3312 if(pItem) 3313 { 3314 pNewItem = pItem->Clone(); 3315 } 3316 else 3317 { 3318 switch(nItemType) 3319 { 3320 case TYPE_BOOL: pNewItem = new SfxBoolItem(nRes); break; 3321 case TYPE_SIZE: pNewItem = new SvxSizeItem(nRes); break; 3322 case TYPE_BRUSH: pNewItem = new SvxBrushItem(nRes); break; 3323 case TYPE_ULSPACE: pNewItem = new SvxULSpaceItem(nRes); break; 3324 case TYPE_SHADOW : pNewItem = new SvxShadowItem(nRes); break; 3325 case TYPE_LRSPACE: pNewItem = new SvxLRSpaceItem(nRes); break; 3326 case TYPE_BOX: pNewItem = new SvxBoxItem(nRes); break; 3327 } 3328 } 3329 bSetItem = pNewItem->PutValue(pValues[nProp], pEntry->nMemberId); 3330 rSetSet.Put(*pNewItem); 3331 aBaseImpl.GetItemSet().Put(*pNewSetItem); 3332 delete pNewItem; 3333 delete pNewSetItem; 3334 } 3335 else if(SID_ATTR_PAGE_ON == nRes ) 3336 { 3337 sal_Bool bVal = *(sal_Bool*)pValues[nProp].getValue(); 3338 if(bVal) 3339 { 3340 SfxItemSet aTempSet(*aBaseImpl.GetItemSet().GetPool(), 3341 RES_BACKGROUND, RES_SHADOW, 3342 RES_LR_SPACE, RES_UL_SPACE, 3343 nRes, nRes, 3344 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 3345 SID_ATTR_PAGE_DYNAMIC, SID_ATTR_PAGE_DYNAMIC, 3346 SID_ATTR_PAGE_SHARED, SID_ATTR_PAGE_SHARED, 3347 0 ); 3348 aTempSet.Put(SfxBoolItem(nRes, sal_True)); 3349 aTempSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(MM50, MM50))); 3350 aTempSet.Put(SvxLRSpaceItem(RES_LR_SPACE)); 3351 aTempSet.Put(SvxULSpaceItem(RES_UL_SPACE)); 3352 aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED, sal_True)); 3353 aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_DYNAMIC, sal_True)); 3354 3355 SvxSetItem aNewSetItem( bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, 3356 aTempSet); 3357 aBaseImpl.GetItemSet().Put(aNewSetItem); 3358 } 3359 } 3360 } 3361 break; 3362 case FN_PARAM_FTN_INFO : 3363 { 3364 const SfxPoolItem& rItem = aBaseImpl.GetItemSet().Get(FN_PARAM_FTN_INFO); 3365 SfxPoolItem* pNewFtnItem = rItem.Clone(); 3366 sal_Bool bPut = pNewFtnItem->PutValue(pValues[nProp], pEntry->nMemberId); 3367 aBaseImpl.GetItemSet().Put(*pNewFtnItem); 3368 delete pNewFtnItem; 3369 if(!bPut) 3370 throw lang::IllegalArgumentException(); 3371 } 3372 break; 3373 case FN_UNO_HEADER : 3374 case FN_UNO_HEADER_LEFT : 3375 case FN_UNO_HEADER_RIGHT : 3376 case FN_UNO_FOOTER : 3377 case FN_UNO_FOOTER_LEFT : 3378 case FN_UNO_FOOTER_RIGHT : 3379 throw lang::IllegalArgumentException(); 3380 //break; 3381 default: 3382 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, 3383 GetBasePool(), GetDoc(), GetFamily()); 3384 } 3385 } 3386 else if(IsDescriptor()) 3387 { 3388 if(!GetPropImpl()->SetProperty(pNames[nProp], pValues[nProp])) 3389 throw lang::IllegalArgumentException(); 3390 } 3391 else 3392 throw uno::RuntimeException(); 3393 } 3394 if(aBaseImpl.HasItemSet()) 3395 { 3396 ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo()); 3397 if (undoGuard.UndoWasEnabled()) 3398 { 3399 // Fix i64460: as long as Undo of page styles with header/footer causes trouble... 3400 GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj(); 3401 } 3402 aBaseImpl.mxNewBase->SetItemSet(aBaseImpl.GetItemSet()); 3403 } 3404 } 3405 3406 void SwXPageStyle::setPropertyValues( 3407 const uno::Sequence< OUString >& rPropertyNames, 3408 const uno::Sequence< uno::Any >& rValues ) 3409 throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 3410 { 3411 vos::OGuard aGuard(Application::GetSolarMutex()); 3412 3413 // workaround for bad designed API 3414 try 3415 { 3416 SetPropertyValues_Impl( rPropertyNames, rValues ); 3417 } 3418 catch (beans::UnknownPropertyException &rException) 3419 { 3420 // wrap the original (here not allowed) exception in 3421 // a lang::WrappedTargetException that gets thrown instead. 3422 lang::WrappedTargetException aWExc; 3423 aWExc.TargetException <<= rException; 3424 throw aWExc; 3425 } 3426 } 3427 /* -----------------------------04.11.03 13:50-------------------------------- 3428 3429 ---------------------------------------------------------------------------*/ 3430 static uno::Reference<text::XText> 3431 lcl_makeHeaderFooter( 3432 const sal_uInt16 nRes, const bool bHeader, SwFrmFmt const*const pFrmFmt) 3433 { 3434 if (!pFrmFmt) { return 0; } 3435 3436 const SfxItemSet& rSet = pFrmFmt->GetAttrSet(); 3437 const SfxPoolItem* pItem; 3438 if (SFX_ITEM_SET == rSet.GetItemState(nRes, sal_True, &pItem)) 3439 { 3440 SwFrmFmt *const pHeadFootFmt = (bHeader) 3441 ? static_cast<SwFmtHeader*>(const_cast<SfxPoolItem*>(pItem))-> 3442 GetHeaderFmt() 3443 : static_cast<SwFmtFooter*>(const_cast<SfxPoolItem*>(pItem))-> 3444 GetFooterFmt(); 3445 if (pHeadFootFmt) 3446 { 3447 return SwXHeadFootText::CreateXHeadFootText(*pHeadFootFmt, bHeader); 3448 } 3449 } 3450 return 0; 3451 } 3452 3453 uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( 3454 const uno::Sequence< OUString >& rPropertyNames ) 3455 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 3456 { 3457 if(!GetDoc()) 3458 throw uno::RuntimeException(); 3459 3460 sal_Int32 nLength = rPropertyNames.getLength(); 3461 const OUString* pNames = rPropertyNames.getConstArray(); 3462 uno::Sequence< uno::Any > aRet ( nLength ); 3463 3464 uno::Any* pRet = aRet.getArray(); 3465 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE); 3466 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap(); 3467 SwStyleBase_Impl aBase(*GetDoc(), GetStyleName()); 3468 SfxStyleSheetBase* pBase = 0; 3469 for(sal_Int32 nProp = 0; nProp < nLength; nProp++) 3470 { 3471 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp] ); 3472 if (!pEntry) 3473 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); 3474 3475 if(GetBasePool()) 3476 { 3477 if(!pBase) 3478 { 3479 sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask(); 3480 GetBasePool()->SetSearchMask(GetFamily(), SFXSTYLEBIT_ALL ); 3481 pBase = GetBasePool()->Find(GetStyleName()); 3482 GetBasePool()->SetSearchMask(GetFamily(), nSaveMask ); 3483 } 3484 sal_uInt16 nRes = 0; 3485 bool bHeader = false; 3486 sal_Bool bAll = sal_False, bLeft = sal_False, bRight = sal_False; 3487 switch(pEntry->nWID) 3488 { 3489 case FN_UNO_HEADER_ON: 3490 case FN_UNO_HEADER_BACKGROUND: 3491 case FN_UNO_HEADER_BOX: 3492 case FN_UNO_HEADER_LR_SPACE: 3493 case FN_UNO_HEADER_SHADOW: 3494 case FN_UNO_HEADER_BODY_DISTANCE: 3495 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: 3496 case FN_UNO_HEADER_SHARE_CONTENT: 3497 case FN_UNO_HEADER_HEIGHT: 3498 case FN_UNO_HEADER_EAT_SPACING: 3499 3500 case FN_UNO_FOOTER_ON: 3501 case FN_UNO_FOOTER_BACKGROUND: 3502 case FN_UNO_FOOTER_BOX: 3503 case FN_UNO_FOOTER_LR_SPACE: 3504 case FN_UNO_FOOTER_SHADOW: 3505 case FN_UNO_FOOTER_BODY_DISTANCE: 3506 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE: 3507 case FN_UNO_FOOTER_SHARE_CONTENT: 3508 case FN_UNO_FOOTER_HEIGHT: 3509 case FN_UNO_FOOTER_EAT_SPACING: 3510 { 3511 SfxStyleSheetBasePool* pBasePool2 = ((SwXPageStyle*)this)->GetBasePool(); 3512 pBasePool2->SetSearchMask(GetFamily()); 3513 SfxStyleSheetBase* pBase2 = pBasePool2->Find(GetStyleName()); 3514 if(pBase2) 3515 { 3516 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 3517 const SfxItemSet& rSet = xStyle->GetItemSet(); 3518 sal_Bool bFooter = sal_False; 3519 switch(pEntry->nWID) 3520 { 3521 case FN_UNO_FOOTER_ON: 3522 bFooter = sal_True; 3523 // kein break! 3524 case FN_UNO_HEADER_ON: 3525 { 3526 //falls das SetItem nicht da ist, dann ist der Wert sal_False 3527 sal_Bool bRet = sal_False; 3528 pRet[nProp].setValue(&bRet, ::getCppuBooleanType()); 3529 nRes = SID_ATTR_PAGE_ON; 3530 } 3531 break; 3532 case FN_UNO_FOOTER_BACKGROUND: bFooter = sal_True; 3533 // kein break; 3534 case FN_UNO_HEADER_BACKGROUND: nRes = RES_BACKGROUND; 3535 break; 3536 case FN_UNO_FOOTER_BOX: bFooter = sal_True; 3537 // kein break; 3538 case FN_UNO_HEADER_BOX: nRes = RES_BOX; 3539 break; 3540 case FN_UNO_FOOTER_LR_SPACE: bFooter = sal_True; 3541 // kein break; 3542 case FN_UNO_HEADER_LR_SPACE: nRes = RES_LR_SPACE; 3543 break; 3544 case FN_UNO_FOOTER_SHADOW: bFooter = sal_True; 3545 // kein break; 3546 case FN_UNO_HEADER_SHADOW: nRes = RES_SHADOW; 3547 break; 3548 case FN_UNO_FOOTER_BODY_DISTANCE: bFooter = sal_True; 3549 // kein break; 3550 case FN_UNO_HEADER_BODY_DISTANCE: nRes = RES_UL_SPACE; 3551 break; 3552 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE: bFooter = sal_True; 3553 // kein break; 3554 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC; 3555 break; 3556 case FN_UNO_FOOTER_SHARE_CONTENT: bFooter = sal_True; 3557 // kein break; 3558 case FN_UNO_HEADER_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED; 3559 break; 3560 case FN_UNO_FOOTER_HEIGHT: bFooter = sal_True; 3561 // kein break; 3562 case FN_UNO_HEADER_HEIGHT: nRes = SID_ATTR_PAGE_SIZE; 3563 break; 3564 case FN_UNO_FOOTER_EAT_SPACING: bFooter = sal_True; 3565 // kein break; 3566 case FN_UNO_HEADER_EAT_SPACING: nRes = RES_HEADER_FOOTER_EAT_SPACING; 3567 break; 3568 } 3569 const SvxSetItem* pSetItem; 3570 if(SFX_ITEM_SET == rSet.GetItemState( 3571 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, 3572 sal_False, (const SfxPoolItem**)&pSetItem)) 3573 { 3574 const SfxItemSet& rTmpSet = pSetItem->GetItemSet(); 3575 const SfxPoolItem* pItem = 0; 3576 rTmpSet.GetItemState(nRes, sal_True, &pItem); 3577 if(!pItem && nRes != rTmpSet.GetPool()->GetSlotId(nRes)) 3578 pItem = &rTmpSet.GetPool()->GetDefaultItem(nRes); 3579 if(pItem) 3580 pItem->QueryValue(pRet[nProp], pEntry->nMemberId); 3581 } 3582 } 3583 } 3584 break; 3585 case FN_UNO_HEADER : 3586 bAll = sal_True; goto Header; 3587 case FN_UNO_HEADER_LEFT : 3588 bLeft = sal_True; goto Header; 3589 case FN_UNO_HEADER_RIGHT : 3590 bRight = sal_True; goto Header; 3591 Header: 3592 bHeader = true; 3593 nRes = RES_HEADER; goto MakeObject; 3594 case FN_UNO_FOOTER : 3595 bAll = sal_True; goto Footer; 3596 case FN_UNO_FOOTER_LEFT : 3597 bLeft = sal_True; goto Footer; 3598 case FN_UNO_FOOTER_RIGHT : 3599 bRight = sal_True; 3600 Footer: 3601 nRes = RES_FOOTER; 3602 MakeObject: 3603 { 3604 const SwPageDesc& rDesc = aBase.GetOldPageDesc(); 3605 const SwFrmFmt* pFrmFmt = 0; 3606 sal_Bool bShare = (bHeader && rDesc.IsHeaderShared())|| 3607 (!bHeader && rDesc.IsFooterShared()); 3608 // TextLeft returns the left content if there is one, 3609 // Text and TextRight return the master content. 3610 // TextRight does the same as Text and is for 3611 // comptability only. 3612 if( bLeft && !bShare ) 3613 { 3614 pFrmFmt = &rDesc.GetLeft(); 3615 } 3616 else 3617 { 3618 pFrmFmt = &rDesc.GetMaster(); 3619 } 3620 const uno::Reference< text::XText > xRet = 3621 lcl_makeHeaderFooter(nRes, bHeader, pFrmFmt); 3622 if (xRet.is()) 3623 { 3624 pRet[nProp] <<= xRet; 3625 } 3626 } 3627 break; 3628 case FN_PARAM_FTN_INFO : 3629 { 3630 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); 3631 const SfxItemSet& rSet = xStyle->GetItemSet(); 3632 const SfxPoolItem& rItem = rSet.Get(FN_PARAM_FTN_INFO); 3633 rItem.QueryValue(pRet[nProp], pEntry->nMemberId); 3634 } 3635 break; 3636 default: 3637 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() ); 3638 } 3639 } 3640 else if(IsDescriptor()) 3641 { 3642 uno::Any* pAny = 0; 3643 GetPropImpl()->GetProperty(pNames[nProp], pAny); 3644 if ( !pAny ) 3645 GetPropImpl()->GetProperty ( pNames[nProp], mxStyleData, pRet[ nProp ] ); 3646 else 3647 pRet[nProp] = *pAny; 3648 } 3649 else 3650 throw uno::RuntimeException(); 3651 } 3652 return aRet; 3653 } 3654 /* -----------------------------18.04.01 13:50-------------------------------- 3655 3656 ---------------------------------------------------------------------------*/ 3657 uno::Sequence< uno::Any > SwXPageStyle::getPropertyValues( 3658 const uno::Sequence< OUString >& rPropertyNames ) 3659 throw(uno::RuntimeException) 3660 { 3661 vos::OGuard aGuard(Application::GetSolarMutex()); 3662 uno::Sequence< uno::Any > aValues; 3663 3664 // workaround for bad designed API 3665 try 3666 { 3667 aValues = GetPropertyValues_Impl( rPropertyNames ); 3668 } 3669 catch (beans::UnknownPropertyException &) 3670 { 3671 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 3672 } 3673 catch (lang::WrappedTargetException &) 3674 { 3675 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 3676 } 3677 3678 return aValues; 3679 } 3680 /*-- 17.12.98 08:43:36--------------------------------------------------- 3681 3682 -----------------------------------------------------------------------*/ 3683 uno::Any SwXPageStyle::getPropertyValue(const OUString& rPropertyName) throw( 3684 beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 3685 { 3686 vos::OGuard aGuard(Application::GetSolarMutex()); 3687 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 3688 return GetPropertyValues_Impl(aProperties).getConstArray()[0]; 3689 } 3690 /*-- 17.12.98 08:43:36--------------------------------------------------- 3691 3692 -----------------------------------------------------------------------*/ 3693 void SwXPageStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue) 3694 throw( beans::UnknownPropertyException, 3695 beans::PropertyVetoException, 3696 lang::IllegalArgumentException, 3697 lang::WrappedTargetException, 3698 uno::RuntimeException) 3699 { 3700 vos::OGuard aGuard(Application::GetSolarMutex()); 3701 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 3702 const uno::Sequence<uno::Any> aValues(&rValue, 1); 3703 SetPropertyValues_Impl( aProperties, aValues ); 3704 } 3705 3706 SwXFrameStyle::SwXFrameStyle ( SwDoc *pDoc ) 3707 : SwXStyle ( pDoc, SFX_STYLE_FAMILY_FRAME, sal_False) 3708 { 3709 } 3710 /* -----------------------------15.12.00 15:45-------------------------------- 3711 3712 ---------------------------------------------------------------------------*/ 3713 SwXFrameStyle::~SwXFrameStyle() 3714 { 3715 } 3716 /* -----------------------------15.12.00 14:30-------------------------------- 3717 3718 ---------------------------------------------------------------------------*/ 3719 uno::Sequence< uno::Type > SwXFrameStyle::getTypes( ) throw(uno::RuntimeException) 3720 { 3721 uno::Sequence< uno::Type > aTypes = SwXStyle::getTypes(); 3722 sal_Int32 nLen = aTypes.getLength(); 3723 aTypes.realloc(nLen + 1); 3724 aTypes.getArray()[nLen] = ::getCppuType((uno::Reference<XEventsSupplier>*)0); 3725 return aTypes; 3726 } 3727 /* -----------------------------15.12.00 14:30-------------------------------- 3728 3729 ---------------------------------------------------------------------------*/ 3730 uno::Any SwXFrameStyle::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException) 3731 { 3732 uno::Any aRet; 3733 if(rType == ::getCppuType((uno::Reference<XEventsSupplier>*)0)) 3734 aRet <<= uno::Reference<XEventsSupplier>(this); 3735 else 3736 aRet = SwXStyle::queryInterface(rType); 3737 return aRet; 3738 } 3739 /* -----------------------------15.12.00 14:30-------------------------------- 3740 3741 ---------------------------------------------------------------------------*/ 3742 uno::Reference< container::XNameReplace > SwXFrameStyle::getEvents( ) throw(uno::RuntimeException) 3743 { 3744 return new SwFrameStyleEventDescriptor( *this ); 3745 } 3746 /*-- 19.05.2006 11:23:55--------------------------------------------------- 3747 3748 -----------------------------------------------------------------------*/ 3749 SwXAutoStyles::SwXAutoStyles(SwDocShell& rDocShell) : 3750 SwUnoCollection(rDocShell.GetDoc()), pDocShell( &rDocShell ) 3751 { 3752 } 3753 /*-- 19.05.2006 11:23:56--------------------------------------------------- 3754 3755 -----------------------------------------------------------------------*/ 3756 SwXAutoStyles::~SwXAutoStyles() 3757 { 3758 } 3759 /*-- 19.05.2006 11:23:57--------------------------------------------------- 3760 3761 -----------------------------------------------------------------------*/ 3762 sal_Int32 SwXAutoStyles::getCount(void) throw( uno::RuntimeException ) 3763 { 3764 return AUTOSTYLE_FAMILY_COUNT; 3765 } 3766 /*-- 19.05.2006 11:23:57--------------------------------------------------- 3767 3768 -----------------------------------------------------------------------*/ 3769 uno::Any SwXAutoStyles::getByIndex(sal_Int32 nIndex) 3770 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, 3771 uno::RuntimeException ) 3772 { 3773 vos::OGuard aGuard(Application::GetSolarMutex()); 3774 uno::Any aRet; 3775 if(nIndex < 0 || nIndex >= AUTOSTYLE_FAMILY_COUNT) 3776 throw lang::IndexOutOfBoundsException(); 3777 if(IsValid()) 3778 { 3779 uno::Reference< style::XAutoStyleFamily > aRef; 3780 IStyleAccess::SwAutoStyleFamily nType = aAutoStyleByIndex[nIndex]; 3781 switch( nType ) 3782 { 3783 case IStyleAccess::AUTO_STYLE_CHAR: 3784 { 3785 if(!xAutoCharStyles.is()) 3786 xAutoCharStyles = new SwXAutoStyleFamily(pDocShell, nType); 3787 aRef = xAutoCharStyles; 3788 } 3789 break; 3790 case IStyleAccess::AUTO_STYLE_RUBY: 3791 { 3792 if(!xAutoRubyStyles.is()) 3793 xAutoRubyStyles = new SwXAutoStyleFamily(pDocShell, nType ); 3794 aRef = xAutoRubyStyles; 3795 } 3796 break; 3797 case IStyleAccess::AUTO_STYLE_PARA: 3798 { 3799 if(!xAutoParaStyles.is()) 3800 xAutoParaStyles = new SwXAutoStyleFamily(pDocShell, nType ); 3801 aRef = xAutoParaStyles; 3802 } 3803 break; 3804 3805 default: 3806 ; 3807 } 3808 aRet.setValue(&aRef, ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0)); 3809 } 3810 else 3811 throw uno::RuntimeException(); 3812 return aRet; 3813 } 3814 /*-- 19.05.2006 11:23:57--------------------------------------------------- 3815 3816 -----------------------------------------------------------------------*/ 3817 uno::Type SwXAutoStyles::getElementType( ) throw(uno::RuntimeException) 3818 { 3819 return ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0); 3820 } 3821 /*-- 19.05.2006 11:23:58--------------------------------------------------- 3822 3823 -----------------------------------------------------------------------*/ 3824 sal_Bool SwXAutoStyles::hasElements( ) throw(uno::RuntimeException) 3825 { 3826 return sal_True; 3827 } 3828 /*-- 19.05.2006 11:23:58--------------------------------------------------- 3829 3830 -----------------------------------------------------------------------*/ 3831 uno::Any SwXAutoStyles::getByName(const rtl::OUString& Name) 3832 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) 3833 { 3834 uno::Any aRet; 3835 if(Name.compareToAscii("CharacterStyles") == 0 ) 3836 aRet = getByIndex(0); 3837 else if(Name.compareToAscii("RubyStyles") == 0 ) 3838 aRet = getByIndex(1); 3839 else if(Name.compareToAscii("ParagraphStyles") == 0 ) 3840 aRet = getByIndex(2); 3841 else 3842 throw container::NoSuchElementException(); 3843 return aRet; 3844 } 3845 /*-- 19.05.2006 11:23:59--------------------------------------------------- 3846 3847 -----------------------------------------------------------------------*/ 3848 uno::Sequence< rtl::OUString > SwXAutoStyles::getElementNames(void) 3849 throw( uno::RuntimeException ) 3850 { 3851 uno::Sequence< OUString > aNames(AUTOSTYLE_FAMILY_COUNT); 3852 OUString* pNames = aNames.getArray(); 3853 pNames[0] = C2U("CharacterStyles"); 3854 pNames[1] = C2U("RubyStyles"); 3855 pNames[2] = C2U("ParagraphStyles"); 3856 return aNames; 3857 } 3858 /*-- 19.05.2006 11:24:00--------------------------------------------------- 3859 3860 -----------------------------------------------------------------------*/ 3861 sal_Bool SwXAutoStyles::hasByName(const rtl::OUString& Name) 3862 throw( uno::RuntimeException ) 3863 { 3864 if( Name.compareToAscii("CharacterStyles") == 0 || 3865 Name.compareToAscii("RubyStyles") == 0 || 3866 Name.compareToAscii("ParagraphStyles") == 0 ) 3867 return sal_True; 3868 else 3869 return sal_False; 3870 } 3871 3872 /*-- 19.05.2006 11:24:02--------------------------------------------------- 3873 3874 -----------------------------------------------------------------------*/ 3875 SwXAutoStyleFamily::SwXAutoStyleFamily(SwDocShell* pDocSh, IStyleAccess::SwAutoStyleFamily nFamily) : 3876 pDocShell( pDocSh ), eFamily(nFamily) 3877 { 3878 // Register ourselves as a listener to the document (via the page descriptor) 3879 pDocSh->GetDoc()->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); 3880 } 3881 /*-- 19.05.2006 11:24:02--------------------------------------------------- 3882 3883 -----------------------------------------------------------------------*/ 3884 SwXAutoStyleFamily::~SwXAutoStyleFamily() 3885 { 3886 } 3887 3888 void SwXAutoStyleFamily::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) 3889 { 3890 ClientModify(this, pOld, pNew); 3891 if(!GetRegisteredIn()) 3892 pDocShell = 0; 3893 } 3894 3895 /*-- 31.05.2006 11:24:02--------------------------------------------------- 3896 3897 -----------------------------------------------------------------------*/ 3898 uno::Reference< style::XAutoStyle > SwXAutoStyleFamily::insertStyle( 3899 const uno::Sequence< beans::PropertyValue >& Values ) 3900 throw (uno::RuntimeException) 3901 { 3902 if( !pDocShell ) 3903 throw uno::RuntimeException(); 3904 const sal_uInt16* pRange = 0; 3905 const SfxItemPropertySet* pPropSet = 0; 3906 switch( eFamily ) 3907 { 3908 case IStyleAccess::AUTO_STYLE_CHAR: 3909 { 3910 pRange = aCharAutoFmtSetRange; 3911 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE); 3912 } 3913 break; 3914 case IStyleAccess::AUTO_STYLE_RUBY: 3915 { 3916 pRange = 0;//aTxtNodeSetRange; 3917 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_RUBY_AUTO_STYLE); 3918 } 3919 break; 3920 case IStyleAccess::AUTO_STYLE_PARA: 3921 { 3922 pRange = aTxtNodeSetRange; 3923 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARA_AUTO_STYLE); 3924 } 3925 break; 3926 3927 default: 3928 ; 3929 } 3930 SwAttrSet aSet( pDocShell->GetDoc()->GetAttrPool(), pRange ); 3931 const beans::PropertyValue* pSeq = Values.getConstArray(); 3932 sal_Int32 nLen = Values.getLength(); 3933 for( sal_Int32 i = 0; i < nLen; ++i ) 3934 { 3935 try 3936 { 3937 pPropSet->setPropertyValue( pSeq[i].Name, pSeq[i].Value, aSet ); 3938 } 3939 catch (beans::UnknownPropertyException &) 3940 { 3941 ASSERT( false, "Unknown property" ); 3942 } 3943 catch (lang::IllegalArgumentException &) 3944 { 3945 ASSERT( false, "Illegal argument" ); 3946 } 3947 } 3948 3949 SfxItemSet_Pointer_t pSet = pDocShell->GetDoc()->GetIStyleAccess().cacheAutomaticStyle( aSet, eFamily ); 3950 uno::Reference<style::XAutoStyle> xRet = new SwXAutoStyle(pDocShell->GetDoc(), pSet, eFamily); 3951 return xRet; 3952 } 3953 /*-- 31.05.2006 11:24:02--------------------------------------------------- 3954 3955 -----------------------------------------------------------------------*/ 3956 uno::Reference< container::XEnumeration > SwXAutoStyleFamily::createEnumeration( ) 3957 throw (uno::RuntimeException) 3958 { 3959 if( !pDocShell ) 3960 throw uno::RuntimeException(); 3961 return uno::Reference< container::XEnumeration > 3962 (new SwXAutoStylesEnumerator( pDocShell->GetDoc(), eFamily )); 3963 } 3964 /*-- 19.05.2006 11:24:03--------------------------------------------------- 3965 3966 -----------------------------------------------------------------------*/ 3967 uno::Type SwXAutoStyleFamily::getElementType( ) throw(uno::RuntimeException) 3968 { 3969 return ::getCppuType((const uno::Reference<style::XAutoStyle>*)0); 3970 } 3971 /*-- 19.05.2006 11:24:04--------------------------------------------------- 3972 3973 -----------------------------------------------------------------------*/ 3974 sal_Bool SwXAutoStyleFamily::hasElements( ) throw(uno::RuntimeException) 3975 { 3976 return sal_False; 3977 } 3978 3979 /*-- 31.05.2006 11:24:05--------------------------------------------------- 3980 3981 -----------------------------------------------------------------------*/ 3982 SwAutoStylesEnumImpl::SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam ) 3983 : pDoc( pInitDoc ), eFamily( eFam ) 3984 { 3985 // special case for ruby auto styles: 3986 if ( IStyleAccess::AUTO_STYLE_RUBY == eFam ) 3987 { 3988 std::set< std::pair< sal_uInt16, sal_uInt16 > > aRubyMap; 3989 SwAttrPool& rAttrPool = pDoc->GetAttrPool(); 3990 sal_uInt32 nCount = rAttrPool.GetItemCount2( RES_TXTATR_CJK_RUBY ); 3991 3992 for ( sal_uInt32 nI = 0; nI < nCount; ++nI ) 3993 { 3994 const SwFmtRuby* pItem = static_cast<const SwFmtRuby*>(rAttrPool.GetItem2( RES_TXTATR_CJK_RUBY, nI )); 3995 if ( pItem && pItem->GetTxtRuby() ) 3996 { 3997 std::pair< sal_uInt16, sal_uInt16 > aPair( pItem->GetPosition(), pItem->GetAdjustment() ); 3998 if ( aRubyMap.find( aPair ) == aRubyMap.end() ) 3999 { 4000 aRubyMap.insert( aPair ); 4001 SfxItemSet_Pointer_t pItemSet( new SfxItemSet( rAttrPool, RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY ) ); 4002 pItemSet->Put( *pItem ); 4003 mAutoStyles.push_back( pItemSet ); 4004 } 4005 } 4006 } 4007 } 4008 else 4009 { 4010 pDoc->GetIStyleAccess().getAllStyles( mAutoStyles, eFamily ); 4011 } 4012 4013 aIter = mAutoStyles.begin(); 4014 } 4015 4016 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4017 4018 -----------------------------------------------------------------------*/ 4019 SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwAutoStyleFamily eFam ) 4020 : pImpl( new SwAutoStylesEnumImpl( pDoc, eFam ) ) 4021 { 4022 // Register ourselves as a listener to the document (via the page descriptor) 4023 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); 4024 } 4025 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4026 4027 -----------------------------------------------------------------------*/ 4028 SwXAutoStylesEnumerator::~SwXAutoStylesEnumerator() 4029 { 4030 delete pImpl; 4031 } 4032 4033 void SwXAutoStylesEnumerator::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) 4034 { 4035 ClientModify(this, pOld, pNew); 4036 if(!GetRegisteredIn()) 4037 { 4038 delete pImpl; 4039 pImpl = 0; 4040 } 4041 } 4042 4043 4044 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4045 4046 -----------------------------------------------------------------------*/ 4047 ::sal_Bool SwXAutoStylesEnumerator::hasMoreElements( ) 4048 throw (uno::RuntimeException) 4049 { 4050 if( !pImpl ) 4051 throw uno::RuntimeException(); 4052 return pImpl->hasMoreElements(); 4053 } 4054 /*-- 31.05.2006 11:24:05--------------------------------------------------- 4055 4056 -----------------------------------------------------------------------*/ 4057 uno::Any SwXAutoStylesEnumerator::nextElement( ) 4058 throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 4059 { 4060 if( !pImpl ) 4061 throw uno::RuntimeException(); 4062 uno::Any aRet; 4063 if( pImpl->hasMoreElements() ) 4064 { 4065 SfxItemSet_Pointer_t pNextSet = pImpl->nextElement(); 4066 uno::Reference< style::XAutoStyle > xAutoStyle = new SwXAutoStyle(pImpl->getDoc(), 4067 pNextSet, pImpl->getFamily()); 4068 aRet.setValue(&xAutoStyle, ::getCppuType((uno::Reference<style::XAutoStyle>*)0)); 4069 } 4070 return aRet; 4071 } 4072 /*-- 19.05.2006 11:24:09--------------------------------------------------- 4073 4074 -----------------------------------------------------------------------*/ 4075 SwXAutoStyle::SwXAutoStyle( SwDoc* pDoc, SfxItemSet_Pointer_t pInitSet, IStyleAccess::SwAutoStyleFamily eFam ) 4076 : pSet( pInitSet ), eFamily( eFam ) 4077 { 4078 // Register ourselves as a listener to the document (via the page descriptor) 4079 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); 4080 } 4081 4082 /*-- 19.05.2006 11:24:09--------------------------------------------------- 4083 4084 -----------------------------------------------------------------------*/ 4085 SwXAutoStyle::~SwXAutoStyle() 4086 { 4087 } 4088 4089 void SwXAutoStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) 4090 { 4091 ClientModify(this, pOld, pNew); 4092 if(!GetRegisteredIn()) 4093 pSet.reset(); 4094 } 4095 4096 /*-- 19.05.2006 11:24:09--------------------------------------------------- 4097 4098 -----------------------------------------------------------------------*/ 4099 uno::Reference< beans::XPropertySetInfo > SwXAutoStyle::getPropertySetInfo( ) 4100 throw (uno::RuntimeException) 4101 { 4102 uno::Reference< beans::XPropertySetInfo > xRet; 4103 switch( eFamily ) 4104 { 4105 case IStyleAccess::AUTO_STYLE_CHAR: 4106 { 4107 static uno::Reference< beans::XPropertySetInfo > xCharRef; 4108 if(!xCharRef.is()) 4109 { 4110 xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE)->getPropertySetInfo(); 4111 } 4112 xRet = xCharRef; 4113 } 4114 break; 4115 case IStyleAccess::AUTO_STYLE_RUBY: 4116 { 4117 static uno::Reference< beans::XPropertySetInfo > xRubyRef; 4118 if(!xRubyRef.is()) 4119 { 4120 sal_uInt16 nMapId = PROPERTY_MAP_RUBY_AUTO_STYLE; 4121 xRubyRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo(); 4122 } 4123 xRet = xRubyRef; 4124 } 4125 break; 4126 case IStyleAccess::AUTO_STYLE_PARA: 4127 { 4128 static uno::Reference< beans::XPropertySetInfo > xParaRef; 4129 if(!xParaRef.is()) 4130 { 4131 sal_uInt16 nMapId = PROPERTY_MAP_PARA_AUTO_STYLE; 4132 xParaRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo(); 4133 } 4134 xRet = xParaRef; 4135 } 4136 break; 4137 4138 default: 4139 ; 4140 } 4141 4142 return xRet; 4143 } 4144 4145 /*-- 19.05.2006 11:24:09--------------------------------------------------- 4146 4147 -----------------------------------------------------------------------*/ 4148 void SwXAutoStyle::setPropertyValue( const OUString& /*rPropertyName*/, const uno::Any& /*rValue*/ ) 4149 throw( beans::UnknownPropertyException, 4150 beans::PropertyVetoException, 4151 lang::IllegalArgumentException, 4152 lang::WrappedTargetException, 4153 uno::RuntimeException) 4154 { 4155 } 4156 4157 /*-- 19.05.2006 11:24:09--------------------------------------------------- 4158 4159 -----------------------------------------------------------------------*/ 4160 uno::Any SwXAutoStyle::getPropertyValue( const OUString& rPropertyName ) 4161 throw( beans::UnknownPropertyException, 4162 lang::WrappedTargetException, 4163 uno::RuntimeException ) 4164 { 4165 vos::OGuard aGuard(Application::GetSolarMutex()); 4166 const uno::Sequence<OUString> aProperties(&rPropertyName, 1); 4167 return GetPropertyValues_Impl(aProperties).getConstArray()[0]; 4168 } 4169 4170 /*-- 19.05.2006 11:24:09--------------------------------------------------- 4171 4172 -----------------------------------------------------------------------*/ 4173 void SwXAutoStyle::addPropertyChangeListener( const OUString& /*aPropertyName*/, 4174 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) 4175 throw( beans::UnknownPropertyException, 4176 lang::WrappedTargetException, 4177 uno::RuntimeException ) 4178 { 4179 } 4180 4181 /*-- 19.05.2006 11:24:09--------------------------------------------------- 4182 4183 -----------------------------------------------------------------------*/ 4184 void SwXAutoStyle::removePropertyChangeListener( const OUString& /*aPropertyName*/, 4185 const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) 4186 throw( beans::UnknownPropertyException, 4187 lang::WrappedTargetException, 4188 uno::RuntimeException ) 4189 { 4190 } 4191 4192 /*-- 19.05.2006 11:24:09--------------------------------------------------- 4193 4194 -----------------------------------------------------------------------*/ 4195 void SwXAutoStyle::addVetoableChangeListener( const OUString& /*PropertyName*/, 4196 const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) 4197 throw( beans::UnknownPropertyException, 4198 lang::WrappedTargetException, 4199 uno::RuntimeException ) 4200 { 4201 } 4202 4203 /*-- 19.05.2006 11:24:09--------------------------------------------------- 4204 4205 -----------------------------------------------------------------------*/ 4206 void SwXAutoStyle::removeVetoableChangeListener( const OUString& /*PropertyName*/, 4207 const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) 4208 throw( beans::UnknownPropertyException, 4209 lang::WrappedTargetException, 4210 uno::RuntimeException ) 4211 { 4212 } 4213 4214 /*-- 19.05.2006 11:24:09--------------------------------------------------- 4215 4216 -----------------------------------------------------------------------*/ 4217 void SwXAutoStyle::setPropertyValues( 4218 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, 4219 const uno::Sequence< uno::Any >& /*aValues*/ ) 4220 throw (beans::PropertyVetoException, lang::IllegalArgumentException, 4221 lang::WrappedTargetException, uno::RuntimeException) 4222 { 4223 } 4224 4225 /*-- 19.05.2006 11:24:09--------------------------------------------------- 4226 4227 -----------------------------------------------------------------------*/ 4228 uno::Sequence< uno::Any > SwXAutoStyle::GetPropertyValues_Impl( 4229 const uno::Sequence< OUString > & rPropertyNames ) 4230 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 4231 { 4232 if( !pSet.get() ) 4233 throw uno::RuntimeException(); 4234 // query_item 4235 4236 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; 4237 switch(eFamily) 4238 { 4239 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break; 4240 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break; 4241 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break; 4242 default: 4243 ; 4244 } 4245 4246 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 4247 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 4248 const OUString* pNames = rPropertyNames.getConstArray(); 4249 4250 sal_Int32 nLen = rPropertyNames.getLength(); 4251 uno::Sequence< uno::Any > aRet( nLen ); 4252 uno::Any* pValues = aRet.getArray(); 4253 4254 SfxItemSet& rSet = *pSet.get(); 4255 4256 for( sal_Int32 i = 0; i < nLen; ++i ) 4257 { 4258 const String& rPropName = pNames[i]; 4259 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName); 4260 if(!pEntry) 4261 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 4262 else if ( RES_TXTATR_AUTOFMT == pEntry->nWID || RES_AUTO_STYLE == pEntry->nWID ) 4263 { 4264 OUString sName(StylePool::nameOf( pSet )); 4265 pValues[i] <<= sName; 4266 } 4267 else 4268 pPropSet->getPropertyValue( *pEntry, rSet, pValues[i] ); 4269 } 4270 return aRet; 4271 } 4272 4273 /*-- 19.05.2006 11:24:09--------------------------------------------------- 4274 4275 -----------------------------------------------------------------------*/ 4276 uno::Sequence< uno::Any > SwXAutoStyle::getPropertyValues ( 4277 const uno::Sequence< ::rtl::OUString >& rPropertyNames ) 4278 throw (uno::RuntimeException) 4279 { 4280 vos::OGuard aGuard(Application::GetSolarMutex()); 4281 uno::Sequence< uno::Any > aValues; 4282 4283 // workaround for bad designed API 4284 try 4285 { 4286 aValues = GetPropertyValues_Impl( rPropertyNames ); 4287 } 4288 catch (beans::UnknownPropertyException &) 4289 { 4290 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 4291 } 4292 catch (lang::WrappedTargetException &) 4293 { 4294 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 4295 } 4296 4297 return aValues; 4298 } 4299 4300 /*-- 19.05.2006 11:24:10--------------------------------------------------- 4301 4302 -----------------------------------------------------------------------*/ 4303 void SwXAutoStyle::addPropertiesChangeListener( 4304 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, 4305 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 4306 throw (uno::RuntimeException) 4307 { 4308 } 4309 4310 /*-- 19.05.2006 11:24:10--------------------------------------------------- 4311 4312 -----------------------------------------------------------------------*/ 4313 void SwXAutoStyle::removePropertiesChangeListener( 4314 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 4315 throw (uno::RuntimeException) 4316 { 4317 } 4318 4319 /*-- 19.05.2006 11:24:11--------------------------------------------------- 4320 4321 -----------------------------------------------------------------------*/ 4322 void SwXAutoStyle::firePropertiesChangeEvent( 4323 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, 4324 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 4325 throw (uno::RuntimeException) 4326 { 4327 } 4328 4329 /*-- 19.05.2006 11:24:11--------------------------------------------------- 4330 4331 -----------------------------------------------------------------------*/ 4332 beans::PropertyState SwXAutoStyle::getPropertyState( const OUString& rPropertyName ) 4333 throw( beans::UnknownPropertyException, 4334 uno::RuntimeException) 4335 { 4336 vos::OGuard aGuard(Application::GetSolarMutex()); 4337 4338 uno::Sequence< OUString > aNames(1); 4339 OUString* pNames = aNames.getArray(); 4340 pNames[0] = rPropertyName; 4341 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames); 4342 return aStates.getConstArray()[0]; 4343 } 4344 4345 /*-- 19.05.2006 11:24:11--------------------------------------------------- 4346 4347 -----------------------------------------------------------------------*/ 4348 void SwXAutoStyle::setPropertyToDefault( const OUString& /*PropertyName*/ ) 4349 throw( beans::UnknownPropertyException, 4350 uno::RuntimeException ) 4351 { 4352 } 4353 4354 /*-- 19.05.2006 11:24:11--------------------------------------------------- 4355 4356 -----------------------------------------------------------------------*/ 4357 uno::Any SwXAutoStyle::getPropertyDefault( const OUString& rPropertyName ) 4358 throw( beans::UnknownPropertyException, 4359 lang::WrappedTargetException, 4360 uno::RuntimeException) 4361 { 4362 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 ); 4363 return getPropertyDefaults ( aSequence ).getConstArray()[0]; 4364 } 4365 4366 /*-- 19.05.2006 11:24:12--------------------------------------------------- 4367 4368 -----------------------------------------------------------------------*/ 4369 uno::Sequence< beans::PropertyState > SwXAutoStyle::getPropertyStates( 4370 const uno::Sequence< ::rtl::OUString >& rPropertyNames ) 4371 throw (beans::UnknownPropertyException, uno::RuntimeException) 4372 { 4373 if( !pSet.get() ) 4374 throw uno::RuntimeException(); 4375 vos::OGuard aGuard(Application::GetSolarMutex()); 4376 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength()); 4377 beans::PropertyState* pStates = aRet.getArray(); 4378 const OUString* pNames = rPropertyNames.getConstArray(); 4379 4380 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; 4381 switch(eFamily) 4382 { 4383 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break; 4384 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break; 4385 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break; 4386 default: 4387 ; 4388 } 4389 4390 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 4391 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 4392 SfxItemSet& rSet = *pSet.get(); 4393 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) 4394 { 4395 const String& rPropName = pNames[i]; 4396 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName); 4397 if(!pEntry) 4398 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); 4399 pStates[i] = pPropSet->getPropertyState(*pEntry, rSet ); 4400 } 4401 return aRet; 4402 } 4403 4404 /*-- 19.05.2006 11:24:12--------------------------------------------------- 4405 4406 -----------------------------------------------------------------------*/ 4407 void SwXAutoStyle::setAllPropertiesToDefault( ) 4408 throw (uno::RuntimeException) 4409 { 4410 } 4411 4412 /*-- 19.05.2006 11:24:13--------------------------------------------------- 4413 4414 -----------------------------------------------------------------------*/ 4415 void SwXAutoStyle::setPropertiesToDefault( 4416 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/ ) 4417 throw (beans::UnknownPropertyException, uno::RuntimeException) 4418 { 4419 } 4420 4421 /*-- 19.05.2006 11:24:14--------------------------------------------------- 4422 4423 -----------------------------------------------------------------------*/ 4424 uno::Sequence< uno::Any > SwXAutoStyle::getPropertyDefaults( 4425 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/ ) 4426 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 4427 uno::RuntimeException) 4428 { 4429 uno::Sequence< uno::Any > aRet(0); 4430 return aRet; 4431 } 4432 4433 /*-- 19.05.2006 11:24:14--------------------------------------------------- 4434 4435 -----------------------------------------------------------------------*/ 4436 uno::Sequence< beans::PropertyValue > SwXAutoStyle::getProperties() throw (uno::RuntimeException) 4437 { 4438 if( !pSet.get() ) 4439 throw uno::RuntimeException(); 4440 vos::OGuard aGuard(Application::GetSolarMutex()); 4441 std::vector< beans::PropertyValue > aPropertyVector; 4442 4443 sal_Int8 nPropSetId = 0; 4444 switch(eFamily) 4445 { 4446 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break; 4447 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break; 4448 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break; 4449 default: 4450 ; 4451 } 4452 4453 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); 4454 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap(); 4455 PropertyEntryVector_t aPropVector = pMap->getPropertyEntries(); 4456 // struct compareWhichIds 4457 // { 4458 // bool operator()(const sal_uInt16 w1, const sal_uInt16 w2) const 4459 // { 4460 // return w1 < w2; 4461 // } 4462 // }; 4463 // typedef std::map<const sal_uInt16, SfxItemPropertyNamedEntry, compareWhichIds> PropertyMap_t; 4464 // PropertyMap_t aPropMap; 4465 // aPropMap.reserve( aPropVector.size() ); 4466 // PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin(); 4467 // while( aIt != aPropertyEntries.end() ) 4468 // { 4469 // aPropMap[aIt->nWID] = *aIt; 4470 // ++aIt; 4471 // } 4472 4473 SfxItemSet& rSet = *pSet.get(); 4474 SfxItemIter aIter(rSet); 4475 const SfxPoolItem* pItem = aIter.FirstItem(); 4476 4477 while ( pItem ) 4478 { 4479 const sal_uInt16 nWID = pItem->Which(); 4480 4481 // PropertyMap_t::const_iterator aMapIt = aPropMap[nWID]; 4482 // if( aMapIt != aPropMap.getEnd() ) 4483 // { 4484 // beans::PropertyValue aPropertyValue; 4485 // aPropertyValue.Name = aIt->sName; 4486 // pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId ); 4487 // aPropertyVector.push_back( aPropertyValue ); 4488 // } 4489 // TODO: Optimize - and fix! the old iteration filled each WhichId 4490 // only once but there are more properties than WhichIds 4491 PropertyEntryVector_t::const_iterator aIt = aPropVector.begin(); 4492 while( aIt != aPropVector.end() ) 4493 { 4494 if ( aIt->nWID == nWID ) 4495 { 4496 beans::PropertyValue aPropertyValue; 4497 aPropertyValue.Name = aIt->sName; 4498 pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId ); 4499 aPropertyVector.push_back( aPropertyValue ); 4500 } 4501 ++aIt; 4502 } 4503 /* int i = 0; 4504 while ( pMap[i].nWID != 0 ) 4505 { 4506 if ( pMap[i].nWID == nWID ) 4507 { 4508 beans::PropertyValue aPropertyValue; 4509 String sString( OUString::createFromAscii( pMap[i].pName ) ); 4510 aPropertyValue.Name = sString; 4511 pItem->QueryValue( aPropertyValue.Value, pMap[i].nMemberId ); 4512 aPropertyVector.push_back( aPropertyValue ); 4513 break; 4514 } 4515 ++i; 4516 }*/ 4517 pItem = aIter.NextItem(); 4518 } 4519 4520 const sal_Int32 nCount = aPropertyVector.size(); 4521 uno::Sequence< beans::PropertyValue > aRet( nCount ); 4522 beans::PropertyValue* pProps = aRet.getArray(); 4523 4524 for ( int i = 0; i < nCount; ++i, pProps++ ) 4525 { 4526 *pProps = aPropertyVector[i]; 4527 } 4528 4529 return aRet; 4530 } 4531