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