1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/container/XNamed.hpp>
25 #include <com/sun/star/text/XTextContent.hpp>
26 #include <com/sun/star/text/XTextField.hpp>
27 #include <com/sun/star/text/XFormField.hpp>
29 #include <cppuhelper/implbase.hxx>
31 #include <svl/listener.hxx>
32 #include <sfx2/Metadatable.hxx>
34 #include <unobaseclass.hxx>
35 #include <IDocumentMarkAccess.hxx>
40 typedef ::cppu::ImplInheritanceHelper
41 < ::sfx2::MetadatableMixin
42 , css::lang::XServiceInfo
43 , css::beans::XPropertySet
44 , css::container::XNamed
45 , css::text::XTextContent
48 /// UNO API wrapper around an internal sw::mark::MarkBase.
49 class SAL_DLLPUBLIC_RTTI SwXBookmark
50 : public SwXBookmark_Base
56 ::sw::UnoImplPtr
<Impl
> m_pImpl
;
59 /// @throws css::lang::IllegalArgumentException
60 /// @throws css::uno::RuntimeException
62 const css::uno::Reference
< css::text::XTextRange
> & xTextRange
,
63 IDocumentMarkAccess::MarkType eType
,
64 bool isFieldmarkSeparatorAtStart
= false);
65 /// @throws css::lang::IllegalArgumentException
66 /// @throws css::uno::RuntimeException
67 virtual void attachToRange(
68 const css::uno::Reference
< css::text::XTextRange
> & xTextRange
);
70 ::sw::mark::MarkBase
* GetBookmark() const;
72 IDocumentMarkAccess
* GetIDocumentMarkAccess();
76 void registerInMark( SwXBookmark
& rXMark
, ::sw::mark::MarkBase
* const pMarkBase
);
78 virtual ~SwXBookmark() override
;
80 SwXBookmark(SwDoc
*const pDoc
);
87 static rtl::Reference
<SwXBookmark
>
88 CreateXBookmark(SwDoc
& rDoc
, ::sw::mark::MarkBase
* pBookmark
);
90 /// @return IMark for this, but only if it lives in pDoc
91 static ::sw::mark::MarkBase
const* GetBookmarkInDoc(SwDoc
const*const pDoc
,
92 const css::uno::Reference
<css::uno::XInterface
> & xUT
);
95 virtual ::sfx2::Metadatable
* GetCoreObject() override
;
96 virtual css::uno::Reference
< css::frame::XModel
> GetModel() override
;
99 virtual OUString SAL_CALL
getImplementationName() override
;
100 virtual sal_Bool SAL_CALL
supportsService(
101 const OUString
& rServiceName
) override
;
102 virtual css::uno::Sequence
< OUString
> SAL_CALL
103 getSupportedServiceNames() override
;
106 virtual void SAL_CALL
dispose() override
;
107 virtual void SAL_CALL
addEventListener(
108 const css::uno::Reference
< css::lang::XEventListener
> & xListener
) override
;
109 virtual void SAL_CALL
removeEventListener(
110 const css::uno::Reference
< css::lang::XEventListener
> & xListener
) override
;
113 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
114 getPropertySetInfo() override
;
115 virtual void SAL_CALL
setPropertyValue(
116 const OUString
& rPropertyName
,
117 const css::uno::Any
& rValue
) override
;
118 virtual css::uno::Any SAL_CALL
getPropertyValue(
119 const OUString
& rPropertyName
) override
;
120 virtual void SAL_CALL
addPropertyChangeListener(
121 const OUString
& rPropertyName
,
122 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
123 virtual void SAL_CALL
removePropertyChangeListener(
124 const OUString
& rPropertyName
,
125 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
126 virtual void SAL_CALL
addVetoableChangeListener(
127 const OUString
& rPropertyName
,
128 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& xListener
) override
;
129 virtual void SAL_CALL
removeVetoableChangeListener(
130 const OUString
& rPropertyName
,
131 const css::uno::Reference
<
132 css::beans::XVetoableChangeListener
>& xListener
) override
;
135 virtual OUString SAL_CALL
getName() override
;
136 SW_DLLPUBLIC
virtual void SAL_CALL
setName(const OUString
& rName
) override
;
139 virtual void SAL_CALL
attach(
140 const css::uno::Reference
< css::text::XTextRange
> & xTextRange
) override
;
141 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
getAnchor() override
;
145 class SwXFieldmarkParameters final
146 : public ::cppu::WeakImplHelper
< css::container::XNameContainer
>
150 ::sw::mark::Fieldmark
* m_pFieldmark
;
151 /// @throws css::uno::RuntimeException
152 ::sw::mark::Fieldmark::parameter_map_t
* getCoreParameters();
154 SwXFieldmarkParameters(::sw::mark::Fieldmark
* const pFieldmark
)
155 : m_pFieldmark(pFieldmark
)
157 StartListening(pFieldmark
->GetNotifier());
161 virtual void SAL_CALL
insertByName( const OUString
& aName
, const css::uno::Any
& aElement
) override
;
162 virtual void SAL_CALL
removeByName( const OUString
& Name
) override
;
164 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const css::uno::Any
& aElement
) override
;
166 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
167 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
;
168 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
170 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
171 virtual sal_Bool SAL_CALL
hasElements( ) override
;
173 virtual void Notify( const SfxHint
& rHint
) override
;
176 typedef cppu::ImplInheritanceHelper
< SwXBookmark
,
177 css::text::XFormField
,
178 css::text::XTextField
181 /// UNO wrapper around an sw::mark::Fieldmark.
182 class SW_DLLPUBLIC SwXFieldmark final
183 : public SwXFieldmark_Base
185 ::sw::mark::CheckboxFieldmark
* getCheckboxFieldmark();
186 bool const m_bReplacementObject
;
187 bool m_isFieldmarkSeparatorAtStart
= false;
189 rtl::Reference
<SwXTextRange
>
190 GetCommand(::sw::mark::Fieldmark
const& rMark
);
191 rtl::Reference
<SwXTextRange
>
192 GetResult(::sw::mark::Fieldmark
const& rMark
);
194 SwXFieldmark(bool isReplacementObject
, SwDoc
* pDoc
);
196 // workaround MSVC compiler
197 SwXFieldmark(const SwXFieldmark
&) = delete;
198 SwXFieldmark(SwXFieldmark
&&) = delete;
201 static rtl::Reference
<SwXFieldmark
>
202 CreateXFieldmark(SwDoc
& rDoc
, ::sw::mark::MarkBase
* pMark
,
203 bool isReplacementObject
= false);
205 virtual void attachToRange(
206 const css::uno::Reference
<css::text::XTextRange
> & xTextRange
) override
;
209 virtual OUString SAL_CALL
getImplementationName() override
;
210 virtual css::uno::Sequence
<OUString
> SAL_CALL
211 getSupportedServiceNames() override
;
214 virtual css::uno::Reference
<css::beans::XPropertySetInfo
> SAL_CALL
215 getPropertySetInfo() override
;
216 virtual void SAL_CALL
setPropertyValue(
217 const OUString
& rPropertyName
,
218 const css::uno::Any
& rValue
) override
;
219 virtual css::uno::Any SAL_CALL
getPropertyValue(
220 const OUString
& rPropertyName
) override
;
223 virtual void SAL_CALL
dispose() override
;
224 virtual void SAL_CALL
addEventListener(
225 const css::uno::Reference
<css::lang::XEventListener
> & xListener
) override
;
226 virtual void SAL_CALL
removeEventListener(
227 const css::uno::Reference
<css::lang::XEventListener
> & xListener
) override
;
230 virtual void SAL_CALL
attach(
231 const css::uno::Reference
<css::text::XTextRange
> & xTextRange
) override
;
232 virtual css::uno::Reference
<css::text::XTextRange
> SAL_CALL
getAnchor() override
;
235 virtual OUString SAL_CALL
getPresentation(sal_Bool bShowCommand
) override
;
238 virtual OUString SAL_CALL
getFieldType() override
;
239 virtual void SAL_CALL
setFieldType(const OUString
& description
) override
;
240 virtual css::uno::Reference
<css::container::XNameContainer
> SAL_CALL
getParameters() override
;
244 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */