1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 #include <com/sun/star/beans/PropertyAttribute.hpp> 32 #include <com/sun/star/text/SectionFileLink.hpp> 33 34 #include <cmdid.h> 35 #include <hintids.hxx> 36 #include <svl/urihelper.hxx> 37 #include <editeng/brshitem.hxx> 38 #include <editeng/xmlcnitm.hxx> 39 #include <sfx2/linkmgr.hxx> 40 #include <sfx2/lnkbase.hxx> 41 #include <vos/mutex.hxx> 42 #include <vcl/svapp.hxx> 43 #include <fmtclds.hxx> 44 #include <unotextrange.hxx> 45 #include <unosection.hxx> 46 #include <TextCursorHelper.hxx> 47 #include <unoredline.hxx> 48 #include <redline.hxx> 49 #include <unomap.hxx> 50 #include <unocrsr.hxx> 51 #include <section.hxx> 52 #include <doc.hxx> 53 #include <IDocumentUndoRedo.hxx> 54 #include <docsh.hxx> 55 #include <sfx2/docfile.hxx> 56 #include <docary.hxx> 57 #include <swundo.hxx> 58 #include <hints.hxx> 59 #include <tox.hxx> 60 #include <unoidx.hxx> 61 #include <doctxm.hxx> 62 #include <fmtftntx.hxx> 63 #include <fmtclbl.hxx> 64 #include <com/sun/star/beans/PropertyAttribute.hpp> 65 #include <editeng/frmdiritem.hxx> 66 #include <fmtcntnt.hxx> 67 /* #109700# */ 68 #include <editeng/lrspitem.hxx> 69 70 71 using namespace ::com::sun::star; 72 using ::rtl::OUString; 73 74 75 /****************************************************************** 76 * 77 ******************************************************************/ 78 struct SwTextSectionProperties_Impl 79 { 80 uno::Sequence<sal_Int8> m_Password; 81 ::rtl::OUString m_sCondition; 82 ::rtl::OUString m_sLinkFileName; 83 ::rtl::OUString m_sSectionFilter; 84 ::rtl::OUString m_sSectionRegion; 85 86 ::std::auto_ptr<SwFmtCol> m_pColItem; 87 ::std::auto_ptr<SvxBrushItem> m_pBrushItem; 88 ::std::auto_ptr<SwFmtFtnAtTxtEnd> m_pFtnItem; 89 ::std::auto_ptr<SwFmtEndAtTxtEnd> m_pEndItem; 90 ::std::auto_ptr<SvXMLAttrContainerItem> m_pXMLAttr; 91 ::std::auto_ptr<SwFmtNoBalancedColumns> m_pNoBalanceItem; 92 ::std::auto_ptr<SvxFrameDirectionItem> m_pFrameDirItem; 93 ::std::auto_ptr<SvxLRSpaceItem> m_pLRSpaceItem; // #109700# 94 95 bool m_bDDE; 96 bool m_bHidden; 97 bool m_bCondHidden; 98 bool m_bProtect; 99 // --> FME 2004-06-22 #114856# edit in readonly sections 100 bool m_bEditInReadonly; 101 // <-- 102 bool m_bUpdateType; 103 104 SwTextSectionProperties_Impl() 105 : m_bDDE(false) 106 , m_bHidden(false) 107 , m_bCondHidden(false) 108 , m_bProtect(false) 109 // --> FME 2004-06-22 #114856# edit in readonly sections 110 , m_bEditInReadonly(false) 111 // <-- 112 , m_bUpdateType(true) 113 { 114 } 115 116 }; 117 118 119 class SwXTextSection::Impl 120 : public SwClient 121 { 122 123 public: 124 125 SwXTextSection & m_rThis; 126 const SfxItemPropertySet & m_rPropSet; 127 SwEventListenerContainer m_ListenerContainer; 128 const bool m_bIndexHeader; 129 bool m_bIsDescriptor; 130 ::rtl::OUString m_sName; 131 ::std::auto_ptr<SwTextSectionProperties_Impl> m_pProps; 132 133 Impl( SwXTextSection & rThis, 134 SwSectionFmt *const pFmt, const bool bIndexHeader) 135 : SwClient(pFmt) 136 , m_rThis(rThis) 137 , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_SECTION)) 138 , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) 139 , m_bIndexHeader(bIndexHeader) 140 // #i111177# unxsols4 (Sun C++ 5.9 SunOS_sparc) may generate wrong code 141 , m_bIsDescriptor((0 == pFmt) ? true : false) 142 , m_pProps((pFmt) ? 0 : new SwTextSectionProperties_Impl()) 143 { 144 } 145 146 SwSectionFmt * GetSectionFmt() const 147 { 148 return static_cast<SwSectionFmt*>(const_cast<SwModify*>( 149 GetRegisteredIn())); 150 } 151 152 SwSectionFmt & GetSectionFmtOrThrow() const { 153 SwSectionFmt *const pFmt( GetSectionFmt() ); 154 if (!pFmt) { 155 throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( 156 "SwXTextSection: disposed or invalid")), 0); 157 } 158 return *pFmt; 159 } 160 161 void SAL_CALL SetPropertyValues_Impl( 162 const uno::Sequence< ::rtl::OUString >& rPropertyNames, 163 const uno::Sequence< uno::Any >& aValues) 164 throw (beans::UnknownPropertyException, beans::PropertyVetoException, 165 lang::IllegalArgumentException, lang::WrappedTargetException, 166 uno::RuntimeException); 167 uno::Sequence< uno::Any > SAL_CALL 168 GetPropertyValues_Impl( 169 const uno::Sequence< ::rtl::OUString >& rPropertyNames) 170 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 171 uno::RuntimeException); 172 protected: 173 // SwClient 174 virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew); 175 176 }; 177 178 /*-- 10.12.98 14:42:52--------------------------------------------------- 179 180 -----------------------------------------------------------------------*/ 181 void SwXTextSection::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew) 182 { 183 ClientModify(this, pOld, pNew); 184 if (!GetRegisteredIn()) 185 { 186 m_ListenerContainer.Disposing(); 187 } 188 } 189 190 /*-- 20.12.2005 10:27:33--------------------------------------------------- 191 192 -----------------------------------------------------------------------*/ 193 SwSectionFmt * SwXTextSection::GetFmt() const 194 { 195 return m_pImpl->GetSectionFmt(); 196 } 197 198 /*-- 20.12.2005 09:56:36--------------------------------------------------- 199 200 -----------------------------------------------------------------------*/ 201 uno::Reference< text::XTextSection > 202 SwXTextSection::CreateXTextSection( 203 SwSectionFmt *const pFmt, const bool bIndexHeader) 204 { 205 // re-use existing SwXTextSection 206 // #i105557#: do not iterate over the registered clients: race condition 207 uno::Reference< text::XTextSection > xSection; 208 if (pFmt) 209 { 210 xSection.set(pFmt->GetXTextSection()); 211 } 212 if ( !xSection.is() ) 213 { 214 SwXTextSection *const pNew = new SwXTextSection(pFmt, bIndexHeader); 215 xSection.set(pNew); 216 if (pFmt) 217 { 218 pFmt->SetXTextSection(xSection); 219 } 220 } 221 return xSection; 222 } 223 224 /*-- 10.12.98 14:47:05--------------------------------------------------- 225 226 -----------------------------------------------------------------------*/ 227 SwXTextSection::SwXTextSection( 228 SwSectionFmt *const pFmt, const bool bIndexHeader) 229 : m_pImpl( new SwXTextSection::Impl(*this, pFmt, bIndexHeader) ) 230 { 231 } 232 233 /*-- 10.12.98 14:47:07--------------------------------------------------- 234 235 -----------------------------------------------------------------------*/ 236 SwXTextSection::~SwXTextSection() 237 { 238 } 239 240 /* -----------------------------13.03.00 12:15-------------------------------- 241 242 ---------------------------------------------------------------------------*/ 243 const uno::Sequence< sal_Int8 > & SwXTextSection::getUnoTunnelId() 244 { 245 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); 246 return aSeq; 247 } 248 /* -----------------------------10.03.00 18:04-------------------------------- 249 250 ---------------------------------------------------------------------------*/ 251 sal_Int64 SAL_CALL 252 SwXTextSection::getSomething(const uno::Sequence< sal_Int8 >& rId) 253 throw (uno::RuntimeException) 254 { 255 return ::sw::UnoTunnelImpl<SwXTextSection>(rId, this); 256 } 257 258 /*-- 10.12.98 14:47:08--------------------------------------------------- 259 260 -----------------------------------------------------------------------*/ 261 uno::Reference< text::XTextSection > SAL_CALL 262 SwXTextSection::getParentSection() throw (uno::RuntimeException) 263 { 264 vos::OGuard aGuard(Application::GetSolarMutex()); 265 266 SwSectionFmt & rSectionFmt( m_pImpl->GetSectionFmtOrThrow() ); 267 268 SwSectionFmt *const pParentFmt = rSectionFmt.GetParent(); 269 const uno::Reference< text::XTextSection > xRet = 270 (pParentFmt) ? CreateXTextSection(pParentFmt) : 0; 271 return xRet; 272 } 273 274 /*-- 10.12.98 14:47:08--------------------------------------------------- 275 276 -----------------------------------------------------------------------*/ 277 uno::Sequence< uno::Reference< text::XTextSection > > SAL_CALL 278 SwXTextSection::getChildSections() throw (uno::RuntimeException) 279 { 280 vos::OGuard aGuard(Application::GetSolarMutex()); 281 282 SwSectionFmt & rSectionFmt( m_pImpl->GetSectionFmtOrThrow() ); 283 284 SwSections aChildren; 285 rSectionFmt.GetChildSections(aChildren, SORTSECT_NOT, sal_False); 286 uno::Sequence<uno::Reference<text::XTextSection> > aSeq(aChildren.Count()); 287 uno::Reference< text::XTextSection > * pArray = aSeq.getArray(); 288 for (sal_uInt16 i = 0; i < aChildren.Count(); i++) 289 { 290 SwSectionFmt *const pChild = aChildren.GetObject(i)->GetFmt(); 291 pArray[i] = CreateXTextSection(pChild); 292 } 293 return aSeq; 294 } 295 296 /* -----------------18.02.99 13:31------------------- 297 * 298 * --------------------------------------------------*/ 299 void SAL_CALL 300 SwXTextSection::attach(const uno::Reference< text::XTextRange > & xTextRange) 301 throw (lang::IllegalArgumentException, uno::RuntimeException) 302 { 303 vos::OGuard g(Application::GetSolarMutex()); 304 305 if (!m_pImpl->m_bIsDescriptor) 306 { 307 throw uno::RuntimeException(); 308 } 309 310 uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); 311 SwXTextRange* pRange = 0; 312 OTextCursorHelper* pCursor = 0; 313 if(xRangeTunnel.is()) 314 { 315 pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel); 316 pCursor = 317 ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel); 318 } 319 320 SwDoc *const pDoc = 321 (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); 322 if (!pDoc) 323 { 324 throw lang::IllegalArgumentException(); 325 } 326 327 SwUnoInternalPaM aPam(*pDoc); 328 //das muss jetzt sal_True liefern 329 ::sw::XTextRangeToSwPaM(aPam, xTextRange); 330 UnoActionContext aCont(pDoc); 331 pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_INSSECTION, NULL ); 332 333 if (!m_pImpl->m_sName.getLength()) 334 { 335 m_pImpl->m_sName = C2U("TextSection"); 336 } 337 SectionType eType = (m_pImpl->m_pProps->m_bDDE) 338 ? DDE_LINK_SECTION 339 : ((m_pImpl->m_pProps->m_sLinkFileName.getLength() || 340 m_pImpl->m_pProps->m_sSectionRegion.getLength()) 341 ? FILE_LINK_SECTION : CONTENT_SECTION); 342 // index header section? 343 if (m_pImpl->m_bIndexHeader) 344 { 345 // caller wants an index header section, but will only 346 // give him one if a) we are inside an index, and b) said 347 // index doesn't yet have a header section. 348 const SwTOXBase* pBase = aPam.GetDoc()->GetCurTOX(*aPam.Start()); 349 350 // are we inside an index? 351 if (pBase) 352 { 353 // get all child sections 354 SwSections aSectionsArr; 355 static_cast<const SwTOXBaseSection*>(pBase)->GetFmt()-> 356 GetChildSections(aSectionsArr); 357 358 // and search for current header section 359 const sal_uInt16 nCount = aSectionsArr.Count(); 360 sal_Bool bHeaderPresent = sal_False; 361 for(sal_uInt16 i = 0; i < nCount; i++) 362 { 363 bHeaderPresent |= 364 (aSectionsArr[i]->GetType() == TOX_HEADER_SECTION); 365 } 366 if (! bHeaderPresent) 367 { 368 eType = TOX_HEADER_SECTION; 369 } 370 } 371 } 372 373 String tmp(m_pImpl->m_sName); 374 SwSectionData aSect(eType, pDoc->GetUniqueSectionName(&tmp)); 375 aSect.SetCondition(m_pImpl->m_pProps->m_sCondition); 376 ::rtl::OUStringBuffer sLinkNameBuf(m_pImpl->m_pProps->m_sLinkFileName); 377 sLinkNameBuf.append(sfx2::cTokenSeperator); 378 sLinkNameBuf.append(m_pImpl->m_pProps->m_sSectionFilter); 379 sLinkNameBuf.append(sfx2::cTokenSeperator); 380 sLinkNameBuf.append(m_pImpl->m_pProps->m_sSectionRegion); 381 aSect.SetLinkFileName(sLinkNameBuf.makeStringAndClear()); 382 383 aSect.SetHidden(m_pImpl->m_pProps->m_bHidden); 384 aSect.SetProtectFlag(m_pImpl->m_pProps->m_bProtect); 385 // --> FME 2004-06-22 #114856# edit in readonly sections 386 aSect.SetEditInReadonlyFlag(m_pImpl->m_pProps->m_bEditInReadonly); 387 // <-- 388 389 SfxItemSet aSet(pDoc->GetAttrPool(), 390 RES_COL, RES_COL, 391 RES_BACKGROUND, RES_BACKGROUND, 392 RES_FTN_AT_TXTEND, RES_FRAMEDIR, 393 RES_LR_SPACE, RES_LR_SPACE, // #109700# 394 RES_UNKNOWNATR_CONTAINER,RES_UNKNOWNATR_CONTAINER, 395 0); 396 if (m_pImpl->m_pProps->m_pBrushItem.get()) 397 { 398 aSet.Put(*m_pImpl->m_pProps->m_pBrushItem); 399 } 400 if (m_pImpl->m_pProps->m_pColItem.get()) 401 { 402 aSet.Put(*m_pImpl->m_pProps->m_pColItem); 403 } 404 if (m_pImpl->m_pProps->m_pFtnItem.get()) 405 { 406 aSet.Put(*m_pImpl->m_pProps->m_pFtnItem); 407 } 408 if (m_pImpl->m_pProps->m_pEndItem.get()) 409 { 410 aSet.Put(*m_pImpl->m_pProps->m_pEndItem); 411 } 412 if (m_pImpl->m_pProps->m_pXMLAttr.get()) 413 { 414 aSet.Put(*m_pImpl->m_pProps->m_pXMLAttr); 415 } 416 if (m_pImpl->m_pProps->m_pNoBalanceItem.get()) 417 { 418 aSet.Put(*m_pImpl->m_pProps->m_pNoBalanceItem); 419 } 420 if (m_pImpl->m_pProps->m_pFrameDirItem.get()) 421 { 422 aSet.Put(*m_pImpl->m_pProps->m_pFrameDirItem); 423 } 424 /* #109700# */ 425 if (m_pImpl->m_pProps->m_pLRSpaceItem.get()) 426 { 427 aSet.Put(*m_pImpl->m_pProps->m_pLRSpaceItem); 428 } 429 // section password 430 if (m_pImpl->m_pProps->m_Password.getLength() > 0) 431 { 432 aSect.SetPassword(m_pImpl->m_pProps->m_Password); 433 } 434 435 SwSection *const pRet = 436 pDoc->InsertSwSection( aPam, aSect, 0, aSet.Count() ? &aSet : 0 ); 437 pRet->GetFmt()->Add(m_pImpl.get()); 438 pRet->GetFmt()->SetXObject(static_cast< ::cppu::OWeakObject*>(this)); 439 440 // #97450# XML import must hide sections depending on their old 441 // condition status 442 if (m_pImpl->m_pProps->m_sCondition.getLength() != 0) 443 { 444 pRet->SetCondHidden(m_pImpl->m_pProps->m_bCondHidden); 445 } 446 447 // set update type if DDE link (and connect, if necessary) 448 if (m_pImpl->m_pProps->m_bDDE) 449 { 450 if (! pRet->IsConnected()) 451 { 452 pRet->CreateLink(CREATE_CONNECT); 453 } 454 pRet->SetUpdateType( static_cast< sal_uInt16 >( 455 (m_pImpl->m_pProps->m_bUpdateType) ? 456 sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); 457 } 458 459 // Undo-Klammerung hier beenden 460 pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_INSSECTION, NULL ); 461 m_pImpl->m_pProps.reset(); 462 m_pImpl->m_bIsDescriptor = false; 463 } 464 465 /*-- 10.12.98 14:47:09--------------------------------------------------- 466 467 -----------------------------------------------------------------------*/ 468 uno::Reference< text::XTextRange > SAL_CALL 469 SwXTextSection::getAnchor() throw (uno::RuntimeException) 470 { 471 vos::OGuard aGuard(Application::GetSolarMutex()); 472 473 uno::Reference< text::XTextRange > xRet; 474 SwSectionFmt *const pSectFmt = m_pImpl->GetSectionFmt(); 475 if(pSectFmt) 476 { 477 const SwSection* pSect; 478 const SwNodeIndex* pIdx; 479 if( 0 != ( pSect = pSectFmt->GetSection() ) && 480 0 != ( pIdx = pSectFmt->GetCntnt().GetCntntIdx() ) && 481 pIdx->GetNode().GetNodes().IsDocNodes() ) 482 { 483 SwPaM aPaM(*pIdx); 484 aPaM.Move( fnMoveForward, fnGoCntnt ); 485 486 const SwEndNode* pEndNode = pIdx->GetNode().EndOfSectionNode(); 487 SwPaM aEnd(*pEndNode); 488 aEnd.Move( fnMoveBackward, fnGoCntnt ); 489 xRet = SwXTextRange::CreateXTextRange(*pSectFmt->GetDoc(), 490 *aPaM.Start(), aEnd.Start()); 491 } 492 } 493 return xRet; 494 } 495 /*-- 10.12.98 14:47:09--------------------------------------------------- 496 497 -----------------------------------------------------------------------*/ 498 void SAL_CALL SwXTextSection::dispose() throw (uno::RuntimeException) 499 { 500 vos::OGuard aGuard(Application::GetSolarMutex()); 501 502 SwSectionFmt *const pSectFmt = m_pImpl->GetSectionFmt(); 503 if (pSectFmt) 504 { 505 pSectFmt->GetDoc()->DelSectionFmt( pSectFmt ); 506 } 507 } 508 /*-- 10.12.98 14:47:10--------------------------------------------------- 509 510 -----------------------------------------------------------------------*/ 511 void SAL_CALL SwXTextSection::addEventListener( 512 const uno::Reference< lang::XEventListener > & xListener) 513 throw (uno::RuntimeException) 514 { 515 vos::OGuard g(Application::GetSolarMutex()); 516 517 if (!m_pImpl->GetSectionFmt()) 518 { 519 throw uno::RuntimeException(); 520 } 521 m_pImpl->m_ListenerContainer.AddListener(xListener); 522 } 523 /*-- 10.12.98 14:47:10--------------------------------------------------- 524 525 -----------------------------------------------------------------------*/ 526 void SAL_CALL SwXTextSection::removeEventListener( 527 const uno::Reference< lang::XEventListener > & xListener) 528 throw (uno::RuntimeException) 529 { 530 vos::OGuard g(Application::GetSolarMutex()); 531 532 if (!m_pImpl->GetSectionFmt() || 533 !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) 534 { 535 throw uno::RuntimeException(); 536 } 537 } 538 /*-- 10.12.98 14:47:11--------------------------------------------------- 539 540 -----------------------------------------------------------------------*/ 541 uno::Reference< beans::XPropertySetInfo > SAL_CALL 542 SwXTextSection::getPropertySetInfo() throw (uno::RuntimeException) 543 { 544 vos::OGuard g(Application::GetSolarMutex()); 545 546 static const uno::Reference< beans::XPropertySetInfo > aRef = 547 m_pImpl->m_rPropSet.getPropertySetInfo(); 548 return aRef; 549 } 550 551 /* -----------------------------12.02.01 10:45-------------------------------- 552 553 ---------------------------------------------------------------------------*/ 554 static void 555 lcl_UpdateLinkType(SwSection & rSection, bool const bLinkUpdateAlways = true) 556 { 557 if (rSection.GetType() == DDE_LINK_SECTION) 558 { 559 // set update type; needs an established link 560 if (!rSection.IsConnected()) 561 { 562 rSection.CreateLink(CREATE_CONNECT); 563 } 564 rSection.SetUpdateType( static_cast< sal_uInt16 >((bLinkUpdateAlways) 565 ? sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); 566 } 567 } 568 569 static void 570 lcl_UpdateSection(SwSectionFmt *const pFmt, 571 ::std::auto_ptr<SwSectionData> const& pSectionData, 572 ::std::auto_ptr<SfxItemSet> const& pItemSet, 573 bool const bLinkModeChanged, bool const bLinkUpdateAlways = true) 574 { 575 if (pFmt) 576 { 577 SwSection & rSection = *pFmt->GetSection(); 578 SwDoc *const pDoc = pFmt->GetDoc(); 579 SwSectionFmts const& rFmts = pDoc->GetSections(); 580 UnoActionContext aContext(pDoc); 581 for (sal_uInt16 i = 0; i < rFmts.Count(); i++) 582 { 583 if (rFmts[i]->GetSection()->GetSectionName() 584 == rSection.GetSectionName()) 585 { 586 pDoc->UpdateSection(i, *pSectionData, pItemSet.get(), 587 pDoc->IsInReading()); 588 { 589 // temporarily remove actions to allow cursor update 590 UnoActionRemoveContext aRemoveContext( pDoc ); 591 } 592 593 if (bLinkModeChanged) 594 { 595 lcl_UpdateLinkType(rSection, bLinkUpdateAlways); 596 } 597 // section found and processed: break from loop 598 break; 599 } 600 } 601 } 602 } 603 604 void SwXTextSection::Impl::SetPropertyValues_Impl( 605 const uno::Sequence< OUString >& rPropertyNames, 606 const uno::Sequence< uno::Any >& rValues) 607 throw (beans::UnknownPropertyException, beans::PropertyVetoException, 608 lang::IllegalArgumentException, lang::WrappedTargetException, 609 uno::RuntimeException) 610 { 611 if(rPropertyNames.getLength() != rValues.getLength()) 612 { 613 throw lang::IllegalArgumentException(); 614 } 615 SwSectionFmt *const pFmt = GetSectionFmt(); 616 if (!pFmt && !m_bIsDescriptor) 617 { 618 throw uno::RuntimeException(); 619 } 620 621 ::std::auto_ptr<SwSectionData> const pSectionData( 622 (pFmt) ? new SwSectionData(*pFmt->GetSection()) : 0); 623 624 OUString const*const pPropertyNames = rPropertyNames.getConstArray(); 625 uno::Any const*const pValues = rValues.getConstArray(); 626 ::std::auto_ptr<SfxItemSet> pItemSet; 627 sal_Bool bLinkModeChanged = sal_False; 628 sal_Bool bLinkMode = sal_False; 629 630 for (sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength(); 631 nProperty++) 632 { 633 SfxItemPropertySimpleEntry const*const pEntry = 634 m_rPropSet.getPropertyMap()->getByName(pPropertyNames[nProperty]); 635 if (!pEntry) 636 { 637 throw beans::UnknownPropertyException( 638 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 639 + pPropertyNames[nProperty], 640 static_cast<cppu::OWeakObject *>(& m_rThis)); 641 } 642 if (pEntry->nFlags & beans::PropertyAttribute::READONLY) 643 { 644 throw beans::PropertyVetoException( 645 OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) 646 + pPropertyNames[nProperty], 647 static_cast<cppu::OWeakObject *>(& m_rThis)); 648 } 649 switch (pEntry->nWID) 650 { 651 case WID_SECT_CONDITION: 652 { 653 OUString uTmp; 654 pValues[nProperty] >>= uTmp; 655 if (m_bIsDescriptor) 656 { 657 m_pProps->m_sCondition = uTmp; 658 } 659 else 660 { 661 pSectionData->SetCondition(uTmp); 662 } 663 } 664 break; 665 case WID_SECT_DDE_TYPE: 666 case WID_SECT_DDE_FILE: 667 case WID_SECT_DDE_ELEMENT: 668 { 669 OUString uTmp; 670 pValues[nProperty] >>= uTmp; 671 String sTmp(uTmp); 672 if (m_bIsDescriptor) 673 { 674 if (!m_pProps->m_bDDE) 675 { 676 ::rtl::OUStringBuffer buf; 677 buf.append(sfx2::cTokenSeperator); 678 buf.append(sfx2::cTokenSeperator); 679 m_pProps->m_sLinkFileName = buf.makeStringAndClear(); 680 m_pProps->m_bDDE = true; 681 } 682 String sLinkFileName(m_pProps->m_sLinkFileName); 683 sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE, 684 sfx2::cTokenSeperator, sTmp); 685 m_pProps->m_sLinkFileName = sLinkFileName; 686 } 687 else 688 { 689 String sLinkFileName(pSectionData->GetLinkFileName()); 690 if (pSectionData->GetType() != DDE_LINK_SECTION) 691 { 692 sLinkFileName = sfx2::cTokenSeperator; 693 sLinkFileName += sfx2::cTokenSeperator; 694 pSectionData->SetType(DDE_LINK_SECTION); 695 } 696 sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE, 697 sfx2::cTokenSeperator, sTmp); 698 pSectionData->SetLinkFileName(sLinkFileName); 699 } 700 } 701 break; 702 case WID_SECT_DDE_AUTOUPDATE: 703 { 704 sal_Bool bVal(sal_False); 705 if (!(pValues[nProperty] >>= bVal)) 706 { 707 throw lang::IllegalArgumentException(); 708 } 709 if (m_bIsDescriptor) 710 { 711 m_pProps->m_bUpdateType = bVal; 712 } 713 else 714 { 715 bLinkModeChanged = sal_True; 716 bLinkMode = bVal; 717 } 718 } 719 break; 720 case WID_SECT_LINK: 721 { 722 text::SectionFileLink aLink; 723 if (!(pValues[nProperty] >>= aLink)) 724 { 725 throw lang::IllegalArgumentException(); 726 } 727 if (m_bIsDescriptor) 728 { 729 m_pProps->m_bDDE = sal_False; 730 m_pProps->m_sLinkFileName = aLink.FileURL; 731 m_pProps->m_sSectionFilter = aLink.FilterName; 732 } 733 else 734 { 735 if (pSectionData->GetType() != FILE_LINK_SECTION && 736 aLink.FileURL.getLength()) 737 { 738 pSectionData->SetType(FILE_LINK_SECTION); 739 } 740 ::rtl::OUStringBuffer sFileNameBuf; 741 if (aLink.FileURL.getLength()) 742 { 743 sFileNameBuf.append( URIHelper::SmartRel2Abs( 744 pFmt->GetDoc()->GetDocShell()->GetMedium() 745 ->GetURLObject(), 746 aLink.FileURL, URIHelper::GetMaybeFileHdl())); 747 } 748 sFileNameBuf.append(sfx2::cTokenSeperator); 749 sFileNameBuf.append(aLink.FilterName); 750 sFileNameBuf.append(sfx2::cTokenSeperator); 751 sFileNameBuf.append( 752 pSectionData->GetLinkFileName().GetToken(2, 753 sfx2::cTokenSeperator)); 754 const ::rtl::OUString sFileName( 755 sFileNameBuf.makeStringAndClear()); 756 pSectionData->SetLinkFileName(sFileName); 757 if (sFileName.getLength() < 3) 758 { 759 pSectionData->SetType(CONTENT_SECTION); 760 } 761 } 762 } 763 break; 764 case WID_SECT_REGION: 765 { 766 OUString sLink; 767 pValues[nProperty] >>= sLink; 768 if (m_bIsDescriptor) 769 { 770 m_pProps->m_bDDE = sal_False; 771 m_pProps->m_sSectionRegion = sLink; 772 } 773 else 774 { 775 if (pSectionData->GetType() != FILE_LINK_SECTION && 776 sLink.getLength()) 777 { 778 pSectionData->SetType(FILE_LINK_SECTION); 779 } 780 String sSectLink(pSectionData->GetLinkFileName()); 781 while (3 < sSectLink.GetTokenCount(sfx2::cTokenSeperator)) 782 { 783 sSectLink += sfx2::cTokenSeperator; 784 } 785 sSectLink.SetToken(2, sfx2::cTokenSeperator, sLink); 786 pSectionData->SetLinkFileName(sSectLink); 787 if (sSectLink.Len() < 3) 788 { 789 pSectionData->SetType(CONTENT_SECTION); 790 } 791 } 792 } 793 break; 794 case WID_SECT_VISIBLE: 795 { 796 sal_Bool bVal(sal_False); 797 if (!(pValues[nProperty] >>= bVal)) 798 { 799 throw lang::IllegalArgumentException(); 800 } 801 if (m_bIsDescriptor) 802 { 803 m_pProps->m_bHidden = !bVal; 804 } 805 else 806 { 807 pSectionData->SetHidden(!bVal); 808 } 809 } 810 break; 811 case WID_SECT_CURRENTLY_VISIBLE: 812 { 813 sal_Bool bVal(sal_False); 814 if (!(pValues[nProperty] >>= bVal)) 815 { 816 throw lang::IllegalArgumentException(); 817 } 818 if (m_bIsDescriptor) 819 { 820 m_pProps->m_bCondHidden = !bVal; 821 } 822 else 823 { 824 if (pSectionData->GetCondition().Len() != 0) 825 { 826 pSectionData->SetCondHidden(!bVal); 827 } 828 } 829 } 830 break; 831 case WID_SECT_PROTECTED: 832 { 833 sal_Bool bVal(sal_False); 834 if (!(pValues[nProperty] >>= bVal)) 835 { 836 throw lang::IllegalArgumentException(); 837 } 838 if (m_bIsDescriptor) 839 { 840 m_pProps->m_bProtect = bVal; 841 } 842 else 843 { 844 pSectionData->SetProtectFlag(bVal); 845 } 846 } 847 break; 848 // --> FME 2004-06-22 #114856# edit in readonly sections 849 case WID_SECT_EDIT_IN_READONLY: 850 { 851 sal_Bool bVal(sal_False); 852 if (!(pValues[nProperty] >>= bVal)) 853 { 854 throw lang::IllegalArgumentException(); 855 } 856 if (m_bIsDescriptor) 857 { 858 m_pProps->m_bEditInReadonly = bVal; 859 } 860 else 861 { 862 pSectionData->SetEditInReadonlyFlag(bVal); 863 } 864 } 865 // <-- 866 break; 867 case WID_SECT_PASSWORD: 868 { 869 uno::Sequence<sal_Int8> aSeq; 870 pValues[nProperty] >>= aSeq; 871 if (m_bIsDescriptor) 872 { 873 m_pProps->m_Password = aSeq; 874 } 875 else 876 { 877 pSectionData->SetPassword(aSeq); 878 } 879 } 880 break; 881 default: 882 { 883 if (pFmt) 884 { 885 const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); 886 pItemSet.reset( new SfxItemSet(*rOldAttrSet.GetPool(), 887 pEntry->nWID, pEntry->nWID, 0)); 888 pItemSet->Put(rOldAttrSet); 889 m_rPropSet.setPropertyValue(*pEntry, 890 pValues[nProperty], *pItemSet); 891 } 892 else 893 { 894 SfxPoolItem* pPutItem = 0; 895 if (RES_COL == pEntry->nWID) 896 { 897 if (!m_pProps->m_pColItem.get()) 898 { 899 m_pProps->m_pColItem.reset(new SwFmtCol); 900 } 901 pPutItem = m_pProps->m_pColItem.get(); 902 } 903 else if (RES_BACKGROUND == pEntry->nWID) 904 { 905 if (!m_pProps->m_pBrushItem.get()) 906 { 907 m_pProps->m_pBrushItem.reset( 908 new SvxBrushItem(RES_BACKGROUND)); 909 } 910 pPutItem = m_pProps->m_pBrushItem.get(); 911 } 912 else if (RES_FTN_AT_TXTEND == pEntry->nWID) 913 { 914 if (!m_pProps->m_pFtnItem.get()) 915 { 916 m_pProps->m_pFtnItem.reset(new SwFmtFtnAtTxtEnd); 917 } 918 pPutItem = m_pProps->m_pFtnItem.get(); 919 } 920 else if (RES_END_AT_TXTEND == pEntry->nWID) 921 { 922 if (!m_pProps->m_pEndItem.get()) 923 { 924 m_pProps->m_pEndItem.reset(new SwFmtEndAtTxtEnd); 925 } 926 pPutItem = m_pProps->m_pEndItem.get(); 927 } 928 else if (RES_UNKNOWNATR_CONTAINER== pEntry->nWID) 929 { 930 if (!m_pProps->m_pXMLAttr.get()) 931 { 932 m_pProps->m_pXMLAttr.reset( 933 new SvXMLAttrContainerItem( 934 RES_UNKNOWNATR_CONTAINER)); 935 } 936 pPutItem = m_pProps->m_pXMLAttr.get(); 937 } 938 else if (RES_COLUMNBALANCE== pEntry->nWID) 939 { 940 if (!m_pProps->m_pNoBalanceItem.get()) 941 { 942 m_pProps->m_pNoBalanceItem.reset( 943 new SwFmtNoBalancedColumns(RES_COLUMNBALANCE)); 944 } 945 pPutItem = m_pProps->m_pNoBalanceItem.get(); 946 } 947 else if (RES_FRAMEDIR == pEntry->nWID) 948 { 949 if (!m_pProps->m_pFrameDirItem.get()) 950 { 951 m_pProps->m_pFrameDirItem.reset( 952 new SvxFrameDirectionItem( 953 FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR)); 954 } 955 pPutItem = m_pProps->m_pFrameDirItem.get(); 956 } 957 else if (RES_LR_SPACE == pEntry->nWID) 958 { 959 // #109700# 960 if (!m_pProps->m_pLRSpaceItem.get()) 961 { 962 m_pProps->m_pLRSpaceItem.reset( 963 new SvxLRSpaceItem( RES_LR_SPACE )); 964 } 965 pPutItem = m_pProps->m_pLRSpaceItem.get(); 966 } 967 if (pPutItem) 968 { 969 pPutItem->PutValue(pValues[nProperty], 970 pEntry->nMemberId); 971 } 972 } 973 } 974 } 975 } 976 977 lcl_UpdateSection(pFmt, pSectionData, pItemSet, bLinkModeChanged, 978 bLinkMode); 979 } 980 981 void SAL_CALL 982 SwXTextSection::setPropertyValues( 983 const uno::Sequence< ::rtl::OUString >& rPropertyNames, 984 const uno::Sequence< uno::Any >& rValues) 985 throw (beans::PropertyVetoException, lang::IllegalArgumentException, 986 lang::WrappedTargetException, uno::RuntimeException) 987 { 988 vos::OGuard aGuard(Application::GetSolarMutex()); 989 990 // workaround for bad designed API 991 try 992 { 993 m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues ); 994 } 995 catch (beans::UnknownPropertyException &rException) 996 { 997 // wrap the original (here not allowed) exception in 998 // a WrappedTargetException that gets thrown instead. 999 lang::WrappedTargetException aWExc; 1000 aWExc.TargetException <<= rException; 1001 throw aWExc; 1002 } 1003 } 1004 /*-- 10.12.98 14:47:11--------------------------------------------------- 1005 1006 -----------------------------------------------------------------------*/ 1007 void SwXTextSection::setPropertyValue( 1008 const OUString& rPropertyName, const uno::Any& rValue) 1009 throw (beans::UnknownPropertyException, beans::PropertyVetoException, 1010 lang::IllegalArgumentException, lang::WrappedTargetException, 1011 uno::RuntimeException ) 1012 { 1013 vos::OGuard aGuard(Application::GetSolarMutex()); 1014 1015 uno::Sequence< ::rtl::OUString > aPropertyNames(1); 1016 aPropertyNames.getArray()[0] = rPropertyName; 1017 uno::Sequence< uno::Any > aValues(1); 1018 aValues.getArray()[0] = rValue; 1019 m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues ); 1020 } 1021 1022 /* -----------------------------12.02.01 10:43-------------------------------- 1023 1024 ---------------------------------------------------------------------------*/ 1025 uno::Sequence< uno::Any > 1026 SwXTextSection::Impl::GetPropertyValues_Impl( 1027 const uno::Sequence< OUString > & rPropertyNames ) 1028 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1029 uno::RuntimeException) 1030 { 1031 SwSectionFmt *const pFmt = GetSectionFmt(); 1032 if (!pFmt && !m_bIsDescriptor) 1033 { 1034 throw uno::RuntimeException(); 1035 } 1036 1037 uno::Sequence< uno::Any > aRet(rPropertyNames.getLength()); 1038 uno::Any* pRet = aRet.getArray(); 1039 SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0; 1040 const OUString* pPropertyNames = rPropertyNames.getConstArray(); 1041 1042 for (sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength(); 1043 nProperty++) 1044 { 1045 SfxItemPropertySimpleEntry const*const pEntry = 1046 m_rPropSet.getPropertyMap()->getByName(pPropertyNames[nProperty]); 1047 if (!pEntry) 1048 { 1049 throw beans::UnknownPropertyException( 1050 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 1051 + pPropertyNames[nProperty], 1052 static_cast<cppu::OWeakObject *>(& m_rThis)); 1053 } 1054 switch(pEntry->nWID) 1055 { 1056 case WID_SECT_CONDITION: 1057 { 1058 OUString uTmp( (m_bIsDescriptor) 1059 ? m_pProps->m_sCondition 1060 : ::rtl::OUString(pSect->GetCondition())); 1061 pRet[nProperty] <<= uTmp; 1062 } 1063 break; 1064 case WID_SECT_DDE_TYPE: 1065 case WID_SECT_DDE_FILE: 1066 case WID_SECT_DDE_ELEMENT: 1067 { 1068 ::rtl::OUString sRet; 1069 if (m_bIsDescriptor) 1070 { 1071 if (m_pProps->m_bDDE) 1072 { 1073 sRet = m_pProps->m_sLinkFileName; 1074 } 1075 } 1076 else if (DDE_LINK_SECTION == pSect->GetType()) 1077 { 1078 sRet = pSect->GetLinkFileName(); 1079 } 1080 sal_Int32 nDummy(0); 1081 sRet = sRet.getToken(pEntry->nWID - WID_SECT_DDE_TYPE, 1082 sfx2::cTokenSeperator, nDummy); 1083 pRet[nProperty] <<= sRet; 1084 } 1085 break; 1086 case WID_SECT_DDE_AUTOUPDATE: 1087 { 1088 // GetUpdateType() returns .._ALWAYS or .._ONCALL 1089 if (pSect && pSect->IsLinkType() && pSect->IsConnected()) // lijian i73247 1090 { 1091 const sal_Bool bTemp = 1092 (pSect->GetUpdateType() == sfx2::LINKUPDATE_ALWAYS); 1093 pRet[nProperty] <<= bTemp; 1094 } 1095 } 1096 break; 1097 case WID_SECT_LINK : 1098 { 1099 text::SectionFileLink aLink; 1100 if (m_bIsDescriptor) 1101 { 1102 if (!m_pProps->m_bDDE) 1103 { 1104 aLink.FileURL = m_pProps->m_sLinkFileName; 1105 aLink.FilterName = m_pProps->m_sSectionFilter; 1106 } 1107 } 1108 else if (FILE_LINK_SECTION == pSect->GetType()) 1109 { 1110 ::rtl::OUString sRet( pSect->GetLinkFileName() ); 1111 sal_Int32 nIndex(0); 1112 aLink.FileURL = 1113 sRet.getToken(0, sfx2::cTokenSeperator, nIndex); 1114 aLink.FilterName = 1115 sRet.getToken(0, sfx2::cTokenSeperator, nIndex); 1116 } 1117 pRet[nProperty] <<= aLink; 1118 } 1119 break; 1120 case WID_SECT_REGION : 1121 { 1122 ::rtl::OUString sRet; 1123 if (m_bIsDescriptor) 1124 { 1125 sRet = m_pProps->m_sSectionRegion; 1126 } 1127 else if (FILE_LINK_SECTION == pSect->GetType()) 1128 { 1129 sRet = pSect->GetLinkFileName().GetToken(2, 1130 sfx2::cTokenSeperator); 1131 } 1132 pRet[nProperty] <<= sRet; 1133 } 1134 break; 1135 case WID_SECT_VISIBLE : 1136 { 1137 const sal_Bool bTemp = (m_bIsDescriptor) 1138 ? !m_pProps->m_bHidden : !pSect->IsHidden(); 1139 pRet[nProperty] <<= bTemp; 1140 } 1141 break; 1142 case WID_SECT_CURRENTLY_VISIBLE: 1143 { 1144 const sal_Bool bTemp = (m_bIsDescriptor) 1145 ? !m_pProps->m_bCondHidden : !pSect->IsCondHidden(); 1146 pRet[nProperty] <<= bTemp; 1147 } 1148 break; 1149 case WID_SECT_PROTECTED: 1150 { 1151 const sal_Bool bTemp = (m_bIsDescriptor) 1152 ? m_pProps->m_bProtect : pSect->IsProtect(); 1153 pRet[nProperty] <<= bTemp; 1154 } 1155 break; 1156 // --> FME 2004-06-22 #114856# edit in readonly sections 1157 case WID_SECT_EDIT_IN_READONLY: 1158 { 1159 const sal_Bool bTemp = (m_bIsDescriptor) 1160 ? m_pProps->m_bEditInReadonly : pSect->IsEditInReadonly(); 1161 pRet[nProperty] <<= bTemp; 1162 } 1163 break; 1164 // <-- 1165 case FN_PARAM_LINK_DISPLAY_NAME: 1166 { 1167 if (pFmt) 1168 { 1169 pRet[nProperty] <<= 1170 OUString(pFmt->GetSection()->GetSectionName()); 1171 } 1172 } 1173 break; 1174 case WID_SECT_DOCUMENT_INDEX: 1175 { 1176 // search enclosing index 1177 SwSection* pEnclosingSection = pSect; 1178 while ((pEnclosingSection != NULL) && 1179 (TOX_CONTENT_SECTION != pEnclosingSection->GetType())) 1180 { 1181 pEnclosingSection = pEnclosingSection->GetParent(); 1182 } 1183 if (pEnclosingSection) 1184 { 1185 // convert section to TOXBase and get SwXDocumentIndex 1186 SwTOXBaseSection *const pTOXBaseSect = 1187 PTR_CAST(SwTOXBaseSection, pEnclosingSection); 1188 const uno::Reference<text::XDocumentIndex> xIndex = 1189 SwXDocumentIndex::CreateXDocumentIndex( 1190 *pTOXBaseSect->GetFmt()->GetDoc(), *pTOXBaseSect); 1191 pRet[nProperty] <<= xIndex; 1192 } 1193 // else: no enclosing index found -> empty return value 1194 } 1195 break; 1196 case WID_SECT_IS_GLOBAL_DOC_SECTION: 1197 { 1198 const sal_Bool bRet = (NULL == pFmt) ? sal_False : 1199 static_cast<sal_Bool>(NULL != pFmt->GetGlobalDocSection()); 1200 pRet[nProperty] <<= bRet; 1201 } 1202 break; 1203 case FN_UNO_ANCHOR_TYPES: 1204 case FN_UNO_TEXT_WRAP: 1205 case FN_UNO_ANCHOR_TYPE: 1206 ::sw::GetDefaultTextContentValue( 1207 pRet[nProperty], OUString(), pEntry->nWID); 1208 break; 1209 case FN_UNO_REDLINE_NODE_START: 1210 case FN_UNO_REDLINE_NODE_END: 1211 { 1212 if (!pFmt) 1213 break; // lijian i73247 1214 SwNode* pSectNode = pFmt->GetSectionNode(); 1215 if (FN_UNO_REDLINE_NODE_END == pEntry->nWID) 1216 { 1217 pSectNode = pSectNode->EndOfSectionNode(); 1218 } 1219 const SwRedlineTbl& rRedTbl = 1220 pFmt->GetDoc()->GetRedlineTbl(); 1221 for (sal_uInt16 nRed = 0; nRed < rRedTbl.Count(); nRed++) 1222 { 1223 const SwRedline* pRedline = rRedTbl[nRed]; 1224 SwNode const*const pRedPointNode = pRedline->GetNode(sal_True); 1225 SwNode const*const pRedMarkNode = pRedline->GetNode(sal_False); 1226 if ((pRedPointNode == pSectNode) || 1227 (pRedMarkNode == pSectNode)) 1228 { 1229 SwNode const*const pStartOfRedline = 1230 (SwNodeIndex(*pRedPointNode) <= 1231 SwNodeIndex(*pRedMarkNode)) 1232 ? pRedPointNode : pRedMarkNode; 1233 const bool bIsStart = (pStartOfRedline == pSectNode); 1234 pRet[nProperty] <<= 1235 SwXRedlinePortion::CreateRedlineProperties( 1236 *pRedline, bIsStart); 1237 break; 1238 } 1239 } 1240 } 1241 break; 1242 case WID_SECT_PASSWORD: 1243 { 1244 pRet[nProperty] <<= (m_bIsDescriptor) 1245 ? m_pProps->m_Password : pSect->GetPassword(); 1246 } 1247 break; 1248 default: 1249 { 1250 if (pFmt) 1251 { 1252 m_rPropSet.getPropertyValue(*pEntry, 1253 pFmt->GetAttrSet(), pRet[nProperty]); 1254 } 1255 else 1256 { 1257 const SfxPoolItem* pQueryItem = 0; 1258 if (RES_COL == pEntry->nWID) 1259 { 1260 if (!m_pProps->m_pColItem.get()) 1261 { 1262 m_pProps->m_pColItem.reset(new SwFmtCol); 1263 } 1264 pQueryItem = m_pProps->m_pColItem.get(); 1265 } 1266 else if (RES_BACKGROUND == pEntry->nWID) 1267 { 1268 if (!m_pProps->m_pBrushItem.get()) 1269 { 1270 m_pProps->m_pBrushItem.reset( 1271 new SvxBrushItem(RES_BACKGROUND)); 1272 } 1273 pQueryItem = m_pProps->m_pBrushItem.get(); 1274 } 1275 else if (RES_FTN_AT_TXTEND == pEntry->nWID) 1276 { 1277 if (!m_pProps->m_pFtnItem.get()) 1278 { 1279 m_pProps->m_pFtnItem.reset(new SwFmtFtnAtTxtEnd); 1280 } 1281 pQueryItem = m_pProps->m_pFtnItem.get(); 1282 } 1283 else if (RES_END_AT_TXTEND == pEntry->nWID) 1284 { 1285 if (!m_pProps->m_pEndItem.get()) 1286 { 1287 m_pProps->m_pEndItem.reset(new SwFmtEndAtTxtEnd); 1288 } 1289 pQueryItem = m_pProps->m_pEndItem.get(); 1290 } 1291 else if (RES_UNKNOWNATR_CONTAINER== pEntry->nWID) 1292 { 1293 if (!m_pProps->m_pXMLAttr.get()) 1294 { 1295 m_pProps->m_pXMLAttr.reset( 1296 new SvXMLAttrContainerItem); 1297 } 1298 pQueryItem = m_pProps->m_pXMLAttr.get(); 1299 } 1300 else if (RES_COLUMNBALANCE== pEntry->nWID) 1301 { 1302 if (!m_pProps->m_pNoBalanceItem.get()) 1303 { 1304 m_pProps->m_pNoBalanceItem.reset( 1305 new SwFmtNoBalancedColumns); 1306 } 1307 pQueryItem = m_pProps->m_pNoBalanceItem.get(); 1308 } 1309 else if (RES_FRAMEDIR == pEntry->nWID) 1310 { 1311 if (!m_pProps->m_pFrameDirItem.get()) 1312 { 1313 m_pProps->m_pFrameDirItem.reset( 1314 new SvxFrameDirectionItem( 1315 FRMDIR_ENVIRONMENT, RES_FRAMEDIR)); 1316 } 1317 pQueryItem = m_pProps->m_pFrameDirItem.get(); 1318 } 1319 /* -> #109700# */ 1320 else if (RES_LR_SPACE == pEntry->nWID) 1321 { 1322 if (!m_pProps->m_pLRSpaceItem.get()) 1323 { 1324 m_pProps->m_pLRSpaceItem.reset( 1325 new SvxLRSpaceItem( RES_LR_SPACE )); 1326 } 1327 pQueryItem = m_pProps->m_pLRSpaceItem.get(); 1328 } 1329 /* <- #109700# */ 1330 if (pQueryItem) 1331 { 1332 pQueryItem->QueryValue(pRet[nProperty], 1333 pEntry->nMemberId); 1334 } 1335 } 1336 } 1337 } 1338 } 1339 return aRet; 1340 } 1341 1342 /* -----------------------------04.11.03 10:43-------------------------------- 1343 1344 ---------------------------------------------------------------------------*/ 1345 uno::Sequence< uno::Any > SAL_CALL 1346 SwXTextSection::getPropertyValues( 1347 const uno::Sequence< ::rtl::OUString >& rPropertyNames) 1348 throw (uno::RuntimeException) 1349 { 1350 vos::OGuard aGuard(Application::GetSolarMutex()); 1351 uno::Sequence< uno::Any > aValues; 1352 1353 // workaround for bad designed API 1354 try 1355 { 1356 aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames ); 1357 } 1358 catch (beans::UnknownPropertyException &) 1359 { 1360 throw uno::RuntimeException(OUString( 1361 RTL_CONSTASCII_USTRINGPARAM("Unknown property exception caught")), 1362 static_cast<cppu::OWeakObject *>(this)); 1363 } 1364 catch (lang::WrappedTargetException &) 1365 { 1366 throw uno::RuntimeException(OUString( 1367 RTL_CONSTASCII_USTRINGPARAM("WrappedTargetException caught")), 1368 static_cast<cppu::OWeakObject *>(this)); 1369 } 1370 1371 return aValues; 1372 } 1373 /*-- 10.12.98 14:47:12--------------------------------------------------- 1374 1375 -----------------------------------------------------------------------*/ 1376 uno::Any SAL_CALL 1377 SwXTextSection::getPropertyValue(const OUString& rPropertyName) 1378 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1379 uno::RuntimeException) 1380 { 1381 vos::OGuard aGuard(Application::GetSolarMutex()); 1382 1383 uno::Sequence< ::rtl::OUString > aPropertyNames(1); 1384 aPropertyNames.getArray()[0] = rPropertyName; 1385 return m_pImpl->GetPropertyValues_Impl(aPropertyNames).getConstArray()[0]; 1386 } 1387 /* -----------------------------12.02.01 10:30-------------------------------- 1388 1389 ---------------------------------------------------------------------------*/ 1390 void SAL_CALL SwXTextSection::addPropertiesChangeListener( 1391 const uno::Sequence< OUString >& /*aPropertyNames*/, 1392 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 1393 throw (uno::RuntimeException) 1394 { 1395 OSL_ENSURE(false, 1396 "SwXTextSection::addPropertiesChangeListener(): not implemented"); 1397 } 1398 1399 /* -----------------------------12.02.01 10:30-------------------------------- 1400 1401 ---------------------------------------------------------------------------*/ 1402 void SAL_CALL SwXTextSection::removePropertiesChangeListener( 1403 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 1404 throw (uno::RuntimeException) 1405 { 1406 OSL_ENSURE(false, 1407 "SwXTextSection::removePropertiesChangeListener(): not implemented"); 1408 } 1409 1410 /* -----------------------------12.02.01 10:30-------------------------------- 1411 1412 ---------------------------------------------------------------------------*/ 1413 void SAL_CALL SwXTextSection::firePropertiesChangeEvent( 1414 const uno::Sequence< OUString >& /*aPropertyNames*/, 1415 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) 1416 throw(uno::RuntimeException) 1417 { 1418 OSL_ENSURE(false, 1419 "SwXTextSection::firePropertiesChangeEvent(): not implemented"); 1420 } 1421 1422 /*-- 10.12.98 14:47:13--------------------------------------------------- 1423 1424 -----------------------------------------------------------------------*/ 1425 void SAL_CALL 1426 SwXTextSection::addPropertyChangeListener( 1427 const ::rtl::OUString& /*rPropertyName*/, 1428 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) 1429 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1430 uno::RuntimeException) 1431 { 1432 OSL_ENSURE(false, 1433 "SwXTextSection::addPropertyChangeListener(): not implemented"); 1434 } 1435 1436 void SAL_CALL 1437 SwXTextSection::removePropertyChangeListener( 1438 const ::rtl::OUString& /*rPropertyName*/, 1439 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) 1440 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1441 uno::RuntimeException) 1442 { 1443 OSL_ENSURE(false, 1444 "SwXTextSection::removePropertyChangeListener(): not implemented"); 1445 } 1446 1447 void SAL_CALL 1448 SwXTextSection::addVetoableChangeListener( 1449 const ::rtl::OUString& /*rPropertyName*/, 1450 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) 1451 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1452 uno::RuntimeException) 1453 { 1454 OSL_ENSURE(false, 1455 "SwXTextSection::addVetoableChangeListener(): not implemented"); 1456 } 1457 1458 void SAL_CALL 1459 SwXTextSection::removeVetoableChangeListener( 1460 const ::rtl::OUString& /*rPropertyName*/, 1461 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) 1462 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1463 uno::RuntimeException) 1464 { 1465 OSL_ENSURE(false, 1466 "SwXTextSection::removeVetoableChangeListener(): not implemented"); 1467 } 1468 1469 /*-- 08.11.00 10:47:55--------------------------------------------------- 1470 1471 -----------------------------------------------------------------------*/ 1472 beans::PropertyState SAL_CALL 1473 SwXTextSection::getPropertyState(const OUString& rPropertyName) 1474 throw (beans::UnknownPropertyException, uno::RuntimeException) 1475 { 1476 vos::OGuard aGuard(Application::GetSolarMutex()); 1477 1478 uno::Sequence< OUString > aNames(1); 1479 aNames.getArray()[0] = rPropertyName; 1480 return getPropertyStates(aNames).getConstArray()[0]; 1481 } 1482 /*-- 08.11.00 10:47:55--------------------------------------------------- 1483 1484 -----------------------------------------------------------------------*/ 1485 uno::Sequence< beans::PropertyState > SAL_CALL 1486 SwXTextSection::getPropertyStates( 1487 const uno::Sequence< OUString >& rPropertyNames) 1488 throw (beans::UnknownPropertyException, uno::RuntimeException) 1489 { 1490 vos::OGuard aGuard(Application::GetSolarMutex()); 1491 1492 SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); 1493 if (!pFmt && !m_pImpl->m_bIsDescriptor) 1494 { 1495 throw uno::RuntimeException(); 1496 } 1497 1498 uno::Sequence< beans::PropertyState > aStates(rPropertyNames.getLength()); 1499 beans::PropertyState *const pStates = aStates.getArray(); 1500 const OUString* pNames = rPropertyNames.getConstArray(); 1501 for (sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) 1502 { 1503 pStates[i] = beans::PropertyState_DEFAULT_VALUE; 1504 SfxItemPropertySimpleEntry const*const pEntry = 1505 m_pImpl->m_rPropSet.getPropertyMap()->getByName( pNames[i]); 1506 if (!pEntry) 1507 { 1508 throw beans::UnknownPropertyException( 1509 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 1510 + pNames[i], static_cast< cppu::OWeakObject* >(this)); 1511 } 1512 switch (pEntry->nWID) 1513 { 1514 case WID_SECT_CONDITION: 1515 case WID_SECT_DDE_TYPE: 1516 case WID_SECT_DDE_FILE: 1517 case WID_SECT_DDE_ELEMENT: 1518 case WID_SECT_DDE_AUTOUPDATE: 1519 case WID_SECT_LINK: 1520 case WID_SECT_REGION : 1521 case WID_SECT_VISIBLE: 1522 case WID_SECT_PROTECTED: 1523 // --> FME 2004-06-22 #114856# edit in readonly sections 1524 case WID_SECT_EDIT_IN_READONLY: 1525 // <-- 1526 case FN_PARAM_LINK_DISPLAY_NAME: 1527 case FN_UNO_ANCHOR_TYPES: 1528 case FN_UNO_TEXT_WRAP: 1529 case FN_UNO_ANCHOR_TYPE: 1530 pStates[i] = beans::PropertyState_DIRECT_VALUE; 1531 break; 1532 default: 1533 { 1534 if (pFmt) 1535 { 1536 pStates[i] = m_pImpl->m_rPropSet.getPropertyState( 1537 pNames[i], pFmt->GetAttrSet()); 1538 } 1539 else 1540 { 1541 if (RES_COL == pEntry->nWID) 1542 { 1543 if (!m_pImpl->m_pProps->m_pColItem.get()) 1544 { 1545 pStates[i] = beans::PropertyState_DEFAULT_VALUE; 1546 } 1547 else 1548 { 1549 pStates[i] = beans::PropertyState_DIRECT_VALUE; 1550 } 1551 } 1552 else //if(RES_BACKGROUND == pEntry->nWID) 1553 { 1554 if (!m_pImpl->m_pProps->m_pBrushItem.get()) 1555 { 1556 pStates[i] = beans::PropertyState_DEFAULT_VALUE; 1557 } 1558 else 1559 { 1560 pStates[i] = beans::PropertyState_DIRECT_VALUE; 1561 } 1562 } 1563 } 1564 } 1565 } 1566 } 1567 return aStates; 1568 } 1569 1570 /*-- 08.11.00 10:47:55--------------------------------------------------- 1571 1572 -----------------------------------------------------------------------*/ 1573 void SAL_CALL 1574 SwXTextSection::setPropertyToDefault(const OUString& rPropertyName) 1575 throw (beans::UnknownPropertyException, uno::RuntimeException) 1576 { 1577 vos::OGuard aGuard(Application::GetSolarMutex()); 1578 1579 SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); 1580 if (!pFmt && !m_pImpl->m_bIsDescriptor) 1581 { 1582 throw uno::RuntimeException(); 1583 } 1584 1585 SfxItemPropertySimpleEntry const*const pEntry = 1586 m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); 1587 if (!pEntry) 1588 { 1589 throw beans::UnknownPropertyException( 1590 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 1591 + rPropertyName, static_cast< cppu::OWeakObject* >(this)); 1592 } 1593 if (pEntry->nFlags & beans::PropertyAttribute::READONLY) 1594 { 1595 throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( 1596 "setPropertyToDefault: property is read-only: ")) 1597 + rPropertyName, 1598 static_cast<cppu::OWeakObject *>(this)); 1599 } 1600 1601 ::std::auto_ptr<SwSectionData> const pSectionData( 1602 (pFmt) ? new SwSectionData(*pFmt->GetSection()) : 0); 1603 1604 ::std::auto_ptr<SfxItemSet> pNewAttrSet; 1605 bool bLinkModeChanged = false; 1606 1607 switch (pEntry->nWID) 1608 { 1609 case WID_SECT_CONDITION: 1610 { 1611 if (m_pImpl->m_bIsDescriptor) 1612 { 1613 m_pImpl->m_pProps->m_sCondition = aEmptyStr; 1614 } 1615 else 1616 { 1617 pSectionData->SetCondition(aEmptyStr); 1618 } 1619 } 1620 break; 1621 case WID_SECT_DDE_TYPE : 1622 case WID_SECT_DDE_FILE : 1623 case WID_SECT_DDE_ELEMENT : 1624 case WID_SECT_LINK : 1625 case WID_SECT_REGION : 1626 if (m_pImpl->m_bIsDescriptor) 1627 { 1628 m_pImpl->m_pProps->m_bDDE = false; 1629 m_pImpl->m_pProps->m_sLinkFileName = ::rtl::OUString(); 1630 m_pImpl->m_pProps->m_sSectionRegion = ::rtl::OUString(); 1631 m_pImpl->m_pProps->m_sSectionFilter = ::rtl::OUString(); 1632 } 1633 else 1634 { 1635 pSectionData->SetType(CONTENT_SECTION); 1636 } 1637 break; 1638 case WID_SECT_DDE_AUTOUPDATE: 1639 if (m_pImpl->m_bIsDescriptor) 1640 { 1641 m_pImpl->m_pProps->m_bUpdateType = true; 1642 } 1643 else 1644 { 1645 bLinkModeChanged = true; 1646 } 1647 break; 1648 case WID_SECT_VISIBLE : 1649 { 1650 if (m_pImpl->m_bIsDescriptor) 1651 { 1652 m_pImpl->m_pProps->m_bHidden = false; 1653 } 1654 else 1655 { 1656 pSectionData->SetHidden(false); 1657 } 1658 } 1659 break; 1660 case WID_SECT_PROTECTED: 1661 { 1662 if (m_pImpl->m_bIsDescriptor) 1663 { 1664 m_pImpl->m_pProps->m_bProtect = false; 1665 } 1666 else 1667 { 1668 pSectionData->SetProtectFlag(false); 1669 } 1670 } 1671 break; 1672 // --> FME 2004-06-22 #114856# edit in readonly sections 1673 case WID_SECT_EDIT_IN_READONLY: 1674 { 1675 if (m_pImpl->m_bIsDescriptor) 1676 { 1677 m_pImpl->m_pProps->m_bEditInReadonly = false; 1678 } 1679 else 1680 { 1681 pSectionData->SetEditInReadonlyFlag(false); 1682 } 1683 } 1684 break; 1685 // <-- 1686 1687 case FN_UNO_ANCHOR_TYPES: 1688 case FN_UNO_TEXT_WRAP: 1689 case FN_UNO_ANCHOR_TYPE: 1690 break; 1691 default: 1692 { 1693 if (pEntry->nWID <= SFX_WHICH_MAX) 1694 { 1695 if (pFmt) 1696 { 1697 const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); 1698 pNewAttrSet.reset( new SfxItemSet(*rOldAttrSet.GetPool(), 1699 pEntry->nWID, pEntry->nWID, 0)); 1700 pNewAttrSet->ClearItem(pEntry->nWID); 1701 } 1702 else 1703 { 1704 if (RES_COL == pEntry->nWID) 1705 { 1706 m_pImpl->m_pProps->m_pColItem.reset(); 1707 } 1708 else if (RES_BACKGROUND == pEntry->nWID) 1709 { 1710 m_pImpl->m_pProps->m_pBrushItem.reset(); 1711 } 1712 } 1713 } 1714 } 1715 } 1716 1717 lcl_UpdateSection(pFmt, pSectionData, pNewAttrSet, bLinkModeChanged); 1718 } 1719 1720 /*-- 08.11.00 10:47:56--------------------------------------------------- 1721 1722 -----------------------------------------------------------------------*/ 1723 uno::Any SAL_CALL 1724 SwXTextSection::getPropertyDefault(const OUString& rPropertyName) 1725 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 1726 uno::RuntimeException) 1727 { 1728 vos::OGuard aGuard(Application::GetSolarMutex()); 1729 1730 uno::Any aRet; 1731 SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); 1732 SfxItemPropertySimpleEntry const*const pEntry = 1733 m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); 1734 if (!pEntry) 1735 { 1736 throw beans::UnknownPropertyException( 1737 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) 1738 + rPropertyName, 1739 static_cast<cppu::OWeakObject *>(this)); 1740 } 1741 1742 switch(pEntry->nWID) 1743 { 1744 case WID_SECT_CONDITION: 1745 case WID_SECT_DDE_TYPE : 1746 case WID_SECT_DDE_FILE : 1747 case WID_SECT_DDE_ELEMENT : 1748 case WID_SECT_REGION : 1749 case FN_PARAM_LINK_DISPLAY_NAME: 1750 aRet <<= OUString(); 1751 break; 1752 case WID_SECT_LINK : 1753 aRet <<= text::SectionFileLink(); 1754 break; 1755 case WID_SECT_DDE_AUTOUPDATE: 1756 case WID_SECT_VISIBLE : 1757 { 1758 sal_Bool bTemp = sal_True; 1759 aRet.setValue( &bTemp, ::getCppuBooleanType()); 1760 } 1761 break; 1762 case WID_SECT_PROTECTED: 1763 // --> FME 2004-06-22 #114856# edit in readonly sections 1764 case WID_SECT_EDIT_IN_READONLY: 1765 // <-- 1766 { 1767 sal_Bool bTemp = sal_False; 1768 aRet.setValue( &bTemp, ::getCppuBooleanType()); 1769 } 1770 break; 1771 case FN_UNO_ANCHOR_TYPES: 1772 case FN_UNO_TEXT_WRAP: 1773 case FN_UNO_ANCHOR_TYPE: 1774 ::sw::GetDefaultTextContentValue(aRet, OUString(), pEntry->nWID); 1775 break; 1776 default: 1777 if(pFmt && pEntry->nWID <= SFX_WHICH_MAX) 1778 { 1779 SwDoc *const pDoc = pFmt->GetDoc(); 1780 const SfxPoolItem& rDefItem = 1781 pDoc->GetAttrPool().GetDefaultItem(pEntry->nWID); 1782 rDefItem.QueryValue(aRet, pEntry->nMemberId); 1783 } 1784 } 1785 return aRet; 1786 } 1787 1788 /*-- 10.12.98 14:47:15--------------------------------------------------- 1789 1790 -----------------------------------------------------------------------*/ 1791 OUString SAL_CALL SwXTextSection::getName() throw (uno::RuntimeException) 1792 { 1793 vos::OGuard aGuard(Application::GetSolarMutex()); 1794 1795 ::rtl::OUString sRet; 1796 SwSectionFmt const*const pFmt = m_pImpl->GetSectionFmt(); 1797 if(pFmt) 1798 { 1799 sRet = pFmt->GetSection()->GetSectionName(); 1800 } 1801 else if (m_pImpl->m_bIsDescriptor) 1802 { 1803 sRet = m_pImpl->m_sName; 1804 } 1805 else 1806 { 1807 throw uno::RuntimeException(); 1808 } 1809 return sRet; 1810 } 1811 /*-- 10.12.98 14:47:16--------------------------------------------------- 1812 1813 -----------------------------------------------------------------------*/ 1814 void SAL_CALL SwXTextSection::setName(const OUString& rName) 1815 throw (uno::RuntimeException) 1816 { 1817 vos::OGuard aGuard(Application::GetSolarMutex()); 1818 1819 SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); 1820 if(pFmt) 1821 { 1822 SwSection *const pSect = pFmt->GetSection(); 1823 SwSectionData aSection(*pSect); 1824 String sNewName(rName); 1825 aSection.SetSectionName(sNewName); 1826 1827 const SwSectionFmts& rFmts = pFmt->GetDoc()->GetSections(); 1828 sal_uInt16 nApplyPos = USHRT_MAX; 1829 for( sal_uInt16 i = 0; i < rFmts.Count(); i++ ) 1830 { 1831 if(rFmts[i]->GetSection() == pSect) 1832 { 1833 nApplyPos = i; 1834 } 1835 else if (sNewName == rFmts[i]->GetSection()->GetSectionName()) 1836 { 1837 throw uno::RuntimeException(); 1838 } 1839 } 1840 if(nApplyPos != USHRT_MAX) 1841 { 1842 { 1843 UnoActionContext aContext(pFmt->GetDoc()); 1844 pFmt->GetDoc()->UpdateSection(nApplyPos, aSection); 1845 } 1846 { 1847 // temporarily remove actions to allow cursor update 1848 UnoActionRemoveContext aRemoveContext( pFmt->GetDoc() ); 1849 } 1850 } 1851 } 1852 else if (m_pImpl->m_bIsDescriptor) 1853 { 1854 m_pImpl->m_sName = rName; 1855 } 1856 else 1857 { 1858 throw uno::RuntimeException(); 1859 } 1860 } 1861 /* -----------------02.11.99 11:30------------------- 1862 1863 --------------------------------------------------*/ 1864 OUString SAL_CALL 1865 SwXTextSection::getImplementationName() throw (uno::RuntimeException) 1866 { 1867 return C2U("SwXTextSection"); 1868 } 1869 1870 /* -----------------02.11.99 11:30------------------- 1871 1872 --------------------------------------------------*/ 1873 static char const*const g_ServicesTextSection[] = 1874 { 1875 "com.sun.star.text.TextContent", 1876 "com.sun.star.text.TextSection", 1877 "com.sun.star.document.LinkTarget", 1878 }; 1879 static const size_t g_nServicesTextSection( 1880 sizeof(g_ServicesTextSection)/sizeof(g_ServicesTextSection[0])); 1881 1882 sal_Bool SAL_CALL SwXTextSection::supportsService(const OUString& rServiceName) 1883 throw (uno::RuntimeException) 1884 { 1885 return ::sw::SupportsServiceImpl( 1886 g_nServicesTextSection, g_ServicesTextSection, rServiceName); 1887 } 1888 1889 /* -----------------02.11.99 11:30------------------- 1890 1891 --------------------------------------------------*/ 1892 uno::Sequence< OUString > SAL_CALL 1893 SwXTextSection::getSupportedServiceNames() throw (uno::RuntimeException) 1894 { 1895 return ::sw::GetSupportedServiceNamesImpl( 1896 g_nServicesTextSection, g_ServicesTextSection); 1897 } 1898 1899 1900 // MetadatableMixin 1901 ::sfx2::Metadatable* SwXTextSection::GetCoreObject() 1902 { 1903 SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); 1904 return pSectionFmt; 1905 } 1906 1907 uno::Reference<frame::XModel> SwXTextSection::GetModel() 1908 { 1909 SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); 1910 if (pSectionFmt) 1911 { 1912 SwDocShell const*const pShell( pSectionFmt->GetDoc()->GetDocShell() ); 1913 return (pShell) ? pShell->GetModel() : 0; 1914 } 1915 return 0; 1916 } 1917 1918