1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef SC_CHARTPOS_HXX 29*cdf0e10cSrcweir #define SC_CHARTPOS_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // ----------------------------------------------------------------------- 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include "collect.hxx" 34*cdf0e10cSrcweir #include "rangelst.hxx" 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir class ScAddress; 38*cdf0e10cSrcweir class Table; 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir class ScChartPositionMap 41*cdf0e10cSrcweir { 42*cdf0e10cSrcweir friend class ScChartPositioner; 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir ScAddress** ppData; 45*cdf0e10cSrcweir ScAddress** ppColHeader; 46*cdf0e10cSrcweir ScAddress** ppRowHeader; 47*cdf0e10cSrcweir sal_uLong nCount; 48*cdf0e10cSrcweir SCCOL nColCount; 49*cdf0e10cSrcweir SCROW nRowCount; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows, 52*cdf0e10cSrcweir SCCOL nColAdd, // Header-Spalten 53*cdf0e10cSrcweir SCROW nRowAdd, // Header-Zeilen 54*cdf0e10cSrcweir Table& rCols // Table mit Col-Tables mit Address* 55*cdf0e10cSrcweir ); 56*cdf0e10cSrcweir ~ScChartPositionMap(); //! deletes all ScAddress* 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir // not implemented 59*cdf0e10cSrcweir ScChartPositionMap( const ScChartPositionMap& ); 60*cdf0e10cSrcweir ScChartPositionMap& operator=( const ScChartPositionMap& ); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir public: 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir sal_uLong GetCount() const { return nCount; } 65*cdf0e10cSrcweir SCCOL GetColCount() const { return nColCount; } 66*cdf0e10cSrcweir SCROW GetRowCount() const { return nRowCount; } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir sal_Bool IsValid( SCCOL nCol, SCROW nRow ) const 69*cdf0e10cSrcweir { return nCol < nColCount && nRow < nRowCount; } 70*cdf0e10cSrcweir // Daten spaltenweise 71*cdf0e10cSrcweir sal_uLong GetIndex( SCCOL nCol, SCROW nRow ) const 72*cdf0e10cSrcweir { return (sal_uLong) nCol * nRowCount + nRow; } 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir const ScAddress* GetPosition( sal_uLong nIndex ) const 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir if ( nIndex < nCount ) 77*cdf0e10cSrcweir return ppData[ nIndex ]; 78*cdf0e10cSrcweir return NULL; 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir //! kann NULL sein und damit "kein Wert" 82*cdf0e10cSrcweir const ScAddress* GetPosition( SCCOL nChartCol, SCROW nChartRow ) const 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir if ( IsValid( nChartCol, nChartRow ) ) 85*cdf0e10cSrcweir return ppData[ GetIndex( nChartCol, nChartRow ) ]; 86*cdf0e10cSrcweir return NULL; 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir const ScAddress* GetColHeaderPosition( SCCOL nChartCol ) const 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir if ( nChartCol < nColCount ) 91*cdf0e10cSrcweir return ppColHeader[ nChartCol ]; 92*cdf0e10cSrcweir return NULL; 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir const ScAddress* GetRowHeaderPosition( SCROW nChartRow ) const 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir if ( nChartRow < nRowCount ) 97*cdf0e10cSrcweir return ppRowHeader[ nChartRow ]; 98*cdf0e10cSrcweir return NULL; 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir //UNUSED2009-05 ScRangeListRef GetColRanges( SCCOL nChartCol ) const; 101*cdf0e10cSrcweir //UNUSED2009-05 ScRangeListRef GetRowRanges( SCROW nChartRow ) const; 102*cdf0e10cSrcweir }; 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir enum ScChartGlue { 106*cdf0e10cSrcweir SC_CHARTGLUE_NA, 107*cdf0e10cSrcweir SC_CHARTGLUE_NONE, // alte Mimik 108*cdf0e10cSrcweir SC_CHARTGLUE_COLS, // alte Mimik 109*cdf0e10cSrcweir SC_CHARTGLUE_ROWS, 110*cdf0e10cSrcweir SC_CHARTGLUE_BOTH 111*cdf0e10cSrcweir }; 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir class ScDocument; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir class ScChartPositioner // nur noch Parameter-Struct 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir ScRangeListRef aRangeListRef; 118*cdf0e10cSrcweir ScDocument* pDocument; 119*cdf0e10cSrcweir ScChartPositionMap* pPositionMap; 120*cdf0e10cSrcweir ScChartGlue eGlue; 121*cdf0e10cSrcweir SCCOL nStartCol; 122*cdf0e10cSrcweir SCROW nStartRow; 123*cdf0e10cSrcweir sal_Bool bColHeaders; 124*cdf0e10cSrcweir sal_Bool bRowHeaders; 125*cdf0e10cSrcweir sal_Bool bDummyUpperLeft; 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir private: 128*cdf0e10cSrcweir void CheckColRowHeaders(); 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir void GlueState(); // zusammengefasste Bereiche 131*cdf0e10cSrcweir void CreatePositionMap(); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir public: 134*cdf0e10cSrcweir ScChartPositioner( ScDocument* pDoc, SCTAB nTab, 135*cdf0e10cSrcweir SCCOL nStartColP, SCROW nStartRowP, 136*cdf0e10cSrcweir SCCOL nEndColP, SCROW nEndRowP ); 137*cdf0e10cSrcweir ScChartPositioner( ScDocument* pDoc, const ScRangeListRef& rRangeList ); 138*cdf0e10cSrcweir ScChartPositioner( const ScChartPositioner& rPositioner ); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir virtual ~ScChartPositioner(); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir const ScRangeListRef& GetRangeList() const { return aRangeListRef; } 143*cdf0e10cSrcweir void SetRangeList( const ScRangeListRef& rNew ) { aRangeListRef = rNew; } 144*cdf0e10cSrcweir void SetRangeList( const ScRange& rNew ); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir void SetHeaders(sal_Bool bCol, sal_Bool bRow) { bColHeaders=bCol; bRowHeaders=bRow; } 147*cdf0e10cSrcweir sal_Bool HasColHeaders() const { return bColHeaders; } 148*cdf0e10cSrcweir sal_Bool HasRowHeaders() const { return bRowHeaders; } 149*cdf0e10cSrcweir void SetDummyUpperLeft(sal_Bool bNew) { bDummyUpperLeft = bNew; } 150*cdf0e10cSrcweir void SeteGlue(ScChartGlue eNew) { eGlue = eNew; } 151*cdf0e10cSrcweir void SetStartCol(SCCOL nNew) { nStartCol = nNew; } 152*cdf0e10cSrcweir void SetStartRow(SCROW nNew) { nStartRow = nNew; } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir sal_Bool operator==(const ScChartPositioner& rCmp) const; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir void InvalidateGlue() 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir eGlue = SC_CHARTGLUE_NA; 159*cdf0e10cSrcweir if ( pPositionMap ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir delete pPositionMap; 162*cdf0e10cSrcweir pPositionMap = NULL; 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir const ScChartPositionMap* GetPositionMap(); 166*cdf0e10cSrcweir }; 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir #endif 170*cdf0e10cSrcweir 171