LibreOffice Module sw (master) 1
unobookmark.hxx
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#pragma once
21
22#include <com/sun/star/lang/XUnoTunnel.hpp>
23#include <com/sun/star/lang/XServiceInfo.hpp>
24#include <com/sun/star/beans/XPropertySet.hpp>
25#include <com/sun/star/container/XNamed.hpp>
26#include <com/sun/star/text/XTextContent.hpp>
27#include <com/sun/star/text/XTextField.hpp>
28#include <com/sun/star/text/XFormField.hpp>
29
31
32#include <svl/listener.hxx>
33#include <sfx2/Metadatable.hxx>
34
35#include <unobaseclass.hxx>
37
38class SwDoc;
39
40typedef ::cppu::ImplInheritanceHelper
42, css::lang::XUnoTunnel
43, css::lang::XServiceInfo
44, css::beans::XPropertySet
45, css::container::XNamed
46, css::text::XTextContent
48
51 : public SwXBookmark_Base
52{
53
54private:
55
56 class Impl;
58
59protected:
62 void attachToRangeEx(
63 const css::uno::Reference< css::text::XTextRange > & xTextRange,
67 virtual void attachToRange(
68 const css::uno::Reference< css::text::XTextRange > & xTextRange);
69
71
73
74 SwDoc * GetDoc();
75
76 void registerInMark( SwXBookmark& rXMark, ::sw::mark::IMark* const pMarkBase );
77
78 virtual ~SwXBookmark() override;
79
80 SwXBookmark(SwDoc *const pDoc);
81
84
85public:
86
87 static css::uno::Reference< css::text::XTextContent>
88 CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark * pBookmark);
89
91 static ::sw::mark::IMark const* GetBookmarkInDoc(SwDoc const*const pDoc,
92 const css::uno::Reference<css::lang::XUnoTunnel> & xUT);
93
94 // MetadatableMixin
95 virtual ::sfx2::Metadatable* GetCoreObject() override;
96 virtual css::uno::Reference< css::frame::XModel > GetModel() override;
97
98 static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
99
100 // XUnoTunnel
101 virtual sal_Int64 SAL_CALL getSomething(
102 const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
103
104 // XServiceInfo
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;
110
111 // XComponent
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;
117
118 // XPropertySet
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;
139
140 // XNamed
141 virtual OUString SAL_CALL getName() override;
142 virtual void SAL_CALL setName(const OUString& rName) override;
143
144 // XTextContent
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;
148
149};
150
152 : public ::cppu::WeakImplHelper< css::container::XNameContainer>
153 , public SvtListener
154{
155 private:
159 public:
161 : m_pFieldmark(pFieldmark)
162 {
163 StartListening(pFieldmark->GetNotifier());
164 }
165
166 // XNameContainer
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;
169 // XNameReplace
170 virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override;
171 // XNameAccess
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;
175 // XElementAccess
176 virtual css::uno::Type SAL_CALL getElementType( ) override;
177 virtual sal_Bool SAL_CALL hasElements( ) override;
178
179 virtual void Notify( const SfxHint& rHint ) override;
180};
181
182typedef cppu::ImplInheritanceHelper< SwXBookmark,
183 css::text::XFormField,
184 css::text::XTextField
186
188class SwXFieldmark final
189 : public SwXFieldmark_Base
190{
193
194 css::uno::Reference<css::text::XTextRange>
196 css::uno::Reference<css::text::XTextRange>
197 GetResult(::sw::mark::IFieldmark const& rMark);
198
199 SwXFieldmark(bool isReplacementObject, SwDoc* pDoc);
200
201public:
202 static css::uno::Reference<css::text::XTextContent>
204 bool isReplacementObject = false);
205
206 virtual void attachToRange(
207 const css::uno::Reference<css::text::XTextRange > & xTextRange) override;
208
209 // XServiceInfo
210 virtual OUString SAL_CALL getImplementationName() override;
211 virtual css::uno::Sequence<OUString> SAL_CALL
212 getSupportedServiceNames() override;
213
214 // XPropertySet
215 virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL
216 getPropertySetInfo() override;
217 virtual void SAL_CALL setPropertyValue(
218 const OUString& rPropertyName,
219 const css::uno::Any& rValue) override;
220 virtual css::uno::Any SAL_CALL getPropertyValue(
221 const OUString& rPropertyName) override;
222
223 // XComponent
224 virtual void SAL_CALL dispose() override;
225 virtual void SAL_CALL addEventListener(
226 const css::uno::Reference<css::lang::XEventListener> & xListener) override;
227 virtual void SAL_CALL removeEventListener(
228 const css::uno::Reference<css::lang::XEventListener> & xListener) override;
229
230 // XTextContent
231 virtual void SAL_CALL attach(
232 const css::uno::Reference<css::text::XTextRange> & xTextRange) override;
233 virtual css::uno::Reference<css::text::XTextRange> SAL_CALL getAnchor() override;
234
235 // XTextField
236 virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override;
237
238 // XFormField
239 virtual OUString SAL_CALL getFieldType() override;
240 virtual void SAL_CALL setFieldType(const OUString& description) override;
241 virtual css::uno::Reference<css::container::XNameContainer> SAL_CALL getParameters() override;
242
243};
244
245/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides access to the marks of a document.
bool StartListening(SvtBroadcaster &rBroadcaster)
Definition: doc.hxx:188
UNO API wrapper around an internal sw::mark::IMark.
Definition: unobookmark.hxx:52
void registerInMark(SwXBookmark &rXMark, ::sw::mark::IMark *const pMarkBase)
Definition: unobkm.cxx:122
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:298
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unobkm.cxx:402
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unobkm.cxx:501
virtual ~SwXBookmark() override
Definition: unobkm.cxx:153
virtual css::uno::Reference< css::frame::XModel > GetModel() override
Definition: unobkm.cxx:380
void attachToRangeEx(const css::uno::Reference< css::text::XTextRange > &xTextRange, IDocumentMarkAccess::MarkType eType)
Definition: unobkm.cxx:207
virtual OUString SAL_CALL getName() override
Definition: unobkm.cxx:314
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unobkm.cxx:196
static css::uno::Reference< css::text::XTextContent > CreateXBookmark(SwDoc &rDoc, ::sw::mark::IMark *pBookmark)
Definition: unobkm.cxx:157
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unobkm.cxx:493
virtual void SAL_CALL setName(const OUString &rName) override
Definition: unobkm.cxx:323
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unobkm.cxx:202
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unobkm.cxx:485
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:306
virtual ::sfx2::Metadatable * GetCoreObject() override
Definition: unobkm.cxx:375
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unobkm.cxx:391
virtual OUString SAL_CALL getImplementationName() override
Definition: unobkm.cxx:354
SwXBookmark()
descriptor
Definition: unobkm.cxx:148
SwDoc * GetDoc()
Definition: unobkm.cxx:138
virtual void attachToRange(const css::uno::Reference< css::text::XTextRange > &xTextRange)
Definition: unobkm.cxx:263
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unobkm.cxx:365
IDocumentMarkAccess * GetIDocumentMarkAccess()
Definition: unobkm.cxx:133
virtual void SAL_CALL dispose() override
Definition: unobkm.cxx:289
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unobkm.cxx:274
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unobkm.cxx:268
::sw::mark::IMark const * GetBookmarkInDoc(SwDoc const *const pDoc, const css::uno::Reference< css::lang::XUnoTunnel > &xUT)
Definition: unobkm.cxx:184
::sw::mark::IMark * GetBookmark() const
Definition: unobkm.cxx:128
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unobookmark.hxx:56
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unobkm.cxx:359
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unobkm.cxx:445
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unobkm.cxx:509
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unobkm.cxx:567
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: unobkm.cxx:543
virtual void Notify(const SfxHint &rHint) override
Definition: unobkm.cxx:578
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: unobkm.cxx:517
virtual sal_Bool SAL_CALL hasElements() override
Definition: unobkm.cxx:572
virtual void SAL_CALL removeByName(const OUString &Name) override
Definition: unobkm.cxx:526
::sw::mark::IFieldmark::parameter_map_t * getCoreParameters()
Definition: unobkm.cxx:584
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: unobkm.cxx:533
::sw::mark::IFieldmark * m_pFieldmark
SwXFieldmarkParameters(::sw::mark::IFieldmark *const pFieldmark)
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unobkm.cxx:553
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: unobkm.cxx:560
UNO wrapper around an sw::mark::IFieldmark.
::sw::mark::ICheckboxFieldmark * getCheckboxFieldmark()
Definition: unobkm.cxx:716
virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override
Definition: unobkm.cxx:825
virtual OUString SAL_CALL getImplementationName() override
Definition: unobkm.cxx:598
css::uno::Reference< css::text::XTextRange > GetCommand(::sw::mark::IFieldmark const &rMark)
Definition: unobkm.cxx:806
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:782
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unobkm.cxx:800
bool const m_bReplacementObject
SwXFieldmark(bool isReplacementObject, SwDoc *pDoc)
Definition: unobkm.cxx:591
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unobkm.cxx:604
virtual void attachToRange(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unobkm.cxx:621
css::uno::Reference< css::text::XTextRange > GetResult(::sw::mark::IFieldmark const &rMark)
Definition: unobkm.cxx:815
virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getParameters() override
Definition: unobkm.cxx:672
static css::uno::Reference< css::text::XTextContent > CreateXFieldmark(SwDoc &rDoc, ::sw::mark::IMark *pMark, bool isReplacementObject=false)
Definition: unobkm.cxx:682
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unobkm.cxx:752
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unobkm.cxx:767
virtual void SAL_CALL setFieldType(const OUString &description) override
Definition: unobkm.cxx:637
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unobkm.cxx:733
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:787
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unobkm.cxx:794
virtual void SAL_CALL dispose() override
Definition: unobkm.cxx:778
virtual OUString SAL_CALL getFieldType() override
Definition: unobkm.cxx:628
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:101
std::map< OUString, css::uno::Any > parameter_map_t
Definition: IMark.hxx:94
std::unique_ptr< T, UnoImplPtrDeleter< T > > UnoImplPtr
Smart pointer class ensuring that the pointed object is deleted with a locked SolarMutex.
unsigned char sal_Bool
::cppu::ImplInheritanceHelper< ::sfx2::MetadatableMixin, css::lang::XUnoTunnel, css::lang::XServiceInfo, css::beans::XPropertySet, css::container::XNamed, css::text::XTextContent > SwXBookmark_Base
Definition: unobookmark.hxx:38
cppu::ImplInheritanceHelper< SwXBookmark, css::text::XFormField, css::text::XTextField > SwXFieldmark_Base