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