xref: /AOO41X/main/sw/source/core/unocore/unobkm.cxx (revision 64a494d0eb1b8b6a37e8d27f7dd2723f345d9d68)
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         IDocumentMarkAccess::IsLegalPaMForCrossRefHeadingBookmark( aPam ) )
246     {
247         eType = IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK;
248     }
249     m_pImpl->registerInMark(*this,
250         m_pImpl->m_pDoc->getIDocumentMarkAccess()->makeMark(
251             aPam, m_pImpl->m_sMarkName, eType));
252     // --> OD 2007-10-23 #i81002#
253     // Check, if bookmark has been created.
254     // E.g., the creation of a cross-reference bookmark is suppress,
255     // if the PaM isn't a valid one for cross-reference bookmarks.
256     if (!m_pImpl->m_pRegisteredBookmark)
257     {
258         OSL_ENSURE(false,
259             "<SwXBookmark::attachToRange(..)>"
260             " - could not create Mark.");
261         throw lang::IllegalArgumentException();
262     }
263     // <--
264 }
265 
266 void SwXBookmark::attachToRange(
267         const uno::Reference< text::XTextRange > & xTextRange)
268 throw (lang::IllegalArgumentException, uno::RuntimeException)
269 {
270     attachToRangeEx(xTextRange, IDocumentMarkAccess::BOOKMARK);
271 }
272 
273 void SAL_CALL
274 SwXBookmark::attach(const uno::Reference< text::XTextRange > & xTextRange)
275 throw (lang::IllegalArgumentException, uno::RuntimeException)
276 {
277     vos::OGuard aGuard(Application::GetSolarMutex());
278     attachToRange( xTextRange );
279 }
280 
281 uno::Reference< text::XTextRange > SAL_CALL
282 SwXBookmark::getAnchor() throw (uno::RuntimeException)
283 {
284     vos::OGuard aGuard(Application::GetSolarMutex());
285 
286     if (!m_pImpl->m_pRegisteredBookmark)
287     {
288         throw uno::RuntimeException();
289     }
290     return SwXTextRange::CreateXTextRange(
291             *m_pImpl->m_pDoc,
292             m_pImpl->m_pRegisteredBookmark->GetMarkPos(),
293             (m_pImpl->m_pRegisteredBookmark->IsExpanded())
294                 ? &m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos() : NULL);
295 }
296 
297 void SAL_CALL SwXBookmark::dispose() throw (uno::RuntimeException)
298 {
299     vos::OGuard aGuard(Application::GetSolarMutex());
300     if (m_pImpl->m_pRegisteredBookmark)
301     {
302         m_pImpl->m_pDoc->getIDocumentMarkAccess()->deleteMark(
303                 m_pImpl->m_pRegisteredBookmark);
304     }
305 }
306 
307 void SAL_CALL SwXBookmark::addEventListener(
308         const uno::Reference< lang::XEventListener > & xListener)
309 throw (uno::RuntimeException)
310 {
311     vos::OGuard g(Application::GetSolarMutex());
312 
313     if (!m_pImpl->m_pRegisteredBookmark)
314     {
315         throw uno::RuntimeException();
316     }
317     m_pImpl->m_ListenerContainer.AddListener(xListener);
318 }
319 
320 void SAL_CALL SwXBookmark::removeEventListener(
321         const uno::Reference< lang::XEventListener > & xListener)
322 throw (uno::RuntimeException)
323 {
324     vos::OGuard g(Application::GetSolarMutex());
325 
326     if (!m_pImpl->m_pRegisteredBookmark ||
327         !m_pImpl->m_ListenerContainer.RemoveListener(xListener))
328     {
329         throw uno::RuntimeException();
330     }
331 }
332 
333 OUString SAL_CALL SwXBookmark::getName()
334 throw (uno::RuntimeException)
335 {
336     vos::OGuard aGuard(Application::GetSolarMutex());
337 
338     return (m_pImpl->m_pRegisteredBookmark)
339         ?   m_pImpl->m_pRegisteredBookmark->GetName()
340         :   m_pImpl->m_sMarkName;
341 }
342 
343 void SAL_CALL SwXBookmark::setName(const OUString& rName)
344 throw (uno::RuntimeException)
345 {
346     vos::OGuard aGuard(Application::GetSolarMutex());
347 
348     if (!m_pImpl->m_pRegisteredBookmark)
349     {
350         m_pImpl->m_sMarkName = rName;
351     }
352     if (!m_pImpl->m_pRegisteredBookmark || (getName() == rName))
353     {
354         return;
355     }
356     IDocumentMarkAccess *const pMarkAccess =
357         m_pImpl->m_pDoc->getIDocumentMarkAccess();
358     if(pMarkAccess->findMark(rName) != pMarkAccess->getMarksEnd())
359     {
360         throw uno::RuntimeException();
361     }
362 
363     SwPaM aPam(m_pImpl->m_pRegisteredBookmark->GetMarkPos());
364     if (m_pImpl->m_pRegisteredBookmark->IsExpanded())
365     {
366         aPam.SetMark();
367         *aPam.GetMark() = m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos();
368     }
369 
370     SwRewriter aRewriter;
371     aRewriter.AddRule(UNDO_ARG1, lcl_QuoteName(getName()));
372     aRewriter.AddRule(UNDO_ARG2, SW_RES(STR_YIELDS));
373     aRewriter.AddRule(UNDO_ARG3, lcl_QuoteName(rName));
374 
375     m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo(
376             UNDO_BOOKMARK_RENAME, &aRewriter);
377     pMarkAccess->renameMark(m_pImpl->m_pRegisteredBookmark, rName);
378     m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(
379             UNDO_BOOKMARK_RENAME, &aRewriter);
380 }
381 
382 OUString SAL_CALL
383 SwXBookmark::getImplementationName() throw (uno::RuntimeException)
384 {
385     return OUString::createFromAscii("SwXBookmark");
386 }
387 
388 static char const*const g_ServicesBookmark[] =
389 {
390     "com.sun.star.text.TextContent",
391     "com.sun.star.text.Bookmark",
392     "com.sun.star.document.LinkTarget",
393 };
394 static const size_t g_nServicesBookmark(
395     sizeof(g_ServicesBookmark)/sizeof(g_ServicesBookmark[0]));
396 
397 sal_Bool SAL_CALL SwXBookmark::supportsService(const OUString& rServiceName)
398 throw (uno::RuntimeException)
399 {
400     return ::sw::SupportsServiceImpl(
401             g_nServicesBookmark, g_ServicesBookmark, rServiceName);
402 }
403 
404 uno::Sequence< OUString > SAL_CALL
405 SwXBookmark::getSupportedServiceNames() throw (uno::RuntimeException)
406 {
407     return ::sw::GetSupportedServiceNamesImpl(
408             g_nServicesBookmark, g_ServicesBookmark);
409 }
410 
411 // MetadatableMixin
412 ::sfx2::Metadatable* SwXBookmark::GetCoreObject()
413 {
414     return dynamic_cast< ::sfx2::Metadatable* >(m_pImpl->m_pRegisteredBookmark);
415 }
416 
417 uno::Reference<frame::XModel> SwXBookmark::GetModel()
418 {
419     if (m_pImpl->m_pDoc)
420     {
421         SwDocShell const * const pShell( m_pImpl->m_pDoc->GetDocShell() );
422         return (pShell) ? pShell->GetModel() : 0;
423     }
424     return 0;
425 }
426 
427 
428 uno::Reference< beans::XPropertySetInfo > SAL_CALL
429 SwXBookmark::getPropertySetInfo() throw (uno::RuntimeException)
430 {
431     vos::OGuard g(Application::GetSolarMutex());
432 
433     static uno::Reference< beans::XPropertySetInfo > xRef(
434         aSwMapProvider.GetPropertySet(PROPERTY_MAP_BOOKMARK)
435             ->getPropertySetInfo() );
436     return xRef;
437 }
438 
439 void SAL_CALL
440 SwXBookmark::setPropertyValue(const OUString& PropertyName,
441         const uno::Any& /*rValue*/)
442 throw (beans::UnknownPropertyException, beans::PropertyVetoException,
443     lang::IllegalArgumentException, lang::WrappedTargetException,
444     uno::RuntimeException)
445 {
446     // nothing to set here
447     throw lang::IllegalArgumentException( ::rtl::OUString(
448             RTL_CONSTASCII_USTRINGPARAM("Property is read-only: "))
449             + PropertyName, static_cast< cppu::OWeakObject * >(this), 0 );
450 }
451 
452 uno::Any SAL_CALL SwXBookmark::getPropertyValue(const OUString& rPropertyName)
453 throw (beans::UnknownPropertyException, lang::WrappedTargetException,
454         uno::RuntimeException)
455 {
456     vos::OGuard g(Application::GetSolarMutex());
457 
458     uno::Any aRet;
459     if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName))
460     {
461         if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME)))
462         {
463             aRet <<= getName();
464         }
465     }
466     return aRet;
467 }
468 
469 void SAL_CALL
470 SwXBookmark::addPropertyChangeListener(
471         const ::rtl::OUString& /*rPropertyName*/,
472         const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
473 throw (beans::UnknownPropertyException, lang::WrappedTargetException,
474     uno::RuntimeException)
475 {
476     OSL_ENSURE(false,
477         "SwXBookmark::addPropertyChangeListener(): not implemented");
478 }
479 
480 void SAL_CALL
481 SwXBookmark::removePropertyChangeListener(
482         const ::rtl::OUString& /*rPropertyName*/,
483         const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
484 throw (beans::UnknownPropertyException, lang::WrappedTargetException,
485     uno::RuntimeException)
486 {
487     OSL_ENSURE(false,
488         "SwXBookmark::removePropertyChangeListener(): not implemented");
489 }
490 
491 void SAL_CALL
492 SwXBookmark::addVetoableChangeListener(
493         const ::rtl::OUString& /*rPropertyName*/,
494         const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
495 throw (beans::UnknownPropertyException, lang::WrappedTargetException,
496     uno::RuntimeException)
497 {
498     OSL_ENSURE(false,
499         "SwXBookmark::addVetoableChangeListener(): not implemented");
500 }
501 
502 void SAL_CALL
503 SwXBookmark::removeVetoableChangeListener(
504         const ::rtl::OUString& /*rPropertyName*/,
505         const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
506 throw (beans::UnknownPropertyException, lang::WrappedTargetException,
507         uno::RuntimeException)
508 {
509     OSL_ENSURE(false,
510         "SwXBookmark::removeVetoableChangeListener(): not implemented");
511 }
512 
513 /******************************************************************
514  * SwXFieldmark
515  ******************************************************************/
516 
517 SwXFieldmark::SwXFieldmark(bool _isReplacementObject, ::sw::mark::IMark* pBkm, SwDoc* pDc)
518     : SwXFieldmark_Base(pBkm, pDc)
519     , isReplacementObject(_isReplacementObject)
520 { }
521 
522 void SwXFieldmarkParameters::insertByName(const OUString& aName, const uno::Any& aElement)
523     throw (lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException)
524 {
525     vos::OGuard aGuard(Application::GetSolarMutex());
526     IFieldmark::parameter_map_t* pParameters = getCoreParameters();
527     if(pParameters->find(aName) != pParameters->end())
528         throw container::ElementExistException();
529     (*pParameters)[aName] = aElement;
530 }
531 
532 void SwXFieldmarkParameters::removeByName(const OUString& aName)
533     throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
534 {
535     vos::OGuard aGuard(Application::GetSolarMutex());
536     if(!getCoreParameters()->erase(aName))
537         throw container::NoSuchElementException();
538 }
539 
540 void SwXFieldmarkParameters::replaceByName(const OUString& aName, const uno::Any& aElement)
541     throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
542 {
543     vos::OGuard aGuard(Application::GetSolarMutex());
544     IFieldmark::parameter_map_t* pParameters = getCoreParameters();
545     IFieldmark::parameter_map_t::iterator pEntry = pParameters->find(aName);
546     if(pEntry == pParameters->end())
547         throw container::NoSuchElementException();
548     pEntry->second = aElement;
549 }
550 
551 uno::Any SwXFieldmarkParameters::getByName(const OUString& aName)
552     throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
553 {
554     vos::OGuard aGuard(Application::GetSolarMutex());
555     IFieldmark::parameter_map_t* pParameters = getCoreParameters();
556     IFieldmark::parameter_map_t::iterator pEntry = pParameters->find(aName);
557     if(pEntry == pParameters->end())
558         throw container::NoSuchElementException();
559     return pEntry->second;
560 }
561 
562 uno::Sequence<OUString> SwXFieldmarkParameters::getElementNames()
563     throw (uno::RuntimeException)
564 {
565     vos::OGuard aGuard(Application::GetSolarMutex());
566     IFieldmark::parameter_map_t* pParameters = getCoreParameters();
567     uno::Sequence<OUString> vResult(pParameters->size());
568     OUString* pOutEntry = vResult.getArray();
569     for(IFieldmark::parameter_map_t::iterator pEntry = pParameters->begin(); pEntry!=pParameters->end(); ++pEntry, ++pOutEntry)
570         *pOutEntry = pEntry->first;
571     return vResult;
572 }
573 
574 ::sal_Bool SwXFieldmarkParameters::hasByName(const OUString& aName)
575     throw (uno::RuntimeException)
576 {
577     vos::OGuard aGuard(Application::GetSolarMutex());
578     IFieldmark::parameter_map_t* pParameters = getCoreParameters();
579     return (pParameters->find(aName) != pParameters->end());
580 }
581 
582 uno::Type SwXFieldmarkParameters::getElementType()
583     throw (uno::RuntimeException)
584 {
585     return ::cppu::UnoType< ::cppu::UnoVoidType>::get();
586 }
587 
588 ::sal_Bool SwXFieldmarkParameters::hasElements()
589     throw (uno::RuntimeException)
590 {
591     vos::OGuard aGuard(Application::GetSolarMutex());
592     return !getCoreParameters()->empty();
593 }
594 
595 void SwXFieldmarkParameters::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew)
596 {
597     ClientModify(this, pOld, pNew);
598 }
599 
600 
601 IFieldmark::parameter_map_t* SwXFieldmarkParameters::getCoreParameters()
602     throw (uno::RuntimeException)
603 {
604     const IFieldmark* pFieldmark = dynamic_cast< const IFieldmark* >(GetRegisteredIn());
605     if(!pFieldmark)
606         throw uno::RuntimeException();
607     return const_cast< IFieldmark* >(pFieldmark)->GetParameters();
608 }
609 
610 
611 void SwXFieldmark::attachToRange( const uno::Reference < text::XTextRange >& xTextRange )
612     throw(lang::IllegalArgumentException, uno::RuntimeException)
613 {
614     attachToRangeEx( xTextRange,
615                      ( isReplacementObject ? IDocumentMarkAccess::CHECKBOX_FIELDMARK : IDocumentMarkAccess::TEXT_FIELDMARK ) );
616 }
617 
618 ::rtl::OUString SwXFieldmark::getFieldType(void)
619     throw(uno::RuntimeException)
620 {
621     vos::OGuard aGuard(Application::GetSolarMutex());
622     const IFieldmark *pBkm = dynamic_cast<const IFieldmark*>(GetBookmark());
623     if(!pBkm)
624         throw uno::RuntimeException();
625     return pBkm->GetFieldname();
626 }
627 
628 void SwXFieldmark::setFieldType(const::rtl::OUString & fieldType)
629     throw(uno::RuntimeException)
630 {
631     vos::OGuard aGuard(Application::GetSolarMutex());
632     IFieldmark *pBkm = const_cast<IFieldmark*>(
633         dynamic_cast<const IFieldmark*>(GetBookmark()));
634     if(!pBkm)
635         throw uno::RuntimeException();
636     pBkm->SetFieldname(fieldType);
637 }
638 
639 uno::Reference<container::XNameContainer> SwXFieldmark::getParameters()
640     throw (uno::RuntimeException)
641 {
642     vos::OGuard aGuard(Application::GetSolarMutex());
643     IFieldmark *pBkm = const_cast<IFieldmark*>(
644         dynamic_cast<const IFieldmark*>(GetBookmark()));
645     if(!pBkm)
646         throw uno::RuntimeException();
647     return uno::Reference<container::XNameContainer>(new SwXFieldmarkParameters(pBkm));
648 }
649 
650