xref: /aoo41x/main/sc/inc/tokenuno.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_TOKENUNO_HXX
29 #define SC_TOKENUNO_HXX
30 
31 #include <com/sun/star/uno/Sequence.hxx>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/sheet/FormulaOpCodeMapEntry.hpp>
35 #include <com/sun/star/sheet/FormulaToken.hpp>
36 #include <com/sun/star/sheet/XFormulaParser.hpp>
37 #include <cppuhelper/implbase3.hxx>
38 #include <svl/lstner.hxx>
39 #include <formula/FormulaOpCodeMapperObj.hxx>
40 #include "address.hxx"
41 #include "compiler.hxx"
42 
43 class ScTokenArray;
44 class ScDocShell;
45 
46 // ============================================================================
47 
48 class ScTokenConversion
49 {
50 public:
51     static bool ConvertToTokenArray(
52                         ScDocument& rDoc,
53                         ScTokenArray& rTokenArray,
54                         const com::sun::star::uno::Sequence< com::sun::star::sheet::FormulaToken >& rSequence );
55     static bool ConvertToTokenSequence(
56                         ScDocument& rDoc,
57                         com::sun::star::uno::Sequence< com::sun::star::sheet::FormulaToken >& rSequence,
58                         const ScTokenArray& rTokenArray );
59 };
60 
61 // ============================================================================
62 
63 class ScFormulaParserObj : public ::cppu::WeakImplHelper3<
64                             ::com::sun::star::sheet::XFormulaParser,
65                             ::com::sun::star::beans::XPropertySet,
66                             ::com::sun::star::lang::XServiceInfo >,
67                         public SfxListener
68 {
69 private:
70     ::com::sun::star::uno::Sequence< const ::com::sun::star::sheet::FormulaOpCodeMapEntry > maOpCodeMapping;
71     ::com::sun::star::uno::Sequence< const ::com::sun::star::sheet::ExternalLinkInfo > maExternalLinks;
72     ScCompiler::OpCodeMapPtr    mxOpCodeMap;
73     ScDocShell*         mpDocShell;
74     sal_Int16           mnConv;
75     bool                mbEnglish;
76     bool                mbIgnoreSpaces;
77     bool                mbCompileFAP;
78 
79     void                    SetCompilerFlags( ScCompiler& rCompiler ) const;
80 
81 public:
82                             ScFormulaParserObj(ScDocShell* pDocSh);
83     virtual                 ~ScFormulaParserObj();
84 
85     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
86 
87                             // XFormulaParser
88     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > SAL_CALL parseFormula(
89                                     const ::rtl::OUString& aFormula,
90                                     const ::com::sun::star::table::CellAddress& rReferencePos )
91                                 throw (::com::sun::star::uno::RuntimeException);
92     virtual ::rtl::OUString SAL_CALL printFormula( const ::com::sun::star::uno::Sequence<
93                                     ::com::sun::star::sheet::FormulaToken >& aTokens,
94                                     const ::com::sun::star::table::CellAddress& rReferencePos )
95                                 throw (::com::sun::star::uno::RuntimeException);
96 
97                             // XPropertySet
98     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
99                             SAL_CALL getPropertySetInfo()
100                                 throw(::com::sun::star::uno::RuntimeException);
101     virtual void SAL_CALL   setPropertyValue( const ::rtl::OUString& aPropertyName,
102                                     const ::com::sun::star::uno::Any& aValue )
103                                 throw(::com::sun::star::beans::UnknownPropertyException,
104                                     ::com::sun::star::beans::PropertyVetoException,
105                                     ::com::sun::star::lang::IllegalArgumentException,
106                                     ::com::sun::star::lang::WrappedTargetException,
107                                     ::com::sun::star::uno::RuntimeException);
108     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
109                                     const ::rtl::OUString& PropertyName )
110                                 throw(::com::sun::star::beans::UnknownPropertyException,
111                                     ::com::sun::star::lang::WrappedTargetException,
112                                     ::com::sun::star::uno::RuntimeException);
113     virtual void SAL_CALL   addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
114                                     const ::com::sun::star::uno::Reference<
115                                         ::com::sun::star::beans::XPropertyChangeListener >& xListener )
116                                 throw(::com::sun::star::beans::UnknownPropertyException,
117                                     ::com::sun::star::lang::WrappedTargetException,
118                                     ::com::sun::star::uno::RuntimeException);
119     virtual void SAL_CALL   removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
120                                     const ::com::sun::star::uno::Reference<
121                                         ::com::sun::star::beans::XPropertyChangeListener >& aListener )
122                                 throw(::com::sun::star::beans::UnknownPropertyException,
123                                     ::com::sun::star::lang::WrappedTargetException,
124                                     ::com::sun::star::uno::RuntimeException);
125     virtual void SAL_CALL   addVetoableChangeListener( const ::rtl::OUString& PropertyName,
126                                     const ::com::sun::star::uno::Reference<
127                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener )
128                                 throw(::com::sun::star::beans::UnknownPropertyException,
129                                     ::com::sun::star::lang::WrappedTargetException,
130                                     ::com::sun::star::uno::RuntimeException);
131     virtual void SAL_CALL   removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
132                                     const ::com::sun::star::uno::Reference<
133                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener )
134                                 throw(::com::sun::star::beans::UnknownPropertyException,
135                                     ::com::sun::star::lang::WrappedTargetException,
136                                     ::com::sun::star::uno::RuntimeException);
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 ScFormulaOpCodeMapperObj : public formula::FormulaOpCodeMapperObj
150 {
151 public:
152     ScFormulaOpCodeMapperObj(::std::auto_ptr<formula::FormulaCompiler> _pCompiler);
153 };
154 
155 // ============================================================================
156 
157 #endif
158 
159