1*3334a7e6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*3334a7e6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*3334a7e6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*3334a7e6SAndrew Rist * distributed with this work for additional information 6*3334a7e6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*3334a7e6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*3334a7e6SAndrew Rist * "License"); you may not use this file except in compliance 9*3334a7e6SAndrew Rist * with the License. You may obtain a copy of the License at 10*3334a7e6SAndrew Rist * 11*3334a7e6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*3334a7e6SAndrew Rist * 13*3334a7e6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*3334a7e6SAndrew Rist * software distributed under the License is distributed on an 15*3334a7e6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*3334a7e6SAndrew Rist * KIND, either express or implied. See the License for the 17*3334a7e6SAndrew Rist * specific language governing permissions and limitations 18*3334a7e6SAndrew Rist * under the License. 19*3334a7e6SAndrew Rist * 20*3334a7e6SAndrew Rist *************************************************************/ 21*3334a7e6SAndrew Rist 22*3334a7e6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SVX_FRAMELINKARRAY_HXX 25cdf0e10cSrcweir #define SVX_FRAMELINKARRAY_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <svx/framelink.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <memory> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <vector> 32cdf0e10cSrcweir #include "svx/svxdllapi.h" 33cdf0e10cSrcweir 34cdf0e10cSrcweir namespace svx { 35cdf0e10cSrcweir namespace frame { 36cdf0e10cSrcweir 37cdf0e10cSrcweir // ============================================================================ 38cdf0e10cSrcweir 39cdf0e10cSrcweir 40cdf0e10cSrcweir struct Cell 41cdf0e10cSrcweir { 42cdf0e10cSrcweir Style maLeft; 43cdf0e10cSrcweir Style maRight; 44cdf0e10cSrcweir Style maTop; 45cdf0e10cSrcweir Style maBottom; 46cdf0e10cSrcweir Style maTLBR; 47cdf0e10cSrcweir Style maBLTR; 48cdf0e10cSrcweir long mnAddLeft; 49cdf0e10cSrcweir long mnAddRight; 50cdf0e10cSrcweir long mnAddTop; 51cdf0e10cSrcweir long mnAddBottom; 52cdf0e10cSrcweir bool mbMergeOrig; 53cdf0e10cSrcweir bool mbOverlapX; 54cdf0e10cSrcweir bool mbOverlapY; 55cdf0e10cSrcweir 56cdf0e10cSrcweir explicit Cell(); 57cdf0e10cSrcweir IsMergedsvx::frame::Cell58cdf0e10cSrcweir inline bool IsMerged() const { return mbMergeOrig || mbOverlapX || mbOverlapY; } IsOverlappedsvx::frame::Cell59cdf0e10cSrcweir inline bool IsOverlapped() const { return mbOverlapX || mbOverlapY; } 60cdf0e10cSrcweir 61cdf0e10cSrcweir void MirrorSelfX( bool bMirrorStyles, bool bSwapDiag ); 62cdf0e10cSrcweir void MirrorSelfY( bool bMirrorStyles, bool bSwapDiag ); 63cdf0e10cSrcweir }; 64cdf0e10cSrcweir 65cdf0e10cSrcweir typedef std::vector< long > LongVec; 66cdf0e10cSrcweir typedef std::vector< Cell > CellVec; 67cdf0e10cSrcweir 68cdf0e10cSrcweir struct ArrayImpl 69cdf0e10cSrcweir { 70cdf0e10cSrcweir CellVec maCells; 71cdf0e10cSrcweir LongVec maWidths; 72cdf0e10cSrcweir LongVec maHeights; 73cdf0e10cSrcweir mutable LongVec maXCoords; 74cdf0e10cSrcweir mutable LongVec maYCoords; 75cdf0e10cSrcweir size_t mnWidth; 76cdf0e10cSrcweir size_t mnHeight; 77cdf0e10cSrcweir size_t mnFirstClipCol; 78cdf0e10cSrcweir size_t mnFirstClipRow; 79cdf0e10cSrcweir size_t mnLastClipCol; 80cdf0e10cSrcweir size_t mnLastClipRow; 81cdf0e10cSrcweir mutable bool mbXCoordsDirty; 82cdf0e10cSrcweir mutable bool mbYCoordsDirty; 83cdf0e10cSrcweir bool mbDiagDblClip; 84cdf0e10cSrcweir 85cdf0e10cSrcweir explicit ArrayImpl( size_t nWidth, size_t nHeight, bool bDiagDblClip ); 86cdf0e10cSrcweir IsValidPossvx::frame::ArrayImpl87cdf0e10cSrcweir inline bool IsValidPos( size_t nCol, size_t nRow ) const 88cdf0e10cSrcweir { return (nCol < mnWidth) && (nRow < mnHeight); } GetIndexsvx::frame::ArrayImpl89cdf0e10cSrcweir inline size_t GetIndex( size_t nCol, size_t nRow ) const 90cdf0e10cSrcweir { return nRow * mnWidth + nCol; } 91cdf0e10cSrcweir 92cdf0e10cSrcweir const Cell& GetCell( size_t nCol, size_t nRow ) const; 93cdf0e10cSrcweir Cell& GetCellAcc( size_t nCol, size_t nRow ); 94cdf0e10cSrcweir 95cdf0e10cSrcweir size_t GetMergedFirstCol( size_t nCol, size_t nRow ) const; 96cdf0e10cSrcweir size_t GetMergedFirstRow( size_t nCol, size_t nRow ) const; 97cdf0e10cSrcweir size_t GetMergedLastCol( size_t nCol, size_t nRow ) const; 98cdf0e10cSrcweir size_t GetMergedLastRow( size_t nCol, size_t nRow ) const; 99cdf0e10cSrcweir 100cdf0e10cSrcweir const Cell& GetMergedOriginCell( size_t nCol, size_t nRow ) const; 101cdf0e10cSrcweir Cell& GetMergedOriginCellAcc( size_t nCol, size_t nRow ); 102cdf0e10cSrcweir 103cdf0e10cSrcweir bool IsMergedOverlappedLeft( size_t nCol, size_t nRow ) const; 104cdf0e10cSrcweir bool IsMergedOverlappedRight( size_t nCol, size_t nRow ) const; 105cdf0e10cSrcweir bool IsMergedOverlappedTop( size_t nCol, size_t nRow ) const; 106cdf0e10cSrcweir bool IsMergedOverlappedBottom( size_t nCol, size_t nRow ) const; 107cdf0e10cSrcweir 108cdf0e10cSrcweir bool IsInClipRange( size_t nCol, size_t nRow ) const; 109cdf0e10cSrcweir bool IsColInClipRange( size_t nCol ) const; 110cdf0e10cSrcweir bool IsRowInClipRange( size_t nRow ) const; 111cdf0e10cSrcweir GetMirrorColsvx::frame::ArrayImpl112cdf0e10cSrcweir inline size_t GetMirrorCol( size_t nCol ) const { return mnWidth - nCol - 1; } GetMirrorRowsvx::frame::ArrayImpl113cdf0e10cSrcweir inline size_t GetMirrorRow( size_t nRow ) const { return mnHeight - nRow - 1; } 114cdf0e10cSrcweir 115cdf0e10cSrcweir long GetColPosition( size_t nCol ) const; 116cdf0e10cSrcweir long GetRowPosition( size_t nRow ) const; 117cdf0e10cSrcweir 118cdf0e10cSrcweir long GetColWidth( size_t nFirstCol, size_t nLastCol ) const; 119cdf0e10cSrcweir long GetRowHeight( size_t nFirstRow, size_t nLastRow ) const; 120cdf0e10cSrcweir 121cdf0e10cSrcweir double GetHorDiagAngle( size_t nCol, size_t nRow, bool bSimple = false ) const; 122cdf0e10cSrcweir double GetVerDiagAngle( size_t nCol, size_t nRow, bool bSimple = false ) const; 123cdf0e10cSrcweir }; 124cdf0e10cSrcweir 125cdf0e10cSrcweir /** Stores frame styles of an array of cells, supports merged ranges. 126cdf0e10cSrcweir 127cdf0e10cSrcweir This class is able to store the frame styles of an array of cells and to 128cdf0e10cSrcweir draw the entire array or parts of it to any output device. 129cdf0e10cSrcweir 130cdf0e10cSrcweir Every cell contains the style of the left, right, top, bottom, top-left to 131cdf0e10cSrcweir bottom-right, and bottom-left to top-right frame border. 132cdf0e10cSrcweir 133cdf0e10cSrcweir On drawing, the thicker frame border of neighbored cells is selected 134cdf0e10cSrcweir automatically. All borders are drawn "connected", that means, the correct 135cdf0e10cSrcweir start and end coordinates of all lines of the borders are calculated, 136cdf0e10cSrcweir especaially, if they are drawn together with diagonal frame borders. 137cdf0e10cSrcweir 138cdf0e10cSrcweir This array fully supports merged cell ranges. In a merged range, the frame 139cdf0e10cSrcweir borders of the top-left cell is extended to the entire range, and all other 140cdf0e10cSrcweir cells in that range are overlapped. Again, all connected frame borders, 141cdf0e10cSrcweir also diagonals and frame borders from adjacent merged ranges, are handled 142cdf0e10cSrcweir automatically. 143cdf0e10cSrcweir 144cdf0e10cSrcweir Additionally, a clipping range can be set. If such a range is used, all 145cdf0e10cSrcweir frame borders outside this range are completely ignored, and are not used 146cdf0e10cSrcweir in the connected border calculation anymore. 147cdf0e10cSrcweir 148cdf0e10cSrcweir The array can be mirrored in both directions. It is possible to specify, 149cdf0e10cSrcweir whether to mirror the double frame styles, and whether to swap diagonal 150cdf0e10cSrcweir frame borders. 151cdf0e10cSrcweir */ 152cdf0e10cSrcweir class SVX_DLLPUBLIC Array 153cdf0e10cSrcweir { 154cdf0e10cSrcweir public: 155cdf0e10cSrcweir /** Constructs an empty array. */ 156cdf0e10cSrcweir explicit Array(); 157cdf0e10cSrcweir 158cdf0e10cSrcweir /** Constructs an array with the specified width and height. */ 159cdf0e10cSrcweir explicit Array( size_t nWidth, size_t nHeight ); 160cdf0e10cSrcweir 161cdf0e10cSrcweir /** Destructs the array. */ 162cdf0e10cSrcweir ~Array(); 163cdf0e10cSrcweir 164cdf0e10cSrcweir // array size and column/row indexes -------------------------------------- 165cdf0e10cSrcweir 166cdf0e10cSrcweir /** Reinitializes the array with the specified size. Clears all styles. */ 167cdf0e10cSrcweir void Initialize( size_t nWidth, size_t nHeight ); 168cdf0e10cSrcweir 169cdf0e10cSrcweir /** Clears all line styles, column widths, row heights, merge data, and the clip range. */ 170cdf0e10cSrcweir void Clear(); 171cdf0e10cSrcweir 172cdf0e10cSrcweir /** Returns the number of columns in the array. */ 173cdf0e10cSrcweir size_t GetColCount() const; 174cdf0e10cSrcweir 175cdf0e10cSrcweir /** Returns the number of rows in the array. */ 176cdf0e10cSrcweir size_t GetRowCount() const; 177cdf0e10cSrcweir 178cdf0e10cSrcweir /** Returns the number of cells in the array. */ 179cdf0e10cSrcweir size_t GetCellCount() const; 180cdf0e10cSrcweir 181cdf0e10cSrcweir /** Returns the column index of the specified cell index. */ 182cdf0e10cSrcweir size_t GetColFromIndex( size_t nCellIndex ) const; 183cdf0e10cSrcweir 184cdf0e10cSrcweir /** Returns the row index of the specified cell index. */ 185cdf0e10cSrcweir size_t GetRowFromIndex( size_t nCellIndex ) const; 186cdf0e10cSrcweir 187cdf0e10cSrcweir /** Returns the cell index from the cell address (nCol,nRow). */ 188cdf0e10cSrcweir size_t GetCellIndex( size_t nCol, size_t nRow, bool bRTL = false) const; 189cdf0e10cSrcweir 190cdf0e10cSrcweir // cell border styles ----------------------------------------------------- 191cdf0e10cSrcweir 192cdf0e10cSrcweir /** Sets the left frame style of the cell (nCol,nRow). Ignores merged ranges. */ 193cdf0e10cSrcweir void SetCellStyleLeft( size_t nCol, size_t nRow, const Style& rStyle ); 194cdf0e10cSrcweir 195cdf0e10cSrcweir /** Sets the right frame style of the cell (nCol,nRow). Ignores merged ranges. */ 196cdf0e10cSrcweir void SetCellStyleRight( size_t nCol, size_t nRow, const Style& rStyle ); 197cdf0e10cSrcweir 198cdf0e10cSrcweir /** Sets the top frame style of the cell (nCol,nRow). Ignores merged ranges. */ 199cdf0e10cSrcweir void SetCellStyleTop( size_t nCol, size_t nRow, const Style& rStyle ); 200cdf0e10cSrcweir 201cdf0e10cSrcweir /** Sets the bottom frame style of the specified cell (nCol,nRow). Ignores merged ranges. */ 202cdf0e10cSrcweir void SetCellStyleBottom( size_t nCol, size_t nRow, const Style& rStyle ); 203cdf0e10cSrcweir 204cdf0e10cSrcweir /** Sets the top-left to bottom-right frame style of the cell (nCol,nRow). Ignores merged ranges. */ 205cdf0e10cSrcweir void SetCellStyleTLBR( size_t nCol, size_t nRow, const Style& rStyle ); 206cdf0e10cSrcweir 207cdf0e10cSrcweir /** Sets the bottom-left to top-right frame style of the cell (nCol,nRow). Ignores merged ranges. */ 208cdf0e10cSrcweir void SetCellStyleBLTR( size_t nCol, size_t nRow, const Style& rStyle ); 209cdf0e10cSrcweir 210cdf0e10cSrcweir /** Sets both diagonal frame styles of the specified cell (nCol,nRow). Ignores merged ranges. */ 211cdf0e10cSrcweir void SetCellStyleDiag( size_t nCol, size_t nRow, const Style& rTLBR, const Style& rBLTR ); 212cdf0e10cSrcweir 213cdf0e10cSrcweir /** Sets the left frame style of the specified column. Ignores merged ranges. */ 214cdf0e10cSrcweir void SetColumnStyleLeft( size_t nCol, const Style& rStyle ); 215cdf0e10cSrcweir 216cdf0e10cSrcweir /** Sets the right frame style of the specified column. Ignores merged ranges. */ 217cdf0e10cSrcweir void SetColumnStyleRight( size_t nCol, const Style& rStyle ); 218cdf0e10cSrcweir 219cdf0e10cSrcweir /** Sets the top frame style of the specified row. Ignores merged ranges. */ 220cdf0e10cSrcweir void SetRowStyleTop( size_t nRow, const Style& rStyle ); 221cdf0e10cSrcweir 222cdf0e10cSrcweir /** Sets the bottom frame style of the specified row. Ignores merged ranges. */ 223cdf0e10cSrcweir void SetRowStyleBottom( size_t nRow, const Style& rStyle ); 224cdf0e10cSrcweir 225cdf0e10cSrcweir /** Returns the left frame style of the cell (nCol,nRow). 226cdf0e10cSrcweir @param bSimple 227cdf0e10cSrcweir true = Ignores merged ranges and neighbor cells; 228cdf0e10cSrcweir false = Returns thicker of own left style or right style of the cell to the left. 229cdf0e10cSrcweir Returns the style only if visible (i.e. at left border of a merged range). 230cdf0e10cSrcweir @return 231cdf0e10cSrcweir The left frame style or an invisible style for invalid cell addresses. */ 232cdf0e10cSrcweir const Style& GetCellStyleLeft( size_t nCol, size_t nRow, bool bSimple = false ) const; 233cdf0e10cSrcweir 234cdf0e10cSrcweir /** Returns the right frame style of the cell (nCol,nRow). 235cdf0e10cSrcweir @param bSimple 236cdf0e10cSrcweir true = Ignores merged ranges and neighbor cells; 237cdf0e10cSrcweir false = Returns thicker of own right style or left style of the cell to the right. 238cdf0e10cSrcweir Returns the style only if visible (i.e. at right border of a merged range). 239cdf0e10cSrcweir @return 240cdf0e10cSrcweir The left frame style or an invisible style for invalid cell addresses. */ 241cdf0e10cSrcweir const Style& GetCellStyleRight( size_t nCol, size_t nRow, bool bSimple = false ) const; 242cdf0e10cSrcweir 243cdf0e10cSrcweir /** Returns the top frame style of the cell (nCol,nRow). 244cdf0e10cSrcweir @param bSimple 245cdf0e10cSrcweir true = Ignores merged ranges and neighbor cells; 246cdf0e10cSrcweir false = Returns thicker of own top style or bottom style of the cell above. 247cdf0e10cSrcweir Returns the style only if visible (i.e. at top border of a merged range). 248cdf0e10cSrcweir @return 249cdf0e10cSrcweir The top frame style or an invisible style for invalid cell addresses. */ 250cdf0e10cSrcweir const Style& GetCellStyleTop( size_t nCol, size_t nRow, bool bSimple = false ) const; 251cdf0e10cSrcweir 252cdf0e10cSrcweir /** Returns the top frame style of the cell (nCol,nRow). 253cdf0e10cSrcweir @param bSimple 254cdf0e10cSrcweir true = Ignores merged ranges and neighbor cells; 255cdf0e10cSrcweir false = Returns thicker of own top style or bottom style of the cell above. 256cdf0e10cSrcweir Returns the style only if visible (i.e. at top border of a merged range). 257cdf0e10cSrcweir @return 258cdf0e10cSrcweir The top frame style or an invisible style for invalid cell addresses. */ 259cdf0e10cSrcweir const Style& GetCellStyleBottom( size_t nCol, size_t nRow, bool bSimple = false ) const; 260cdf0e10cSrcweir 261cdf0e10cSrcweir /** Returns the top-left to bottom-right frame style of the cell (nCol,nRow). 262cdf0e10cSrcweir @param bSimple 263cdf0e10cSrcweir true = Ignores merged ranges; 264cdf0e10cSrcweir false = Returns the visible style (i.e. from top-left corner of a merged range). 265cdf0e10cSrcweir @return 266cdf0e10cSrcweir The top-left to bottom-right frame style or an invisible style for invalid cell addresses. */ 267cdf0e10cSrcweir const Style& GetCellStyleTLBR( size_t nCol, size_t nRow, bool bSimple = false ) const; 268cdf0e10cSrcweir 269cdf0e10cSrcweir /** Returns the bottom-left to top-right frame style of the cell (nCol,nRow). 270cdf0e10cSrcweir @param bSimple 271cdf0e10cSrcweir true = Ignores merged ranges; 272cdf0e10cSrcweir false = Returns the visible style (i.e. from top-left corner of a merged range). 273cdf0e10cSrcweir @return 274cdf0e10cSrcweir The bottom-left to top-right frame style or an invisible style for invalid cell addresses. */ 275cdf0e10cSrcweir const Style& GetCellStyleBLTR( size_t nCol, size_t nRow, bool bSimple = false ) const; 276cdf0e10cSrcweir 277cdf0e10cSrcweir /** Returns the top-left to bottom-right frame style of the cell (nCol,nRow). 278cdf0e10cSrcweir @return 279cdf0e10cSrcweir The top-left to bottom-right frame style, if the cell is not part of 280cdf0e10cSrcweir a merged range, or if (nCol,nRow) is the top-left corner of a merged 281cdf0e10cSrcweir range (useful to find connected frame styles). 282cdf0e10cSrcweir An invisible style for invalid cell addresses. */ 283cdf0e10cSrcweir const Style& GetCellStyleTL( size_t nCol, size_t nRow ) const; 284cdf0e10cSrcweir 285cdf0e10cSrcweir /** Returns the top-left to bottom-right frame style of the cell (nCol,nRow). 286cdf0e10cSrcweir @return 287cdf0e10cSrcweir The top-left to bottom-right frame style, if the cell is not part of 288cdf0e10cSrcweir a merged range, or if (nCol,nRow) is the bottom-right corner of a 289cdf0e10cSrcweir merged range (useful to find connected frame styles). 290cdf0e10cSrcweir An invisible style for invalid cell addresses. */ 291cdf0e10cSrcweir const Style& GetCellStyleBR( size_t nCol, size_t nRow ) const; 292cdf0e10cSrcweir 293cdf0e10cSrcweir /** Returns the bottom-left to top-right frame style of the cell (nCol,nRow). 294cdf0e10cSrcweir @return 295cdf0e10cSrcweir The bottom-left to top-right frame style, if the cell is not part of 296cdf0e10cSrcweir a merged range, or if (nCol,nRow) is the bottom-left corner of a 297cdf0e10cSrcweir merged range (useful to find connected frame styles). 298cdf0e10cSrcweir An invisible style for invalid cell addresses. */ 299cdf0e10cSrcweir const Style& GetCellStyleBL( size_t nCol, size_t nRow ) const; 300cdf0e10cSrcweir 301cdf0e10cSrcweir /** Returns the bottom-left to top-right frame style of the cell (nCol,nRow). 302cdf0e10cSrcweir @return 303cdf0e10cSrcweir The bottom-left to top-right frame style, if the cell is not part of 304cdf0e10cSrcweir a merged range, or if (nCol,nRow) is the top-right corner of a 305cdf0e10cSrcweir merged range (useful to find connected frame styles). 306cdf0e10cSrcweir An invisible style for invalid cell addresses. */ 307cdf0e10cSrcweir const Style& GetCellStyleTR( size_t nCol, size_t nRow ) const; 308cdf0e10cSrcweir 309cdf0e10cSrcweir // cell merging ----------------------------------------------------------- 310cdf0e10cSrcweir 311cdf0e10cSrcweir /** Inserts a new merged cell range. 312cdf0e10cSrcweir @precond The range must not intersect other merged ranges. */ 313cdf0e10cSrcweir void SetMergedRange( size_t nFirstCol, size_t nFirstRow, size_t nLastCol, size_t nLastRow ); 314cdf0e10cSrcweir 315cdf0e10cSrcweir /** Removes the merged cell range that contains (nCol,nRow). */ 316cdf0e10cSrcweir void RemoveMergedRange( size_t nCol, size_t nRow ); 317cdf0e10cSrcweir 318cdf0e10cSrcweir /** Sets an additional left width for the merged range that contains (nCol,nRow). 319cdf0e10cSrcweir @descr Useful to handle merged ranges that are not completely part of the array. 320cdf0e10cSrcweir @precond The merged range must be at the left border of the array. */ 321cdf0e10cSrcweir void SetAddMergedLeftSize( size_t nCol, size_t nRow, long nAddSize ); 322cdf0e10cSrcweir 323cdf0e10cSrcweir /** Sets an additional right width for the merged range that contains (nCol,nRow). 324cdf0e10cSrcweir @descr Useful to handle merged ranges that are not completely part of the array. 325cdf0e10cSrcweir @precond The merged range must be at the right border of the array. */ 326cdf0e10cSrcweir void SetAddMergedRightSize( size_t nCol, size_t nRow, long nAddSize ); 327cdf0e10cSrcweir 328cdf0e10cSrcweir /** Sets an additional top height for the merged range that contains (nCol,nRow). 329cdf0e10cSrcweir @descr Useful to handle merged ranges that are not completely part of the array. 330cdf0e10cSrcweir @precond The merged range must be at the top border of the array. */ 331cdf0e10cSrcweir void SetAddMergedTopSize( size_t nCol, size_t nRow, long nAddSize ); 332cdf0e10cSrcweir 333cdf0e10cSrcweir /** Sets an additional bottom height for the merged range that contains (nCol,nRow). 334cdf0e10cSrcweir @descr Useful to handle merged ranges that are not completely part of the array. 335cdf0e10cSrcweir @precond The merged range must be at the bottom border of the array. */ 336cdf0e10cSrcweir void SetAddMergedBottomSize( size_t nCol, size_t nRow, long nAddSize ); 337cdf0e10cSrcweir 338cdf0e10cSrcweir /** Returns true, if the cell (nCol,nRow) is part of a merged range. */ 339cdf0e10cSrcweir bool IsMerged( size_t nCol, size_t nRow ) const; 340cdf0e10cSrcweir 341cdf0e10cSrcweir /** Returns true, if the cell (nCol,nRow) is the top-left corner of a merged range. */ 342cdf0e10cSrcweir bool IsMergedOrigin( size_t nCol, size_t nRow ) const; 343cdf0e10cSrcweir 344cdf0e10cSrcweir /** Returns true, if the cell (nCol,nRow) is overlapped by a merged range. */ 345cdf0e10cSrcweir bool IsMergedOverlapped( size_t nCol, size_t nRow ) const; 346cdf0e10cSrcweir 347cdf0e10cSrcweir /** Returns true, if the left border of the cell (nCol,nRow) is overlapped by a merged range. */ 348cdf0e10cSrcweir bool IsMergedOverlappedLeft( size_t nCol, size_t nRow ) const; 349cdf0e10cSrcweir 350cdf0e10cSrcweir /** Returns true, if the right border of the cell (nCol,nRow) is overlapped by a merged range. */ 351cdf0e10cSrcweir bool IsMergedOverlappedRight( size_t nCol, size_t nRow ) const; 352cdf0e10cSrcweir 353cdf0e10cSrcweir /** Returns true, if the top border of the cell (nCol,nRow) is overlapped by a merged range. */ 354cdf0e10cSrcweir bool IsMergedOverlappedTop( size_t nCol, size_t nRow ) const; 355cdf0e10cSrcweir 356cdf0e10cSrcweir /** Returns true, if the bottom border of the cell (nCol,nRow) is overlapped by a merged range. */ 357cdf0e10cSrcweir bool IsMergedOverlappedBottom( size_t nCol, size_t nRow ) const; 358cdf0e10cSrcweir 359cdf0e10cSrcweir /** Returns the address of the top-left cell of the merged range that contains (nCol,nRow). */ 360cdf0e10cSrcweir void GetMergedOrigin( size_t& rnFirstCol, size_t& rnFirstRow, size_t nCol, size_t nRow ) const; 361cdf0e10cSrcweir 362cdf0e10cSrcweir /** Returns the range size of the merged range thst contains (nCol,nRow). */ 363cdf0e10cSrcweir void GetMergedSize( size_t& rnWidth, size_t& rnHeight, size_t nCol, size_t nRow ) const; 364cdf0e10cSrcweir 365cdf0e10cSrcweir /** Returns the top-left and bottom-right address of the merged range that contains (nCol,nRow). */ 366cdf0e10cSrcweir void GetMergedRange( size_t& rnFirstCol, size_t& rnFirstRow, 367cdf0e10cSrcweir size_t& rnLastCol, size_t& rnLastRow, size_t nCol, size_t nRow ) const; 368cdf0e10cSrcweir 369cdf0e10cSrcweir // clipping --------------------------------------------------------------- 370cdf0e10cSrcweir 371cdf0e10cSrcweir /** Sets a clipping range. 372cdf0e10cSrcweir @descr 373cdf0e10cSrcweir No cell borders outside of this clipping range will be drawn. In 374cdf0e10cSrcweir difference to simply using the DrawRange() function with the same 375cdf0e10cSrcweir range, a clipping range causes the drawing functions to completely 376cdf0e10cSrcweir ignore the frame styles connected from outside. This is used i.e. 377cdf0e10cSrcweir in Calc to print single pages and to draw the print preview. 378cdf0e10cSrcweir Partly visible diagonal frame borders in merged ranges are correctly 379cdf0e10cSrcweir clipped too. This array can handle only one clip range at a time. */ 380cdf0e10cSrcweir void SetClipRange( size_t nFirstCol, size_t nFirstRow, size_t nLastCol, size_t nLastRow ); 381cdf0e10cSrcweir 382cdf0e10cSrcweir /** Removes the clipping range set with the SetClipRange() function. */ 383cdf0e10cSrcweir void RemoveClipRange(); 384cdf0e10cSrcweir 385cdf0e10cSrcweir /** Returns true, if the cell (bCol,nRow) is inside the current clip range. */ 386cdf0e10cSrcweir bool IsInClipRange( size_t nCol, size_t nRow ) const; 387cdf0e10cSrcweir 388cdf0e10cSrcweir /** Returns the rectangle (output coordinates) of the current clipping range. */ 389cdf0e10cSrcweir Rectangle GetClipRangeRectangle() const; 390cdf0e10cSrcweir 391cdf0e10cSrcweir // cell coordinates ------------------------------------------------------- 392cdf0e10cSrcweir 393cdf0e10cSrcweir /** Sets the X output coordinate of the left column. */ 394cdf0e10cSrcweir void SetXOffset( long nXOffset ); 395cdf0e10cSrcweir 396cdf0e10cSrcweir /** Sets the Y output coordinate of the top row. */ 397cdf0e10cSrcweir void SetYOffset( long nYOffset ); 398cdf0e10cSrcweir 399cdf0e10cSrcweir /** Sets the output width of the specified column. */ 400cdf0e10cSrcweir void SetColWidth( size_t nCol, long nWidth ); 401cdf0e10cSrcweir 402cdf0e10cSrcweir /** Sets the output height of the specified row. */ 403cdf0e10cSrcweir void SetRowHeight( size_t nRow, long nHeight ); 404cdf0e10cSrcweir 405cdf0e10cSrcweir /** Sets the same output width for all columns. */ 406cdf0e10cSrcweir void SetAllColWidths( long nWidth ); 407cdf0e10cSrcweir 408cdf0e10cSrcweir /** Sets the same output height for all rows. */ 409cdf0e10cSrcweir void SetAllRowHeights( long nHeight ); 410cdf0e10cSrcweir 411cdf0e10cSrcweir /** Returns the X output coordinate of the left border of the specified column. 412cdf0e10cSrcweir @descr The column index <array-width> returns the X output coordinate 413cdf0e10cSrcweir of the right array border. */ 414cdf0e10cSrcweir long GetColPosition( size_t nCol ) const; 415cdf0e10cSrcweir 416cdf0e10cSrcweir /** Returns the Y output coordinate of the top border of the specified row. 417cdf0e10cSrcweir @descr The row index <array-height> returns the Y output coordinate 418cdf0e10cSrcweir of the bottom array border. */ 419cdf0e10cSrcweir long GetRowPosition( size_t nRow ) const; 420cdf0e10cSrcweir 421cdf0e10cSrcweir /** Returns the output width of the specified column. */ 422cdf0e10cSrcweir long GetColWidth( size_t nCol ) const; 423cdf0e10cSrcweir 424cdf0e10cSrcweir /** Returns the output width of the specified range of columns. */ 425cdf0e10cSrcweir long GetColWidth( size_t nFirstCol, size_t nLastCol ) const; 426cdf0e10cSrcweir 427cdf0e10cSrcweir /** Returns the output height of the specified row. */ 428cdf0e10cSrcweir long GetRowHeight( size_t nRow ) const; 429cdf0e10cSrcweir 430cdf0e10cSrcweir /** Returns the output height of the specified range of rows. */ 431cdf0e10cSrcweir long GetRowHeight( size_t nFirstRow, size_t nLastRow ) const; 432cdf0e10cSrcweir 433cdf0e10cSrcweir /** Returns the output width of the entire array. */ 434cdf0e10cSrcweir long GetWidth() const; 435cdf0e10cSrcweir 436cdf0e10cSrcweir /** Returns the output height of the entire array. */ 437cdf0e10cSrcweir long GetHeight() const; 438cdf0e10cSrcweir 439cdf0e10cSrcweir /** Returns the top-left output position of the cell (nCol,nRow). 440cdf0e10cSrcweir @param bSimple 441cdf0e10cSrcweir true = Ignores merged ranges; 442cdf0e10cSrcweir false = Returns output position of top-left corner of merged ranges. */ 443cdf0e10cSrcweir Point GetCellPosition( size_t nCol, size_t nRow, bool bSimple = false ) const; 444cdf0e10cSrcweir 445cdf0e10cSrcweir /** Returns the output size of the cell (nCol,nRow). 446cdf0e10cSrcweir @param bSimple 447cdf0e10cSrcweir true = Ignores merged ranges; 448cdf0e10cSrcweir false = Returns total output size of merged ranges. */ 449cdf0e10cSrcweir Size GetCellSize( size_t nCol, size_t nRow, bool bSimple = false ) const; 450cdf0e10cSrcweir 451cdf0e10cSrcweir /** Returns the output rectangle of the cell (nCol,nRow). 452cdf0e10cSrcweir @param bSimple 453cdf0e10cSrcweir true = Ignores merged ranges; 454cdf0e10cSrcweir false = Returns total output rectangle of merged ranges. */ 455cdf0e10cSrcweir Rectangle GetCellRect( size_t nCol, size_t nRow, bool bSimple = false ) const; 456cdf0e10cSrcweir 457cdf0e10cSrcweir // diagonal frame borders ------------------------------------------------- 458cdf0e10cSrcweir 459cdf0e10cSrcweir /** Returns the angle between horizontal and diagonal border of the cell (nCol,nRow). 460cdf0e10cSrcweir @param bSimple 461cdf0e10cSrcweir true = Ignores merged ranges; 462cdf0e10cSrcweir false = Returns the horizontal angle of merged ranges. */ 463cdf0e10cSrcweir double GetHorDiagAngle( size_t nCol, size_t nRow, bool bSimple = false ) const; 464cdf0e10cSrcweir 465cdf0e10cSrcweir /** Returns the angle between vertical and diagonal border of the cell (nCol,nRow). 466cdf0e10cSrcweir @param bSimple 467cdf0e10cSrcweir true = Ignores merged ranges; 468cdf0e10cSrcweir false = Returns the vertical angle of merged ranges. */ 469cdf0e10cSrcweir double GetVerDiagAngle( size_t nCol, size_t nRow, bool bSimple = false ) const; 470cdf0e10cSrcweir 471cdf0e10cSrcweir /** Specifies whether to use polygon clipping to draw diagonal frame borders. 472cdf0e10cSrcweir @descr 473cdf0e10cSrcweir If enabled, diagonal frame borders are drawn interrupted, if they are 474cdf0e10cSrcweir crossed by a double frame border. Polygon clipping is very expensive 475cdf0e10cSrcweir and should only be used for very small output devices (i.e. in the 476cdf0e10cSrcweir Border tab page). Default after construction is OFF. */ 477cdf0e10cSrcweir void SetUseDiagDoubleClipping( bool bSet ); 478cdf0e10cSrcweir 479cdf0e10cSrcweir /** Returns true, if polygon clipping is used to draw diagonal frame borders. */ 480cdf0e10cSrcweir bool GetUseDiagDoubleClipping() const; 481cdf0e10cSrcweir 482cdf0e10cSrcweir // mirroring -------------------------------------------------------------- 483cdf0e10cSrcweir 484cdf0e10cSrcweir /** Mirrors the entire array horizontally. 485cdf0e10cSrcweir @param bMirrorStyles 486cdf0e10cSrcweir true = Swap primary and secondary line of all vertical double frame borders. 487cdf0e10cSrcweir @param bSwapDiag 488cdf0e10cSrcweir true = Swap top-left to bottom-right and bottom-left to top-right frame borders. */ 489cdf0e10cSrcweir void MirrorSelfX( bool bMirrorStyles, bool bSwapDiag ); 490cdf0e10cSrcweir 491cdf0e10cSrcweir /** Mirrors the entire array vertically. 492cdf0e10cSrcweir @param bMirrorStyles 493cdf0e10cSrcweir true = Swap primary and secondary line of all horizontal double frame borders. 494cdf0e10cSrcweir @param bSwapDiag 495cdf0e10cSrcweir true = Swap top-left to bottom-right and bottom-left to top-right frame borders. */ 496cdf0e10cSrcweir void MirrorSelfY( bool bMirrorStyles, bool bSwapDiag ); 497cdf0e10cSrcweir 498cdf0e10cSrcweir // drawing ---------------------------------------------------------------- 499cdf0e10cSrcweir 500cdf0e10cSrcweir /** Draws the cell (nCol,nRow), if it is inside the clipping range. 501cdf0e10cSrcweir @param pForceColor 502cdf0e10cSrcweir If not NULL, only this color will be used to draw all frame borders. */ 503cdf0e10cSrcweir void DrawCell( OutputDevice& rDev, size_t nCol, size_t nRow, 504cdf0e10cSrcweir const Color* pForceColor = 0 ) const; 505cdf0e10cSrcweir 506cdf0e10cSrcweir /** Draws the part of the specified range, that is inside the clipping range. 507cdf0e10cSrcweir @param pForceColor 508cdf0e10cSrcweir If not NULL, only this color will be used to draw all frame borders. */ 509cdf0e10cSrcweir void DrawRange( OutputDevice& rDev, 510cdf0e10cSrcweir size_t nFirstCol, size_t nFirstRow, 511cdf0e10cSrcweir size_t nLastCol, size_t nLastRow, 512cdf0e10cSrcweir const Color* pForceColor = 0 ) const; 513cdf0e10cSrcweir 514cdf0e10cSrcweir /** Draws the part of the array, that is inside the clipping range. 515cdf0e10cSrcweir @param pForceColor 516cdf0e10cSrcweir If not NULL, only this color will be used to draw all frame borders. */ 517cdf0e10cSrcweir void DrawArray( OutputDevice& rDev, const Color* pForceColor = 0 ) const; 518cdf0e10cSrcweir 519cdf0e10cSrcweir // ------------------------------------------------------------------------ 520cdf0e10cSrcweir 521cdf0e10cSrcweir private: 522cdf0e10cSrcweir typedef std::auto_ptr< ArrayImpl > ArrayImplPtr; 523cdf0e10cSrcweir 524cdf0e10cSrcweir ArrayImplPtr mxImpl; 525cdf0e10cSrcweir }; 526cdf0e10cSrcweir 527cdf0e10cSrcweir // ============================================================================ 528cdf0e10cSrcweir 529cdf0e10cSrcweir } // namespace frame 530cdf0e10cSrcweir } // namespace svx 531cdf0e10cSrcweir 532cdf0e10cSrcweir #endif 533cdf0e10cSrcweir 534