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