34#include <unoprnms.hxx>
72 if(rHint.
GetId() == SfxHintId::Dying)
76 uno::Reference<uno::XInterface>
const xThis(
m_wThis);
81 lang::EventObject
const ev(xThis);
82 std::unique_lock aGuard(
m_Mutex);
96 OSL_ENSURE(pMarkBase,
"registerInMark: no MarkBase?");
104 else if (m_pRegisteredBookmark)
106 m_sMarkName = m_pRegisteredBookmark->GetName();
109 IBookmark* pBookmark =
dynamic_cast<IBookmark*
>(m_pRegisteredBookmark);
112 m_bHidden = pBookmark->IsHidden();
113 m_HideCondition = pBookmark->GetHideCondition();
117 m_pRegisteredBookmark = pBkmk;
119 m_wThis = xBookmark.get();
125 m_pImpl->registerInMark( rThis, pBkmk );
130 return m_pImpl->m_pRegisteredBookmark;
135 return m_pImpl->m_pDoc->getIDocumentMarkAccess();
163 OSL_ENSURE(!pBookmark || pMarkBase,
"CreateXBookmark: no MarkBase?");
171 OSL_ENSURE(!pBookmark ||
174 "<SwXBookmark::GetObject(..)>"
175 "SwXBookmark requested for non-bookmark mark and non-annotation mark.");
178 xBookmark.set(pXBookmark);
179 pXBookmark->
m_pImpl->registerInMark(*pXBookmark, pMarkBase);
185 const uno::Reference<uno::XInterface> & xUT)
188 if (pXBkm && (pDoc == pXBkm->
m_pImpl->m_pDoc))
190 return pXBkm->
m_pImpl->m_pRegisteredBookmark;
196 const uno::Reference< text::XTextRange > & xTextRange,
198 bool const isFieldmarkSeparatorAtStart)
200 if (
m_pImpl->m_pRegisteredBookmark)
202 throw uno::RuntimeException();
206 OTextCursorHelper* pCursor =
dynamic_cast<OTextCursorHelper*
>(xTextRange.get());
209 pRange ? &pRange->
GetDoc() : (pCursor ? pCursor->GetDoc() :
nullptr);
212 throw lang::IllegalArgumentException();
219 if (
m_pImpl->m_sMarkName.isEmpty())
221 m_pImpl->m_sMarkName =
"Bookmark";
235 m_pImpl->m_pDoc->getIDocumentMarkAccess()->makeMark(
236 aPam,
m_pImpl->m_sMarkName,
eType, ::sw::mark::InsertMode::New,
239 isFieldmarkSeparatorAtStart ? aPam.
Start() :
nullptr));
244 if (!
m_pImpl->m_pRegisteredBookmark)
246 OSL_FAIL(
"<SwXBookmark::attachToRange(..)>"
247 " - could not create Mark.");
248 throw lang::IllegalArgumentException();
267 if (!
m_pImpl->m_pRegisteredBookmark)
269 throw uno::RuntimeException();
273 m_pImpl->m_pRegisteredBookmark->GetMarkPos(),
274 (
m_pImpl->m_pRegisteredBookmark->IsExpanded())
275 ? &
m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos() :
nullptr);
281 if (
m_pImpl->m_pRegisteredBookmark)
283 m_pImpl->m_pDoc->getIDocumentMarkAccess()->deleteMark(
m_pImpl->m_pRegisteredBookmark );
288 const uno::Reference< lang::XEventListener > & xListener)
291 std::unique_lock aGuard(
m_pImpl->m_Mutex);
292 m_pImpl->m_EventListeners.addInterface(aGuard, xListener);
296 const uno::Reference< lang::XEventListener > & xListener)
299 std::unique_lock aGuard(
m_pImpl->m_Mutex);
300 m_pImpl->m_EventListeners.removeInterface(aGuard, xListener);
307 return (
m_pImpl->m_pRegisteredBookmark)
308 ?
m_pImpl->m_pRegisteredBookmark->GetName()
316 if (!
m_pImpl->m_pRegisteredBookmark)
325 m_pImpl->m_pDoc->getIDocumentMarkAccess();
328 throw uno::RuntimeException(
"setName(): name already in use",
332 SwPaM aPam(
m_pImpl->m_pRegisteredBookmark->GetMarkPos());
333 if (
m_pImpl->m_pRegisteredBookmark->IsExpanded())
336 *aPam.
GetMark() =
m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos();
345 return "SwXBookmark";
353uno::Sequence< OUString > SAL_CALL
357 "com.sun.star.text.TextContent",
358 "com.sun.star.text.Bookmark",
359 "com.sun.star.document.LinkTarget"
366 return dynamic_cast< ::sfx2::Metadatable*
>(
m_pImpl->m_pRegisteredBookmark);
374 return pShell ? pShell->
GetModel() :
nullptr;
379uno::Reference< beans::XPropertySetInfo > SAL_CALL
384 static uno::Reference< beans::XPropertySetInfo > xRef(
398 bool bNewValue =
false;
399 if (!(rValue >>= bNewValue))
400 throw lang::IllegalArgumentException(
"Property BookmarkHidden requires value of type boolean",
nullptr, 0);
402 IBookmark* pBookmark =
dynamic_cast<IBookmark*
>(
m_pImpl->m_pRegisteredBookmark);
405 pBookmark->Hide(bNewValue);
409 m_pImpl->m_bHidden = bNewValue;
416 if (!(rValue >>= newValue))
417 throw lang::IllegalArgumentException(
"Property BookmarkCondition requires value of type string",
nullptr, 0);
419 IBookmark* pBookmark =
dynamic_cast<IBookmark*
>(
m_pImpl->m_pRegisteredBookmark);
422 pBookmark->SetHideCondition(newValue);
426 m_pImpl->m_HideCondition = newValue;
432 throw lang::IllegalArgumentException(
"Property is read-only: "
449 IBookmark* pBookmark =
dynamic_cast<IBookmark*
>(
m_pImpl->m_pRegisteredBookmark);
452 aRet <<= pBookmark->IsHidden();
461 IBookmark* pBookmark =
dynamic_cast<IBookmark*
>(
m_pImpl->m_pRegisteredBookmark);
464 aRet <<= pBookmark->GetHideCondition();
468 aRet <<=
m_pImpl->m_HideCondition;
478 const uno::Reference< beans::XPropertyChangeListener >& )
480 OSL_FAIL(
"SwXBookmark::addPropertyChangeListener(): not implemented");
486 const uno::Reference< beans::XPropertyChangeListener >& )
488 OSL_FAIL(
"SwXBookmark::removePropertyChangeListener(): not implemented");
494 const uno::Reference< beans::XVetoableChangeListener >& )
496 OSL_FAIL(
"SwXBookmark::addVetoableChangeListener(): not implemented");
502 const uno::Reference< beans::XVetoableChangeListener >& )
504 OSL_FAIL(
"SwXBookmark::removeVetoableChangeListener(): not implemented");
512 if(pParameters->find(
aName) != pParameters->end())
513 throw container::ElementExistException();
514 (*pParameters)[
aName] = aElement;
521 throw container::NoSuchElementException();
528 IFieldmark::parameter_map_t::iterator pEntry = pParameters->find(
aName);
529 if(pEntry == pParameters->end())
530 throw container::NoSuchElementException();
531 pEntry->second = aElement;
538 IFieldmark::parameter_map_t::iterator pEntry = pParameters->find(
aName);
539 if(pEntry == pParameters->end())
540 throw container::NoSuchElementException();
541 return pEntry->second;
555 return (pParameters->find(
aName) != pParameters->end());
571 if(rHint.
GetId() == SfxHintId::Dying)
578 throw uno::RuntimeException();
584 , m_bReplacementObject(isReplacementObject)
591 return "SwXFieldmark";
594uno::Sequence<OUString> SAL_CALL
600 return {
"com.sun.star.text.TextContent",
601 "com.sun.star.text.Bookmark",
602 "com.sun.star.text.FormFieldmark"};
606 return {
"com.sun.star.text.TextContent",
607 "com.sun.star.text.Bookmark",
608 "com.sun.star.text.Fieldmark"};
615 attachToRangeEx( xTextRange,
623 const IFieldmark *pBkm =
dynamic_cast<const IFieldmark*
>(GetBookmark());
625 throw uno::RuntimeException();
626 return pBkm->GetFieldname();
632 IFieldmark *pBkm =
dynamic_cast<IFieldmark*
>(GetBookmark());
634 throw uno::RuntimeException();
637 if (fieldType == oldFieldType)
643 ::sw::mark::IFieldmark* pNewFieldmark = GetIDocumentMarkAccess()->changeFormFieldmarkType(pBkm, fieldType);
646 registerInMark(*
this, pNewFieldmark);
657 pBkm->SetFieldname(fieldType);
661 throw uno::RuntimeException(
"changing to that type isn't implemented");
667 IFieldmark *pBkm =
dynamic_cast<IFieldmark*
>(GetBookmark());
669 throw uno::RuntimeException();
675 bool const isReplacementObject)
680 assert(!pMark || pMarkBase);
701 xMark = pXBkmk.get();
702 pXBkmk->registerInMark(*pXBkmk, pMarkBase);
714 assert( GetBookmark() ==
nullptr || pCheckboxFm !=
nullptr );
729 if ( PropertyName ==
"Checked" )
732 bool bChecked(
false );
733 if ( !(pCheckboxFm && ( rValue >>= bChecked )) )
734 throw uno::RuntimeException();
738 else if (PropertyName ==
"PrivateSeparatorAtStart")
740 bool isFieldmarkSeparatorAtStart{};
741 if (rValue >>= isFieldmarkSeparatorAtStart)
755 if ( rPropertyName ==
"Checked" )
759 throw uno::RuntimeException();
766uno::Reference<beans::XPropertySetInfo> SAL_CALL
771 static uno::Reference<beans::XPropertySetInfo>
const xRef(
783 uno::Reference<lang::XEventListener>
const& xListener)
788 uno::Reference<lang::XEventListener>
const& xListener)
795 uno::Reference<text::XTextRange>
const& xTextRange)
810 start.AdjustContent(1);
829 IFieldmark
const*
const pMark(
dynamic_cast<IFieldmark*
>(GetBookmark()));
832 throw lang::DisposedException();
843 uno::Reference<text::XTextRange>
const xCommand(
GetCommand(*pMark));
844 return xCommand->getString();
857 uno::Reference<text::XTextRange>
const xResult(
GetResult(*pMark));
858 return xResult->getString();
Provides access to the marks of a document.
virtual bool renameMark(::sw::mark::IMark *io_pMark, const OUString &rNewName)=0
Renames an existing Mark, if possible.
virtual const_iterator_t getAllMarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of marks.
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
@ CROSSREF_NUMITEM_BOOKMARK
@ CROSSREF_HEADING_BOOKMARK
static SW_DLLPUBLIC bool IsLegalPaMForCrossRefHeadingBookmark(const SwPaM &rPaM)
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
PaM is Point and Mark: a selection of the document model.
const SwPosition * GetMark() const
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
const SwPosition * Start() const
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
::comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_EventListeners
::sw::mark::IMark * m_pRegisteredBookmark
virtual void Notify(const SfxHint &) override
unotools::WeakReference< SwXBookmark > m_wThis
void registerInMark(SwXBookmark &rThis, ::sw::mark::IMark *const pBkmk)
UNO API wrapper around an internal sw::mark::IMark.
void registerInMark(SwXBookmark &rXMark, ::sw::mark::IMark *const pMarkBase)
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
virtual ~SwXBookmark() override
virtual css::uno::Reference< css::frame::XModel > GetModel() override
virtual OUString SAL_CALL getName() override
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
::sw::mark::IMark const * GetBookmarkInDoc(SwDoc const *const pDoc, const css::uno::Reference< css::uno::XInterface > &xUT)
virtual void SAL_CALL setName(const OUString &rName) override
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
static rtl::Reference< SwXBookmark > CreateXBookmark(SwDoc &rDoc, ::sw::mark::IMark *pBookmark)
virtual ::sfx2::Metadatable * GetCoreObject() override
void attachToRangeEx(const css::uno::Reference< css::text::XTextRange > &xTextRange, IDocumentMarkAccess::MarkType eType, bool isFieldmarkSeparatorAtStart=false)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual OUString SAL_CALL getImplementationName() override
virtual void attachToRange(const css::uno::Reference< css::text::XTextRange > &xTextRange)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
IDocumentMarkAccess * GetIDocumentMarkAccess()
virtual void SAL_CALL dispose() override
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
::sw::mark::IMark * GetBookmark() const
::sw::UnoImplPtr< Impl > m_pImpl
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
virtual css::uno::Type SAL_CALL getElementType() override
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
virtual void Notify(const SfxHint &rHint) override
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
virtual sal_Bool SAL_CALL hasElements() override
virtual void SAL_CALL removeByName(const OUString &Name) override
::sw::mark::IFieldmark::parameter_map_t * getCoreParameters()
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
::sw::mark::IFieldmark * m_pFieldmark
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
::sw::mark::ICheckboxFieldmark * getCheckboxFieldmark()
virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override
rtl::Reference< SwXTextRange > GetResult(::sw::mark::IFieldmark const &rMark)
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
rtl::Reference< SwXTextRange > GetCommand(::sw::mark::IFieldmark const &rMark)
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
bool m_isFieldmarkSeparatorAtStart
static rtl::Reference< SwXBookmark > CreateXFieldmark(SwDoc &rDoc, ::sw::mark::IMark *pMark, bool isReplacementObject=false)
bool const m_bReplacementObject
SwXFieldmark(bool isReplacementObject, SwDoc *pDoc)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void attachToRange(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getParameters() override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL setFieldType(const OUString &description) override
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
virtual void SAL_CALL dispose() override
virtual OUString SAL_CALL getFieldType() override
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
Fieldmark representing a checkbox form field.
static bool IsLegalName(std::u16string_view rName)
static bool IsLegalName(std::u16string_view rName)
Fieldmark representing a date form field.
Fieldmark representing a drop-down form field.
virtual void SetChecked(bool checked)=0
virtual bool IsChecked() const =0
virtual const SwPosition & GetMarkPos() const =0
const unotools::WeakReference< SwXBookmark > & GetXBookmark() const
void SetXBookmark(rtl::Reference< SwXBookmark > const &xBkmk)
css::uno::Sequence< typename M::key_type > mapKeysToSequence(M const &map)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SwPosition FindFieldSep(IFieldmark const &rMark)
return position of the CH_TXT_ATR_FIELDSEP for rMark
OUString ExpandFieldmark(IFieldmark *pBM)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange, ::sw::TextRangeMode const eMode)
bool GetDefaultTextContentValue(css::uno::Any &rAny, std::u16string_view rPropertyName, sal_uInt16 nWID=0)
constexpr OUStringLiteral ODF_FORMTEXT
constexpr OUStringLiteral ODF_FORMCHECKBOX
constexpr OUStringLiteral ODF_FORMDATE
constexpr OUStringLiteral ODF_UNHANDLED
constexpr OUStringLiteral ODF_FORMDROPDOWN
Marks a position in the document model.
void AdjustContent(sal_Int32 nDelta)
Adjust content index, only valid to call this if the position points to a SwContentNode subclass.
SwDoc & GetDoc() const
Returns the document this position is in.
cppu::ImplInheritanceHelper< SwXBookmark, css::text::XFormField, css::text::XTextField > SwXFieldmark_Base
SwUnoPropertyMapProvider aSwMapProvider
#define PROPERTY_MAP_FIELDMARK
#define PROPERTY_MAP_BOOKMARK
constexpr OUStringLiteral UNO_LINK_DISPLAY_NAME
constexpr OUStringLiteral UNO_NAME_BOOKMARK_CONDITION
constexpr OUStringLiteral UNO_NAME_BOOKMARK_HIDDEN