1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOMETA_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_UNOMETA_HXX
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/container/XChild.hpp>
29 #include <com/sun/star/container/XEnumerationAccess.hpp>
30 #include <com/sun/star/text/XTextContent.hpp>
31 #include <com/sun/star/text/XTextField.hpp>
33 #include <cppuhelper/implbase.hxx>
35 #include <sfx2/Metadatable.hxx>
37 #include <unobaseclass.hxx>
40 css::uno::Reference
< css::text::XTextRange
> >
50 typedef ::cppu::ImplInheritanceHelper
51 < ::sfx2::MetadatableMixin
52 , css::lang::XServiceInfo
53 , css::container::XChild
54 , css::container::XEnumerationAccess
55 , css::text::XTextContent
69 ::sw::UnoImplPtr
<Impl
> m_pImpl
;
71 /// @throws css::lang::IllegalArgumentException
72 /// @throws css::uno::RuntimeException
74 const css::uno::Reference
< css::text::XTextRange
> & xTextRange
,
75 const sal_uInt16 nWhich
);
77 virtual ~SwXMeta() override
;
79 SwXMeta(SwXMeta
const&) = delete;
80 SwXMeta
& operator=(SwXMeta
const&) = delete;
82 /// @param pDoc and pMeta != 0, but not & because of ImplInheritanceHelper
83 SwXMeta(SwDoc
*const pDoc
, ::sw::Meta
*const pMeta
,
84 css::uno::Reference
< css::text::XText
> const& xParentText
,
85 std::unique_ptr
<TextRangeList_t
const> pPortions
);
87 SwXMeta(SwDoc
*const pDoc
);
91 static rtl::Reference
<SwXMeta
>
94 css::uno::Reference
< css::text::XText
> const& xParentText
= nullptr,
95 std::unique_ptr
<TextRangeList_t
const> && pPortions
= std::unique_ptr
<TextRangeList_t
const>());
97 static rtl::Reference
<SwXMeta
>
98 CreateXMeta(SwDoc
& rDoc
, bool isField
);
100 /// init params with position of the attribute content (w/out CH_TXTATR)
101 bool SetContentRange( SwTextNode
*& rpNode
, sal_Int32
& rStart
, sal_Int32
& rEnd
) const;
102 css::uno::Reference
< css::text::XText
> const & GetParentText() const;
104 /// @throws css::lang::IllegalArgumentException
105 /// @throws css::uno::RuntimeException
106 bool CheckForOwnMemberMeta(const SwPaM
& rPam
, const bool bAbsorb
);
109 virtual ::sfx2::Metadatable
* GetCoreObject() override
;
110 virtual css::uno::Reference
< css::frame::XModel
>
114 virtual OUString SAL_CALL
getImplementationName() override
;
115 virtual sal_Bool SAL_CALL
supportsService(
116 const OUString
& rServiceName
) override
;
117 virtual css::uno::Sequence
< OUString
> SAL_CALL
118 getSupportedServiceNames() override
;
121 virtual void SAL_CALL
dispose() override
;
122 virtual void SAL_CALL
addEventListener(
123 const css::uno::Reference
< css::lang::XEventListener
> & xListener
) override
;
124 virtual void SAL_CALL
removeEventListener(
125 const css::uno::Reference
< css::lang::XEventListener
> & xListener
) override
;
128 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
129 getParent() override
;
130 virtual void SAL_CALL
setParent(
131 css::uno::Reference
< css::uno::XInterface
> const& xParent
) override
;
134 virtual css::uno::Type SAL_CALL
getElementType() override
;
135 virtual sal_Bool SAL_CALL
hasElements() override
;
137 // XEnumerationAccess
138 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
139 createEnumeration() override
;
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
;
147 virtual css::uno::Reference
< css::text::XText
>
148 SAL_CALL
getText() override
;
149 virtual css::uno::Reference
<
150 css::text::XTextRange
> SAL_CALL
getStart() override
;
151 virtual css::uno::Reference
<
152 css::text::XTextRange
> SAL_CALL
getEnd() override
;
153 virtual OUString SAL_CALL
getString() override
;
154 virtual void SAL_CALL
setString(const OUString
& rString
) override
;
157 virtual css::uno::Reference
< css::text::XTextCursor
> SAL_CALL
158 createTextCursor() override
;
159 virtual css::uno::Reference
< css::text::XTextCursor
> SAL_CALL
160 createTextCursorByRange(
161 const css::uno::Reference
< css::text::XTextRange
> & xTextPosition
) override
;
162 virtual void SAL_CALL
insertString(
163 const css::uno::Reference
< css::text::XTextRange
> & xRange
,
164 const OUString
& aString
, sal_Bool bAbsorb
) override
;
165 virtual void SAL_CALL
insertControlCharacter(
166 const css::uno::Reference
< css::text::XTextRange
> & xRange
,
167 sal_Int16 nControlCharacter
, sal_Bool bAbsorb
) override
;
170 virtual void SAL_CALL
insertTextContent(
171 const css::uno::Reference
< css::text::XTextRange
> & xRange
,
172 const css::uno::Reference
< css::text::XTextContent
> & xContent
,
173 sal_Bool bAbsorb
) override
;
174 virtual void SAL_CALL
removeTextContent(
175 const css::uno::Reference
< css::text::XTextContent
> & xContent
) override
;
179 typedef ::cppu::ImplInheritanceHelper
181 , css::beans::XPropertySet
182 , css::text::XTextField
185 class SwXMetaField final
186 : public SwXMetaField_Base
191 virtual ~SwXMetaField() override
;
193 friend rtl::Reference
<SwXMeta
>
194 SwXMeta::CreateXMeta(::sw::Meta
&,
195 css::uno::Reference
< css::text::XText
> const&,
196 std::unique_ptr
<TextRangeList_t
const> && pPortions
);
198 SwXMetaField(SwDoc
*const pDoc
, ::sw::Meta
*const pMeta
,
199 css::uno::Reference
< css::text::XText
> const& xParentText
,
200 std::unique_ptr
<TextRangeList_t
const> pPortions
);
202 friend rtl::Reference
<SwXMeta
>
203 SwXMeta::CreateXMeta(SwDoc
&, bool);
205 SwXMetaField(SwDoc
*const pDoc
);
210 virtual OUString SAL_CALL
getImplementationName() override
;
211 virtual sal_Bool SAL_CALL
supportsService(
212 const OUString
& ServiceName
) override
;
213 virtual css::uno::Sequence
< OUString
> SAL_CALL
214 getSupportedServiceNames( ) override
;
217 virtual void SAL_CALL
dispose() override
;
218 virtual void SAL_CALL
addEventListener(
219 const css::uno::Reference
< css::lang::XEventListener
> & xListener
) override
;
220 virtual void SAL_CALL
removeEventListener(
221 const css::uno::Reference
< css::lang::XEventListener
> & xListener
) override
;
224 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
225 getPropertySetInfo() override
;
226 virtual void SAL_CALL
setPropertyValue(
227 const OUString
& rPropertyName
,
228 const css::uno::Any
& rValue
) override
;
229 virtual css::uno::Any SAL_CALL
230 getPropertyValue(const OUString
& rPropertyName
) override
;
231 virtual void SAL_CALL
addPropertyChangeListener(
232 const OUString
& rPropertyName
,
233 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
234 virtual void SAL_CALL
removePropertyChangeListener(
235 const OUString
& rPropertyName
,
236 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
237 virtual void SAL_CALL
addVetoableChangeListener(
238 const OUString
& rPropertyName
,
239 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& xListener
) override
;
240 virtual void SAL_CALL
removeVetoableChangeListener(
241 const OUString
& rPropertyName
,
242 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& xListener
) override
;
245 virtual void SAL_CALL
attach(
246 const css::uno::Reference
< css::text::XTextRange
> & xTextRange
) override
;
247 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
getAnchor() override
;
250 virtual OUString SAL_CALL
getPresentation(sal_Bool bShowCommand
) override
;
254 /// get prefix/suffix from the RDF repository. @throws RuntimeException
255 void getPrefixAndSuffix(
256 const css::uno::Reference
< css::frame::XModel
>& xModel
,
257 const css::uno::Reference
< css::rdf::XMetadatable
>& xMetaField
,
258 OUString
*const o_pPrefix
, OUString
*const o_pSuffix
, OUString
*const o_pShadowColor
);
260 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNOMETA_HXX
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */