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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOBOOKMARK_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_UNOBOOKMARK_HXX
23 #include <com/sun/star/lang/XUnoTunnel.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/container/XNamed.hpp>
27 #include <com/sun/star/text/XTextContent.hpp>
28 #include <com/sun/star/text/XTextField.hpp>
29 #include <com/sun/star/text/XFormField.hpp>
31 #include <cppuhelper/implbase.hxx>
33 #include <svl/listener.hxx>
34 #include <sfx2/Metadatable.hxx>
36 #include <unobaseclass.hxx>
37 #include <IDocumentMarkAccess.hxx>
41 typedef ::cppu::ImplInheritanceHelper
42 < ::sfx2::MetadatableMixin
43 , css::lang::XUnoTunnel
44 , css::lang::XServiceInfo
45 , css::beans::XPropertySet
46 , css::container::XNamed
47 , css::text::XTextContent
51 : public SwXBookmark_Base
57 ::sw::UnoImplPtr
<Impl
> m_pImpl
;
60 /// @throws css::lang::IllegalArgumentException
61 /// @throws css::uno::RuntimeException
63 const css::uno::Reference
< css::text::XTextRange
> & xTextRange
,
64 IDocumentMarkAccess::MarkType eType
);
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::IMark
* GetBookmark() const;
72 IDocumentMarkAccess
* GetIDocumentMarkAccess();
76 void registerInMark( SwXBookmark
& rXMark
, ::sw::mark::IMark
* const pMarkBase
);
78 virtual ~SwXBookmark() override
;
80 SwXBookmark(SwDoc
*const pDoc
);
87 static css::uno::Reference
< css::text::XTextContent
>
88 CreateXBookmark(SwDoc
& rDoc
, ::sw::mark::IMark
* pBookmark
);
90 /// @return IMark for this, but only if it lives in pDoc
91 static ::sw::mark::IMark
const* GetBookmarkInDoc(SwDoc
const*const pDoc
,
92 const css::uno::Reference
<css::lang::XUnoTunnel
> & xUT
);
95 virtual ::sfx2::Metadatable
* GetCoreObject() override
;
96 virtual css::uno::Reference
< css::frame::XModel
> GetModel() override
;
98 static const css::uno::Sequence
< sal_Int8
>& getUnoTunnelId();
101 virtual sal_Int64 SAL_CALL
getSomething(
102 const css::uno::Sequence
< sal_Int8
>& rIdentifier
) override
;
105 virtual OUString SAL_CALL
getImplementationName() override
;
106 virtual sal_Bool SAL_CALL
supportsService(
107 const OUString
& rServiceName
) override
;
108 virtual css::uno::Sequence
< OUString
> SAL_CALL
109 getSupportedServiceNames() override
;
112 virtual void SAL_CALL
dispose() override
;
113 virtual void SAL_CALL
addEventListener(
114 const css::uno::Reference
< css::lang::XEventListener
> & xListener
) override
;
115 virtual void SAL_CALL
removeEventListener(
116 const css::uno::Reference
< css::lang::XEventListener
> & xListener
) override
;
119 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
120 getPropertySetInfo() override
;
121 virtual void SAL_CALL
setPropertyValue(
122 const OUString
& rPropertyName
,
123 const css::uno::Any
& rValue
) override
;
124 virtual css::uno::Any SAL_CALL
getPropertyValue(
125 const OUString
& rPropertyName
) override
;
126 virtual void SAL_CALL
addPropertyChangeListener(
127 const OUString
& rPropertyName
,
128 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
129 virtual void SAL_CALL
removePropertyChangeListener(
130 const OUString
& rPropertyName
,
131 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
132 virtual void SAL_CALL
addVetoableChangeListener(
133 const OUString
& rPropertyName
,
134 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& xListener
) override
;
135 virtual void SAL_CALL
removeVetoableChangeListener(
136 const OUString
& rPropertyName
,
137 const css::uno::Reference
<
138 css::beans::XVetoableChangeListener
>& xListener
) override
;
141 virtual OUString SAL_CALL
getName() override
;
142 virtual void SAL_CALL
setName(const OUString
& rName
) override
;
145 virtual void SAL_CALL
attach(
146 const css::uno::Reference
< css::text::XTextRange
> & xTextRange
) override
;
147 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
getAnchor() override
;
151 class SwXFieldmarkParameters
152 : public ::cppu::WeakImplHelper
< css::container::XNameContainer
>
156 ::sw::mark::IFieldmark
* m_pFieldmark
;
157 /// @throws css::uno::RuntimeException
158 ::sw::mark::IFieldmark::parameter_map_t
* getCoreParameters();
160 SwXFieldmarkParameters(::sw::mark::IFieldmark
* const pFieldmark
)
161 : m_pFieldmark(pFieldmark
)
163 StartListening(pFieldmark
->GetNotifier());
167 virtual void SAL_CALL
insertByName( const OUString
& aName
, const css::uno::Any
& aElement
) override
;
168 virtual void SAL_CALL
removeByName( const OUString
& Name
) override
;
170 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const css::uno::Any
& aElement
) override
;
172 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
173 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
;
174 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
176 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
177 virtual sal_Bool SAL_CALL
hasElements( ) override
;
179 virtual void Notify( const SfxHint
& rHint
) override
;
182 typedef cppu::ImplInheritanceHelper
< SwXBookmark
,
183 css::text::XFormField
,
184 css::text::XTextField
187 class SwXFieldmark final
188 : public SwXFieldmark_Base
190 ::sw::mark::ICheckboxFieldmark
* getCheckboxFieldmark();
191 bool const m_bReplacementObject
;
193 css::uno::Reference
<css::text::XTextRange
>
194 GetCommand(::sw::mark::IFieldmark
const& rMark
);
195 css::uno::Reference
<css::text::XTextRange
>
196 GetResult(::sw::mark::IFieldmark
const& rMark
);
198 SwXFieldmark(bool isReplacementObject
, SwDoc
* pDoc
);
201 static css::uno::Reference
<css::text::XTextContent
>
202 CreateXFieldmark(SwDoc
& rDoc
, ::sw::mark::IMark
* 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 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNOBOOKMARK_HXX
246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */