Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef CHART2_VIEW_EXPLICITCATEGORIESPROVIDER_HXX
20 : #define CHART2_VIEW_EXPLICITCATEGORIESPROVIDER_HXX
21 :
22 : #include "ServiceMacros.hxx"
23 : #include <cppuhelper/implbase1.hxx>
24 : #include <cppuhelper/weakref.hxx>
25 : #include <com/sun/star/chart2/XCoordinateSystem.hpp>
26 : #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
27 : #include <com/sun/star/frame/XModel.hpp>
28 : #include "charttoolsdllapi.hxx"
29 :
30 : #include <vector>
31 :
32 : namespace chart
33 : {
34 :
35 0 : struct OOO_DLLPUBLIC_CHARTTOOLS ComplexCategory
36 : {
37 : rtl::OUString Text;
38 : sal_Int32 Count;
39 :
40 0 : ComplexCategory( const rtl::OUString& rText, sal_Int32 nCount ) : Text( rText ), Count (nCount)
41 0 : {}
42 : };
43 :
44 0 : class OOO_DLLPUBLIC_CHARTTOOLS SplitCategoriesProvider
45 : {
46 : public:
47 : virtual ~SplitCategoriesProvider();
48 :
49 : virtual sal_Int32 getLevelCount() const = 0;
50 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const = 0;
51 : };
52 :
53 : struct DatePlusIndex
54 : {
55 : DatePlusIndex()
56 : : fValue(1.0)
57 : , nIndex( -1 )
58 : {
59 : }
60 :
61 492 : DatePlusIndex( const double& _fValue, sal_Int32 _nIndex )
62 : : fValue(_fValue)
63 492 : , nIndex( _nIndex )
64 : {
65 492 : }
66 :
67 : double fValue;
68 : sal_Int32 nIndex;
69 : };
70 :
71 : class OOO_DLLPUBLIC_CHARTTOOLS ExplicitCategoriesProvider
72 : {
73 : public:
74 : ExplicitCategoriesProvider( const ::com::sun::star::uno::Reference<
75 : ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel
76 : , const ::com::sun::star::uno::Reference<
77 : ::com::sun::star::frame::XModel >& xChartModel
78 : );
79 : virtual ~ExplicitCategoriesProvider();
80 :
81 : void init();
82 :
83 : ::com::sun::star::uno::Reference<
84 : ::com::sun::star::chart2::data::XDataSequence > getOriginalCategories();
85 :
86 : ::com::sun::star::uno::Sequence< ::rtl::OUString > getSimpleCategories();
87 : const std::vector<ComplexCategory>* getCategoriesByLevel( sal_Int32 nLevel );
88 :
89 : static ::rtl::OUString getCategoryByIndex(
90 : const ::com::sun::star::uno::Reference<
91 : ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel
92 : , const ::com::sun::star::uno::Reference<
93 : ::com::sun::star::frame::XModel >& xChartModel
94 : , sal_Int32 nIndex );
95 :
96 : static ::com::sun::star::uno::Sequence< ::rtl::OUString > getExplicitSimpleCategories(
97 : const SplitCategoriesProvider& rSplitCategoriesProvider );
98 :
99 : static void convertCategoryAnysToText( ::com::sun::star::uno::Sequence< rtl::OUString >& rOutTexts
100 : , const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rInAnys
101 : , ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xChartModel );
102 :
103 : bool hasComplexCategories() const;
104 : sal_Int32 getCategoryLevelCount() const;
105 :
106 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
107 : ::com::sun::star::chart2::data::XLabeledDataSequence> >& getSplitCategoriesList();
108 :
109 : bool isDateAxis();
110 : const std::vector< DatePlusIndex >& getDateCategories();
111 :
112 : private: //member
113 : bool volatile m_bDirty;
114 : ::com::sun::star::uno::WeakReference<
115 : ::com::sun::star::chart2::XCoordinateSystem > m_xCooSysModel;
116 : ::com::sun::star::uno::WeakReference<
117 : ::com::sun::star::frame::XModel > m_xChartModel;
118 : ::com::sun::star::uno::Reference<
119 : ::com::sun::star::chart2::data::XLabeledDataSequence> m_xOriginalCategories;
120 :
121 : bool m_bIsExplicitCategoriesInited;
122 : ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aExplicitCategories;
123 : ::std::vector< ::std::vector< ComplexCategory > > m_aComplexCats;
124 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
125 : ::com::sun::star::chart2::data::XLabeledDataSequence> > m_aSplitCategoriesList;
126 :
127 : bool m_bIsDateAxis;
128 : bool m_bIsAutoDate;
129 : std::vector< DatePlusIndex > m_aDateCategories;
130 : };
131 :
132 : } // namespace chart
133 :
134 : // CHART2_VIEW_EXPLICITCATEGORIESPROVIDER_HXX
135 : #endif
136 :
137 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|