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