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 #ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOBOOKMARK_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_UNOBOOKMARK_HXX
22 
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/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 
69  const ::sw::mark::IMark* GetBookmark() const;
70 
72 
73  void registerInMark( SwXBookmark& rXMark, ::sw::mark::IMark* const pMarkBase );
74 
75  virtual ~SwXBookmark() override;
76 
77  SwXBookmark(SwDoc *const pDoc);
78 
80  SwXBookmark();
81 
82 public:
83 
84  static css::uno::Reference< css::text::XTextContent>
85  CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark * pBookmark);
86 
88  static ::sw::mark::IMark const* GetBookmarkInDoc(SwDoc const*const pDoc,
89  const css::uno::Reference<css::lang::XUnoTunnel> & xUT);
90 
91  // MetadatableMixin
92  virtual ::sfx2::Metadatable* GetCoreObject() override;
93  virtual css::uno::Reference< css::frame::XModel > GetModel() override;
94 
95  static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
96 
97  // XUnoTunnel
98  virtual sal_Int64 SAL_CALL getSomething(
99  const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
100 
101  // XServiceInfo
102  virtual OUString SAL_CALL getImplementationName() override;
103  virtual sal_Bool SAL_CALL supportsService(
104  const OUString& rServiceName) override;
105  virtual css::uno::Sequence< OUString > SAL_CALL
106  getSupportedServiceNames() override;
107 
108  // XComponent
109  virtual void SAL_CALL dispose() override;
110  virtual void SAL_CALL addEventListener(
111  const css::uno::Reference< css::lang::XEventListener > & xListener) override;
112  virtual void SAL_CALL removeEventListener(
113  const css::uno::Reference< css::lang::XEventListener > & xListener) override;
114 
115  // XPropertySet
116  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
117  getPropertySetInfo() override;
118  virtual void SAL_CALL setPropertyValue(
119  const OUString& rPropertyName,
120  const css::uno::Any& rValue) override;
121  virtual css::uno::Any SAL_CALL getPropertyValue(
122  const OUString& rPropertyName) override;
123  virtual void SAL_CALL addPropertyChangeListener(
124  const OUString& rPropertyName,
125  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
126  virtual void SAL_CALL removePropertyChangeListener(
127  const OUString& rPropertyName,
128  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
129  virtual void SAL_CALL addVetoableChangeListener(
130  const OUString& rPropertyName,
131  const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
132  virtual void SAL_CALL removeVetoableChangeListener(
133  const OUString& rPropertyName,
134  const css::uno::Reference<
135  css::beans::XVetoableChangeListener >& xListener) override;
136 
137  // XNamed
138  virtual OUString SAL_CALL getName() override;
139  virtual void SAL_CALL setName(const OUString& rName) override;
140 
141  // XTextContent
142  virtual void SAL_CALL attach(
143  const css::uno::Reference< css::text::XTextRange > & xTextRange) override;
144  virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override;
145 
146 };
147 
149  : public ::cppu::WeakImplHelper< css::container::XNameContainer>
150  , public SvtListener
151 {
152  private:
156  public:
158  : m_pFieldmark(pFieldmark)
159  {
160  StartListening(pFieldmark->GetNotifier());
161  }
162 
163  // XNameContainer
164  virtual void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override;
165  virtual void SAL_CALL removeByName( const OUString& Name ) override;
166  // XNameReplace
167  virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override;
168  // XNameAccess
169  virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
170  virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
171  virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
172  // XElementAccess
173  virtual css::uno::Type SAL_CALL getElementType( ) override;
174  virtual sal_Bool SAL_CALL hasElements( ) override;
175 
176  virtual void Notify( const SfxHint& rHint ) override;
177 };
178 
179 typedef cppu::ImplInheritanceHelper< SwXBookmark,
180  css::text::XFormField > SwXFieldmark_Base;
181 
182 class SwXFieldmark final
183  : public SwXFieldmark_Base
184 {
187 
188  SwXFieldmark(bool isReplacementObject, SwDoc* pDoc);
189 
190 public:
191  static css::uno::Reference<css::text::XTextContent>
192  CreateXFieldmark(SwDoc & rDoc, ::sw::mark::IMark * pMark,
193  bool isReplacementObject = false);
194 
195  virtual void attachToRange(
196  const css::uno::Reference<css::text::XTextRange > & xTextRange) override;
197  virtual OUString SAL_CALL getFieldType() override;
198  virtual void SAL_CALL setFieldType(const OUString& description ) override;
199  virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getParameters( ) override;
200  virtual void SAL_CALL setPropertyValue(
201  const OUString& rPropertyName,
202  const css::uno::Any& rValue) override;
203 
204  virtual css::uno::Any SAL_CALL getPropertyValue(
205  const OUString& rPropertyName) override;
206 };
207 
208 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNOBOOKMARK_HXX
209 
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::map< OUString, css::uno::Any > parameter_map_t
Definition: IMark.hxx:94
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unobkm.cxx:200
SwXFieldmark(bool isReplacementObject, SwDoc *pDoc)
Definition: unobkm.cxx:521
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unobkm.cxx:576
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unobkm.cxx:450
IDocumentMarkAccess * GetIDocumentMarkAccess()
Definition: unobkm.cxx:137
Provides access to the marks of a document.
Definition: doc.hxx:185
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unobkm.cxx:506
virtual css::uno::Reference< css::frame::XModel > GetModel() override
Definition: unobkm.cxx:385
virtual ::sfx2::Metadatable * GetCoreObject() override
Definition: unobkm.cxx:380
::sw::mark::IFieldmark::parameter_map_t * getCoreParameters()
Definition: unobkm.cxx:593
SwXFieldmarkParameters(::sw::mark::IFieldmark *const pFieldmark)
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unobkm.cxx:282
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unobkm.cxx:562
virtual void SAL_CALL removeByName(const OUString &Name) override
Definition: unobkm.cxx:535
static css::uno::Reference< css::text::XTextContent > CreateXFieldmark(SwDoc &rDoc,::sw::mark::IMark *pMark, bool isReplacementObject=false)
Definition: unobkm.cxx:651
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unobkm.cxx:498
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unobkm.cxx:723
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: unobkm.cxx:569
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:147
cppu::ImplInheritanceHelper< SwXBookmark, css::text::XFormField > SwXFieldmark_Base
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unobkm.cxx:276
static css::uno::Reference< css::text::XTextContent > CreateXBookmark(SwDoc &rDoc,::sw::mark::IMark *pBookmark)
Definition: unobkm.cxx:156
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unobkm.cxx:370
::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:490
unsigned char sal_Bool
bool const isReplacementObject
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:313
bool StartListening(SvtBroadcaster &rBroadcaster)
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unobkm.cxx:306
virtual void SAL_CALL setFieldType(const OUString &description) override
Definition: unobkm.cxx:616
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: unobkm.cxx:542
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unobkm.cxx:703
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:93
virtual void Notify(const SfxHint &rHint) override
Definition: unobkm.cxx:587
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: unobkm.cxx:526
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unobkm.cxx:514
virtual sal_Bool SAL_CALL hasElements() override
Definition: unobkm.cxx:581
void registerInMark(SwXBookmark &rXMark,::sw::mark::IMark *const pMarkBase)
Definition: unobkm.cxx:126
virtual OUString SAL_CALL getFieldType() override
Definition: unobkm.cxx:607
virtual void SAL_CALL setName(const OUString &rName) override
Definition: unobkm.cxx:329
virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getParameters() override
Definition: unobkm.cxx:640
virtual ~SwXBookmark() override
Definition: unobkm.cxx:152
::sw::mark::ICheckboxFieldmark * getCheckboxFieldmark()
Definition: unobkm.cxx:685
::sw::mark::IMark const * GetBookmarkInDoc(SwDoc const *const pDoc, const css::uno::Reference< css::lang::XUnoTunnel > &xUT)
Definition: unobkm.cxx:183
virtual OUString SAL_CALL getImplementationName() override
Definition: unobkm.cxx:359
virtual void attachToRange(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unobkm.cxx:600
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
virtual OUString SAL_CALL getName() override
Definition: unobkm.cxx:320
virtual void attachToRange(const css::uno::Reference< css::text::XTextRange > &xTextRange)
Definition: unobkm.cxx:271
virtual void SAL_CALL dispose() override
Definition: unobkm.cxx:297
const ::sw::mark::IMark * GetBookmark() const
Definition: unobkm.cxx:132
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: unobkm.cxx:552
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unobookmark.hxx:55
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unobkm.cxx:396
::sw::mark::IFieldmark * m_pFieldmark
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unobkm.cxx:407
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unobkm.cxx:364