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 OUString("SwXBookmark");
362 }
363 
364 static char const*const g_ServicesBookmark[] =
365 {
366  "com.sun.star.text.TextContent",
367  "com.sun.star.text.Bookmark",
368  "com.sun.star.document.LinkTarget",
369 };
371 
372 sal_Bool SAL_CALL SwXBookmark::supportsService(const OUString& rServiceName)
373 {
374  return cppu::supportsService(this, rServiceName);
375 }
376 
377 uno::Sequence< OUString > SAL_CALL
379 {
382 }
383 
384 // MetadatableMixin
386 {
387  return dynamic_cast< ::sfx2::Metadatable* >(m_pImpl->m_pRegisteredBookmark);
388 }
389 
390 uno::Reference<frame::XModel> SwXBookmark::GetModel()
391 {
392  if (m_pImpl->m_pDoc)
393  {
394  SwDocShell const * const pShell( m_pImpl->m_pDoc->GetDocShell() );
395  return pShell ? pShell->GetModel() : nullptr;
396  }
397  return nullptr;
398 }
399 
400 uno::Reference< beans::XPropertySetInfo > SAL_CALL
402 {
403  SolarMutexGuard g;
404 
405  static uno::Reference< beans::XPropertySetInfo > xRef(
407  ->getPropertySetInfo() );
408  return xRef;
409 }
410 
411 void SAL_CALL
412 SwXBookmark::setPropertyValue(const OUString& PropertyName,
413  const uno::Any& rValue)
414 {
415  if (PropertyName == UNO_NAME_BOOKMARK_HIDDEN)
416  {
417  bool bNewValue = false;
418  if (!(rValue >>= bNewValue))
419  throw lang::IllegalArgumentException("Property BookmarkHidden requires value of type boolean", nullptr, 0);
420 
421  IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pImpl->m_pRegisteredBookmark);
422  if (pBookmark)
423  {
424  pBookmark->Hide(bNewValue);
425  }
426  else
427  {
428  m_pImpl->m_bHidden = bNewValue;
429  }
430  return;
431  }
432  else if (PropertyName == UNO_NAME_BOOKMARK_CONDITION)
433  {
434  OUString newValue;
435  if (!(rValue >>= newValue))
436  throw lang::IllegalArgumentException("Property BookmarkCondition requires value of type string", nullptr, 0);
437 
438  IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pImpl->m_pRegisteredBookmark);
439  if (pBookmark)
440  {
441  pBookmark->SetHideCondition(newValue);
442  }
443  else
444  {
445  m_pImpl->m_HideCondition = newValue;
446  }
447  return;
448  }
449 
450  // nothing to set here
451  throw lang::IllegalArgumentException("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 {
457  SolarMutexGuard g;
458 
459  uno::Any aRet;
460  if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName))
461  {
462  if(rPropertyName == UNO_LINK_DISPLAY_NAME)
463  {
464  aRet <<= getName();
465  }
466  else if (rPropertyName == UNO_NAME_BOOKMARK_HIDDEN)
467  {
468  IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pImpl->m_pRegisteredBookmark);
469  if (pBookmark)
470  {
471  aRet <<= pBookmark->IsHidden();
472  }
473  else
474  {
475  aRet <<= m_pImpl->m_bHidden;
476  }
477  }
478  else if (rPropertyName == UNO_NAME_BOOKMARK_CONDITION)
479  {
480  IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pImpl->m_pRegisteredBookmark);
481  if (pBookmark)
482  {
483  aRet <<= pBookmark->GetHideCondition();
484  }
485  else
486  {
487  aRet <<= m_pImpl->m_HideCondition;
488  }
489  }
490  }
491  return aRet;
492 }
493 
494 void SAL_CALL
496  const OUString& /*rPropertyName*/,
497  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
498 {
499  OSL_FAIL("SwXBookmark::addPropertyChangeListener(): not implemented");
500 }
501 
502 void SAL_CALL
504  const OUString& /*rPropertyName*/,
505  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
506 {
507  OSL_FAIL("SwXBookmark::removePropertyChangeListener(): not implemented");
508 }
509 
510 void SAL_CALL
512  const OUString& /*rPropertyName*/,
513  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
514 {
515  OSL_FAIL("SwXBookmark::addVetoableChangeListener(): not implemented");
516 }
517 
518 void SAL_CALL
520  const OUString& /*rPropertyName*/,
521  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
522 {
523  OSL_FAIL("SwXBookmark::removeVetoableChangeListener(): not implemented");
524 }
525 
526 SwXFieldmark::SwXFieldmark(bool _isReplacementObject, SwDoc* pDc)
527  : SwXFieldmark_Base(pDc)
528  , isReplacementObject(_isReplacementObject)
529 { }
530 
531 void SwXFieldmarkParameters::insertByName(const OUString& aName, const uno::Any& aElement)
532 {
533  SolarMutexGuard aGuard;
534  IFieldmark::parameter_map_t* pParameters = getCoreParameters();
535  if(pParameters->find(aName) != pParameters->end())
536  throw container::ElementExistException();
537  (*pParameters)[aName] = aElement;
538 }
539 
540 void SwXFieldmarkParameters::removeByName(const OUString& aName)
541 {
542  SolarMutexGuard aGuard;
543  if(!getCoreParameters()->erase(aName))
544  throw container::NoSuchElementException();
545 }
546 
547 void SwXFieldmarkParameters::replaceByName(const OUString& aName, const uno::Any& aElement)
548 {
549  SolarMutexGuard aGuard;
550  IFieldmark::parameter_map_t* pParameters = getCoreParameters();
551  IFieldmark::parameter_map_t::iterator pEntry = pParameters->find(aName);
552  if(pEntry == pParameters->end())
553  throw container::NoSuchElementException();
554  pEntry->second = aElement;
555 }
556 
558 {
559  SolarMutexGuard aGuard;
560  IFieldmark::parameter_map_t* pParameters = getCoreParameters();
561  IFieldmark::parameter_map_t::iterator pEntry = pParameters->find(aName);
562  if(pEntry == pParameters->end())
563  throw container::NoSuchElementException();
564  return pEntry->second;
565 }
566 
568 {
569  SolarMutexGuard aGuard;
570  IFieldmark::parameter_map_t* pParameters = getCoreParameters();
571  return comphelper::mapKeysToSequence(*pParameters);
572 }
573 
575 {
576  SolarMutexGuard aGuard;
577  IFieldmark::parameter_map_t* pParameters = getCoreParameters();
578  return (pParameters->find(aName) != pParameters->end());
579 }
580 
582 {
584 }
585 
587 {
588  SolarMutexGuard aGuard;
589  return !getCoreParameters()->empty();
590 }
591 
593 {
594  if(rHint.GetId() == SfxHintId::Dying)
595  m_pFieldmark = nullptr;
596 }
597 
598 IFieldmark::parameter_map_t* SwXFieldmarkParameters::getCoreParameters()
599 {
600  if(!m_pFieldmark)
601  throw uno::RuntimeException();
602  return m_pFieldmark->GetParameters();
603 }
604 
605 void SwXFieldmark::attachToRange( const uno::Reference < text::XTextRange >& xTextRange )
606 {
607 
608  attachToRangeEx( xTextRange,
610 }
611 
613 {
614  SolarMutexGuard aGuard;
615  const IFieldmark *pBkm = dynamic_cast<const IFieldmark*>(GetBookmark());
616  if(!pBkm)
617  throw uno::RuntimeException();
618  return pBkm->GetFieldname();
619 }
620 
621 void SwXFieldmark::setFieldType(const OUString & fieldType)
622 {
623  SolarMutexGuard aGuard;
624  IFieldmark *pBkm = const_cast<IFieldmark*>(
625  dynamic_cast<const IFieldmark*>(GetBookmark()));
626  if(!pBkm)
627  throw uno::RuntimeException();
628  if(fieldType != getFieldType())
629  {
630  if(fieldType == ODF_FORMDROPDOWN || fieldType == ODF_FORMCHECKBOX)
631  {
632  ::sw::mark::IFieldmark* pNewFieldmark = GetIDocumentMarkAccess()->changeNonTextFieldmarkType(pBkm, fieldType);
633  if (pNewFieldmark)
634  {
635  registerInMark(*this, pNewFieldmark);
636  return;
637  }
638  }
639 
640  // We did not generate a new fieldmark, so set the type ID
641  pBkm->SetFieldname(fieldType);
642  }
643 }
644 
645 uno::Reference<container::XNameContainer> SwXFieldmark::getParameters()
646 {
647  SolarMutexGuard aGuard;
648  IFieldmark *pBkm = const_cast<IFieldmark*>(
649  dynamic_cast<const IFieldmark*>(GetBookmark()));
650  if(!pBkm)
651  throw uno::RuntimeException();
652  return uno::Reference<container::XNameContainer>(new SwXFieldmarkParameters(pBkm));
653 }
654 
655 uno::Reference<text::XTextContent>
657  bool const isReplacementObject)
658 {
659  // #i105557#: do not iterate over the registered clients: race condition
660  ::sw::mark::MarkBase *const pMarkBase(
661  dynamic_cast< ::sw::mark::MarkBase * >(pMark));
662  assert(!pMark || pMarkBase);
663  uno::Reference<text::XTextContent> xMark;
664  if (pMarkBase)
665  {
666  xMark = pMarkBase->GetXBookmark();
667  }
668  if (!xMark.is())
669  {
670  // FIXME: These belong in XTextFieldsSupplier
671  SwXFieldmark* pXBkmk = nullptr;
672  if (dynamic_cast< ::sw::mark::TextFieldmark* >(pMark))
673  pXBkmk = new SwXFieldmark(false, &rDoc);
674  else if (dynamic_cast< ::sw::mark::CheckboxFieldmark* >(pMark))
675  pXBkmk = new SwXFieldmark(true, &rDoc);
676  else if (dynamic_cast< ::sw::mark::DropDownFieldmark* >(pMark))
677  pXBkmk = new SwXFieldmark(true, &rDoc);
678  else
679  pXBkmk = new SwXFieldmark(isReplacementObject, &rDoc);
680 
681  xMark.set(pXBkmk);
682  pXBkmk->registerInMark(*pXBkmk, pMarkBase);
683  }
684  return xMark;
685 }
686 
689 {
690  ::sw::mark::ICheckboxFieldmark* pCheckboxFm = nullptr;
691  if ( getFieldType() == ODF_FORMCHECKBOX )
692  {
693  // evil #TODO #FIXME casting away the const-ness
694  pCheckboxFm = const_cast<sw::mark::ICheckboxFieldmark*>(dynamic_cast< const ::sw::mark::ICheckboxFieldmark* >( GetBookmark()));
695  assert( GetBookmark() == nullptr || pCheckboxFm != nullptr );
696  // unclear to me whether GetBookmark() can be null here
697  }
698  return pCheckboxFm;
699 
700 }
701 
702 // support 'hidden' "Checked" property ( note: this property is just for convenience to support
703 // docx import filter thus not published via PropertySet info )
704 
705 void SAL_CALL
706 SwXFieldmark::setPropertyValue(const OUString& PropertyName,
707  const uno::Any& rValue)
708 {
709  SolarMutexGuard g;
710  if ( PropertyName == "Checked" )
711  {
713  bool bChecked( false );
714  if ( !(pCheckboxFm && ( rValue >>= bChecked )) )
715  throw uno::RuntimeException();
716 
717  pCheckboxFm->SetChecked( bChecked );
718  }
719  else
720  SwXFieldmark_Base::setPropertyValue( PropertyName, rValue );
721 }
722 
723 // support 'hidden' "Checked" property ( note: this property is just for convenience to support
724 // docx import filter thus not published via PropertySet info )
725 
726 uno::Any SAL_CALL SwXFieldmark::getPropertyValue(const OUString& rPropertyName)
727 {
728  SolarMutexGuard g;
729  if ( rPropertyName == "Checked" )
730  {
732  if ( !pCheckboxFm )
733  throw uno::RuntimeException();
734 
735  return uno::makeAny( pCheckboxFm->IsChecked() );
736  }
737  return SwXFieldmark_Base::getPropertyValue( rPropertyName );
738 }
739 
740 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
static char const *const g_ServicesBookmark[]
Definition: unobkm.cxx:364
::comphelper::OInterfaceContainerHelper2 m_EventListeners
Definition: unobkm.cxx:55
::osl::Mutex m_Mutex
Definition: unobkm.cxx:51
virtual const SwDoc * GetDoc() const =0
uno::Sequence< OUString > GetSupportedServiceNamesImpl(size_t const nServices, char const *const pServices[])
Definition: unoobj2.cxx:121
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:526
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unobkm.cxx:581
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
Definition: docbm.cxx:349
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unobkm.cxx:455
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:511
virtual css::uno::Reference< css::frame::XModel > GetModel() override
Definition: unobkm.cxx:390
css::uno::Reference< css::frame::XModel > GetModel() const
OUString m_sMarkName
Definition: unobkm.cxx:58
virtual ::sfx2::Metadatable * GetCoreObject() override
Definition: unobkm.cxx:385
::sw::mark::IFieldmark::parameter_map_t * getCoreParameters()
Definition: unobkm.cxx:598
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:567
void registerInMark(SwXBookmark &rThis,::sw::mark::IMark *const pBkmk)
Definition: unobkm.cxx:93
const SwDoc & GetDoc() const
Definition: unoobj2.cxx:806
static SW_DLLPUBLIC bool IsLegalPaMForCrossRefHeadingBookmark(const SwPaM &rPaM)
Definition: docbm.cxx:386
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:540
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:656
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unobkm.cxx:503
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:726
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: unobkm.cxx:574
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange)
Definition: unoobj2.cxx:1031
SwXBookmark()
descriptor
Definition: unobkm.cxx:147
#define SAL_N_ELEMENTS(arr)
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:378
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:495
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:621
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: unobkm.cxx:547
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unobkm.cxx:706
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:592
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: unobkm.cxx:531
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:519
virtual sal_Bool SAL_CALL hasElements() override
Definition: unobkm.cxx:586
void registerInMark(SwXBookmark &rXMark,::sw::mark::IMark *const pMarkBase)
Definition: unobkm.cxx:126
virtual OUString SAL_CALL getFieldType() override
Definition: unobkm.cxx:612
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:645
static const size_t g_nServicesBookmark(SAL_N_ELEMENTS(g_ServicesBookmark))
virtual ~SwXBookmark() override
Definition: unobkm.cxx:152
::sw::mark::ICheckboxFieldmark * getCheckboxFieldmark()
Definition: unobkm.cxx:688
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:605
void attachToRangeEx(const css::uno::Reference< css::text::XTextRange > &xTextRange, IDocumentMarkAccess::MarkType eType)
Definition: unobkm.cxx:210
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:107
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:1135
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:557
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unobookmark.hxx:55
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unobkm.cxx:401
::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:412
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:372