LibreOffice Module sw (master)  1
unobkm.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <unobookmark.hxx>
21 
23 #include <comphelper/sequence.hxx>
26 #include <osl/mutex.hxx>
27 #include <svl/itemprop.hxx>
28 #include <svl/listener.hxx>
29 #include <vcl/svapp.hxx>
30 #include <xmloff/odffields.hxx>
31 
32 #include <TextCursorHelper.hxx>
33 #include <unotextrange.hxx>
34 #include <unomap.hxx>
35 #include <unoprnms.hxx>
36 #include <IMark.hxx>
37 #include <crossrefbookmark.hxx>
38 #include <doc.hxx>
39 #include <IDocumentState.hxx>
40 #include <docary.hxx>
41 #include <swundo.hxx>
42 #include <docsh.hxx>
43 
44 using namespace ::sw::mark;
45 using namespace ::com::sun::star;
46 
48  : public SvtListener
49 {
50 private:
51  ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
52 
53 public:
54  uno::WeakReference<uno::XInterface> m_wThis;
58  OUString m_sMarkName;
59  bool m_bHidden;
60  OUString m_HideCondition;
61 
62  Impl( SwDoc *const pDoc )
63  : m_EventListeners(m_Mutex)
64  , m_pDoc(pDoc)
65  , m_pRegisteredBookmark(nullptr)
66  , m_bHidden(false)
67  {
68  // DO NOT registerInMark here! (because SetXBookmark would delete rThis)
69  }
70 
71  void registerInMark(SwXBookmark & rThis, ::sw::mark::IMark *const pBkmk);
72 protected:
73  virtual void Notify(const SfxHint&) override;
74 
75 };
76 
78 {
79  if(rHint.GetId() == SfxHintId::Dying)
80  {
81  m_pRegisteredBookmark = nullptr;
82  m_pDoc = nullptr;
83  uno::Reference<uno::XInterface> const xThis(m_wThis);
84  if (!xThis.is())
85  { // fdo#72695: if UNO object is already dead, don't revive it with event
86  return;
87  }
88  lang::EventObject const ev(xThis);
90  }
91 }
92 
94  ::sw::mark::IMark* const pBkmk)
95 {
96  const uno::Reference<text::XTextContent> xBookmark(&rThis);
97  if (pBkmk)
98  {
99  EndListeningAll();
100  StartListening(pBkmk->GetNotifier());
101  ::sw::mark::MarkBase *const pMarkBase(dynamic_cast< ::sw::mark::MarkBase * >(pBkmk));
102  OSL_ENSURE(pMarkBase, "registerInMark: no MarkBase?");
103  if (pMarkBase)
104  {
105  pMarkBase->SetXBookmark(xBookmark);
106  }
107  }
108  else if (m_pRegisteredBookmark)
109  {
110  m_sMarkName = m_pRegisteredBookmark->GetName();
111 
112  // the following applies only to bookmarks (not to fieldmarks)
113  IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pRegisteredBookmark);
114  if (pBookmark)
115  {
116  m_bHidden = pBookmark->IsHidden();
117  m_HideCondition = pBookmark->GetHideCondition();
118  }
119  EndListeningAll();
120  }
121  m_pRegisteredBookmark = pBkmk;
122  // need a permanent Reference to initialize m_wThis
123  m_wThis = xBookmark;
124 }
125 
127  ::sw::mark::IMark *const pBkmk)
128 {
129  m_pImpl->registerInMark( rThis, pBkmk );
130 }
131 
132 const ::sw::mark::IMark* SwXBookmark::GetBookmark() const
133 {
134  return m_pImpl->m_pRegisteredBookmark;
135 }
136 
138 {
139  return m_pImpl->m_pDoc->getIDocumentMarkAccess();
140 }
141 
143  : m_pImpl( new SwXBookmark::Impl(pDoc) )
144 {
145 }
146 
148  : m_pImpl( new SwXBookmark::Impl(nullptr) )
149 {
150 }
151 
153 {
154 }
155 
156 uno::Reference<text::XTextContent> SwXBookmark::CreateXBookmark(
157  SwDoc & rDoc,
158  ::sw::mark::IMark *const pBookmark)
159 {
160  // #i105557#: do not iterate over the registered clients: race condition
161  ::sw::mark::MarkBase *const pMarkBase(dynamic_cast< ::sw::mark::MarkBase * >(pBookmark));
162  OSL_ENSURE(!pBookmark || pMarkBase, "CreateXBookmark: no MarkBase?");
163  uno::Reference<text::XTextContent> xBookmark;
164  if (pMarkBase)
165  {
166  xBookmark = pMarkBase->GetXBookmark();
167  }
168  if (!xBookmark.is())
169  {
170  OSL_ENSURE(!pBookmark ||
171  dynamic_cast< ::sw::mark::IBookmark* >(pBookmark) ||
173  "<SwXBookmark::GetObject(..)>"
174  "SwXBookmark requested for non-bookmark mark and non-annotation mark.");
175  SwXBookmark *const pXBookmark =
176  pBookmark ? new SwXBookmark(&rDoc) : new SwXBookmark;
177  xBookmark.set(pXBookmark);
178  pXBookmark->m_pImpl->registerInMark(*pXBookmark, pMarkBase);
179  }
180  return xBookmark;
181 }
182 
184  const uno::Reference< lang::XUnoTunnel> & xUT)
185 {
186  SwXBookmark *const pXBkm(
187  ::sw::UnoTunnelGetImplementation<SwXBookmark>(xUT));
188  if (pXBkm && (pDoc == pXBkm->m_pImpl->m_pDoc))
189  {
190  return pXBkm->m_pImpl->m_pRegisteredBookmark;
191  }
192  return nullptr;
193 }
194 
195 namespace
196 {
197  class theSwXBookmarkUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXBookmarkUnoTunnelId > {};
198 }
199 
200 const uno::Sequence< sal_Int8 > & SwXBookmark::getUnoTunnelId()
201 {
202  return theSwXBookmarkUnoTunnelId::get().getSeq();
203 }
204 
205 sal_Int64 SAL_CALL SwXBookmark::getSomething( const uno::Sequence< sal_Int8 >& rId )
206 {
207  return ::sw::UnoTunnelImpl<SwXBookmark>(rId, this);
208 }
209 
211  const uno::Reference< text::XTextRange > & xTextRange,
213 {
214  if (m_pImpl->m_pRegisteredBookmark)
215  {
216  throw uno::RuntimeException();
217  }
218 
219  const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
220  xTextRange, uno::UNO_QUERY);
221  SwXTextRange* pRange = nullptr;
222  OTextCursorHelper* pCursor = nullptr;
223  if(xRangeTunnel.is())
224  {
225  pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
226  pCursor =
227  ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
228  }
229 
230  SwDoc *const pDoc =
231  pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr);
232  if (!pDoc)
233  {
234  throw lang::IllegalArgumentException();
235  }
236 
237  m_pImpl->m_pDoc = pDoc;
238  SwUnoInternalPaM aPam(*m_pImpl->m_pDoc);
239  ::sw::XTextRangeToSwPaM(aPam, xTextRange);
240  UnoActionContext aCont(m_pImpl->m_pDoc);
241  if (m_pImpl->m_sMarkName.isEmpty())
242  {
243  m_pImpl->m_sMarkName = "Bookmark";
244  }
247  {
249  }
250  else if ((eType == IDocumentMarkAccess::MarkType::BOOKMARK) &&
253  {
255  }
256  m_pImpl->registerInMark(*this,
257  m_pImpl->m_pDoc->getIDocumentMarkAccess()->makeMark(
258  aPam, m_pImpl->m_sMarkName, eType, ::sw::mark::InsertMode::New));
259  // #i81002#
260  // Check, if bookmark has been created.
261  // E.g., the creation of a cross-reference bookmark is suppress,
262  // if the PaM isn't a valid one for cross-reference bookmarks.
263  if (!m_pImpl->m_pRegisteredBookmark)
264  {
265  OSL_FAIL("<SwXBookmark::attachToRange(..)>"
266  " - could not create Mark.");
267  throw lang::IllegalArgumentException();
268  }
269 }
270 
271 void SwXBookmark::attachToRange( const uno::Reference< text::XTextRange > & xTextRange )
272 {
274 }
275 
276 void SAL_CALL SwXBookmark::attach( const uno::Reference< text::XTextRange > & xTextRange )
277 {
278  SolarMutexGuard aGuard;
279  attachToRange( xTextRange );
280 }
281 
282 uno::Reference< text::XTextRange > SAL_CALL SwXBookmark::getAnchor()
283 {
284  SolarMutexGuard aGuard;
285 
286  if (!m_pImpl->m_pRegisteredBookmark)
287  {
288  throw uno::RuntimeException();
289  }
291  *m_pImpl->m_pDoc,
292  m_pImpl->m_pRegisteredBookmark->GetMarkPos(),
293  (m_pImpl->m_pRegisteredBookmark->IsExpanded())
294  ? &m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos() : nullptr);
295 }
296 
297 void SAL_CALL SwXBookmark::dispose()
298 {
299  SolarMutexGuard aGuard;
300  if (m_pImpl->m_pRegisteredBookmark)
301  {
302  m_pImpl->m_pDoc->getIDocumentMarkAccess()->deleteMark( m_pImpl->m_pRegisteredBookmark );
303  }
304 }
305 
307  const uno::Reference< lang::XEventListener > & xListener)
308 {
309  // no need to lock here as m_pImpl is const and container threadsafe
310  m_pImpl->m_EventListeners.addInterface(xListener);
311 }
312 
314  const uno::Reference< lang::XEventListener > & xListener)
315 {
316  // no need to lock here as m_pImpl is const and container threadsafe
317  m_pImpl->m_EventListeners.removeInterface(xListener);
318 }
319 
320 OUString SAL_CALL SwXBookmark::getName()
321 {
322  SolarMutexGuard aGuard;
323 
324  return (m_pImpl->m_pRegisteredBookmark)
325  ? m_pImpl->m_pRegisteredBookmark->GetName()
326  : m_pImpl->m_sMarkName;
327 }
328 
329 void SAL_CALL SwXBookmark::setName(const OUString& rName)
330 {
331  SolarMutexGuard aGuard;
332 
333  if (!m_pImpl->m_pRegisteredBookmark)
334  {
335  m_pImpl->m_sMarkName = rName;
336  }
337  if (!m_pImpl->m_pRegisteredBookmark || (getName() == rName))
338  {
339  return;
340  }
341  IDocumentMarkAccess *const pMarkAccess =
342  m_pImpl->m_pDoc->getIDocumentMarkAccess();
343  if(pMarkAccess->findMark(rName) != pMarkAccess->getAllMarksEnd())
344  {
345  throw uno::RuntimeException();
346  }
347 
348  SwPaM aPam(m_pImpl->m_pRegisteredBookmark->GetMarkPos());
349  if (m_pImpl->m_pRegisteredBookmark->IsExpanded())
350  {
351  aPam.SetMark();
352  *aPam.GetMark() = m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos();
353  }
354 
355  pMarkAccess->renameMark(m_pImpl->m_pRegisteredBookmark, rName);
356 }
357 
358 OUString SAL_CALL
360 {
361  return "SwXBookmark";
362 }
363 
364 sal_Bool SAL_CALL SwXBookmark::supportsService(const OUString& rServiceName)
365 {
366  return cppu::supportsService(this, rServiceName);
367 }
368 
369 uno::Sequence< OUString > SAL_CALL
371 {
372  return {
373  "com.sun.star.text.TextContent",
374  "com.sun.star.text.Bookmark",
375  "com.sun.star.document.LinkTarget"
376  };
377 }
378 
379 // MetadatableMixin
381 {
382  return dynamic_cast< ::sfx2::Metadatable* >(m_pImpl->m_pRegisteredBookmark);
383 }
384 
385 uno::Reference<frame::XModel> SwXBookmark::GetModel()
386 {
387  if (m_pImpl->m_pDoc)
388  {
389  SwDocShell const * const pShell( m_pImpl->m_pDoc->GetDocShell() );
390  return pShell ? pShell->GetModel() : nullptr;
391  }
392  return nullptr;
393 }
394 
395 uno::Reference< beans::XPropertySetInfo > SAL_CALL
397 {
398  SolarMutexGuard g;
399 
400  static uno::Reference< beans::XPropertySetInfo > xRef(
402  ->getPropertySetInfo() );
403  return xRef;
404 }
405 
406 void SAL_CALL
407 SwXBookmark::setPropertyValue(const OUString& PropertyName,
408  const uno::Any& rValue)
409 {
410  if (PropertyName == UNO_NAME_BOOKMARK_HIDDEN)
411  {
412  bool bNewValue = false;
413  if (!(rValue >>= bNewValue))
414  throw lang::IllegalArgumentException("Property BookmarkHidden requires value of type boolean", nullptr, 0);
415 
416  IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pImpl->m_pRegisteredBookmark);
417  if (pBookmark)
418  {
419  pBookmark->Hide(bNewValue);
420  }
421  else
422  {
423  m_pImpl->m_bHidden = bNewValue;
424  }
425  return;
426  }
427  else if (PropertyName == UNO_NAME_BOOKMARK_CONDITION)
428  {
429  OUString newValue;
430  if (!(rValue >>= newValue))
431  throw lang::IllegalArgumentException("Property BookmarkCondition requires value of type string", nullptr, 0);
432 
433  IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pImpl->m_pRegisteredBookmark);
434  if (pBookmark)
435  {
436  pBookmark->SetHideCondition(newValue);
437  }
438  else
439  {
440  m_pImpl->m_HideCondition = newValue;
441  }
442  return;
443  }
444 
445  // nothing to set here
446  throw lang::IllegalArgumentException("Property is read-only: "
447  + PropertyName, static_cast< cppu::OWeakObject * >(this), 0 );
448 }
449 
450 uno::Any SAL_CALL SwXBookmark::getPropertyValue(const OUString& rPropertyName)
451 {
452  SolarMutexGuard g;
453 
454  uno::Any aRet;
455  if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName))
456  {
457  if(rPropertyName == UNO_LINK_DISPLAY_NAME)
458  {
459  aRet <<= getName();
460  }
461  else if (rPropertyName == UNO_NAME_BOOKMARK_HIDDEN)
462  {
463  IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pImpl->m_pRegisteredBookmark);
464  if (pBookmark)
465  {
466  aRet <<= pBookmark->IsHidden();
467  }
468  else
469  {
470  aRet <<= m_pImpl->m_bHidden;
471  }
472  }
473  else if (rPropertyName == UNO_NAME_BOOKMARK_CONDITION)
474  {
475  IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pImpl->m_pRegisteredBookmark);
476  if (pBookmark)
477  {
478  aRet <<= pBookmark->GetHideCondition();
479  }
480  else
481  {
482  aRet <<= m_pImpl->m_HideCondition;
483  }
484  }
485  }
486  return aRet;
487 }
488 
489 void SAL_CALL
491  const OUString& /*rPropertyName*/,
492  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
493 {
494  OSL_FAIL("SwXBookmark::addPropertyChangeListener(): not implemented");
495 }
496 
497 void SAL_CALL
499  const OUString& /*rPropertyName*/,
500  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
501 {
502  OSL_FAIL("SwXBookmark::removePropertyChangeListener(): not implemented");
503 }
504 
505 void SAL_CALL
507  const OUString& /*rPropertyName*/,
508  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
509 {
510  OSL_FAIL("SwXBookmark::addVetoableChangeListener(): not implemented");
511 }
512 
513 void SAL_CALL
515  const OUString& /*rPropertyName*/,
516  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
517 {
518  OSL_FAIL("SwXBookmark::removeVetoableChangeListener(): not implemented");
519 }
520 
521 SwXFieldmark::SwXFieldmark(bool _isReplacementObject, SwDoc* pDc)
522  : SwXFieldmark_Base(pDc)
523  , isReplacementObject(_isReplacementObject)
524 { }
525 
526 void SwXFieldmarkParameters::insertByName(const OUString& aName, const uno::Any& aElement)
527 {
528  SolarMutexGuard aGuard;
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 {
537  SolarMutexGuard aGuard;
538  if(!getCoreParameters()->erase(aName))
539  throw container::NoSuchElementException();
540 }
541 
542 void SwXFieldmarkParameters::replaceByName(const OUString& aName, const uno::Any& aElement)
543 {
544  SolarMutexGuard aGuard;
545  IFieldmark::parameter_map_t* pParameters = getCoreParameters();
546  IFieldmark::parameter_map_t::iterator pEntry = pParameters->find(aName);
547  if(pEntry == pParameters->end())
548  throw container::NoSuchElementException();
549  pEntry->second = aElement;
550 }
551 
553 {
554  SolarMutexGuard aGuard;
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 
563 {
564  SolarMutexGuard aGuard;
565  IFieldmark::parameter_map_t* pParameters = getCoreParameters();
566  return comphelper::mapKeysToSequence(*pParameters);
567 }
568 
570 {
571  SolarMutexGuard aGuard;
572  IFieldmark::parameter_map_t* pParameters = getCoreParameters();
573  return (pParameters->find(aName) != pParameters->end());
574 }
575 
577 {
579 }
580 
582 {
583  SolarMutexGuard aGuard;
584  return !getCoreParameters()->empty();
585 }
586 
588 {
589  if(rHint.GetId() == SfxHintId::Dying)
590  m_pFieldmark = nullptr;
591 }
592 
593 IFieldmark::parameter_map_t* SwXFieldmarkParameters::getCoreParameters()
594 {
595  if(!m_pFieldmark)
596  throw uno::RuntimeException();
597  return m_pFieldmark->GetParameters();
598 }
599 
600 void SwXFieldmark::attachToRange( const uno::Reference < text::XTextRange >& xTextRange )
601 {
602 
603  attachToRangeEx( xTextRange,
605 }
606 
608 {
609  SolarMutexGuard aGuard;
610  const IFieldmark *pBkm = dynamic_cast<const IFieldmark*>(GetBookmark());
611  if(!pBkm)
612  throw uno::RuntimeException();
613  return pBkm->GetFieldname();
614 }
615 
616 void SwXFieldmark::setFieldType(const OUString & fieldType)
617 {
618  SolarMutexGuard aGuard;
619  IFieldmark *pBkm = const_cast<IFieldmark*>(
620  dynamic_cast<const IFieldmark*>(GetBookmark()));
621  if(!pBkm)
622  throw uno::RuntimeException();
623  if(fieldType != getFieldType())
624  {
625  if(fieldType == ODF_FORMDROPDOWN || fieldType == ODF_FORMCHECKBOX || fieldType == ODF_FORMDATE)
626  {
627  ::sw::mark::IFieldmark* pNewFieldmark = GetIDocumentMarkAccess()->changeFormFieldmarkType(pBkm, fieldType);
628  if (pNewFieldmark)
629  {
630  registerInMark(*this, pNewFieldmark);
631  return;
632  }
633  }
634 
635  // We did not generate a new fieldmark, so set the type ID
636  pBkm->SetFieldname(fieldType);
637  }
638 }
639 
640 uno::Reference<container::XNameContainer> SwXFieldmark::getParameters()
641 {
642  SolarMutexGuard aGuard;
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 uno::Reference<text::XTextContent>
652  bool const isReplacementObject)
653 {
654  // #i105557#: do not iterate over the registered clients: race condition
655  ::sw::mark::MarkBase *const pMarkBase(
656  dynamic_cast< ::sw::mark::MarkBase * >(pMark));
657  assert(!pMark || pMarkBase);
658  uno::Reference<text::XTextContent> xMark;
659  if (pMarkBase)
660  {
661  xMark = pMarkBase->GetXBookmark();
662  }
663  if (!xMark.is())
664  {
665  // FIXME: These belong in XTextFieldsSupplier
666  SwXFieldmark* pXBkmk = nullptr;
667  if (dynamic_cast< ::sw::mark::TextFieldmark* >(pMark))
668  pXBkmk = new SwXFieldmark(false, &rDoc);
669  else if (dynamic_cast< ::sw::mark::CheckboxFieldmark* >(pMark))
670  pXBkmk = new SwXFieldmark(true, &rDoc);
671  else if (dynamic_cast< ::sw::mark::DropDownFieldmark* >(pMark))
672  pXBkmk = new SwXFieldmark(true, &rDoc);
673  else if (dynamic_cast< ::sw::mark::DateFieldmark* >(pMark))
674  pXBkmk = new SwXFieldmark(false, &rDoc);
675  else
676  pXBkmk = new SwXFieldmark(isReplacementObject, &rDoc);
677 
678  xMark.set(pXBkmk);
679  pXBkmk->registerInMark(*pXBkmk, pMarkBase);
680  }
681  return xMark;
682 }
683 
686 {
687  ::sw::mark::ICheckboxFieldmark* pCheckboxFm = nullptr;
688  if ( getFieldType() == ODF_FORMCHECKBOX )
689  {
690  // evil #TODO #FIXME casting away the const-ness
691  pCheckboxFm = const_cast<sw::mark::ICheckboxFieldmark*>(dynamic_cast< const ::sw::mark::ICheckboxFieldmark* >( GetBookmark()));
692  assert( GetBookmark() == nullptr || pCheckboxFm != nullptr );
693  // unclear to me whether GetBookmark() can be null here
694  }
695  return pCheckboxFm;
696 
697 }
698 
699 // support 'hidden' "Checked" property ( note: this property is just for convenience to support
700 // docx import filter thus not published via PropertySet info )
701 
702 void SAL_CALL
703 SwXFieldmark::setPropertyValue(const OUString& PropertyName,
704  const uno::Any& rValue)
705 {
706  SolarMutexGuard g;
707  if ( PropertyName == "Checked" )
708  {
710  bool bChecked( false );
711  if ( !(pCheckboxFm && ( rValue >>= bChecked )) )
712  throw uno::RuntimeException();
713 
714  pCheckboxFm->SetChecked( bChecked );
715  }
716  else
717  SwXFieldmark_Base::setPropertyValue( PropertyName, rValue );
718 }
719 
720 // support 'hidden' "Checked" property ( note: this property is just for convenience to support
721 // docx import filter thus not published via PropertySet info )
722 
723 uno::Any SAL_CALL SwXFieldmark::getPropertyValue(const OUString& rPropertyName)
724 {
725  SolarMutexGuard g;
726  if ( rPropertyName == "Checked" )
727  {
729  if ( !pCheckboxFm )
730  throw uno::RuntimeException();
731 
732  return uno::makeAny( pCheckboxFm->IsChecked() );
733  }
734  return SwXFieldmark_Base::getPropertyValue( rPropertyName );
735 }
736 
737 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
::comphelper::OInterfaceContainerHelper2 m_EventListeners
Definition: unobkm.cxx:55
::osl::Mutex m_Mutex
Definition: unobkm.cxx:51
virtual const SwDoc * GetDoc() const =0
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unobkm.cxx:200
SwDoc * m_pDoc
Definition: unobkm.cxx:56
SwXFieldmark(bool isReplacementObject, SwDoc *pDoc)
Definition: unobkm.cxx:521
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unobkm.cxx:576
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
Definition: docbm.cxx:483
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unobkm.cxx:450
IDocumentMarkAccess * GetIDocumentMarkAccess()
Definition: unobkm.cxx:137
Provides access to the marks of a document.
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
Definition: unomap1.cxx:1098
Definition: doc.hxx:185
#define ODF_FORMCHECKBOX
#define PROPERTY_MAP_BOOKMARK
Definition: unomap.hxx:52
::sw::mark::IMark * m_pRegisteredBookmark
Definition: unobkm.cxx:57
void disposeAndClear(const css::lang::EventObject &rEvt)
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unobkm.cxx:506
virtual css::uno::Reference< css::frame::XModel > GetModel() override
Definition: unobkm.cxx:385
css::uno::Reference< css::frame::XModel > GetModel() const
OUString m_sMarkName
Definition: unobkm.cxx:58
virtual ::sfx2::Metadatable * GetCoreObject() override
Definition: unobkm.cxx:380
::sw::mark::IFieldmark::parameter_map_t * getCoreParameters()
Definition: unobkm.cxx:593
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
static bool IsLegalName(const OUString &rName)
SfxHintId GetId() const
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unobkm.cxx:282
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unobkm.cxx:562
void registerInMark(SwXBookmark &rThis,::sw::mark::IMark *const pBkmk)
Definition: unobkm.cxx:93
const SwDoc & GetDoc() const
Definition: unoobj2.cxx:790
static SW_DLLPUBLIC bool IsLegalPaMForCrossRefHeadingBookmark(const SwPaM &rPaM)
Definition: docbm.cxx:522
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
bool GetDefaultTextContentValue(css::uno::Any &rAny, const OUString &rPropertyName, sal_uInt16 nWID=0)
virtual void SAL_CALL removeByName(const OUString &Name) override
Definition: unobkm.cxx:535
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
static css::uno::Reference< css::text::XTextContent > CreateXFieldmark(SwDoc &rDoc,::sw::mark::IMark *pMark, bool isReplacementObject=false)
Definition: unobkm.cxx:651
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unobkm.cxx:498
virtual parameter_map_t * GetParameters()=0
#define UNO_NAME_BOOKMARK_HIDDEN
Definition: unoprnms.hxx:347
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unobkm.cxx:723
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: unobkm.cxx:569
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange)
Definition: unoobj2.cxx:1009
SwXBookmark()
descriptor
Definition: unobkm.cxx:147
cppu::ImplInheritanceHelper< SwXBookmark, css::text::XFormField > SwXFieldmark_Base
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unobkm.cxx:276
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
static css::uno::Reference< css::text::XTextContent > CreateXBookmark(SwDoc &rDoc,::sw::mark::IMark *pBookmark)
Definition: unobkm.cxx:156
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unobkm.cxx:370
virtual bool IsChecked() const =0
virtual const_iterator_t getAllMarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of marks.
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unobkm.cxx:490
unsigned char sal_Bool
bool const isReplacementObject
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:313
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:306
virtual void SAL_CALL setFieldType(const OUString &description) override
Definition: unobkm.cxx:616
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: unobkm.cxx:542
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unobkm.cxx:703
uno::WeakReference< uno::XInterface > m_wThis
Definition: unobkm.cxx:54
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:93
virtual void Notify(const SfxHint &rHint) override
Definition: unobkm.cxx:587
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: unobkm.cxx:526
Impl(SwDoc *const pDoc)
Definition: unobkm.cxx:62
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unobkm.cxx:514
virtual sal_Bool SAL_CALL hasElements() override
Definition: unobkm.cxx:581
void registerInMark(SwXBookmark &rXMark,::sw::mark::IMark *const pMarkBase)
Definition: unobkm.cxx:126
virtual OUString SAL_CALL getFieldType() override
Definition: unobkm.cxx:607
virtual void SAL_CALL setName(const OUString &rName) override
Definition: unobkm.cxx:329
virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getParameters() override
Definition: unobkm.cxx:640
virtual ~SwXBookmark() override
Definition: unobkm.cxx:152
::sw::mark::ICheckboxFieldmark * getCheckboxFieldmark()
Definition: unobkm.cxx:685
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:131
::sw::mark::IMark const * GetBookmarkInDoc(SwDoc const *const pDoc, const css::uno::Reference< css::lang::XUnoTunnel > &xUT)
Definition: unobkm.cxx:183
#define UNO_LINK_DISPLAY_NAME
Definition: unoprnms.hxx:461
virtual OUString SAL_CALL getImplementationName() override
Definition: unobkm.cxx:359
#define UNO_NAME_BOOKMARK_CONDITION
Definition: unoprnms.hxx:348
virtual void attachToRange(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unobkm.cxx:600
void attachToRangeEx(const css::uno::Reference< css::text::XTextRange > &xTextRange, IDocumentMarkAccess::MarkType eType)
Definition: unobkm.cxx:210
#define ODF_FORMDATE
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unobkm.cxx:205
virtual bool renameMark(::sw::mark::IMark *io_pMark, const OUString &rNewName)=0
Renames an existing Mark, if possible.
virtual OUString SAL_CALL getName() override
Definition: unobkm.cxx:320
virtual void attachToRange(const css::uno::Reference< css::text::XTextRange > &xTextRange)
Definition: unobkm.cxx:271
OUString m_HideCondition
Definition: unobkm.cxx:60
const css::uno::WeakReference< css::text::XTextContent > & GetXBookmark() const
Definition: bookmrk.hxx:108
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:457
static bool IsLegalName(const OUString &rName)
static css::uno::Reference< css::text::XTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1113
virtual void SAL_CALL dispose() override
Definition: unobkm.cxx:297
virtual void SetChecked(bool checked)=0
const ::sw::mark::IMark * GetBookmark() const
Definition: unobkm.cxx:132
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: unobkm.cxx:552
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unobookmark.hxx:55
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unobkm.cxx:396
::sw::mark::IFieldmark * m_pFieldmark
virtual void Notify(const SfxHint &) override
Definition: unobkm.cxx:77
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unobkm.cxx:407
css::uno::Sequence< typename M::key_type > mapKeysToSequence(M const &map)
#define ODF_FORMDROPDOWN
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unobkm.cxx:364