1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fmtuno.hxx,v $
10 * $Revision: 1.10.32.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include "address.hxx"
35 #include "conditio.hxx"
36 #include <formula/grammar.hxx>
37 #include <tools/list.hxx>
38 #include <svtools/itemprop.hxx>
39 #include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
40 #include <com/sun/star/sheet/XSheetCondition.hpp>
41 #include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #include <com/sun/star/container/XNameAccess.hpp>
44 #include <com/sun/star/container/XEnumerationAccess.hpp>
45 #include <com/sun/star/lang/XUnoTunnel.hpp>
46 #include <com/sun/star/beans/XPropertySet.hpp>
48 #include <com/sun/star/sheet/XMultiFormulaTokens.hpp>
49 #include <com/sun/star/sheet/FormulaToken.hpp>
50 #include <cppuhelper/implbase3.hxx>
51 #include <cppuhelper/implbase4.hxx>
52 #include <cppuhelper/implbase5.hxx>
56 class ScTableConditionalEntry
;
57 class ScConditionalFormat
;
58 class ScValidationData
;
61 struct ScCondFormatEntryItem
63 ::com::sun::star::uno::Sequence
< ::com::sun::star::sheet::FormulaToken
> maTokens1
;
64 ::com::sun::star::uno::Sequence
< ::com::sun::star::sheet::FormulaToken
> maTokens2
;
69 String maPosStr
; // formula position as text
70 String maStyle
; // display name as stored in ScStyleSheet
72 formula::FormulaGrammar::Grammar meGrammar1
; // grammar used with maExpr1
73 formula::FormulaGrammar::Grammar meGrammar2
; // grammar used with maExpr2
74 ScConditionMode meMode
;
76 // Make sure the grammar is initialized for API calls.
77 ScCondFormatEntryItem();
80 class ScTableConditionalFormat
: public cppu::WeakImplHelper5
<
81 com::sun::star::sheet::XSheetConditionalEntries
,
82 com::sun::star::container::XNameAccess
,
83 com::sun::star::container::XEnumerationAccess
,
84 com::sun::star::lang::XUnoTunnel
,
85 com::sun::star::lang::XServiceInfo
>
90 ScTableConditionalEntry
* GetObjectByIndex_Impl(USHORT nIndex
) const;
91 void AddEntry_Impl(const ScCondFormatEntryItem
& aEntry
);
93 ScTableConditionalFormat(); // disable
95 ScTableConditionalFormat(ScDocument
* pDoc
, ULONG nKey
,
96 formula::FormulaGrammar::Grammar eGrammar
);
97 virtual ~ScTableConditionalFormat();
99 void FillFormat( ScConditionalFormat
& rFormat
, ScDocument
* pDoc
,
100 formula::FormulaGrammar::Grammar eGrammar
) const;
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
);
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
);
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
);
128 // XEnumerationAccess
129 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
130 createEnumeration() throw(::com::sun::star::uno::RuntimeException
);
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
);
138 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
<
139 sal_Int8
>& aIdentifier
)
140 throw(::com::sun::star::uno::RuntimeException
);
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
);
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
);
157 class ScTableConditionalEntry
: public cppu::WeakImplHelper3
<
158 com::sun::star::sheet::XSheetCondition
,
159 com::sun::star::sheet::XSheetConditionalEntry
,
160 com::sun::star::lang::XServiceInfo
>
163 ScTableConditionalFormat
* pParent
;
164 ScCondFormatEntryItem aData
;
166 ScTableConditionalEntry(); // disabled
168 ScTableConditionalEntry(ScTableConditionalFormat
* pPar
,
169 const ScCondFormatEntryItem
& aItem
);
170 virtual ~ScTableConditionalEntry();
172 void GetData(ScCondFormatEntryItem
& rData
) const;
175 virtual ::com::sun::star::sheet::ConditionOperator SAL_CALL
getOperator()
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 ::rtl::OUString SAL_CALL
getFormula1() throw(::com::sun::star::uno::RuntimeException
);
180 virtual void SAL_CALL
setFormula1( const ::rtl::OUString
& aFormula1
)
181 throw(::com::sun::star::uno::RuntimeException
);
182 virtual ::rtl::OUString SAL_CALL
getFormula2() throw(::com::sun::star::uno::RuntimeException
);
183 virtual void SAL_CALL
setFormula2( const ::rtl::OUString
& aFormula2
)
184 throw(::com::sun::star::uno::RuntimeException
);
185 virtual ::com::sun::star::table::CellAddress SAL_CALL
getSourcePosition()
186 throw(::com::sun::star::uno::RuntimeException
);
187 virtual void SAL_CALL
setSourcePosition( const ::com::sun::star::table::CellAddress
& aSourcePosition
)
188 throw(::com::sun::star::uno::RuntimeException
);
190 // XSheetConditionalEntry
191 virtual ::rtl::OUString SAL_CALL
getStyleName() throw(::com::sun::star::uno::RuntimeException
);
192 virtual void SAL_CALL
setStyleName( const ::rtl::OUString
& aStyleName
)
193 throw(::com::sun::star::uno::RuntimeException
);
196 virtual ::rtl::OUString SAL_CALL
getImplementationName()
197 throw(::com::sun::star::uno::RuntimeException
);
198 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
199 throw(::com::sun::star::uno::RuntimeException
);
200 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
201 throw(::com::sun::star::uno::RuntimeException
);
206 class ScTableValidationObj
: public cppu::WeakImplHelper5
<
207 com::sun::star::sheet::XSheetCondition
,
208 com::sun::star::sheet::XMultiFormulaTokens
,
209 com::sun::star::beans::XPropertySet
,
210 com::sun::star::lang::XUnoTunnel
,
211 com::sun::star::lang::XServiceInfo
>
214 SfxItemPropertySet aPropSet
;
215 USHORT nMode
; // enum ScConditionMode
220 formula::FormulaGrammar::Grammar meGrammar1
; // grammar used with aExpr1 and aExpr2
221 formula::FormulaGrammar::Grammar meGrammar2
; // grammar used with aExpr1 and aExpr2
222 ::com::sun::star::uno::Sequence
< ::com::sun::star::sheet::FormulaToken
> aTokens1
;
223 ::com::sun::star::uno::Sequence
< ::com::sun::star::sheet::FormulaToken
> aTokens2
;
225 String aPosString
; // formula position as text
226 USHORT nValMode
; // enum ScValidationMode
231 String aInputMessage
;
233 USHORT nErrorStyle
; // enum ScValidErrorStyle
235 String aErrorMessage
;
237 void ClearData_Impl();
239 ScTableValidationObj(); // disabled
241 ScTableValidationObj(ScDocument
* pDoc
, ULONG nKey
,
242 const formula::FormulaGrammar::Grammar eGrammar
);
243 virtual ~ScTableValidationObj();
245 ScValidationData
* CreateValidationData( ScDocument
* pDoc
,
246 formula::FormulaGrammar::Grammar eGrammar
) const;
250 virtual ::com::sun::star::sheet::ConditionOperator SAL_CALL
getOperator()
251 throw(::com::sun::star::uno::RuntimeException
);
252 virtual void SAL_CALL
setOperator( ::com::sun::star::sheet::ConditionOperator nOperator
)
253 throw(::com::sun::star::uno::RuntimeException
);
254 virtual ::rtl::OUString SAL_CALL
getFormula1() throw(::com::sun::star::uno::RuntimeException
);
255 virtual void SAL_CALL
setFormula1( const ::rtl::OUString
& aFormula1
)
256 throw(::com::sun::star::uno::RuntimeException
);
257 virtual ::rtl::OUString SAL_CALL
getFormula2() throw(::com::sun::star::uno::RuntimeException
);
258 virtual void SAL_CALL
setFormula2( const ::rtl::OUString
& aFormula2
)
259 throw(::com::sun::star::uno::RuntimeException
);
260 virtual ::com::sun::star::table::CellAddress SAL_CALL
getSourcePosition()
261 throw(::com::sun::star::uno::RuntimeException
);
262 virtual void SAL_CALL
setSourcePosition( const ::com::sun::star::table::CellAddress
& aSourcePosition
)
263 throw(::com::sun::star::uno::RuntimeException
);
265 // XMultiFormulaTokens
266 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::sheet::FormulaToken
>
267 SAL_CALL
getTokens( sal_Int32 nIndex
)
268 throw(::com::sun::star::uno::RuntimeException
,::com::sun::star::lang::IndexOutOfBoundsException
);
269 virtual void SAL_CALL
setTokens( sal_Int32 nIndex
,
270 const ::com::sun::star::uno::Sequence
< ::com::sun::star::sheet::FormulaToken
>& aTokens
)
271 throw(::com::sun::star::uno::RuntimeException
,::com::sun::star::lang::IndexOutOfBoundsException
);
272 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
);
275 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
276 SAL_CALL
getPropertySetInfo()
277 throw(::com::sun::star::uno::RuntimeException
);
278 virtual void SAL_CALL
setPropertyValue( const ::rtl::OUString
& aPropertyName
,
279 const ::com::sun::star::uno::Any
& aValue
)
280 throw(::com::sun::star::beans::UnknownPropertyException
,
281 ::com::sun::star::beans::PropertyVetoException
,
282 ::com::sun::star::lang::IllegalArgumentException
,
283 ::com::sun::star::lang::WrappedTargetException
,
284 ::com::sun::star::uno::RuntimeException
);
285 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue(
286 const ::rtl::OUString
& PropertyName
)
287 throw(::com::sun::star::beans::UnknownPropertyException
,
288 ::com::sun::star::lang::WrappedTargetException
,
289 ::com::sun::star::uno::RuntimeException
);
290 virtual void SAL_CALL
addPropertyChangeListener( const ::rtl::OUString
& aPropertyName
,
291 const ::com::sun::star::uno::Reference
<
292 ::com::sun::star::beans::XPropertyChangeListener
>& xListener
)
293 throw(::com::sun::star::beans::UnknownPropertyException
,
294 ::com::sun::star::lang::WrappedTargetException
,
295 ::com::sun::star::uno::RuntimeException
);
296 virtual void SAL_CALL
removePropertyChangeListener( const ::rtl::OUString
& aPropertyName
,
297 const ::com::sun::star::uno::Reference
<
298 ::com::sun::star::beans::XPropertyChangeListener
>& aListener
)
299 throw(::com::sun::star::beans::UnknownPropertyException
,
300 ::com::sun::star::lang::WrappedTargetException
,
301 ::com::sun::star::uno::RuntimeException
);
302 virtual void SAL_CALL
addVetoableChangeListener( const ::rtl::OUString
& PropertyName
,
303 const ::com::sun::star::uno::Reference
<
304 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
305 throw(::com::sun::star::beans::UnknownPropertyException
,
306 ::com::sun::star::lang::WrappedTargetException
,
307 ::com::sun::star::uno::RuntimeException
);
308 virtual void SAL_CALL
removeVetoableChangeListener( const ::rtl::OUString
& PropertyName
,
309 const ::com::sun::star::uno::Reference
<
310 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
311 throw(::com::sun::star::beans::UnknownPropertyException
,
312 ::com::sun::star::lang::WrappedTargetException
,
313 ::com::sun::star::uno::RuntimeException
);
316 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
<
317 sal_Int8
>& aIdentifier
)
318 throw(::com::sun::star::uno::RuntimeException
);
320 static const com::sun::star::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
321 static ScTableValidationObj
* getImplementation( const com::sun::star::uno::Reference
<
322 com::sun::star::beans::XPropertySet
> xObj
);
325 virtual ::rtl::OUString SAL_CALL
getImplementationName()
326 throw(::com::sun::star::uno::RuntimeException
);
327 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
328 throw(::com::sun::star::uno::RuntimeException
);
329 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
330 throw(::com::sun::star::uno::RuntimeException
);