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/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>
28
30
31#include <svl/listener.hxx>
32#include <sfx2/Metadatable.hxx>
33
34#include <unobaseclass.hxx>
36
37class SwDoc;
38class SwXTextRange;
39
40typedef ::cppu::ImplInheritanceHelper
42, css::lang::XServiceInfo
43, css::beans::XPropertySet
44, css::container::XNamed
45, css::text::XTextContent
47
50 : public SwXBookmark_Base
51{
52
53private:
54
55 class Impl;
57
58protected:
61 void attachToRangeEx(
62 const css::uno::Reference< css::text::XTextRange > & xTextRange,
64 bool isFieldmarkSeparatorAtStart = false);
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
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::uno::XInterface> & xUT);
93
94 // MetadatableMixin
95 virtual ::sfx2::Metadatable* GetCoreObject() override;
96 virtual css::uno::Reference< css::frame::XModel > GetModel() override;
97
98 // XServiceInfo
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;
104
105 // XComponent
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;
111
112 // XPropertySet
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;
133
134 // XNamed
135 virtual OUString SAL_CALL getName() override;
136 virtual void SAL_CALL setName(const OUString& rName) override;
137
138 // XTextContent
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;
142
143};
144
146 : public ::cppu::WeakImplHelper< css::container::XNameContainer>
147 , public SvtListener
148{
149 private:
150 ::sw::mark::IFieldmark* m_pFieldmark;
152 ::sw::mark::IFieldmark::parameter_map_t* getCoreParameters();
153 public:
154 SwXFieldmarkParameters(::sw::mark::IFieldmark* const pFieldmark)
155 : m_pFieldmark(pFieldmark)
156 {
157 StartListening(pFieldmark->GetNotifier());
158 }
159
160 // XNameContainer
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;
163 // XNameReplace
164 virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override;
165 // XNameAccess
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;
169 // XElementAccess
170 virtual css::uno::Type SAL_CALL getElementType( ) override;
171 virtual sal_Bool SAL_CALL hasElements( ) override;
172
173 virtual void Notify( const SfxHint& rHint ) override;
174};
175
176typedef cppu::ImplInheritanceHelper< SwXBookmark,
177 css::text::XFormField,
178 css::text::XTextField
180
182class SwXFieldmark final
183 : public SwXFieldmark_Base
184{
188
190 GetCommand(::sw::mark::IFieldmark const& rMark);
192 GetResult(::sw::mark::IFieldmark const& rMark);
193
194 SwXFieldmark(bool isReplacementObject, SwDoc* pDoc);
195
196public:
199 bool isReplacementObject = false);
200
201 virtual void attachToRange(
202 const css::uno::Reference<css::text::XTextRange > & xTextRange) override;
203
204 // XServiceInfo
205 virtual OUString SAL_CALL getImplementationName() override;
206 virtual css::uno::Sequence<OUString> SAL_CALL
207 getSupportedServiceNames() override;
208
209 // XPropertySet
210 virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL
211 getPropertySetInfo() override;
212 virtual void SAL_CALL setPropertyValue(
213 const OUString& rPropertyName,
214 const css::uno::Any& rValue) override;
215 virtual css::uno::Any SAL_CALL getPropertyValue(
216 const OUString& rPropertyName) override;
217
218 // XComponent
219 virtual void SAL_CALL dispose() override;
220 virtual void SAL_CALL addEventListener(
221 const css::uno::Reference<css::lang::XEventListener> & xListener) override;
222 virtual void SAL_CALL removeEventListener(
223 const css::uno::Reference<css::lang::XEventListener> & xListener) override;
224
225 // XTextContent
226 virtual void SAL_CALL attach(
227 const css::uno::Reference<css::text::XTextRange> & xTextRange) override;
228 virtual css::uno::Reference<css::text::XTextRange> SAL_CALL getAnchor() override;
229
230 // XTextField
231 virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override;
232
233 // XFormField
234 virtual OUString SAL_CALL getFieldType() override;
235 virtual void SAL_CALL setFieldType(const OUString& description) override;
236 virtual css::uno::Reference<css::container::XNameContainer> SAL_CALL getParameters() override;
237
238};
239
240/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides access to the marks of a document.
bool StartListening(SvtBroadcaster &rBroadcaster)
Definition: doc.hxx:197
UNO API wrapper around an internal sw::mark::IMark.
Definition: unobookmark.hxx:51
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:287
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unobkm.cxx:391
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unobkm.cxx:492
virtual ~SwXBookmark() override
Definition: unobkm.cxx:153
virtual css::uno::Reference< css::frame::XModel > GetModel() override
Definition: unobkm.cxx:369
virtual OUString SAL_CALL getName() override
Definition: unobkm.cxx:303
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unobkm.cxx:484
::sw::mark::IMark const * GetBookmarkInDoc(SwDoc const *const pDoc, const css::uno::Reference< css::uno::XInterface > &xUT)
Definition: unobkm.cxx:184
virtual void SAL_CALL setName(const OUString &rName) override
Definition: unobkm.cxx:312
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unobkm.cxx:476
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:295
static rtl::Reference< SwXBookmark > CreateXBookmark(SwDoc &rDoc, ::sw::mark::IMark *pBookmark)
Definition: unobkm.cxx:157
virtual ::sfx2::Metadatable * GetCoreObject() override
Definition: unobkm.cxx:364
void attachToRangeEx(const css::uno::Reference< css::text::XTextRange > &xTextRange, IDocumentMarkAccess::MarkType eType, bool isFieldmarkSeparatorAtStart=false)
Definition: unobkm.cxx:195
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unobkm.cxx:380
virtual OUString SAL_CALL getImplementationName() override
Definition: unobkm.cxx:343
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:252
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unobkm.cxx:354
IDocumentMarkAccess * GetIDocumentMarkAccess()
Definition: unobkm.cxx:133
virtual void SAL_CALL dispose() override
Definition: unobkm.cxx:278
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unobkm.cxx:263
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unobkm.cxx:257
::sw::mark::IMark * GetBookmark() const
Definition: unobkm.cxx:128
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unobookmark.hxx:55
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unobkm.cxx:348
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unobkm.cxx:436
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unobkm.cxx:500
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unobkm.cxx:558
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: unobkm.cxx:534
virtual void Notify(const SfxHint &rHint) override
Definition: unobkm.cxx:569
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: unobkm.cxx:508
virtual sal_Bool SAL_CALL hasElements() override
Definition: unobkm.cxx:563
virtual void SAL_CALL removeByName(const OUString &Name) override
Definition: unobkm.cxx:517
::sw::mark::IFieldmark::parameter_map_t * getCoreParameters()
Definition: unobkm.cxx:575
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: unobkm.cxx:524
::sw::mark::IFieldmark * m_pFieldmark
SwXFieldmarkParameters(::sw::mark::IFieldmark *const pFieldmark)
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unobkm.cxx:544
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: unobkm.cxx:551
UNO wrapper around an sw::mark::IFieldmark.
::sw::mark::ICheckboxFieldmark * getCheckboxFieldmark()
Definition: unobkm.cxx:708
virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override
Definition: unobkm.cxx:825
rtl::Reference< SwXTextRange > GetResult(::sw::mark::IFieldmark const &rMark)
Definition: unobkm.cxx:815
virtual OUString SAL_CALL getImplementationName() override
Definition: unobkm.cxx:589
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:782
rtl::Reference< SwXTextRange > GetCommand(::sw::mark::IFieldmark const &rMark)
Definition: unobkm.cxx:806
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unobkm.cxx:800
bool m_isFieldmarkSeparatorAtStart
static rtl::Reference< SwXBookmark > CreateXFieldmark(SwDoc &rDoc, ::sw::mark::IMark *pMark, bool isReplacementObject=false)
Definition: unobkm.cxx:674
bool const m_bReplacementObject
SwXFieldmark(bool isReplacementObject, SwDoc *pDoc)
Definition: unobkm.cxx:582
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unobkm.cxx:595
virtual void attachToRange(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unobkm.cxx:612
virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getParameters() override
Definition: unobkm.cxx:664
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:629
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unobkm.cxx:725
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:620
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::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