Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <vcl/dialog.hxx>
21 : #include <vcl/msgbox.hxx>
22 : #include <vcl/wrkwin.hxx>
23 : #include <viewopt.hxx>
24 : #include <frmtool.hxx>
25 : #include <viscrs.hxx>
26 : #include <crsrsh.hxx>
27 : #include <doc.hxx>
28 : #include <swtable.hxx>
29 : #include <viewimp.hxx>
30 : #include <dview.hxx>
31 : #include <rootfrm.hxx>
32 : #include <txtfrm.hxx>
33 : #include <docary.hxx>
34 : #include <extinput.hxx>
35 : #include <ndtxt.hxx>
36 : #include <scriptinfo.hxx>
37 : #include <mdiexp.hxx>
38 : #include <comcore.hrc>
39 :
40 : #include <svx/sdr/overlay/overlaymanager.hxx>
41 : #include <svx/sdrpaintwindow.hxx>
42 : #include <vcl/svapp.hxx>
43 : #include <svx/sdr/overlay/overlayselection.hxx>
44 :
45 : extern void SwCalcPixStatics( OutputDevice *pOut );
46 :
47 : // Here static members are defined. They will get changed on alteration of the
48 : // MapMode. This is done so that on ShowCrsr the same size does not have to be
49 : // expensively determined again and again.
50 :
51 : long SwSelPaintRects::nPixPtX = 0;
52 : long SwSelPaintRects::nPixPtY = 0;
53 : MapMode* SwSelPaintRects::pMapMode = 0;
54 :
55 : // ----- Starting from here: classes / methods for the non-text-cursor -----
56 :
57 793 : SwVisCrsr::SwVisCrsr( const SwCrsrShell * pCShell )
58 793 : : pCrsrShell( pCShell )
59 : {
60 793 : pCShell->GetWin()->SetCursor( &aTxtCrsr );
61 793 : bIsVisible = aTxtCrsr.IsVisible();
62 793 : bIsDragCrsr = false;
63 793 : aTxtCrsr.SetWidth( 0 );
64 793 : }
65 :
66 :
67 :
68 1584 : SwVisCrsr::~SwVisCrsr()
69 : {
70 792 : if( bIsVisible && aTxtCrsr.IsVisible() )
71 6 : aTxtCrsr.Hide();
72 :
73 792 : pCrsrShell->GetWin()->SetCursor( 0 );
74 792 : }
75 :
76 :
77 :
78 :
79 40179 : void SwVisCrsr::Show()
80 : {
81 40179 : if( !bIsVisible )
82 : {
83 21326 : bIsVisible = true;
84 :
85 : // display at all?
86 21326 : if( pCrsrShell->VisArea().IsOver( pCrsrShell->m_aCharRect ) )
87 18087 : _SetPosAndShow();
88 : }
89 40179 : }
90 :
91 :
92 :
93 25562 : void SwVisCrsr::Hide()
94 : {
95 25562 : if( bIsVisible )
96 : {
97 21303 : bIsVisible = false;
98 :
99 21303 : if( aTxtCrsr.IsVisible() ) // Shouldn't the flags be in effect?
100 18069 : aTxtCrsr.Hide();
101 : }
102 25562 : }
103 :
104 18087 : void SwVisCrsr::_SetPosAndShow()
105 : {
106 18087 : SwRect aRect;
107 18087 : long nTmpY = pCrsrShell->m_aCrsrHeight.getY();
108 18087 : if( 0 > nTmpY )
109 : {
110 0 : nTmpY = -nTmpY;
111 0 : aTxtCrsr.SetOrientation( 900 );
112 0 : aRect = SwRect( pCrsrShell->m_aCharRect.Pos(),
113 0 : Size( pCrsrShell->m_aCharRect.Height(), nTmpY ) );
114 0 : aRect.Pos().setX(aRect.Pos().getX() + pCrsrShell->m_aCrsrHeight.getX());
115 0 : if( pCrsrShell->IsOverwriteCrsr() )
116 0 : aRect.Pos().setY(aRect.Pos().getY() + aRect.Width());
117 : }
118 : else
119 : {
120 18087 : aTxtCrsr.SetOrientation( 0 );
121 36174 : aRect = SwRect( pCrsrShell->m_aCharRect.Pos(),
122 18087 : Size( pCrsrShell->m_aCharRect.Width(), nTmpY ) );
123 18087 : aRect.Pos().setY(aRect.Pos().getY() + pCrsrShell->m_aCrsrHeight.getX());
124 : }
125 :
126 : // check if cursor should show the current cursor bidi level
127 18087 : aTxtCrsr.SetDirection( CURSOR_DIRECTION_NONE );
128 18087 : const SwCursor* pTmpCrsr = pCrsrShell->_GetCrsr();
129 :
130 18087 : if ( pTmpCrsr && !pCrsrShell->IsOverwriteCrsr() )
131 : {
132 18087 : SwNode& rNode = pTmpCrsr->GetPoint()->nNode.GetNode();
133 18087 : if( rNode.IsTxtNode() )
134 : {
135 18087 : const SwTxtNode& rTNd = *rNode.GetTxtNode();
136 18087 : const SwFrm* pFrm = rTNd.getLayoutFrm( pCrsrShell->GetLayout(), 0, 0, sal_False );
137 18087 : if ( pFrm )
138 : {
139 18087 : const SwScriptInfo* pSI = ((SwTxtFrm*)pFrm)->GetScriptInfo();
140 : // cursor level has to be shown
141 18087 : if ( pSI && pSI->CountDirChg() > 1 )
142 : {
143 : aTxtCrsr.SetDirection(
144 0 : ( pTmpCrsr->GetCrsrBidiLevel() % 2 ) ?
145 : CURSOR_DIRECTION_RTL :
146 0 : CURSOR_DIRECTION_LTR );
147 : }
148 :
149 18087 : if ( pFrm->IsRightToLeft() )
150 : {
151 15 : const OutputDevice *pOut = pCrsrShell->GetOut();
152 15 : if ( pOut )
153 : {
154 15 : long nSize = pOut->GetSettings().GetStyleSettings().GetCursorSize();
155 15 : Size aSize( nSize, nSize );
156 15 : aSize = pOut->PixelToLogic( aSize );
157 15 : aRect.Left( aRect.Left() - aSize.Width() );
158 : }
159 : }
160 : }
161 : }
162 : }
163 :
164 18087 : if( aRect.Height() )
165 : {
166 18022 : ::SwCalcPixStatics( pCrsrShell->GetOut() );
167 18022 : ::SwAlignRect( aRect, (ViewShell*)pCrsrShell );
168 : }
169 18087 : if( !pCrsrShell->IsOverwriteCrsr() || bIsDragCrsr ||
170 0 : pCrsrShell->IsSelection() )
171 18087 : aRect.Width( 0 );
172 :
173 18087 : aTxtCrsr.SetSize( aRect.SSize() );
174 :
175 18087 : aTxtCrsr.SetPos( aRect.Pos() );
176 18087 : if ( !pCrsrShell->IsCrsrReadonly() || pCrsrShell->GetViewOptions()->IsSelectionInReadonly() )
177 : {
178 18075 : if ( pCrsrShell->GetDrawView() )
179 18075 : ((SwDrawView*)pCrsrShell->GetDrawView())->SetAnimationEnabled(
180 36150 : !pCrsrShell->IsSelection() );
181 :
182 18075 : sal_uInt16 nStyle = bIsDragCrsr ? CURSOR_SHADOW : 0;
183 18075 : if( nStyle != aTxtCrsr.GetStyle() )
184 : {
185 0 : aTxtCrsr.SetStyle( nStyle );
186 0 : aTxtCrsr.SetWindow( bIsDragCrsr ? pCrsrShell->GetWin() : 0 );
187 : }
188 :
189 18075 : aTxtCrsr.Show();
190 : }
191 18087 : }
192 :
193 :
194 823 : SwSelPaintRects::SwSelPaintRects( const SwCrsrShell& rCSh )
195 : : SwRects(),
196 : pCShell( &rCSh ),
197 823 : mpCursorOverlay(0)
198 : {
199 823 : }
200 :
201 1644 : SwSelPaintRects::~SwSelPaintRects()
202 : {
203 822 : Hide();
204 822 : }
205 :
206 0 : void SwSelPaintRects::swapContent(SwSelPaintRects& rSwap)
207 : {
208 0 : SwRects::swap(rSwap);
209 :
210 : // #i75172# also swap mpCursorOverlay
211 0 : sdr::overlay::OverlayObject* pTempOverlay = getCursorOverlay();
212 0 : setCursorOverlay(rSwap.getCursorOverlay());
213 0 : rSwap.setCursorOverlay(pTempOverlay);
214 0 : }
215 :
216 5081 : void SwSelPaintRects::Hide()
217 : {
218 5081 : if(mpCursorOverlay)
219 : {
220 62 : delete mpCursorOverlay;
221 62 : mpCursorOverlay = 0;
222 : }
223 :
224 5081 : SwRects::clear();
225 5081 : }
226 :
227 42077 : void SwSelPaintRects::Show()
228 : {
229 42077 : SdrView* pView = (SdrView*)pCShell->GetDrawView();
230 :
231 42077 : if(pView && pView->PaintWindowCount())
232 : {
233 : // reset rects
234 42077 : SwRects::clear();
235 42077 : FillRects();
236 :
237 : // get new rects
238 42077 : std::vector< basegfx::B2DRange > aNewRanges;
239 :
240 42408 : for(sal_uInt16 a(0); a < size(); a++)
241 : {
242 331 : const SwRect aNextRect((*this)[a]);
243 331 : const Rectangle aPntRect(aNextRect.SVRect());
244 :
245 : aNewRanges.push_back(basegfx::B2DRange(
246 662 : aPntRect.Left(), aPntRect.Top(),
247 993 : aPntRect.Right() + 1, aPntRect.Bottom() + 1));
248 : }
249 :
250 42077 : if(mpCursorOverlay)
251 : {
252 177 : if(!aNewRanges.empty())
253 : {
254 167 : static_cast< sdr::overlay::OverlaySelection* >(mpCursorOverlay)->setRanges(aNewRanges);
255 : }
256 : else
257 : {
258 10 : delete mpCursorOverlay;
259 10 : mpCursorOverlay = 0;
260 : }
261 : }
262 41900 : else if(!empty())
263 : {
264 72 : SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
265 72 : rtl::Reference< ::sdr::overlay::OverlayManager > xTargetOverlay = pCandidate->GetOverlayManager();
266 :
267 72 : if (xTargetOverlay.is())
268 : {
269 : // get the system's hilight color
270 72 : const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
271 72 : const Color aHighlight(aSvtOptionsDrawinglayer.getHilightColor());
272 :
273 : // create correct selection
274 : mpCursorOverlay = new sdr::overlay::OverlaySelection(
275 : sdr::overlay::OVERLAY_TRANSPARENT,
276 : aHighlight,
277 : aNewRanges,
278 72 : true);
279 :
280 72 : xTargetOverlay->add(*mpCursorOverlay);
281 72 : }
282 42077 : }
283 : }
284 42077 : }
285 :
286 2855 : void SwSelPaintRects::Invalidate( const SwRect& rRect )
287 : {
288 2855 : sal_uInt16 nSz = size();
289 2855 : if( !nSz )
290 5704 : return;
291 :
292 6 : SwRegionRects aReg( GetShell()->VisArea() );
293 6 : aReg.assign( begin(), end() );
294 6 : aReg -= rRect;
295 6 : SwRects::erase( begin(), begin() + nSz );
296 6 : SwRects::insert( begin(), aReg.begin(), aReg.end() );
297 :
298 : // If the selection is to the right or at the bottom, outside the
299 : // visible area, it is never aligned on one pixel at the right/bottom.
300 : // This has to be determined here and if that is the case the
301 : // rectangle has to be expanded.
302 6 : if( GetShell()->m_bVisPortChgd && 0 != ( nSz = size()) )
303 : {
304 0 : SwSelPaintRects::Get1PixelInLogic( *GetShell() );
305 0 : iterator it = begin();
306 0 : for( ; nSz--; ++it )
307 : {
308 0 : SwRect& rRectIt = *it;
309 0 : if( rRectIt.Right() == GetShell()->m_aOldRBPos.X() )
310 0 : rRectIt.Right( rRectIt.Right() + nPixPtX );
311 0 : if( rRectIt.Bottom() == GetShell()->m_aOldRBPos.Y() )
312 0 : rRectIt.Bottom( rRectIt.Bottom() + nPixPtY );
313 : }
314 6 : }
315 : }
316 :
317 0 : void SwSelPaintRects::Paint( const Rectangle& /*rRect*/ )
318 : {
319 : // nothing to do with overlays
320 0 : }
321 :
322 :
323 : // check current MapMode of the shell and set possibly the static members.
324 : // Optional set the parameters pX, pY
325 1 : void SwSelPaintRects::Get1PixelInLogic( const ViewShell& rSh,
326 : long* pX, long* pY )
327 : {
328 1 : const OutputDevice* pOut = rSh.GetWin();
329 1 : if ( ! pOut )
330 0 : pOut = rSh.GetOut();
331 :
332 1 : const MapMode& rMM = pOut->GetMapMode();
333 2 : if( pMapMode->GetMapUnit() != rMM.GetMapUnit() ||
334 1 : pMapMode->GetScaleX() != rMM.GetScaleX() ||
335 0 : pMapMode->GetScaleY() != rMM.GetScaleY() )
336 : {
337 1 : *pMapMode = rMM;
338 1 : Size aTmp( 1, 1 );
339 1 : aTmp = pOut->PixelToLogic( aTmp );
340 1 : nPixPtX = aTmp.Width();
341 1 : nPixPtY = aTmp.Height();
342 : }
343 1 : if( pX )
344 1 : *pX = nPixPtX;
345 1 : if( pY )
346 1 : *pY = nPixPtY;
347 1 : }
348 :
349 :
350 :
351 797 : SwShellCrsr::SwShellCrsr( const SwCrsrShell& rCShell, const SwPosition &rPos )
352 797 : : SwCursor(rPos,0,false), SwSelPaintRects(rCShell), pPt(SwPaM::GetPoint())
353 797 : {}
354 :
355 :
356 26 : SwShellCrsr::SwShellCrsr( const SwCrsrShell& rCShell, const SwPosition &rPos,
357 : const Point& rPtPos, SwPaM* pRing )
358 : : SwCursor(rPos, pRing, false), SwSelPaintRects(rCShell), aMkPt(rPtPos),
359 26 : aPtPt(rPtPos), pPt(SwPaM::GetPoint())
360 26 : {}
361 :
362 :
363 0 : SwShellCrsr::SwShellCrsr( SwShellCrsr& rICrsr )
364 0 : : SwCursor(rICrsr), SwSelPaintRects(*rICrsr.GetShell()),
365 0 : aMkPt(rICrsr.GetMkPos()), aPtPt(rICrsr.GetPtPos()), pPt(SwPaM::GetPoint())
366 0 : {}
367 :
368 1640 : SwShellCrsr::~SwShellCrsr() {}
369 :
370 :
371 113 : bool SwShellCrsr::IsReadOnlyAvailable() const
372 : {
373 113 : return GetShell()->IsReadOnlyAvailable();
374 : }
375 :
376 67 : void SwShellCrsr::SetMark()
377 : {
378 67 : if( SwPaM::GetPoint() == pPt )
379 31 : aMkPt = aPtPt;
380 : else
381 36 : aPtPt = aMkPt;
382 67 : SwPaM::SetMark();
383 67 : }
384 :
385 42060 : void SwShellCrsr::FillRects()
386 : {
387 : // calculate the new rectangles
388 84353 : if( HasMark() &&
389 466 : GetPoint()->nNode.GetNode().IsCntntNode() &&
390 42759 : GetPoint()->nNode.GetNode().GetCntntNode()->getLayoutFrm( GetShell()->GetLayout() ) &&
391 239 : (GetMark()->nNode == GetPoint()->nNode ||
392 12 : (GetMark()->nNode.GetNode().IsCntntNode() &&
393 6 : GetMark()->nNode.GetNode().GetCntntNode()->getLayoutFrm( GetShell()->GetLayout() ) ) ))
394 233 : GetShell()->GetLayout()->CalcFrmRects( *this, GetShell()->IsTableMode() ); //swmod 071107//swmod 071225
395 42060 : }
396 :
397 :
398 24122 : void SwShellCrsr::Show()
399 : {
400 24122 : SwShellCrsr * pTmp = this;
401 24122 : do {
402 24122 : pTmp->SwSelPaintRects::Show();
403 24122 : } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) );
404 24122 : }
405 :
406 : // This rectangle gets painted anew, therefore the SSelection in this
407 : // area is invalid.
408 2855 : void SwShellCrsr::Invalidate( const SwRect& rRect )
409 : {
410 2855 : SwShellCrsr * pTmp = this;
411 :
412 2855 : do
413 : {
414 2855 : pTmp->SwSelPaintRects::Invalidate( rRect );
415 :
416 : // skip any non SwShellCrsr objects in the ring
417 : // see also: SwAutoFormat::DeleteSel()
418 2855 : Ring* pTmpRing = pTmp;
419 2855 : pTmp = 0;
420 2855 : do
421 : {
422 2855 : pTmpRing = pTmpRing->GetNext();
423 2855 : pTmp = dynamic_cast<SwShellCrsr*>(pTmpRing);
424 : }
425 : while ( !pTmp );
426 : }
427 : while( this != pTmp );
428 2855 : }
429 :
430 :
431 4255 : void SwShellCrsr::Hide()
432 : {
433 4255 : SwShellCrsr * pTmp = this;
434 4255 : do {
435 4255 : pTmp->SwSelPaintRects::Hide();
436 4255 : } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) );
437 4255 : }
438 :
439 12 : SwCursor* SwShellCrsr::Create( SwPaM* pRing ) const
440 : {
441 12 : return new SwShellCrsr( *GetShell(), *GetPoint(), GetPtPos(), pRing );
442 : }
443 :
444 :
445 0 : short SwShellCrsr::MaxReplaceArived()
446 : {
447 0 : short nRet = RET_YES;
448 0 : Window* pDlg = ::GetSearchDialog();
449 0 : if( pDlg )
450 : {
451 : // Terminate old actions. The table-frames get constructed and
452 : // a SSelection can be created.
453 0 : std::vector<sal_uInt16> aArr;
454 : sal_uInt16 nActCnt;
455 0 : ViewShell *pShell = const_cast< SwCrsrShell* >( GetShell() ),
456 0 : *pSh = pShell;
457 0 : do {
458 0 : for( nActCnt = 0; pSh->ActionPend(); ++nActCnt )
459 0 : pSh->EndAction();
460 0 : aArr.push_back( nActCnt );
461 0 : } while( pShell != ( pSh = (ViewShell*)pSh->GetNext() ) );
462 :
463 : {
464 0 : nRet = QueryBox( pDlg, SW_RES( MSG_COMCORE_ASKSEARCH )).Execute();
465 : }
466 :
467 0 : for( sal_uInt16 n = 0; n < aArr.size(); ++n )
468 : {
469 0 : for( nActCnt = aArr[n]; nActCnt--; )
470 0 : pSh->StartAction();
471 0 : pSh = (ViewShell*)pSh->GetNext();
472 0 : } //swmod 071107 //swmod 071225
473 : }
474 : else
475 : // otherwise from the Basic, and than switch to RET_YES
476 0 : nRet = RET_YES;
477 :
478 0 : return nRet;
479 : }
480 :
481 0 : void SwShellCrsr::SaveTblBoxCntnt( const SwPosition* pPos )
482 : {
483 0 : ((SwCrsrShell*)GetShell())->SaveTblBoxCntnt( pPos );
484 0 : }
485 :
486 0 : sal_Bool SwShellCrsr::UpDown( sal_Bool bUp, sal_uInt16 nCnt )
487 : {
488 : return SwCursor::UpDown( bUp, nCnt,
489 0 : &GetPtPos(), GetShell()->GetUpDownX() );
490 : }
491 :
492 : // if <true> than the cursor can be set to the position.
493 2 : sal_Bool SwShellCrsr::IsAtValidPos( sal_Bool bPoint ) const
494 : {
495 4 : if( GetShell() && ( GetShell()->IsAllProtect() ||
496 4 : GetShell()->GetViewOptions()->IsReadonly() ||
497 4 : ( GetShell()->Imp()->GetDrawView() &&
498 2 : GetShell()->Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() )))
499 0 : return sal_True;
500 :
501 2 : return SwCursor::IsAtValidPos( bPoint );
502 : }
503 :
504 :
505 2 : SwShellTableCrsr::SwShellTableCrsr( const SwCrsrShell& rCrsrSh,
506 : const SwPosition& rPos )
507 2 : : SwCursor(rPos,0,false), SwShellCrsr(rCrsrSh, rPos), SwTableCursor(rPos)
508 : {
509 2 : }
510 :
511 2 : SwShellTableCrsr::SwShellTableCrsr( const SwCrsrShell& rCrsrSh,
512 : const SwPosition& rMkPos, const Point& rMkPt,
513 : const SwPosition& rPtPos, const Point& rPtPt )
514 2 : : SwCursor(rPtPos,0,false), SwShellCrsr(rCrsrSh, rPtPos), SwTableCursor(rPtPos)
515 : {
516 2 : SetMark();
517 2 : *GetMark() = rMkPos;
518 2 : GetMkPos() = rMkPt;
519 2 : GetPtPos() = rPtPt;
520 2 : }
521 :
522 8 : SwShellTableCrsr::~SwShellTableCrsr() {}
523 :
524 4 : void SwShellTableCrsr::SetMark() { SwShellCrsr::SetMark(); }
525 :
526 0 : SwCursor* SwShellTableCrsr::Create( SwPaM* pRing ) const
527 : {
528 0 : return SwShellCrsr::Create( pRing );
529 : }
530 0 : short SwShellTableCrsr::MaxReplaceArived()
531 : {
532 0 : return SwShellCrsr::MaxReplaceArived();
533 : }
534 0 : void SwShellTableCrsr::SaveTblBoxCntnt( const SwPosition* pPos )
535 : {
536 0 : SwShellCrsr::SaveTblBoxCntnt( pPos );
537 0 : }
538 :
539 :
540 17 : void SwShellTableCrsr::FillRects()
541 : {
542 : // Calculate the new rectangles. If the cursor is still "parked" do nothing
543 17 : if (m_SelectedBoxes.empty() || bParked || !GetPoint()->nNode.GetIndex())
544 17 : return;
545 :
546 17 : SwRegionRects aReg( GetShell()->VisArea() );
547 17 : SwNodes& rNds = GetDoc()->GetNodes();
548 67 : for (size_t n = 0; n < m_SelectedBoxes.size(); ++n)
549 : {
550 50 : const SwStartNode* pSttNd = m_SelectedBoxes[n]->GetSttNd();
551 50 : const SwTableNode* pSelTblNd = pSttNd->FindTableNode();
552 :
553 50 : SwNodeIndex aIdx( *pSttNd );
554 50 : SwCntntNode* pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False );
555 :
556 : // table in table
557 : // (see also lcl_FindTopLevelTable in unoobj2.cxx for a different
558 : // version to do this)
559 50 : const SwTableNode* pCurTblNd = pCNd->FindTableNode();
560 100 : while ( pSelTblNd != pCurTblNd && pCurTblNd )
561 : {
562 0 : aIdx = pCurTblNd->EndOfSectionIndex();
563 0 : pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False );
564 0 : pCurTblNd = pCNd->FindTableNode();
565 : }
566 :
567 50 : if( !pCNd )
568 0 : continue;
569 :
570 50 : SwFrm* pFrm = pCNd->getLayoutFrm( GetShell()->GetLayout(), &GetSttPos() );
571 150 : while( pFrm && !pFrm->IsCellFrm() )
572 50 : pFrm = pFrm->GetUpper();
573 :
574 : OSL_ENSURE( pFrm, "Node not in a table" );
575 :
576 150 : while ( pFrm )
577 : {
578 50 : if( aReg.GetOrigin().IsOver( pFrm->Frm() ) )
579 50 : aReg -= pFrm->Frm();
580 :
581 50 : pFrm = pFrm->GetNextCellLeaf( MAKEPAGE_NONE );
582 : }
583 50 : }
584 17 : aReg.Invert();
585 17 : insert( begin(), aReg.begin(), aReg.end() );
586 : }
587 :
588 :
589 : // Check if the SPoint is within the Table-SSelection.
590 0 : sal_Bool SwShellTableCrsr::IsInside( const Point& rPt ) const
591 : {
592 : // Calculate the new rectangles. If the cursor is still "parked" do nothing
593 0 : if (m_SelectedBoxes.empty() || bParked || !GetPoint()->nNode.GetIndex())
594 0 : return sal_False;
595 :
596 0 : SwNodes& rNds = GetDoc()->GetNodes();
597 0 : for (size_t n = 0; n < m_SelectedBoxes.size(); ++n)
598 : {
599 0 : SwNodeIndex aIdx( *m_SelectedBoxes[n]->GetSttNd() );
600 0 : SwCntntNode* pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False );
601 0 : if( !pCNd )
602 0 : continue;
603 :
604 0 : SwFrm* pFrm = pCNd->getLayoutFrm( GetShell()->GetLayout(), &GetPtPos() );
605 0 : while( pFrm && !pFrm->IsCellFrm() )
606 0 : pFrm = pFrm->GetUpper();
607 : OSL_ENSURE( pFrm, "Node not in a table" );
608 0 : if( pFrm && pFrm->Frm().IsInside( rPt ) )
609 0 : return sal_True;
610 0 : }
611 0 : return sal_False;
612 : }
613 :
614 2 : sal_Bool SwShellTableCrsr::IsAtValidPos( sal_Bool bPoint ) const
615 : {
616 2 : return SwShellCrsr::IsAtValidPos( bPoint );
617 99 : }
618 :
619 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|