1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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>
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>
44 #include "address.hxx"
45 #include "conditio.hxx"
48 class ScTableConditionalEntry
;
49 class ScConditionalFormat
;
50 class ScValidationData
;
53 struct ScCondFormatEntryItem
55 css::uno::Sequence
< css::sheet::FormulaToken
> maTokens1
;
56 css::uno::Sequence
< css::sheet::FormulaToken
> maTokens2
;
61 OUString maPosStr
; // formula position as text
62 OUString maStyle
; // display name as stored in ScStyleSheet
64 formula::FormulaGrammar::Grammar meGrammar1
; // grammar used with maExpr1
65 formula::FormulaGrammar::Grammar meGrammar2
; // grammar used with maExpr2
66 ScConditionMode meMode
;
68 // Make sure the grammar is initialized for API calls.
69 ScCondFormatEntryItem();
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
>
80 std::vector
<ScTableConditionalEntry
*> aEntries
;
82 ScTableConditionalEntry
* GetObjectByIndex_Impl(sal_uInt16 nIndex
) const;
83 void AddEntry_Impl(const ScCondFormatEntryItem
& aEntry
);
85 ScTableConditionalFormat(); // disable
87 ScTableConditionalFormat(ScDocument
* pDoc
, sal_uLong nKey
,
88 SCTAB nTab
, formula::FormulaGrammar::Grammar eGrammar
);
89 virtual ~ScTableConditionalFormat();
91 void FillFormat( ScConditionalFormat
& rFormat
, ScDocument
* pDoc
,
92 formula::FormulaGrammar::Grammar eGrammar
) const;
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
);
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
);
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
);
114 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getElementNames()
115 throw(::com::sun::star::uno::RuntimeException
);
116 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
)
117 throw(::com::sun::star::uno::RuntimeException
);
119 // XEnumerationAccess
120 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
121 createEnumeration() throw(::com::sun::star::uno::RuntimeException
);
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
);
129 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
<
130 sal_Int8
>& aIdentifier
)
131 throw(::com::sun::star::uno::RuntimeException
);
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
);
138 virtual OUString SAL_CALL
getImplementationName()
139 throw(::com::sun::star::uno::RuntimeException
);
140 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
141 throw(::com::sun::star::uno::RuntimeException
);
142 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
143 throw(::com::sun::star::uno::RuntimeException
);
148 class ScTableConditionalEntry
: public cppu::WeakImplHelper3
<
149 com::sun::star::sheet::XSheetCondition2
,
150 com::sun::star::sheet::XSheetConditionalEntry
,
151 com::sun::star::lang::XServiceInfo
>
154 ScCondFormatEntryItem aData
;
156 ScTableConditionalEntry(); // disabled
158 ScTableConditionalEntry(const ScCondFormatEntryItem
& aItem
);
159 virtual ~ScTableConditionalEntry();
161 void GetData(ScCondFormatEntryItem
& rData
) const;
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 OUString SAL_CALL
getFormula1() throw(::com::sun::star::uno::RuntimeException
);
173 virtual void SAL_CALL
setFormula1( const OUString
& aFormula1
)
174 throw(::com::sun::star::uno::RuntimeException
);
175 virtual OUString SAL_CALL
getFormula2() throw(::com::sun::star::uno::RuntimeException
);
176 virtual void SAL_CALL
setFormula2( const 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
);
183 // XSheetConditionalEntry
184 virtual OUString SAL_CALL
getStyleName() throw(::com::sun::star::uno::RuntimeException
);
185 virtual void SAL_CALL
setStyleName( const OUString
& aStyleName
)
186 throw(::com::sun::star::uno::RuntimeException
);
189 virtual OUString SAL_CALL
getImplementationName()
190 throw(::com::sun::star::uno::RuntimeException
);
191 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
192 throw(::com::sun::star::uno::RuntimeException
);
193 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
194 throw(::com::sun::star::uno::RuntimeException
);
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
>
207 SfxItemPropertySet aPropSet
;
208 sal_uInt16 nMode
; // enum ScConditionMode
211 OUString maExprNmsp1
;
212 OUString 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
;
218 OUString aPosString
; // formula position as text
219 sal_uInt16 nValMode
; // enum ScValidationMode
220 sal_Bool bIgnoreBlank
;
223 OUString aInputTitle
;
224 OUString aInputMessage
;
226 sal_uInt16 nErrorStyle
; // enum ScValidErrorStyle
227 OUString aErrorTitle
;
228 OUString aErrorMessage
;
230 void ClearData_Impl();
232 ScTableValidationObj(); // disabled
234 ScTableValidationObj(ScDocument
* pDoc
, sal_uLong nKey
,
235 const formula::FormulaGrammar::Grammar eGrammar
);
236 virtual ~ScTableValidationObj();
238 ScValidationData
* CreateValidationData( ScDocument
* pDoc
,
239 formula::FormulaGrammar::Grammar eGrammar
) const;
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 OUString SAL_CALL
getFormula1() throw(::com::sun::star::uno::RuntimeException
);
251 virtual void SAL_CALL
setFormula1( const OUString
& aFormula1
)
252 throw(::com::sun::star::uno::RuntimeException
);
253 virtual OUString SAL_CALL
getFormula2() throw(::com::sun::star::uno::RuntimeException
);
254 virtual void SAL_CALL
setFormula2( const 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
);
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
);
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 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 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 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 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 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 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
);
312 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
<
313 sal_Int8
>& aIdentifier
)
314 throw(::com::sun::star::uno::RuntimeException
);
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
);
321 virtual OUString SAL_CALL
getImplementationName()
322 throw(::com::sun::star::uno::RuntimeException
);
323 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
324 throw(::com::sun::star::uno::RuntimeException
);
325 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
326 throw(::com::sun::star::uno::RuntimeException
);
332 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */