docthemes: Save themes def. to a file when added to ColorSets
[LibreOffice.git] / sw / source / core / inc / unobookmark.hxx
blobdf39881562a862c8d30ee78a4ce122af13dbe2c0
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 <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/container/XNamed.hpp>
25 #include <com/sun/star/text/XTextContent.hpp>
26 #include <com/sun/star/text/XTextField.hpp>
27 #include <com/sun/star/text/XFormField.hpp>
29 #include <cppuhelper/implbase.hxx>
31 #include <svl/listener.hxx>
32 #include <sfx2/Metadatable.hxx>
34 #include <unobaseclass.hxx>
35 #include <IDocumentMarkAccess.hxx>
37 class SwDoc;
38 class SwXTextRange;
40 typedef ::cppu::ImplInheritanceHelper
41 < ::sfx2::MetadatableMixin
42 , css::lang::XServiceInfo
43 , css::beans::XPropertySet
44 , css::container::XNamed
45 , css::text::XTextContent
46 > SwXBookmark_Base;
48 /// UNO API wrapper around an internal sw::mark::MarkBase.
49 class SAL_DLLPUBLIC_RTTI SwXBookmark
50 : public SwXBookmark_Base
53 private:
55 class Impl;
56 ::sw::UnoImplPtr<Impl> m_pImpl;
58 protected:
59 /// @throws css::lang::IllegalArgumentException
60 /// @throws css::uno::RuntimeException
61 void attachToRangeEx(
62 const css::uno::Reference< css::text::XTextRange > & xTextRange,
63 IDocumentMarkAccess::MarkType eType,
64 bool isFieldmarkSeparatorAtStart = false);
65 /// @throws css::lang::IllegalArgumentException
66 /// @throws css::uno::RuntimeException
67 virtual void attachToRange(
68 const css::uno::Reference< css::text::XTextRange > & xTextRange);
70 ::sw::mark::MarkBase* GetBookmark() const;
72 IDocumentMarkAccess* GetIDocumentMarkAccess();
74 SwDoc * GetDoc();
76 void registerInMark( SwXBookmark& rXMark, ::sw::mark::MarkBase* const pMarkBase );
78 virtual ~SwXBookmark() override;
80 SwXBookmark(SwDoc *const pDoc);
82 /// descriptor
83 SwXBookmark();
85 public:
87 static rtl::Reference<SwXBookmark>
88 CreateXBookmark(SwDoc & rDoc, ::sw::mark::MarkBase * pBookmark);
90 /// @return IMark for this, but only if it lives in pDoc
91 static ::sw::mark::MarkBase const* GetBookmarkInDoc(SwDoc const*const pDoc,
92 const css::uno::Reference<css::uno::XInterface> & xUT);
94 // MetadatableMixin
95 virtual ::sfx2::Metadatable* GetCoreObject() override;
96 virtual css::uno::Reference< css::frame::XModel > GetModel() override;
98 // XServiceInfo
99 virtual OUString SAL_CALL getImplementationName() override;
100 virtual sal_Bool SAL_CALL supportsService(
101 const OUString& rServiceName) override;
102 virtual css::uno::Sequence< OUString > SAL_CALL
103 getSupportedServiceNames() override;
105 // XComponent
106 virtual void SAL_CALL dispose() override;
107 virtual void SAL_CALL addEventListener(
108 const css::uno::Reference< css::lang::XEventListener > & xListener) override;
109 virtual void SAL_CALL removeEventListener(
110 const css::uno::Reference< css::lang::XEventListener > & xListener) override;
112 // XPropertySet
113 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
114 getPropertySetInfo() override;
115 virtual void SAL_CALL setPropertyValue(
116 const OUString& rPropertyName,
117 const css::uno::Any& rValue) override;
118 virtual css::uno::Any SAL_CALL getPropertyValue(
119 const OUString& rPropertyName) override;
120 virtual void SAL_CALL addPropertyChangeListener(
121 const OUString& rPropertyName,
122 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
123 virtual void SAL_CALL removePropertyChangeListener(
124 const OUString& rPropertyName,
125 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
126 virtual void SAL_CALL addVetoableChangeListener(
127 const OUString& rPropertyName,
128 const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
129 virtual void SAL_CALL removeVetoableChangeListener(
130 const OUString& rPropertyName,
131 const css::uno::Reference<
132 css::beans::XVetoableChangeListener >& xListener) override;
134 // XNamed
135 virtual OUString SAL_CALL getName() override;
136 SW_DLLPUBLIC virtual void SAL_CALL setName(const OUString& rName) override;
138 // XTextContent
139 virtual void SAL_CALL attach(
140 const css::uno::Reference< css::text::XTextRange > & xTextRange) override;
141 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override;
145 class SwXFieldmarkParameters final
146 : public ::cppu::WeakImplHelper< css::container::XNameContainer>
147 , public SvtListener
149 private:
150 ::sw::mark::Fieldmark* m_pFieldmark;
151 /// @throws css::uno::RuntimeException
152 ::sw::mark::Fieldmark::parameter_map_t* getCoreParameters();
153 public:
154 SwXFieldmarkParameters(::sw::mark::Fieldmark* const pFieldmark)
155 : m_pFieldmark(pFieldmark)
157 StartListening(pFieldmark->GetNotifier());
160 // XNameContainer
161 virtual void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override;
162 virtual void SAL_CALL removeByName( const OUString& Name ) override;
163 // XNameReplace
164 virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override;
165 // XNameAccess
166 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
167 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
168 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
169 // XElementAccess
170 virtual css::uno::Type SAL_CALL getElementType( ) override;
171 virtual sal_Bool SAL_CALL hasElements( ) override;
173 virtual void Notify( const SfxHint& rHint ) override;
176 typedef cppu::ImplInheritanceHelper< SwXBookmark,
177 css::text::XFormField,
178 css::text::XTextField
179 > SwXFieldmark_Base;
181 /// UNO wrapper around an sw::mark::Fieldmark.
182 class SW_DLLPUBLIC SwXFieldmark final
183 : public SwXFieldmark_Base
185 ::sw::mark::CheckboxFieldmark* getCheckboxFieldmark();
186 bool const m_bReplacementObject;
187 bool m_isFieldmarkSeparatorAtStart = false;
189 rtl::Reference<SwXTextRange>
190 GetCommand(::sw::mark::Fieldmark const& rMark);
191 rtl::Reference<SwXTextRange>
192 GetResult(::sw::mark::Fieldmark const& rMark);
194 SwXFieldmark(bool isReplacementObject, SwDoc* pDoc);
196 // workaround MSVC compiler
197 SwXFieldmark(const SwXFieldmark&) = delete;
198 SwXFieldmark(SwXFieldmark&&) = delete;
200 public:
201 static rtl::Reference<SwXFieldmark>
202 CreateXFieldmark(SwDoc & rDoc, ::sw::mark::MarkBase * pMark,
203 bool isReplacementObject = false);
205 virtual void attachToRange(
206 const css::uno::Reference<css::text::XTextRange > & xTextRange) override;
208 // XServiceInfo
209 virtual OUString SAL_CALL getImplementationName() override;
210 virtual css::uno::Sequence<OUString> SAL_CALL
211 getSupportedServiceNames() override;
213 // XPropertySet
214 virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL
215 getPropertySetInfo() override;
216 virtual void SAL_CALL setPropertyValue(
217 const OUString& rPropertyName,
218 const css::uno::Any& rValue) override;
219 virtual css::uno::Any SAL_CALL getPropertyValue(
220 const OUString& rPropertyName) override;
222 // XComponent
223 virtual void SAL_CALL dispose() override;
224 virtual void SAL_CALL addEventListener(
225 const css::uno::Reference<css::lang::XEventListener> & xListener) override;
226 virtual void SAL_CALL removeEventListener(
227 const css::uno::Reference<css::lang::XEventListener> & xListener) override;
229 // XTextContent
230 virtual void SAL_CALL attach(
231 const css::uno::Reference<css::text::XTextRange> & xTextRange) override;
232 virtual css::uno::Reference<css::text::XTextRange> SAL_CALL getAnchor() override;
234 // XTextField
235 virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override;
237 // XFormField
238 virtual OUString SAL_CALL getFieldType() override;
239 virtual void SAL_CALL setFieldType(const OUString& description) override;
240 virtual css::uno::Reference<css::container::XNameContainer> SAL_CALL getParameters() override;
244 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */