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