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 
10 #ifndef INCLUDED_SC_SOURCE_UI_INC_CONDFORMATUNO_HXX
11 #define INCLUDED_SC_SOURCE_UI_INC_CONDFORMATUNO_HXX
12 
13 #include <types.hxx>
14 
15 #include <com/sun/star/beans/XPropertySet.hpp>
16 #include <com/sun/star/sheet/XConditionalFormats.hpp>
17 #include <com/sun/star/sheet/XConditionalFormat.hpp>
18 #include <com/sun/star/sheet/XConditionEntry.hpp>
19 #include <com/sun/star/sheet/XColorScaleEntry.hpp>
20 #include <com/sun/star/sheet/XDataBarEntry.hpp>
21 #include <com/sun/star/sheet/XIconSetEntry.hpp>
22 
23 #include <cppuhelper/implbase.hxx>
24 #include <svl/itemprop.hxx>
25 #include <svl/lstner.hxx>
26 #include <rtl/ref.hxx>
27 
28 class ScDocShell;
29 class ScConditionalFormatList;
30 class ScConditionalFormat;
31 class ScIconSetFormat;
32 class ScDataBarFormat;
33 class ScColorScaleFormat;
34 class ScCondFormatEntry;
35 class ScColorScaleEntry;
36 class ScCondDateFormatEntry;
37 
38 using namespace com::sun::star;
39 
40 namespace com { namespace sun { namespace star {
41 
42 namespace sheet {
43 
44 class XSheetCellRanges;
45 
46 }
47 
48 } } }
49 
50 class ScCondFormatsObj : public cppu::WeakImplHelper<css::sheet::XConditionalFormats>,
51                             public SfxListener
52 {
53 public:
54     ScCondFormatsObj(ScDocShell* pDocShell, SCTAB nTab);
55 
56     virtual ~ScCondFormatsObj() override;
57 
58     virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
59 
60     // XConditionalFormats
61     virtual sal_Int32 SAL_CALL createByRange(const uno::Reference<sheet::XSheetCellRanges>& xRanges) override;
62 
63     virtual void SAL_CALL removeByID( const sal_Int32 nID ) override;
64 
65     virtual uno::Sequence< uno::Reference< sheet::XConditionalFormat > > SAL_CALL getConditionalFormats() override;
66 
67     virtual sal_Int32 SAL_CALL getLength() override;
68 
69     ScConditionalFormatList* getCoreObject();
70 
71 private:
72     SCTAB const mnTab;
73     ScDocShell* mpDocShell;
74 };
75 
76 class ScCondFormatObj : public cppu::WeakImplHelper<css::sheet::XConditionalFormat,
77                             css::beans::XPropertySet>
78 {
79 public:
80     ScCondFormatObj(ScDocShell* pDocShell, rtl::Reference<ScCondFormatsObj> const & xCondFormats, sal_Int32 nKey);
81 
82     virtual ~ScCondFormatObj() override;
83 
84     ScDocShell* getDocShell();
85 
86     // XConditionalFormat
87     virtual void SAL_CALL createEntry(const sal_Int32 nType, const sal_Int32 nPos) override;
88 
89     virtual void SAL_CALL removeByIndex(const sal_Int32 nIndex) override;
90 
91     // XIndexAccess
92 
93     virtual uno::Type SAL_CALL getElementType() override;
94 
95     virtual sal_Bool SAL_CALL hasElements() override;
96 
97     virtual sal_Int32 SAL_CALL getCount() override;
98 
99     virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
100 
101     // XPropertySet
102     virtual css::uno::Reference< css::beans::XPropertySetInfo >
103                             SAL_CALL getPropertySetInfo() override;
104     virtual void SAL_CALL   setPropertyValue( const OUString& aPropertyName,
105                                     const css::uno::Any& aValue ) override;
106     virtual css::uno::Any SAL_CALL getPropertyValue(
107                                     const OUString& PropertyName ) override;
108     virtual void SAL_CALL   addPropertyChangeListener( const OUString& aPropertyName,
109                                     const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
110     virtual void SAL_CALL   removePropertyChangeListener( const OUString& aPropertyName,
111                                     const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
112     virtual void SAL_CALL   addVetoableChangeListener( const OUString& PropertyName,
113                                     const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
114     virtual void SAL_CALL   removeVetoableChangeListener( const OUString& PropertyName,
115                                     const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
116 
117     ScConditionalFormat* getCoreObject();
118 
119 private:
120     rtl::Reference<ScCondFormatsObj> mxCondFormatList;
121     ScDocShell* mpDocShell;
122     SfxItemPropertySet const maPropSet;
123     sal_Int32 const mnKey;
124 };
125 
126 class ScConditionEntryObj : public cppu::WeakImplHelper<css::beans::XPropertySet,
127                                 css::sheet::XConditionEntry>
128 {
129 public:
130 
131     ScConditionEntryObj(rtl::Reference<ScCondFormatObj> const & xParent,
132             const ScCondFormatEntry* pFormat);
133     virtual ~ScConditionEntryObj() override;
134 
135     ScCondFormatEntry* getCoreObject();
136 
137     // XConditionEntry
138     virtual sal_Int32 SAL_CALL getType() override;
139 
140     // XPropertySet
141     virtual css::uno::Reference< css::beans::XPropertySetInfo >
142                             SAL_CALL getPropertySetInfo() override;
143     virtual void SAL_CALL   setPropertyValue( const OUString& aPropertyName,
144                                     const css::uno::Any& aValue ) override;
145     virtual css::uno::Any SAL_CALL getPropertyValue(
146                                     const OUString& PropertyName ) override;
147     virtual void SAL_CALL   addPropertyChangeListener( const OUString& aPropertyName,
148                                     const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
149     virtual void SAL_CALL   removePropertyChangeListener( const OUString& aPropertyName,
150                                     const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
151     virtual void SAL_CALL   addVetoableChangeListener( const OUString& PropertyName,
152                                     const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
153     virtual void SAL_CALL   removeVetoableChangeListener( const OUString& PropertyName,
154                                     const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
155 
156 private:
157     ScDocShell* mpDocShell;
158     rtl::Reference<ScCondFormatObj> mxParent;
159     SfxItemPropertySet const maPropSet;
160     const ScCondFormatEntry* mpFormat;
161 };
162 
163 class ScColorScaleFormatObj : public cppu::WeakImplHelper<css::beans::XPropertySet,
164                                 css::sheet::XConditionEntry>
165 {
166 public:
167 
168     ScColorScaleFormatObj(rtl::Reference<ScCondFormatObj> const & xParent, const ScColorScaleFormat* pFormat);
169     virtual ~ScColorScaleFormatObj() override;
170 
171     // XConditionEntry
172     virtual sal_Int32 SAL_CALL getType() override;
173 
174 
175     ScColorScaleFormat* getCoreObject();
176 
177                             // XPropertySet
178     virtual css::uno::Reference< css::beans::XPropertySetInfo >
179                             SAL_CALL getPropertySetInfo() override;
180     virtual void SAL_CALL   setPropertyValue( const OUString& aPropertyName,
181                                     const css::uno::Any& aValue ) override;
182     virtual css::uno::Any SAL_CALL getPropertyValue(
183                                     const OUString& PropertyName ) override;
184     virtual void SAL_CALL   addPropertyChangeListener( const OUString& aPropertyName,
185                                     const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
186     virtual void SAL_CALL   removePropertyChangeListener( const OUString& aPropertyName,
187                                     const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
188     virtual void SAL_CALL   addVetoableChangeListener( const OUString& PropertyName,
189                                     const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
190     virtual void SAL_CALL   removeVetoableChangeListener( const OUString& PropertyName,
191                                     const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
192 
193 private:
194     rtl::Reference<ScCondFormatObj> mxParent;
195     SfxItemPropertySet const maPropSet;
196     const ScColorScaleFormat* mpFormat;
197 };
198 
199 class ScColorScaleEntryObj : public cppu::WeakImplHelper<css::sheet::XColorScaleEntry>
200 {
201 public:
202     ScColorScaleEntryObj(rtl::Reference<ScColorScaleFormatObj> const & xParent, size_t nPos);
203 
204     virtual ~ScColorScaleEntryObj() override;
205 
206     virtual sal_Int32 SAL_CALL getColor() override;
207 
208     virtual void SAL_CALL setColor(sal_Int32 aColor) override;
209 
210     virtual sal_Int32 SAL_CALL getType() override;
211 
212     virtual void SAL_CALL setType(sal_Int32 nType) override;
213 
214     virtual OUString SAL_CALL getFormula() override;
215 
216     virtual void SAL_CALL setFormula(const OUString& rString) override;
217 
218 private:
219     ScColorScaleEntry* getCoreObject();
220 
221     rtl::Reference<ScColorScaleFormatObj> mxParent;
222     size_t const mnPos;
223 };
224 
225 class ScDataBarFormatObj : public cppu::WeakImplHelper<css::beans::XPropertySet,
226                                 css::sheet::XConditionEntry>
227 {
228 public:
229     ScDataBarFormatObj(rtl::Reference<ScCondFormatObj> const & xParent,
230             const ScDataBarFormat* pFormat);
231     virtual ~ScDataBarFormatObj() override;
232 
233     ScDataBarFormat* getCoreObject();
234 
235     // XConditionEntry
236     virtual sal_Int32 SAL_CALL getType() override;
237 
238     // XPropertySet
239     virtual css::uno::Reference< css::beans::XPropertySetInfo >
240                             SAL_CALL getPropertySetInfo() override;
241     virtual void SAL_CALL   setPropertyValue( const OUString& aPropertyName,
242                                     const css::uno::Any& aValue ) override;
243     virtual css::uno::Any SAL_CALL getPropertyValue(
244                                     const OUString& PropertyName ) override;
245     virtual void SAL_CALL   addPropertyChangeListener( const OUString& aPropertyName,
246                                     const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
247     virtual void SAL_CALL   removePropertyChangeListener( const OUString& aPropertyName,
248                                     const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
249     virtual void SAL_CALL   addVetoableChangeListener( const OUString& PropertyName,
250                                     const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
251     virtual void SAL_CALL   removeVetoableChangeListener( const OUString& PropertyName,
252                                     const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
253 
254 private:
255     rtl::Reference<ScCondFormatObj> mxParent;
256     SfxItemPropertySet const maPropSet;
257     const ScDataBarFormat* mpFormat;
258 };
259 
260 class ScDataBarEntryObj : public cppu::WeakImplHelper<css::sheet::XDataBarEntry>
261 {
262 public:
263     ScDataBarEntryObj(rtl::Reference<ScDataBarFormatObj> const & xParent, size_t nPos);
264 
265     virtual ~ScDataBarEntryObj() override;
266 
267     virtual sal_Int32 SAL_CALL getType() override;
268 
269     virtual void SAL_CALL setType(sal_Int32 nType) override;
270 
271     virtual OUString SAL_CALL getFormula() override;
272 
273     virtual void SAL_CALL setFormula(const OUString& rString) override;
274 
275 private:
276     ScColorScaleEntry* getCoreObject();
277 
278     rtl::Reference<ScDataBarFormatObj> mxParent;
279     size_t const mnPos;
280 };
281 
282 class ScIconSetFormatObj : public cppu::WeakImplHelper<css::beans::XPropertySet,
283                                 css::sheet::XConditionEntry>
284 {
285 public:
286     ScIconSetFormatObj(rtl::Reference<ScCondFormatObj> const & xParent,
287             const ScIconSetFormat* pFormat);
288     virtual ~ScIconSetFormatObj() override;
289 
290     ScIconSetFormat* getCoreObject();
291 
292     // XConditionEntry
293     virtual sal_Int32 SAL_CALL getType() override;
294 
295     // XPropertySet
296     virtual css::uno::Reference< css::beans::XPropertySetInfo >
297                             SAL_CALL getPropertySetInfo() override;
298     virtual void SAL_CALL   setPropertyValue( const OUString& aPropertyName,
299                                     const css::uno::Any& aValue ) override;
300     virtual css::uno::Any SAL_CALL getPropertyValue(
301                                     const OUString& PropertyName ) override;
302     virtual void SAL_CALL   addPropertyChangeListener( const OUString& aPropertyName,
303                                     const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
304     virtual void SAL_CALL   removePropertyChangeListener( const OUString& aPropertyName,
305                                     const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
306     virtual void SAL_CALL   addVetoableChangeListener( const OUString& PropertyName,
307                                     const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
308     virtual void SAL_CALL   removeVetoableChangeListener( const OUString& PropertyName,
309                                     const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
310 
311 private:
312     rtl::Reference<ScCondFormatObj> mxParent;
313     SfxItemPropertySet const maPropSet;
314     const ScIconSetFormat* mpFormat;
315 };
316 
317 class ScIconSetEntryObj : public cppu::WeakImplHelper<css::sheet::XIconSetEntry>
318 {
319 public:
320     ScIconSetEntryObj(rtl::Reference<ScIconSetFormatObj> const & xParent, size_t nPos);
321 
322     virtual ~ScIconSetEntryObj() override;
323 
324     virtual sal_Int32 SAL_CALL getType() override;
325 
326     virtual void SAL_CALL setType(sal_Int32 nType) override;
327 
328     virtual OUString SAL_CALL getFormula() override;
329 
330     virtual void SAL_CALL setFormula(const OUString& rString) override;
331 
332 private:
333     ScColorScaleEntry* getCoreObject();
334 
335     rtl::Reference<ScIconSetFormatObj> mxParent;
336     size_t const mnPos;
337 };
338 
339 class ScCondDateFormatObj : public cppu::WeakImplHelper<css::beans::XPropertySet,
340                                 css::sheet::XConditionEntry>
341 {
342 public:
343     ScCondDateFormatObj(rtl::Reference<ScCondFormatObj> const & xParent,
344             const ScCondDateFormatEntry* pFormat);
345 
346     virtual ~ScCondDateFormatObj() override;
347 
348     ScCondDateFormatEntry* getCoreObject();
349 
350     // XConditionEntry
351     virtual sal_Int32 SAL_CALL getType() override;
352 
353     // XPropertySet
354     virtual css::uno::Reference< css::beans::XPropertySetInfo >
355                             SAL_CALL getPropertySetInfo() override;
356     virtual void SAL_CALL   setPropertyValue( const OUString& aPropertyName,
357                                     const css::uno::Any& aValue ) override;
358     virtual css::uno::Any SAL_CALL getPropertyValue(
359                                     const OUString& PropertyName ) override;
360     virtual void SAL_CALL   addPropertyChangeListener( const OUString& aPropertyName,
361                                     const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
362     virtual void SAL_CALL   removePropertyChangeListener( const OUString& aPropertyName,
363                                     const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
364     virtual void SAL_CALL   addVetoableChangeListener( const OUString& PropertyName,
365                                     const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
366     virtual void SAL_CALL   removeVetoableChangeListener( const OUString& PropertyName,
367                                     const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
368 
369 private:
370     rtl::Reference<ScCondFormatObj> mxParent;
371     SfxItemPropertySet const maPropSet;
372     const ScCondDateFormatEntry* mpFormat;
373 };
374 
375 #endif
376 
377 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
378