Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <vcl/dialog.hxx>
30 : : #include <vcl/msgbox.hxx>
31 : : #include <vcl/wrkwin.hxx>
32 : : #include <viewopt.hxx>
33 : : #include <frmtool.hxx>
34 : : #include <viscrs.hxx>
35 : : #include <crsrsh.hxx>
36 : : #include <doc.hxx>
37 : : #include <swtable.hxx>
38 : : #include <viewimp.hxx>
39 : : #include <dview.hxx>
40 : : #include <rootfrm.hxx>
41 : : #include <txtfrm.hxx>
42 : : #include <docary.hxx>
43 : : #include <extinput.hxx>
44 : : #include <ndtxt.hxx>
45 : : #include <scriptinfo.hxx>
46 : : #include <mdiexp.hxx>
47 : : #include <comcore.hrc>
48 : :
49 : : #include <svx/sdr/overlay/overlaymanager.hxx>
50 : : #include <svx/sdrpaintwindow.hxx>
51 : : #include <vcl/svapp.hxx>
52 : : #include <svx/sdr/overlay/overlayselection.hxx>
53 : :
54 : : extern void SwCalcPixStatics( OutputDevice *pOut );
55 : :
56 : : // Here static members are defined. They will get changed on alteration of the
57 : : // MapMode. This is done so that on ShowCrsr the same size does not have to be
58 : : // expensively determined again and again.
59 : :
60 : : long SwSelPaintRects::nPixPtX = 0;
61 : : long SwSelPaintRects::nPixPtY = 0;
62 : : MapMode* SwSelPaintRects::pMapMode = 0;
63 : :
64 : : // ----- Starting from here: classes / methods for the non-text-cursor -----
65 : :
66 : 1318 : SwVisCrsr::SwVisCrsr( const SwCrsrShell * pCShell )
67 : 1318 : : pCrsrShell( pCShell )
68 : : {
69 [ + - ]: 1318 : pCShell->GetWin()->SetCursor( &aTxtCrsr );
70 : 1318 : bIsVisible = aTxtCrsr.IsVisible();
71 : 1318 : bIsDragCrsr = sal_False;
72 [ + - ]: 1318 : aTxtCrsr.SetWidth( 0 );
73 : :
74 : : #ifdef SW_CRSR_TIMER
75 : : bTimerOn = sal_True;
76 : : SetTimeout( 50 ); // 50 millisecond delay
77 : : #endif
78 : 1318 : }
79 : :
80 : :
81 : :
82 : 1231 : SwVisCrsr::~SwVisCrsr()
83 : : {
84 : : #ifdef SW_CRSR_TIMER
85 : : if( bTimerOn )
86 : : Stop(); // stop timer
87 : : #endif
88 : :
89 [ + + ][ + + ]: 1231 : if( bIsVisible && aTxtCrsr.IsVisible() )
[ + + ]
90 [ + - ]: 12 : aTxtCrsr.Hide();
91 : :
92 [ + - ]: 1231 : pCrsrShell->GetWin()->SetCursor( 0 );
93 : 1231 : }
94 : :
95 : :
96 : :
97 : :
98 : 75804 : void SwVisCrsr::Show()
99 : : {
100 [ + + ]: 75804 : if( !bIsVisible )
101 : : {
102 : 40154 : bIsVisible = sal_True;
103 : :
104 : : // display at all?
105 [ + + ]: 40154 : if( pCrsrShell->VisArea().IsOver( pCrsrShell->aCharRect ) )
106 : : #ifdef SW_CRSR_TIMER
107 : : {
108 : : if( bTimerOn )
109 : : Start(); // start timer
110 : : else
111 : : {
112 : : if( IsActive() )
113 : : Stop(); // stop timer
114 : :
115 : : _SetPosAndShow();
116 : : }
117 : : }
118 : : #else
119 : 35948 : _SetPosAndShow();
120 : : #endif
121 : : }
122 : 75804 : }
123 : :
124 : :
125 : :
126 : 48168 : void SwVisCrsr::Hide()
127 : : {
128 [ + + ]: 48168 : if( bIsVisible )
129 : : {
130 : 40122 : bIsVisible = sal_False;
131 : :
132 : : #ifdef SW_CRSR_TIMER
133 : : if( IsActive() )
134 : : Stop(); // stop timer
135 : : #endif
136 : :
137 [ + + ]: 40122 : if( aTxtCrsr.IsVisible() ) // Shouldn't the flags be in effect?
138 : 35906 : aTxtCrsr.Hide();
139 : : }
140 : 48168 : }
141 : :
142 : : #ifdef SW_CRSR_TIMER
143 : :
144 : : void SwVisCrsr::Timeout()
145 : : {
146 : : OSL_ENSURE( !bIsDragCrsr, "stop timer before" );
147 : : if( bIsVisible )
148 : : {
149 : : if ( !pCrsrShell->GetWin() ) // SwFrmFmt::GetGraphic suspends Win temporarily!
150 : : Start();
151 : : else
152 : : _SetPosAndShow();
153 : : }
154 : : }
155 : :
156 : : sal_Bool SwCrsrShell::ChgCrsrTimerFlag( sal_Bool bTimerOn )
157 : : {
158 : : return pVisCrsr->ChgTimerFlag( bTimerOn );
159 : : }
160 : :
161 : :
162 : : sal_Bool SwVisCrsr::ChgTimerFlag( sal_Bool bFlag )
163 : : {
164 : : bOld = bTimerOn;
165 : : if( !bFlag && bIsVisible && IsActive() )
166 : : {
167 : : Stop(); // stop timer
168 : : _SetPosAndShow();
169 : : }
170 : : bTimerOn = bFlag;
171 : : return bOld;
172 : : }
173 : :
174 : : #endif
175 : :
176 : :
177 : 35948 : void SwVisCrsr::_SetPosAndShow()
178 : : {
179 : 35948 : SwRect aRect;
180 : 35948 : long nTmpY = pCrsrShell->aCrsrHeight.Y();
181 [ - + ]: 35948 : if( 0 > nTmpY )
182 : : {
183 : 0 : nTmpY = -nTmpY;
184 [ # # ]: 0 : aTxtCrsr.SetOrientation( 900 );
185 : 0 : aRect = SwRect( pCrsrShell->aCharRect.Pos(),
186 : 0 : Size( pCrsrShell->aCharRect.Height(), nTmpY ) );
187 : 0 : aRect.Pos().X() += pCrsrShell->aCrsrHeight.X();
188 [ # # ]: 0 : if( pCrsrShell->IsOverwriteCrsr() )
189 : 0 : aRect.Pos().Y() += aRect.Width();
190 : : }
191 : : else
192 : : {
193 [ + - ]: 35948 : aTxtCrsr.SetOrientation( 0 );
194 : 35948 : aRect = SwRect( pCrsrShell->aCharRect.Pos(),
195 : 71896 : Size( pCrsrShell->aCharRect.Width(), nTmpY ) );
196 : 35948 : aRect.Pos().Y() += pCrsrShell->aCrsrHeight.X();
197 : : }
198 : :
199 : : // check if cursor should show the current cursor bidi level
200 [ + - ]: 35948 : aTxtCrsr.SetDirection( CURSOR_DIRECTION_NONE );
201 [ + - ]: 35948 : const SwCursor* pTmpCrsr = pCrsrShell->_GetCrsr();
202 : :
203 [ + - ][ + - ]: 35948 : if ( pTmpCrsr && !pCrsrShell->IsOverwriteCrsr() )
[ + - ]
204 : : {
205 : 35948 : SwNode& rNode = pTmpCrsr->GetPoint()->nNode.GetNode();
206 [ + - ]: 35948 : if( rNode.IsTxtNode() )
207 : : {
208 : 35948 : const SwTxtNode& rTNd = *rNode.GetTxtNode();
209 [ + - ][ + - ]: 35948 : const SwFrm* pFrm = rTNd.getLayoutFrm( pCrsrShell->GetLayout(), 0, 0, sal_False );
210 [ + - ]: 35948 : if ( pFrm )
211 : : {
212 [ + - ]: 35948 : const SwScriptInfo* pSI = ((SwTxtFrm*)pFrm)->GetScriptInfo();
213 : : // cursor level has to be shown
214 [ + + ][ - + ]: 35948 : if ( pSI && pSI->CountDirChg() > 1 )
[ - + ]
215 : : {
216 : : aTxtCrsr.SetDirection(
217 : 0 : ( pTmpCrsr->GetCrsrBidiLevel() % 2 ) ?
218 : : CURSOR_DIRECTION_RTL :
219 [ # # ][ # # ]: 0 : CURSOR_DIRECTION_LTR );
220 : : }
221 : :
222 [ + - ][ - + ]: 35948 : if ( pFrm->IsRightToLeft() )
223 : : {
224 : 0 : const OutputDevice *pOut = pCrsrShell->GetOut();
225 [ # # ]: 0 : if ( pOut )
226 : : {
227 : 0 : long nSize = pOut->GetSettings().GetStyleSettings().GetCursorSize();
228 : 0 : Size aSize( nSize, nSize );
229 [ # # ]: 0 : aSize = pOut->PixelToLogic( aSize );
230 : 0 : aRect.Left( aRect.Left() - aSize.Width() );
231 : : }
232 : : }
233 : : }
234 : : }
235 : : }
236 : :
237 [ + + ]: 35948 : if( aRect.Height() )
238 : : {
239 [ + - ]: 35864 : ::SwCalcPixStatics( pCrsrShell->GetOut() );
240 [ + - ]: 35864 : ::SwAlignRect( aRect, (ViewShell*)pCrsrShell );
241 : : }
242 [ - + ]: 35948 : if( !pCrsrShell->IsOverwriteCrsr() || bIsDragCrsr ||
[ # # # # ]
[ + - ]
243 : 0 : pCrsrShell->IsSelection() )
244 : 35948 : aRect.Width( 0 );
245 : :
246 [ + - ]: 35948 : aTxtCrsr.SetSize( aRect.SSize() );
247 : :
248 [ + - ]: 35948 : aTxtCrsr.SetPos( aRect.Pos() );
249 [ + - ][ + + ]: 35948 : if ( !pCrsrShell->IsCrsrReadonly() || pCrsrShell->GetViewOptions()->IsSelectionInReadonly() )
[ - + ][ + + ]
250 : : {
251 [ + - ][ + - ]: 35918 : if ( pCrsrShell->GetDrawView() )
252 [ + - ]: 35918 : ((SwDrawView*)pCrsrShell->GetDrawView())->SetAnimationEnabled(
253 [ + - ]: 71836 : !pCrsrShell->IsSelection() );
254 : :
255 [ - + ]: 35918 : sal_uInt16 nStyle = bIsDragCrsr ? CURSOR_SHADOW : 0;
256 [ - + ]: 35918 : if( nStyle != aTxtCrsr.GetStyle() )
257 : : {
258 [ # # ]: 0 : aTxtCrsr.SetStyle( nStyle );
259 [ # # ][ # # ]: 0 : aTxtCrsr.SetWindow( bIsDragCrsr ? pCrsrShell->GetWin() : 0 );
260 : : }
261 : :
262 [ + - ]: 35918 : aTxtCrsr.Show();
263 : : }
264 : 35948 : }
265 : :
266 : :
267 : 1367 : SwSelPaintRects::SwSelPaintRects( const SwCrsrShell& rCSh )
268 : : : SwRects(),
269 : : pCShell( &rCSh ),
270 : 1367 : mpCursorOverlay(0)
271 : : {
272 : 1367 : }
273 : :
274 : 1280 : SwSelPaintRects::~SwSelPaintRects()
275 : : {
276 [ + - ]: 1280 : Hide();
277 [ - + ]: 1280 : }
278 : :
279 : 0 : void SwSelPaintRects::swapContent(SwSelPaintRects& rSwap)
280 : : {
281 : 0 : SwRects::swap(rSwap);
282 : :
283 : : // #i75172# also swap mpCursorOverlay
284 : 0 : sdr::overlay::OverlayObject* pTempOverlay = getCursorOverlay();
285 : 0 : setCursorOverlay(rSwap.getCursorOverlay());
286 : 0 : rSwap.setCursorOverlay(pTempOverlay);
287 : 0 : }
288 : :
289 : 9453 : void SwSelPaintRects::Hide()
290 : : {
291 [ + + ]: 9453 : if(mpCursorOverlay)
292 : : {
293 [ + - ]: 124 : delete mpCursorOverlay;
294 : 124 : mpCursorOverlay = 0;
295 : : }
296 : :
297 : 9453 : SwRects::clear();
298 : 9453 : }
299 : :
300 : 80928 : void SwSelPaintRects::Show()
301 : : {
302 : 80928 : SdrView* pView = (SdrView*)pCShell->GetDrawView();
303 : :
304 [ + - ][ + - ]: 80928 : if(pView && pView->PaintWindowCount())
[ + - ]
305 : : {
306 : : // reset rects
307 : 80928 : SwRects::clear();
308 [ + - ]: 80928 : FillRects();
309 : :
310 : : // get new rects
311 [ + - ]: 80928 : std::vector< basegfx::B2DRange > aNewRanges;
312 : :
313 [ + + ]: 81602 : for(sal_uInt16 a(0); a < size(); a++)
314 : : {
315 : 674 : const SwRect aNextRect((*this)[a]);
316 [ + - ]: 674 : const Rectangle aPntRect(aNextRect.SVRect());
317 : :
318 : : aNewRanges.push_back(basegfx::B2DRange(
319 : 674 : aPntRect.Left(), aPntRect.Top(),
320 [ + - ][ + - ]: 1348 : aPntRect.Right() + 1, aPntRect.Bottom() + 1));
321 : : }
322 : :
323 [ + + ]: 80928 : if(mpCursorOverlay)
324 : : {
325 [ + + ]: 356 : if(!aNewRanges.empty())
326 : : {
327 [ + - ]: 336 : static_cast< sdr::overlay::OverlaySelection* >(mpCursorOverlay)->setRanges(aNewRanges);
328 : : }
329 : : else
330 : : {
331 [ + - ][ + - ]: 20 : delete mpCursorOverlay;
332 : 20 : mpCursorOverlay = 0;
333 : : }
334 : : }
335 [ + + ]: 80572 : else if(!empty())
336 : : {
337 [ + - ]: 144 : SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
338 [ + - ]: 144 : rtl::Reference< ::sdr::overlay::OverlayManager > xTargetOverlay = pCandidate->GetOverlayManager();
339 : :
340 [ + - ]: 144 : if (xTargetOverlay.is())
341 : : {
342 : : // #i97672# get the system's highlight color and limit it to the
343 : : // maximum allowed luminance. This is needed to react on too bright
344 : : // highlight colors which would otherwise vive a bad visualisation.
345 [ + - ]: 144 : const OutputDevice *pOut = Application::GetDefaultDevice();
346 : 144 : Color aHighlight(pOut->GetSettings().GetStyleSettings().GetHighlightColor());
347 [ + - ]: 144 : const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
348 : 144 : const basegfx::BColor aSelection(aHighlight.getBColor());
349 : 144 : const double fLuminance(aSelection.luminance());
350 [ + - ]: 144 : const double fMaxLum(aSvtOptionsDrawinglayer.GetSelectionMaximumLuminancePercent() / 100.0);
351 : :
352 [ - + ]: 144 : if(fLuminance > fMaxLum)
353 : : {
354 : 0 : const double fFactor(fMaxLum / fLuminance);
355 : : const basegfx::BColor aNewSelection(
356 : 0 : aSelection.getRed() * fFactor,
357 : 0 : aSelection.getGreen() * fFactor,
358 : 0 : aSelection.getBlue() * fFactor);
359 : :
360 : 0 : aHighlight = Color(aNewSelection);
361 : : }
362 : :
363 : : // create correct selection
364 : : mpCursorOverlay = new sdr::overlay::OverlaySelection(
365 : : sdr::overlay::OVERLAY_TRANSPARENT,
366 : : aHighlight,
367 : : aNewRanges,
368 [ + - ][ + - ]: 144 : true);
369 : :
370 [ + - ][ + - ]: 144 : xTargetOverlay->add(*mpCursorOverlay);
371 [ + - ]: 144 : }
372 : 80928 : }
373 : : }
374 : 80928 : }
375 : :
376 : 6591 : void SwSelPaintRects::Invalidate( const SwRect& rRect )
377 : : {
378 : 6591 : sal_uInt16 nSz = size();
379 [ + + ]: 6591 : if( !nSz )
380 : 6591 : return;
381 : :
382 [ + - ]: 23 : SwRegionRects aReg( GetShell()->VisArea() );
383 [ + - ]: 23 : aReg.assign( begin(), end() );
384 [ + - ]: 23 : aReg -= rRect;
385 [ + - ][ + - ]: 23 : SwRects::erase( begin(), begin() + nSz );
386 [ + - ]: 23 : SwRects::insert( begin(), aReg.begin(), aReg.end() );
387 : :
388 : : // If the selection is to the right or at the bottom, outside the
389 : : // visible area, it is never aligned on one pixel at the right/bottom.
390 : : // This has to be determined here and if that is the case the
391 : : // rectangle has to be expanded.
392 [ - + ][ # # ]: 23 : if( GetShell()->bVisPortChgd && 0 != ( nSz = size()) )
[ - + ]
393 : : {
394 [ # # ]: 0 : SwSelPaintRects::Get1PixelInLogic( *GetShell() );
395 : 0 : iterator it = begin();
396 [ # # ]: 0 : for( ; nSz--; ++it )
397 : : {
398 : 0 : SwRect& rRectIt = *it;
399 [ # # ]: 0 : if( rRectIt.Right() == GetShell()->aOldRBPos.X() )
400 : 0 : rRectIt.Right( rRectIt.Right() + nPixPtX );
401 [ # # ]: 0 : if( rRectIt.Bottom() == GetShell()->aOldRBPos.Y() )
402 : 0 : rRectIt.Bottom( rRectIt.Bottom() + nPixPtY );
403 : : }
404 : 6591 : }
405 : : }
406 : :
407 : 0 : void SwSelPaintRects::Paint( const Rectangle& /*rRect*/ )
408 : : {
409 : : // nothing to do with overlays
410 : 0 : }
411 : :
412 : :
413 : : // check current MapMode of the shell and set possibly the static members.
414 : : // Optional set the parameters pX, pY
415 : 2 : void SwSelPaintRects::Get1PixelInLogic( const ViewShell& rSh,
416 : : long* pX, long* pY )
417 : : {
418 : 2 : const OutputDevice* pOut = rSh.GetWin();
419 [ - + ]: 2 : if ( ! pOut )
420 : 0 : pOut = rSh.GetOut();
421 : :
422 : 2 : const MapMode& rMM = pOut->GetMapMode();
423 [ + - ][ - + : 2 : if( pMapMode->GetMapUnit() != rMM.GetMapUnit() ||
# # # # ]
424 : 0 : pMapMode->GetScaleX() != rMM.GetScaleX() ||
425 : 0 : pMapMode->GetScaleY() != rMM.GetScaleY() )
426 : : {
427 [ + - ]: 2 : *pMapMode = rMM;
428 : 2 : Size aTmp( 1, 1 );
429 [ + - ]: 2 : aTmp = pOut->PixelToLogic( aTmp );
430 : 2 : nPixPtX = aTmp.Width();
431 : 2 : nPixPtY = aTmp.Height();
432 : : }
433 [ + - ]: 2 : if( pX )
434 : 2 : *pX = nPixPtX;
435 [ + - ]: 2 : if( pY )
436 : 2 : *pY = nPixPtY;
437 : 2 : }
438 : :
439 : :
440 : :
441 : 1326 : SwShellCrsr::SwShellCrsr( const SwCrsrShell& rCShell, const SwPosition &rPos )
442 [ + - ][ + - ]: 1326 : : SwCursor(rPos,0,false), SwSelPaintRects(rCShell), pPt(SwPaM::GetPoint())
443 : 1326 : {}
444 : :
445 : :
446 : 41 : SwShellCrsr::SwShellCrsr( const SwCrsrShell& rCShell, const SwPosition &rPos,
447 : : const Point& rPtPos, SwPaM* pRing )
448 : : : SwCursor(rPos, pRing, false), SwSelPaintRects(rCShell), aMkPt(rPtPos),
449 [ + - ][ # # ]: 41 : aPtPt(rPtPos), pPt(SwPaM::GetPoint())
450 : 41 : {}
451 : :
452 : :
453 : 0 : SwShellCrsr::SwShellCrsr( SwShellCrsr& rICrsr )
454 : 0 : : SwCursor(rICrsr), SwSelPaintRects(*rICrsr.GetShell()),
455 [ # # ][ # # ]: 0 : aMkPt(rICrsr.GetMkPos()), aPtPt(rICrsr.GetPtPos()), pPt(SwPaM::GetPoint())
456 : 0 : {}
457 : :
458 [ + - ][ + - ]: 2552 : SwShellCrsr::~SwShellCrsr() {}
[ - + ][ # # ]
[ + - ][ - + ]
[ - + ][ # # ]
459 : :
460 : :
461 : 171 : bool SwShellCrsr::IsReadOnlyAvailable() const
462 : : {
463 : 171 : return GetShell()->IsReadOnlyAvailable();
464 : : }
465 : :
466 : 134 : void SwShellCrsr::SetMark()
467 : : {
468 [ + + ]: 134 : if( SwPaM::GetPoint() == pPt )
469 : 62 : aMkPt = aPtPt;
470 : : else
471 : 72 : aPtPt = aMkPt;
472 : 134 : SwPaM::SetMark();
473 : 134 : }
474 : :
475 : 80892 : void SwShellCrsr::FillRects()
476 : : {
477 : : // calculate the new rectangles
478 [ + + + - : 82317 : if( HasMark() &&
+ - + + +
- + - ]
[ + + ]
479 : 467 : GetPoint()->nNode.GetNode().IsCntntNode() &&
480 : 467 : GetPoint()->nNode.GetNode().GetCntntNode()->getLayoutFrm( GetShell()->GetLayout() ) &&
481 : 467 : (GetMark()->nNode == GetPoint()->nNode ||
482 : 12 : (GetMark()->nNode.GetNode().IsCntntNode() &&
483 : 12 : GetMark()->nNode.GetNode().GetCntntNode()->getLayoutFrm( GetShell()->GetLayout() ) ) ))
484 : 467 : GetShell()->GetLayout()->CalcFrmRects( *this, GetShell()->IsTableMode() ); //swmod 071107//swmod 071225
485 : 80892 : }
486 : :
487 : :
488 : 46769 : void SwShellCrsr::Show()
489 : : {
490 : 46769 : SwShellCrsr * pTmp = this;
491 [ - + ][ - + ]: 46769 : do {
492 : 46769 : pTmp->SwSelPaintRects::Show();
493 : 46769 : } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) );
494 : 46769 : }
495 : :
496 : : // This rectangle gets painted anew, therefore the SSelection in this
497 : : // area is invalid.
498 : 6591 : void SwShellCrsr::Invalidate( const SwRect& rRect )
499 : : {
500 : 6591 : SwShellCrsr * pTmp = this;
501 : :
502 [ - + ]: 6591 : do
503 : : {
504 : 6591 : pTmp->SwSelPaintRects::Invalidate( rRect );
505 : :
506 : : // skip any non SwShellCrsr objects in the ring
507 : : // see also: SwAutoFormat::DeleteSel()
508 [ + - ]: 6591 : Ring* pTmpRing = pTmp;
509 : 6591 : pTmp = 0;
510 [ - + ]: 6591 : do
511 : : {
512 : 6591 : pTmpRing = pTmpRing->GetNext();
513 [ - + ]: 6591 : pTmp = dynamic_cast<SwShellCrsr*>(pTmpRing);
514 : : }
515 : 6591 : while ( !pTmp );
516 : : }
517 : : while( this != pTmp );
518 : 6591 : }
519 : :
520 : :
521 : 8165 : void SwShellCrsr::Hide()
522 : : {
523 : 8165 : SwShellCrsr * pTmp = this;
524 [ - + ][ - + ]: 8165 : do {
525 : 8165 : pTmp->SwSelPaintRects::Hide();
526 : 8165 : } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) );
527 : 8165 : }
528 : :
529 : 24 : SwCursor* SwShellCrsr::Create( SwPaM* pRing ) const
530 : : {
531 [ + - ][ + - ]: 24 : return new SwShellCrsr( *GetShell(), *GetPoint(), GetPtPos(), pRing );
532 : : }
533 : :
534 : :
535 : 0 : short SwShellCrsr::MaxReplaceArived()
536 : : {
537 : 0 : short nRet = RET_YES;
538 : 0 : Window* pDlg = ::GetSearchDialog();
539 [ # # ]: 0 : if( pDlg )
540 : : {
541 : : // Terminate old actions. The table-frames get constructed and
542 : : // a SSelection can be created.
543 [ # # ]: 0 : std::vector<sal_uInt16> aArr;
544 : : sal_uInt16 nActCnt;
545 : 0 : ViewShell *pShell = const_cast< SwCrsrShell* >( GetShell() ),
546 : 0 : *pSh = pShell;
547 [ # # ]: 0 : do {
548 [ # # ]: 0 : for( nActCnt = 0; pSh->ActionPend(); ++nActCnt )
549 [ # # ]: 0 : pSh->EndAction();
550 [ # # ]: 0 : aArr.push_back( nActCnt );
551 : 0 : } while( pShell != ( pSh = (ViewShell*)pSh->GetNext() ) );
552 : :
553 : : {
554 [ # # ][ # # ]: 0 : nRet = QueryBox( pDlg, SW_RES( MSG_COMCORE_ASKSEARCH )).Execute();
[ # # ]
555 : : }
556 : :
557 [ # # ]: 0 : for( sal_uInt16 n = 0; n < aArr.size(); ++n )
558 : : {
559 [ # # ][ # # ]: 0 : for( nActCnt = aArr[n]; nActCnt--; )
560 [ # # ]: 0 : pSh->StartAction();
561 : 0 : pSh = (ViewShell*)pSh->GetNext();
562 : 0 : } //swmod 071107 //swmod 071225
563 : : }
564 : : else
565 : : // otherwise from the Basic, and than switch to RET_YES
566 : 0 : nRet = RET_YES;
567 : :
568 : 0 : return nRet;
569 : : }
570 : :
571 : 0 : void SwShellCrsr::SaveTblBoxCntnt( const SwPosition* pPos )
572 : : {
573 : 0 : ((SwCrsrShell*)GetShell())->SaveTblBoxCntnt( pPos );
574 : 0 : }
575 : :
576 : 0 : sal_Bool SwShellCrsr::UpDown( sal_Bool bUp, sal_uInt16 nCnt )
577 : : {
578 : : return SwCursor::UpDown( bUp, nCnt,
579 : 0 : &GetPtPos(), GetShell()->GetUpDownX() );
580 : : }
581 : :
582 : : // if <true> than the cursor can be set to the position.
583 : 4 : sal_Bool SwShellCrsr::IsAtValidPos( sal_Bool bPoint ) const
584 : : {
585 [ + - ][ + - : 16 : if( GetShell() && ( GetShell()->IsAllProtect() ||
+ - + - -
+ ][ - + ]
586 : 4 : GetShell()->GetViewOptions()->IsReadonly() ||
587 : 4 : ( GetShell()->Imp()->GetDrawView() &&
588 : 4 : GetShell()->Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() )))
589 : 0 : return sal_True;
590 : :
591 : 4 : return SwCursor::IsAtValidPos( bPoint );
592 : : }
593 : :
594 : :
595 : 4 : SwShellTableCrsr::SwShellTableCrsr( const SwCrsrShell& rCrsrSh,
596 : : const SwPosition& rPos )
597 [ + - ][ + - ]: 4 : : SwCursor(rPos,0,false), SwShellCrsr(rCrsrSh, rPos), SwTableCursor(rPos)
598 : : {
599 : 4 : }
600 : :
601 : 4 : SwShellTableCrsr::SwShellTableCrsr( const SwCrsrShell& rCrsrSh,
602 : : const SwPosition& rMkPos, const Point& rMkPt,
603 : : const SwPosition& rPtPos, const Point& rPtPt )
604 [ + - ][ + - ]: 4 : : SwCursor(rPtPos,0,false), SwShellCrsr(rCrsrSh, rPtPos), SwTableCursor(rPtPos)
605 : : {
606 [ + - ][ # # ]: 4 : SetMark();
607 [ + - ][ # # ]: 4 : *GetMark() = rMkPos;
608 : 4 : GetMkPos() = rMkPt;
609 : 4 : GetPtPos() = rPtPt;
610 : 4 : }
611 : :
612 [ + - ][ + - ]: 16 : SwShellTableCrsr::~SwShellTableCrsr() {}
[ + - ][ + - ]
[ + - ][ - + ]
[ # # # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
613 : :
614 : 8 : void SwShellTableCrsr::SetMark() { SwShellCrsr::SetMark(); }
615 : :
616 : 0 : SwCursor* SwShellTableCrsr::Create( SwPaM* pRing ) const
617 : : {
618 : 0 : return SwShellCrsr::Create( pRing );
619 : : }
620 : 0 : short SwShellTableCrsr::MaxReplaceArived()
621 : : {
622 : 0 : return SwShellCrsr::MaxReplaceArived();
623 : : }
624 : 0 : void SwShellTableCrsr::SaveTblBoxCntnt( const SwPosition* pPos )
625 : : {
626 : 0 : SwShellCrsr::SaveTblBoxCntnt( pPos );
627 : 0 : }
628 : :
629 : :
630 : 36 : void SwShellTableCrsr::FillRects()
631 : : {
632 : : // Calculate the new rectangles. If the cursor is still "parked" do nothing
633 [ + - ]: 72 : if( aSelBoxes.empty() || bParked ||
[ + - - + ]
[ + - ]
634 : 36 : !GetPoint()->nNode.GetIndex() )
635 : 36 : return;
636 : :
637 [ + - ]: 36 : SwRegionRects aReg( GetShell()->VisArea() );
638 [ + - ]: 36 : SwNodes& rNds = GetDoc()->GetNodes();
639 [ + + ]: 144 : for( sal_uInt16 n = 0; n < aSelBoxes.size(); ++n )
640 : : {
641 [ + - ]: 108 : const SwStartNode* pSttNd = aSelBoxes[n]->GetSttNd();
642 [ + - ]: 108 : const SwTableNode* pSelTblNd = pSttNd->FindTableNode();
643 : :
644 [ + - ]: 108 : SwNodeIndex aIdx( *pSttNd );
645 [ + - ]: 108 : SwCntntNode* pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False );
646 : :
647 : : // table in table
648 : : // (see also lcl_FindTopLevelTable in unoobj2.cxx for a different
649 : : // version to do this)
650 [ + - ]: 108 : const SwTableNode* pCurTblNd = pCNd->FindTableNode();
651 [ - + ][ # # ]: 108 : while ( pSelTblNd != pCurTblNd && pCurTblNd )
[ - + ]
652 : : {
653 [ # # ]: 0 : aIdx = pCurTblNd->EndOfSectionIndex();
654 [ # # ]: 0 : pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False );
655 [ # # ]: 0 : pCurTblNd = pCNd->FindTableNode();
656 : : }
657 : :
658 [ - + ]: 108 : if( !pCNd )
659 : 0 : continue;
660 : :
661 [ + - ][ + - ]: 108 : SwFrm* pFrm = pCNd->getLayoutFrm( GetShell()->GetLayout(), &GetSttPos() );
[ + - ]
662 [ + - ][ + + ]: 216 : while( pFrm && !pFrm->IsCellFrm() )
[ + + ]
663 : 108 : pFrm = pFrm->GetUpper();
664 : :
665 : : OSL_ENSURE( pFrm, "Node not in a table" );
666 : :
667 [ + + ]: 216 : while ( pFrm )
668 : : {
669 [ + - ][ + - ]: 108 : if( aReg.GetOrigin().IsOver( pFrm->Frm() ) )
670 [ + - ]: 108 : aReg -= pFrm->Frm();
671 : :
672 [ + - ]: 108 : pFrm = pFrm->GetNextCellLeaf( MAKEPAGE_NONE );
673 : : }
674 [ + - ][ + - ]: 108 : }
675 [ + - ]: 36 : aReg.Invert();
676 [ + - ]: 36 : insert( begin(), aReg.begin(), aReg.end() );
677 : : }
678 : :
679 : :
680 : : // Check if the SPoint is within the Table-SSelection.
681 : 0 : sal_Bool SwShellTableCrsr::IsInside( const Point& rPt ) const
682 : : {
683 : : // Calculate the new rectangles. If the cursor is still "parked" do nothing
684 [ # # ]: 0 : if( aSelBoxes.empty() || bParked ||
[ # # # # ]
[ # # ]
685 : 0 : !GetPoint()->nNode.GetIndex() )
686 : 0 : return sal_False;
687 : :
688 : 0 : SwNodes& rNds = GetDoc()->GetNodes();
689 [ # # ]: 0 : for( sal_uInt16 n = 0; n < aSelBoxes.size(); ++n )
690 : : {
691 [ # # ][ # # ]: 0 : SwNodeIndex aIdx( *aSelBoxes[ n ]->GetSttNd() );
692 [ # # ]: 0 : SwCntntNode* pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False );
693 [ # # ]: 0 : if( !pCNd )
694 : 0 : continue;
695 : :
696 [ # # ][ # # ]: 0 : SwFrm* pFrm = pCNd->getLayoutFrm( GetShell()->GetLayout(), &GetPtPos() );
697 [ # # ][ # # ]: 0 : while( pFrm && !pFrm->IsCellFrm() )
[ # # ]
698 : 0 : pFrm = pFrm->GetUpper();
699 : : OSL_ENSURE( pFrm, "Node not in a table" );
700 [ # # ][ # # ]: 0 : if( pFrm && pFrm->Frm().IsInside( rPt ) )
[ # # ][ # # ]
701 : 0 : return sal_True;
702 [ # # ]: 0 : }
[ # # # ]
703 : 0 : return sal_False;
704 : : }
705 : :
706 : 4 : sal_Bool SwShellTableCrsr::IsAtValidPos( sal_Bool bPoint ) const
707 : : {
708 : 4 : return SwShellCrsr::IsAtValidPos( bPoint );
709 : : }
710 : :
711 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|