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