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 : css::uno::Sequence< css::sheet::FormulaToken > maTokens1;
56 : css::uno::Sequence< css::sheet::FormulaToken > maTokens2;
57 : OUString maExpr1;
58 : OUString maExpr2;
59 : OUString maExprNmsp1;
60 : OUString maExprNmsp2;
61 : OUString maPosStr; // formula position as text
62 : OUString 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, std::exception) SAL_OVERRIDE;
98 : virtual void SAL_CALL removeByIndex( sal_Int32 nIndex )
99 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 : virtual void SAL_CALL clear() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 :
102 : // XIndexAccess
103 : virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
108 :
109 : // XNameAccess
110 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
111 : throw(::com::sun::star::container::NoSuchElementException,
112 : ::com::sun::star::lang::WrappedTargetException,
113 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
115 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
117 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
122 :
123 : // XElementAccess
124 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
125 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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 OUString SAL_CALL getImplementationName()
139 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
140 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
141 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
142 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
143 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
144 : };
145 :
146 : class ScTableConditionalEntry : public cppu::WeakImplHelper3<
147 : com::sun::star::sheet::XSheetCondition2,
148 : com::sun::star::sheet::XSheetConditionalEntry,
149 : com::sun::star::lang::XServiceInfo >
150 : {
151 : private:
152 : ScCondFormatEntryItem aData;
153 :
154 : ScTableConditionalEntry(); // disabled
155 : public:
156 : ScTableConditionalEntry(const ScCondFormatEntryItem& aItem);
157 : virtual ~ScTableConditionalEntry();
158 :
159 : void GetData(ScCondFormatEntryItem& rData) const;
160 :
161 : // XSheetCondition
162 : virtual ::com::sun::star::sheet::ConditionOperator SAL_CALL getOperator()
163 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
164 : virtual sal_Int32 SAL_CALL getConditionOperator()
165 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
166 : virtual void SAL_CALL setOperator( ::com::sun::star::sheet::ConditionOperator nOperator )
167 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
168 : virtual void SAL_CALL setConditionOperator( sal_Int32 nOperator )
169 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
170 : virtual OUString SAL_CALL getFormula1() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
171 : virtual void SAL_CALL setFormula1( const OUString& aFormula1 )
172 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
173 : virtual OUString SAL_CALL getFormula2() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
174 : virtual void SAL_CALL setFormula2( const OUString& aFormula2 )
175 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
176 : virtual ::com::sun::star::table::CellAddress SAL_CALL getSourcePosition()
177 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
178 : virtual void SAL_CALL setSourcePosition( const ::com::sun::star::table::CellAddress& aSourcePosition )
179 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 :
181 : // XSheetConditionalEntry
182 : virtual OUString SAL_CALL getStyleName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
183 : virtual void SAL_CALL setStyleName( const OUString& aStyleName )
184 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
185 :
186 : // XServiceInfo
187 : virtual OUString SAL_CALL getImplementationName()
188 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
189 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
190 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
191 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
192 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
193 : };
194 :
195 : class ScTableValidationObj : public cppu::WeakImplHelper5<
196 : com::sun::star::sheet::XSheetCondition2,
197 : com::sun::star::sheet::XMultiFormulaTokens,
198 : com::sun::star::beans::XPropertySet,
199 : com::sun::star::lang::XUnoTunnel,
200 : com::sun::star::lang::XServiceInfo >
201 : {
202 : private:
203 : SfxItemPropertySet aPropSet;
204 : sal_uInt16 nMode; // enum ScConditionMode
205 : OUString aExpr1;
206 : OUString aExpr2;
207 : OUString maExprNmsp1;
208 : OUString maExprNmsp2;
209 : formula::FormulaGrammar::Grammar meGrammar1; // grammar used with aExpr1 and aExpr2
210 : formula::FormulaGrammar::Grammar meGrammar2; // grammar used with aExpr1 and aExpr2
211 : ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > aTokens1;
212 : ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > aTokens2;
213 : ScAddress aSrcPos;
214 : OUString aPosString; // formula position as text
215 : sal_uInt16 nValMode; // enum ScValidationMode
216 : bool bIgnoreBlank;
217 : sal_Int16 nShowList;
218 : bool bShowInput;
219 : OUString aInputTitle;
220 : OUString aInputMessage;
221 : bool bShowError;
222 : sal_uInt16 nErrorStyle; // enum ScValidErrorStyle
223 : OUString aErrorTitle;
224 : OUString aErrorMessage;
225 :
226 : void ClearData_Impl();
227 :
228 : ScTableValidationObj(); // disabled
229 : public:
230 : ScTableValidationObj(ScDocument* pDoc, sal_uLong nKey,
231 : const formula::FormulaGrammar::Grammar eGrammar);
232 : virtual ~ScTableValidationObj();
233 :
234 : ScValidationData* CreateValidationData( ScDocument* pDoc,
235 : formula::FormulaGrammar::Grammar eGrammar ) const;
236 :
237 : // XSheetCondition
238 : virtual ::com::sun::star::sheet::ConditionOperator SAL_CALL getOperator()
239 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
240 : virtual sal_Int32 SAL_CALL getConditionOperator()
241 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
242 : virtual void SAL_CALL setOperator( ::com::sun::star::sheet::ConditionOperator nOperator )
243 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
244 : virtual void SAL_CALL setConditionOperator( sal_Int32 nOperator )
245 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
246 : virtual OUString SAL_CALL getFormula1() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
247 : virtual void SAL_CALL setFormula1( const OUString& aFormula1 )
248 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
249 : virtual OUString SAL_CALL getFormula2() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
250 : virtual void SAL_CALL setFormula2( const OUString& aFormula2 )
251 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
252 : virtual ::com::sun::star::table::CellAddress SAL_CALL getSourcePosition()
253 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
254 : virtual void SAL_CALL setSourcePosition( const ::com::sun::star::table::CellAddress& aSourcePosition )
255 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
256 :
257 : // XMultiFormulaTokens
258 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >
259 : SAL_CALL getTokens( sal_Int32 nIndex )
260 : throw(::com::sun::star::uno::RuntimeException,::com::sun::star::lang::IndexOutOfBoundsException, std::exception) SAL_OVERRIDE;
261 : virtual void SAL_CALL setTokens( sal_Int32 nIndex,
262 : const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& aTokens )
263 : throw(::com::sun::star::uno::RuntimeException,::com::sun::star::lang::IndexOutOfBoundsException, std::exception) SAL_OVERRIDE;
264 : virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
265 :
266 : // XPropertySet
267 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
268 : SAL_CALL getPropertySetInfo()
269 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
270 : virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
271 : const ::com::sun::star::uno::Any& aValue )
272 : throw(::com::sun::star::beans::UnknownPropertyException,
273 : ::com::sun::star::beans::PropertyVetoException,
274 : ::com::sun::star::lang::IllegalArgumentException,
275 : ::com::sun::star::lang::WrappedTargetException,
276 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
277 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
278 : const OUString& PropertyName )
279 : throw(::com::sun::star::beans::UnknownPropertyException,
280 : ::com::sun::star::lang::WrappedTargetException,
281 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
282 : virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
283 : const ::com::sun::star::uno::Reference<
284 : ::com::sun::star::beans::XPropertyChangeListener >& xListener )
285 : throw(::com::sun::star::beans::UnknownPropertyException,
286 : ::com::sun::star::lang::WrappedTargetException,
287 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
288 : virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
289 : const ::com::sun::star::uno::Reference<
290 : ::com::sun::star::beans::XPropertyChangeListener >& aListener )
291 : throw(::com::sun::star::beans::UnknownPropertyException,
292 : ::com::sun::star::lang::WrappedTargetException,
293 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
294 : virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
295 : const ::com::sun::star::uno::Reference<
296 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
297 : throw(::com::sun::star::beans::UnknownPropertyException,
298 : ::com::sun::star::lang::WrappedTargetException,
299 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
300 : virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
301 : const ::com::sun::star::uno::Reference<
302 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
303 : throw(::com::sun::star::beans::UnknownPropertyException,
304 : ::com::sun::star::lang::WrappedTargetException,
305 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
306 :
307 : // XUnoTunnel
308 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
309 : sal_Int8 >& aIdentifier )
310 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
311 :
312 : static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
313 : static ScTableValidationObj* getImplementation( const com::sun::star::uno::Reference<
314 : com::sun::star::beans::XPropertySet> xObj );
315 :
316 : // XServiceInfo
317 : virtual OUString SAL_CALL getImplementationName()
318 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
319 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
320 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
321 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
322 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
323 : };
324 :
325 :
326 : #endif
327 :
328 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|