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 <unobookmark.hxx> 32 #include <vos/mutex.hxx> 33 #include <vcl/svapp.hxx> 34 35 #include <TextCursorHelper.hxx> 36 #include <unotextrange.hxx> 37 #include <unomap.hxx> 38 #include <unoprnms.hxx> 39 #include <unoevtlstnr.hxx> 40 #include <IMark.hxx> 41 #include <crossrefbookmark.hxx> 42 #include <doc.hxx> 43 #include <IDocumentUndoRedo.hxx> 44 #include <docary.hxx> 45 #include <swundo.hxx> 46 #include <comcore.hrc> 47 #include <SwRewriter.hxx> 48 #include <docsh.hxx> 49 50 51 using namespace ::sw::mark; 52 using namespace ::com::sun::star; 53 using ::rtl::OUString; 54 55 56 namespace 57 { 58 static OUString lcl_QuoteName(const OUString& rName) 59 { 60 static const OUString sStart = OUString(String(SW_RES(STR_START_QUOTE))); 61 static const OUString sEnd = OUString(String(SW_RES(STR_END_QUOTE))); 62 ::rtl::OUStringBuffer sBuf(64); 63 return sBuf.append(sStart).append(rName).append(sEnd).makeStringAndClear(); 64 } 65 } 66 67 /****************************************************************** 68 * SwXBookmark 69 ******************************************************************/ 70 71 class SwXBookmark::Impl 72 : public SwClient 73 { 74 75 public: 76 SwEventListenerContainer m_ListenerContainer; 77 SwDoc * m_pDoc; 78 ::sw::mark::IMark * m_pRegisteredBookmark; 79 ::rtl::OUString m_sMarkName; 80 81 82 Impl( SwXBookmark & rThis, 83 SwDoc *const pDoc, ::sw::mark::IMark *const /*pBookmark*/) 84 : SwClient() 85 , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) 86 , m_pDoc(pDoc) 87 , m_pRegisteredBookmark(0) 88 { 89 // DO NOT regiserInMark here! (because SetXBookmark would delete rThis) 90 } 91 92 void registerInMark(SwXBookmark & rThis, ::sw::mark::IMark *const pBkmk); 93 protected: 94 // SwClient 95 virtual void Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew); 96 97 }; 98 99 void SwXBookmark::Impl::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) 100 { 101 ClientModify(this, pOld, pNew); 102 if (!GetRegisteredIn()) 103 { 104 m_pRegisteredBookmark = NULL; 105 m_pDoc = NULL; 106 m_ListenerContainer.Disposing(); 107 } 108 } 109 110 void SwXBookmark::Impl::registerInMark(SwXBookmark & rThis, 111 ::sw::mark::IMark *const pBkmk) 112 { 113 if (pBkmk) 114 { 115 pBkmk->Add(this); 116 ::sw::mark::MarkBase *const pMarkBase( 117 dynamic_cast< ::sw::mark::MarkBase * >(pBkmk)); 118 OSL_ENSURE(pMarkBase, "registerInMark: no MarkBase?"); 119 if (pMarkBase) 120 { 121 const uno::Reference<text::XTextContent> xBookmark(& rThis); 122 pMarkBase->SetXBookmark(xBookmark); 123 } 124 } 125 else if (m_pRegisteredBookmark) 126 { 127 m_sMarkName = m_pRegisteredBookmark->GetName(); 128 m_pRegisteredBookmark->Remove(this); 129 } 130 m_pRegisteredBookmark = pBkmk; 131 } 132 133 134 const ::sw::mark::IMark* SwXBookmark::GetBookmark() const 135 { 136 return m_pImpl->m_pRegisteredBookmark; 137 } 138 139 SwXBookmark::SwXBookmark(::sw::mark::IMark *const pBkmk, SwDoc *const pDoc) 140 : m_pImpl( new SwXBookmark::Impl(*this, pDoc, pBkmk) ) 141 { 142 } 143 144 SwXBookmark::SwXBookmark() 145 : m_pImpl( new SwXBookmark::Impl(*this, 0, 0) ) 146 { 147 } 148 149 SwXBookmark::~SwXBookmark() 150 { 151 } 152 153 uno::Reference<text::XTextContent> 154 SwXBookmark::CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark & rBookmark) 155 { 156 // #i105557#: do not iterate over the registered clients: race condition 157 ::sw::mark::MarkBase *const pMarkBase( 158 dynamic_cast< ::sw::mark::MarkBase * >(&rBookmark)); 159 OSL_ENSURE(pMarkBase, "CreateXBookmark: no MarkBase?"); 160 if (!pMarkBase) { return 0; } 161 uno::Reference<text::XTextContent> xBookmark(pMarkBase->GetXBookmark()); 162 if (!xBookmark.is()) 163 { 164 // FIXME: These belong in XTextFieldsSupplier 165 //if (dynamic_cast< ::sw::mark::TextFieldmark* >(&rBkmk)) 166 // pXBkmk = new SwXFieldmark(false, &rBkmk, pDoc); 167 //else if (dynamic_cast< ::sw::mark::CheckboxFieldmark* >(&rBkmk)) 168 // pXBkmk = new SwXFieldmark(true, &rBkmk, pDoc); 169 //else 170 OSL_ENSURE( 171 dynamic_cast< ::sw::mark::IBookmark* >(&rBookmark), 172 "<SwXBookmark::GetObject(..)>" 173 "SwXBookmark requested for non-bookmark mark."); 174 SwXBookmark *const pXBookmark = new SwXBookmark(&rBookmark, &rDoc); 175 xBookmark.set(pXBookmark); 176 pXBookmark->m_pImpl->registerInMark(*pXBookmark, pMarkBase); 177 } 178 return xBookmark; 179 } 180 181 ::sw::mark::IMark const* SwXBookmark::GetBookmarkInDoc(SwDoc const*const pDoc, 182 const uno::Reference< lang::XUnoTunnel> & xUT) 183 { 184 SwXBookmark *const pXBkm( 185 ::sw::UnoTunnelGetImplementation<SwXBookmark>(xUT)); 186 if (pXBkm && (pDoc == pXBkm->m_pImpl->m_pDoc)) 187 { 188 return pXBkm->m_pImpl->m_pRegisteredBookmark; 189 } 190 return 0; 191 } 192 193 const uno::Sequence< sal_Int8 > & SwXBookmark::getUnoTunnelId() 194 { 195 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); 196 return aSeq; 197 } 198 199 sal_Int64 SAL_CALL 200 SwXBookmark::getSomething(const uno::Sequence< sal_Int8 >& rId) 201 throw (uno::RuntimeException) 202 { 203 return ::sw::UnoTunnelImpl<SwXBookmark>(rId, this); 204 } 205 206 void SwXBookmark::attachToRangeEx( 207 const uno::Reference< text::XTextRange > & xTextRange, 208 IDocumentMarkAccess::MarkType eType) 209 throw (lang::IllegalArgumentException, uno::RuntimeException) 210 { 211 if (m_pImpl->m_pRegisteredBookmark) 212 { 213 throw uno::RuntimeException(); 214 } 215 216 const uno::Reference<lang::XUnoTunnel> xRangeTunnel( 217 xTextRange, uno::UNO_QUERY); 218 SwXTextRange* pRange = 0; 219 OTextCursorHelper* pCursor = 0; 220 if(xRangeTunnel.is()) 221 { 222 pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel); 223 pCursor = 224 ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel); 225 } 226 227 SwDoc *const pDoc = 228 (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); 229 if (!pDoc) 230 { 231 throw lang::IllegalArgumentException(); 232 } 233 234 m_pImpl->m_pDoc = pDoc; 235 SwUnoInternalPaM aPam(*m_pImpl->m_pDoc); 236 ::sw::XTextRangeToSwPaM(aPam, xTextRange); 237 UnoActionContext aCont(m_pImpl->m_pDoc); 238 if (!m_pImpl->m_sMarkName.getLength()) 239 { 240 m_pImpl->m_sMarkName = OUString::createFromAscii("Bookmark"); 241 } 242 if ((eType == IDocumentMarkAccess::BOOKMARK) && 243 ::sw::mark::CrossRefNumItemBookmark::IsLegalName(m_pImpl->m_sMarkName)) 244 { 245 eType = IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK; 246 } 247 else if ((eType == IDocumentMarkAccess::BOOKMARK) && 248 ::sw::mark::CrossRefHeadingBookmark::IsLegalName(m_pImpl->m_sMarkName)) 249 { 250 eType = IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK; 251 } 252 m_pImpl->registerInMark(*this, 253 m_pImpl->m_pDoc->getIDocumentMarkAccess()->makeMark( 254 aPam, m_pImpl->m_sMarkName, eType)); 255 // --> OD 2007-10-23 #i81002# 256 // Check, if bookmark has been created. 257 // E.g., the creation of a cross-reference bookmark is suppress, 258 // if the PaM isn't a valid one for cross-reference bookmarks. 259 if (!m_pImpl->m_pRegisteredBookmark) 260 { 261 OSL_ENSURE(false, 262 "<SwXBookmark::attachToRange(..)>" 263 " - could not create Mark."); 264 throw lang::IllegalArgumentException(); 265 } 266 // <-- 267 } 268 269 void SwXBookmark::attachToRange( 270 const uno::Reference< text::XTextRange > & xTextRange) 271 throw (lang::IllegalArgumentException, uno::RuntimeException) 272 { 273 attachToRangeEx(xTextRange, IDocumentMarkAccess::BOOKMARK); 274 } 275 276 void SAL_CALL 277 SwXBookmark::attach(const uno::Reference< text::XTextRange > & xTextRange) 278 throw (lang::IllegalArgumentException, uno::RuntimeException) 279 { 280 vos::OGuard aGuard(Application::GetSolarMutex()); 281 attachToRange( xTextRange ); 282 } 283 284 uno::Reference< text::XTextRange > SAL_CALL 285 SwXBookmark::getAnchor() throw (uno::RuntimeException) 286 { 287 vos::OGuard aGuard(Application::GetSolarMutex()); 288 289 if (!m_pImpl->m_pRegisteredBookmark) 290 { 291 throw uno::RuntimeException(); 292 } 293 return SwXTextRange::CreateXTextRange( 294 *m_pImpl->m_pDoc, 295 m_pImpl->m_pRegisteredBookmark->GetMarkPos(), 296 (m_pImpl->m_pRegisteredBookmark->IsExpanded()) 297 ? &m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos() : NULL); 298 } 299 300 void SAL_CALL SwXBookmark::dispose() throw (uno::RuntimeException) 301 { 302 vos::OGuard aGuard(Application::GetSolarMutex()); 303 if (m_pImpl->m_pRegisteredBookmark) 304 { 305 m_pImpl->m_pDoc->getIDocumentMarkAccess()->deleteMark( 306 m_pImpl->m_pRegisteredBookmark); 307 } 308 } 309 310 void SAL_CALL SwXBookmark::addEventListener( 311 const uno::Reference< lang::XEventListener > & xListener) 312 throw (uno::RuntimeException) 313 { 314 vos::OGuard g(Application::GetSolarMutex()); 315 316 if (!m_pImpl->m_pRegisteredBookmark) 317 { 318 throw uno::RuntimeException(); 319 } 320 m_pImpl->m_ListenerContainer.AddListener(xListener); 321 } 322 323 void SAL_CALL SwXBookmark::removeEventListener( 324 const uno::Reference< lang::XEventListener > & xListener) 325 throw (uno::RuntimeException) 326 { 327 vos::OGuard g(Application::GetSolarMutex()); 328 329 if (!m_pImpl->m_pRegisteredBookmark || 330 !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) 331 { 332 throw uno::RuntimeException(); 333 } 334 } 335 336 OUString SAL_CALL SwXBookmark::getName() 337 throw (uno::RuntimeException) 338 { 339 vos::OGuard aGuard(Application::GetSolarMutex()); 340 341 return (m_pImpl->m_pRegisteredBookmark) 342 ? m_pImpl->m_pRegisteredBookmark->GetName() 343 : m_pImpl->m_sMarkName; 344 } 345 346 void SAL_CALL SwXBookmark::setName(const OUString& rName) 347 throw (uno::RuntimeException) 348 { 349 vos::OGuard aGuard(Application::GetSolarMutex()); 350 351 if (!m_pImpl->m_pRegisteredBookmark) 352 { 353 m_pImpl->m_sMarkName = rName; 354 } 355 if (!m_pImpl->m_pRegisteredBookmark || (getName() == rName)) 356 { 357 return; 358 } 359 IDocumentMarkAccess *const pMarkAccess = 360 m_pImpl->m_pDoc->getIDocumentMarkAccess(); 361 if(pMarkAccess->findMark(rName) != pMarkAccess->getMarksEnd()) 362 { 363 throw uno::RuntimeException(); 364 } 365 366 SwPaM aPam(m_pImpl->m_pRegisteredBookmark->GetMarkPos()); 367 if (m_pImpl->m_pRegisteredBookmark->IsExpanded()) 368 { 369 aPam.SetMark(); 370 *aPam.GetMark() = m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos(); 371 } 372 373 SwRewriter aRewriter; 374 aRewriter.AddRule(UNDO_ARG1, lcl_QuoteName(getName())); 375 aRewriter.AddRule(UNDO_ARG2, SW_RES(STR_YIELDS)); 376 aRewriter.AddRule(UNDO_ARG3, lcl_QuoteName(rName)); 377 378 m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo( 379 UNDO_BOOKMARK_RENAME, &aRewriter); 380 pMarkAccess->renameMark(m_pImpl->m_pRegisteredBookmark, rName); 381 m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo( 382 UNDO_BOOKMARK_RENAME, &aRewriter); 383 } 384 385 OUString SAL_CALL 386 SwXBookmark::getImplementationName() throw (uno::RuntimeException) 387 { 388 return OUString::createFromAscii("SwXBookmark"); 389 } 390 391 static char const*const g_ServicesBookmark[] = 392 { 393 "com.sun.star.text.TextContent", 394 "com.sun.star.text.Bookmark", 395 "com.sun.star.document.LinkTarget", 396 }; 397 static const size_t g_nServicesBookmark( 398 sizeof(g_ServicesBookmark)/sizeof(g_ServicesBookmark[0])); 399 400 sal_Bool SAL_CALL SwXBookmark::supportsService(const OUString& rServiceName) 401 throw (uno::RuntimeException) 402 { 403 return ::sw::SupportsServiceImpl( 404 g_nServicesBookmark, g_ServicesBookmark, rServiceName); 405 } 406 407 uno::Sequence< OUString > SAL_CALL 408 SwXBookmark::getSupportedServiceNames() throw (uno::RuntimeException) 409 { 410 return ::sw::GetSupportedServiceNamesImpl( 411 g_nServicesBookmark, g_ServicesBookmark); 412 } 413 414 // MetadatableMixin 415 ::sfx2::Metadatable* SwXBookmark::GetCoreObject() 416 { 417 return dynamic_cast< ::sfx2::Metadatable* >(m_pImpl->m_pRegisteredBookmark); 418 } 419 420 uno::Reference<frame::XModel> SwXBookmark::GetModel() 421 { 422 if (m_pImpl->m_pDoc) 423 { 424 SwDocShell const * const pShell( m_pImpl->m_pDoc->GetDocShell() ); 425 return (pShell) ? pShell->GetModel() : 0; 426 } 427 return 0; 428 } 429 430 431 uno::Reference< beans::XPropertySetInfo > SAL_CALL 432 SwXBookmark::getPropertySetInfo() throw (uno::RuntimeException) 433 { 434 vos::OGuard g(Application::GetSolarMutex()); 435 436 static uno::Reference< beans::XPropertySetInfo > xRef( 437 aSwMapProvider.GetPropertySet(PROPERTY_MAP_BOOKMARK) 438 ->getPropertySetInfo() ); 439 return xRef; 440 } 441 442 void SAL_CALL 443 SwXBookmark::setPropertyValue(const OUString& PropertyName, 444 const uno::Any& /*rValue*/) 445 throw (beans::UnknownPropertyException, beans::PropertyVetoException, 446 lang::IllegalArgumentException, lang::WrappedTargetException, 447 uno::RuntimeException) 448 { 449 // nothing to set here 450 throw lang::IllegalArgumentException( ::rtl::OUString( 451 RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) 452 + PropertyName, static_cast< cppu::OWeakObject * >(this), 0 ); 453 } 454 455 uno::Any SAL_CALL SwXBookmark::getPropertyValue(const OUString& rPropertyName) 456 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 457 uno::RuntimeException) 458 { 459 vos::OGuard g(Application::GetSolarMutex()); 460 461 uno::Any aRet; 462 if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName)) 463 { 464 if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME))) 465 { 466 aRet <<= getName(); 467 } 468 } 469 return aRet; 470 } 471 472 void SAL_CALL 473 SwXBookmark::addPropertyChangeListener( 474 const ::rtl::OUString& /*rPropertyName*/, 475 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) 476 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 477 uno::RuntimeException) 478 { 479 OSL_ENSURE(false, 480 "SwXBookmark::addPropertyChangeListener(): not implemented"); 481 } 482 483 void SAL_CALL 484 SwXBookmark::removePropertyChangeListener( 485 const ::rtl::OUString& /*rPropertyName*/, 486 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) 487 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 488 uno::RuntimeException) 489 { 490 OSL_ENSURE(false, 491 "SwXBookmark::removePropertyChangeListener(): not implemented"); 492 } 493 494 void SAL_CALL 495 SwXBookmark::addVetoableChangeListener( 496 const ::rtl::OUString& /*rPropertyName*/, 497 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) 498 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 499 uno::RuntimeException) 500 { 501 OSL_ENSURE(false, 502 "SwXBookmark::addVetoableChangeListener(): not implemented"); 503 } 504 505 void SAL_CALL 506 SwXBookmark::removeVetoableChangeListener( 507 const ::rtl::OUString& /*rPropertyName*/, 508 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) 509 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 510 uno::RuntimeException) 511 { 512 OSL_ENSURE(false, 513 "SwXBookmark::removeVetoableChangeListener(): not implemented"); 514 } 515 516 /****************************************************************** 517 * SwXFieldmark 518 ******************************************************************/ 519 520 SwXFieldmark::SwXFieldmark(bool _isReplacementObject, ::sw::mark::IMark* pBkm, SwDoc* pDc) 521 : SwXFieldmark_Base(pBkm, pDc) 522 , isReplacementObject(_isReplacementObject) 523 { } 524 525 void SwXFieldmarkParameters::insertByName(const OUString& aName, const uno::Any& aElement) 526 throw (lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException) 527 { 528 vos::OGuard aGuard(Application::GetSolarMutex()); 529 IFieldmark::parameter_map_t* pParameters = getCoreParameters(); 530 if(pParameters->find(aName) != pParameters->end()) 531 throw container::ElementExistException(); 532 (*pParameters)[aName] = aElement; 533 } 534 535 void SwXFieldmarkParameters::removeByName(const OUString& aName) 536 throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 537 { 538 vos::OGuard aGuard(Application::GetSolarMutex()); 539 if(!getCoreParameters()->erase(aName)) 540 throw container::NoSuchElementException(); 541 } 542 543 void SwXFieldmarkParameters::replaceByName(const OUString& aName, const uno::Any& aElement) 544 throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 545 { 546 vos::OGuard aGuard(Application::GetSolarMutex()); 547 IFieldmark::parameter_map_t* pParameters = getCoreParameters(); 548 IFieldmark::parameter_map_t::iterator pEntry = pParameters->find(aName); 549 if(pEntry == pParameters->end()) 550 throw container::NoSuchElementException(); 551 pEntry->second = aElement; 552 } 553 554 uno::Any SwXFieldmarkParameters::getByName(const OUString& aName) 555 throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 556 { 557 vos::OGuard aGuard(Application::GetSolarMutex()); 558 IFieldmark::parameter_map_t* pParameters = getCoreParameters(); 559 IFieldmark::parameter_map_t::iterator pEntry = pParameters->find(aName); 560 if(pEntry == pParameters->end()) 561 throw container::NoSuchElementException(); 562 return pEntry->second; 563 } 564 565 uno::Sequence<OUString> SwXFieldmarkParameters::getElementNames() 566 throw (uno::RuntimeException) 567 { 568 vos::OGuard aGuard(Application::GetSolarMutex()); 569 IFieldmark::parameter_map_t* pParameters = getCoreParameters(); 570 uno::Sequence<OUString> vResult(pParameters->size()); 571 OUString* pOutEntry = vResult.getArray(); 572 for(IFieldmark::parameter_map_t::iterator pEntry = pParameters->begin(); pEntry!=pParameters->end(); ++pEntry, ++pOutEntry) 573 *pOutEntry = pEntry->first; 574 return vResult; 575 } 576 577 ::sal_Bool SwXFieldmarkParameters::hasByName(const OUString& aName) 578 throw (uno::RuntimeException) 579 { 580 vos::OGuard aGuard(Application::GetSolarMutex()); 581 IFieldmark::parameter_map_t* pParameters = getCoreParameters(); 582 return (pParameters->find(aName) != pParameters->end()); 583 } 584 585 uno::Type SwXFieldmarkParameters::getElementType() 586 throw (uno::RuntimeException) 587 { 588 return ::cppu::UnoType< ::cppu::UnoVoidType>::get(); 589 } 590 591 ::sal_Bool SwXFieldmarkParameters::hasElements() 592 throw (uno::RuntimeException) 593 { 594 vos::OGuard aGuard(Application::GetSolarMutex()); 595 return !getCoreParameters()->empty(); 596 } 597 598 void SwXFieldmarkParameters::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) 599 { 600 ClientModify(this, pOld, pNew); 601 } 602 603 604 IFieldmark::parameter_map_t* SwXFieldmarkParameters::getCoreParameters() 605 throw (uno::RuntimeException) 606 { 607 const IFieldmark* pFieldmark = dynamic_cast< const IFieldmark* >(GetRegisteredIn()); 608 if(!pFieldmark) 609 throw uno::RuntimeException(); 610 return const_cast< IFieldmark* >(pFieldmark)->GetParameters(); 611 } 612 613 614 void SwXFieldmark::attachToRange( const uno::Reference < text::XTextRange >& xTextRange ) 615 throw(lang::IllegalArgumentException, uno::RuntimeException) 616 { 617 attachToRangeEx( xTextRange, 618 ( isReplacementObject ? IDocumentMarkAccess::CHECKBOX_FIELDMARK : IDocumentMarkAccess::TEXT_FIELDMARK ) ); 619 } 620 621 ::rtl::OUString SwXFieldmark::getFieldType(void) 622 throw(uno::RuntimeException) 623 { 624 vos::OGuard aGuard(Application::GetSolarMutex()); 625 const IFieldmark *pBkm = dynamic_cast<const IFieldmark*>(GetBookmark()); 626 if(!pBkm) 627 throw uno::RuntimeException(); 628 return pBkm->GetFieldname(); 629 } 630 631 void SwXFieldmark::setFieldType(const::rtl::OUString & fieldType) 632 throw(uno::RuntimeException) 633 { 634 vos::OGuard aGuard(Application::GetSolarMutex()); 635 IFieldmark *pBkm = const_cast<IFieldmark*>( 636 dynamic_cast<const IFieldmark*>(GetBookmark())); 637 if(!pBkm) 638 throw uno::RuntimeException(); 639 pBkm->SetFieldname(fieldType); 640 } 641 642 uno::Reference<container::XNameContainer> SwXFieldmark::getParameters() 643 throw (uno::RuntimeException) 644 { 645 vos::OGuard aGuard(Application::GetSolarMutex()); 646 IFieldmark *pBkm = const_cast<IFieldmark*>( 647 dynamic_cast<const IFieldmark*>(GetBookmark())); 648 if(!pBkm) 649 throw uno::RuntimeException(); 650 return uno::Reference<container::XNameContainer>(new SwXFieldmarkParameters(pBkm)); 651 } 652 653