LibreOffice Module sw (master)  1
unometa.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_UNOMETA_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_UNOMETA_HXX
22 
23 #include <memory>
24 #include <deque>
25 
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/lang/XUnoTunnel.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/container/XChild.hpp>
30 #include <com/sun/star/container/XEnumerationAccess.hpp>
31 #include <com/sun/star/text/XTextContent.hpp>
32 #include <com/sun/star/text/XTextField.hpp>
33 
34 #include <cppuhelper/implbase.hxx>
35 
36 #include <sfx2/Metadatable.hxx>
37 
38 #include <unobaseclass.hxx>
39 
40 typedef std::deque<
41  css::uno::Reference< css::text::XTextRange > >
43 
44 class SwPaM;
45 class SwTextNode;
46 
47 namespace sw {
48  class Meta;
49 }
50 
51 typedef ::cppu::ImplInheritanceHelper
53 , css::lang::XUnoTunnel
54 , css::lang::XServiceInfo
55 , css::container::XChild
56 , css::container::XEnumerationAccess
57 , css::text::XTextContent
58 , css::text::XText
60 
61 class SwXMeta
62  : public SwXMeta_Base
63 {
64 
65 public:
66 
67  class Impl;
68 
69 protected:
70 
72 
75  void AttachImpl(
76  const css::uno::Reference< css::text::XTextRange > & xTextRange,
77  const sal_uInt16 nWhich);
78 
79  virtual ~SwXMeta() override;
80 
81  SwXMeta(SwXMeta const&) = delete;
82  SwXMeta& operator=(SwXMeta const&) = delete;
83 
85  SwXMeta(SwDoc *const pDoc, ::sw::Meta *const pMeta,
86  css::uno::Reference< css::text::XText> const& xParentText,
87  std::unique_ptr<TextRangeList_t const> pPortions);
88 
89  SwXMeta(SwDoc *const pDoc);
90 
91 public:
92 
93  static css::uno::Reference< css::rdf::XMetadatable >
95  ::sw::Meta & rMeta,
96  css::uno::Reference< css::text::XText> const& xParentText = nullptr,
97  std::unique_ptr<TextRangeList_t const> && pPortions = std::unique_ptr<TextRangeList_t const>());
98 
99  static css::uno::Reference<css::rdf::XMetadatable>
100  CreateXMeta(SwDoc & rDoc, bool isField);
101 
103  bool SetContentRange( SwTextNode *& rpNode, sal_Int32 & rStart, sal_Int32 & rEnd) const;
104  css::uno::Reference< css::text::XText > const & GetParentText() const;
105 
108  bool CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb);
109 
110  // MetadatableMixin
111  virtual ::sfx2::Metadatable * GetCoreObject() override;
112  virtual css::uno::Reference< css::frame::XModel >
113  GetModel() override;
114 
115  static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
116 
117  // XUnoTunnel
118  virtual sal_Int64 SAL_CALL getSomething(
119  const css::uno::Sequence< sal_Int8 >& Identifier ) override;
120 
121  // XServiceInfo
122  virtual OUString SAL_CALL getImplementationName() override;
123  virtual sal_Bool SAL_CALL supportsService(
124  const OUString& rServiceName) override;
125  virtual css::uno::Sequence< OUString > SAL_CALL
126  getSupportedServiceNames() override;
127 
128  // XComponent
129  virtual void SAL_CALL dispose() override;
130  virtual void SAL_CALL addEventListener(
131  const css::uno::Reference< css::lang::XEventListener > & xListener) override;
132  virtual void SAL_CALL removeEventListener(
133  const css::uno::Reference< css::lang::XEventListener > & xListener) override;
134 
135  // XChild
136  virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
137  getParent() override;
138  virtual void SAL_CALL setParent(
139  css::uno::Reference< css::uno::XInterface> const& xParent) override;
140 
141  // XElementAccess
142  virtual css::uno::Type SAL_CALL getElementType() override;
143  virtual sal_Bool SAL_CALL hasElements() override;
144 
145  // XEnumerationAccess
146  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
147  createEnumeration() override;
148 
149  // XTextContent
150  virtual void SAL_CALL attach(
151  const css::uno::Reference< css::text::XTextRange > & xTextRange) override;
152  virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override;
153 
154  // XTextRange
155  virtual css::uno::Reference< css::text::XText >
156  SAL_CALL getText() override;
157  virtual css::uno::Reference<
158  css::text::XTextRange > SAL_CALL getStart() override;
159  virtual css::uno::Reference<
160  css::text::XTextRange > SAL_CALL getEnd() override;
161  virtual OUString SAL_CALL getString() override;
162  virtual void SAL_CALL setString(const OUString& rString) override;
163 
164  // XSimpleText
165  virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL
166  createTextCursor() override;
167  virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL
169  const css::uno::Reference< css::text::XTextRange > & xTextPosition) override;
170  virtual void SAL_CALL insertString(
171  const css::uno::Reference< css::text::XTextRange > & xRange,
172  const OUString& aString, sal_Bool bAbsorb) override;
173  virtual void SAL_CALL insertControlCharacter(
174  const css::uno::Reference< css::text::XTextRange > & xRange,
175  sal_Int16 nControlCharacter, sal_Bool bAbsorb) override;
176 
177  // XText
178  virtual void SAL_CALL insertTextContent(
179  const css::uno::Reference< css::text::XTextRange > & xRange,
180  const css::uno::Reference< css::text::XTextContent > & xContent,
181  sal_Bool bAbsorb) override;
182  virtual void SAL_CALL removeTextContent(
183  const css::uno::Reference< css::text::XTextContent > & xContent) override;
184 
185 };
186 
187 typedef ::cppu::ImplInheritanceHelper
188 < SwXMeta
189 , css::beans::XPropertySet
190 , css::text::XTextField
192 
194  : public SwXMetaField_Base
195 {
196 
197 private:
198 
199  virtual ~SwXMetaField() override;
200 
201  friend css::uno::Reference< css::rdf::XMetadatable >
203  css::uno::Reference< css::text::XText> const&,
204  std::unique_ptr<TextRangeList_t const> && pPortions);
205 
206  SwXMetaField(SwDoc *const pDoc, ::sw::Meta *const pMeta,
207  css::uno::Reference< css::text::XText> const& xParentText,
208  std::unique_ptr<TextRangeList_t const> pPortions);
209 
210  friend css::uno::Reference<css::rdf::XMetadatable>
211  SwXMeta::CreateXMeta(SwDoc &, bool);
212 
213  SwXMetaField(SwDoc *const pDoc);
214 
215 public:
216 
217  // XServiceInfo
218  virtual OUString SAL_CALL getImplementationName() override;
219  virtual sal_Bool SAL_CALL supportsService(
220  const OUString& ServiceName) override;
221  virtual css::uno::Sequence< OUString > SAL_CALL
222  getSupportedServiceNames( ) override;
223 
224  // XComponent
225  virtual void SAL_CALL dispose() override;
226  virtual void SAL_CALL addEventListener(
227  const css::uno::Reference< css::lang::XEventListener > & xListener) override;
228  virtual void SAL_CALL removeEventListener(
229  const css::uno::Reference< css::lang::XEventListener > & xListener) override;
230 
231  // XPropertySet
232  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
233  getPropertySetInfo() override;
234  virtual void SAL_CALL setPropertyValue(
235  const OUString& rPropertyName,
236  const css::uno::Any& rValue) override;
237  virtual css::uno::Any SAL_CALL
238  getPropertyValue(const OUString& rPropertyName) override;
239  virtual void SAL_CALL addPropertyChangeListener(
240  const OUString& rPropertyName,
241  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
242  virtual void SAL_CALL removePropertyChangeListener(
243  const OUString& rPropertyName,
244  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
245  virtual void SAL_CALL addVetoableChangeListener(
246  const OUString& rPropertyName,
247  const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
248  virtual void SAL_CALL removeVetoableChangeListener(
249  const OUString& rPropertyName,
250  const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
251 
252  // XTextContent
253  virtual void SAL_CALL attach(
254  const css::uno::Reference< css::text::XTextRange > & xTextRange) override;
255  virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override;
256 
257  // XTextField
258  virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override;
259 
260 };
261 
263 void getPrefixAndSuffix(
264  const css::uno::Reference< css::frame::XModel>& xModel,
265  const css::uno::Reference< css::rdf::XMetadatable>& xMetaField,
266  OUString *const o_pPrefix, OUString *const o_pSuffix);
267 
268 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNOMETA_HXX
269 
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unorefmk.cxx:1020
std::deque< css::uno::Reference< css::text::XTextRange > > TextRangeList_t
Definition: unometa.hxx:42
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unorefmk.cxx:1278
static css::uno::Reference< css::rdf::XMetadatable > CreateXMeta(::sw::Meta &rMeta, css::uno::Reference< css::text::XText > const &xParentText=nullptr, std::unique_ptr< TextRangeList_t const > &&pPortions=std::unique_ptr< TextRangeList_t const >())
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unorefmk.cxx:1060
SwXMeta(SwXMeta const &)=delete
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unorefmk.cxx:1171
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unorefmk.cxx:1026
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unorefmk.cxx:1403
css::uno::Reference< css::text::XText > const & GetParentText() const
Definition: unorefmk.cxx:668
SwXMeta & operator=(SwXMeta const &)=delete
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
Definition: unorefmk.cxx:1145
Definition: doc.hxx:185
virtual OUString SAL_CALL getImplementationName() override
Definition: unorefmk.cxx:860
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unorefmk.cxx:1289
::cppu::ImplInheritanceHelper< ::sfx2::MetadatableMixin, css::lang::XUnoTunnel, css::lang::XServiceInfo, css::container::XChild, css::container::XEnumerationAccess, css::text::XTextContent, css::text::XText > SwXMeta_Base
Definition: unometa.hxx:59
virtual void SAL_CALL insertControlCharacter(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb) override
Definition: unorefmk.cxx:1118
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unorefmk.cxx:882
bool CheckForOwnMemberMeta(const SwPaM &rPam, const bool bAbsorb)
Definition: unorefmk.cxx:780
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unometa.hxx:67
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unorefmk.cxx:1316
Dialog to specify the properties of date form field.
virtual ~SwXMetaField() override
Definition: unorefmk.cxx:1260
virtual void SAL_CALL removeTextContent(const css::uno::Reference< css::text::XTextContent > &xContent) override
Definition: unorefmk.cxx:1136
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > &xTextPosition) override
Definition: unorefmk.cxx:1102
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &Identifier) override
Definition: unorefmk.cxx:853
virtual ~SwXMeta() override
Definition: unorefmk.cxx:685
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unorefmk.cxx:1411
void getPrefixAndSuffix(const css::uno::Reference< css::frame::XModel > &xModel, const css::uno::Reference< css::rdf::XMetadatable > &xMetaField, OUString *const o_pPrefix, OUString *const o_pSuffix)
get prefix/suffix from the RDF repository.
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unorefmk.cxx:890
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unorefmk.cxx:1334
std::unique_ptr< T, UnoImplPtrDeleter< T > > UnoImplPtr
Smart pointer class ensuring that the pointed object is deleted with a locked SolarMutex.
SwXMetaField(SwDoc *const pDoc,::sw::Meta *const pMeta, css::uno::Reference< css::text::XText > const &xParentText, std::unique_ptr< TextRangeList_t const > pPortions)
virtual void SAL_CALL dispose() override
Definition: unorefmk.cxx:898
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
Definition: unorefmk.cxx:1095
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unorefmk.cxx:1310
virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override
Definition: unorefmk.cxx:1496
unsigned char sal_Bool
virtual ::sfx2::Metadatable * GetCoreObject() override
Definition: unorefmk.cxx:1221
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unorefmk.cxx:872
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unorefmk.cxx:1073
virtual void SAL_CALL insertString(const css::uno::Reference< css::text::XTextRange > &xRange, const OUString &aString, sal_Bool bAbsorb) override
Definition: unorefmk.cxx:1110
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unorefmk.cxx:866
virtual sal_Bool SAL_CALL hasElements() override
Definition: unorefmk.cxx:1176
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unorefmk.cxx:1323
virtual void SAL_CALL insertTextContent(const css::uno::Reference< css::text::XTextRange > &xRange, const css::uno::Reference< css::text::XTextContent > &xContent, sal_Bool bAbsorb) override
Definition: unorefmk.cxx:1128
virtual OUString SAL_CALL getString() override
Definition: unorefmk.cxx:1080
virtual OUString SAL_CALL getImplementationName() override
Definition: unorefmk.cxx:1266
void AttachImpl(const css::uno::Reference< css::text::XTextRange > &xTextRange, const sal_uInt16 nWhich)
Definition: unorefmk.cxx:931
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unorefmk.cxx:1272
::cppu::ImplInheritanceHelper< SwXMeta, css::beans::XPropertySet, css::text::XTextField > SwXMetaField_Base
Definition: unometa.hxx:191
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
virtual void SAL_CALL setString(const OUString &rString) override
Definition: unorefmk.cxx:1087
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unorefmk.cxx:1367
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unorefmk.cxx:846
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unorefmk.cxx:1395
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unorefmk.cxx:1184
virtual void SAL_CALL setParent(css::uno::Reference< css::uno::XInterface > const &xParent) override
Definition: unorefmk.cxx:1164
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unorefmk.cxx:1066
virtual css::uno::Reference< css::frame::XModel > GetModel() override
Definition: unorefmk.cxx:1226
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unorefmk.cxx:1419
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unorefmk.cxx:1296
bool SetContentRange(SwTextNode *&rpNode, sal_Int32 &rStart, sal_Int32 &rEnd) const
init params with position of the attribute content (w/out CH_TXTATR)
Definition: unorefmk.cxx:758
virtual void SAL_CALL dispose() override
Definition: unorefmk.cxx:1303