1*de7b3f82SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*de7b3f82SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*de7b3f82SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*de7b3f82SAndrew Rist  * distributed with this work for additional information
6*de7b3f82SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*de7b3f82SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*de7b3f82SAndrew Rist  * "License"); you may not use this file except in compliance
9*de7b3f82SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*de7b3f82SAndrew Rist  *
11*de7b3f82SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*de7b3f82SAndrew Rist  *
13*de7b3f82SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*de7b3f82SAndrew Rist  * software distributed under the License is distributed on an
15*de7b3f82SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*de7b3f82SAndrew Rist  * KIND, either express or implied.  See the License for the
17*de7b3f82SAndrew Rist  * specific language governing permissions and limitations
18*de7b3f82SAndrew Rist  * under the License.
19*de7b3f82SAndrew Rist  *
20*de7b3f82SAndrew Rist  *************************************************************/
21*de7b3f82SAndrew Rist 
22*de7b3f82SAndrew Rist 
23cdf0e10cSrcweir #ifndef CHART2_VIEW_EXPLICITCATEGORIESPROVIDER_HXX
24cdf0e10cSrcweir #define CHART2_VIEW_EXPLICITCATEGORIESPROVIDER_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "ServiceMacros.hxx"
27cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
28cdf0e10cSrcweir #include <cppuhelper/weakref.hxx>
29cdf0e10cSrcweir #include <com/sun/star/chart2/XCoordinateSystem.hpp>
30cdf0e10cSrcweir #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
31cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
32cdf0e10cSrcweir #include "charttoolsdllapi.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <vector>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace chart
37cdf0e10cSrcweir {
38cdf0e10cSrcweir 
39cdf0e10cSrcweir struct OOO_DLLPUBLIC_CHARTTOOLS ComplexCategory
40cdf0e10cSrcweir {
41cdf0e10cSrcweir     rtl::OUString Text;
42cdf0e10cSrcweir     sal_Int32 Count;
43cdf0e10cSrcweir 
ComplexCategorychart::ComplexCategory44cdf0e10cSrcweir     ComplexCategory( const rtl::OUString& rText, sal_Int32 nCount ) : Text( rText ), Count (nCount)
45cdf0e10cSrcweir     {}
46cdf0e10cSrcweir };
47cdf0e10cSrcweir 
48cdf0e10cSrcweir class OOO_DLLPUBLIC_CHARTTOOLS SplitCategoriesProvider
49cdf0e10cSrcweir {
50cdf0e10cSrcweir public:
51cdf0e10cSrcweir     virtual ~SplitCategoriesProvider();
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     virtual sal_Int32 getLevelCount() const = 0;
54cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const = 0;
55cdf0e10cSrcweir };
56cdf0e10cSrcweir 
57cdf0e10cSrcweir struct DatePlusIndex
58cdf0e10cSrcweir {
DatePlusIndexchart::DatePlusIndex59cdf0e10cSrcweir     DatePlusIndex()
60cdf0e10cSrcweir         : fValue(1.0)
61cdf0e10cSrcweir         , nIndex( -1 )
62cdf0e10cSrcweir     {
63cdf0e10cSrcweir     }
64cdf0e10cSrcweir 
DatePlusIndexchart::DatePlusIndex65cdf0e10cSrcweir     DatePlusIndex( const double& _fValue, sal_Int32 _nIndex )
66cdf0e10cSrcweir         : fValue(_fValue)
67cdf0e10cSrcweir         , nIndex( _nIndex )
68cdf0e10cSrcweir     {
69cdf0e10cSrcweir     }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     double fValue;
72cdf0e10cSrcweir     sal_Int32 nIndex;
73cdf0e10cSrcweir };
74cdf0e10cSrcweir 
75cdf0e10cSrcweir class OOO_DLLPUBLIC_CHARTTOOLS ExplicitCategoriesProvider
76cdf0e10cSrcweir {
77cdf0e10cSrcweir public:
78cdf0e10cSrcweir     ExplicitCategoriesProvider( const ::com::sun::star::uno::Reference<
79cdf0e10cSrcweir                         ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel
80cdf0e10cSrcweir                        , const ::com::sun::star::uno::Reference<
81cdf0e10cSrcweir                         ::com::sun::star::frame::XModel >& xChartModel
82cdf0e10cSrcweir                        );
83cdf0e10cSrcweir 	virtual ~ExplicitCategoriesProvider();
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     void init();
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
88cdf0e10cSrcweir         ::com::sun::star::chart2::data::XDataSequence > getOriginalCategories();
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString > getSimpleCategories();
91cdf0e10cSrcweir     ::std::vector< ComplexCategory > getCategoriesByLevel( sal_Int32 nLevel );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     static ::rtl::OUString getCategoryByIndex(
94cdf0e10cSrcweir           const ::com::sun::star::uno::Reference<
95cdf0e10cSrcweir             ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel
96cdf0e10cSrcweir         , const ::com::sun::star::uno::Reference<
97cdf0e10cSrcweir             ::com::sun::star::frame::XModel >& xChartModel
98cdf0e10cSrcweir         , sal_Int32 nIndex );
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     static ::com::sun::star::uno::Sequence< ::rtl::OUString > getExplicitSimpleCategories(
101cdf0e10cSrcweir             const SplitCategoriesProvider& rSplitCategoriesProvider );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     static void convertCategoryAnysToText( ::com::sun::star::uno::Sequence< rtl::OUString >& rOutTexts
104cdf0e10cSrcweir         , const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rInAnys
105cdf0e10cSrcweir         , ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xChartModel );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     bool hasComplexCategories() const;
108cdf0e10cSrcweir     sal_Int32 getCategoryLevelCount() const;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
111cdf0e10cSrcweir         ::com::sun::star::chart2::data::XLabeledDataSequence> >& getSplitCategoriesList();
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     bool isDateAxis();
114cdf0e10cSrcweir     const std::vector< DatePlusIndex >&  getDateCategories();
115cdf0e10cSrcweir 
116cdf0e10cSrcweir private: //member
117cdf0e10cSrcweir     bool volatile m_bDirty;
118cdf0e10cSrcweir     ::com::sun::star::uno::WeakReference<
119cdf0e10cSrcweir         ::com::sun::star::chart2::XCoordinateSystem >   m_xCooSysModel;
120cdf0e10cSrcweir     ::com::sun::star::uno::WeakReference<
121cdf0e10cSrcweir         ::com::sun::star::frame::XModel >               m_xChartModel;
122cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
123cdf0e10cSrcweir         ::com::sun::star::chart2::data::XLabeledDataSequence> m_xOriginalCategories;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     bool m_bIsExplicitCategoriesInited;
126cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString >  m_aExplicitCategories;
127cdf0e10cSrcweir     ::std::vector< ::std::vector< ComplexCategory > >   m_aComplexCats;
128cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
129cdf0e10cSrcweir         ::com::sun::star::chart2::data::XLabeledDataSequence> > m_aSplitCategoriesList;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     bool m_bIsDateAxis;
132cdf0e10cSrcweir     bool m_bIsAutoDate;
133cdf0e10cSrcweir     std::vector< DatePlusIndex >  m_aDateCategories;
134cdf0e10cSrcweir };
135cdf0e10cSrcweir 
136cdf0e10cSrcweir } //  namespace chart
137cdf0e10cSrcweir 
138cdf0e10cSrcweir // CHART2_VIEW_EXPLICITCATEGORIESPROVIDER_HXX
139cdf0e10cSrcweir #endif
140