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 10cdf0e10cSrcweir * 11*de7b3f82SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 20*de7b3f82SAndrew Rist *************************************************************/ 21*de7b3f82SAndrew Rist 22*de7b3f82SAndrew Rist 23cdf0e10cSrcweir #ifndef CHART2_DATABROWSERMODEL_HXX 24cdf0e10cSrcweir #define CHART2_DATABROWSERMODEL_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp> 27cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <memory> 30cdf0e10cSrcweir #include <vector> 31cdf0e10cSrcweir 32cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace chart2 { 33cdf0e10cSrcweir class XDataSeries; 34cdf0e10cSrcweir class XChartType; 35cdf0e10cSrcweir namespace data { 36cdf0e10cSrcweir class XLabeledDataSequence; 37cdf0e10cSrcweir } 38cdf0e10cSrcweir }}}} 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace chart 41cdf0e10cSrcweir { 42cdf0e10cSrcweir 43cdf0e10cSrcweir class DialogModel; 44cdf0e10cSrcweir 45cdf0e10cSrcweir class DataBrowserModel 46cdf0e10cSrcweir { 47cdf0e10cSrcweir public: 48cdf0e10cSrcweir explicit DataBrowserModel( 49cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc, 50cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 51cdf0e10cSrcweir ::com::sun::star::uno::XComponentContext > & xContext ); 52cdf0e10cSrcweir virtual ~DataBrowserModel(); 53cdf0e10cSrcweir 54cdf0e10cSrcweir /** Inserts a new data series after the data series to which the data column 55cdf0e10cSrcweir with index nAfterColumnIndex belongs. 56cdf0e10cSrcweir */ 57cdf0e10cSrcweir void insertDataSeries( sal_Int32 nAfterColumnIndex ); 58cdf0e10cSrcweir 59cdf0e10cSrcweir /** Inserts a new text column for complex categories. 60cdf0e10cSrcweir */ 61cdf0e10cSrcweir void insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex ); 62cdf0e10cSrcweir 63cdf0e10cSrcweir /** Removes a data series to which the data column with index nAtColumnIndex 64cdf0e10cSrcweir belongs. 65cdf0e10cSrcweir */ 66cdf0e10cSrcweir void removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex ); 67cdf0e10cSrcweir 68cdf0e10cSrcweir /** Swaps the series to which the data column with index nFirstIndex belongs 69cdf0e10cSrcweir with the next series (which starts at an index >= nFirstIndex + 1) 70cdf0e10cSrcweir */ 71cdf0e10cSrcweir void swapDataSeries( sal_Int32 nFirstIndex ); 72cdf0e10cSrcweir void swapDataPointForAllSeries( sal_Int32 nFirstIndex ); 73cdf0e10cSrcweir 74cdf0e10cSrcweir void insertDataPointForAllSeries( sal_Int32 nAfterIndex ); 75cdf0e10cSrcweir void removeDataPointForAllSeries( sal_Int32 nAtIndex ); 76cdf0e10cSrcweir 77cdf0e10cSrcweir enum eCellType 78cdf0e10cSrcweir { 79cdf0e10cSrcweir NUMBER, 80cdf0e10cSrcweir TEXT, 81cdf0e10cSrcweir TEXTORDATE 82cdf0e10cSrcweir }; 83cdf0e10cSrcweir 84cdf0e10cSrcweir eCellType getCellType( sal_Int32 nAtColumn, sal_Int32 nAtRow ) const; 85cdf0e10cSrcweir /// If getCellType( nAtColumn, nAtRow ) returns TEXT, the result will be Nan 86cdf0e10cSrcweir double getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ); 87cdf0e10cSrcweir ::rtl::OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ); 88cdf0e10cSrcweir ::com::sun::star::uno::Any getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow ); 89cdf0e10cSrcweir sal_uInt32 getNumberFormatKey( sal_Int32 nAtColumn, sal_Int32 nAtRow ); 90cdf0e10cSrcweir 91cdf0e10cSrcweir /// returns </sal_True> if the number could successfully be set at the given position 92cdf0e10cSrcweir bool setCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow, double fValue ); 93cdf0e10cSrcweir /// returns </sal_True> if the text could successfully be set at the given position 94cdf0e10cSrcweir bool setCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow, const ::rtl::OUString & rText ); 95cdf0e10cSrcweir bool setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const ::com::sun::star::uno::Any & aValue ); 96cdf0e10cSrcweir 97cdf0e10cSrcweir sal_Int32 getColumnCount() const; 98cdf0e10cSrcweir sal_Int32 getMaxRowCount() const; 99cdf0e10cSrcweir 100cdf0e10cSrcweir // returns the UI string of the corresponding role 101cdf0e10cSrcweir ::rtl::OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const; 102cdf0e10cSrcweir bool isCategoriesColumn( sal_Int32 nColumnIndex ) const; 103cdf0e10cSrcweir 104cdf0e10cSrcweir struct tDataHeader 105cdf0e10cSrcweir { 106cdf0e10cSrcweir ::com::sun::star::uno::Reference< 107cdf0e10cSrcweir ::com::sun::star::chart2::XDataSeries > m_xDataSeries; 108cdf0e10cSrcweir ::com::sun::star::uno::Reference< 109cdf0e10cSrcweir ::com::sun::star::chart2::XChartType > m_xChartType; 110cdf0e10cSrcweir bool m_bSwapXAndYAxis; 111cdf0e10cSrcweir sal_Int32 m_nStartColumn; 112cdf0e10cSrcweir sal_Int32 m_nEndColumn; 113cdf0e10cSrcweir 114cdf0e10cSrcweir // default CTOR tDataHeaderchart::DataBrowserModel::tDataHeader115cdf0e10cSrcweir tDataHeader() : 116cdf0e10cSrcweir m_bSwapXAndYAxis( false ), 117cdf0e10cSrcweir m_nStartColumn( -1 ), 118cdf0e10cSrcweir m_nEndColumn( -1 ) 119cdf0e10cSrcweir {} 120cdf0e10cSrcweir // "full" CTOR tDataHeaderchart::DataBrowserModel::tDataHeader121cdf0e10cSrcweir tDataHeader( 122cdf0e10cSrcweir ::com::sun::star::uno::Reference< 123cdf0e10cSrcweir ::com::sun::star::chart2::XDataSeries > xDataSeries, 124cdf0e10cSrcweir ::com::sun::star::uno::Reference< 125cdf0e10cSrcweir ::com::sun::star::chart2::XChartType > xChartType, 126cdf0e10cSrcweir bool bSwapXAndYAxis, 127cdf0e10cSrcweir sal_Int32 nStartColumn, 128cdf0e10cSrcweir sal_Int32 nEndColumn ) : 129cdf0e10cSrcweir m_xDataSeries( xDataSeries ), 130cdf0e10cSrcweir m_xChartType( xChartType ), 131cdf0e10cSrcweir m_bSwapXAndYAxis( bSwapXAndYAxis ), 132cdf0e10cSrcweir m_nStartColumn( nStartColumn ), 133cdf0e10cSrcweir m_nEndColumn( nEndColumn ) 134cdf0e10cSrcweir {} 135cdf0e10cSrcweir }; 136cdf0e10cSrcweir 137cdf0e10cSrcweir typedef ::std::vector< tDataHeader > tDataHeaderVector; 138cdf0e10cSrcweir 139cdf0e10cSrcweir const tDataHeaderVector& getDataHeaders() const; 140cdf0e10cSrcweir 141cdf0e10cSrcweir tDataHeader getHeaderForSeries( 142cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 143cdf0e10cSrcweir ::com::sun::star::chart2::XDataSeries > &xSeries ) const; 144cdf0e10cSrcweir 145cdf0e10cSrcweir ::com::sun::star::uno::Reference< 146cdf0e10cSrcweir ::com::sun::star::chart2::XDataSeries > 147cdf0e10cSrcweir getDataSeriesByColumn( sal_Int32 nColumn ) const; 148cdf0e10cSrcweir 149cdf0e10cSrcweir private: 150cdf0e10cSrcweir void updateFromModel(); 151cdf0e10cSrcweir 152cdf0e10cSrcweir void addErrorBarRanges( 153cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 154cdf0e10cSrcweir ::com::sun::star::chart2::XDataSeries > & xDataSeries, 155cdf0e10cSrcweir sal_Int32 nNumberFormatKey, 156cdf0e10cSrcweir sal_Int32 & rInOutSequenceIndex, 157cdf0e10cSrcweir sal_Int32 & rInOutHeaderEnd ); 158cdf0e10cSrcweir 159cdf0e10cSrcweir sal_Int32 getCategoryColumnCount(); 160cdf0e10cSrcweir 161cdf0e10cSrcweir ::com::sun::star::uno::Reference< 162cdf0e10cSrcweir ::com::sun::star::chart2::XChartDocument > m_xChartDocument; 163cdf0e10cSrcweir ::com::sun::star::uno::Reference< 164cdf0e10cSrcweir ::com::sun::star::uno::XComponentContext > m_xContext; 165cdf0e10cSrcweir ::std::auto_ptr< DialogModel > m_apDialogModel; 166cdf0e10cSrcweir 167cdf0e10cSrcweir struct tDataColumn; 168cdf0e10cSrcweir struct implColumnLess; 169cdf0e10cSrcweir 170cdf0e10cSrcweir typedef ::std::vector< tDataColumn > tDataColumnVector; 171cdf0e10cSrcweir 172cdf0e10cSrcweir tDataColumnVector m_aColumns; 173cdf0e10cSrcweir tDataHeaderVector m_aHeaders; 174cdf0e10cSrcweir }; 175cdf0e10cSrcweir 176cdf0e10cSrcweir } // namespace chart 177cdf0e10cSrcweir 178cdf0e10cSrcweir // CHART2_DATABROWSERMODEL_HXX 179cdf0e10cSrcweir #endif 180