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 #ifndef CHART_DATAINTERPRETER_HXX
24 #define CHART_DATAINTERPRETER_HXX
25 
26 #include "ServiceMacros.hxx"
27 #include <cppuhelper/implbase2.hxx>
28 #include <com/sun/star/chart2/XDataInterpreter.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/uno/XComponentContext.hpp>
31 
32 namespace chart
33 {
34 
35 class DataInterpreter : public ::cppu::WeakImplHelper2<
36         ::com::sun::star::chart2::XDataInterpreter,
37         ::com::sun::star::lang::XServiceInfo >
38 {
39 public:
40     explicit DataInterpreter( const ::com::sun::star::uno::Reference<
41                                   ::com::sun::star::uno::XComponentContext > & xContext );
42     virtual ~DataInterpreter();
43 
44     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
45         GetComponentContext() const;
46 
47     /// XServiceInfo declarations
48     APPHELPER_XSERVICEINFO_DECL()
49 
50     // convenience methods
51     static  ::rtl::OUString GetRole(
52         const ::com::sun::star::uno::Reference<
53             ::com::sun::star::chart2::data::XDataSequence > & xSeq );
54 
55     static void SetRole(
56         const ::com::sun::star::uno::Reference<
57             ::com::sun::star::chart2::data::XDataSequence > & xSeq,
58         const ::rtl::OUString & rRole );
59 
60     static ::com::sun::star::uno::Any GetProperty(
61         const ::com::sun::star::uno::Sequence<
62             ::com::sun::star::beans::PropertyValue > & aArguments,
63         const ::rtl::OUString & rName );
64 
65     static bool HasCategories(
66         const ::com::sun::star::uno::Sequence<
67             ::com::sun::star::beans::PropertyValue > & rArguments,
68         const ::com::sun::star::uno::Sequence<
69             ::com::sun::star::uno::Reference<
70                 ::com::sun::star::chart2::data::XLabeledDataSequence > > & rData );
71 
72     static bool UseCategoriesAsX(
73         const ::com::sun::star::uno::Sequence<
74             ::com::sun::star::beans::PropertyValue > & rArguments );
75 
76 protected:
77     // ____ XDataInterpreter ____
78     virtual ::com::sun::star::chart2::InterpretedData SAL_CALL interpretDataSource(
79         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource >& xSource,
80         const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments,
81         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > >& aSeriesToReUse )
82         throw (::com::sun::star::uno::RuntimeException);
83     virtual ::com::sun::star::chart2::InterpretedData SAL_CALL reinterpretDataSeries(
84         const ::com::sun::star::chart2::InterpretedData& aInterpretedData )
85         throw (::com::sun::star::uno::RuntimeException);
86     virtual sal_Bool SAL_CALL isDataCompatible(
87         const ::com::sun::star::chart2::InterpretedData& aInterpretedData )
88         throw (::com::sun::star::uno::RuntimeException);
89     virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > SAL_CALL mergeInterpretedData(
90         const ::com::sun::star::chart2::InterpretedData& aInterpretedData )
91         throw (::com::sun::star::uno::RuntimeException);
92 
93     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
94         m_xContext;
95 };
96 
97 } // namespace chart
98 
99 // CHART_DATAINTERPRETER_HXX
100 #endif
101