docthemes: Save themes def. to a file when added to ColorSets
[LibreOffice.git] / sw / source / core / inc / unometa.hxx
blobcb63789d492c5f78c2e2dafa4e05883affeb7089
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <memory>
23 #include <deque>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/container/XChild.hpp>
28 #include <com/sun/star/container/XEnumerationAccess.hpp>
29 #include <com/sun/star/text/XTextContent.hpp>
30 #include <com/sun/star/text/XTextField.hpp>
32 #include <cppuhelper/implbase.hxx>
34 #include <sfx2/Metadatable.hxx>
36 #include <unobaseclass.hxx>
38 class SwXTextPortion;
39 class SwPaM;
40 class SwTextNode;
41 class SwXText;
42 namespace sw {
43 class Meta;
46 typedef std::deque<
47 rtl::Reference<SwXTextPortion> >
48 TextRangeList_t;
52 typedef ::cppu::ImplInheritanceHelper
53 < ::sfx2::MetadatableMixin
54 , css::lang::XServiceInfo
55 , css::container::XChild
56 , css::container::XEnumerationAccess
57 , css::text::XTextContent
58 , css::text::XText
59 > SwXMeta_Base;
61 class SwXMeta
62 : public SwXMeta_Base
65 public:
67 class Impl;
69 protected:
71 ::sw::UnoImplPtr<Impl> m_pImpl;
73 /// @throws css::lang::IllegalArgumentException
74 /// @throws css::uno::RuntimeException
75 void AttachImpl(
76 const css::uno::Reference< css::text::XTextRange > & xTextRange,
77 const sal_uInt16 nWhich);
79 virtual ~SwXMeta() override;
81 SwXMeta(SwXMeta const&) = delete;
82 SwXMeta& operator=(SwXMeta const&) = delete;
84 /// @param pDoc and pMeta != 0, but not & because of ImplInheritanceHelper
85 SwXMeta(SwDoc *const pDoc, ::sw::Meta *const pMeta,
86 css::uno::Reference<SwXText> const& xParentText,
87 std::unique_ptr<TextRangeList_t const> pPortions);
89 SwXMeta(SwDoc *const pDoc);
91 public:
93 static rtl::Reference<SwXMeta>
94 CreateXMeta(
95 ::sw::Meta & rMeta,
96 const css::uno::Reference<SwXText>& xParentText,
97 std::unique_ptr<TextRangeList_t const> && pPortions);
99 static rtl::Reference<SwXMeta>
100 CreateXMeta(SwDoc & rDoc, bool isField);
102 /// init params with position of the attribute content (w/out CH_TXTATR)
103 bool SetContentRange( SwTextNode *& rpNode, sal_Int32 & rStart, sal_Int32 & rEnd) const;
104 css::uno::Reference< SwXText > const & GetParentText() const;
106 /// @throws css::lang::IllegalArgumentException
107 /// @throws css::uno::RuntimeException
108 bool CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb);
110 // MetadatableMixin
111 virtual ::sfx2::Metadatable * GetCoreObject() override;
112 virtual css::uno::Reference< css::frame::XModel >
113 GetModel() override;
115 // XServiceInfo
116 virtual OUString SAL_CALL getImplementationName() override;
117 virtual sal_Bool SAL_CALL supportsService(
118 const OUString& rServiceName) override;
119 virtual css::uno::Sequence< OUString > SAL_CALL
120 getSupportedServiceNames() override;
122 // XComponent
123 virtual void SAL_CALL dispose() override;
124 virtual void SAL_CALL addEventListener(
125 const css::uno::Reference< css::lang::XEventListener > & xListener) override;
126 virtual void SAL_CALL removeEventListener(
127 const css::uno::Reference< css::lang::XEventListener > & xListener) override;
129 // XChild
130 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
131 getParent() override;
132 virtual void SAL_CALL setParent(
133 css::uno::Reference< css::uno::XInterface> const& xParent) override;
135 // XElementAccess
136 virtual css::uno::Type SAL_CALL getElementType() override;
137 virtual sal_Bool SAL_CALL hasElements() override;
139 // XEnumerationAccess
140 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
141 createEnumeration() override;
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;
148 // XTextRange
149 virtual css::uno::Reference< css::text::XText >
150 SAL_CALL getText() override;
151 virtual css::uno::Reference<
152 css::text::XTextRange > SAL_CALL getStart() override;
153 virtual css::uno::Reference<
154 css::text::XTextRange > SAL_CALL getEnd() override;
155 virtual OUString SAL_CALL getString() override;
156 virtual void SAL_CALL setString(const OUString& rString) override;
158 // XSimpleText
159 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL
160 createTextCursor() override;
161 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL
162 createTextCursorByRange(
163 const css::uno::Reference< css::text::XTextRange > & xTextPosition) override;
164 virtual void SAL_CALL insertString(
165 const css::uno::Reference< css::text::XTextRange > & xRange,
166 const OUString& aString, sal_Bool bAbsorb) override;
167 virtual void SAL_CALL insertControlCharacter(
168 const css::uno::Reference< css::text::XTextRange > & xRange,
169 sal_Int16 nControlCharacter, sal_Bool bAbsorb) override;
171 // XText
172 virtual void SAL_CALL insertTextContent(
173 const css::uno::Reference< css::text::XTextRange > & xRange,
174 const css::uno::Reference< css::text::XTextContent > & xContent,
175 sal_Bool bAbsorb) override;
176 virtual void SAL_CALL removeTextContent(
177 const css::uno::Reference< css::text::XTextContent > & xContent) override;
181 typedef ::cppu::ImplInheritanceHelper
182 < SwXMeta
183 , css::beans::XPropertySet
184 , css::text::XTextField
185 > SwXMetaField_Base;
187 class SwXMetaField final
188 : public SwXMetaField_Base
191 private:
193 virtual ~SwXMetaField() override;
195 friend rtl::Reference<SwXMeta>
196 SwXMeta::CreateXMeta(::sw::Meta &,
197 const css::uno::Reference<SwXText>&,
198 std::unique_ptr<TextRangeList_t const> && pPortions);
200 SwXMetaField(SwDoc *const pDoc, ::sw::Meta *const pMeta,
201 css::uno::Reference<SwXText> const& xParentText,
202 std::unique_ptr<TextRangeList_t const> pPortions);
204 friend rtl::Reference<SwXMeta>
205 SwXMeta::CreateXMeta(SwDoc &, bool);
207 SwXMetaField(SwDoc *const pDoc);
209 public:
211 // XServiceInfo
212 virtual OUString SAL_CALL getImplementationName() override;
213 virtual sal_Bool SAL_CALL supportsService(
214 const OUString& ServiceName) override;
215 virtual css::uno::Sequence< OUString > SAL_CALL
216 getSupportedServiceNames( ) override;
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;
225 // XPropertySet
226 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
227 getPropertySetInfo() override;
228 virtual void SAL_CALL setPropertyValue(
229 const OUString& rPropertyName,
230 const css::uno::Any& rValue) override;
231 virtual css::uno::Any SAL_CALL
232 getPropertyValue(const OUString& rPropertyName) override;
233 virtual void SAL_CALL addPropertyChangeListener(
234 const OUString& rPropertyName,
235 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
236 virtual void SAL_CALL removePropertyChangeListener(
237 const OUString& rPropertyName,
238 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
239 virtual void SAL_CALL addVetoableChangeListener(
240 const OUString& rPropertyName,
241 const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
242 virtual void SAL_CALL removeVetoableChangeListener(
243 const OUString& rPropertyName,
244 const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
246 // XTextContent
247 virtual void SAL_CALL attach(
248 const css::uno::Reference< css::text::XTextRange > & xTextRange) override;
249 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override;
251 // XTextField
252 virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override;
256 /// get prefix/suffix from the RDF repository. @throws RuntimeException
257 void getPrefixAndSuffix(
258 const css::uno::Reference< css::frame::XModel>& xModel,
259 const css::uno::Reference< css::rdf::XMetadatable>& xMetaField,
260 OUString *const o_pPrefix, OUString *const o_pSuffix, OUString *const o_pShadowColor);
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */