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