1*1d2dbeb0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*1d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*1d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*1d2dbeb0SAndrew Rist * distributed with this work for additional information 6*1d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*1d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*1d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance 9*1d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at 10*1d2dbeb0SAndrew Rist * 11*1d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*1d2dbeb0SAndrew Rist * 13*1d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*1d2dbeb0SAndrew Rist * software distributed under the License is distributed on an 15*1d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the 17*1d2dbeb0SAndrew Rist * specific language governing permissions and limitations 18*1d2dbeb0SAndrew Rist * under the License. 19*1d2dbeb0SAndrew Rist * 20*1d2dbeb0SAndrew Rist *************************************************************/ 21*1d2dbeb0SAndrew Rist 22*1d2dbeb0SAndrew Rist 23cdf0e10cSrcweir #ifndef _TBLSEL_HXX 24cdf0e10cSrcweir #define _TBLSEL_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <svl/svarray.hxx> 27cdf0e10cSrcweir #include <swtable.hxx> 28cdf0e10cSrcweir #include <swrect.hxx> 29cdf0e10cSrcweir #include "swdllapi.h" 30cdf0e10cSrcweir 31cdf0e10cSrcweir class SwCrsrShell; 32cdf0e10cSrcweir class SwCursor; 33cdf0e10cSrcweir class SwTableCursor; 34cdf0e10cSrcweir class SwFrm; 35cdf0e10cSrcweir class SwTabFrm; 36cdf0e10cSrcweir class SwTableBox; 37cdf0e10cSrcweir class SwTableLine; 38cdf0e10cSrcweir class SwLayoutFrm; 39cdf0e10cSrcweir class SwPaM; 40cdf0e10cSrcweir class SwNode; 41cdf0e10cSrcweir class SwTable; 42cdf0e10cSrcweir class SwUndoTblMerge; 43cdf0e10cSrcweir class SwCellFrm; 44cdf0e10cSrcweir 45cdf0e10cSrcweir SV_DECL_PTRARR( SwCellFrms, SwCellFrm*, 16, 16 ) 46cdf0e10cSrcweir SV_DECL_PTRARR_SORT( SwSelBoxes, SwTableBoxPtr, 10, 20 ) 47cdf0e10cSrcweir 48cdf0e10cSrcweir 49cdf0e10cSrcweir //Sucht alle Boxen zusammen, die in der Tabelle selektiert sind. 50cdf0e10cSrcweir //Je nach enum-Parameter wird die Selektion in der angegebenen Richtung 51cdf0e10cSrcweir //erweitert. 52cdf0e10cSrcweir //Die Boxen werden ueber das Layout zusammengsucht, es wird auch bei 53cdf0e10cSrcweir //aufgespaltenen Tabellen korrekt gearbeitet (siehe: MakeSelUnions()). 54cdf0e10cSrcweir typedef sal_uInt16 SwTblSearchType; 55cdf0e10cSrcweir namespace nsSwTblSearchType 56cdf0e10cSrcweir { 57cdf0e10cSrcweir const SwTblSearchType TBLSEARCH_NONE = 0x1; // keine Erweiterung 58cdf0e10cSrcweir const SwTblSearchType TBLSEARCH_ROW = 0x2; // erweiter auf Zeilen 59cdf0e10cSrcweir const SwTblSearchType TBLSEARCH_COL = 0x3; // erweiter auf Spalten 60cdf0e10cSrcweir 61cdf0e10cSrcweir // als Flag zu den anderen Werten!! 62cdf0e10cSrcweir const SwTblSearchType TBLSEARCH_PROTECT = 0x8; // auch geschuetzte Boxen einsammeln 63cdf0e10cSrcweir const SwTblSearchType TBLSEARCH_NO_UNION_CORRECT = 0x10; // die zusammenges. Union nicht korrigieren 64cdf0e10cSrcweir } 65cdf0e10cSrcweir 66cdf0e10cSrcweir SW_DLLPUBLIC void GetTblSel( const SwCrsrShell& rShell, SwSelBoxes& rBoxes, 67cdf0e10cSrcweir const SwTblSearchType = nsSwTblSearchType::TBLSEARCH_NONE ); 68cdf0e10cSrcweir 69cdf0e10cSrcweir void GetTblSel( const SwCursor& rCrsr, SwSelBoxes& rBoxes, 70cdf0e10cSrcweir const SwTblSearchType = nsSwTblSearchType::TBLSEARCH_NONE ); 71cdf0e10cSrcweir 72cdf0e10cSrcweir //wie vor, jedoch wird nicht von der Selektion sondern von den 73cdf0e10cSrcweir //Start- EndFrms ausgegangen. 74cdf0e10cSrcweir void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd, 75cdf0e10cSrcweir SwSelBoxes& rBoxes, SwCellFrms* pCells, 76cdf0e10cSrcweir const SwTblSearchType = nsSwTblSearchType::TBLSEARCH_NONE ); 77cdf0e10cSrcweir 78cdf0e10cSrcweir // Desgleichen nocheinmal direkt per PaM's 79cdf0e10cSrcweir void GetTblSelCrs( const SwCrsrShell& rShell, SwSelBoxes& rBoxes ); 80cdf0e10cSrcweir void GetTblSelCrs( const SwTableCursor& rTblCrsr, SwSelBoxes& rBoxes ); 81cdf0e10cSrcweir 82cdf0e10cSrcweir // suche fuer eine AutoSumme die beteiligten Boxen zusammen 83cdf0e10cSrcweir sal_Bool GetAutoSumSel( const SwCrsrShell&, SwCellFrms& ); 84cdf0e10cSrcweir 85cdf0e10cSrcweir // check if the SelBoxes contains protected Boxes 86cdf0e10cSrcweir sal_Bool HasProtectedCells( const SwSelBoxes& rBoxes ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir // teste, ob die Selektion ausgeglichen ist 89cdf0e10cSrcweir SV_DECL_PTRARR( SwChartBoxes, SwTableBoxPtr, 16, 16) 90cdf0e10cSrcweir SV_DECL_PTRARR_DEL( SwChartLines, SwChartBoxes*, 25, 50) 91cdf0e10cSrcweir 92cdf0e10cSrcweir sal_Bool ChkChartSel( const SwNode& rSttNd, const SwNode& rEndNd, 93cdf0e10cSrcweir SwChartLines* pGetCLines = 0 ); 94cdf0e10cSrcweir 95cdf0e10cSrcweir // teste ob die Celle in die SSelection gehoert 96cdf0e10cSrcweir // (wurde eine Funktion, damit GetTblSel() und MakeTblCrsr() immer 97cdf0e10cSrcweir // das "gleiche Verstaendnis" fuer die Selektion haben) 98cdf0e10cSrcweir sal_Bool IsFrmInTblSel( const SwRect& rUnion, const SwFrm* pCell ); 99cdf0e10cSrcweir 100cdf0e10cSrcweir // bestimme die Boxen, die zusammen gefasst werden sollen. 101cdf0e10cSrcweir // Dabei wird auf Layout Basis das Rechteck "angepasst". D.H. es 102cdf0e10cSrcweir // werden Boxen zugefuegt wenn welche an den Seiten ueberlappen 103cdf0e10cSrcweir // Zusaetzlich wird die neue Box erzeugt und mit dem entsprechenden 104cdf0e10cSrcweir // Inhalt gefuellt. 105cdf0e10cSrcweir void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, 106cdf0e10cSrcweir SwTableBox** ppMergeBox, SwUndoTblMerge* pUndo = 0 ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir // teste ob die selektierten Boxen ein gueltiges Merge erlauben 109cdf0e10cSrcweir sal_uInt16 CheckMergeSel( const SwPaM& rPam ); 110cdf0e10cSrcweir sal_uInt16 CheckMergeSel( const SwSelBoxes& rBoxes ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir sal_Bool IsEmptyBox( const SwTableBox& rBox, SwPaM& rPam ); 113cdf0e10cSrcweir 114cdf0e10cSrcweir // teste ob ein Split oder InsertCol dazu fuehrt, das eine Box 115cdf0e10cSrcweir // kleiner als MINLAY wird. 116cdf0e10cSrcweir sal_Bool CheckSplitCells( const SwCrsrShell& rShell, sal_uInt16 nDiv, 117cdf0e10cSrcweir const SwTblSearchType = nsSwTblSearchType::TBLSEARCH_NONE ); 118cdf0e10cSrcweir sal_Bool CheckSplitCells( const SwCursor& rCrsr, sal_uInt16 nDiv, 119cdf0e10cSrcweir const SwTblSearchType = nsSwTblSearchType::TBLSEARCH_NONE ); 120cdf0e10cSrcweir 121cdf0e10cSrcweir //Fuer das Arbeiten auf TabSelektion auch fuer aufgespaltene Tabellen. 122cdf0e10cSrcweir class SwSelUnion 123cdf0e10cSrcweir { 124cdf0e10cSrcweir SwRect aUnion; //Das die Sel umschliessende Rechteck. 125cdf0e10cSrcweir SwTabFrm *pTable; //Die (Follow-)Table zu der Union. 126cdf0e10cSrcweir 127cdf0e10cSrcweir public: 128cdf0e10cSrcweir SwSelUnion( const SwRect &rRect, SwTabFrm *pTab ) : 129cdf0e10cSrcweir aUnion( rRect ), pTable( pTab ) {} 130cdf0e10cSrcweir 131cdf0e10cSrcweir const SwRect& GetUnion() const { return aUnion; } 132cdf0e10cSrcweir SwRect& GetUnion() { return aUnion; } 133cdf0e10cSrcweir const SwTabFrm *GetTable() const { return pTable; } 134cdf0e10cSrcweir SwTabFrm *GetTable() { return pTable; } 135cdf0e10cSrcweir }; 136cdf0e10cSrcweir 137cdf0e10cSrcweir SV_DECL_PTRARR_DEL( SwSelUnions, SwSelUnion*, 10, 20 ) 138cdf0e10cSrcweir 139cdf0e10cSrcweir //Ermittelt die von einer Tabellenselektion betroffenen Tabellen und die 140cdf0e10cSrcweir //Union-Rechteckte der Selektionen - auch fuer aufgespaltene Tabellen. 141cdf0e10cSrcweir //Wenn ein Parameter != nsSwTblSearchType::TBLSEARCH_NONE uebergeben wird, so wird die 142cdf0e10cSrcweir //Selektion in der angegebenen Richtung erweitert. 143cdf0e10cSrcweir void MakeSelUnions( SwSelUnions&, const SwLayoutFrm *pStart, 144cdf0e10cSrcweir const SwLayoutFrm *pEnd, 145cdf0e10cSrcweir const SwTblSearchType = nsSwTblSearchType::TBLSEARCH_NONE ); 146cdf0e10cSrcweir 147cdf0e10cSrcweir 148cdf0e10cSrcweir // ------------------------------------------------------------------- 149cdf0e10cSrcweir // Diese Klassen kopieren die aktuelle Tabellen-Selektion (rBoxes) 150cdf0e10cSrcweir // unter Beibehaltung der Tabellen-Strubktur in eine eigene Struktur 151cdf0e10cSrcweir 152cdf0e10cSrcweir class _FndBox; 153cdf0e10cSrcweir class _FndLine; 154cdf0e10cSrcweir 155cdf0e10cSrcweir SV_DECL_PTRARR_DEL( _FndBoxes, _FndBox*, 10, 20 ) 156cdf0e10cSrcweir SV_DECL_PTRARR_DEL( _FndLines, _FndLine*,10, 20 ) 157cdf0e10cSrcweir 158cdf0e10cSrcweir class _FndBox 159cdf0e10cSrcweir { 160cdf0e10cSrcweir SwTableBox* pBox; 161cdf0e10cSrcweir _FndLines aLines; 162cdf0e10cSrcweir _FndLine* pUpper; 163cdf0e10cSrcweir 164cdf0e10cSrcweir SwTableLine *pLineBefore; //Zum Loeschen/Restaurieren des Layouts. 165cdf0e10cSrcweir SwTableLine *pLineBehind; 166cdf0e10cSrcweir 167cdf0e10cSrcweir public: 168cdf0e10cSrcweir _FndBox( SwTableBox* pB, _FndLine* pFL ) : 169cdf0e10cSrcweir pBox(pB), pUpper(pFL), pLineBefore( 0 ), pLineBehind( 0 ) {} 170cdf0e10cSrcweir 171cdf0e10cSrcweir const _FndLines& GetLines() const { return aLines; } 172cdf0e10cSrcweir _FndLines& GetLines() { return aLines; } 173cdf0e10cSrcweir const SwTableBox* GetBox() const { return pBox; } 174cdf0e10cSrcweir SwTableBox* GetBox() { return pBox; } 175cdf0e10cSrcweir const _FndLine* GetUpper() const { return pUpper; } 176cdf0e10cSrcweir _FndLine* GetUpper() { return pUpper; } 177cdf0e10cSrcweir 178cdf0e10cSrcweir void SetTableLines( const SwSelBoxes &rBoxes, const SwTable &rTable ); 179cdf0e10cSrcweir void SetTableLines( const SwTable &rTable ); 180cdf0e10cSrcweir void DelFrms ( SwTable &rTable ); 181cdf0e10cSrcweir void MakeFrms( SwTable &rTable ); 182cdf0e10cSrcweir void MakeNewFrms( SwTable &rTable, const sal_uInt16 nNumber, 183cdf0e10cSrcweir const sal_Bool bBehind ); 184cdf0e10cSrcweir sal_Bool AreLinesToRestore( const SwTable &rTable ) const; 185cdf0e10cSrcweir 186cdf0e10cSrcweir void ClearLineBehind() { pLineBehind = 0; } 187cdf0e10cSrcweir }; 188cdf0e10cSrcweir 189cdf0e10cSrcweir 190cdf0e10cSrcweir class _FndLine 191cdf0e10cSrcweir { 192cdf0e10cSrcweir SwTableLine* pLine; 193cdf0e10cSrcweir _FndBoxes aBoxes; 194cdf0e10cSrcweir _FndBox* pUpper; 195cdf0e10cSrcweir public: 196cdf0e10cSrcweir _FndLine(SwTableLine* pL, _FndBox* pFB=0) : pLine(pL), pUpper(pFB) {} 197cdf0e10cSrcweir const _FndBoxes& GetBoxes() const { return aBoxes; } 198cdf0e10cSrcweir _FndBoxes& GetBoxes() { return aBoxes; } 199cdf0e10cSrcweir const SwTableLine* GetLine() const { return pLine; } 200cdf0e10cSrcweir SwTableLine* GetLine() { return pLine; } 201cdf0e10cSrcweir const _FndBox* GetUpper() const { return pUpper; } 202cdf0e10cSrcweir _FndBox* GetUpper() { return pUpper; } 203cdf0e10cSrcweir 204cdf0e10cSrcweir void SetUpper( _FndBox* pUp ) { pUpper = pUp; } 205cdf0e10cSrcweir }; 206cdf0e10cSrcweir 207cdf0e10cSrcweir 208cdf0e10cSrcweir struct _FndPara 209cdf0e10cSrcweir { 210cdf0e10cSrcweir const SwSelBoxes& rBoxes; 211cdf0e10cSrcweir _FndLine* pFndLine; 212cdf0e10cSrcweir _FndBox* pFndBox; 213cdf0e10cSrcweir 214cdf0e10cSrcweir _FndPara( const SwSelBoxes& rBxs, _FndBox* pFB ) 215cdf0e10cSrcweir : rBoxes(rBxs), pFndLine(0), pFndBox(pFB) {} 216cdf0e10cSrcweir _FndPara( const _FndPara& rPara, _FndBox* pFB ) 217cdf0e10cSrcweir : rBoxes(rPara.rBoxes), pFndLine(rPara.pFndLine), pFndBox(pFB) {} 218cdf0e10cSrcweir _FndPara( const _FndPara& rPara, _FndLine* pFL ) 219cdf0e10cSrcweir : rBoxes(rPara.rBoxes), pFndLine(pFL), pFndBox(rPara.pFndBox) {} 220cdf0e10cSrcweir }; 221cdf0e10cSrcweir 222cdf0e10cSrcweir sal_Bool _FndBoxCopyCol( const SwTableBox*& rpBox, void* pPara ); 223cdf0e10cSrcweir SW_DLLPUBLIC sal_Bool _FndLineCopyCol( const SwTableLine*& rpLine, void* pPara ); 224cdf0e10cSrcweir 225cdf0e10cSrcweir 226cdf0e10cSrcweir #endif // _TBLSEL_HXX 227