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 virtual ::rtl::OUString SAL_CALL printFormula( const ::com::sun::star::uno::Sequence< 88 ::com::sun::star::sheet::FormulaToken >& aTokens, 89 const ::com::sun::star::table::CellAddress& rReferencePos ); 90 91 // XPropertySet 92 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > 93 SAL_CALL getPropertySetInfo(); 94 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, 95 const ::com::sun::star::uno::Any& aValue ); 96 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( 97 const ::rtl::OUString& PropertyName ); 98 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, 99 const ::com::sun::star::uno::Reference< 100 ::com::sun::star::beans::XPropertyChangeListener >& xListener ); 101 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, 102 const ::com::sun::star::uno::Reference< 103 ::com::sun::star::beans::XPropertyChangeListener >& aListener ); 104 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, 105 const ::com::sun::star::uno::Reference< 106 ::com::sun::star::beans::XVetoableChangeListener >& aListener ); 107 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, 108 const ::com::sun::star::uno::Reference< 109 ::com::sun::star::beans::XVetoableChangeListener >& aListener ); 110 111 // XServiceInfo 112 virtual ::rtl::OUString SAL_CALL getImplementationName(); 113 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ); 114 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(); 115 }; 116 117 // ============================================================================ 118 119 class ScFormulaOpCodeMapperObj : public formula::FormulaOpCodeMapperObj 120 { 121 public: 122 ScFormulaOpCodeMapperObj(::std::auto_ptr<formula::FormulaCompiler> _pCompiler); 123 }; 124 125 // ============================================================================ 126 127 #endif 128