Line data Source code
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 SC_FMTUNO_HXX
21 : #define SC_FMTUNO_HXX
22 :
23 : #include <vector>
24 :
25 : #include <formula/grammar.hxx>
26 : #include <svl/itemprop.hxx>
27 : #include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
28 : #include <com/sun/star/sheet/XSheetCondition.hpp>
29 : #include <com/sun/star/sheet/XSheetCondition2.hpp>
30 : #include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
31 : #include <com/sun/star/lang/XServiceInfo.hpp>
32 : #include <com/sun/star/container/XNameAccess.hpp>
33 : #include <com/sun/star/container/XEnumerationAccess.hpp>
34 : #include <com/sun/star/lang/XUnoTunnel.hpp>
35 : #include <com/sun/star/beans/XPropertySet.hpp>
36 :
37 : #include <com/sun/star/sheet/XMultiFormulaTokens.hpp>
38 : #include <com/sun/star/sheet/FormulaToken.hpp>
39 : #include <cppuhelper/implbase3.hxx>
40 : #include <cppuhelper/implbase4.hxx>
41 : #include <cppuhelper/implbase5.hxx>
42 : #include <com/sun/star/sheet/ConditionOperator2.hpp>
43 :
44 : #include "address.hxx"
45 : #include "conditio.hxx"
46 :
47 : class ScDocument;
48 : class ScTableConditionalEntry;
49 : class ScConditionalFormat;
50 : class ScValidationData;
51 :
52 :
53 0 : struct ScCondFormatEntryItem
54 : {
55 : ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > maTokens1;
56 : ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > maTokens2;
57 : String maExpr1;
58 : String maExpr2;
59 : String maExprNmsp1;
60 : String maExprNmsp2;
61 : String maPosStr; // formula position as text
62 : String maStyle; // display name as stored in ScStyleSheet
63 : ScAddress maPos;
64 : formula::FormulaGrammar::Grammar meGrammar1; // grammar used with maExpr1
65 : formula::FormulaGrammar::Grammar meGrammar2; // grammar used with maExpr2
66 : ScConditionMode meMode;
67 :
68 : // Make sure the grammar is initialized for API calls.
69 : ScCondFormatEntryItem();
70 : };
71 :
72 : class ScTableConditionalFormat : public cppu::WeakImplHelper5<
73 : com::sun::star::sheet::XSheetConditionalEntries,
74 : com::sun::star::container::XNameAccess,
75 : com::sun::star::container::XEnumerationAccess,
76 : com::sun::star::lang::XUnoTunnel,
77 : com::sun::star::lang::XServiceInfo >
78 : {
79 : private:
80 : std::vector<ScTableConditionalEntry*> aEntries;
81 :
82 : ScTableConditionalEntry* GetObjectByIndex_Impl(sal_uInt16 nIndex) const;
83 : void AddEntry_Impl(const ScCondFormatEntryItem& aEntry);
84 :
85 : ScTableConditionalFormat(); // disable
86 : public:
87 : ScTableConditionalFormat(ScDocument* pDoc, sal_uLong nKey,
88 : SCTAB nTab, formula::FormulaGrammar::Grammar eGrammar);
89 : virtual ~ScTableConditionalFormat();
90 :
91 : void FillFormat( ScConditionalFormat& rFormat, ScDocument* pDoc,
92 : formula::FormulaGrammar::Grammar eGrammar) const;
93 :
94 : // XSheetConditionalEntries
95 : virtual void SAL_CALL addNew( const ::com::sun::star::uno::Sequence<
96 : ::com::sun::star::beans::PropertyValue >& aConditionalEntry )
97 : throw(::com::sun::star::uno::RuntimeException);
98 : virtual void SAL_CALL removeByIndex( sal_Int32 nIndex )
99 : throw(::com::sun::star::uno::RuntimeException);
100 : virtual void SAL_CALL clear() throw(::com::sun::star::uno::RuntimeException);
101 :
102 : // XIndexAccess
103 : virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
104 : virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
105 : throw(::com::sun::star::lang::IndexOutOfBoundsException,
106 : ::com::sun::star::lang::WrappedTargetException,
107 : ::com::sun::star::uno::RuntimeException);
108 :
109 : // XNameAccess
110 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
111 : throw(::com::sun::star::container::NoSuchElementException,
112 : ::com::sun::star::lang::WrappedTargetException,
113 : ::com::sun::star::uno::RuntimeException);
114 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
115 : throw(::com::sun::star::uno::RuntimeException);
116 : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
117 : throw(::com::sun::star::uno::RuntimeException);
118 :
119 : // XEnumerationAccess
120 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
121 : createEnumeration() throw(::com::sun::star::uno::RuntimeException);
122 :
123 : // XElementAccess
124 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
125 : throw(::com::sun::star::uno::RuntimeException);
126 : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
127 :
128 : // XUnoTunnel
129 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
130 : sal_Int8 >& aIdentifier )
131 : throw(::com::sun::star::uno::RuntimeException);
132 :
133 : static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
134 : static ScTableConditionalFormat* getImplementation( const com::sun::star::uno::Reference<
135 : com::sun::star::sheet::XSheetConditionalEntries> xObj );
136 :
137 : // XServiceInfo
138 : virtual ::rtl::OUString SAL_CALL getImplementationName()
139 : throw(::com::sun::star::uno::RuntimeException);
140 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
141 : throw(::com::sun::star::uno::RuntimeException);
142 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
143 : throw(::com::sun::star::uno::RuntimeException);
144 : };
145 :
146 :
147 :
148 : class ScTableConditionalEntry : public cppu::WeakImplHelper3<
149 : com::sun::star::sheet::XSheetCondition2,
150 : com::sun::star::sheet::XSheetConditionalEntry,
151 : com::sun::star::lang::XServiceInfo >
152 : {
153 : private:
154 : ScCondFormatEntryItem aData;
155 :
156 : ScTableConditionalEntry(); // disabled
157 : public:
158 : ScTableConditionalEntry(const ScCondFormatEntryItem& aItem);
159 : virtual ~ScTableConditionalEntry();
160 :
161 : void GetData(ScCondFormatEntryItem& rData) const;
162 :
163 : // XSheetCondition
164 : virtual ::com::sun::star::sheet::ConditionOperator SAL_CALL getOperator()
165 : throw(::com::sun::star::uno::RuntimeException);
166 : virtual sal_Int32 SAL_CALL getConditionOperator()
167 : throw(::com::sun::star::uno::RuntimeException);
168 : virtual void SAL_CALL setOperator( ::com::sun::star::sheet::ConditionOperator nOperator )
169 : throw(::com::sun::star::uno::RuntimeException);
170 : virtual void SAL_CALL setConditionOperator( sal_Int32 nOperator )
171 : throw(::com::sun::star::uno::RuntimeException);
172 : virtual ::rtl::OUString SAL_CALL getFormula1() throw(::com::sun::star::uno::RuntimeException);
173 : virtual void SAL_CALL setFormula1( const ::rtl::OUString& aFormula1 )
174 : throw(::com::sun::star::uno::RuntimeException);
175 : virtual ::rtl::OUString SAL_CALL getFormula2() throw(::com::sun::star::uno::RuntimeException);
176 : virtual void SAL_CALL setFormula2( const ::rtl::OUString& aFormula2 )
177 : throw(::com::sun::star::uno::RuntimeException);
178 : virtual ::com::sun::star::table::CellAddress SAL_CALL getSourcePosition()
179 : throw(::com::sun::star::uno::RuntimeException);
180 : virtual void SAL_CALL setSourcePosition( const ::com::sun::star::table::CellAddress& aSourcePosition )
181 : throw(::com::sun::star::uno::RuntimeException);
182 :
183 : // XSheetConditionalEntry
184 : virtual ::rtl::OUString SAL_CALL getStyleName() throw(::com::sun::star::uno::RuntimeException);
185 : virtual void SAL_CALL setStyleName( const ::rtl::OUString& aStyleName )
186 : throw(::com::sun::star::uno::RuntimeException);
187 :
188 : // XServiceInfo
189 : virtual ::rtl::OUString SAL_CALL getImplementationName()
190 : throw(::com::sun::star::uno::RuntimeException);
191 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
192 : throw(::com::sun::star::uno::RuntimeException);
193 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
194 : throw(::com::sun::star::uno::RuntimeException);
195 : };
196 :
197 :
198 :
199 : class ScTableValidationObj : public cppu::WeakImplHelper5<
200 : com::sun::star::sheet::XSheetCondition2,
201 : com::sun::star::sheet::XMultiFormulaTokens,
202 : com::sun::star::beans::XPropertySet,
203 : com::sun::star::lang::XUnoTunnel,
204 : com::sun::star::lang::XServiceInfo >
205 : {
206 : private:
207 : SfxItemPropertySet aPropSet;
208 : sal_uInt16 nMode; // enum ScConditionMode
209 : String aExpr1;
210 : String aExpr2;
211 : String maExprNmsp1;
212 : String maExprNmsp2;
213 : formula::FormulaGrammar::Grammar meGrammar1; // grammar used with aExpr1 and aExpr2
214 : formula::FormulaGrammar::Grammar meGrammar2; // grammar used with aExpr1 and aExpr2
215 : ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > aTokens1;
216 : ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > aTokens2;
217 : ScAddress aSrcPos;
218 : String aPosString; // formula position as text
219 : sal_uInt16 nValMode; // enum ScValidationMode
220 : sal_Bool bIgnoreBlank;
221 : sal_Int16 nShowList;
222 : sal_Bool bShowInput;
223 : String aInputTitle;
224 : String aInputMessage;
225 : sal_Bool bShowError;
226 : sal_uInt16 nErrorStyle; // enum ScValidErrorStyle
227 : String aErrorTitle;
228 : String aErrorMessage;
229 :
230 : void ClearData_Impl();
231 :
232 : ScTableValidationObj(); // disabled
233 : public:
234 : ScTableValidationObj(ScDocument* pDoc, sal_uLong nKey,
235 : const formula::FormulaGrammar::Grammar eGrammar);
236 : virtual ~ScTableValidationObj();
237 :
238 : ScValidationData* CreateValidationData( ScDocument* pDoc,
239 : formula::FormulaGrammar::Grammar eGrammar ) const;
240 :
241 : // XSheetCondition
242 : virtual ::com::sun::star::sheet::ConditionOperator SAL_CALL getOperator()
243 : throw(::com::sun::star::uno::RuntimeException);
244 : virtual sal_Int32 SAL_CALL getConditionOperator()
245 : throw(::com::sun::star::uno::RuntimeException);
246 : virtual void SAL_CALL setOperator( ::com::sun::star::sheet::ConditionOperator nOperator )
247 : throw(::com::sun::star::uno::RuntimeException);
248 : virtual void SAL_CALL setConditionOperator( sal_Int32 nOperator )
249 : throw(::com::sun::star::uno::RuntimeException);
250 : virtual ::rtl::OUString SAL_CALL getFormula1() throw(::com::sun::star::uno::RuntimeException);
251 : virtual void SAL_CALL setFormula1( const ::rtl::OUString& aFormula1 )
252 : throw(::com::sun::star::uno::RuntimeException);
253 : virtual ::rtl::OUString SAL_CALL getFormula2() throw(::com::sun::star::uno::RuntimeException);
254 : virtual void SAL_CALL setFormula2( const ::rtl::OUString& aFormula2 )
255 : throw(::com::sun::star::uno::RuntimeException);
256 : virtual ::com::sun::star::table::CellAddress SAL_CALL getSourcePosition()
257 : throw(::com::sun::star::uno::RuntimeException);
258 : virtual void SAL_CALL setSourcePosition( const ::com::sun::star::table::CellAddress& aSourcePosition )
259 : throw(::com::sun::star::uno::RuntimeException);
260 :
261 : // XMultiFormulaTokens
262 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >
263 : SAL_CALL getTokens( sal_Int32 nIndex )
264 : throw(::com::sun::star::uno::RuntimeException,::com::sun::star::lang::IndexOutOfBoundsException);
265 : virtual void SAL_CALL setTokens( sal_Int32 nIndex,
266 : const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& aTokens )
267 : throw(::com::sun::star::uno::RuntimeException,::com::sun::star::lang::IndexOutOfBoundsException);
268 : virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
269 :
270 : // XPropertySet
271 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
272 : SAL_CALL getPropertySetInfo()
273 : throw(::com::sun::star::uno::RuntimeException);
274 : virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
275 : const ::com::sun::star::uno::Any& aValue )
276 : throw(::com::sun::star::beans::UnknownPropertyException,
277 : ::com::sun::star::beans::PropertyVetoException,
278 : ::com::sun::star::lang::IllegalArgumentException,
279 : ::com::sun::star::lang::WrappedTargetException,
280 : ::com::sun::star::uno::RuntimeException);
281 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
282 : const ::rtl::OUString& PropertyName )
283 : throw(::com::sun::star::beans::UnknownPropertyException,
284 : ::com::sun::star::lang::WrappedTargetException,
285 : ::com::sun::star::uno::RuntimeException);
286 : virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
287 : const ::com::sun::star::uno::Reference<
288 : ::com::sun::star::beans::XPropertyChangeListener >& xListener )
289 : throw(::com::sun::star::beans::UnknownPropertyException,
290 : ::com::sun::star::lang::WrappedTargetException,
291 : ::com::sun::star::uno::RuntimeException);
292 : virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
293 : const ::com::sun::star::uno::Reference<
294 : ::com::sun::star::beans::XPropertyChangeListener >& aListener )
295 : throw(::com::sun::star::beans::UnknownPropertyException,
296 : ::com::sun::star::lang::WrappedTargetException,
297 : ::com::sun::star::uno::RuntimeException);
298 : virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
299 : const ::com::sun::star::uno::Reference<
300 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
301 : throw(::com::sun::star::beans::UnknownPropertyException,
302 : ::com::sun::star::lang::WrappedTargetException,
303 : ::com::sun::star::uno::RuntimeException);
304 : virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
305 : const ::com::sun::star::uno::Reference<
306 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
307 : throw(::com::sun::star::beans::UnknownPropertyException,
308 : ::com::sun::star::lang::WrappedTargetException,
309 : ::com::sun::star::uno::RuntimeException);
310 :
311 : // XUnoTunnel
312 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
313 : sal_Int8 >& aIdentifier )
314 : throw(::com::sun::star::uno::RuntimeException);
315 :
316 : static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
317 : static ScTableValidationObj* getImplementation( const com::sun::star::uno::Reference<
318 : com::sun::star::beans::XPropertySet> xObj );
319 :
320 : // XServiceInfo
321 : virtual ::rtl::OUString SAL_CALL getImplementationName()
322 : throw(::com::sun::star::uno::RuntimeException);
323 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
324 : throw(::com::sun::star::uno::RuntimeException);
325 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
326 : throw(::com::sun::star::uno::RuntimeException);
327 : };
328 :
329 :
330 : #endif
331 :
332 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|