xref: /trunk/main/sc/inc/tokenuno.hxx (revision 38d50f7b)
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_TOKENUNO_HXX
25 #define SC_TOKENUNO_HXX
26 
27 #include <com/sun/star/uno/Sequence.hxx>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/sheet/FormulaOpCodeMapEntry.hpp>
31 #include <com/sun/star/sheet/FormulaToken.hpp>
32 #include <com/sun/star/sheet/XFormulaParser.hpp>
33 #include <cppuhelper/implbase3.hxx>
34 #include <svl/lstner.hxx>
35 #include <formula/FormulaOpCodeMapperObj.hxx>
36 #include "address.hxx"
37 #include "compiler.hxx"
38 
39 class ScTokenArray;
40 class ScDocShell;
41 
42 // ============================================================================
43 
44 class ScTokenConversion
45 {
46 public:
47     static bool ConvertToTokenArray(
48                         ScDocument& rDoc,
49                         ScTokenArray& rTokenArray,
50                         const com::sun::star::uno::Sequence< com::sun::star::sheet::FormulaToken >& rSequence );
51     static bool ConvertToTokenSequence(
52                         ScDocument& rDoc,
53                         com::sun::star::uno::Sequence< com::sun::star::sheet::FormulaToken >& rSequence,
54                         const ScTokenArray& rTokenArray );
55 };
56 
57 // ============================================================================
58 
59 class ScFormulaParserObj : public ::cppu::WeakImplHelper3<
60                             ::com::sun::star::sheet::XFormulaParser,
61                             ::com::sun::star::beans::XPropertySet,
62                             ::com::sun::star::lang::XServiceInfo >,
63                         public SfxListener
64 {
65 private:
66     ::com::sun::star::uno::Sequence< const ::com::sun::star::sheet::FormulaOpCodeMapEntry > maOpCodeMapping;
67     ::com::sun::star::uno::Sequence< const ::com::sun::star::sheet::ExternalLinkInfo > maExternalLinks;
68     ScCompiler::OpCodeMapPtr    mxOpCodeMap;
69     ScDocShell*         mpDocShell;
70     sal_Int16           mnConv;
71     bool                mbEnglish;
72     bool                mbIgnoreSpaces;
73     bool                mbCompileFAP;
74 
75     void                    SetCompilerFlags( ScCompiler& rCompiler ) const;
76 
77 public:
78                             ScFormulaParserObj(ScDocShell* pDocSh);
79     virtual                 ~ScFormulaParserObj();
80 
81     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
82 
83                             // XFormulaParser
84     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > SAL_CALL parseFormula(
85                                     const ::rtl::OUString& aFormula,
86                                     const ::com::sun::star::table::CellAddress& rReferencePos )
87                                 throw (::com::sun::star::uno::RuntimeException);
88     virtual ::rtl::OUString SAL_CALL printFormula( const ::com::sun::star::uno::Sequence<
89                                     ::com::sun::star::sheet::FormulaToken >& aTokens,
90                                     const ::com::sun::star::table::CellAddress& rReferencePos )
91                                 throw (::com::sun::star::uno::RuntimeException);
92 
93                             // XPropertySet
94     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
95                             SAL_CALL getPropertySetInfo()
96                                 throw(::com::sun::star::uno::RuntimeException);
97     virtual void SAL_CALL   setPropertyValue( const ::rtl::OUString& aPropertyName,
98                                     const ::com::sun::star::uno::Any& aValue )
99                                 throw(::com::sun::star::beans::UnknownPropertyException,
100                                     ::com::sun::star::beans::PropertyVetoException,
101                                     ::com::sun::star::lang::IllegalArgumentException,
102                                     ::com::sun::star::lang::WrappedTargetException,
103                                     ::com::sun::star::uno::RuntimeException);
104     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
105                                     const ::rtl::OUString& PropertyName )
106                                 throw(::com::sun::star::beans::UnknownPropertyException,
107                                     ::com::sun::star::lang::WrappedTargetException,
108                                     ::com::sun::star::uno::RuntimeException);
109     virtual void SAL_CALL   addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
110                                     const ::com::sun::star::uno::Reference<
111                                         ::com::sun::star::beans::XPropertyChangeListener >& xListener )
112                                 throw(::com::sun::star::beans::UnknownPropertyException,
113                                     ::com::sun::star::lang::WrappedTargetException,
114                                     ::com::sun::star::uno::RuntimeException);
115     virtual void SAL_CALL   removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
116                                     const ::com::sun::star::uno::Reference<
117                                         ::com::sun::star::beans::XPropertyChangeListener >& aListener )
118                                 throw(::com::sun::star::beans::UnknownPropertyException,
119                                     ::com::sun::star::lang::WrappedTargetException,
120                                     ::com::sun::star::uno::RuntimeException);
121     virtual void SAL_CALL   addVetoableChangeListener( const ::rtl::OUString& PropertyName,
122                                     const ::com::sun::star::uno::Reference<
123                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener )
124                                 throw(::com::sun::star::beans::UnknownPropertyException,
125                                     ::com::sun::star::lang::WrappedTargetException,
126                                     ::com::sun::star::uno::RuntimeException);
127     virtual void SAL_CALL   removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
128                                     const ::com::sun::star::uno::Reference<
129                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener )
130                                 throw(::com::sun::star::beans::UnknownPropertyException,
131                                     ::com::sun::star::lang::WrappedTargetException,
132                                     ::com::sun::star::uno::RuntimeException);
133 
134                             // XServiceInfo
135     virtual ::rtl::OUString SAL_CALL getImplementationName()
136                                 throw(::com::sun::star::uno::RuntimeException);
137     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
138                                 throw(::com::sun::star::uno::RuntimeException);
139     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
140                                 throw(::com::sun::star::uno::RuntimeException);
141 };
142 
143 // ============================================================================
144 
145 class ScFormulaOpCodeMapperObj : public formula::FormulaOpCodeMapperObj
146 {
147 public:
148     ScFormulaOpCodeMapperObj(::std::auto_ptr<formula::FormulaCompiler> _pCompiler);
149 };
150 
151 // ============================================================================
152 
153 #endif
154 
155