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 CHART2_DIALOGMODEL_HXX 24 #define CHART2_DIALOGMODEL_HXX 25 26 #include "TimerTriggeredControllerLock.hxx" 27 #include <com/sun/star/chart2/XChartDocument.hpp> 28 #include <com/sun/star/frame/XModel.hpp> 29 #include <com/sun/star/uno/XComponentContext.hpp> 30 31 #include <vector> 32 #include <map> 33 #include <boost/shared_ptr.hpp> 34 35 namespace com { namespace sun { namespace star { namespace chart2 { 36 class XDataSeriesContainer; 37 class XDataSeries; 38 class XChartType; 39 class XChartTypeTemplate; 40 struct InterpretedData; 41 namespace data { 42 class XDataProvider; 43 class XLabeledDataSequence; 44 } 45 }}}} 46 47 namespace chart 48 { 49 50 class RangeSelectionHelper; 51 52 class DialogModel 53 { 54 public: 55 explicit DialogModel( 56 const ::com::sun::star::uno::Reference< 57 ::com::sun::star::chart2::XChartDocument > & xChartDocument, 58 const ::com::sun::star::uno::Reference< 59 ::com::sun::star::uno::XComponentContext > & xContext ); 60 ~DialogModel(); 61 62 typedef ::std::pair< 63 ::rtl::OUString, 64 ::std::pair< ::com::sun::star::uno::Reference< 65 ::com::sun::star::chart2::XDataSeries >, 66 ::com::sun::star::uno::Reference< 67 ::com::sun::star::chart2::XChartType > > > 68 tSeriesWithChartTypeByName; 69 70 typedef ::std::map< ::rtl::OUString, ::rtl::OUString > 71 tRolesWithRanges; 72 73 void setTemplate( 74 const ::com::sun::star::uno::Reference< 75 ::com::sun::star::chart2::XChartTypeTemplate > & xTemplate ); 76 77 ::boost::shared_ptr< RangeSelectionHelper > 78 getRangeSelectionHelper() const; 79 80 ::com::sun::star::uno::Reference< 81 ::com::sun::star::frame::XModel > 82 getChartModel() const; 83 84 ::com::sun::star::uno::Reference< 85 ::com::sun::star::chart2::data::XDataProvider > 86 getDataProvider() const; 87 88 ::std::vector< ::com::sun::star::uno::Reference< 89 ::com::sun::star::chart2::XDataSeriesContainer > > 90 getAllDataSeriesContainers() const; 91 92 ::std::vector< tSeriesWithChartTypeByName > 93 getAllDataSeriesWithLabel() const; 94 95 tRolesWithRanges getRolesWithRanges( 96 const ::com::sun::star::uno::Reference< 97 ::com::sun::star::chart2::XDataSeries > & xSeries, 98 const ::rtl::OUString & aRoleOfSequenceForLabel, 99 const ::com::sun::star::uno::Reference< 100 ::com::sun::star::chart2::XChartType > & xChartType ) const; 101 102 enum eMoveDirection 103 { 104 MOVE_DOWN, 105 MOVE_UP 106 }; 107 108 void moveSeries( const ::com::sun::star::uno::Reference< 109 ::com::sun::star::chart2::XDataSeries > & xSeries, 110 eMoveDirection eDirection ); 111 112 /// @return the newly inserted series 113 ::com::sun::star::uno::Reference< 114 ::com::sun::star::chart2::XDataSeries > insertSeriesAfter( 115 const ::com::sun::star::uno::Reference< 116 ::com::sun::star::chart2::XDataSeries > & xSeries, 117 const ::com::sun::star::uno::Reference< 118 ::com::sun::star::chart2::XChartType > & xChartType, 119 bool bCreateDataCachedSequences = false ); 120 121 void deleteSeries( 122 const ::com::sun::star::uno::Reference< 123 ::com::sun::star::chart2::XDataSeries > & xSeries, 124 const ::com::sun::star::uno::Reference< 125 ::com::sun::star::chart2::XChartType > & xChartType ); 126 127 ::com::sun::star::uno::Reference< 128 ::com::sun::star::chart2::data::XLabeledDataSequence > 129 getCategories() const; 130 131 void setCategories( const ::com::sun::star::uno::Reference< 132 ::com::sun::star::chart2::data::XLabeledDataSequence > & xCategories ); 133 134 ::rtl::OUString getCategoriesRange() const; 135 136 bool isCategoryDiagram() const; 137 138 void detectArguments( 139 ::rtl::OUString & rOutRangeString, 140 bool & rOutUseColumns, bool & rOutFirstCellAsLabel, bool & rOutHasCategories ) const; 141 142 bool allArgumentsForRectRangeDetected() const; 143 144 bool setData( const ::com::sun::star::uno::Sequence< 145 ::com::sun::star::beans::PropertyValue > & rArguments ); 146 147 void startControllerLockTimer(); 148 149 static ::rtl::OUString ConvertRoleFromInternalToUI( const ::rtl::OUString & rRoleString ); 150 static ::rtl::OUString GetRoleDataLabel(); 151 152 // pass a role string (not translated) and get an index that serves for 153 // relative ordering, to get e.g. x-values and y-values in the right order 154 static sal_Int32 GetRoleIndexForSorting( const ::rtl::OUString & rInternalRoleString ); 155 156 private: 157 ::com::sun::star::uno::Reference< 158 ::com::sun::star::chart2::XChartDocument > 159 m_xChartDocument; 160 161 ::com::sun::star::uno::Reference< 162 ::com::sun::star::chart2::XChartTypeTemplate > 163 m_xTemplate; 164 165 ::com::sun::star::uno::Reference< 166 ::com::sun::star::uno::XComponentContext > 167 m_xContext; 168 169 mutable ::boost::shared_ptr< RangeSelectionHelper > 170 m_spRangeSelectionHelper; 171 172 TimerTriggeredControllerLock m_aTimerTriggeredControllerLock; 173 174 private: 175 void createBackup(); 176 177 void applyInterpretedData( 178 const ::com::sun::star::chart2::InterpretedData & rNewData, 179 const ::std::vector< ::com::sun::star::uno::Reference< 180 ::com::sun::star::chart2::XDataSeries > > & rSeriesToReUse, 181 bool bSetStyles ); 182 183 sal_Int32 countSeries() const; 184 }; 185 186 } // namespace chart 187 188 // CHART2_DIALOGMODEL_HXX 189 #endif 190