1*38d50f7bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*38d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*38d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*38d50f7bSAndrew Rist * distributed with this work for additional information 6*38d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*38d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*38d50f7bSAndrew Rist * "License"); you may not use this file except in compliance 9*38d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at 10*38d50f7bSAndrew Rist * 11*38d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*38d50f7bSAndrew Rist * 13*38d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*38d50f7bSAndrew Rist * software distributed under the License is distributed on an 15*38d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*38d50f7bSAndrew Rist * KIND, either express or implied. See the License for the 17*38d50f7bSAndrew Rist * specific language governing permissions and limitations 18*38d50f7bSAndrew Rist * under the License. 19*38d50f7bSAndrew Rist * 20*38d50f7bSAndrew Rist *************************************************************/ 21*38d50f7bSAndrew Rist 22*38d50f7bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SC_CHARTPOS_HXX 25cdf0e10cSrcweir #define SC_CHARTPOS_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir // ----------------------------------------------------------------------- 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "collect.hxx" 30cdf0e10cSrcweir #include "rangelst.hxx" 31cdf0e10cSrcweir 32cdf0e10cSrcweir 33cdf0e10cSrcweir class ScAddress; 34cdf0e10cSrcweir class Table; 35cdf0e10cSrcweir 36cdf0e10cSrcweir class ScChartPositionMap 37cdf0e10cSrcweir { 38cdf0e10cSrcweir friend class ScChartPositioner; 39cdf0e10cSrcweir 40cdf0e10cSrcweir ScAddress** ppData; 41cdf0e10cSrcweir ScAddress** ppColHeader; 42cdf0e10cSrcweir ScAddress** ppRowHeader; 43cdf0e10cSrcweir sal_uLong nCount; 44cdf0e10cSrcweir SCCOL nColCount; 45cdf0e10cSrcweir SCROW nRowCount; 46cdf0e10cSrcweir 47cdf0e10cSrcweir ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows, 48cdf0e10cSrcweir SCCOL nColAdd, // Header-Spalten 49cdf0e10cSrcweir SCROW nRowAdd, // Header-Zeilen 50cdf0e10cSrcweir Table& rCols // Table mit Col-Tables mit Address* 51cdf0e10cSrcweir ); 52cdf0e10cSrcweir ~ScChartPositionMap(); //! deletes all ScAddress* 53cdf0e10cSrcweir 54cdf0e10cSrcweir // not implemented 55cdf0e10cSrcweir ScChartPositionMap( const ScChartPositionMap& ); 56cdf0e10cSrcweir ScChartPositionMap& operator=( const ScChartPositionMap& ); 57cdf0e10cSrcweir 58cdf0e10cSrcweir public: 59cdf0e10cSrcweir GetCount() const60cdf0e10cSrcweir sal_uLong GetCount() const { return nCount; } GetColCount() const61cdf0e10cSrcweir SCCOL GetColCount() const { return nColCount; } GetRowCount() const62cdf0e10cSrcweir SCROW GetRowCount() const { return nRowCount; } 63cdf0e10cSrcweir IsValid(SCCOL nCol,SCROW nRow) const64cdf0e10cSrcweir sal_Bool IsValid( SCCOL nCol, SCROW nRow ) const 65cdf0e10cSrcweir { return nCol < nColCount && nRow < nRowCount; } 66cdf0e10cSrcweir // Daten spaltenweise GetIndex(SCCOL nCol,SCROW nRow) const67cdf0e10cSrcweir sal_uLong GetIndex( SCCOL nCol, SCROW nRow ) const 68cdf0e10cSrcweir { return (sal_uLong) nCol * nRowCount + nRow; } 69cdf0e10cSrcweir GetPosition(sal_uLong nIndex) const70cdf0e10cSrcweir const ScAddress* GetPosition( sal_uLong nIndex ) const 71cdf0e10cSrcweir { 72cdf0e10cSrcweir if ( nIndex < nCount ) 73cdf0e10cSrcweir return ppData[ nIndex ]; 74cdf0e10cSrcweir return NULL; 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir //! kann NULL sein und damit "kein Wert" GetPosition(SCCOL nChartCol,SCROW nChartRow) const78cdf0e10cSrcweir const ScAddress* GetPosition( SCCOL nChartCol, SCROW nChartRow ) const 79cdf0e10cSrcweir { 80cdf0e10cSrcweir if ( IsValid( nChartCol, nChartRow ) ) 81cdf0e10cSrcweir return ppData[ GetIndex( nChartCol, nChartRow ) ]; 82cdf0e10cSrcweir return NULL; 83cdf0e10cSrcweir } GetColHeaderPosition(SCCOL nChartCol) const84cdf0e10cSrcweir const ScAddress* GetColHeaderPosition( SCCOL nChartCol ) const 85cdf0e10cSrcweir { 86cdf0e10cSrcweir if ( nChartCol < nColCount ) 87cdf0e10cSrcweir return ppColHeader[ nChartCol ]; 88cdf0e10cSrcweir return NULL; 89cdf0e10cSrcweir } GetRowHeaderPosition(SCROW nChartRow) const90cdf0e10cSrcweir const ScAddress* GetRowHeaderPosition( SCROW nChartRow ) const 91cdf0e10cSrcweir { 92cdf0e10cSrcweir if ( nChartRow < nRowCount ) 93cdf0e10cSrcweir return ppRowHeader[ nChartRow ]; 94cdf0e10cSrcweir return NULL; 95cdf0e10cSrcweir } 96cdf0e10cSrcweir //UNUSED2009-05 ScRangeListRef GetColRanges( SCCOL nChartCol ) const; 97cdf0e10cSrcweir //UNUSED2009-05 ScRangeListRef GetRowRanges( SCROW nChartRow ) const; 98cdf0e10cSrcweir }; 99cdf0e10cSrcweir 100cdf0e10cSrcweir 101cdf0e10cSrcweir enum ScChartGlue { 102cdf0e10cSrcweir SC_CHARTGLUE_NA, 103cdf0e10cSrcweir SC_CHARTGLUE_NONE, // alte Mimik 104cdf0e10cSrcweir SC_CHARTGLUE_COLS, // alte Mimik 105cdf0e10cSrcweir SC_CHARTGLUE_ROWS, 106cdf0e10cSrcweir SC_CHARTGLUE_BOTH 107cdf0e10cSrcweir }; 108cdf0e10cSrcweir 109cdf0e10cSrcweir class ScDocument; 110cdf0e10cSrcweir 111cdf0e10cSrcweir class ScChartPositioner // nur noch Parameter-Struct 112cdf0e10cSrcweir { 113cdf0e10cSrcweir ScRangeListRef aRangeListRef; 114cdf0e10cSrcweir ScDocument* pDocument; 115cdf0e10cSrcweir ScChartPositionMap* pPositionMap; 116cdf0e10cSrcweir ScChartGlue eGlue; 117cdf0e10cSrcweir SCCOL nStartCol; 118cdf0e10cSrcweir SCROW nStartRow; 119cdf0e10cSrcweir sal_Bool bColHeaders; 120cdf0e10cSrcweir sal_Bool bRowHeaders; 121cdf0e10cSrcweir sal_Bool bDummyUpperLeft; 122cdf0e10cSrcweir 123cdf0e10cSrcweir private: 124cdf0e10cSrcweir void CheckColRowHeaders(); 125cdf0e10cSrcweir 126cdf0e10cSrcweir void GlueState(); // zusammengefasste Bereiche 127cdf0e10cSrcweir void CreatePositionMap(); 128cdf0e10cSrcweir 129cdf0e10cSrcweir public: 130cdf0e10cSrcweir ScChartPositioner( ScDocument* pDoc, SCTAB nTab, 131cdf0e10cSrcweir SCCOL nStartColP, SCROW nStartRowP, 132cdf0e10cSrcweir SCCOL nEndColP, SCROW nEndRowP ); 133cdf0e10cSrcweir ScChartPositioner( ScDocument* pDoc, const ScRangeListRef& rRangeList ); 134cdf0e10cSrcweir ScChartPositioner( const ScChartPositioner& rPositioner ); 135cdf0e10cSrcweir 136cdf0e10cSrcweir virtual ~ScChartPositioner(); 137cdf0e10cSrcweir GetRangeList() const138cdf0e10cSrcweir const ScRangeListRef& GetRangeList() const { return aRangeListRef; } SetRangeList(const ScRangeListRef & rNew)139cdf0e10cSrcweir void SetRangeList( const ScRangeListRef& rNew ) { aRangeListRef = rNew; } 140cdf0e10cSrcweir void SetRangeList( const ScRange& rNew ); 141cdf0e10cSrcweir SetHeaders(sal_Bool bCol,sal_Bool bRow)142cdf0e10cSrcweir void SetHeaders(sal_Bool bCol, sal_Bool bRow) { bColHeaders=bCol; bRowHeaders=bRow; } HasColHeaders() const143cdf0e10cSrcweir sal_Bool HasColHeaders() const { return bColHeaders; } HasRowHeaders() const144cdf0e10cSrcweir sal_Bool HasRowHeaders() const { return bRowHeaders; } SetDummyUpperLeft(sal_Bool bNew)145cdf0e10cSrcweir void SetDummyUpperLeft(sal_Bool bNew) { bDummyUpperLeft = bNew; } SeteGlue(ScChartGlue eNew)146cdf0e10cSrcweir void SeteGlue(ScChartGlue eNew) { eGlue = eNew; } SetStartCol(SCCOL nNew)147cdf0e10cSrcweir void SetStartCol(SCCOL nNew) { nStartCol = nNew; } SetStartRow(SCROW nNew)148cdf0e10cSrcweir void SetStartRow(SCROW nNew) { nStartRow = nNew; } 149cdf0e10cSrcweir 150cdf0e10cSrcweir sal_Bool operator==(const ScChartPositioner& rCmp) const; 151cdf0e10cSrcweir InvalidateGlue()152cdf0e10cSrcweir void InvalidateGlue() 153cdf0e10cSrcweir { 154cdf0e10cSrcweir eGlue = SC_CHARTGLUE_NA; 155cdf0e10cSrcweir if ( pPositionMap ) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir delete pPositionMap; 158cdf0e10cSrcweir pPositionMap = NULL; 159cdf0e10cSrcweir } 160cdf0e10cSrcweir } 161cdf0e10cSrcweir const ScChartPositionMap* GetPositionMap(); 162cdf0e10cSrcweir }; 163cdf0e10cSrcweir 164cdf0e10cSrcweir 165cdf0e10cSrcweir #endif 166cdf0e10cSrcweir 167