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 CHART2_VIEW_EXPLICITCATEGORIESPROVIDER_HXX 28 #define CHART2_VIEW_EXPLICITCATEGORIESPROVIDER_HXX 29 30 #include "ServiceMacros.hxx" 31 #include <cppuhelper/implbase1.hxx> 32 #include <cppuhelper/weakref.hxx> 33 #include <com/sun/star/chart2/XCoordinateSystem.hpp> 34 #include <com/sun/star/chart2/data/XTextualDataSequence.hpp> 35 #include <com/sun/star/frame/XModel.hpp> 36 #include "charttoolsdllapi.hxx" 37 38 #include <vector> 39 40 namespace chart 41 { 42 43 struct OOO_DLLPUBLIC_CHARTTOOLS ComplexCategory 44 { 45 rtl::OUString Text; 46 sal_Int32 Count; 47 48 ComplexCategory( const rtl::OUString& rText, sal_Int32 nCount ) : Text( rText ), Count (nCount) 49 {} 50 }; 51 52 class OOO_DLLPUBLIC_CHARTTOOLS SplitCategoriesProvider 53 { 54 public: 55 virtual ~SplitCategoriesProvider(); 56 57 virtual sal_Int32 getLevelCount() const = 0; 58 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const = 0; 59 }; 60 61 struct DatePlusIndex 62 { 63 DatePlusIndex() 64 : fValue(1.0) 65 , nIndex( -1 ) 66 { 67 } 68 69 DatePlusIndex( const double& _fValue, sal_Int32 _nIndex ) 70 : fValue(_fValue) 71 , nIndex( _nIndex ) 72 { 73 } 74 75 double fValue; 76 sal_Int32 nIndex; 77 }; 78 79 class OOO_DLLPUBLIC_CHARTTOOLS ExplicitCategoriesProvider 80 { 81 public: 82 ExplicitCategoriesProvider( const ::com::sun::star::uno::Reference< 83 ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel 84 , const ::com::sun::star::uno::Reference< 85 ::com::sun::star::frame::XModel >& xChartModel 86 ); 87 virtual ~ExplicitCategoriesProvider(); 88 89 void init(); 90 91 ::com::sun::star::uno::Reference< 92 ::com::sun::star::chart2::data::XDataSequence > getOriginalCategories(); 93 94 ::com::sun::star::uno::Sequence< ::rtl::OUString > getSimpleCategories(); 95 ::std::vector< ComplexCategory > getCategoriesByLevel( sal_Int32 nLevel ); 96 97 static ::rtl::OUString getCategoryByIndex( 98 const ::com::sun::star::uno::Reference< 99 ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel 100 , const ::com::sun::star::uno::Reference< 101 ::com::sun::star::frame::XModel >& xChartModel 102 , sal_Int32 nIndex ); 103 104 static ::com::sun::star::uno::Sequence< ::rtl::OUString > getExplicitSimpleCategories( 105 const SplitCategoriesProvider& rSplitCategoriesProvider ); 106 107 static void convertCategoryAnysToText( ::com::sun::star::uno::Sequence< rtl::OUString >& rOutTexts 108 , const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rInAnys 109 , ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xChartModel ); 110 111 bool hasComplexCategories() const; 112 sal_Int32 getCategoryLevelCount() const; 113 114 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< 115 ::com::sun::star::chart2::data::XLabeledDataSequence> >& getSplitCategoriesList(); 116 117 bool isDateAxis(); 118 const std::vector< DatePlusIndex >& getDateCategories(); 119 120 private: //member 121 bool volatile m_bDirty; 122 ::com::sun::star::uno::WeakReference< 123 ::com::sun::star::chart2::XCoordinateSystem > m_xCooSysModel; 124 ::com::sun::star::uno::WeakReference< 125 ::com::sun::star::frame::XModel > m_xChartModel; 126 ::com::sun::star::uno::Reference< 127 ::com::sun::star::chart2::data::XLabeledDataSequence> m_xOriginalCategories; 128 129 bool m_bIsExplicitCategoriesInited; 130 ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aExplicitCategories; 131 ::std::vector< ::std::vector< ComplexCategory > > m_aComplexCats; 132 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< 133 ::com::sun::star::chart2::data::XLabeledDataSequence> > m_aSplitCategoriesList; 134 135 bool m_bIsDateAxis; 136 bool m_bIsAutoDate; 137 std::vector< DatePlusIndex > m_aDateCategories; 138 }; 139 140 } // namespace chart 141 142 // CHART2_VIEW_EXPLICITCATEGORIESPROVIDER_HXX 143 #endif 144