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 OOX_XLS_OOXFORMULAPARSER_HXX
25 #define OOX_XLS_OOXFORMULAPARSER_HXX
26 
27 #include <boost/shared_ptr.hpp>
28 #include <com/sun/star/lang/XComponent.hpp>
29 #include <com/sun/star/lang/XInitialization.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/sheet/XFilterFormulaParser.hpp>
32 #include <cppuhelper/implbase3.hxx>
33 
34 namespace oox {
35 namespace xls {
36 
37 class OOXMLFormulaParserImpl;
38 class OOXMLFormulaPrinterImpl;
39 
40 // ============================================================================
41 
42 typedef ::cppu::WeakImplHelper3<
43     ::com::sun::star::lang::XServiceInfo,
44     ::com::sun::star::lang::XInitialization,
45     ::com::sun::star::sheet::XFilterFormulaParser > OOXMLFormulaParser_BASE;
46 
47 /** OOXML formula parser/compiler service for usage in ODF filters. */
48 class OOXMLFormulaParser : public OOXMLFormulaParser_BASE
49 {
50 public:
51     explicit            OOXMLFormulaParser();
52     virtual             ~OOXMLFormulaParser();
53 
54     // com.sun.star.lang.XServiceInfo interface -------------------------------
55 
56     virtual ::rtl::OUString SAL_CALL
57                         getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
58 
59     virtual sal_Bool SAL_CALL
60                         supportsService( const ::rtl::OUString& rService )
61                             throw( ::com::sun::star::uno::RuntimeException );
62 
63     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
64                         getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
65 
66     // com.sun.star.lang.XInitialization interface ----------------------------
67 
68     virtual void SAL_CALL initialize(
69                             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArgs )
70                             throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException );
71 
72     // com.sun.star.sheet.XFilterFormulaParser interface ----------------------
73 
74     virtual ::rtl::OUString SAL_CALL
75                         getSupportedNamespace()
76                             throw( ::com::sun::star::uno::RuntimeException );
77 
78     // com.sun.star.sheet.XFormulaParser interface ----------------------------
79 
80     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > SAL_CALL
81                         parseFormula(
82                             const ::rtl::OUString& rFormula,
83                             const ::com::sun::star::table::CellAddress& rReferencePos )
84                         throw( ::com::sun::star::uno::RuntimeException );
85 
86     virtual ::rtl::OUString SAL_CALL
87                         printFormula(
88                             const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& rTokens,
89                             const ::com::sun::star::table::CellAddress& rReferencePos )
90                         throw( ::com::sun::star::uno::RuntimeException );
91 
92 private:
93     typedef ::boost::shared_ptr< OOXMLFormulaParserImpl >   ParserImplRef;
94     typedef ::boost::shared_ptr< OOXMLFormulaPrinterImpl >  PrinterImplRef;
95 
96     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
97                         mxComponent;
98     ParserImplRef       mxParserImpl;       /// Implementation of import parser.
99     PrinterImplRef      mxPrinterImpl;      /// Implementation of export printer.
100 };
101 
102 // ============================================================================
103 
104 } // namespace xls
105 } // namespace oox
106 
107 #endif
108