1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <tools/errinf.hxx>
31cdf0e10cSrcweir #include <vcl/svapp.hxx>
32cdf0e10cSrcweir #include <basegfx/vector/b2dvector.hxx>
33cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC
34cdf0e10cSrcweir #include <svx/svxids.hrc>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include <editeng/protitem.hxx>
37cdf0e10cSrcweir #include <editeng/brshitem.hxx>
38cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
39cdf0e10cSrcweir #include <svtools/ruler.hxx>
40cdf0e10cSrcweir #include <swwait.hxx>
41cdf0e10cSrcweir #include <fmtfsize.hxx>
42cdf0e10cSrcweir #include <fmtornt.hxx>
43cdf0e10cSrcweir #include <frmatr.hxx>
44cdf0e10cSrcweir #include <docary.hxx>
45cdf0e10cSrcweir #include <fesh.hxx>
46cdf0e10cSrcweir #include <doc.hxx>
47cdf0e10cSrcweir #include <cntfrm.hxx>
48cdf0e10cSrcweir #include <rootfrm.hxx>
49cdf0e10cSrcweir #include <pagefrm.hxx>
50cdf0e10cSrcweir #include <tabfrm.hxx>
51cdf0e10cSrcweir #include <rowfrm.hxx>
52cdf0e10cSrcweir #include <cellfrm.hxx>
53cdf0e10cSrcweir #include <flyfrm.hxx>
54cdf0e10cSrcweir #include <dflyobj.hxx>
55cdf0e10cSrcweir #include <swtable.hxx>
56cdf0e10cSrcweir #include <swddetbl.hxx>
57cdf0e10cSrcweir #include <ndtxt.hxx>
58cdf0e10cSrcweir #include <calc.hxx>
59cdf0e10cSrcweir #include <tabcol.hxx>
60cdf0e10cSrcweir #include <cellatr.hxx>
61cdf0e10cSrcweir #include <pam.hxx>
62cdf0e10cSrcweir #include <viscrs.hxx>
63cdf0e10cSrcweir #include <tblsel.hxx>
64cdf0e10cSrcweir #include <swtblfmt.hxx>
65cdf0e10cSrcweir #include <swerror.h>
66cdf0e10cSrcweir #include <swundo.hxx>
67cdf0e10cSrcweir #include <frmtool.hxx>
68cdf0e10cSrcweir
69cdf0e10cSrcweir #include <node.hxx> // #i23726#
70cdf0e10cSrcweir // OD 2004-05-24 #i28701#
71cdf0e10cSrcweir #include <sortedobjs.hxx>
72cdf0e10cSrcweir
73cdf0e10cSrcweir using namespace ::com::sun::star;
74cdf0e10cSrcweir
75cdf0e10cSrcweir
76cdf0e10cSrcweir //siehe auch swtable.cxx
77cdf0e10cSrcweir #define COLFUZZY 20L
78cdf0e10cSrcweir
IsSame(long nA,long nB)79cdf0e10cSrcweir inline sal_Bool IsSame( long nA, long nB ) { return Abs(nA-nB) <= COLFUZZY; }
IsNear(long nA,long nB,long nTolerance)80cdf0e10cSrcweir inline sal_Bool IsNear( long nA, long nB, long nTolerance ) { return Abs( nA - nB ) <= nTolerance; }
81cdf0e10cSrcweir
82cdf0e10cSrcweir // table column cache
83cdf0e10cSrcweir SwTabCols *pLastCols = 0;
84cdf0e10cSrcweir const SwTable *pColumnCacheLastTable = 0;
85cdf0e10cSrcweir const SwTabFrm *pColumnCacheLastTabFrm = 0;
86cdf0e10cSrcweir const SwFrm *pColumnCacheLastCellFrm = 0;
87cdf0e10cSrcweir
88cdf0e10cSrcweir // table row cache
89cdf0e10cSrcweir SwTabCols *pLastRows = 0;
90cdf0e10cSrcweir const SwTable *pRowCacheLastTable = 0;
91cdf0e10cSrcweir const SwTabFrm *pRowCacheLastTabFrm = 0;
92cdf0e10cSrcweir const SwFrm *pRowCacheLastCellFrm = 0;
93cdf0e10cSrcweir
94cdf0e10cSrcweir
95cdf0e10cSrcweir class TblWait
96cdf0e10cSrcweir {
97cdf0e10cSrcweir SwWait *pWait;
98cdf0e10cSrcweir public:
99cdf0e10cSrcweir TblWait( sal_uInt16 nCnt, SwFrm *pFrm, SwDocShell &rDocShell, sal_uInt16 nCnt2 = 0);
~TblWait()100cdf0e10cSrcweir ~TblWait() { delete pWait; }
101cdf0e10cSrcweir };
102cdf0e10cSrcweir
TblWait(sal_uInt16 nCnt,SwFrm * pFrm,SwDocShell & rDocShell,sal_uInt16 nCnt2)103cdf0e10cSrcweir TblWait::TblWait( sal_uInt16 nCnt, SwFrm *pFrm, SwDocShell &rDocShell, sal_uInt16 nCnt2):
104cdf0e10cSrcweir pWait( 0 )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir sal_Bool bWait = 20 < nCnt || 20 < nCnt2 || (pFrm &&
107cdf0e10cSrcweir 20 < pFrm->ImplFindTabFrm()->GetTable()->GetTabLines().Count());
108cdf0e10cSrcweir if( bWait )
109*8ef2f12bSOliver-Rainer Wittmann pWait = new SwWait( rDocShell, true );
110cdf0e10cSrcweir }
111cdf0e10cSrcweir
112cdf0e10cSrcweir
ParkCursorInTab()113cdf0e10cSrcweir void SwFEShell::ParkCursorInTab()
114cdf0e10cSrcweir {
115cdf0e10cSrcweir SwCursor * pSwCrsr = GetSwCrsr();
116cdf0e10cSrcweir
117cdf0e10cSrcweir ASSERT(pSwCrsr, "no SwCursor");
118cdf0e10cSrcweir
119cdf0e10cSrcweir SwPosition aStartPos = *pSwCrsr->GetPoint(), aEndPos = aStartPos;
120cdf0e10cSrcweir
121cdf0e10cSrcweir SwCursor * pTmpCrsr = (SwCursor *) pSwCrsr;
122cdf0e10cSrcweir
123cdf0e10cSrcweir /* Search least and greatest position in current cursor ring.
124cdf0e10cSrcweir */
125cdf0e10cSrcweir do
126cdf0e10cSrcweir {
127cdf0e10cSrcweir const SwPosition * pPt = pTmpCrsr->GetPoint(),
128cdf0e10cSrcweir * pMk = pTmpCrsr->GetMark();
129cdf0e10cSrcweir
130cdf0e10cSrcweir if (*pPt < aStartPos)
131cdf0e10cSrcweir aStartPos = *pPt;
132cdf0e10cSrcweir
133cdf0e10cSrcweir if (*pPt > aEndPos)
134cdf0e10cSrcweir aEndPos = *pPt;
135cdf0e10cSrcweir
136cdf0e10cSrcweir if (*pMk < aStartPos)
137cdf0e10cSrcweir aStartPos = *pMk;
138cdf0e10cSrcweir
139cdf0e10cSrcweir if (*pMk > aEndPos)
140cdf0e10cSrcweir aEndPos = *pMk;
141cdf0e10cSrcweir
142cdf0e10cSrcweir pTmpCrsr = (SwCursor *) pTmpCrsr->GetNext();
143cdf0e10cSrcweir }
144cdf0e10cSrcweir while (pTmpCrsr != pSwCrsr);
145cdf0e10cSrcweir
146cdf0e10cSrcweir KillPams();
147cdf0e10cSrcweir
148cdf0e10cSrcweir /* @@@ semantic: SwCursor::operator=() is not implemented @@@ */
149cdf0e10cSrcweir
150cdf0e10cSrcweir /* Set cursor to end of selection to ensure IsLastCellInRow works
151cdf0e10cSrcweir properly. */
152cdf0e10cSrcweir {
153cdf0e10cSrcweir SwCursor aTmpCrsr( aEndPos, 0, false );
154cdf0e10cSrcweir *pSwCrsr = aTmpCrsr;
155cdf0e10cSrcweir }
156cdf0e10cSrcweir
157cdf0e10cSrcweir /* Move the cursor out of the columns to delete and stay in the
158cdf0e10cSrcweir same row. If the table has only one column the cursor will
159cdf0e10cSrcweir stay in the row and the shell will take care of it. */
160cdf0e10cSrcweir if (IsLastCellInRow())
161cdf0e10cSrcweir {
162cdf0e10cSrcweir /* If the cursor is in the last row of the table, first
163cdf0e10cSrcweir try to move it to the previous cell. If that fails move
164cdf0e10cSrcweir it to the next cell. */
165cdf0e10cSrcweir
166cdf0e10cSrcweir {
167cdf0e10cSrcweir SwCursor aTmpCrsr( aStartPos, 0, false );
168cdf0e10cSrcweir *pSwCrsr = aTmpCrsr;
169cdf0e10cSrcweir }
170cdf0e10cSrcweir
171cdf0e10cSrcweir if (! pSwCrsr->GoPrevCell())
172cdf0e10cSrcweir {
173cdf0e10cSrcweir SwCursor aTmpCrsr( aEndPos, 0, false );
174cdf0e10cSrcweir *pSwCrsr = aTmpCrsr;
175cdf0e10cSrcweir pSwCrsr->GoNextCell();
176cdf0e10cSrcweir }
177cdf0e10cSrcweir }
178cdf0e10cSrcweir else
179cdf0e10cSrcweir {
180cdf0e10cSrcweir /* If the cursor is not in the last row of the table, first
181cdf0e10cSrcweir try to move it to the next cell. If that fails move it
182cdf0e10cSrcweir to the previous cell. */
183cdf0e10cSrcweir
184cdf0e10cSrcweir {
185cdf0e10cSrcweir SwCursor aTmpCrsr( aEndPos, 0, false );
186cdf0e10cSrcweir *pSwCrsr = aTmpCrsr;
187cdf0e10cSrcweir }
188cdf0e10cSrcweir
189cdf0e10cSrcweir if (! pSwCrsr->GoNextCell())
190cdf0e10cSrcweir {
191cdf0e10cSrcweir SwCursor aTmpCrsr( aStartPos, 0, false );
192cdf0e10cSrcweir *pSwCrsr = aTmpCrsr;
193cdf0e10cSrcweir pSwCrsr->GoPrevCell();
194cdf0e10cSrcweir }
195cdf0e10cSrcweir }
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir /***********************************************************************
199cdf0e10cSrcweir #* Class : SwFEShell
200cdf0e10cSrcweir #* Methoden : InsertRow(), InsertCol
201cdf0e10cSrcweir #* Datum : MA 03. May. 93
202cdf0e10cSrcweir #* Update : MA 19. Apr. 95
203cdf0e10cSrcweir #***********************************************************************/
InsertRow(sal_uInt16 nCnt,sal_Bool bBehind)204cdf0e10cSrcweir sal_Bool SwFEShell::InsertRow( sal_uInt16 nCnt, sal_Bool bBehind )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir // pruefe ob vom aktuellen Crsr der Point/Mark in einer Tabelle stehen
207cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
208cdf0e10cSrcweir if( !pFrm || !pFrm->IsInTab() )
209cdf0e10cSrcweir return sal_False;
210cdf0e10cSrcweir
211cdf0e10cSrcweir if( pFrm->ImplFindTabFrm()->GetTable()->ISA( SwDDETable ))
212cdf0e10cSrcweir {
213cdf0e10cSrcweir ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
214cdf0e10cSrcweir ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
215cdf0e10cSrcweir return sal_False;
216cdf0e10cSrcweir }
217cdf0e10cSrcweir
218cdf0e10cSrcweir SET_CURR_SHELL( this );
219cdf0e10cSrcweir StartAllAction();
220cdf0e10cSrcweir
221cdf0e10cSrcweir // lasse ueber das Layout die Boxen suchen
222cdf0e10cSrcweir SwSelBoxes aBoxes;
223cdf0e10cSrcweir GetTblSel( *this, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW );
224cdf0e10cSrcweir
225cdf0e10cSrcweir TblWait( nCnt, pFrm, *GetDoc()->GetDocShell(), aBoxes.Count() );
226cdf0e10cSrcweir
227cdf0e10cSrcweir sal_Bool bRet = sal_False;
228cdf0e10cSrcweir if ( aBoxes.Count() )
229cdf0e10cSrcweir bRet = GetDoc()->InsertRow( aBoxes, nCnt, bBehind );
230cdf0e10cSrcweir
231cdf0e10cSrcweir EndAllActionAndCall();
232cdf0e10cSrcweir return bRet;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
InsertCol(sal_uInt16 nCnt,sal_Bool bBehind)235cdf0e10cSrcweir sal_Bool SwFEShell::InsertCol( sal_uInt16 nCnt, sal_Bool bBehind )
236cdf0e10cSrcweir {
237cdf0e10cSrcweir // pruefe ob vom aktuellen Crsr der Point/Mark in einer Tabelle stehen
238cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
239cdf0e10cSrcweir if( !pFrm || !pFrm->IsInTab() )
240cdf0e10cSrcweir return sal_False;
241cdf0e10cSrcweir
242cdf0e10cSrcweir if( pFrm->ImplFindTabFrm()->GetTable()->ISA( SwDDETable ))
243cdf0e10cSrcweir {
244cdf0e10cSrcweir ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
245cdf0e10cSrcweir ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
246cdf0e10cSrcweir return sal_False;
247cdf0e10cSrcweir }
248cdf0e10cSrcweir
249cdf0e10cSrcweir SET_CURR_SHELL( this );
250cdf0e10cSrcweir
251cdf0e10cSrcweir if( !CheckSplitCells( *this, nCnt + 1, nsSwTblSearchType::TBLSEARCH_COL ) )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir ErrorHandler::HandleError( ERR_TBLINSCOL_ERROR,
254cdf0e10cSrcweir ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
255cdf0e10cSrcweir return sal_False;
256cdf0e10cSrcweir }
257cdf0e10cSrcweir
258cdf0e10cSrcweir StartAllAction();
259cdf0e10cSrcweir // lasse ueber das Layout die Boxen suchen
260cdf0e10cSrcweir SwSelBoxes aBoxes;
261cdf0e10cSrcweir GetTblSel( *this, aBoxes, nsSwTblSearchType::TBLSEARCH_COL );
262cdf0e10cSrcweir
263cdf0e10cSrcweir TblWait( nCnt, pFrm, *GetDoc()->GetDocShell(), aBoxes.Count() );
264cdf0e10cSrcweir
265cdf0e10cSrcweir sal_Bool bRet = sal_False;
266cdf0e10cSrcweir if( aBoxes.Count() )
267cdf0e10cSrcweir bRet = GetDoc()->InsertCol( aBoxes, nCnt, bBehind );
268cdf0e10cSrcweir
269cdf0e10cSrcweir EndAllActionAndCall();
270cdf0e10cSrcweir return bRet;
271cdf0e10cSrcweir }
272cdf0e10cSrcweir
273cdf0e10cSrcweir /***********************************************************************
274cdf0e10cSrcweir #* Class : SwFEShell
275cdf0e10cSrcweir #* Methoden : DeleteRow(), DeleteCol()
276cdf0e10cSrcweir #* Datum : MA 03. May. 93
277cdf0e10cSrcweir #* Update : MA 19. Apr. 95
278cdf0e10cSrcweir #***********************************************************************/
279cdf0e10cSrcweir
280cdf0e10cSrcweir /**
281cdf0e10cSrcweir Determines if the current cursor is in the last row of the table.
282cdf0e10cSrcweir */
IsLastCellInRow() const283cdf0e10cSrcweir sal_Bool SwFEShell::IsLastCellInRow() const
284cdf0e10cSrcweir {
285cdf0e10cSrcweir SwTabCols aTabCols;
286cdf0e10cSrcweir GetTabCols( aTabCols );
287cdf0e10cSrcweir sal_Bool bResult = sal_False;
288cdf0e10cSrcweir
289cdf0e10cSrcweir if (IsTableRightToLeft())
290cdf0e10cSrcweir /* If the table is right-to-left the last row is the most left one. */
291cdf0e10cSrcweir bResult = 0 == GetCurTabColNum();
292cdf0e10cSrcweir else
293cdf0e10cSrcweir /* If the table is left-to-right the last row is the most right one. */
294cdf0e10cSrcweir bResult = aTabCols.Count() == GetCurTabColNum();
295cdf0e10cSrcweir
296cdf0e10cSrcweir return bResult;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir
DeleteCol()299cdf0e10cSrcweir sal_Bool SwFEShell::DeleteCol()
300cdf0e10cSrcweir {
301cdf0e10cSrcweir // pruefe ob vom aktuellen Crsr der SPoint/Mark in einer Tabelle stehen
302cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
303cdf0e10cSrcweir if( !pFrm || !pFrm->IsInTab() )
304cdf0e10cSrcweir return sal_False;
305cdf0e10cSrcweir
306cdf0e10cSrcweir if( pFrm->ImplFindTabFrm()->GetTable()->ISA( SwDDETable ))
307cdf0e10cSrcweir {
308cdf0e10cSrcweir ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
309cdf0e10cSrcweir ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
310cdf0e10cSrcweir return sal_False;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir
313cdf0e10cSrcweir SET_CURR_SHELL( this );
314cdf0e10cSrcweir StartAllAction();
315cdf0e10cSrcweir
316cdf0e10cSrcweir // lasse ueber das Layout die Boxen suchen
317cdf0e10cSrcweir sal_Bool bRet;
318cdf0e10cSrcweir SwSelBoxes aBoxes;
319cdf0e10cSrcweir GetTblSel( *this, aBoxes, nsSwTblSearchType::TBLSEARCH_COL );
320cdf0e10cSrcweir if ( aBoxes.Count() )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir TblWait( aBoxes.Count(), pFrm, *GetDoc()->GetDocShell() );
323cdf0e10cSrcweir
324cdf0e10cSrcweir // die Crsr muessen noch aus dem Loesch Bereich entfernt
325cdf0e10cSrcweir // werden. Setze sie immer hinter/auf die Tabelle; ueber die
326cdf0e10cSrcweir // Dokument-Position werden sie dann immer an die alte Position gesetzt.
327cdf0e10cSrcweir while( !pFrm->IsCellFrm() )
328cdf0e10cSrcweir pFrm = pFrm->GetUpper();
329cdf0e10cSrcweir
330cdf0e10cSrcweir ParkCursorInTab();
331cdf0e10cSrcweir
332cdf0e10cSrcweir // dann loesche doch die Spalten
333cdf0e10cSrcweir StartUndo(UNDO_COL_DELETE);
334cdf0e10cSrcweir bRet = GetDoc()->DeleteRowCol( aBoxes, true );
335cdf0e10cSrcweir EndUndo(UNDO_COL_DELETE);
336cdf0e10cSrcweir
337cdf0e10cSrcweir }
338cdf0e10cSrcweir else
339cdf0e10cSrcweir bRet = sal_False;
340cdf0e10cSrcweir
341cdf0e10cSrcweir EndAllActionAndCall();
342cdf0e10cSrcweir return bRet;
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
DeleteRow()345cdf0e10cSrcweir sal_Bool SwFEShell::DeleteRow()
346cdf0e10cSrcweir {
347cdf0e10cSrcweir // pruefe ob vom aktuellen Crsr der SPoint/Mark in einer Tabelle stehen
348cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
349cdf0e10cSrcweir if( !pFrm || !pFrm->IsInTab() )
350cdf0e10cSrcweir return sal_False;
351cdf0e10cSrcweir
352cdf0e10cSrcweir if( pFrm->ImplFindTabFrm()->GetTable()->ISA( SwDDETable ))
353cdf0e10cSrcweir {
354cdf0e10cSrcweir ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
355cdf0e10cSrcweir ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
356cdf0e10cSrcweir return sal_False;
357cdf0e10cSrcweir }
358cdf0e10cSrcweir
359cdf0e10cSrcweir SET_CURR_SHELL( this );
360cdf0e10cSrcweir StartAllAction();
361cdf0e10cSrcweir
362cdf0e10cSrcweir // lasse ueber das Layout die Boxen suchen
363cdf0e10cSrcweir sal_Bool bRet;
364cdf0e10cSrcweir SwSelBoxes aBoxes;
365cdf0e10cSrcweir GetTblSel( *this, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW );
366cdf0e10cSrcweir
367cdf0e10cSrcweir if( aBoxes.Count() )
368cdf0e10cSrcweir {
369cdf0e10cSrcweir TblWait( aBoxes.Count(), pFrm, *GetDoc()->GetDocShell() );
370cdf0e10cSrcweir
371cdf0e10cSrcweir // die Crsr aus dem Loeschbereich entfernen.
372cdf0e10cSrcweir // Der Cursor steht danach:
373cdf0e10cSrcweir // - es folgt noch eine Zeile, in dieser
374cdf0e10cSrcweir // - vorher steht noch eine Zeile, in dieser
375cdf0e10cSrcweir // - sonst immer dahinter
376cdf0e10cSrcweir {
377cdf0e10cSrcweir SwTableNode* pTblNd = ((SwCntntFrm*)pFrm)->GetNode()->FindTableNode();
378cdf0e10cSrcweir
379cdf0e10cSrcweir // suche alle Boxen / Lines
380cdf0e10cSrcweir _FndBox aFndBox( 0, 0 );
381cdf0e10cSrcweir {
382cdf0e10cSrcweir _FndPara aPara( aBoxes, &aFndBox );
383cdf0e10cSrcweir pTblNd->GetTable().GetTabLines().ForEach( &_FndLineCopyCol, &aPara );
384cdf0e10cSrcweir }
385cdf0e10cSrcweir
386cdf0e10cSrcweir if( !aFndBox.GetLines().Count() )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir EndAllActionAndCall();
389cdf0e10cSrcweir return sal_False;
390cdf0e10cSrcweir }
391cdf0e10cSrcweir
392cdf0e10cSrcweir KillPams();
393cdf0e10cSrcweir
394cdf0e10cSrcweir _FndBox* pFndBox = &aFndBox;
395cdf0e10cSrcweir while( 1 == pFndBox->GetLines().Count() &&
396cdf0e10cSrcweir 1 == pFndBox->GetLines()[0]->GetBoxes().Count() )
397cdf0e10cSrcweir {
398cdf0e10cSrcweir _FndBox* pTmp = pFndBox->GetLines()[0]->GetBoxes()[0];
399cdf0e10cSrcweir if( pTmp->GetBox()->GetSttNd() )
400cdf0e10cSrcweir break; // das ist sonst zu weit
401cdf0e10cSrcweir pFndBox = pTmp;
402cdf0e10cSrcweir }
403cdf0e10cSrcweir
404cdf0e10cSrcweir SwTableLine* pDelLine = pFndBox->GetLines()[
405cdf0e10cSrcweir pFndBox->GetLines().Count()-1 ]->GetLine();
406cdf0e10cSrcweir SwTableBox* pDelBox = pDelLine->GetTabBoxes()[
407cdf0e10cSrcweir pDelLine->GetTabBoxes().Count() - 1 ];
408cdf0e10cSrcweir while( !pDelBox->GetSttNd() )
409cdf0e10cSrcweir {
410cdf0e10cSrcweir SwTableLine* pLn = pDelBox->GetTabLines()[
411cdf0e10cSrcweir pDelBox->GetTabLines().Count()-1 ];
412cdf0e10cSrcweir pDelBox = pLn->GetTabBoxes()[ pLn->GetTabBoxes().Count() - 1 ];
413cdf0e10cSrcweir }
414cdf0e10cSrcweir SwTableBox* pNextBox = pDelLine->FindNextBox( pTblNd->GetTable(),
415cdf0e10cSrcweir pDelBox, sal_True );
416cdf0e10cSrcweir while( pNextBox &&
417cdf0e10cSrcweir pNextBox->GetFrmFmt()->GetProtect().IsCntntProtected() )
418cdf0e10cSrcweir pNextBox = pNextBox->FindNextBox( pTblNd->GetTable(), pNextBox );
419cdf0e10cSrcweir
420cdf0e10cSrcweir if( !pNextBox ) // keine nachfolgende? dann die vorhergehende
421cdf0e10cSrcweir {
422cdf0e10cSrcweir pDelLine = pFndBox->GetLines()[ 0 ]->GetLine();
423cdf0e10cSrcweir pDelBox = pDelLine->GetTabBoxes()[ 0 ];
424cdf0e10cSrcweir while( !pDelBox->GetSttNd() )
425cdf0e10cSrcweir pDelBox = pDelBox->GetTabLines()[0]->GetTabBoxes()[0];
426cdf0e10cSrcweir pNextBox = pDelLine->FindPreviousBox( pTblNd->GetTable(),
427cdf0e10cSrcweir pDelBox, sal_True );
428cdf0e10cSrcweir while( pNextBox &&
429cdf0e10cSrcweir pNextBox->GetFrmFmt()->GetProtect().IsCntntProtected() )
430cdf0e10cSrcweir pNextBox = pNextBox->FindPreviousBox( pTblNd->GetTable(), pNextBox );
431cdf0e10cSrcweir }
432cdf0e10cSrcweir
433cdf0e10cSrcweir sal_uLong nIdx;
434cdf0e10cSrcweir if( pNextBox ) // dann den Cursor hier hinein
435cdf0e10cSrcweir nIdx = pNextBox->GetSttIdx() + 1;
436cdf0e10cSrcweir else // ansonsten hinter die Tabelle
437cdf0e10cSrcweir nIdx = pTblNd->EndOfSectionIndex() + 1;
438cdf0e10cSrcweir
439cdf0e10cSrcweir SwNodeIndex aIdx( GetDoc()->GetNodes(), nIdx );
440cdf0e10cSrcweir SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
441cdf0e10cSrcweir if( !pCNd )
442cdf0e10cSrcweir pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
443cdf0e10cSrcweir
444cdf0e10cSrcweir if( pCNd )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir SwPaM* pPam = GetCrsr();
447cdf0e10cSrcweir pPam->GetPoint()->nNode = aIdx;
448cdf0e10cSrcweir pPam->GetPoint()->nContent.Assign( pCNd, 0 );
449cdf0e10cSrcweir pPam->SetMark(); // beide wollen etwas davon haben
450cdf0e10cSrcweir pPam->DeleteMark();
451cdf0e10cSrcweir }
452cdf0e10cSrcweir }
453cdf0e10cSrcweir
454cdf0e10cSrcweir // dann loesche doch die Zeilen
455cdf0e10cSrcweir StartUndo(UNDO_ROW_DELETE);
456cdf0e10cSrcweir bRet = GetDoc()->DeleteRowCol( aBoxes );
457cdf0e10cSrcweir EndUndo(UNDO_ROW_DELETE);
458cdf0e10cSrcweir }
459cdf0e10cSrcweir else
460cdf0e10cSrcweir bRet = sal_False;
461cdf0e10cSrcweir
462cdf0e10cSrcweir EndAllActionAndCall();
463cdf0e10cSrcweir return bRet;
464cdf0e10cSrcweir }
465cdf0e10cSrcweir
466cdf0e10cSrcweir /***********************************************************************
467cdf0e10cSrcweir #* Class : SwFEShell
468cdf0e10cSrcweir #* Methoden : MergeTab(), SplitTab()
469cdf0e10cSrcweir #* Datum : MA 03. May. 93
470cdf0e10cSrcweir #* Update : MA 19. Apr. 95
471cdf0e10cSrcweir #***********************************************************************/
472cdf0e10cSrcweir
MergeTab()473cdf0e10cSrcweir sal_uInt16 SwFEShell::MergeTab()
474cdf0e10cSrcweir {
475cdf0e10cSrcweir // pruefe ob vom aktuellen Crsr der SPoint/Mark in einer Tabelle stehen
476cdf0e10cSrcweir sal_uInt16 nRet = TBLMERGE_NOSELECTION;
477cdf0e10cSrcweir if( IsTableMode() )
478cdf0e10cSrcweir {
479cdf0e10cSrcweir SwShellTableCrsr* pTableCrsr = GetTableCrsr();
480cdf0e10cSrcweir const SwTableNode* pTblNd = pTableCrsr->GetNode()->FindTableNode();
481cdf0e10cSrcweir if( pTblNd->GetTable().ISA( SwDDETable ))
482cdf0e10cSrcweir {
483cdf0e10cSrcweir ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
484cdf0e10cSrcweir ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
485cdf0e10cSrcweir }
486cdf0e10cSrcweir else
487cdf0e10cSrcweir {
488cdf0e10cSrcweir SET_CURR_SHELL( this );
489cdf0e10cSrcweir StartAllAction();
490cdf0e10cSrcweir
491cdf0e10cSrcweir TblWait( pTableCrsr->GetBoxesCount(), 0, *GetDoc()->GetDocShell(),
492cdf0e10cSrcweir pTblNd->GetTable().GetTabLines().Count() );
493cdf0e10cSrcweir
494cdf0e10cSrcweir nRet = GetDoc()->MergeTbl( *pTableCrsr );
495cdf0e10cSrcweir
496cdf0e10cSrcweir KillPams();
497cdf0e10cSrcweir
498cdf0e10cSrcweir EndAllActionAndCall();
499cdf0e10cSrcweir }
500cdf0e10cSrcweir }
501cdf0e10cSrcweir return nRet;
502cdf0e10cSrcweir }
503cdf0e10cSrcweir
SplitTab(sal_Bool bVert,sal_uInt16 nCnt,sal_Bool bSameHeight)504cdf0e10cSrcweir sal_Bool SwFEShell::SplitTab( sal_Bool bVert, sal_uInt16 nCnt, sal_Bool bSameHeight )
505cdf0e10cSrcweir {
506cdf0e10cSrcweir // pruefe ob vom aktuellen Crsr der SPoint/Mark in einer Tabelle stehen
507cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
508cdf0e10cSrcweir if( !pFrm || !pFrm->IsInTab() )
509cdf0e10cSrcweir return sal_False;
510cdf0e10cSrcweir
511cdf0e10cSrcweir if( pFrm->ImplFindTabFrm()->GetTable()->ISA( SwDDETable ))
512cdf0e10cSrcweir {
513cdf0e10cSrcweir ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
514cdf0e10cSrcweir ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
515cdf0e10cSrcweir return sal_False;
516cdf0e10cSrcweir }
517cdf0e10cSrcweir
518cdf0e10cSrcweir SET_CURR_SHELL( this );
519cdf0e10cSrcweir
520cdf0e10cSrcweir if( bVert && !CheckSplitCells( *this, nCnt + 1 ) )
521cdf0e10cSrcweir {
522cdf0e10cSrcweir ErrorHandler::HandleError( ERR_TBLSPLIT_ERROR,
523cdf0e10cSrcweir ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
524cdf0e10cSrcweir return sal_False;
525cdf0e10cSrcweir }
526cdf0e10cSrcweir StartAllAction();
527cdf0e10cSrcweir // lasse ueber das Layout die Boxen suchen
528cdf0e10cSrcweir sal_Bool bRet;
529cdf0e10cSrcweir SwSelBoxes aBoxes;
530cdf0e10cSrcweir GetTblSel( *this, aBoxes );
531cdf0e10cSrcweir if( aBoxes.Count() )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir TblWait( nCnt, pFrm, *GetDoc()->GetDocShell(), aBoxes.Count() );
534cdf0e10cSrcweir
535cdf0e10cSrcweir // dann loesche doch die Spalten
536cdf0e10cSrcweir bRet = GetDoc()->SplitTbl( aBoxes, bVert, nCnt, bSameHeight );
537cdf0e10cSrcweir
538cdf0e10cSrcweir DELETEZ( pLastCols );
539cdf0e10cSrcweir DELETEZ( pLastRows );
540cdf0e10cSrcweir }
541cdf0e10cSrcweir else
542cdf0e10cSrcweir bRet = sal_False;
543cdf0e10cSrcweir EndAllActionAndCall();
544cdf0e10cSrcweir return bRet;
545cdf0e10cSrcweir }
546cdf0e10cSrcweir
547cdf0e10cSrcweir
548cdf0e10cSrcweir /***********************************************************************
549cdf0e10cSrcweir #* Class : SwFEShell
550cdf0e10cSrcweir #* Methoden : _GetTabCols
551cdf0e10cSrcweir #* Datum : MA 30. Nov. 95
552cdf0e10cSrcweir #* Update : MA 08. Jan. 97
553cdf0e10cSrcweir #***********************************************************************/
_GetTabCols(SwTabCols & rToFill,const SwFrm * pBox) const554cdf0e10cSrcweir void SwFEShell::_GetTabCols( SwTabCols &rToFill, const SwFrm *pBox ) const
555cdf0e10cSrcweir {
556cdf0e10cSrcweir const SwTabFrm *pTab = pBox->FindTabFrm();
557cdf0e10cSrcweir if ( pLastCols )
558cdf0e10cSrcweir {
559cdf0e10cSrcweir //Paar Kleinigkeiten muessen wir schon noch sicherstellen
560cdf0e10cSrcweir sal_Bool bDel = sal_True;
561cdf0e10cSrcweir if ( pColumnCacheLastTable == pTab->GetTable() )
562cdf0e10cSrcweir {
563cdf0e10cSrcweir bDel = sal_False;
564cdf0e10cSrcweir SWRECTFN( pTab )
565cdf0e10cSrcweir
566cdf0e10cSrcweir const SwPageFrm* pPage = pTab->FindPageFrm();
567cdf0e10cSrcweir const sal_uLong nLeftMin = (pTab->Frm().*fnRect->fnGetLeft)() -
568cdf0e10cSrcweir (pPage->Frm().*fnRect->fnGetLeft)();
569cdf0e10cSrcweir const sal_uLong nRightMax = (pTab->Frm().*fnRect->fnGetRight)() -
570cdf0e10cSrcweir (pPage->Frm().*fnRect->fnGetLeft)();
571cdf0e10cSrcweir
572cdf0e10cSrcweir if ( pColumnCacheLastTabFrm != pTab )
573cdf0e10cSrcweir {
574cdf0e10cSrcweir //Wenn der TabFrm gewechselt hat, brauchen wir bei gleicher
575cdf0e10cSrcweir //Breite nur ein wenig shiften.
576cdf0e10cSrcweir SWRECTFNX( pColumnCacheLastTabFrm )
577cdf0e10cSrcweir if( (pColumnCacheLastTabFrm->Frm().*fnRectX->fnGetWidth)() ==
578cdf0e10cSrcweir (pTab->Frm().*fnRect->fnGetWidth)() )
579cdf0e10cSrcweir {
580cdf0e10cSrcweir pLastCols->SetLeftMin( nLeftMin );
581cdf0e10cSrcweir
582cdf0e10cSrcweir //ASSERT( bVert ||
583cdf0e10cSrcweir // pLastCols->GetLeftMin() == (pTab->Frm().*fnRect->fnGetLeft)(),
584cdf0e10cSrcweir // "GetTabCols: wrong result" )
585cdf0e10cSrcweir
586cdf0e10cSrcweir pColumnCacheLastTabFrm = pTab;
587cdf0e10cSrcweir }
588cdf0e10cSrcweir else
589cdf0e10cSrcweir bDel = sal_True;
590cdf0e10cSrcweir }
591cdf0e10cSrcweir
592cdf0e10cSrcweir if ( !bDel &&
593cdf0e10cSrcweir pLastCols->GetLeftMin () == (sal_uInt16)nLeftMin &&
594cdf0e10cSrcweir pLastCols->GetLeft () == (sal_uInt16)(pTab->Prt().*fnRect->fnGetLeft)() &&
595cdf0e10cSrcweir pLastCols->GetRight () == (sal_uInt16)(pTab->Prt().*fnRect->fnGetRight)()&&
596cdf0e10cSrcweir pLastCols->GetRightMax() == (sal_uInt16)nRightMax - pLastCols->GetLeftMin() )
597cdf0e10cSrcweir {
598cdf0e10cSrcweir if ( pColumnCacheLastCellFrm != pBox )
599cdf0e10cSrcweir {
600cdf0e10cSrcweir pTab->GetTable()->GetTabCols( *pLastCols,
601cdf0e10cSrcweir ((SwCellFrm*)pBox)->GetTabBox(), sal_True);
602cdf0e10cSrcweir pColumnCacheLastCellFrm = pBox;
603cdf0e10cSrcweir }
604cdf0e10cSrcweir rToFill = *pLastCols;
605cdf0e10cSrcweir }
606cdf0e10cSrcweir else
607cdf0e10cSrcweir bDel = sal_True;
608cdf0e10cSrcweir }
609cdf0e10cSrcweir if ( bDel )
610cdf0e10cSrcweir DELETEZ(pLastCols);
611cdf0e10cSrcweir }
612cdf0e10cSrcweir if ( !pLastCols )
613cdf0e10cSrcweir {
614cdf0e10cSrcweir GetDoc()->GetTabCols( rToFill, 0, (SwCellFrm*)pBox );
615cdf0e10cSrcweir
616cdf0e10cSrcweir pLastCols = new SwTabCols( rToFill );
617cdf0e10cSrcweir pColumnCacheLastTable = pTab->GetTable();
618cdf0e10cSrcweir pColumnCacheLastTabFrm = pTab;
619cdf0e10cSrcweir pColumnCacheLastCellFrm= pBox;
620cdf0e10cSrcweir }
621cdf0e10cSrcweir
622cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
623cdf0e10cSrcweir SwTabColsEntry aEntry;
624cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < rToFill.Count(); ++i )
625cdf0e10cSrcweir {
626cdf0e10cSrcweir aEntry = rToFill.GetEntry( i );
627cdf0e10cSrcweir (void)aEntry;
628cdf0e10cSrcweir }
629cdf0e10cSrcweir #endif
630cdf0e10cSrcweir }
631cdf0e10cSrcweir
632cdf0e10cSrcweir /***********************************************************************
633cdf0e10cSrcweir #* Class : SwFEShell
634cdf0e10cSrcweir #* Methoden : _GetTabRows
635cdf0e10cSrcweir #* Datum : FME 2004-01-14
636cdf0e10cSrcweir #* Update :
637cdf0e10cSrcweir #***********************************************************************/
_GetTabRows(SwTabCols & rToFill,const SwFrm * pBox) const638cdf0e10cSrcweir void SwFEShell::_GetTabRows( SwTabCols &rToFill, const SwFrm *pBox ) const
639cdf0e10cSrcweir {
640cdf0e10cSrcweir const SwTabFrm *pTab = pBox->FindTabFrm();
641cdf0e10cSrcweir if ( pLastRows )
642cdf0e10cSrcweir {
643cdf0e10cSrcweir //Paar Kleinigkeiten muessen wir schon noch sicherstellen
644cdf0e10cSrcweir sal_Bool bDel = sal_True;
645cdf0e10cSrcweir if ( pRowCacheLastTable == pTab->GetTable() )
646cdf0e10cSrcweir {
647cdf0e10cSrcweir bDel = sal_False;
648cdf0e10cSrcweir SWRECTFN( pTab )
649cdf0e10cSrcweir const SwPageFrm* pPage = pTab->FindPageFrm();
650cdf0e10cSrcweir const long nLeftMin = ( bVert ?
651cdf0e10cSrcweir pTab->GetPrtLeft() - pPage->Frm().Left() :
652cdf0e10cSrcweir pTab->GetPrtTop() - pPage->Frm().Top() );
653cdf0e10cSrcweir const long nLeft = bVert ? LONG_MAX : 0;
654cdf0e10cSrcweir const long nRight = (pTab->Prt().*fnRect->fnGetHeight)();
655cdf0e10cSrcweir const long nRightMax = bVert ? nRight : LONG_MAX;
656cdf0e10cSrcweir
657cdf0e10cSrcweir if ( pRowCacheLastTabFrm != pTab ||
658cdf0e10cSrcweir pRowCacheLastCellFrm != pBox )
659cdf0e10cSrcweir bDel = sal_True;
660cdf0e10cSrcweir
661cdf0e10cSrcweir if ( !bDel &&
662cdf0e10cSrcweir pLastRows->GetLeftMin () == nLeftMin &&
663cdf0e10cSrcweir pLastRows->GetLeft () == nLeft &&
664cdf0e10cSrcweir pLastRows->GetRight () == nRight &&
665cdf0e10cSrcweir pLastRows->GetRightMax() == nRightMax )
666cdf0e10cSrcweir {
667cdf0e10cSrcweir rToFill = *pLastRows;
668cdf0e10cSrcweir }
669cdf0e10cSrcweir else
670cdf0e10cSrcweir bDel = sal_True;
671cdf0e10cSrcweir }
672cdf0e10cSrcweir if ( bDel )
673cdf0e10cSrcweir DELETEZ(pLastRows);
674cdf0e10cSrcweir }
675cdf0e10cSrcweir if ( !pLastRows )
676cdf0e10cSrcweir {
677cdf0e10cSrcweir GetDoc()->GetTabRows( rToFill, 0, (SwCellFrm*)pBox );
678cdf0e10cSrcweir
679cdf0e10cSrcweir pLastRows = new SwTabCols( rToFill );
680cdf0e10cSrcweir pRowCacheLastTable = pTab->GetTable();
681cdf0e10cSrcweir pRowCacheLastTabFrm = pTab;
682cdf0e10cSrcweir pRowCacheLastCellFrm= pBox;
683cdf0e10cSrcweir }
684cdf0e10cSrcweir }
685cdf0e10cSrcweir
686cdf0e10cSrcweir /***********************************************************************
687cdf0e10cSrcweir #* Class : SwFEShell
688cdf0e10cSrcweir #* Methoden : SetTabCols(), GetTabCols()
689cdf0e10cSrcweir #* Datum : MA 03. May. 93
690cdf0e10cSrcweir #* Update : MA 18. May. 93
691cdf0e10cSrcweir #***********************************************************************/
SetTabCols(const SwTabCols & rNew,sal_Bool bCurRowOnly)692cdf0e10cSrcweir void SwFEShell::SetTabCols( const SwTabCols &rNew, sal_Bool bCurRowOnly )
693cdf0e10cSrcweir {
694cdf0e10cSrcweir SwFrm *pBox = GetCurrFrm();
695cdf0e10cSrcweir if( !pBox || !pBox->IsInTab() )
696cdf0e10cSrcweir return;
697cdf0e10cSrcweir
698cdf0e10cSrcweir SET_CURR_SHELL( this );
699cdf0e10cSrcweir StartAllAction();
700cdf0e10cSrcweir
701cdf0e10cSrcweir do {
702cdf0e10cSrcweir pBox = pBox->GetUpper();
703cdf0e10cSrcweir } while ( !pBox->IsCellFrm() );
704cdf0e10cSrcweir
705cdf0e10cSrcweir GetDoc()->SetTabCols( rNew, bCurRowOnly, 0, (SwCellFrm*)pBox );
706cdf0e10cSrcweir EndAllActionAndCall();
707cdf0e10cSrcweir }
708cdf0e10cSrcweir
GetTabCols(SwTabCols & rToFill) const709cdf0e10cSrcweir void SwFEShell::GetTabCols( SwTabCols &rToFill ) const
710cdf0e10cSrcweir {
711cdf0e10cSrcweir const SwFrm *pFrm = GetCurrFrm();
712cdf0e10cSrcweir if( !pFrm || !pFrm->IsInTab() )
713cdf0e10cSrcweir return;
714cdf0e10cSrcweir do
715cdf0e10cSrcweir { pFrm = pFrm->GetUpper();
716cdf0e10cSrcweir } while ( !pFrm->IsCellFrm() );
717cdf0e10cSrcweir
718cdf0e10cSrcweir _GetTabCols( rToFill, pFrm );
719cdf0e10cSrcweir }
720cdf0e10cSrcweir
721cdf0e10cSrcweir /*-- 19.01.2004 08:56:42---------------------------------------------------
722cdf0e10cSrcweir
723cdf0e10cSrcweir -----------------------------------------------------------------------*/
GetTabRows(SwTabCols & rToFill) const724cdf0e10cSrcweir void SwFEShell::GetTabRows( SwTabCols &rToFill ) const
725cdf0e10cSrcweir {
726cdf0e10cSrcweir const SwFrm *pFrm = GetCurrFrm();
727cdf0e10cSrcweir if( !pFrm || !pFrm->IsInTab() )
728cdf0e10cSrcweir return;
729cdf0e10cSrcweir do
730cdf0e10cSrcweir { pFrm = pFrm->GetUpper();
731cdf0e10cSrcweir } while ( !pFrm->IsCellFrm() );
732cdf0e10cSrcweir
733cdf0e10cSrcweir _GetTabRows( rToFill, pFrm );
734cdf0e10cSrcweir }
735cdf0e10cSrcweir /*-- 19.01.2004 08:56:44---------------------------------------------------
736cdf0e10cSrcweir
737cdf0e10cSrcweir -----------------------------------------------------------------------*/
SetTabRows(const SwTabCols & rNew,sal_Bool bCurColOnly)738cdf0e10cSrcweir void SwFEShell::SetTabRows( const SwTabCols &rNew, sal_Bool bCurColOnly )
739cdf0e10cSrcweir {
740cdf0e10cSrcweir SwFrm *pBox = GetCurrFrm();
741cdf0e10cSrcweir if( !pBox || !pBox->IsInTab() )
742cdf0e10cSrcweir return;
743cdf0e10cSrcweir
744cdf0e10cSrcweir SET_CURR_SHELL( this );
745cdf0e10cSrcweir StartAllAction();
746cdf0e10cSrcweir
747cdf0e10cSrcweir do {
748cdf0e10cSrcweir pBox = pBox->GetUpper();
749cdf0e10cSrcweir } while ( !pBox->IsCellFrm() );
750cdf0e10cSrcweir
751cdf0e10cSrcweir GetDoc()->SetTabRows( rNew, bCurColOnly, 0, (SwCellFrm*)pBox );
752cdf0e10cSrcweir EndAllActionAndCall();
753cdf0e10cSrcweir }
754cdf0e10cSrcweir /*-- 19.01.2004 08:59:45---------------------------------------------------
755cdf0e10cSrcweir
756cdf0e10cSrcweir -----------------------------------------------------------------------*/
GetMouseTabRows(SwTabCols & rToFill,const Point & rPt) const757cdf0e10cSrcweir void SwFEShell::GetMouseTabRows( SwTabCols &rToFill, const Point &rPt ) const
758cdf0e10cSrcweir {
759cdf0e10cSrcweir const SwFrm *pBox = GetBox( rPt );
760cdf0e10cSrcweir if ( pBox )
761cdf0e10cSrcweir _GetTabRows( rToFill, pBox );
762cdf0e10cSrcweir }
763cdf0e10cSrcweir /*-- 19.01.2004 08:59:45---------------------------------------------------
764cdf0e10cSrcweir
765cdf0e10cSrcweir -----------------------------------------------------------------------*/
SetMouseTabRows(const SwTabCols & rNew,sal_Bool bCurColOnly,const Point & rPt)766cdf0e10cSrcweir void SwFEShell::SetMouseTabRows( const SwTabCols &rNew, sal_Bool bCurColOnly, const Point &rPt )
767cdf0e10cSrcweir {
768cdf0e10cSrcweir const SwFrm *pBox = GetBox( rPt );
769cdf0e10cSrcweir if( pBox )
770cdf0e10cSrcweir {
771cdf0e10cSrcweir SET_CURR_SHELL( this );
772cdf0e10cSrcweir StartAllAction();
773cdf0e10cSrcweir GetDoc()->SetTabRows( rNew, bCurColOnly, 0, (SwCellFrm*)pBox );
774cdf0e10cSrcweir EndAllActionAndCall();
775cdf0e10cSrcweir }
776cdf0e10cSrcweir }
777cdf0e10cSrcweir
778cdf0e10cSrcweir /***********************************************************************
779cdf0e10cSrcweir * Class : SwFEShell
780cdf0e10cSrcweir * Methoden : SetRowSplit(), GetRowSplit()
781cdf0e10cSrcweir * Datum : FME 13.11.2003
782cdf0e10cSrcweir ***********************************************************************/
783cdf0e10cSrcweir
SetRowSplit(const SwFmtRowSplit & rNew)784cdf0e10cSrcweir void SwFEShell::SetRowSplit( const SwFmtRowSplit& rNew )
785cdf0e10cSrcweir {
786cdf0e10cSrcweir SET_CURR_SHELL( this );
787cdf0e10cSrcweir StartAllAction();
788cdf0e10cSrcweir GetDoc()->SetRowSplit( *getShellCrsr( false ), rNew );
789cdf0e10cSrcweir EndAllActionAndCall();
790cdf0e10cSrcweir }
791cdf0e10cSrcweir
GetRowSplit(SwFmtRowSplit * & rpSz) const792cdf0e10cSrcweir void SwFEShell::GetRowSplit( SwFmtRowSplit*& rpSz ) const
793cdf0e10cSrcweir {
794cdf0e10cSrcweir GetDoc()->GetRowSplit( *getShellCrsr( false ), rpSz );
795cdf0e10cSrcweir }
796cdf0e10cSrcweir
797cdf0e10cSrcweir
798cdf0e10cSrcweir /***********************************************************************
799cdf0e10cSrcweir #* Class : SwFEShell
800cdf0e10cSrcweir #* Methoden : SetRowHeight(), GetRowHeight()
801cdf0e10cSrcweir #* Datum : MA 17. May. 93
802cdf0e10cSrcweir #* Update : JP 29.04.98
803cdf0e10cSrcweir #***********************************************************************/
804cdf0e10cSrcweir
SetRowHeight(const SwFmtFrmSize & rNew)805cdf0e10cSrcweir void SwFEShell::SetRowHeight( const SwFmtFrmSize &rNew )
806cdf0e10cSrcweir {
807cdf0e10cSrcweir SET_CURR_SHELL( this );
808cdf0e10cSrcweir StartAllAction();
809cdf0e10cSrcweir GetDoc()->SetRowHeight( *getShellCrsr( false ), rNew );
810cdf0e10cSrcweir EndAllActionAndCall();
811cdf0e10cSrcweir }
812cdf0e10cSrcweir
813cdf0e10cSrcweir /******************************************************************************
814cdf0e10cSrcweir * SwTwips SwFEShell::GetRowHeight() const
815cdf0e10cSrcweir ******************************************************************************/
GetRowHeight(SwFmtFrmSize * & rpSz) const816cdf0e10cSrcweir void SwFEShell::GetRowHeight( SwFmtFrmSize *& rpSz ) const
817cdf0e10cSrcweir {
818cdf0e10cSrcweir GetDoc()->GetRowHeight( *getShellCrsr( false ), rpSz );
819cdf0e10cSrcweir }
820cdf0e10cSrcweir
BalanceRowHeight(sal_Bool bTstOnly)821cdf0e10cSrcweir sal_Bool SwFEShell::BalanceRowHeight( sal_Bool bTstOnly )
822cdf0e10cSrcweir {
823cdf0e10cSrcweir SET_CURR_SHELL( this );
824cdf0e10cSrcweir if( !bTstOnly )
825cdf0e10cSrcweir StartAllAction();
826cdf0e10cSrcweir sal_Bool bRet = GetDoc()->BalanceRowHeight( *getShellCrsr( false ), bTstOnly );
827cdf0e10cSrcweir if( !bTstOnly )
828cdf0e10cSrcweir EndAllActionAndCall();
829cdf0e10cSrcweir return bRet;
830cdf0e10cSrcweir }
831cdf0e10cSrcweir
832cdf0e10cSrcweir /******************************************************************************
833cdf0e10cSrcweir * void SwFEShell::SetRowBackground()
834cdf0e10cSrcweir ******************************************************************************/
SetRowBackground(const SvxBrushItem & rNew)835cdf0e10cSrcweir void SwFEShell::SetRowBackground( const SvxBrushItem &rNew )
836cdf0e10cSrcweir {
837cdf0e10cSrcweir SET_CURR_SHELL( this );
838cdf0e10cSrcweir StartAllAction();
839cdf0e10cSrcweir GetDoc()->SetRowBackground( *getShellCrsr( false ), rNew );
840cdf0e10cSrcweir EndAllActionAndCall();
841cdf0e10cSrcweir }
842cdf0e10cSrcweir
843cdf0e10cSrcweir /******************************************************************************
844cdf0e10cSrcweir * SwTwips SwFEShell::GetRowBackground() const
845cdf0e10cSrcweir ******************************************************************************/
GetRowBackground(SvxBrushItem & rToFill) const846cdf0e10cSrcweir sal_Bool SwFEShell::GetRowBackground( SvxBrushItem &rToFill ) const
847cdf0e10cSrcweir {
848cdf0e10cSrcweir return GetDoc()->GetRowBackground( *getShellCrsr( false ), rToFill );
849cdf0e10cSrcweir }
850cdf0e10cSrcweir
851cdf0e10cSrcweir /***********************************************************************
852cdf0e10cSrcweir #* Class : SwFEShell
853cdf0e10cSrcweir #* Methoden : SetTabBorders(), GetTabBorders()
854cdf0e10cSrcweir #* Datum : MA 18. May. 93
855cdf0e10cSrcweir #* Update : JP 29.04.98
856cdf0e10cSrcweir #***********************************************************************/
857cdf0e10cSrcweir
SetTabBorders(const SfxItemSet & rSet)858cdf0e10cSrcweir void SwFEShell::SetTabBorders( const SfxItemSet& rSet )
859cdf0e10cSrcweir {
860cdf0e10cSrcweir SET_CURR_SHELL( this );
861cdf0e10cSrcweir StartAllAction();
862cdf0e10cSrcweir GetDoc()->SetTabBorders( *getShellCrsr( false ), rSet );
863cdf0e10cSrcweir EndAllActionAndCall();
864cdf0e10cSrcweir }
865cdf0e10cSrcweir
SetTabLineStyle(const Color * pColor,sal_Bool bSetLine,const SvxBorderLine * pBorderLine)866cdf0e10cSrcweir void SwFEShell::SetTabLineStyle( const Color* pColor, sal_Bool bSetLine,
867cdf0e10cSrcweir const SvxBorderLine* pBorderLine )
868cdf0e10cSrcweir {
869cdf0e10cSrcweir SET_CURR_SHELL( this );
870cdf0e10cSrcweir StartAllAction();
871cdf0e10cSrcweir GetDoc()->SetTabLineStyle( *getShellCrsr( false ),
872cdf0e10cSrcweir pColor, bSetLine, pBorderLine );
873cdf0e10cSrcweir EndAllActionAndCall();
874cdf0e10cSrcweir }
875cdf0e10cSrcweir
GetTabBorders(SfxItemSet & rSet) const876cdf0e10cSrcweir void SwFEShell::GetTabBorders( SfxItemSet& rSet ) const
877cdf0e10cSrcweir {
878cdf0e10cSrcweir GetDoc()->GetTabBorders( *getShellCrsr( false ), rSet );
879cdf0e10cSrcweir }
880cdf0e10cSrcweir
881cdf0e10cSrcweir
882cdf0e10cSrcweir /***********************************************************************
883cdf0e10cSrcweir #* Class : SwFEShell
884cdf0e10cSrcweir #* Methoden : SetBoxBackground(), GetBoxBackground()
885cdf0e10cSrcweir #* Datum : MA 01. Jun. 93
886cdf0e10cSrcweir #* Update : MA 03. Jul. 96
887cdf0e10cSrcweir #***********************************************************************/
SetBoxBackground(const SvxBrushItem & rNew)888cdf0e10cSrcweir void SwFEShell::SetBoxBackground( const SvxBrushItem &rNew )
889cdf0e10cSrcweir {
890cdf0e10cSrcweir SET_CURR_SHELL( this );
891cdf0e10cSrcweir StartAllAction();
892cdf0e10cSrcweir GetDoc()->SetBoxAttr( *getShellCrsr( false ), rNew );
893cdf0e10cSrcweir EndAllActionAndCall();
894cdf0e10cSrcweir }
895cdf0e10cSrcweir
GetBoxBackground(SvxBrushItem & rToFill) const896cdf0e10cSrcweir sal_Bool SwFEShell::GetBoxBackground( SvxBrushItem &rToFill ) const
897cdf0e10cSrcweir {
898cdf0e10cSrcweir return GetDoc()->GetBoxAttr( *getShellCrsr( false ), rToFill );
899cdf0e10cSrcweir }
900cdf0e10cSrcweir
901cdf0e10cSrcweir /***********************************************************************
902cdf0e10cSrcweir #* Class : SwFEShell
903cdf0e10cSrcweir #* Methoden : SetBoxDirection(), GetBoxDirection()
904cdf0e10cSrcweir #* Datum : FME 2004-02-03
905cdf0e10cSrcweir #* Update : FME 2004-02-03
906cdf0e10cSrcweir #***********************************************************************/
SetBoxDirection(const SvxFrameDirectionItem & rNew)907cdf0e10cSrcweir void SwFEShell::SetBoxDirection( const SvxFrameDirectionItem& rNew )
908cdf0e10cSrcweir {
909cdf0e10cSrcweir SET_CURR_SHELL( this );
910cdf0e10cSrcweir StartAllAction();
911cdf0e10cSrcweir GetDoc()->SetBoxAttr( *getShellCrsr( false ), rNew );
912cdf0e10cSrcweir EndAllActionAndCall();
913cdf0e10cSrcweir }
914cdf0e10cSrcweir
GetBoxDirection(SvxFrameDirectionItem & rToFill) const915cdf0e10cSrcweir sal_Bool SwFEShell::GetBoxDirection( SvxFrameDirectionItem& rToFill ) const
916cdf0e10cSrcweir {
917cdf0e10cSrcweir return GetDoc()->GetBoxAttr( *getShellCrsr( false ), rToFill );
918cdf0e10cSrcweir }
919cdf0e10cSrcweir
920cdf0e10cSrcweir /***********************************************************************
921cdf0e10cSrcweir #* Class : SwFEShell
922cdf0e10cSrcweir #* Methoden : SetBoxAlign, SetBoxAlign
923cdf0e10cSrcweir #* Datum : MA 18. Dec. 96
924cdf0e10cSrcweir #* Update : JP 29.04.98
925cdf0e10cSrcweir #***********************************************************************/
SetBoxAlign(sal_uInt16 nAlign)926cdf0e10cSrcweir void SwFEShell::SetBoxAlign( sal_uInt16 nAlign )
927cdf0e10cSrcweir {
928cdf0e10cSrcweir SET_CURR_SHELL( this );
929cdf0e10cSrcweir StartAllAction();
930cdf0e10cSrcweir GetDoc()->SetBoxAlign( *getShellCrsr( false ), nAlign );
931cdf0e10cSrcweir EndAllActionAndCall();
932cdf0e10cSrcweir }
933cdf0e10cSrcweir
GetBoxAlign() const934cdf0e10cSrcweir sal_uInt16 SwFEShell::GetBoxAlign() const
935cdf0e10cSrcweir {
936cdf0e10cSrcweir return GetDoc()->GetBoxAlign( *getShellCrsr( false ) );
937cdf0e10cSrcweir }
938cdf0e10cSrcweir
939cdf0e10cSrcweir /***********************************************************************
940cdf0e10cSrcweir #* Class : SwFEShell
941cdf0e10cSrcweir #* Methoden : SetTabBackground(), GetTabBackground()
942cdf0e10cSrcweir #* Datum : MA 08. Jul. 96
943cdf0e10cSrcweir #* Update : MA 08. Jul. 96
944cdf0e10cSrcweir #***********************************************************************/
SetTabBackground(const SvxBrushItem & rNew)945cdf0e10cSrcweir void SwFEShell::SetTabBackground( const SvxBrushItem &rNew )
946cdf0e10cSrcweir {
947cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
948cdf0e10cSrcweir if( !pFrm || !pFrm->IsInTab() )
949cdf0e10cSrcweir return;
950cdf0e10cSrcweir
951cdf0e10cSrcweir SET_CURR_SHELL( this );
952cdf0e10cSrcweir StartAllAction();
953cdf0e10cSrcweir GetDoc()->SetAttr( rNew, *pFrm->ImplFindTabFrm()->GetFmt() );
954cdf0e10cSrcweir EndAllAction(); //Kein Call, denn es veraendert sich nichts!
955cdf0e10cSrcweir GetDoc()->SetModified();
956cdf0e10cSrcweir }
957cdf0e10cSrcweir
GetTabBackground(SvxBrushItem & rToFill) const958cdf0e10cSrcweir void SwFEShell::GetTabBackground( SvxBrushItem &rToFill ) const
959cdf0e10cSrcweir {
960cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
961cdf0e10cSrcweir if( pFrm && pFrm->IsInTab() )
962cdf0e10cSrcweir rToFill = pFrm->ImplFindTabFrm()->GetFmt()->GetBackground();
963cdf0e10cSrcweir }
964cdf0e10cSrcweir
965cdf0e10cSrcweir
966cdf0e10cSrcweir /***********************************************************************
967cdf0e10cSrcweir #* Class : SwFEShell
968cdf0e10cSrcweir #* Methoden : HasWholeTabSelection()
969cdf0e10cSrcweir #* Datum : MA 18. May. 93
970cdf0e10cSrcweir #* Update : MA 20. Jul. 93
971cdf0e10cSrcweir #***********************************************************************/
HasWholeTabSelection() const972cdf0e10cSrcweir sal_Bool SwFEShell::HasWholeTabSelection() const
973cdf0e10cSrcweir {
974cdf0e10cSrcweir //Ist die ganze Tabelle Selektiert?
975cdf0e10cSrcweir if ( IsTableMode() )
976cdf0e10cSrcweir {
977cdf0e10cSrcweir SwSelBoxes aBoxes;
978cdf0e10cSrcweir ::GetTblSelCrs( *this, aBoxes );
979cdf0e10cSrcweir if( aBoxes.Count() )
980cdf0e10cSrcweir {
981cdf0e10cSrcweir const SwTableNode *pTblNd = IsCrsrInTbl();
982cdf0e10cSrcweir return ( pTblNd && aBoxes[0]->GetSttIdx()-1 == pTblNd->
983cdf0e10cSrcweir EndOfSectionNode()->StartOfSectionIndex() &&
984cdf0e10cSrcweir aBoxes[aBoxes.Count()-1]->GetSttNd()->EndOfSectionIndex()+1
985cdf0e10cSrcweir == pTblNd->EndOfSectionIndex() );
986cdf0e10cSrcweir }
987cdf0e10cSrcweir }
988cdf0e10cSrcweir return sal_False;
989cdf0e10cSrcweir }
990cdf0e10cSrcweir
HasBoxSelection() const991cdf0e10cSrcweir sal_Bool SwFEShell::HasBoxSelection() const
992cdf0e10cSrcweir {
993cdf0e10cSrcweir if(!IsCrsrInTbl())
994cdf0e10cSrcweir return sal_False;
995cdf0e10cSrcweir //Ist die ganze Tabelle Selektiert?
996cdf0e10cSrcweir if( IsTableMode() )
997cdf0e10cSrcweir return sal_True;
998cdf0e10cSrcweir SwPaM* pPam = GetCrsr();
999cdf0e10cSrcweir // leere Boxen gelten auch ohne Selektion als selektiert
1000cdf0e10cSrcweir // if( !pPam->HasMark() )
1001cdf0e10cSrcweir // return sal_False;
1002cdf0e10cSrcweir sal_Bool bChg = sal_False;
1003cdf0e10cSrcweir if( pPam->GetPoint() == pPam->End())
1004cdf0e10cSrcweir {
1005cdf0e10cSrcweir bChg = sal_True;
1006cdf0e10cSrcweir pPam->Exchange();
1007cdf0e10cSrcweir }
1008cdf0e10cSrcweir SwNode* pNd;
1009cdf0e10cSrcweir if( pPam->GetPoint()->nNode.GetIndex() -1 ==
1010cdf0e10cSrcweir ( pNd = pPam->GetNode())->StartOfSectionIndex() &&
1011cdf0e10cSrcweir !pPam->GetPoint()->nContent.GetIndex() &&
1012cdf0e10cSrcweir pPam->GetMark()->nNode.GetIndex() + 1 ==
1013cdf0e10cSrcweir pNd->EndOfSectionIndex())
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir SwNodeIndex aIdx( *pNd->EndOfSectionNode(), -1 );
1016cdf0e10cSrcweir SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
1017cdf0e10cSrcweir if( !pCNd )
1018cdf0e10cSrcweir {
1019cdf0e10cSrcweir pCNd = GetDoc()->GetNodes().GoPrevious( &aIdx );
1020cdf0e10cSrcweir ASSERT( pCNd, "kein ContentNode in der Box ??" );
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir if( pPam->GetMark()->nContent == pCNd->Len() )
1023cdf0e10cSrcweir {
1024cdf0e10cSrcweir if( bChg )
1025cdf0e10cSrcweir pPam->Exchange();
1026cdf0e10cSrcweir return sal_True;
1027cdf0e10cSrcweir }
1028cdf0e10cSrcweir }
1029cdf0e10cSrcweir if( bChg )
1030cdf0e10cSrcweir pPam->Exchange();
1031cdf0e10cSrcweir return sal_False;
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir
1034cdf0e10cSrcweir /***********************************************************************
1035cdf0e10cSrcweir #* Class : SwFEShell
1036cdf0e10cSrcweir #* Methoden : ProtectCells(), UnProtectCells()
1037cdf0e10cSrcweir #* Datum : MA 20. Jul. 93
1038cdf0e10cSrcweir #* Update : JP 25. Sep. 93
1039cdf0e10cSrcweir #***********************************************************************/
ProtectCells()1040cdf0e10cSrcweir void SwFEShell::ProtectCells()
1041cdf0e10cSrcweir {
1042cdf0e10cSrcweir SvxProtectItem aProt( RES_PROTECT );
1043cdf0e10cSrcweir aProt.SetCntntProtect( sal_True );
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir SET_CURR_SHELL( this );
1046cdf0e10cSrcweir StartAllAction();
1047cdf0e10cSrcweir
1048cdf0e10cSrcweir GetDoc()->SetBoxAttr( *getShellCrsr( false ), aProt );
1049cdf0e10cSrcweir
1050cdf0e10cSrcweir if( !IsCrsrReadonly() )
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir if( IsTableMode() )
1053cdf0e10cSrcweir ClearMark();
1054cdf0e10cSrcweir ParkCursorInTab();
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir EndAllActionAndCall();
1057cdf0e10cSrcweir }
1058cdf0e10cSrcweir
1059cdf0e10cSrcweir // die Tabellenselektion aufheben
UnProtectCells()1060cdf0e10cSrcweir void SwFEShell::UnProtectCells()
1061cdf0e10cSrcweir {
1062cdf0e10cSrcweir SET_CURR_SHELL( this );
1063cdf0e10cSrcweir StartAllAction();
1064cdf0e10cSrcweir
1065cdf0e10cSrcweir SwSelBoxes aBoxes;
1066cdf0e10cSrcweir if( IsTableMode() )
1067cdf0e10cSrcweir ::GetTblSelCrs( *this, aBoxes );
1068cdf0e10cSrcweir else
1069cdf0e10cSrcweir {
1070cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
1071cdf0e10cSrcweir do {
1072cdf0e10cSrcweir pFrm = pFrm->GetUpper();
1073cdf0e10cSrcweir } while ( pFrm && !pFrm->IsCellFrm() );
1074cdf0e10cSrcweir if( pFrm )
1075cdf0e10cSrcweir {
1076cdf0e10cSrcweir SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox();
1077cdf0e10cSrcweir aBoxes.Insert( pBox );
1078cdf0e10cSrcweir }
1079cdf0e10cSrcweir }
1080cdf0e10cSrcweir
1081cdf0e10cSrcweir if( aBoxes.Count() )
1082cdf0e10cSrcweir GetDoc()->UnProtectCells( aBoxes );
1083cdf0e10cSrcweir
1084cdf0e10cSrcweir EndAllActionAndCall();
1085cdf0e10cSrcweir }
1086cdf0e10cSrcweir
UnProtectTbls()1087cdf0e10cSrcweir void SwFEShell::UnProtectTbls()
1088cdf0e10cSrcweir {
1089cdf0e10cSrcweir SET_CURR_SHELL( this );
1090cdf0e10cSrcweir StartAllAction();
1091cdf0e10cSrcweir GetDoc()->UnProtectTbls( *GetCrsr() );
1092cdf0e10cSrcweir EndAllActionAndCall();
1093cdf0e10cSrcweir }
1094cdf0e10cSrcweir
HasTblAnyProtection(const String * pTblName,sal_Bool * pFullTblProtection)1095cdf0e10cSrcweir sal_Bool SwFEShell::HasTblAnyProtection( const String* pTblName,
1096cdf0e10cSrcweir sal_Bool* pFullTblProtection )
1097cdf0e10cSrcweir {
1098cdf0e10cSrcweir return GetDoc()->HasTblAnyProtection( GetCrsr()->GetPoint(), pTblName,
1099cdf0e10cSrcweir pFullTblProtection );
1100cdf0e10cSrcweir }
1101cdf0e10cSrcweir
CanUnProtectCells() const1102cdf0e10cSrcweir sal_Bool SwFEShell::CanUnProtectCells() const
1103cdf0e10cSrcweir {
1104cdf0e10cSrcweir sal_Bool bUnProtectAvailable = sal_False;
1105cdf0e10cSrcweir const SwTableNode *pTblNd = IsCrsrInTbl();
1106cdf0e10cSrcweir if( pTblNd && !pTblNd->IsProtect() )
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir SwSelBoxes aBoxes;
1109cdf0e10cSrcweir if( IsTableMode() )
1110cdf0e10cSrcweir ::GetTblSelCrs( *this, aBoxes );
1111cdf0e10cSrcweir else
1112cdf0e10cSrcweir {
1113cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
1114cdf0e10cSrcweir do {
1115cdf0e10cSrcweir pFrm = pFrm->GetUpper();
1116cdf0e10cSrcweir } while ( pFrm && !pFrm->IsCellFrm() );
1117cdf0e10cSrcweir if( pFrm )
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox();
1120cdf0e10cSrcweir aBoxes.Insert( pBox );
1121cdf0e10cSrcweir }
1122cdf0e10cSrcweir }
1123cdf0e10cSrcweir if( aBoxes.Count() )
1124cdf0e10cSrcweir bUnProtectAvailable = ::HasProtectedCells( aBoxes );
1125cdf0e10cSrcweir }
1126cdf0e10cSrcweir return bUnProtectAvailable;
1127cdf0e10cSrcweir }
1128cdf0e10cSrcweir
1129cdf0e10cSrcweir /***********************************************************************
1130cdf0e10cSrcweir #* Class : SwFEShell
1131cdf0e10cSrcweir #* Methoden : GetRowsToRepeat(), SetRowsToRepeat()
1132cdf0e10cSrcweir #***********************************************************************/
GetRowsToRepeat() const1133cdf0e10cSrcweir sal_uInt16 SwFEShell::GetRowsToRepeat() const
1134cdf0e10cSrcweir {
1135cdf0e10cSrcweir const SwFrm *pFrm = GetCurrFrm();
1136cdf0e10cSrcweir const SwTabFrm *pTab = pFrm ? pFrm->FindTabFrm() : 0;
1137cdf0e10cSrcweir if( pTab )
1138cdf0e10cSrcweir return pTab->GetTable()->GetRowsToRepeat();
1139cdf0e10cSrcweir return 0;
1140cdf0e10cSrcweir }
1141cdf0e10cSrcweir
SetRowsToRepeat(sal_uInt16 nSet)1142cdf0e10cSrcweir void SwFEShell::SetRowsToRepeat( sal_uInt16 nSet )
1143cdf0e10cSrcweir {
1144cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
1145cdf0e10cSrcweir SwTabFrm *pTab = pFrm ? pFrm->FindTabFrm() : 0;
1146cdf0e10cSrcweir if( pTab && pTab->GetTable()->GetRowsToRepeat() != nSet )
1147cdf0e10cSrcweir {
1148*8ef2f12bSOliver-Rainer Wittmann SwWait aWait( *GetDoc()->GetDocShell(), true );
1149cdf0e10cSrcweir SET_CURR_SHELL( this );
1150cdf0e10cSrcweir StartAllAction();
1151cdf0e10cSrcweir GetDoc()->SetRowsToRepeat( *pTab->GetTable(), nSet );
1152cdf0e10cSrcweir EndAllActionAndCall();
1153cdf0e10cSrcweir }
1154cdf0e10cSrcweir }
1155cdf0e10cSrcweir /*-- 30.06.2004 08:46:35---------------------------------------------------
1156cdf0e10cSrcweir returns the number of rows consecutively selected from top
1157cdf0e10cSrcweir -----------------------------------------------------------------------*/
lcl_GetRowNumber(const SwPosition & rPos)1158cdf0e10cSrcweir sal_uInt16 lcl_GetRowNumber( const SwPosition& rPos )
1159cdf0e10cSrcweir {
1160cdf0e10cSrcweir sal_uInt16 nRet = USHRT_MAX;
1161cdf0e10cSrcweir Point aTmpPt;
1162cdf0e10cSrcweir const SwCntntNode *pNd;
1163cdf0e10cSrcweir const SwCntntFrm *pFrm;
1164cdf0e10cSrcweir
1165cdf0e10cSrcweir if( 0 != ( pNd = rPos.nNode.GetNode().GetCntntNode() ))
1166cdf0e10cSrcweir pFrm = pNd->getLayoutFrm( pNd->GetDoc()->GetCurrentLayout(), &aTmpPt, &rPos, sal_False );
1167cdf0e10cSrcweir else
1168cdf0e10cSrcweir pFrm = 0;
1169cdf0e10cSrcweir
1170cdf0e10cSrcweir if ( pFrm && pFrm->IsInTab() )
1171cdf0e10cSrcweir {
1172cdf0e10cSrcweir const SwFrm* pRow = pFrm->GetUpper();
1173cdf0e10cSrcweir while ( !pRow->GetUpper()->IsTabFrm() )
1174cdf0e10cSrcweir pRow = pRow->GetUpper();
1175cdf0e10cSrcweir
1176cdf0e10cSrcweir const SwTabFrm* pTabFrm = (const SwTabFrm*)pRow->GetUpper();
1177cdf0e10cSrcweir const SwTableLine* pTabLine = static_cast<const SwRowFrm*>(pRow)->GetTabLine();
1178cdf0e10cSrcweir
1179cdf0e10cSrcweir sal_uInt16 nI = 0;
1180cdf0e10cSrcweir while ( nI < pTabFrm->GetTable()->GetTabLines().Count() )
1181cdf0e10cSrcweir {
1182cdf0e10cSrcweir if ( pTabFrm->GetTable()->GetTabLines()[ nI ] == pTabLine )
1183cdf0e10cSrcweir {
1184cdf0e10cSrcweir nRet = nI;
1185cdf0e10cSrcweir break;
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir ++nI;
1188cdf0e10cSrcweir }
1189cdf0e10cSrcweir }
1190cdf0e10cSrcweir
1191cdf0e10cSrcweir return nRet;
1192cdf0e10cSrcweir }
GetRowSelectionFromTop() const1193cdf0e10cSrcweir sal_uInt16 SwFEShell::GetRowSelectionFromTop() const
1194cdf0e10cSrcweir {
1195cdf0e10cSrcweir sal_uInt16 nRet = 0;
1196cdf0e10cSrcweir const SwPaM* pPaM = IsTableMode() ? GetTableCrsr() : _GetCrsr();
1197cdf0e10cSrcweir const sal_uInt16 nPtLine = lcl_GetRowNumber( *pPaM->GetPoint() );
1198cdf0e10cSrcweir
1199cdf0e10cSrcweir if ( !IsTableMode() )
1200cdf0e10cSrcweir {
1201cdf0e10cSrcweir nRet = 0 == nPtLine ? 1 : 0;
1202cdf0e10cSrcweir }
1203cdf0e10cSrcweir else
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir const sal_uInt16 nMkLine = lcl_GetRowNumber( *pPaM->GetMark() );
1206cdf0e10cSrcweir
1207cdf0e10cSrcweir if ( ( nPtLine == 0 && nMkLine != USHRT_MAX ) ||
1208cdf0e10cSrcweir ( nMkLine == 0 && nPtLine != USHRT_MAX ) )
1209cdf0e10cSrcweir {
1210cdf0e10cSrcweir nRet = Max( nPtLine, nMkLine ) + 1;
1211cdf0e10cSrcweir }
1212cdf0e10cSrcweir }
1213cdf0e10cSrcweir
1214cdf0e10cSrcweir return nRet;
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir
1217cdf0e10cSrcweir /*
1218cdf0e10cSrcweir * 1. case: bRepeat = true
1219cdf0e10cSrcweir * returns true if the current frame is located inside a table headline in
1220cdf0e10cSrcweir * a follow frame
1221cdf0e10cSrcweir *
1222cdf0e10cSrcweir * 2. case: bRepeat = false
1223cdf0e10cSrcweir * returns true if the current frame is localed inside a table headline OR
1224cdf0e10cSrcweir * inside the first line of a table!!!
1225cdf0e10cSrcweir */
CheckHeadline(bool bRepeat) const1226cdf0e10cSrcweir sal_Bool SwFEShell::CheckHeadline( bool bRepeat ) const
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir sal_Bool bRet = sal_False;
1229cdf0e10cSrcweir if ( !IsTableMode() )
1230cdf0e10cSrcweir {
1231cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm(); // DONE MULTIIHEADER
1232cdf0e10cSrcweir if ( pFrm && pFrm->IsInTab() )
1233cdf0e10cSrcweir {
1234cdf0e10cSrcweir SwTabFrm* pTab = pFrm->FindTabFrm();
1235cdf0e10cSrcweir if ( bRepeat )
1236cdf0e10cSrcweir {
1237cdf0e10cSrcweir bRet = pTab->IsFollow() && pTab->IsInHeadline( *pFrm );
1238cdf0e10cSrcweir }
1239cdf0e10cSrcweir else
1240cdf0e10cSrcweir {
1241cdf0e10cSrcweir bRet = ((SwLayoutFrm*)pTab->Lower())->IsAnLower( pFrm ) ||
1242cdf0e10cSrcweir pTab->IsInHeadline( *pFrm );
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir }
1245cdf0e10cSrcweir }
1246cdf0e10cSrcweir return bRet;
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir
1249cdf0e10cSrcweir /***********************************************************************
1250cdf0e10cSrcweir #* Class : SwFEShell
1251cdf0e10cSrcweir #* Methoden : AdjustCellWidth()
1252cdf0e10cSrcweir #* Datum : MA 20. Feb. 95
1253cdf0e10cSrcweir #* Update : MA 27. Jul. 95
1254cdf0e10cSrcweir #***********************************************************************/
1255cdf0e10cSrcweir
AdjustCellWidth(sal_Bool bBalance)1256cdf0e10cSrcweir void SwFEShell::AdjustCellWidth( sal_Bool bBalance )
1257cdf0e10cSrcweir {
1258cdf0e10cSrcweir SET_CURR_SHELL( this );
1259cdf0e10cSrcweir StartAllAction();
1260cdf0e10cSrcweir
1261cdf0e10cSrcweir //WarteCrsr immer einschalten, weil sich im vorraus nicht so recht
1262cdf0e10cSrcweir //ermitteln laesst wieviel Inhalt betroffen ist.
1263cdf0e10cSrcweir TblWait aWait( USHRT_MAX, 0, *GetDoc()->GetDocShell() );
1264cdf0e10cSrcweir
1265cdf0e10cSrcweir GetDoc()->AdjustCellWidth( *getShellCrsr( false ), bBalance );
1266cdf0e10cSrcweir EndAllActionAndCall();
1267cdf0e10cSrcweir }
1268cdf0e10cSrcweir
IsAdjustCellWidthAllowed(sal_Bool bBalance) const1269cdf0e10cSrcweir sal_Bool SwFEShell::IsAdjustCellWidthAllowed( sal_Bool bBalance ) const
1270cdf0e10cSrcweir {
1271cdf0e10cSrcweir //Es muss mindestens eine Zelle mit Inhalt in der Selektion enthalten
1272cdf0e10cSrcweir //sein.
1273cdf0e10cSrcweir
1274cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
1275cdf0e10cSrcweir if( !pFrm || !pFrm->IsInTab() )
1276cdf0e10cSrcweir return sal_False;
1277cdf0e10cSrcweir
1278cdf0e10cSrcweir SwSelBoxes aBoxes;
1279cdf0e10cSrcweir ::GetTblSelCrs( *this, aBoxes );
1280cdf0e10cSrcweir
1281cdf0e10cSrcweir if ( bBalance )
1282cdf0e10cSrcweir return aBoxes.Count() > 1;
1283cdf0e10cSrcweir
1284cdf0e10cSrcweir if ( !aBoxes.Count() )
1285cdf0e10cSrcweir {
1286cdf0e10cSrcweir do
1287cdf0e10cSrcweir { pFrm = pFrm->GetUpper();
1288cdf0e10cSrcweir } while ( !pFrm->IsCellFrm() );
1289cdf0e10cSrcweir SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox();
1290cdf0e10cSrcweir aBoxes.Insert( pBox );
1291cdf0e10cSrcweir }
1292cdf0e10cSrcweir
1293cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < aBoxes.Count(); ++i )
1294cdf0e10cSrcweir {
1295cdf0e10cSrcweir SwTableBox *pBox = aBoxes[i];
1296cdf0e10cSrcweir if ( pBox->GetSttNd() )
1297cdf0e10cSrcweir {
1298cdf0e10cSrcweir SwNodeIndex aIdx( *pBox->GetSttNd(), 1 );
1299cdf0e10cSrcweir SwTxtNode* pCNd = aIdx.GetNode().GetTxtNode();
1300cdf0e10cSrcweir if( !pCNd )
1301cdf0e10cSrcweir pCNd = (SwTxtNode*)GetDoc()->GetNodes().GoNext( &aIdx );
1302cdf0e10cSrcweir
1303cdf0e10cSrcweir while ( pCNd )
1304cdf0e10cSrcweir {
1305cdf0e10cSrcweir if ( pCNd->GetTxt().Len() )
1306cdf0e10cSrcweir return sal_True;
1307cdf0e10cSrcweir ++aIdx;
1308cdf0e10cSrcweir pCNd = aIdx.GetNode().GetTxtNode();
1309cdf0e10cSrcweir }
1310cdf0e10cSrcweir }
1311cdf0e10cSrcweir }
1312cdf0e10cSrcweir return sal_False;
1313cdf0e10cSrcweir }
1314cdf0e10cSrcweir
1315cdf0e10cSrcweir // AutoFormat fuer die Tabelle/TabellenSelection
SetTableAutoFmt(const SwTableAutoFmt & rNew)1316cdf0e10cSrcweir sal_Bool SwFEShell::SetTableAutoFmt( const SwTableAutoFmt& rNew )
1317cdf0e10cSrcweir {
1318cdf0e10cSrcweir SwTableNode *pTblNd = (SwTableNode*)IsCrsrInTbl();
1319cdf0e10cSrcweir if( !pTblNd || pTblNd->GetTable().IsTblComplex() )
1320cdf0e10cSrcweir return sal_False;
1321cdf0e10cSrcweir
1322cdf0e10cSrcweir SwSelBoxes aBoxes;
1323cdf0e10cSrcweir
1324cdf0e10cSrcweir if ( !IsTableMode() ) // falls Crsr noch nicht akt. sind
1325cdf0e10cSrcweir GetCrsr();
1326cdf0e10cSrcweir
1327cdf0e10cSrcweir // gesamte Tabelle oder nur auf die akt. Selektion
1328cdf0e10cSrcweir if( IsTableMode() )
1329cdf0e10cSrcweir ::GetTblSelCrs( *this, aBoxes );
1330cdf0e10cSrcweir else
1331cdf0e10cSrcweir {
1332cdf0e10cSrcweir const SwTableSortBoxes& rTBoxes = pTblNd->GetTable().GetTabSortBoxes();
1333cdf0e10cSrcweir for( sal_uInt16 n = 0; n < rTBoxes.Count(); ++n )
1334cdf0e10cSrcweir {
1335cdf0e10cSrcweir SwTableBox* pBox = rTBoxes[ n ];
1336cdf0e10cSrcweir aBoxes.Insert( pBox );
1337cdf0e10cSrcweir }
1338cdf0e10cSrcweir }
1339cdf0e10cSrcweir
1340cdf0e10cSrcweir sal_Bool bRet;
1341cdf0e10cSrcweir if( aBoxes.Count() )
1342cdf0e10cSrcweir {
1343cdf0e10cSrcweir SET_CURR_SHELL( this );
1344cdf0e10cSrcweir StartAllAction();
1345cdf0e10cSrcweir bRet = GetDoc()->SetTableAutoFmt( aBoxes, rNew );
1346cdf0e10cSrcweir DELETEZ( pLastCols );
1347cdf0e10cSrcweir DELETEZ( pLastRows );
1348cdf0e10cSrcweir EndAllActionAndCall();
1349cdf0e10cSrcweir }
1350cdf0e10cSrcweir else
1351cdf0e10cSrcweir bRet = sal_False;
1352cdf0e10cSrcweir return bRet;
1353cdf0e10cSrcweir }
1354cdf0e10cSrcweir
GetTableAutoFmt(SwTableAutoFmt & rGet)1355cdf0e10cSrcweir sal_Bool SwFEShell::GetTableAutoFmt( SwTableAutoFmt& rGet )
1356cdf0e10cSrcweir {
1357cdf0e10cSrcweir const SwTableNode *pTblNd = IsCrsrInTbl();
1358cdf0e10cSrcweir if( !pTblNd || pTblNd->GetTable().IsTblComplex() )
1359cdf0e10cSrcweir return sal_False;
1360cdf0e10cSrcweir
1361cdf0e10cSrcweir SwSelBoxes aBoxes;
1362cdf0e10cSrcweir
1363cdf0e10cSrcweir if ( !IsTableMode() ) // falls Crsr noch nicht akt. sind
1364cdf0e10cSrcweir GetCrsr();
1365cdf0e10cSrcweir
1366cdf0e10cSrcweir // gesamte Tabelle oder nur auf die akt. Selektion
1367cdf0e10cSrcweir if( IsTableMode() )
1368cdf0e10cSrcweir ::GetTblSelCrs( *this, aBoxes );
1369cdf0e10cSrcweir else
1370cdf0e10cSrcweir {
1371cdf0e10cSrcweir const SwTableSortBoxes& rTBoxes = pTblNd->GetTable().GetTabSortBoxes();
1372cdf0e10cSrcweir for( sal_uInt16 n = 0; n < rTBoxes.Count(); ++n )
1373cdf0e10cSrcweir {
1374cdf0e10cSrcweir SwTableBox* pBox = rTBoxes[ n ];
1375cdf0e10cSrcweir aBoxes.Insert( pBox );
1376cdf0e10cSrcweir }
1377cdf0e10cSrcweir }
1378cdf0e10cSrcweir
1379cdf0e10cSrcweir return GetDoc()->GetTableAutoFmt( aBoxes, rGet );
1380cdf0e10cSrcweir }
1381cdf0e10cSrcweir
1382cdf0e10cSrcweir /***********************************************************************
1383cdf0e10cSrcweir #* Class : SwFEShell
1384cdf0e10cSrcweir #* Methoden : DeleteTblSel()
1385cdf0e10cSrcweir #* Datum : MA 03. May. 93
1386cdf0e10cSrcweir #* Update : MA 19. Apr. 95
1387cdf0e10cSrcweir #***********************************************************************/
DeleteTblSel()1388cdf0e10cSrcweir sal_Bool SwFEShell::DeleteTblSel()
1389cdf0e10cSrcweir {
1390cdf0e10cSrcweir // pruefe ob vom aktuellen Crsr der SPoint/Mark in einer Tabelle stehen
1391cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
1392cdf0e10cSrcweir if( !pFrm || !pFrm->IsInTab() )
1393cdf0e10cSrcweir return sal_False;
1394cdf0e10cSrcweir
1395cdf0e10cSrcweir if( pFrm->ImplFindTabFrm()->GetTable()->ISA( SwDDETable ))
1396cdf0e10cSrcweir {
1397cdf0e10cSrcweir ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
1398cdf0e10cSrcweir ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
1399cdf0e10cSrcweir return sal_False;
1400cdf0e10cSrcweir }
1401cdf0e10cSrcweir
1402cdf0e10cSrcweir SET_CURR_SHELL( this );
1403cdf0e10cSrcweir StartAllAction();
1404cdf0e10cSrcweir
1405cdf0e10cSrcweir // lasse ueber das Layout die Boxen suchen
1406cdf0e10cSrcweir sal_Bool bRet;
1407cdf0e10cSrcweir SwSelBoxes aBoxes;
1408cdf0e10cSrcweir GetTblSelCrs( *this, aBoxes );
1409cdf0e10cSrcweir if( aBoxes.Count() )
1410cdf0e10cSrcweir {
1411cdf0e10cSrcweir TblWait( aBoxes.Count(), pFrm, *GetDoc()->GetDocShell() );
1412cdf0e10cSrcweir
1413cdf0e10cSrcweir // die Crsr muessen noch aus dem Loesch Bereich entfernt
1414cdf0e10cSrcweir // werden. Setze sie immer hinter/auf die Tabelle; ueber die
1415cdf0e10cSrcweir // Dokument-Position werden sie dann immer an die alte Position gesetzt.
1416cdf0e10cSrcweir while( !pFrm->IsCellFrm() )
1417cdf0e10cSrcweir pFrm = pFrm->GetUpper();
1418cdf0e10cSrcweir ParkCrsr( SwNodeIndex( *((SwCellFrm*)pFrm)->GetTabBox()->GetSttNd() ));
1419cdf0e10cSrcweir
1420cdf0e10cSrcweir bRet = GetDoc()->DeleteRowCol( aBoxes );
1421cdf0e10cSrcweir
1422cdf0e10cSrcweir DELETEZ( pLastCols );
1423cdf0e10cSrcweir DELETEZ( pLastRows );
1424cdf0e10cSrcweir }
1425cdf0e10cSrcweir else
1426cdf0e10cSrcweir bRet = sal_False;
1427cdf0e10cSrcweir EndAllActionAndCall();
1428cdf0e10cSrcweir return bRet;
1429cdf0e10cSrcweir }
1430cdf0e10cSrcweir
1431cdf0e10cSrcweir /*************************************************************************
1432cdf0e10cSrcweir |*
1433cdf0e10cSrcweir |* SwFEShell::GetCurTabColNum()
1434cdf0e10cSrcweir |*
1435cdf0e10cSrcweir |* Ersterstellung MA 03. Feb. 95
1436cdf0e10cSrcweir |* Letzte Aenderung MA 21. May. 95
1437cdf0e10cSrcweir |
1438cdf0e10cSrcweir |*************************************************************************/
GetCurTabColNum() const1439cdf0e10cSrcweir sal_uInt16 SwFEShell::GetCurTabColNum() const
1440cdf0e10cSrcweir {
1441cdf0e10cSrcweir //!!!GetCurMouseTabColNum() mitpflegen!!!!
1442cdf0e10cSrcweir sal_uInt16 nRet = 0;
1443cdf0e10cSrcweir
1444cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
1445cdf0e10cSrcweir ASSERT( pFrm, "Crsr geparkt?" );
1446cdf0e10cSrcweir
1447cdf0e10cSrcweir // pruefe ob vom aktuellen Crsr der SPoint/Mark in einer Tabelle stehen
1448cdf0e10cSrcweir if( pFrm && pFrm->IsInTab() )
1449cdf0e10cSrcweir {
1450cdf0e10cSrcweir do { // JP 26.09.95: warum mit dem CntntFrame und nicht mit
1451cdf0e10cSrcweir // dem CellFrame vergleichen????
1452cdf0e10cSrcweir pFrm = pFrm->GetUpper();
1453cdf0e10cSrcweir } while ( !pFrm->IsCellFrm() );
1454cdf0e10cSrcweir SWRECTFN( pFrm )
1455cdf0e10cSrcweir
1456cdf0e10cSrcweir const SwPageFrm* pPage = pFrm->FindPageFrm();
1457cdf0e10cSrcweir
1458cdf0e10cSrcweir //TabCols besorgen, den nur ueber diese erreichen wir die Position.
1459cdf0e10cSrcweir SwTabCols aTabCols;
1460cdf0e10cSrcweir GetTabCols( aTabCols );
1461cdf0e10cSrcweir
1462cdf0e10cSrcweir if( pFrm->FindTabFrm()->IsRightToLeft() )
1463cdf0e10cSrcweir {
1464cdf0e10cSrcweir long nX = (pFrm->Frm().*fnRect->fnGetRight)() - (pPage->Frm().*fnRect->fnGetLeft)();
1465cdf0e10cSrcweir
1466cdf0e10cSrcweir const long nRight = aTabCols.GetLeftMin() + aTabCols.GetRight();;
1467cdf0e10cSrcweir
1468cdf0e10cSrcweir if ( !::IsSame( nX, nRight ) )
1469cdf0e10cSrcweir {
1470cdf0e10cSrcweir nX = nRight - nX + aTabCols.GetLeft();
1471cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i )
1472cdf0e10cSrcweir if ( ::IsSame( nX, aTabCols[i] ) )
1473cdf0e10cSrcweir {
1474cdf0e10cSrcweir nRet = i + 1;
1475cdf0e10cSrcweir break;
1476cdf0e10cSrcweir }
1477cdf0e10cSrcweir }
1478cdf0e10cSrcweir }
1479cdf0e10cSrcweir else
1480cdf0e10cSrcweir {
1481cdf0e10cSrcweir const long nX = (pFrm->Frm().*fnRect->fnGetLeft)() -
1482cdf0e10cSrcweir (pPage->Frm().*fnRect->fnGetLeft)();
1483cdf0e10cSrcweir
1484cdf0e10cSrcweir const long nLeft = aTabCols.GetLeftMin();
1485cdf0e10cSrcweir
1486cdf0e10cSrcweir if ( !::IsSame( nX, nLeft + aTabCols.GetLeft() ) )
1487cdf0e10cSrcweir {
1488cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i )
1489cdf0e10cSrcweir if ( ::IsSame( nX, nLeft + aTabCols[i] ) )
1490cdf0e10cSrcweir {
1491cdf0e10cSrcweir nRet = i + 1;
1492cdf0e10cSrcweir break;
1493cdf0e10cSrcweir }
1494cdf0e10cSrcweir }
1495cdf0e10cSrcweir }
1496cdf0e10cSrcweir }
1497cdf0e10cSrcweir return nRet;
1498cdf0e10cSrcweir }
1499cdf0e10cSrcweir
1500cdf0e10cSrcweir /*************************************************************************
1501cdf0e10cSrcweir |*
1502cdf0e10cSrcweir |* SwFEShell::GetBox()
1503cdf0e10cSrcweir |*
1504cdf0e10cSrcweir |* Ersterstellung MA 22. Jun. 95
1505cdf0e10cSrcweir |* Letzte Aenderung MA 21. Nov. 96
1506cdf0e10cSrcweir |*
1507cdf0e10cSrcweir |*************************************************************************/
1508cdf0e10cSrcweir
lcl_FindFrmInTab(const SwLayoutFrm * pLay,const Point & rPt,SwTwips nFuzzy)1509cdf0e10cSrcweir const SwFrm *lcl_FindFrmInTab( const SwLayoutFrm *pLay, const Point &rPt, SwTwips nFuzzy )
1510cdf0e10cSrcweir {
1511cdf0e10cSrcweir const SwFrm *pFrm = pLay->Lower();
1512cdf0e10cSrcweir
1513cdf0e10cSrcweir while( pFrm && pLay->IsAnLower( pFrm ) )
1514cdf0e10cSrcweir {
1515cdf0e10cSrcweir if ( pFrm->Frm().IsNear( rPt, nFuzzy ) )
1516cdf0e10cSrcweir {
1517cdf0e10cSrcweir if ( pFrm->IsLayoutFrm() )
1518cdf0e10cSrcweir {
1519cdf0e10cSrcweir const SwFrm *pTmp = ::lcl_FindFrmInTab( (SwLayoutFrm*)pFrm, rPt, nFuzzy );
1520cdf0e10cSrcweir if ( pTmp )
1521cdf0e10cSrcweir return pTmp;
1522cdf0e10cSrcweir }
1523cdf0e10cSrcweir
1524cdf0e10cSrcweir return pFrm;
1525cdf0e10cSrcweir }
1526cdf0e10cSrcweir
1527cdf0e10cSrcweir pFrm = pFrm->FindNext();
1528cdf0e10cSrcweir }
1529cdf0e10cSrcweir
1530cdf0e10cSrcweir return 0;
1531cdf0e10cSrcweir }
1532cdf0e10cSrcweir
lcl_FindFrm(const SwLayoutFrm * pLay,const Point & rPt,SwTwips nFuzzy,bool * pbRow,bool * pbCol)1533cdf0e10cSrcweir const SwCellFrm *lcl_FindFrm( const SwLayoutFrm *pLay, const Point &rPt,
1534cdf0e10cSrcweir SwTwips nFuzzy, bool* pbRow, bool* pbCol )
1535cdf0e10cSrcweir {
1536cdf0e10cSrcweir // bMouseMoveRowCols :
1537cdf0e10cSrcweir // Method is called for
1538cdf0e10cSrcweir // - Moving columns/rows with the mouse or
1539cdf0e10cSrcweir // - Enhanced table selection
1540cdf0e10cSrcweir const bool bMouseMoveRowCols = 0 == pbCol;
1541cdf0e10cSrcweir
1542cdf0e10cSrcweir bool bCloseToRow = false;
1543cdf0e10cSrcweir bool bCloseToCol = false;
1544cdf0e10cSrcweir
1545cdf0e10cSrcweir const SwFrm *pFrm = pLay->ContainsCntnt();
1546cdf0e10cSrcweir const SwFrm* pRet = 0;
1547cdf0e10cSrcweir
1548cdf0e10cSrcweir if ( pFrm )
1549cdf0e10cSrcweir {
1550cdf0e10cSrcweir do
1551cdf0e10cSrcweir {
1552cdf0e10cSrcweir if ( pFrm->IsInTab() )
1553cdf0e10cSrcweir pFrm = ((SwFrm*)pFrm)->ImplFindTabFrm();
1554cdf0e10cSrcweir
1555cdf0e10cSrcweir if ( pFrm->IsTabFrm() )
1556cdf0e10cSrcweir {
1557cdf0e10cSrcweir Point aPt( rPt );
1558cdf0e10cSrcweir bool bSearchForFrmInTab = true;
1559cdf0e10cSrcweir SwTwips nTmpFuzzy = nFuzzy;
1560cdf0e10cSrcweir
1561cdf0e10cSrcweir if ( !bMouseMoveRowCols )
1562cdf0e10cSrcweir {
1563cdf0e10cSrcweir // We ignore nested tables for the enhanced table selection:
1564cdf0e10cSrcweir while ( pFrm->GetUpper()->IsInTab() )
1565cdf0e10cSrcweir pFrm = pFrm->GetUpper()->FindTabFrm();
1566cdf0e10cSrcweir
1567cdf0e10cSrcweir // We first check if the given point is 'close' to the left or top
1568cdf0e10cSrcweir // border of the table frame:
1569cdf0e10cSrcweir ASSERT( pFrm, "Nested table frame without outer table" )
1570cdf0e10cSrcweir SWRECTFN( pFrm )
1571cdf0e10cSrcweir const bool bRTL = pFrm->IsRightToLeft();
1572cdf0e10cSrcweir
1573cdf0e10cSrcweir SwRect aTabRect = pFrm->Prt();
1574cdf0e10cSrcweir aTabRect.Pos() += pFrm->Frm().Pos();
1575cdf0e10cSrcweir
1576cdf0e10cSrcweir const SwTwips nLeft = bRTL ?
1577cdf0e10cSrcweir (aTabRect.*fnRect->fnGetRight)() :
1578cdf0e10cSrcweir (aTabRect.*fnRect->fnGetLeft)();
1579cdf0e10cSrcweir const SwTwips nTop = (aTabRect.*fnRect->fnGetTop)();
1580cdf0e10cSrcweir
1581cdf0e10cSrcweir SwTwips& rPointX = bVert ? aPt.Y() : aPt.X();
1582cdf0e10cSrcweir SwTwips& rPointY = bVert ? aPt.X() : aPt.Y();
1583cdf0e10cSrcweir
1584cdf0e10cSrcweir const SwTwips nXDiff = (*fnRect->fnXDiff)( nLeft, rPointX ) * ( bRTL ? (-1) : 1 );
1585cdf0e10cSrcweir const SwTwips nYDiff = (*fnRect->fnYDiff)( nTop, rPointY );
1586cdf0e10cSrcweir
1587cdf0e10cSrcweir bCloseToRow = nXDiff >= 0 && nXDiff < nFuzzy;
1588cdf0e10cSrcweir bCloseToCol = nYDiff >= 0 && nYDiff < nFuzzy;
1589cdf0e10cSrcweir
1590cdf0e10cSrcweir if ( bCloseToCol && 2 * nYDiff > nFuzzy )
1591cdf0e10cSrcweir {
1592cdf0e10cSrcweir const SwFrm* pPrev = pFrm->GetPrev();
1593cdf0e10cSrcweir if ( pPrev )
1594cdf0e10cSrcweir {
1595cdf0e10cSrcweir SwRect aPrevRect = pPrev->Prt();
1596cdf0e10cSrcweir aPrevRect.Pos() += pPrev->Frm().Pos();
1597cdf0e10cSrcweir
1598cdf0e10cSrcweir if( aPrevRect.IsInside( rPt ) )
1599cdf0e10cSrcweir {
1600cdf0e10cSrcweir bCloseToCol = false;
1601cdf0e10cSrcweir }
1602cdf0e10cSrcweir }
1603cdf0e10cSrcweir
1604cdf0e10cSrcweir }
1605cdf0e10cSrcweir
1606cdf0e10cSrcweir // If we found the point to be 'close' to the left or top border
1607cdf0e10cSrcweir // of the table frame, we adjust the point to be on that border:
1608cdf0e10cSrcweir if ( bCloseToRow && bCloseToCol )
1609cdf0e10cSrcweir aPt = bRTL ? aTabRect.TopRight() : (aTabRect.*fnRect->fnGetPos)();
1610cdf0e10cSrcweir else if ( bCloseToRow )
1611cdf0e10cSrcweir rPointX = nLeft;
1612cdf0e10cSrcweir else if ( bCloseToCol )
1613cdf0e10cSrcweir rPointY = nTop;
1614cdf0e10cSrcweir
1615cdf0e10cSrcweir if ( !bCloseToRow && !bCloseToCol )
1616cdf0e10cSrcweir bSearchForFrmInTab = false;
1617cdf0e10cSrcweir
1618cdf0e10cSrcweir // Since the point has been adjusted, we call lcl_FindFrmInTab()
1619cdf0e10cSrcweir // with a fuzzy value of 1:
1620cdf0e10cSrcweir nTmpFuzzy = 1;
1621cdf0e10cSrcweir }
1622cdf0e10cSrcweir
1623cdf0e10cSrcweir const SwFrm* pTmp = bSearchForFrmInTab ?
1624cdf0e10cSrcweir ::lcl_FindFrmInTab( (SwLayoutFrm*)pFrm, aPt, nTmpFuzzy ) :
1625cdf0e10cSrcweir 0;
1626cdf0e10cSrcweir
1627cdf0e10cSrcweir if ( pTmp )
1628cdf0e10cSrcweir {
1629cdf0e10cSrcweir pFrm = pTmp;
1630cdf0e10cSrcweir break;
1631cdf0e10cSrcweir }
1632cdf0e10cSrcweir }
1633cdf0e10cSrcweir pFrm = pFrm->FindNextCnt();
1634cdf0e10cSrcweir
1635cdf0e10cSrcweir } while ( pFrm && pLay->IsAnLower( pFrm ) );
1636cdf0e10cSrcweir }
1637cdf0e10cSrcweir
1638cdf0e10cSrcweir if ( pFrm && pFrm->IsInTab() && pLay->IsAnLower( pFrm ) )
1639cdf0e10cSrcweir {
1640cdf0e10cSrcweir do
1641cdf0e10cSrcweir {
1642cdf0e10cSrcweir // We allow mouse drag of table borders within nested tables,
1643cdf0e10cSrcweir // but disallow hotspot selection of nested tables.
1644cdf0e10cSrcweir if ( bMouseMoveRowCols )
1645cdf0e10cSrcweir {
1646cdf0e10cSrcweir // find the next cell frame
1647cdf0e10cSrcweir while ( pFrm && !pFrm->IsCellFrm() )
1648cdf0e10cSrcweir pFrm = pFrm->GetUpper();
1649cdf0e10cSrcweir }
1650cdf0e10cSrcweir else
1651cdf0e10cSrcweir {
1652cdf0e10cSrcweir // find the most upper cell frame:
1653cdf0e10cSrcweir while ( pFrm &&
1654cdf0e10cSrcweir ( !pFrm->IsCellFrm() ||
1655cdf0e10cSrcweir !pFrm->GetUpper()->GetUpper()->IsTabFrm() ||
1656cdf0e10cSrcweir pFrm->GetUpper()->GetUpper()->GetUpper()->IsInTab() ) )
1657cdf0e10cSrcweir pFrm = pFrm->GetUpper();
1658cdf0e10cSrcweir }
1659cdf0e10cSrcweir
1660cdf0e10cSrcweir if ( pFrm ) // Note: this condition should be the same like the while condition!!!
1661cdf0e10cSrcweir {
1662cdf0e10cSrcweir // --> FME 2004-07-30 #i32329# Enhanced table selection
1663cdf0e10cSrcweir // used for hotspot selection of tab/cols/rows
1664cdf0e10cSrcweir if ( !bMouseMoveRowCols )
1665cdf0e10cSrcweir {
1666cdf0e10cSrcweir
1667cdf0e10cSrcweir ASSERT( pbCol && pbRow, "pbCol or pbRow missing" )
1668cdf0e10cSrcweir
1669cdf0e10cSrcweir if ( bCloseToRow || bCloseToCol )
1670cdf0e10cSrcweir {
1671cdf0e10cSrcweir *pbRow = bCloseToRow;
1672cdf0e10cSrcweir *pbCol = bCloseToCol;
1673cdf0e10cSrcweir pRet = pFrm;
1674cdf0e10cSrcweir break;
1675cdf0e10cSrcweir }
1676cdf0e10cSrcweir }
1677cdf0e10cSrcweir // <--
1678cdf0e10cSrcweir else
1679cdf0e10cSrcweir {
1680cdf0e10cSrcweir // used for mouse move of columns/rows
1681cdf0e10cSrcweir const SwTabFrm* pTabFrm = pFrm->FindTabFrm();
1682cdf0e10cSrcweir SwRect aTabRect = pTabFrm->Prt();
1683cdf0e10cSrcweir aTabRect.Pos() += pTabFrm->Frm().Pos();
1684cdf0e10cSrcweir
1685cdf0e10cSrcweir SWRECTFN( pTabFrm )
1686cdf0e10cSrcweir
1687cdf0e10cSrcweir const SwTwips nTabTop = (aTabRect.*fnRect->fnGetTop)();
1688cdf0e10cSrcweir const SwTwips nMouseTop = bVert ? rPt.X() : rPt.Y();
1689cdf0e10cSrcweir
1690cdf0e10cSrcweir // Do not allow to drag upper table border:
1691cdf0e10cSrcweir if ( !::IsSame( nTabTop, nMouseTop ) )
1692cdf0e10cSrcweir {
1693cdf0e10cSrcweir if ( ::IsSame( pFrm->Frm().Left(), rPt.X() ) ||
1694cdf0e10cSrcweir ::IsSame( pFrm->Frm().Right(),rPt.X() ) )
1695cdf0e10cSrcweir {
1696cdf0e10cSrcweir if ( pbRow ) *pbRow = false;
1697cdf0e10cSrcweir pRet = pFrm;
1698cdf0e10cSrcweir break;
1699cdf0e10cSrcweir }
1700cdf0e10cSrcweir if ( ::IsSame( pFrm->Frm().Top(), rPt.Y() ) ||
1701cdf0e10cSrcweir ::IsSame( pFrm->Frm().Bottom(),rPt.Y() ) )
1702cdf0e10cSrcweir {
1703cdf0e10cSrcweir if ( pbRow ) *pbRow = true;
1704cdf0e10cSrcweir pRet = pFrm;
1705cdf0e10cSrcweir break;
1706cdf0e10cSrcweir }
1707cdf0e10cSrcweir }
1708cdf0e10cSrcweir }
1709cdf0e10cSrcweir
1710cdf0e10cSrcweir pFrm = pFrm->GetUpper();
1711cdf0e10cSrcweir }
1712cdf0e10cSrcweir } while ( pFrm );
1713cdf0e10cSrcweir }
1714cdf0e10cSrcweir
1715cdf0e10cSrcweir // robust:
1716cdf0e10cSrcweir ASSERT( !pRet || pRet->IsCellFrm(), "lcl_FindFrm() is supposed to find a cell frame!" )
1717cdf0e10cSrcweir return pRet && pRet->IsCellFrm() ? static_cast<const SwCellFrm*>(pRet) : 0;
1718cdf0e10cSrcweir }
1719cdf0e10cSrcweir
1720cdf0e10cSrcweir //
1721cdf0e10cSrcweir // pbCol = 0 => Used for moving table rows/cols with mouse
1722cdf0e10cSrcweir // pbCol != 0 => Used for selecting table/rows/cols
1723cdf0e10cSrcweir //
1724cdf0e10cSrcweir #define ENHANCED_TABLE_SELECTION_FUZZY 10
1725cdf0e10cSrcweir
GetBox(const Point & rPt,bool * pbRow,bool * pbCol) const1726cdf0e10cSrcweir const SwFrm* SwFEShell::GetBox( const Point &rPt, bool* pbRow, bool* pbCol ) const
1727cdf0e10cSrcweir {
1728cdf0e10cSrcweir const SwPageFrm *pPage = (SwPageFrm*)GetLayout()->Lower();
1729cdf0e10cSrcweir Window* pOutWin = GetWin();
1730cdf0e10cSrcweir SwTwips nFuzzy = COLFUZZY;
1731cdf0e10cSrcweir if( pOutWin )
1732cdf0e10cSrcweir {
1733cdf0e10cSrcweir // --> FME 2004-07-30 #i32329# Enhanced table selection
1734cdf0e10cSrcweir SwTwips nSize = pbCol ? ENHANCED_TABLE_SELECTION_FUZZY : RULER_MOUSE_MARGINWIDTH;
1735cdf0e10cSrcweir // <--
1736cdf0e10cSrcweir Size aTmp( nSize, nSize );
1737cdf0e10cSrcweir aTmp = pOutWin->PixelToLogic( aTmp );
1738cdf0e10cSrcweir nFuzzy = aTmp.Width();
1739cdf0e10cSrcweir }
1740cdf0e10cSrcweir
1741cdf0e10cSrcweir while ( pPage && !pPage->Frm().IsNear( rPt, nFuzzy ) )
1742cdf0e10cSrcweir pPage = (SwPageFrm*)pPage->GetNext();
1743cdf0e10cSrcweir
1744cdf0e10cSrcweir const SwCellFrm *pFrm = 0;
1745cdf0e10cSrcweir if ( pPage )
1746cdf0e10cSrcweir {
1747cdf0e10cSrcweir //Per GetCrsrOfst oder GetCntntPos koennen wir hier die Box leider
1748cdf0e10cSrcweir //nicht suchen. Das wuerde zu einem Performance-Zusammenbruch bei
1749cdf0e10cSrcweir //Dokumenten mit vielen Absaetzen/Tabellen auf einer Seite fuehren
1750cdf0e10cSrcweir //(BrowseMode!)
1751cdf0e10cSrcweir
1752cdf0e10cSrcweir //Erst die Flys checken.
1753cdf0e10cSrcweir if ( pPage->GetSortedObjs() )
1754cdf0e10cSrcweir {
1755cdf0e10cSrcweir for ( sal_uInt16 i = 0; !pFrm && i < pPage->GetSortedObjs()->Count(); ++i )
1756cdf0e10cSrcweir {
1757cdf0e10cSrcweir SwAnchoredObject* pObj = (*pPage->GetSortedObjs())[i];
1758cdf0e10cSrcweir if ( pObj->ISA(SwFlyFrm) )
1759cdf0e10cSrcweir {
1760cdf0e10cSrcweir pFrm = lcl_FindFrm( static_cast<SwFlyFrm*>(pObj),
1761cdf0e10cSrcweir rPt, nFuzzy, pbRow, pbCol );
1762cdf0e10cSrcweir }
1763cdf0e10cSrcweir }
1764cdf0e10cSrcweir }
1765cdf0e10cSrcweir const SwLayoutFrm *pLay = (SwLayoutFrm*)pPage->Lower();
1766cdf0e10cSrcweir while ( pLay && !pFrm )
1767cdf0e10cSrcweir {
1768cdf0e10cSrcweir pFrm = lcl_FindFrm( pLay, rPt, nFuzzy, pbRow, pbCol );
1769cdf0e10cSrcweir pLay = (SwLayoutFrm*)pLay->GetNext();
1770cdf0e10cSrcweir }
1771cdf0e10cSrcweir }
1772cdf0e10cSrcweir return pFrm;
1773cdf0e10cSrcweir }
1774cdf0e10cSrcweir
1775cdf0e10cSrcweir /* Helper function*/
1776cdf0e10cSrcweir /* calculated the distance between Point rC and Line Segment (rA, rB) */
lcl_DistancePoint2Segment(const Point & rA,const Point & rB,const Point & rC)1777cdf0e10cSrcweir double lcl_DistancePoint2Segment( const Point& rA, const Point& rB, const Point& rC )
1778cdf0e10cSrcweir {
1779cdf0e10cSrcweir double nRet = 0;
1780cdf0e10cSrcweir
1781cdf0e10cSrcweir const basegfx::B2DVector aBC( rC.X() - rB.X(), rC.Y() - rB.Y() );
1782cdf0e10cSrcweir const basegfx::B2DVector aAB( rB.X() - rA.X(), rB.Y() - rA.Y() );
1783cdf0e10cSrcweir const double nDot1 = aBC.scalar( aAB );
1784cdf0e10cSrcweir
1785cdf0e10cSrcweir if ( nDot1 > 0 ) // check outside case 1
1786cdf0e10cSrcweir nRet = aBC.getLength();
1787cdf0e10cSrcweir else
1788cdf0e10cSrcweir {
1789cdf0e10cSrcweir const basegfx::B2DVector aAC( rC.X() - rA.X(), rC.Y() - rA.Y() );
1790cdf0e10cSrcweir const basegfx::B2DVector aBA( rA.X() - rB.X(), rA.Y() - rB.Y() );
1791cdf0e10cSrcweir const double nDot2 = aAC.scalar( aBA );
1792cdf0e10cSrcweir
1793cdf0e10cSrcweir if ( nDot2 > 0 ) // check outside case 2
1794cdf0e10cSrcweir nRet = aAC.getLength();
1795cdf0e10cSrcweir else
1796cdf0e10cSrcweir {
1797cdf0e10cSrcweir const double nDiv = aAB.getLength();
1798cdf0e10cSrcweir nRet = nDiv ? aAB.cross( aAC ) / nDiv : 0;
1799cdf0e10cSrcweir }
1800cdf0e10cSrcweir }
1801cdf0e10cSrcweir
1802cdf0e10cSrcweir return Abs(nRet);
1803cdf0e10cSrcweir }
1804cdf0e10cSrcweir
1805cdf0e10cSrcweir /* Helper function*/
lcl_ProjectOntoClosestTableFrm(const SwTabFrm & rTab,const Point & rPoint,bool bRowDrag)1806cdf0e10cSrcweir Point lcl_ProjectOntoClosestTableFrm( const SwTabFrm& rTab, const Point& rPoint, bool bRowDrag )
1807cdf0e10cSrcweir {
1808cdf0e10cSrcweir Point aRet( rPoint );
1809cdf0e10cSrcweir const SwTabFrm* pCurrentTab = &rTab;
1810cdf0e10cSrcweir const bool bVert = pCurrentTab->IsVertical();
1811cdf0e10cSrcweir const bool bRTL = pCurrentTab->IsRightToLeft();
1812cdf0e10cSrcweir
1813cdf0e10cSrcweir // Western Layout:
1814cdf0e10cSrcweir // bRowDrag = true => compare to left border of table
1815cdf0e10cSrcweir // bRowDrag = false => compare to top border of table
1816cdf0e10cSrcweir
1817cdf0e10cSrcweir // Asian Layout:
1818cdf0e10cSrcweir // bRowDrag = true => compare to right border of table
1819cdf0e10cSrcweir // bRowDrag = false => compare to top border of table
1820cdf0e10cSrcweir
1821cdf0e10cSrcweir // RTL Layout:
1822cdf0e10cSrcweir // bRowDrag = true => compare to right border of table
1823cdf0e10cSrcweir // bRowDrag = false => compare to top border of table
1824cdf0e10cSrcweir bool bLeft = false;
1825cdf0e10cSrcweir bool bRight = false;
1826cdf0e10cSrcweir
1827cdf0e10cSrcweir if ( bRowDrag )
1828cdf0e10cSrcweir {
1829cdf0e10cSrcweir if ( bVert || bRTL )
1830cdf0e10cSrcweir bRight = true;
1831cdf0e10cSrcweir else
1832cdf0e10cSrcweir bLeft = true;
1833cdf0e10cSrcweir }
1834cdf0e10cSrcweir
1835cdf0e10cSrcweir // used to find the minimal distance
1836cdf0e10cSrcweir double nMin = -1;
1837cdf0e10cSrcweir Point aMin1;
1838cdf0e10cSrcweir Point aMin2;
1839cdf0e10cSrcweir
1840cdf0e10cSrcweir Point aS1;
1841cdf0e10cSrcweir Point aS2;
1842cdf0e10cSrcweir
1843cdf0e10cSrcweir while ( pCurrentTab )
1844cdf0e10cSrcweir {
1845cdf0e10cSrcweir SwRect aTabRect( pCurrentTab->Prt() );
1846cdf0e10cSrcweir aTabRect += pCurrentTab->Frm().Pos();
1847cdf0e10cSrcweir
1848cdf0e10cSrcweir if ( bLeft )
1849cdf0e10cSrcweir {
1850cdf0e10cSrcweir // distance to left table border
1851cdf0e10cSrcweir aS1 = aTabRect.TopLeft();
1852cdf0e10cSrcweir aS2 = aTabRect.BottomLeft();
1853cdf0e10cSrcweir }
1854cdf0e10cSrcweir else if ( bRight )
1855cdf0e10cSrcweir {
1856cdf0e10cSrcweir // distance to right table border
1857cdf0e10cSrcweir aS1 = aTabRect.TopRight();
1858cdf0e10cSrcweir aS2 = aTabRect.BottomRight();
1859cdf0e10cSrcweir }
1860cdf0e10cSrcweir else //if ( bTop )
1861cdf0e10cSrcweir {
1862cdf0e10cSrcweir // distance to top table border
1863cdf0e10cSrcweir aS1 = aTabRect.TopLeft();
1864cdf0e10cSrcweir aS2 = aTabRect.TopRight();
1865cdf0e10cSrcweir }
1866cdf0e10cSrcweir
1867cdf0e10cSrcweir const double nDist = lcl_DistancePoint2Segment( aS1, aS2, rPoint );
1868cdf0e10cSrcweir
1869cdf0e10cSrcweir if ( nDist < nMin || -1 == nMin )
1870cdf0e10cSrcweir {
1871cdf0e10cSrcweir aMin1 = aS1;
1872cdf0e10cSrcweir aMin2 = aS2;
1873cdf0e10cSrcweir nMin = nDist;
1874cdf0e10cSrcweir }
1875cdf0e10cSrcweir
1876cdf0e10cSrcweir pCurrentTab = pCurrentTab->GetFollow();
1877cdf0e10cSrcweir }
1878cdf0e10cSrcweir
1879cdf0e10cSrcweir // project onto closest line:
1880cdf0e10cSrcweir if ( bLeft || bRight )
1881cdf0e10cSrcweir {
1882cdf0e10cSrcweir aRet.X() = aMin1.X();
1883cdf0e10cSrcweir if ( aRet.Y() > aMin2.Y() )
1884cdf0e10cSrcweir aRet.Y() = aMin2.Y();
1885cdf0e10cSrcweir else if ( aRet.Y() < aMin1.Y() )
1886cdf0e10cSrcweir aRet.Y() = aMin1.Y();
1887cdf0e10cSrcweir }
1888cdf0e10cSrcweir else //if ( bTop )
1889cdf0e10cSrcweir {
1890cdf0e10cSrcweir aRet.Y() = aMin1.Y();
1891cdf0e10cSrcweir if ( aRet.X() > aMin2.X() )
1892cdf0e10cSrcweir aRet.X() = aMin2.X();
1893cdf0e10cSrcweir else if ( aRet.X() < aMin1.X() )
1894cdf0e10cSrcweir aRet.X() = aMin1.X();
1895cdf0e10cSrcweir }
1896cdf0e10cSrcweir
1897cdf0e10cSrcweir return aRet;
1898cdf0e10cSrcweir }
1899cdf0e10cSrcweir
1900cdf0e10cSrcweir // --> FME 2004-07-30 #i32329# Enhanced table selection
SelTblRowCol(const Point & rPt,const Point * pEnd,bool bRowDrag)1901cdf0e10cSrcweir bool SwFEShell::SelTblRowCol( const Point& rPt, const Point* pEnd, bool bRowDrag )
1902cdf0e10cSrcweir {
1903cdf0e10cSrcweir bool bRet = false;
1904cdf0e10cSrcweir Point aEndPt;
1905cdf0e10cSrcweir if ( pEnd )
1906cdf0e10cSrcweir aEndPt = *pEnd;
1907cdf0e10cSrcweir
1908cdf0e10cSrcweir SwPosition* ppPos[2] = { 0, 0 };
1909cdf0e10cSrcweir Point paPt [2] = { rPt, aEndPt };
1910cdf0e10cSrcweir bool pbRow[2] = { 0, 0 };
1911cdf0e10cSrcweir bool pbCol[2] = { 0, 0 };
1912cdf0e10cSrcweir
1913cdf0e10cSrcweir // pEnd is set during dragging.
1914cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < ( pEnd ? 2 : 1 ); ++i )
1915cdf0e10cSrcweir {
1916cdf0e10cSrcweir const SwCellFrm* pFrm =
1917cdf0e10cSrcweir static_cast<const SwCellFrm*>(GetBox( paPt[i], &pbRow[i], &pbCol[i] ) );
1918cdf0e10cSrcweir
1919cdf0e10cSrcweir if( pFrm )
1920cdf0e10cSrcweir {
1921cdf0e10cSrcweir while( pFrm->Lower() && pFrm->Lower()->IsRowFrm() )
1922cdf0e10cSrcweir pFrm = static_cast<const SwCellFrm*>( static_cast<const SwLayoutFrm*>( pFrm->Lower() )->Lower() );
1923cdf0e10cSrcweir if( pFrm && pFrm->GetTabBox()->GetSttNd() &&
1924cdf0e10cSrcweir pFrm->GetTabBox()->GetSttNd()->IsInProtectSect() )
1925cdf0e10cSrcweir pFrm = 0;
1926cdf0e10cSrcweir }
1927cdf0e10cSrcweir
1928cdf0e10cSrcweir if ( pFrm )
1929cdf0e10cSrcweir {
1930cdf0e10cSrcweir const SwCntntFrm* pCntnt = ::GetCellCntnt( *pFrm );
1931cdf0e10cSrcweir
1932cdf0e10cSrcweir if ( pCntnt && pCntnt->IsTxtFrm() )
1933cdf0e10cSrcweir {
1934cdf0e10cSrcweir ppPos[i] = new SwPosition( *pCntnt->GetNode() );
1935cdf0e10cSrcweir ppPos[i]->nContent.Assign( const_cast<SwCntntNode*>(pCntnt->GetNode()), 0 );
1936cdf0e10cSrcweir
1937cdf0e10cSrcweir // paPt[i] will not be used any longer, now we use it to store
1938cdf0e10cSrcweir // a position inside the content frame
1939cdf0e10cSrcweir paPt[i] = pCntnt->Frm().Center();
1940cdf0e10cSrcweir }
1941cdf0e10cSrcweir }
1942cdf0e10cSrcweir
1943cdf0e10cSrcweir // no calculation of end frame if start frame has not been found.
1944cdf0e10cSrcweir if ( 1 == i || !ppPos[0] || !pEnd )
1945cdf0e10cSrcweir break;
1946cdf0e10cSrcweir
1947cdf0e10cSrcweir // find 'closest' table frame to pEnd:
1948cdf0e10cSrcweir const SwTabFrm* pCurrentTab = pFrm->FindTabFrm();
1949cdf0e10cSrcweir if ( pCurrentTab->IsFollow() )
1950cdf0e10cSrcweir pCurrentTab = pCurrentTab->FindMaster( true );
1951cdf0e10cSrcweir
1952cdf0e10cSrcweir const Point aProjection = lcl_ProjectOntoClosestTableFrm( *pCurrentTab, *pEnd, bRowDrag );
1953cdf0e10cSrcweir paPt[1] = aProjection;
1954cdf0e10cSrcweir }
1955cdf0e10cSrcweir
1956cdf0e10cSrcweir if ( ppPos[0] )
1957cdf0e10cSrcweir {
1958cdf0e10cSrcweir SwShellCrsr* pCrsr = _GetCrsr();
1959cdf0e10cSrcweir SwCrsrSaveState aSaveState( *pCrsr );
1960cdf0e10cSrcweir SwPosition aOldPos( *pCrsr->GetPoint() );
1961cdf0e10cSrcweir
1962cdf0e10cSrcweir pCrsr->DeleteMark();
1963cdf0e10cSrcweir *pCrsr->GetPoint() = *ppPos[0];
1964cdf0e10cSrcweir pCrsr->GetPtPos() = paPt[0];
1965cdf0e10cSrcweir
1966cdf0e10cSrcweir if ( !pCrsr->IsInProtectTable( sal_False, sal_True ) )
1967cdf0e10cSrcweir {
1968cdf0e10cSrcweir bool bNewSelection = true;
1969cdf0e10cSrcweir
1970cdf0e10cSrcweir if ( ppPos[1] )
1971cdf0e10cSrcweir {
1972cdf0e10cSrcweir if ( ppPos[1]->nNode.GetNode().StartOfSectionNode() !=
1973cdf0e10cSrcweir aOldPos.nNode.GetNode().StartOfSectionNode() )
1974cdf0e10cSrcweir {
1975cdf0e10cSrcweir pCrsr->SetMark();
1976cdf0e10cSrcweir SwCrsrSaveState aSaveState2( *pCrsr );
1977cdf0e10cSrcweir *pCrsr->GetPoint() = *ppPos[1];
1978cdf0e10cSrcweir pCrsr->GetPtPos() = paPt[1];
1979cdf0e10cSrcweir
1980cdf0e10cSrcweir if ( pCrsr->IsInProtectTable( sal_False, sal_False ) )
1981cdf0e10cSrcweir {
1982cdf0e10cSrcweir pCrsr->RestoreSavePos();
1983cdf0e10cSrcweir bNewSelection = false;
1984cdf0e10cSrcweir }
1985cdf0e10cSrcweir }
1986cdf0e10cSrcweir else
1987cdf0e10cSrcweir {
1988cdf0e10cSrcweir pCrsr->RestoreSavePos();
1989cdf0e10cSrcweir bNewSelection = false;
1990cdf0e10cSrcweir }
1991cdf0e10cSrcweir }
1992cdf0e10cSrcweir
1993cdf0e10cSrcweir if ( bNewSelection )
1994cdf0e10cSrcweir {
1995cdf0e10cSrcweir // --> FME 2004-10-20 #i35543# SelTblRowCol should remove any existing
1996cdf0e10cSrcweir // table cursor:
1997cdf0e10cSrcweir if ( IsTableMode() )
1998cdf0e10cSrcweir TblCrsrToCursor();
1999cdf0e10cSrcweir // <--
2000cdf0e10cSrcweir
2001cdf0e10cSrcweir if ( pbRow[0] && pbCol[0] )
2002cdf0e10cSrcweir bRet = SwCrsrShell::SelTbl();
2003cdf0e10cSrcweir else if ( pbRow[0] )
2004cdf0e10cSrcweir bRet = SwCrsrShell::_SelTblRowOrCol( true, true );
2005cdf0e10cSrcweir else if ( pbCol[0] )
2006cdf0e10cSrcweir bRet = SwCrsrShell::_SelTblRowOrCol( false, true );
2007cdf0e10cSrcweir }
2008cdf0e10cSrcweir else
2009cdf0e10cSrcweir bRet = true;
2010cdf0e10cSrcweir }
2011cdf0e10cSrcweir
2012cdf0e10cSrcweir delete ppPos[0];
2013cdf0e10cSrcweir delete ppPos[1];
2014cdf0e10cSrcweir }
2015cdf0e10cSrcweir
2016cdf0e10cSrcweir return bRet;
2017cdf0e10cSrcweir }
2018cdf0e10cSrcweir // <--
2019cdf0e10cSrcweir
2020cdf0e10cSrcweir
2021cdf0e10cSrcweir /*************************************************************************
2022cdf0e10cSrcweir |*
2023cdf0e10cSrcweir |* SwFEShell::WhichMouseTabCol()
2024cdf0e10cSrcweir |*
2025cdf0e10cSrcweir |* Ersterstellung MA 22. Jun. 95
2026cdf0e10cSrcweir |* Last change AMA 12. Jun. 02
2027cdf0e10cSrcweir |
2028cdf0e10cSrcweir |*************************************************************************/
WhichMouseTabCol(const Point & rPt) const2029cdf0e10cSrcweir sal_uInt8 SwFEShell::WhichMouseTabCol( const Point &rPt ) const
2030cdf0e10cSrcweir {
2031cdf0e10cSrcweir sal_uInt8 nRet = SW_TABCOL_NONE;
2032cdf0e10cSrcweir bool bRow = false;
2033cdf0e10cSrcweir bool bCol = false;
2034cdf0e10cSrcweir bool bSelect = false;
2035cdf0e10cSrcweir
2036cdf0e10cSrcweir // First try: Do we get the row/col move cursor?
2037cdf0e10cSrcweir SwCellFrm* pFrm = (SwCellFrm*)GetBox( rPt, &bRow, 0 );
2038cdf0e10cSrcweir
2039cdf0e10cSrcweir if ( !pFrm )
2040cdf0e10cSrcweir {
2041cdf0e10cSrcweir // Second try: Do we get the row/col/tab selection cursor?
2042cdf0e10cSrcweir pFrm = (SwCellFrm*)GetBox( rPt, &bRow, &bCol );
2043cdf0e10cSrcweir bSelect = true;
2044cdf0e10cSrcweir }
2045cdf0e10cSrcweir
2046cdf0e10cSrcweir if( pFrm )
2047cdf0e10cSrcweir {
2048cdf0e10cSrcweir while( pFrm->Lower() && pFrm->Lower()->IsRowFrm() )
2049cdf0e10cSrcweir pFrm = (SwCellFrm*)((SwLayoutFrm*)pFrm->Lower())->Lower();
2050cdf0e10cSrcweir if( pFrm && pFrm->GetTabBox()->GetSttNd() &&
2051cdf0e10cSrcweir pFrm->GetTabBox()->GetSttNd()->IsInProtectSect() )
2052cdf0e10cSrcweir pFrm = 0;
2053cdf0e10cSrcweir }
2054cdf0e10cSrcweir
2055cdf0e10cSrcweir if( pFrm )
2056cdf0e10cSrcweir {
2057cdf0e10cSrcweir if ( !bSelect )
2058cdf0e10cSrcweir {
2059cdf0e10cSrcweir if ( pFrm->IsVertical() )
2060cdf0e10cSrcweir nRet = bRow ? SW_TABCOL_VERT : SW_TABROW_VERT;
2061cdf0e10cSrcweir else
2062cdf0e10cSrcweir nRet = bRow ? SW_TABROW_HORI : SW_TABCOL_HORI;
2063cdf0e10cSrcweir }
2064cdf0e10cSrcweir else
2065cdf0e10cSrcweir {
2066cdf0e10cSrcweir const SwTabFrm* pTabFrm = pFrm->FindTabFrm();
2067cdf0e10cSrcweir if ( pTabFrm->IsVertical() )
2068cdf0e10cSrcweir {
2069cdf0e10cSrcweir if ( bRow && bCol )
2070cdf0e10cSrcweir {
2071cdf0e10cSrcweir nRet = SW_TABSEL_VERT;
2072cdf0e10cSrcweir }
2073cdf0e10cSrcweir else if ( bRow )
2074cdf0e10cSrcweir {
2075cdf0e10cSrcweir nRet = SW_TABROWSEL_VERT;
2076cdf0e10cSrcweir }
2077cdf0e10cSrcweir else if ( bCol )
2078cdf0e10cSrcweir {
2079cdf0e10cSrcweir nRet = SW_TABCOLSEL_VERT;
2080cdf0e10cSrcweir }
2081cdf0e10cSrcweir }
2082cdf0e10cSrcweir else
2083cdf0e10cSrcweir {
2084cdf0e10cSrcweir if ( bRow && bCol )
2085cdf0e10cSrcweir {
2086cdf0e10cSrcweir nRet = pTabFrm->IsRightToLeft() ?
2087cdf0e10cSrcweir SW_TABSEL_HORI_RTL :
2088cdf0e10cSrcweir SW_TABSEL_HORI;
2089cdf0e10cSrcweir }
2090cdf0e10cSrcweir else if ( bRow )
2091cdf0e10cSrcweir {
2092cdf0e10cSrcweir nRet = pTabFrm->IsRightToLeft() ?
2093cdf0e10cSrcweir SW_TABROWSEL_HORI_RTL :
2094cdf0e10cSrcweir SW_TABROWSEL_HORI;
2095cdf0e10cSrcweir }
2096cdf0e10cSrcweir else if ( bCol )
2097cdf0e10cSrcweir {
2098cdf0e10cSrcweir nRet = SW_TABCOLSEL_HORI;
2099cdf0e10cSrcweir }
2100cdf0e10cSrcweir }
2101cdf0e10cSrcweir }
2102cdf0e10cSrcweir }
2103cdf0e10cSrcweir
2104cdf0e10cSrcweir return nRet;
2105cdf0e10cSrcweir }
2106cdf0e10cSrcweir
2107cdf0e10cSrcweir // -> #i23726#
GetNumRuleNodeAtPos(const Point & rPt)2108cdf0e10cSrcweir SwTxtNode * SwFEShell::GetNumRuleNodeAtPos( const Point &rPt)
2109cdf0e10cSrcweir {
2110cdf0e10cSrcweir SwTxtNode * pResult = NULL;
2111cdf0e10cSrcweir
2112cdf0e10cSrcweir SwContentAtPos aCntntAtPos
2113cdf0e10cSrcweir (SwContentAtPos::SW_NUMLABEL);
2114cdf0e10cSrcweir
2115cdf0e10cSrcweir if( GetContentAtPos(rPt, aCntntAtPos) && aCntntAtPos.aFnd.pNode)
2116cdf0e10cSrcweir pResult = aCntntAtPos.aFnd.pNode->GetTxtNode();
2117cdf0e10cSrcweir
2118cdf0e10cSrcweir return pResult;
2119cdf0e10cSrcweir }
2120cdf0e10cSrcweir
IsNumLabel(const Point & rPt,int nMaxOffset)2121cdf0e10cSrcweir sal_Bool SwFEShell::IsNumLabel( const Point &rPt, int nMaxOffset )
2122cdf0e10cSrcweir {
2123cdf0e10cSrcweir sal_Bool bResult = sal_False;
2124cdf0e10cSrcweir
2125cdf0e10cSrcweir SwContentAtPos aCntntAtPos
2126cdf0e10cSrcweir (SwContentAtPos::SW_NUMLABEL);
2127cdf0e10cSrcweir
2128cdf0e10cSrcweir if( GetContentAtPos(rPt, aCntntAtPos))
2129cdf0e10cSrcweir {
2130cdf0e10cSrcweir if ((nMaxOffset >= 0 && aCntntAtPos.nDist <= nMaxOffset) ||
2131cdf0e10cSrcweir (nMaxOffset < 0))
2132cdf0e10cSrcweir bResult = sal_True;
2133cdf0e10cSrcweir }
2134cdf0e10cSrcweir
2135cdf0e10cSrcweir return bResult;
2136cdf0e10cSrcweir }
2137cdf0e10cSrcweir // <- #i23726#
2138cdf0e10cSrcweir
2139cdf0e10cSrcweir // --> OD 2005-02-21 #i42921#
IsVerticalModeAtNdAndPos(const SwTxtNode & _rTxtNode,const Point & _rDocPos) const2140cdf0e10cSrcweir bool SwFEShell::IsVerticalModeAtNdAndPos( const SwTxtNode& _rTxtNode,
2141cdf0e10cSrcweir const Point& _rDocPos ) const
2142cdf0e10cSrcweir {
2143cdf0e10cSrcweir bool bRet( false );
2144cdf0e10cSrcweir
2145cdf0e10cSrcweir const short nTextDir =
2146cdf0e10cSrcweir _rTxtNode.GetTextDirection( SwPosition(_rTxtNode), &_rDocPos );
2147cdf0e10cSrcweir switch ( nTextDir )
2148cdf0e10cSrcweir {
2149cdf0e10cSrcweir case -1:
2150cdf0e10cSrcweir case FRMDIR_HORI_RIGHT_TOP:
2151cdf0e10cSrcweir case FRMDIR_HORI_LEFT_TOP:
2152cdf0e10cSrcweir {
2153cdf0e10cSrcweir bRet = false;
2154cdf0e10cSrcweir }
2155cdf0e10cSrcweir break;
2156cdf0e10cSrcweir case FRMDIR_VERT_TOP_LEFT:
2157cdf0e10cSrcweir case FRMDIR_VERT_TOP_RIGHT:
2158cdf0e10cSrcweir {
2159cdf0e10cSrcweir bRet = true;
2160cdf0e10cSrcweir }
2161cdf0e10cSrcweir break;
2162cdf0e10cSrcweir }
2163cdf0e10cSrcweir
2164cdf0e10cSrcweir return bRet;
2165cdf0e10cSrcweir }
2166cdf0e10cSrcweir // <--
2167cdf0e10cSrcweir
2168cdf0e10cSrcweir /*************************************************************************
2169cdf0e10cSrcweir |*
2170cdf0e10cSrcweir |* SwFEShell::GetMouseTabCols()
2171cdf0e10cSrcweir |*
2172cdf0e10cSrcweir |* Ersterstellung MA 22. Jun. 95
2173cdf0e10cSrcweir |* Letzte Aenderung MA 27. Aug. 96
2174cdf0e10cSrcweir |
2175cdf0e10cSrcweir |*************************************************************************/
GetMouseTabCols(SwTabCols & rToFill,const Point & rPt) const2176cdf0e10cSrcweir void SwFEShell::GetMouseTabCols( SwTabCols &rToFill, const Point &rPt ) const
2177cdf0e10cSrcweir {
2178cdf0e10cSrcweir const SwFrm *pBox = GetBox( rPt );
2179cdf0e10cSrcweir if ( pBox )
2180cdf0e10cSrcweir _GetTabCols( rToFill, pBox );
2181cdf0e10cSrcweir }
2182cdf0e10cSrcweir
SetMouseTabCols(const SwTabCols & rNew,sal_Bool bCurRowOnly,const Point & rPt)2183cdf0e10cSrcweir void SwFEShell::SetMouseTabCols( const SwTabCols &rNew, sal_Bool bCurRowOnly,
2184cdf0e10cSrcweir const Point &rPt )
2185cdf0e10cSrcweir {
2186cdf0e10cSrcweir const SwFrm *pBox = GetBox( rPt );
2187cdf0e10cSrcweir if( pBox )
2188cdf0e10cSrcweir {
2189cdf0e10cSrcweir SET_CURR_SHELL( this );
2190cdf0e10cSrcweir StartAllAction();
2191cdf0e10cSrcweir GetDoc()->SetTabCols( rNew, bCurRowOnly, 0, (SwCellFrm*)pBox );
2192cdf0e10cSrcweir EndAllActionAndCall();
2193cdf0e10cSrcweir }
2194cdf0e10cSrcweir }
2195cdf0e10cSrcweir
2196cdf0e10cSrcweir /*************************************************************************
2197cdf0e10cSrcweir |*
2198cdf0e10cSrcweir |* SwFEShell::GetMouseColNum(), GetMouseTabColNum()
2199cdf0e10cSrcweir |*
2200cdf0e10cSrcweir |* Ersterstellung MA 04. Jul. 95
2201cdf0e10cSrcweir |* Letzte Aenderung MA 04. Jul. 95
2202cdf0e10cSrcweir |
2203cdf0e10cSrcweir |*************************************************************************/
GetCurMouseColNum(const Point & rPt,SwGetCurColNumPara * pPara) const2204cdf0e10cSrcweir sal_uInt16 SwFEShell::GetCurMouseColNum( const Point &rPt,
2205cdf0e10cSrcweir SwGetCurColNumPara* pPara ) const
2206cdf0e10cSrcweir {
2207cdf0e10cSrcweir return _GetCurColNum( GetBox( rPt ), pPara );
2208cdf0e10cSrcweir }
2209cdf0e10cSrcweir
GetCurMouseTabColNum(const Point & rPt) const2210cdf0e10cSrcweir sal_uInt16 SwFEShell::GetCurMouseTabColNum( const Point &rPt ) const
2211cdf0e10cSrcweir {
2212cdf0e10cSrcweir //!!!GetCurTabColNum() mitpflegen!!!!
2213cdf0e10cSrcweir sal_uInt16 nRet = 0;
2214cdf0e10cSrcweir
2215cdf0e10cSrcweir const SwFrm *pFrm = GetBox( rPt );
2216cdf0e10cSrcweir ASSERT( pFrm, "Table not found" );
2217cdf0e10cSrcweir if( pFrm )
2218cdf0e10cSrcweir {
2219cdf0e10cSrcweir const long nX = pFrm->Frm().Left();
2220cdf0e10cSrcweir
2221cdf0e10cSrcweir //TabCols besorgen, den nur ueber diese erreichen wir die Position.
2222cdf0e10cSrcweir SwTabCols aTabCols;
2223cdf0e10cSrcweir GetMouseTabCols( aTabCols, rPt );
2224cdf0e10cSrcweir
2225cdf0e10cSrcweir const long nLeft = aTabCols.GetLeftMin();
2226cdf0e10cSrcweir
2227cdf0e10cSrcweir if ( !::IsSame( nX, nLeft + aTabCols.GetLeft() ) )
2228cdf0e10cSrcweir {
2229cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i )
2230cdf0e10cSrcweir if ( ::IsSame( nX, nLeft + aTabCols[i] ) )
2231cdf0e10cSrcweir {
2232cdf0e10cSrcweir nRet = i + 1;
2233cdf0e10cSrcweir break;
2234cdf0e10cSrcweir }
2235cdf0e10cSrcweir }
2236cdf0e10cSrcweir }
2237cdf0e10cSrcweir return nRet;
2238cdf0e10cSrcweir }
2239cdf0e10cSrcweir
ClearFEShellTabCols()2240cdf0e10cSrcweir void ClearFEShellTabCols()
2241cdf0e10cSrcweir {
2242cdf0e10cSrcweir DELETEZ( pLastCols );
2243cdf0e10cSrcweir DELETEZ( pLastRows );
2244cdf0e10cSrcweir }
2245cdf0e10cSrcweir
2246cdf0e10cSrcweir /*************************************************************************
2247cdf0e10cSrcweir |*
2248cdf0e10cSrcweir |* SwFEShell::GetTblAttr(), SetTblAttr()
2249cdf0e10cSrcweir |*
2250cdf0e10cSrcweir |* Ersterstellung MA 09. Dec. 96
2251cdf0e10cSrcweir |* Letzte Aenderung MA 09. Dec. 96
2252cdf0e10cSrcweir |
2253cdf0e10cSrcweir |*************************************************************************/
GetTblAttr(SfxItemSet & rSet) const2254cdf0e10cSrcweir void SwFEShell::GetTblAttr( SfxItemSet &rSet ) const
2255cdf0e10cSrcweir {
2256cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
2257cdf0e10cSrcweir if( pFrm && pFrm->IsInTab() )
2258cdf0e10cSrcweir rSet.Put( pFrm->ImplFindTabFrm()->GetFmt()->GetAttrSet() );
2259cdf0e10cSrcweir }
2260cdf0e10cSrcweir
SetTblAttr(const SfxItemSet & rNew)2261cdf0e10cSrcweir void SwFEShell::SetTblAttr( const SfxItemSet &rNew )
2262cdf0e10cSrcweir {
2263cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
2264cdf0e10cSrcweir if( pFrm && pFrm->IsInTab() )
2265cdf0e10cSrcweir {
2266cdf0e10cSrcweir SET_CURR_SHELL( this );
2267cdf0e10cSrcweir StartAllAction();
2268cdf0e10cSrcweir SwTabFrm *pTab = pFrm->FindTabFrm();
2269cdf0e10cSrcweir pTab->GetTable()->SetHTMLTableLayout( 0 );
2270cdf0e10cSrcweir GetDoc()->SetAttr( rNew, *pTab->GetFmt() );
2271cdf0e10cSrcweir GetDoc()->SetModified();
2272cdf0e10cSrcweir EndAllActionAndCall();
2273cdf0e10cSrcweir }
2274cdf0e10cSrcweir }
2275cdf0e10cSrcweir
2276cdf0e10cSrcweir /** move cursor within a table into previous/next row (same column)
2277cdf0e10cSrcweir * @param pShell cursor shell whose cursor is to be moved
2278cdf0e10cSrcweir * @param bUp true: move up, false: move down
2279cdf0e10cSrcweir * @returns true if successful
2280cdf0e10cSrcweir */
lcl_GoTableRow(SwCrsrShell * pShell,bool bUp)2281cdf0e10cSrcweir bool lcl_GoTableRow( SwCrsrShell* pShell, bool bUp )
2282cdf0e10cSrcweir {
2283cdf0e10cSrcweir ASSERT( pShell != NULL, "need shell" );
2284cdf0e10cSrcweir
2285cdf0e10cSrcweir bool bRet = false;
2286cdf0e10cSrcweir
2287cdf0e10cSrcweir SwPaM* pPam = pShell->GetCrsr();
2288cdf0e10cSrcweir const SwStartNode* pTableBox = pPam->GetNode()->FindTableBoxStartNode();
2289cdf0e10cSrcweir ASSERT( pTableBox != NULL, "I'm living in a box... NOT!" );
2290cdf0e10cSrcweir
2291cdf0e10cSrcweir // move cursor to start node of table box
2292cdf0e10cSrcweir pPam->GetPoint()->nNode = pTableBox->GetIndex();
2293cdf0e10cSrcweir pPam->GetPoint()->nContent.Assign( NULL, 0 );
2294cdf0e10cSrcweir GoInCntnt( *pPam, fnMoveForward );
2295cdf0e10cSrcweir
2296cdf0e10cSrcweir // go to beginning end of table box
2297cdf0e10cSrcweir SwPosSection fnPosSect = bUp ? fnSectionStart : fnSectionEnd;
2298cdf0e10cSrcweir pShell->MoveSection( fnSectionCurr, fnPosSect );
2299cdf0e10cSrcweir
2300cdf0e10cSrcweir // and go up/down into next content
2301cdf0e10cSrcweir bRet = bUp ? pShell->Up() : pShell->Down();
2302cdf0e10cSrcweir
2303cdf0e10cSrcweir return bRet;
2304cdf0e10cSrcweir }
2305cdf0e10cSrcweir
2306cdf0e10cSrcweir // aender eine Zellenbreite/-Hoehe/Spaltenbreite/Zeilenhoehe
SetColRowWidthHeight(sal_uInt16 eType,sal_uInt16 nDiff)2307cdf0e10cSrcweir sal_Bool SwFEShell::SetColRowWidthHeight( sal_uInt16 eType, sal_uInt16 nDiff )
2308cdf0e10cSrcweir {
2309cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
2310cdf0e10cSrcweir if( !pFrm || !pFrm->IsInTab() )
2311cdf0e10cSrcweir return sal_False;
2312cdf0e10cSrcweir
2313cdf0e10cSrcweir if( nsTblChgWidthHeightType::WH_FLAG_INSDEL & eType &&
2314cdf0e10cSrcweir pFrm->ImplFindTabFrm()->GetTable()->ISA( SwDDETable ))
2315cdf0e10cSrcweir {
2316cdf0e10cSrcweir ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR,
2317cdf0e10cSrcweir ERRCODE_MSG_INFO | ERRCODE_BUTTON_DEF_OK );
2318cdf0e10cSrcweir return sal_False;
2319cdf0e10cSrcweir }
2320cdf0e10cSrcweir
2321cdf0e10cSrcweir SET_CURR_SHELL( this );
2322cdf0e10cSrcweir StartAllAction();
2323cdf0e10cSrcweir
2324cdf0e10cSrcweir do {
2325cdf0e10cSrcweir pFrm = pFrm->GetUpper();
2326cdf0e10cSrcweir } while( !pFrm->IsCellFrm() );
2327cdf0e10cSrcweir
2328cdf0e10cSrcweir SwTabFrm *pTab = pFrm->ImplFindTabFrm();
2329cdf0e10cSrcweir
2330cdf0e10cSrcweir // sollte die Tabelle noch auf relativen Werten (USHRT_MAX) stehen
2331cdf0e10cSrcweir // dann muss es jetzt auf absolute umgerechnet werden.
2332cdf0e10cSrcweir const SwFmtFrmSize& rTblFrmSz = pTab->GetFmt()->GetFrmSize();
2333cdf0e10cSrcweir SWRECTFN( pTab )
2334cdf0e10cSrcweir long nPrtWidth = (pTab->Prt().*fnRect->fnGetWidth)();
2335cdf0e10cSrcweir if( TBLVAR_CHGABS == pTab->GetTable()->GetTblChgMode() &&
2336cdf0e10cSrcweir ( eType & nsTblChgWidthHeightType::WH_COL_LEFT || eType & nsTblChgWidthHeightType::WH_COL_RIGHT ) &&
2337cdf0e10cSrcweir text::HoriOrientation::NONE == pTab->GetFmt()->GetHoriOrient().GetHoriOrient() &&
2338cdf0e10cSrcweir nPrtWidth != rTblFrmSz.GetWidth() )
2339cdf0e10cSrcweir {
2340cdf0e10cSrcweir SwFmtFrmSize aSz( rTblFrmSz );
2341cdf0e10cSrcweir aSz.SetWidth( pTab->Prt().Width() );
2342cdf0e10cSrcweir pTab->GetFmt()->SetFmtAttr( aSz );
2343cdf0e10cSrcweir }
2344cdf0e10cSrcweir
2345cdf0e10cSrcweir if( (eType & (nsTblChgWidthHeightType::WH_FLAG_BIGGER | nsTblChgWidthHeightType::WH_FLAG_INSDEL)) ==
2346cdf0e10cSrcweir (nsTblChgWidthHeightType::WH_FLAG_BIGGER | nsTblChgWidthHeightType::WH_FLAG_INSDEL) )
2347cdf0e10cSrcweir {
2348cdf0e10cSrcweir nDiff = sal_uInt16((pFrm->Frm().*fnRect->fnGetWidth)());
2349cdf0e10cSrcweir
2350cdf0e10cSrcweir // we must move the cursor outside the current cell before
2351cdf0e10cSrcweir // deleting the cells.
2352cdf0e10cSrcweir TblChgWidthHeightType eTmp =
2353cdf0e10cSrcweir static_cast<TblChgWidthHeightType>( eType & 0xfff );
2354cdf0e10cSrcweir switch( eTmp )
2355cdf0e10cSrcweir {
2356cdf0e10cSrcweir case nsTblChgWidthHeightType::WH_ROW_TOP:
2357cdf0e10cSrcweir lcl_GoTableRow( this, true );
2358cdf0e10cSrcweir break;
2359cdf0e10cSrcweir case nsTblChgWidthHeightType::WH_ROW_BOTTOM:
2360cdf0e10cSrcweir lcl_GoTableRow( this, false );
2361cdf0e10cSrcweir break;
2362cdf0e10cSrcweir case nsTblChgWidthHeightType::WH_COL_LEFT:
2363cdf0e10cSrcweir GoPrevCell();
2364cdf0e10cSrcweir break;
2365cdf0e10cSrcweir case nsTblChgWidthHeightType::WH_COL_RIGHT:
2366cdf0e10cSrcweir GoNextCell();
2367cdf0e10cSrcweir break;
2368cdf0e10cSrcweir default:
2369cdf0e10cSrcweir break;
2370cdf0e10cSrcweir }
2371cdf0e10cSrcweir }
2372cdf0e10cSrcweir
2373cdf0e10cSrcweir SwTwips nLogDiff = nDiff;
2374cdf0e10cSrcweir nLogDiff *= pTab->GetFmt()->GetFrmSize().GetWidth();
2375cdf0e10cSrcweir nLogDiff /= nPrtWidth;
2376cdf0e10cSrcweir
2377cdf0e10cSrcweir /** The cells are destroyed in here */
2378cdf0e10cSrcweir sal_Bool bRet = GetDoc()->SetColRowWidthHeight(
2379cdf0e10cSrcweir *(SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox(),
2380cdf0e10cSrcweir eType, nDiff, nLogDiff );
2381cdf0e10cSrcweir
2382cdf0e10cSrcweir delete pLastCols, pLastCols = 0;
2383cdf0e10cSrcweir EndAllActionAndCall();
2384cdf0e10cSrcweir
2385cdf0e10cSrcweir if( bRet && (eType & (nsTblChgWidthHeightType::WH_FLAG_BIGGER | nsTblChgWidthHeightType::WH_FLAG_INSDEL)) == nsTblChgWidthHeightType::WH_FLAG_INSDEL )
2386cdf0e10cSrcweir {
2387cdf0e10cSrcweir switch(eType & ~(nsTblChgWidthHeightType::WH_FLAG_BIGGER | nsTblChgWidthHeightType::WH_FLAG_INSDEL))
2388cdf0e10cSrcweir {
2389cdf0e10cSrcweir case nsTblChgWidthHeightType::WH_CELL_LEFT:
2390cdf0e10cSrcweir case nsTblChgWidthHeightType::WH_COL_LEFT:
2391cdf0e10cSrcweir GoPrevCell();
2392cdf0e10cSrcweir break;
2393cdf0e10cSrcweir
2394cdf0e10cSrcweir case nsTblChgWidthHeightType::WH_CELL_RIGHT:
2395cdf0e10cSrcweir case nsTblChgWidthHeightType::WH_COL_RIGHT:
2396cdf0e10cSrcweir GoNextCell();
2397cdf0e10cSrcweir break;
2398cdf0e10cSrcweir
2399cdf0e10cSrcweir case nsTblChgWidthHeightType::WH_CELL_TOP:
2400cdf0e10cSrcweir case nsTblChgWidthHeightType::WH_ROW_TOP:
2401cdf0e10cSrcweir lcl_GoTableRow( this, true );
2402cdf0e10cSrcweir break;
2403cdf0e10cSrcweir
2404cdf0e10cSrcweir case nsTblChgWidthHeightType::WH_CELL_BOTTOM:
2405cdf0e10cSrcweir case nsTblChgWidthHeightType::WH_ROW_BOTTOM:
2406cdf0e10cSrcweir lcl_GoTableRow( this, false );
2407cdf0e10cSrcweir break;
2408cdf0e10cSrcweir }
2409cdf0e10cSrcweir }
2410cdf0e10cSrcweir
2411cdf0e10cSrcweir return bRet;
2412cdf0e10cSrcweir }
2413cdf0e10cSrcweir
lcl_IsFormulaSelBoxes(const SwTable & rTbl,const SwTblBoxFormula & rFml,SwCellFrms & rCells)2414cdf0e10cSrcweir sal_Bool lcl_IsFormulaSelBoxes( const SwTable& rTbl, const SwTblBoxFormula& rFml,
2415cdf0e10cSrcweir SwCellFrms& rCells )
2416cdf0e10cSrcweir {
2417cdf0e10cSrcweir SwTblBoxFormula aTmp( rFml );
2418cdf0e10cSrcweir SwSelBoxes aBoxes;
2419cdf0e10cSrcweir for( sal_uInt16 nSelBoxes = aTmp.GetBoxesOfFormula( rTbl,aBoxes ); nSelBoxes; )
2420cdf0e10cSrcweir {
2421cdf0e10cSrcweir SwTableBox* pBox = aBoxes[ --nSelBoxes ];
2422cdf0e10cSrcweir sal_uInt16 i;
2423cdf0e10cSrcweir for( i = 0; i < rCells.Count(); ++i )
2424cdf0e10cSrcweir if( rCells[ i ]->GetTabBox() == pBox )
2425cdf0e10cSrcweir break; // gefunden
2426cdf0e10cSrcweir
2427cdf0e10cSrcweir if( i == rCells.Count() )
2428cdf0e10cSrcweir return sal_False;
2429cdf0e10cSrcweir }
2430cdf0e10cSrcweir
2431cdf0e10cSrcweir return sal_True;
2432cdf0e10cSrcweir }
2433cdf0e10cSrcweir
2434cdf0e10cSrcweir // erfrage die Formel fuer die Autosumme
GetAutoSum(String & rFml) const2435cdf0e10cSrcweir sal_Bool SwFEShell::GetAutoSum( String& rFml ) const
2436cdf0e10cSrcweir {
2437cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
2438cdf0e10cSrcweir SwTabFrm *pTab = pFrm ? pFrm->ImplFindTabFrm() : 0;
2439cdf0e10cSrcweir if( !pTab )
2440cdf0e10cSrcweir return sal_False;
2441cdf0e10cSrcweir
2442cdf0e10cSrcweir rFml = String::CreateFromAscii( sCalc_Sum );
2443cdf0e10cSrcweir
2444cdf0e10cSrcweir SwCellFrms aCells;
2445cdf0e10cSrcweir if( ::GetAutoSumSel( *this, aCells ))
2446cdf0e10cSrcweir {
2447cdf0e10cSrcweir sal_uInt16 nW = 0, nInsPos = 0;
2448cdf0e10cSrcweir for( sal_uInt16 n = aCells.Count(); n; )
2449cdf0e10cSrcweir {
2450cdf0e10cSrcweir SwCellFrm* pCFrm = aCells[ --n ];
2451cdf0e10cSrcweir sal_uInt16 nBoxW = pCFrm->GetTabBox()->IsFormulaOrValueBox();
2452cdf0e10cSrcweir if( !nBoxW )
2453cdf0e10cSrcweir break;
2454cdf0e10cSrcweir
2455cdf0e10cSrcweir if( !nW )
2456cdf0e10cSrcweir {
2457cdf0e10cSrcweir if( USHRT_MAX == nBoxW )
2458cdf0e10cSrcweir continue; // leere am Anfang ueberspringen
2459cdf0e10cSrcweir
2460cdf0e10cSrcweir rFml += '(';
2461cdf0e10cSrcweir nInsPos = rFml.Len();
2462cdf0e10cSrcweir
2463cdf0e10cSrcweir // Formeln nur wenn diese Boxen enthalten
2464cdf0e10cSrcweir if( RES_BOXATR_FORMULA == nBoxW &&
2465cdf0e10cSrcweir !::lcl_IsFormulaSelBoxes( *pTab->GetTable(), pCFrm->
2466cdf0e10cSrcweir GetTabBox()->GetFrmFmt()->GetTblBoxFormula(), aCells))
2467cdf0e10cSrcweir {
2468cdf0e10cSrcweir nW = RES_BOXATR_VALUE;
2469cdf0e10cSrcweir // alle vorhierigen Leere wieder mit aufnehmen !
2470cdf0e10cSrcweir for( sal_uInt16 i = aCells.Count(); n+1 < i; )
2471cdf0e10cSrcweir {
2472cdf0e10cSrcweir String sTmp( String::CreateFromAscii(
2473cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "|<" )) );
2474cdf0e10cSrcweir sTmp += aCells[ --i ]->GetTabBox()->GetName();
2475cdf0e10cSrcweir sTmp += '>';
2476cdf0e10cSrcweir rFml.Insert( sTmp, nInsPos );
2477cdf0e10cSrcweir }
2478cdf0e10cSrcweir }
2479cdf0e10cSrcweir else
2480cdf0e10cSrcweir nW = nBoxW;
2481cdf0e10cSrcweir }
2482cdf0e10cSrcweir else if( RES_BOXATR_VALUE == nW )
2483cdf0e10cSrcweir {
2484cdf0e10cSrcweir // values werden gesucht, Value/Formel/Text gefunden -> aufn.
2485cdf0e10cSrcweir if( RES_BOXATR_FORMULA == nBoxW &&
2486cdf0e10cSrcweir ::lcl_IsFormulaSelBoxes( *pTab->GetTable(), pCFrm->
2487cdf0e10cSrcweir GetTabBox()->GetFrmFmt()->GetTblBoxFormula(), aCells ))
2488cdf0e10cSrcweir break;
2489cdf0e10cSrcweir else if( USHRT_MAX != nBoxW )
2490cdf0e10cSrcweir rFml.Insert( cListDelim, nInsPos );
2491cdf0e10cSrcweir else
2492cdf0e10cSrcweir break;
2493cdf0e10cSrcweir }
2494cdf0e10cSrcweir else if( RES_BOXATR_FORMULA == nW )
2495cdf0e10cSrcweir {
2496cdf0e10cSrcweir // bei Formeln nur weiter suchen, wenn die akt. Formel auf
2497cdf0e10cSrcweir // alle Boxen verweist, die sich in der Selektion befinden
2498cdf0e10cSrcweir if( RES_BOXATR_FORMULA == nBoxW )
2499cdf0e10cSrcweir {
2500cdf0e10cSrcweir if( !::lcl_IsFormulaSelBoxes( *pTab->GetTable(), pCFrm->
2501cdf0e10cSrcweir GetTabBox()->GetFrmFmt()->GetTblBoxFormula(), aCells ))
2502cdf0e10cSrcweir {
2503cdf0e10cSrcweir // dann noch mal von vorne und nur die Values!
2504cdf0e10cSrcweir
2505cdf0e10cSrcweir nW = RES_BOXATR_VALUE;
2506cdf0e10cSrcweir rFml.Erase( nInsPos );
2507cdf0e10cSrcweir // alle vorhierigen Leere wieder mit aufnehmen !
2508cdf0e10cSrcweir for( sal_uInt16 i = aCells.Count(); n+1 < i; )
2509cdf0e10cSrcweir {
2510cdf0e10cSrcweir String sTmp( String::CreateFromAscii(
2511cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "|<" )) );
2512cdf0e10cSrcweir sTmp += aCells[ --i ]->GetTabBox()->GetName();
2513cdf0e10cSrcweir sTmp += '>';
2514cdf0e10cSrcweir rFml.Insert( sTmp, nInsPos );
2515cdf0e10cSrcweir }
2516cdf0e10cSrcweir }
2517cdf0e10cSrcweir else
2518cdf0e10cSrcweir rFml.Insert( cListDelim, nInsPos );
2519cdf0e10cSrcweir }
2520cdf0e10cSrcweir else if( USHRT_MAX == nBoxW )
2521cdf0e10cSrcweir break;
2522cdf0e10cSrcweir else
2523cdf0e10cSrcweir continue; // diese Boxen ignorieren
2524cdf0e10cSrcweir }
2525cdf0e10cSrcweir else
2526cdf0e10cSrcweir // alles andere beendet die Schleife
2527cdf0e10cSrcweir // evt. Texte noch zu lassen??
2528cdf0e10cSrcweir break;
2529cdf0e10cSrcweir
2530cdf0e10cSrcweir String sTmp( '<' );
2531cdf0e10cSrcweir sTmp += pCFrm->GetTabBox()->GetName();
2532cdf0e10cSrcweir sTmp += '>';
2533cdf0e10cSrcweir rFml.Insert( sTmp, nInsPos );
2534cdf0e10cSrcweir }
2535cdf0e10cSrcweir if( nW )
2536cdf0e10cSrcweir {
2537cdf0e10cSrcweir rFml += ')';
2538cdf0e10cSrcweir
2539cdf0e10cSrcweir /*
2540cdf0e10cSrcweir // TabellenSelektion erzeugen??
2541cdf0e10cSrcweir SwTblBoxFormula aTmp( rFml );
2542cdf0e10cSrcweir SwSelBoxes aBoxes;
2543cdf0e10cSrcweir for( sal_uInt16 nSelBoxes = aTmp.GetBoxesOfFormula( rTbl,aBoxes );
2544cdf0e10cSrcweir nSelBoxes; )
2545cdf0e10cSrcweir {
2546cdf0e10cSrcweir }
2547cdf0e10cSrcweir */
2548cdf0e10cSrcweir }
2549cdf0e10cSrcweir }
2550cdf0e10cSrcweir
2551cdf0e10cSrcweir return sal_True;
2552cdf0e10cSrcweir }
2553cdf0e10cSrcweir /* -----------------------------22.08.2002 12:50------------------------------
2554cdf0e10cSrcweir
2555cdf0e10cSrcweir ---------------------------------------------------------------------------*/
IsTableRightToLeft() const2556cdf0e10cSrcweir sal_Bool SwFEShell::IsTableRightToLeft() const
2557cdf0e10cSrcweir {
2558cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
2559cdf0e10cSrcweir if( !pFrm || !pFrm->IsInTab() )
2560cdf0e10cSrcweir return sal_False;
2561cdf0e10cSrcweir
2562cdf0e10cSrcweir return pFrm->ImplFindTabFrm()->IsRightToLeft();
2563cdf0e10cSrcweir }
2564cdf0e10cSrcweir
2565cdf0e10cSrcweir /* -----------------------------22.08.2002 12:50------------------------------
2566cdf0e10cSrcweir
2567cdf0e10cSrcweir ---------------------------------------------------------------------------*/
IsMouseTableRightToLeft(const Point & rPt) const2568cdf0e10cSrcweir sal_Bool SwFEShell::IsMouseTableRightToLeft(const Point &rPt) const
2569cdf0e10cSrcweir {
2570cdf0e10cSrcweir SwFrm *pFrm = (SwFrm *)GetBox( rPt );
2571cdf0e10cSrcweir const SwTabFrm* pTabFrm = pFrm ? pFrm->ImplFindTabFrm() : 0;
2572cdf0e10cSrcweir ASSERT( pTabFrm, "Table not found" );
2573cdf0e10cSrcweir return pTabFrm ? pTabFrm->IsRightToLeft() : sal_False;
2574cdf0e10cSrcweir }
2575cdf0e10cSrcweir
2576cdf0e10cSrcweir /* -----------------------------11.02.2004 12:50------------------------------
2577cdf0e10cSrcweir
2578cdf0e10cSrcweir ---------------------------------------------------------------------------*/
IsTableVertical() const2579cdf0e10cSrcweir sal_Bool SwFEShell::IsTableVertical() const
2580cdf0e10cSrcweir {
2581cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
2582cdf0e10cSrcweir if( !pFrm || !pFrm->IsInTab() )
2583cdf0e10cSrcweir return sal_False;
2584cdf0e10cSrcweir
2585cdf0e10cSrcweir return pFrm->ImplFindTabFrm()->IsVertical();
2586cdf0e10cSrcweir }
2587cdf0e10cSrcweir
2588cdf0e10cSrcweir
2589cdf0e10cSrcweir
2590