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