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 
30 #include <cppuhelper/implbase.hxx>
31 
32 #include <svl/listener.hxx>
33 #include <sfx2/Metadatable.hxx>
34 
35 #include <unobaseclass.hxx>
36 #include <IDocumentMarkAccess.hxx>
37 
38 class SwDoc;
39 
40 typedef ::cppu::ImplInheritanceHelper
42 , css::lang::XUnoTunnel
43 , css::lang::XServiceInfo
44 , css::beans::XPropertySet
45 , css::container::XNamed
46 , css::text::XTextContent
48 
50  : public SwXBookmark_Base
51 {
52 
53 private:
54 
55  class Impl;
57 
58 protected:
61  void attachToRangeEx(
62  const css::uno::Reference< css::text::XTextRange > & xTextRange,
66  virtual void attachToRange(
67  const css::uno::Reference< css::text::XTextRange > & xTextRange);
68 
70 
72 
73  SwDoc * GetDoc();
74 
75  void registerInMark( SwXBookmark& rXMark, ::sw::mark::IMark* const pMarkBase );
76 
77  virtual ~SwXBookmark() override;
78 
79  SwXBookmark(SwDoc *const pDoc);
80 
82  SwXBookmark();
83 
84 public:
85 
86  static css::uno::Reference< css::text::XTextContent>
87  CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark * pBookmark);
88 
90  static ::sw::mark::IMark const* GetBookmarkInDoc(SwDoc const*const pDoc,
91  const css::uno::Reference<css::lang::XUnoTunnel> & xUT);
92 
93  // MetadatableMixin
94  virtual ::sfx2::Metadatable* GetCoreObject() override;
95  virtual css::uno::Reference< css::frame::XModel > GetModel() override;
96 
97  static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
98 
99  // XUnoTunnel
100  virtual sal_Int64 SAL_CALL getSomething(
101  const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
102 
103  // XServiceInfo
104  virtual OUString SAL_CALL getImplementationName() override;
105  virtual sal_Bool SAL_CALL supportsService(
106  const OUString& rServiceName) override;
107  virtual css::uno::Sequence< OUString > SAL_CALL
108  getSupportedServiceNames() override;
109 
110  // XComponent
111  virtual void SAL_CALL dispose() override;
112  virtual void SAL_CALL addEventListener(
113  const css::uno::Reference< css::lang::XEventListener > & xListener) override;
114  virtual void SAL_CALL removeEventListener(
115  const css::uno::Reference< css::lang::XEventListener > & xListener) override;
116 
117  // XPropertySet
118  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
119  getPropertySetInfo() override;
120  virtual void SAL_CALL setPropertyValue(
121  const OUString& rPropertyName,
122  const css::uno::Any& rValue) override;
123  virtual css::uno::Any SAL_CALL getPropertyValue(
124  const OUString& rPropertyName) override;
125  virtual void SAL_CALL addPropertyChangeListener(
126  const OUString& rPropertyName,
127  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
128  virtual void SAL_CALL removePropertyChangeListener(
129  const OUString& rPropertyName,
130  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
131  virtual void SAL_CALL addVetoableChangeListener(
132  const OUString& rPropertyName,
133  const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
134  virtual void SAL_CALL removeVetoableChangeListener(
135  const OUString& rPropertyName,
136  const css::uno::Reference<
137  css::beans::XVetoableChangeListener >& xListener) override;
138 
139  // XNamed
140  virtual OUString SAL_CALL getName() override;
141  virtual void SAL_CALL setName(const OUString& rName) override;
142 
143  // XTextContent
144  virtual void SAL_CALL attach(
145  const css::uno::Reference< css::text::XTextRange > & xTextRange) override;
146  virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override;
147 
148 };
149 
151  : public ::cppu::WeakImplHelper< css::container::XNameContainer>
152  , public SvtListener
153 {
154  private:
158  public:
160  : m_pFieldmark(pFieldmark)
161  {
162  StartListening(pFieldmark->GetNotifier());
163  }
164 
165  // XNameContainer
166  virtual void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override;
167  virtual void SAL_CALL removeByName( const OUString& Name ) override;
168  // XNameReplace
169  virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override;
170  // XNameAccess
171  virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
172  virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
173  virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
174  // XElementAccess
175  virtual css::uno::Type SAL_CALL getElementType( ) override;
176  virtual sal_Bool SAL_CALL hasElements( ) override;
177 
178  virtual void Notify( const SfxHint& rHint ) override;
179 };
180 
181 typedef cppu::ImplInheritanceHelper< SwXBookmark,
182  css::text::XFormField,
183  css::text::XTextField
185 
186 class SwXFieldmark final
187  : public SwXFieldmark_Base
188 {
191 
192  css::uno::Reference<css::text::XTextRange>
193  GetCommand(::sw::mark::IFieldmark const& rMark);
194  css::uno::Reference<css::text::XTextRange>
195  GetResult(::sw::mark::IFieldmark const& rMark);
196 
197  SwXFieldmark(bool isReplacementObject, SwDoc* pDoc);
198 
199 public:
200  static css::uno::Reference<css::text::XTextContent>
201  CreateXFieldmark(SwDoc & rDoc, ::sw::mark::IMark * pMark,
202  bool isReplacementObject = false);
203 
204  virtual void attachToRange(
205  const css::uno::Reference<css::text::XTextRange > & xTextRange) override;
206 
207  // XServiceInfo
208  virtual OUString SAL_CALL getImplementationName() override;
209  virtual css::uno::Sequence<OUString> SAL_CALL
210  getSupportedServiceNames() override;
211 
212  // XPropertySet
213  virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL
214  getPropertySetInfo() override;
215  virtual void SAL_CALL setPropertyValue(
216  const OUString& rPropertyName,
217  const css::uno::Any& rValue) override;
218  virtual css::uno::Any SAL_CALL getPropertyValue(
219  const OUString& rPropertyName) override;
220 
221  // XComponent
222  virtual void SAL_CALL dispose() override;
223  virtual void SAL_CALL addEventListener(
224  const css::uno::Reference<css::lang::XEventListener> & xListener) override;
225  virtual void SAL_CALL removeEventListener(
226  const css::uno::Reference<css::lang::XEventListener> & xListener) override;
227 
228  // XTextContent
229  virtual void SAL_CALL attach(
230  const css::uno::Reference<css::text::XTextRange> & xTextRange) override;
231  virtual css::uno::Reference<css::text::XTextRange> SAL_CALL getAnchor() override;
232 
233  // XTextField
234  virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override;
235 
236  // XFormField
237  virtual OUString SAL_CALL getFieldType() override;
238  virtual void SAL_CALL setFieldType(const OUString& description) override;
239  virtual css::uno::Reference<css::container::XNameContainer> SAL_CALL getParameters() override;
240 
241 };
242 
243 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:783
std::map< OUString, css::uno::Any > parameter_map_t
Definition: IMark.hxx:94
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unobkm.cxx:199
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unobkm.cxx:768
SwXFieldmark(bool isReplacementObject, SwDoc *pDoc)
Definition: unobkm.cxx:592
SwDoc * GetDoc()
Definition: unobkm.cxx:141
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unobkm.cxx:568
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unobkm.cxx:446
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:788
IDocumentMarkAccess * GetIDocumentMarkAccess()
Definition: unobkm.cxx:136
Provides access to the marks of a document.
Definition: doc.hxx:188
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unobkm.cxx:502
virtual css::uno::Reference< css::frame::XModel > GetModel() override
Definition: unobkm.cxx:381
virtual ::sfx2::Metadatable * GetCoreObject() override
Definition: unobkm.cxx:376
::sw::mark::IFieldmark::parameter_map_t * getCoreParameters()
Definition: unobkm.cxx:585
SwXFieldmarkParameters(::sw::mark::IFieldmark *const pFieldmark)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unobkm.cxx:605
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unobkm.cxx:277
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unobkm.cxx:554
virtual void SAL_CALL dispose() override
Definition: unobkm.cxx:779
css::uno::Reference< css::text::XTextRange > GetCommand(::sw::mark::IFieldmark const &rMark)
Definition: unobkm.cxx:807
virtual void SAL_CALL removeByName(const OUString &Name) override
Definition: unobkm.cxx:527
static css::uno::Reference< css::text::XTextContent > CreateXFieldmark(SwDoc &rDoc,::sw::mark::IMark *pMark, bool isReplacementObject=false)
Definition: unobkm.cxx:683
virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override
Definition: unobkm.cxx:826
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unobkm.cxx:494
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unobkm.cxx:753
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: unobkm.cxx:561
std::unique_ptr< T, UnoImplPtrDeleter< T > > UnoImplPtr
Smart pointer class ensuring that the pointed object is deleted with a locked SolarMutex.
SwXBookmark()
descriptor
Definition: unobkm.cxx:151
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unobkm.cxx:271
static css::uno::Reference< css::text::XTextContent > CreateXBookmark(SwDoc &rDoc,::sw::mark::IMark *pBookmark)
Definition: unobkm.cxx:160
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unobkm.cxx:366
virtual OUString SAL_CALL getImplementationName() override
Definition: unobkm.cxx:599
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unobkm.cxx:801
::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
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unobkm.cxx:486
unsigned char sal_Bool
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:308
bool StartListening(SvtBroadcaster &rBroadcaster)
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:301
virtual void SAL_CALL setFieldType(const OUString &description) override
Definition: unobkm.cxx:638
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: unobkm.cxx:534
::sw::mark::IMark * GetBookmark() const
Definition: unobkm.cxx:131
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unobkm.cxx:734
css::uno::Reference< css::text::XTextRange > GetResult(::sw::mark::IFieldmark const &rMark)
Definition: unobkm.cxx:816
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:102
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unobkm.cxx:795
virtual void Notify(const SfxHint &rHint) override
Definition: unobkm.cxx:579
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: unobkm.cxx:518
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unobkm.cxx:510
virtual sal_Bool SAL_CALL hasElements() override
Definition: unobkm.cxx:573
void registerInMark(SwXBookmark &rXMark,::sw::mark::IMark *const pMarkBase)
Definition: unobkm.cxx:125
virtual OUString SAL_CALL getFieldType() override
Definition: unobkm.cxx:629
virtual void SAL_CALL setName(const OUString &rName) override
Definition: unobkm.cxx:324
virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getParameters() override
Definition: unobkm.cxx:673
virtual ~SwXBookmark() override
Definition: unobkm.cxx:156
::sw::mark::ICheckboxFieldmark * getCheckboxFieldmark()
Definition: unobkm.cxx:717
::sw::mark::IMark const * GetBookmarkInDoc(SwDoc const *const pDoc, const css::uno::Reference< css::lang::XUnoTunnel > &xUT)
Definition: unobkm.cxx:187
virtual OUString SAL_CALL getImplementationName() override
Definition: unobkm.cxx:355
virtual void attachToRange(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unobkm.cxx:622
void attachToRangeEx(const css::uno::Reference< css::text::XTextRange > &xTextRange, IDocumentMarkAccess::MarkType eType)
Definition: unobkm.cxx:210
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unobkm.cxx:205
bool const m_bReplacementObject
virtual OUString SAL_CALL getName() override
Definition: unobkm.cxx:315
virtual void attachToRange(const css::uno::Reference< css::text::XTextRange > &xTextRange)
Definition: unobkm.cxx:266
virtual void SAL_CALL dispose() override
Definition: unobkm.cxx:292
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: unobkm.cxx:544
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unobookmark.hxx:55
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unobkm.cxx:392
::sw::mark::IFieldmark * m_pFieldmark
cppu::ImplInheritanceHelper< SwXBookmark, css::text::XFormField, css::text::XTextField > SwXFieldmark_Base
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unobkm.cxx:403
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unobkm.cxx:360