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