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 <config_features.h>
21 :
22 : #include <com/sun/star/accessibility/XAccessible.hpp>
23 : #include <sfx2/viewfrm.hxx>
24 : #include <sfx2/progress.hxx>
25 : #include <svx/srchdlg.hxx>
26 : #include <svx/svdobj.hxx>
27 : #include <sfx2/viewsh.hxx>
28 : #include <drawdoc.hxx>
29 : #include <swwait.hxx>
30 : #include <swmodule.hxx>
31 : #include <fesh.hxx>
32 : #include <doc.hxx>
33 : #include <IDocumentDeviceAccess.hxx>
34 : #include <IDocumentDrawModelAccess.hxx>
35 : #include <IDocumentOutlineNodes.hxx>
36 : #include <IDocumentFieldsAccess.hxx>
37 : #include <IDocumentLayoutAccess.hxx>
38 : #include <IDocumentState.hxx>
39 : #include <rootfrm.hxx>
40 : #include <pagefrm.hxx>
41 : #include <cntfrm.hxx>
42 : #include <viewimp.hxx>
43 : #include <frmtool.hxx>
44 : #include <viewopt.hxx>
45 : #include <dview.hxx>
46 : #include <swregion.hxx>
47 : #include <hints.hxx>
48 : #include <fmtfsize.hxx>
49 : #include <docufld.hxx>
50 : #include <txtfrm.hxx>
51 : #include <layact.hxx>
52 : #include <mdiexp.hxx>
53 : #include <fntcache.hxx>
54 : #include <ptqueue.hxx>
55 : #include <tabfrm.hxx>
56 : #include <docsh.hxx>
57 : #include <pagedesc.hxx>
58 : #include <ndole.hxx>
59 : #include <ndindex.hxx>
60 : #include <accmap.hxx>
61 : #include <vcl/bitmapex.hxx>
62 : #include <svtools/colorcfg.hxx>
63 : #include <vcl/bmpacc.hxx>
64 : #include <vcl/alpha.hxx>
65 : #include <svtools/accessibilityoptions.hxx>
66 : #include <accessibilityoptions.hxx>
67 : #include <statstr.hrc>
68 : #include <comcore.hrc>
69 : #include <pagepreviewlayout.hxx>
70 : #include <sortedobjs.hxx>
71 : #include <anchoredobject.hxx>
72 : #include <wrtsh.hxx>
73 : #include <DocumentSettingManager.hxx>
74 :
75 : #include "../../uibase/inc/view.hxx"
76 : #include <PostItMgr.hxx>
77 : #include <vcl/dibtools.hxx>
78 : #include <vcl/virdev.hxx>
79 : #include <vcl/svapp.hxx>
80 : #include <svx/sdrpaintwindow.hxx>
81 : #include <LibreOfficeKit/LibreOfficeKitEnums.h>
82 :
83 : #if !HAVE_FEATURE_DESKTOP
84 : #include <vcl/sysdata.hxx>
85 : #endif
86 :
87 : bool SwViewShell::mbLstAct = false;
88 : ShellResource *SwViewShell::mpShellRes = 0;
89 59 : VclPtr<vcl::Window> SwViewShell::mpCareWindow = nullptr;
90 : BitmapEx* SwViewShell::mpErrorBmp = NULL;
91 : BitmapEx* SwViewShell::mpReplaceBmp = NULL;
92 :
93 : bool bInSizeNotify = false;
94 :
95 124743 : TYPEINIT0(SwViewShell);
96 :
97 : using namespace ::com::sun::star;
98 :
99 0 : void SwViewShell::ToggleHeaderFooterEdit()
100 : {
101 0 : mbHeaderFooterEdit = !mbHeaderFooterEdit;
102 0 : if ( !mbHeaderFooterEdit )
103 : {
104 0 : SetShowHeaderFooterSeparator( Header, false );
105 0 : SetShowHeaderFooterSeparator( Footer, false );
106 : }
107 :
108 : // Avoid corner case
109 0 : if ( !IsShowHeaderFooterSeparator( Header ) &&
110 0 : !IsShowHeaderFooterSeparator( Footer ) )
111 : {
112 0 : mbHeaderFooterEdit = false;
113 : }
114 :
115 : // Repaint everything
116 0 : GetWin()->Invalidate();
117 0 : }
118 :
119 4 : void SwViewShell::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData)
120 : {
121 4 : getIDocumentDrawModelAccess()->GetDrawModel()->registerLibreOfficeKitCallback(pCallback, pData);
122 4 : }
123 :
124 59037 : void SwViewShell::libreOfficeKitCallback(int nType, const char* pPayload) const
125 : {
126 59037 : if (mbInLibreOfficeKitCallback)
127 59037 : return;
128 :
129 59037 : getIDocumentDrawModelAccess()->GetDrawModel()->libreOfficeKitCallback(nType, pPayload);
130 : }
131 :
132 12 : void SwViewShell::setTiledRendering(bool bTiledRendering)
133 : {
134 12 : getIDocumentDrawModelAccess()->GetDrawModel()->setTiledRendering(bTiledRendering);
135 12 : }
136 :
137 248955 : bool SwViewShell::isTiledRendering() const
138 : {
139 248955 : return getIDocumentDrawModelAccess()->GetDrawModel()->isTiledRendering();
140 : }
141 :
142 : static void
143 4457 : lcl_PaintTransparentFormControls(SwViewShell & rShell, SwRect const& rRect)
144 : {
145 : // Direct paint has been performed: the background of transparent child
146 : // windows has been painted, so need to paint the child windows now.
147 4457 : if (rShell.GetWin())
148 : {
149 4457 : vcl::Window& rWindow = *(rShell.GetWin());
150 4457 : const Rectangle aRectanglePixel(rShell.GetOut()->LogicToPixel(rRect.SVRect()));
151 4457 : PaintTransparentChildren(rWindow, aRectanglePixel);
152 : }
153 4457 : }
154 :
155 : // #i72754# 2nd set of Pre/PostPaints
156 : // This time it uses the lock counter (mPrePostPaintRegions empty/non-empty) to allow only one activation
157 : // and deactivation and mpPrePostOutDev to remember the OutDev from the BeginDrawLayers
158 : // call. That way, all places where paint take place can be handled the same way, even
159 : // when calling other paint methods. This is the case at the places where SW paints
160 : // buffered into VDevs to avoid flicker. Tis is in general problematic and should be
161 : // solved once using the BufferedOutput functionality of the DrawView.
162 :
163 27195 : void SwViewShell::PrePaint()
164 : {
165 : // forward PrePaint event from VCL Window to DrawingLayer
166 27195 : if(HasDrawView())
167 : {
168 27195 : Imp()->GetDrawView()->PrePaint();
169 : }
170 27195 : }
171 :
172 22705 : void SwViewShell::DLPrePaint2(const vcl::Region& rRegion)
173 : {
174 22705 : if(mPrePostPaintRegions.empty())
175 : {
176 9448 : mPrePostPaintRegions.push( rRegion );
177 : // #i75172# ensure DrawView to use DrawingLayer bufferings
178 9448 : if ( !HasDrawView() )
179 0 : MakeDrawView();
180 :
181 : // Prefer window; if tot available, get mpOut (e.g. printer)
182 9448 : mpPrePostOutDev = (GetWin() && !isTiledRendering())? GetWin(): GetOut();
183 :
184 : // #i74769# use SdrPaintWindow now direct
185 9448 : mpTargetPaintWindow = Imp()->GetDrawView()->BeginDrawLayers(mpPrePostOutDev, rRegion);
186 : OSL_ENSURE(mpTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
187 :
188 : // #i74769# if prerender, save OutDev and redirect to PreRenderDevice
189 9448 : if(mpTargetPaintWindow->GetPreRenderDevice())
190 : {
191 9100 : mpBufferedOut = mpOut;
192 9100 : mpOut = &(mpTargetPaintWindow->GetTargetOutputDevice());
193 : }
194 :
195 : // remember original paint MapMode for wrapped FlyFrame paints
196 9448 : maPrePostMapMode = mpOut->GetMapMode();
197 : }
198 : else
199 : {
200 : // region needs to be updated to the given one
201 13257 : if( mPrePostPaintRegions.top() != rRegion )
202 12845 : Imp()->GetDrawView()->UpdateDrawLayersRegion(mpPrePostOutDev, rRegion);
203 13257 : mPrePostPaintRegions.push( rRegion );
204 : }
205 22705 : }
206 :
207 22705 : void SwViewShell::DLPostPaint2(bool bPaintFormLayer)
208 : {
209 : OSL_ENSURE(!mPrePostPaintRegions.empty(), "SwViewShell::DLPostPaint2: Pre/PostPaint encapsulation broken (!)");
210 :
211 22705 : if( mPrePostPaintRegions.size() > 1 )
212 : {
213 13257 : vcl::Region current = mPrePostPaintRegions.top();
214 13257 : mPrePostPaintRegions.pop();
215 13257 : if( current != mPrePostPaintRegions.top())
216 12845 : Imp()->GetDrawView()->UpdateDrawLayersRegion(mpPrePostOutDev, mPrePostPaintRegions.top());
217 35962 : return;
218 : }
219 9448 : mPrePostPaintRegions.pop(); // clear
220 9448 : if(0 != mpTargetPaintWindow)
221 : {
222 : // #i74769# restore buffered OutDev
223 9448 : if(mpTargetPaintWindow->GetPreRenderDevice())
224 : {
225 9100 : mpOut = mpBufferedOut;
226 : }
227 :
228 : // #i74769# use SdrPaintWindow now direct
229 9448 : Imp()->GetDrawView()->EndDrawLayers(*mpTargetPaintWindow, bPaintFormLayer);
230 9448 : mpTargetPaintWindow = 0;
231 : }
232 : }
233 : // end of Pre/PostPaints
234 :
235 41254 : void SwViewShell::ImplEndAction( const bool bIdleEnd )
236 : {
237 : // Nothing to do for the printer?
238 41254 : if ( !GetWin() || IsPreview() )
239 : {
240 0 : mbPaintWorks = true;
241 0 : UISizeNotify();
242 41254 : return;
243 : }
244 :
245 41254 : mbInEndAction = true;
246 : //will this put the EndAction of the last shell in the sequence?
247 :
248 41254 : SwViewShell::mbLstAct = true;
249 82508 : for(SwViewShell& rShell : GetRingContainer())
250 : {
251 41254 : if(&rShell != this && rShell.ActionPend())
252 : {
253 0 : SwViewShell::mbLstAct = false;
254 0 : break;
255 : }
256 : }
257 :
258 41254 : const bool bIsShellForCheckViewLayout = ( this == GetLayout()->GetCurrShell() );
259 :
260 41254 : SET_CURR_SHELL( this );
261 41254 : if ( Imp()->HasDrawView() && !Imp()->GetDrawView()->areMarkHandlesHidden() )
262 27314 : Imp()->StartAction();
263 :
264 41254 : if ( Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea() )
265 0 : Imp()->DelRegion();
266 :
267 41254 : const bool bExtraData = ::IsExtraData( GetDoc() );
268 :
269 41254 : if ( !bIdleEnd )
270 : {
271 38581 : SwLayAction aAction( GetLayout(), Imp() );
272 38581 : aAction.SetComplete( false );
273 38581 : if ( mnLockPaint )
274 13939 : aAction.SetPaint( false );
275 38581 : aAction.SetInputType( VclInputFlags::KEYBOARD );
276 38581 : aAction.Action();
277 : }
278 :
279 41254 : if ( bIsShellForCheckViewLayout )
280 41254 : GetLayout()->CheckViewLayout( GetViewOptions(), &maVisArea );
281 :
282 : //If we don't call Paints, we wait for the Paint of the system.
283 : //Then the clipping is set correctly; e.g. shifting of a Draw object
284 120666 : if ( Imp()->GetRegion() ||
285 78919 : maInvalidRect.HasArea() ||
286 : bExtraData )
287 : {
288 4283 : if ( !mnLockPaint )
289 : {
290 3891 : SolarMutexGuard aGuard;
291 :
292 3891 : bool bPaintsFromSystem = maInvalidRect.HasArea();
293 3891 : GetWin()->Update();
294 3891 : if ( maInvalidRect.HasArea() )
295 : {
296 1200 : if ( bPaintsFromSystem )
297 524 : Imp()->AddPaintRect( maInvalidRect );
298 :
299 1200 : ResetInvalidRect();
300 1200 : bPaintsFromSystem = true;
301 : }
302 3891 : mbPaintWorks = true;
303 :
304 3891 : SwRegionRects *pRegion = Imp()->GetRegion();
305 :
306 : //JP 27.11.97: what hid the selection, must also Show it,
307 : // else we get Paint errors!
308 : // e.g. additional mode, page half visible vertically, in the
309 : // middle a selection and with an other cursor jump to left
310 : // right border. Without ShowCrsr the selection disappears.
311 3891 : bool bShowCrsr = pRegion && IsA( TYPE(SwCrsrShell) );
312 3891 : if( bShowCrsr )
313 3816 : static_cast<SwCrsrShell*>(this)->HideCrsrs();
314 :
315 3891 : if ( pRegion )
316 : {
317 3816 : SwRootFrm* pCurrentLayout = GetLayout();
318 :
319 3816 : Imp()->pRegion = NULL;
320 :
321 : //First Invert then Compress, never the other way round!
322 3816 : pRegion->Invert();
323 :
324 3816 : pRegion->Compress();
325 :
326 3816 : VclPtr<VirtualDevice> pVout;
327 11861 : while ( !pRegion->empty() )
328 : {
329 4229 : SwRect aRect( pRegion->back() );
330 4229 : pRegion->pop_back();
331 :
332 4229 : bool bPaint = true;
333 4229 : if ( IsEndActionByVirDev() )
334 : {
335 : //create virtual device and set.
336 1 : if ( !pVout )
337 1 : pVout = VclPtr<VirtualDevice>::Create( *GetOut() );
338 1 : MapMode aMapMode( GetOut()->GetMapMode() );
339 1 : pVout->SetMapMode( aMapMode );
340 :
341 1 : bool bSizeOK = true;
342 :
343 1 : Rectangle aTmp1( aRect.SVRect() );
344 1 : aTmp1 = GetOut()->LogicToPixel( aTmp1 );
345 1 : Rectangle aTmp2( GetOut()->PixelToLogic( aTmp1 ) );
346 1 : if ( aTmp2.Left() > aRect.Left() )
347 0 : aTmp1.Left() = std::max( 0L, aTmp1.Left() - 1L );
348 1 : if ( aTmp2.Top() > aRect.Top() )
349 0 : aTmp1.Top() = std::max( 0L, aTmp1.Top() - 1L );
350 1 : aTmp1.Right() += 1;
351 1 : aTmp1.Bottom() += 1;
352 1 : aTmp1 = GetOut()->PixelToLogic( aTmp1 );
353 1 : aRect = SwRect( aTmp1 );
354 :
355 1 : const Size aTmp( pVout->GetOutputSize() );
356 1 : if ( aTmp.Height() < aRect.Height() ||
357 0 : aTmp.Width() < aRect.Width() )
358 : {
359 1 : bSizeOK = pVout->SetOutputSize( aRect.SSize() );
360 : }
361 1 : if ( bSizeOK )
362 : {
363 1 : bPaint = false;
364 :
365 : // --> OD 2007-07-26 #i79947#
366 : // #i72754# start Pre/PostPaint encapsulation before mpOut is changed to the buffering VDev
367 1 : const vcl::Region aRepaintRegion(aRect.SVRect());
368 1 : DLPrePaint2(aRepaintRegion);
369 : // <--
370 :
371 1 : OutputDevice *pOld = GetOut();
372 1 : pVout->SetLineColor( pOld->GetLineColor() );
373 1 : pVout->SetFillColor( pOld->GetFillColor() );
374 1 : Point aOrigin( aRect.Pos() );
375 1 : aOrigin.X() = -aOrigin.X(); aOrigin.Y() = -aOrigin.Y();
376 1 : aMapMode.SetOrigin( aOrigin );
377 1 : pVout->SetMapMode( aMapMode );
378 :
379 1 : mpOut = pVout.get();
380 1 : if ( bPaintsFromSystem )
381 0 : PaintDesktop(*mpOut, aRect);
382 1 : pCurrentLayout->Paint( aRect );
383 1 : pOld->DrawOutDev( aRect.Pos(), aRect.SSize(),
384 2 : aRect.Pos(), aRect.SSize(), *pVout );
385 1 : mpOut = pOld;
386 :
387 : // #i72754# end Pre/PostPaint encapsulation when mpOut is back and content is painted
388 1 : DLPostPaint2(true);
389 1 : }
390 : }
391 4229 : if ( bPaint )
392 : {
393 : // #i75172# begin DrawingLayer paint
394 : // need to do begin/end DrawingLayer preparation for each single rectangle of the
395 : // repaint region. I already tried to prepare only once for the whole Region. This
396 : // seems to work (and does technically) but fails with transparent objects. Since the
397 : // region given to BeginDarwLayers() defines the clip region for DrawingLayer paint,
398 : // transparent objects in the single rectangles will indeed be painted multiple times.
399 4228 : DLPrePaint2(vcl::Region(aRect.SVRect()));
400 :
401 4228 : if ( bPaintsFromSystem )
402 1381 : PaintDesktop(*GetOut(), aRect);
403 4228 : if (!isTiledRendering())
404 4213 : pCurrentLayout->Paint( aRect );
405 : else
406 15 : pCurrentLayout->GetCurrShell()->InvalidateWindows(aRect.SVRect());
407 :
408 : // #i75172# end DrawingLayer paint
409 4228 : DLPostPaint2(true);
410 : }
411 :
412 4229 : lcl_PaintTransparentFormControls(*this, aRect); // i#107365
413 : }
414 :
415 3816 : pVout.disposeAndClear();
416 3816 : delete pRegion;
417 3816 : Imp()->DelRegion();
418 : }
419 3891 : if( bShowCrsr )
420 3816 : static_cast<SwCrsrShell*>(this)->ShowCrsrs( true );
421 : }
422 : else
423 : {
424 392 : Imp()->DelRegion();
425 392 : mbPaintWorks = true;
426 : }
427 : }
428 : else
429 36971 : mbPaintWorks = true;
430 :
431 41254 : mbInEndAction = false;
432 41254 : SwViewShell::mbLstAct = false;
433 41254 : Imp()->EndAction();
434 :
435 : //We artificially end the action here to enable the automatic scrollbars
436 : //to adjust themselves correctly
437 : //EndAction sends a Notify, and that must call Start-/EndAction to
438 : //adjust the scrollbars correctly
439 41254 : --mnStartAction;
440 41254 : UISizeNotify();
441 41254 : ++mnStartAction;
442 :
443 41254 : if( Imp()->IsAccessible() )
444 80 : Imp()->FireAccessibleEvents();
445 : }
446 :
447 41254 : void SwViewShell::ImplStartAction()
448 : {
449 41254 : mbPaintWorks = false;
450 41254 : Imp()->StartAction();
451 41254 : }
452 :
453 14996 : void SwViewShell::ImplLockPaint()
454 : {
455 14996 : if ( GetWin() && GetWin()->IsVisible() )
456 14968 : GetWin()->EnablePaint( false ); //Also cut off the controls.
457 14996 : Imp()->LockPaint();
458 14996 : }
459 :
460 14996 : void SwViewShell::ImplUnlockPaint( bool bVirDev )
461 : {
462 14996 : SET_CURR_SHELL( this );
463 14996 : if ( GetWin() && GetWin()->IsVisible() )
464 : {
465 14968 : if ( (bInSizeNotify || bVirDev ) && VisArea().HasArea() )
466 : {
467 : //Refresh with virtual device to avoid flickering.
468 228 : VclPtrInstance<VirtualDevice> pVout( *mpOut );
469 228 : pVout->SetMapMode( mpOut->GetMapMode() );
470 228 : Size aSize( VisArea().SSize() );
471 228 : aSize.Width() += 20;
472 228 : aSize.Height()+= 20;
473 228 : if( pVout->SetOutputSize( aSize ) )
474 : {
475 228 : GetWin()->EnablePaint( true );
476 228 : GetWin()->Validate();
477 :
478 228 : Imp()->UnlockPaint();
479 228 : pVout->SetLineColor( mpOut->GetLineColor() );
480 228 : pVout->SetFillColor( mpOut->GetFillColor() );
481 :
482 : // #i72754# start Pre/PostPaint encapsulation before mpOut is changed to the buffering VDev
483 228 : const vcl::Region aRepaintRegion(VisArea().SVRect());
484 228 : DLPrePaint2(aRepaintRegion);
485 :
486 228 : OutputDevice *pOld = mpOut;
487 228 : mpOut = pVout.get();
488 228 : Paint(*mpOut, VisArea().SVRect());
489 228 : mpOut = pOld;
490 456 : mpOut->DrawOutDev( VisArea().Pos(), aSize,
491 456 : VisArea().Pos(), aSize, *pVout );
492 :
493 : // #i72754# end Pre/PostPaint encapsulation when mpOut is back and content is painted
494 228 : DLPostPaint2(true);
495 :
496 228 : lcl_PaintTransparentFormControls(*this, VisArea()); // fdo#63949
497 : }
498 : else
499 : {
500 0 : Imp()->UnlockPaint();
501 0 : GetWin()->EnablePaint( true );
502 0 : GetWin()->Invalidate( InvalidateFlags::Children );
503 : }
504 228 : pVout.disposeAndClear();
505 : }
506 : else
507 : {
508 14740 : Imp()->UnlockPaint();
509 14740 : GetWin()->EnablePaint( true );
510 14740 : GetWin()->Invalidate( InvalidateFlags::Children );
511 : }
512 : }
513 : else
514 28 : Imp()->UnlockPaint();
515 14996 : }
516 :
517 25657 : bool SwViewShell::AddPaintRect( const SwRect & rRect )
518 : {
519 25657 : bool bRet = false;
520 51314 : for(SwViewShell& rSh : GetRingContainer())
521 : {
522 25657 : if( rSh.Imp() )
523 : {
524 25657 : if ( rSh.IsPreview() && rSh.GetWin() )
525 0 : ::RepaintPagePreview( &rSh, rRect );
526 : else
527 25657 : bRet |= rSh.Imp()->AddPaintRect( rRect );
528 : }
529 : }
530 25657 : return bRet;
531 : }
532 :
533 14513 : void SwViewShell::InvalidateWindows( const SwRect &rRect )
534 : {
535 14513 : if ( !Imp()->IsCalcLayoutProgress() )
536 : {
537 19788 : for(SwViewShell& rSh : GetRingContainer())
538 : {
539 9894 : if ( rSh.GetWin() )
540 : {
541 9894 : if ( rSh.IsPreview() )
542 0 : ::RepaintPagePreview( &rSh, rRect );
543 : // In case of tiled rendering, invalidation is wanted even if
544 : // the rectangle is outside the visual area.
545 9894 : else if ( rSh.VisArea().IsOver( rRect ) || rSh.isTiledRendering() )
546 6755 : rSh.GetWin()->Invalidate( rRect.SVRect() );
547 : }
548 : }
549 : }
550 14513 : }
551 :
552 38417 : void SwViewShell::MakeVisible( const SwRect &rRect )
553 : {
554 38417 : if ( !VisArea().IsInside( rRect ) || IsScrollMDI( this, rRect ) || GetCareWin(*this) )
555 : {
556 3493 : if ( !IsViewLocked() )
557 : {
558 932 : if( mpWin )
559 : {
560 932 : const SwFrm* pRoot = GetLayout();
561 932 : int nLoopCnt = 3;
562 : long nOldH;
563 932 : do{
564 932 : nOldH = pRoot->Frm().Height();
565 932 : StartAction();
566 932 : ScrollMDI( this, rRect, USHRT_MAX, USHRT_MAX );
567 932 : EndAction();
568 932 : } while( nOldH != pRoot->Frm().Height() && nLoopCnt-- );
569 : }
570 : #if OSL_DEBUG_LEVEL > 0
571 : else
572 : {
573 : //MA: 04. Nov. 94, no one needs this, does one?
574 : OSL_ENSURE( false, "Is MakeVisible still needed for printers?" );
575 : }
576 :
577 : #endif
578 : }
579 : }
580 38417 : }
581 :
582 35353 : vcl::Window* SwViewShell::CareChildWin(SwViewShell& rVSh)
583 : {
584 35353 : if(rVSh.mpSfxViewShell)
585 : {
586 : #if HAVE_FEATURE_DESKTOP
587 35353 : const sal_uInt16 nId = SvxSearchDialogWrapper::GetChildWindowId();
588 35353 : SfxViewFrame* pVFrame = rVSh.mpSfxViewShell->GetViewFrame();
589 35353 : const SfxChildWindow* pChWin = pVFrame->GetChildWindow( nId );
590 35353 : vcl::Window *pWin = pChWin ? pChWin->GetWindow() : NULL;
591 35353 : if ( pWin && pWin->IsVisible() )
592 0 : return pWin;
593 : #endif
594 : }
595 35353 : return NULL;
596 : }
597 :
598 0 : Point SwViewShell::GetPagePos( sal_uInt16 nPageNum ) const
599 : {
600 0 : return GetLayout()->GetPagePos( nPageNum );
601 : }
602 :
603 29343 : sal_uInt16 SwViewShell::GetNumPages()
604 : {
605 : //It is possible that no layout exists when the method from
606 : //root-Ctor is called.
607 29343 : return GetLayout() ? GetLayout()->GetPageNum() : 0;
608 : }
609 :
610 0 : bool SwViewShell::IsDummyPage( sal_uInt16 nPageNum ) const
611 : {
612 0 : return GetLayout() && GetLayout()->IsDummyPage( nPageNum );
613 : }
614 :
615 : /**
616 : * Forces update of each field.
617 : * It notifies all fields with pNewHt. If that is 0 (default), the field
618 : * type is sent (???).
619 : * @param[in] bCloseDB Passed in to GetDoc()->UpdateFields. [TODO] Purpose???
620 : */
621 66 : void SwViewShell::UpdateFields(bool bCloseDB)
622 : {
623 66 : SET_CURR_SHELL( this );
624 :
625 66 : bool bCrsr = ISA(SwCrsrShell);
626 66 : if ( bCrsr )
627 66 : static_cast<SwCrsrShell*>(this)->StartAction();
628 : else
629 0 : StartAction();
630 :
631 66 : GetDoc()->getIDocumentFieldsAccess().UpdateFields(0, bCloseDB);
632 :
633 66 : if ( bCrsr )
634 66 : static_cast<SwCrsrShell*>(this)->EndAction();
635 : else
636 0 : EndAction();
637 66 : }
638 :
639 : /** update all charts for which any table exists */
640 0 : void SwViewShell::UpdateAllCharts()
641 : {
642 0 : SET_CURR_SHELL( this );
643 : // Start-/EndAction handled in the SwDoc-Method!
644 0 : GetDoc()->UpdateAllCharts();
645 0 : }
646 :
647 0 : bool SwViewShell::HasCharts() const
648 : {
649 0 : bool bRet = false;
650 0 : SwNodeIndex aIdx( *GetDoc()->GetNodes().GetEndOfAutotext().
651 0 : StartOfSectionNode(), 1 );
652 0 : while (aIdx.GetNode().GetStartNode())
653 : {
654 0 : ++aIdx;
655 0 : const SwOLENode *pNd = aIdx.GetNode().GetOLENode();
656 0 : if( pNd && !pNd->GetChartTableName().isEmpty() )
657 : {
658 0 : bRet = true;
659 0 : break;
660 : }
661 : }
662 0 : return bRet;
663 : }
664 :
665 26775077 : void SwViewShell::LayoutIdle()
666 : {
667 53550154 : if( !mpOpt->IsIdle() || !GetWin() ||
668 53550108 : ( Imp()->HasDrawView() && Imp()->GetDrawView()->IsDragObj() ) )
669 46 : return;
670 :
671 : //No idle when printing is going on.
672 53550108 : for(SwViewShell& rSh : GetRingContainer())
673 : {
674 26775054 : if ( !rSh.GetWin() )
675 0 : return;
676 : }
677 :
678 26775054 : SET_CURR_SHELL( this );
679 :
680 : #ifdef DBG_UTIL
681 : // If Test5 has been set, the IdleFormatter is disabled.
682 : if( mpOpt->IsTest5() )
683 : return;
684 : #endif
685 :
686 : {
687 : //Prepare and recover cache, so that it will not get fouled.
688 26775054 : SwSaveSetLRUOfst aSave( *SwTextFrm::GetTextCache(),
689 53550108 : SwTextFrm::GetTextCache()->GetCurMax() - 50 );
690 : // #125243# there are lots of stacktraces indicating that Imp() returns NULL
691 : // this SwViewShell seems to be invalid - but it's not clear why
692 : // this return is only a workaround!
693 : OSL_ENSURE(Imp(), "SwViewShell already deleted?");
694 26775054 : if(!Imp())
695 0 : return;
696 26775054 : SwLayIdle aIdle( GetLayout(), Imp() );
697 26775054 : }
698 : }
699 :
700 0 : static void lcl_InvalidateAllContent( SwViewShell& rSh, sal_uInt8 nInv )
701 : {
702 0 : bool bCrsr = rSh.ISA(SwCrsrShell);
703 0 : if ( bCrsr )
704 0 : static_cast<SwCrsrShell&>(rSh).StartAction();
705 : else
706 0 : rSh.StartAction();
707 0 : rSh.GetLayout()->InvalidateAllContent( nInv );
708 0 : if ( bCrsr )
709 0 : static_cast<SwCrsrShell&>(rSh).EndAction();
710 : else
711 0 : rSh.EndAction();
712 :
713 0 : rSh.GetDoc()->getIDocumentState().SetModified();
714 0 : }
715 :
716 : /** local method to invalidate/re-calculate positions of floating screen
717 : * objects (Writer fly frame and drawing objects), which are anchored
718 : * to paragraph or to character. #i11860#
719 : */
720 0 : static void lcl_InvalidateAllObjPos( SwViewShell &_rSh )
721 : {
722 0 : const bool bIsCrsrShell = _rSh.ISA(SwCrsrShell);
723 0 : if ( bIsCrsrShell )
724 0 : static_cast<SwCrsrShell&>(_rSh).StartAction();
725 : else
726 0 : _rSh.StartAction();
727 :
728 0 : _rSh.GetLayout()->InvalidateAllObjPos();
729 :
730 0 : if ( bIsCrsrShell )
731 0 : static_cast<SwCrsrShell&>(_rSh).EndAction();
732 : else
733 0 : _rSh.EndAction();
734 :
735 0 : _rSh.GetDoc()->getIDocumentState().SetModified();
736 0 : }
737 :
738 0 : void SwViewShell::SetParaSpaceMax( bool bNew )
739 : {
740 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
741 0 : if( pIDSA->get(DocumentSettingId::PARA_SPACE_MAX) != bNew )
742 : {
743 0 : SwWait aWait( *GetDoc()->GetDocShell(), true );
744 0 : pIDSA->set(DocumentSettingId::PARA_SPACE_MAX, bNew );
745 0 : const sal_uInt8 nInv = INV_PRTAREA | INV_TABLE | INV_SECTION;
746 0 : lcl_InvalidateAllContent( *this, nInv );
747 : }
748 0 : }
749 :
750 0 : void SwViewShell::SetParaSpaceMaxAtPages( bool bNew )
751 : {
752 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
753 0 : if( pIDSA->get(DocumentSettingId::PARA_SPACE_MAX_AT_PAGES) != bNew )
754 : {
755 0 : SwWait aWait( *GetDoc()->GetDocShell(), true );
756 0 : pIDSA->set(DocumentSettingId::PARA_SPACE_MAX_AT_PAGES, bNew );
757 0 : const sal_uInt8 nInv = INV_PRTAREA | INV_TABLE | INV_SECTION;
758 0 : lcl_InvalidateAllContent( *this, nInv );
759 : }
760 0 : }
761 :
762 0 : void SwViewShell::SetTabCompat( bool bNew )
763 : {
764 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
765 0 : if( pIDSA->get(DocumentSettingId::TAB_COMPAT) != bNew )
766 : {
767 0 : SwWait aWait( *GetDoc()->GetDocShell(), true );
768 0 : pIDSA->set(DocumentSettingId::TAB_COMPAT, bNew );
769 0 : const sal_uInt8 nInv = INV_PRTAREA | INV_SIZE | INV_TABLE | INV_SECTION;
770 0 : lcl_InvalidateAllContent( *this, nInv );
771 : }
772 0 : }
773 :
774 0 : void SwViewShell::SetAddExtLeading( bool bNew )
775 : {
776 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
777 0 : if ( pIDSA->get(DocumentSettingId::ADD_EXT_LEADING) != bNew )
778 : {
779 0 : SwWait aWait( *GetDoc()->GetDocShell(), true );
780 0 : pIDSA->set(DocumentSettingId::ADD_EXT_LEADING, bNew );
781 0 : SwDrawModel* pTmpDrawModel = getIDocumentDrawModelAccess()->GetDrawModel();
782 0 : if ( pTmpDrawModel )
783 0 : pTmpDrawModel->SetAddExtLeading( bNew );
784 0 : const sal_uInt8 nInv = INV_PRTAREA | INV_SIZE | INV_TABLE | INV_SECTION;
785 0 : lcl_InvalidateAllContent( *this, nInv );
786 : }
787 0 : }
788 :
789 0 : void SwViewShell::SetUseVirDev( bool bNewVirtual )
790 : {
791 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
792 0 : if ( pIDSA->get(DocumentSettingId::USE_VIRTUAL_DEVICE) != bNewVirtual )
793 : {
794 0 : SwWait aWait( *GetDoc()->GetDocShell(), true );
795 : // this sets the flag at the document and calls PrtDataChanged
796 0 : IDocumentDeviceAccess* pIDDA = getIDocumentDeviceAccess();
797 0 : pIDDA->setReferenceDeviceType( bNewVirtual, true );
798 : }
799 0 : }
800 :
801 : /** Sets if paragraph and table spacing is added at bottom of table cells.
802 : * #106629#
803 : * @param[in] (bool) setting of the new value
804 : */
805 0 : void SwViewShell::SetAddParaSpacingToTableCells( bool _bAddParaSpacingToTableCells )
806 : {
807 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
808 0 : if ( pIDSA->get(DocumentSettingId::ADD_PARA_SPACING_TO_TABLE_CELLS) != _bAddParaSpacingToTableCells )
809 : {
810 0 : SwWait aWait( *GetDoc()->GetDocShell(), true );
811 0 : pIDSA->set(DocumentSettingId::ADD_PARA_SPACING_TO_TABLE_CELLS, _bAddParaSpacingToTableCells );
812 0 : const sal_uInt8 nInv = INV_PRTAREA;
813 0 : lcl_InvalidateAllContent( *this, nInv );
814 : }
815 0 : }
816 :
817 : /**
818 : * Sets if former formatting of text lines with proportional line spacing should used.
819 : * #i11859#
820 : * @param[in] (bool) setting of the new value
821 : */
822 0 : void SwViewShell::SetUseFormerLineSpacing( bool _bUseFormerLineSpacing )
823 : {
824 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
825 0 : if ( pIDSA->get(DocumentSettingId::OLD_LINE_SPACING) != _bUseFormerLineSpacing )
826 : {
827 0 : SwWait aWait( *GetDoc()->GetDocShell(), true );
828 0 : pIDSA->set(DocumentSettingId::OLD_LINE_SPACING, _bUseFormerLineSpacing );
829 0 : const sal_uInt8 nInv = INV_PRTAREA;
830 0 : lcl_InvalidateAllContent( *this, nInv );
831 : }
832 0 : }
833 :
834 : /**
835 : * Sets IDocumentSettingAccess if former object positioning should be used.
836 : * #i11860#
837 : * @param[in] (bool) setting the new value
838 : */
839 0 : void SwViewShell::SetUseFormerObjectPositioning( bool _bUseFormerObjPos )
840 : {
841 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
842 0 : if ( pIDSA->get(DocumentSettingId::USE_FORMER_OBJECT_POS) != _bUseFormerObjPos )
843 : {
844 0 : SwWait aWait( *GetDoc()->GetDocShell(), true );
845 0 : pIDSA->set(DocumentSettingId::USE_FORMER_OBJECT_POS, _bUseFormerObjPos );
846 0 : lcl_InvalidateAllObjPos( *this );
847 : }
848 0 : }
849 :
850 : // #i28701#
851 0 : void SwViewShell::SetConsiderWrapOnObjPos( bool _bConsiderWrapOnObjPos )
852 : {
853 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
854 0 : if ( pIDSA->get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) != _bConsiderWrapOnObjPos )
855 : {
856 0 : SwWait aWait( *GetDoc()->GetDocShell(), true );
857 0 : pIDSA->set(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION, _bConsiderWrapOnObjPos );
858 0 : lcl_InvalidateAllObjPos( *this );
859 : }
860 0 : }
861 :
862 0 : void SwViewShell::SetUseFormerTextWrapping( bool _bUseFormerTextWrapping )
863 : {
864 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
865 0 : if ( pIDSA->get(DocumentSettingId::USE_FORMER_TEXT_WRAPPING) != _bUseFormerTextWrapping )
866 : {
867 0 : SwWait aWait( *GetDoc()->GetDocShell(), true );
868 0 : pIDSA->set(DocumentSettingId::USE_FORMER_TEXT_WRAPPING, _bUseFormerTextWrapping );
869 0 : const sal_uInt8 nInv = INV_PRTAREA | INV_SIZE | INV_TABLE | INV_SECTION;
870 0 : lcl_InvalidateAllContent( *this, nInv );
871 : }
872 0 : }
873 :
874 : // #i45491#
875 0 : void SwViewShell::SetDoNotJustifyLinesWithManualBreak( bool _bDoNotJustifyLinesWithManualBreak )
876 : {
877 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
878 0 : if ( pIDSA->get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK) != _bDoNotJustifyLinesWithManualBreak )
879 : {
880 0 : SwWait aWait( *GetDoc()->GetDocShell(), true );
881 0 : pIDSA->set(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, _bDoNotJustifyLinesWithManualBreak );
882 0 : const sal_uInt8 nInv = INV_PRTAREA | INV_SIZE | INV_TABLE | INV_SECTION;
883 0 : lcl_InvalidateAllContent( *this, nInv );
884 : }
885 0 : }
886 :
887 14 : void SwViewShell::Reformat()
888 : {
889 14 : SwWait aWait( *GetDoc()->GetDocShell(), true );
890 :
891 : // we go for safe: get rid of the old font information,
892 : // when the printer resolution or zoom factor changes.
893 : // Init() and Reformat() are the safest locations.
894 14 : pFntCache->Flush( );
895 :
896 14 : if( GetLayout()->IsCallbackActionEnabled() )
897 : {
898 :
899 14 : StartAction();
900 14 : GetLayout()->InvalidateAllContent( INV_SIZE | INV_POS | INV_PRTAREA );
901 14 : EndAction();
902 14 : }
903 14 : }
904 :
905 0 : void SwViewShell::ChgNumberDigits()
906 : {
907 0 : SdrModel* pTmpDrawModel = getIDocumentDrawModelAccess()->GetDrawModel();
908 0 : if ( pTmpDrawModel )
909 0 : pTmpDrawModel->ReformatAllTextObjects();
910 0 : Reformat();
911 0 : }
912 :
913 2819 : void SwViewShell::CalcLayout()
914 : {
915 : // extremely likely to be a Bad Idea to call this without StartAction
916 : // (except the Page Preview apparently only has a non-subclassed ViewShell)
917 : assert((typeid(*this) == typeid(SwViewShell)) || mnStartAction);
918 :
919 2819 : SET_CURR_SHELL( this );
920 5638 : SwWait aWait( *GetDoc()->GetDocShell(), true );
921 :
922 : //prepare and recover cache, so that it will not get fouled.
923 2819 : SwSaveSetLRUOfst aSaveLRU( *SwTextFrm::GetTextCache(),
924 8457 : SwTextFrm::GetTextCache()->GetCurMax() - 50 );
925 :
926 : //switch on Progress when none is running yet.
927 2819 : const bool bEndProgress = SfxProgress::GetActiveProgress( GetDoc()->GetDocShell() ) == 0;
928 2819 : if ( bEndProgress )
929 : {
930 2819 : long nEndPage = GetLayout()->GetPageNum();
931 2819 : nEndPage += nEndPage * 10 / 100;
932 2819 : ::StartProgress( STR_STATSTR_REFORMAT, 0, nEndPage, GetDoc()->GetDocShell() );
933 : }
934 :
935 5638 : SwLayAction aAction( GetLayout(), Imp() );
936 2819 : aAction.SetPaint( false );
937 2819 : aAction.SetStatBar( true );
938 2819 : aAction.SetCalcLayout( true );
939 2819 : aAction.SetReschedule( true );
940 2819 : GetDoc()->getIDocumentFieldsAccess().LockExpFields();
941 2819 : aAction.Action();
942 2819 : GetDoc()->getIDocumentFieldsAccess().UnlockExpFields();
943 :
944 : //the SetNewFieldLst() on the Doc was cut off and must be fetched again
945 : //(see flowfrm.cxx, txtfld.cxx)
946 2819 : if ( aAction.IsExpFields() )
947 : {
948 84 : aAction.Reset();
949 84 : aAction.SetPaint( false );
950 84 : aAction.SetStatBar( true );
951 84 : aAction.SetReschedule( true );
952 :
953 84 : SwDocPosUpdate aMsgHint( 0 );
954 84 : GetDoc()->getIDocumentFieldsAccess().UpdatePageFields( &aMsgHint );
955 84 : GetDoc()->getIDocumentFieldsAccess().UpdateExpFields(NULL, true);
956 :
957 84 : aAction.Action();
958 : }
959 :
960 2819 : if ( VisArea().HasArea() )
961 2739 : InvalidateWindows( VisArea() );
962 2819 : if ( bEndProgress )
963 5638 : ::EndProgress( GetDoc()->GetDocShell() );
964 2819 : }
965 :
966 23027 : void SwViewShell::SetFirstVisPageInvalid()
967 : {
968 46054 : for(SwViewShell& rSh : GetRingContainer())
969 : {
970 23027 : if ( rSh.Imp() )
971 23027 : rSh.Imp()->SetFirstVisPageInvalid();
972 : }
973 23027 : }
974 :
975 8423 : void SwViewShell::SizeChgNotify()
976 : {
977 8423 : if ( !mpWin )
978 629 : mbDocSizeChgd = true;
979 7794 : else if( ActionPend() || Imp()->IsCalcLayoutProgress() || mbPaintInProgress )
980 : {
981 997 : mbDocSizeChgd = true;
982 :
983 997 : if ( !Imp()->IsCalcLayoutProgress() && ISA( SwCrsrShell ) )
984 : {
985 827 : const SwFrm *pCnt = static_cast<SwCrsrShell*>(this)->GetCurrFrm( false );
986 : const SwPageFrm *pPage;
987 827 : if ( pCnt && 0 != (pPage = pCnt->FindPageFrm()) )
988 : {
989 827 : const sal_uInt16 nVirtNum = pPage->GetVirtPageNum();
990 827 : const SvxNumberType& rNum = pPage->GetPageDesc()->GetNumType();
991 827 : OUString sDisplay = rNum.GetNumStr( nVirtNum );
992 827 : PageNumNotify( this, pCnt->GetPhyPageNum(), nVirtNum, sDisplay );
993 :
994 827 : if (isTiledRendering())
995 : {
996 1 : Size aDocSize = GetDocSize();
997 1 : std::stringstream ss;
998 1 : ss << aDocSize.Width() + 2L * DOCUMENTBORDER << ", " << aDocSize.Height() + 2L * DOCUMENTBORDER;
999 2 : OString sRect = ss.str().c_str();
1000 2 : libreOfficeKitCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sRect.getStr());
1001 827 : }
1002 : }
1003 : }
1004 : }
1005 : else
1006 : {
1007 6797 : mbDocSizeChgd = false;
1008 6797 : ::SizeNotify( this, GetDocSize() );
1009 : }
1010 8423 : }
1011 :
1012 12754 : void SwViewShell::VisPortChgd( const SwRect &rRect)
1013 : {
1014 : OSL_ENSURE( GetWin(), "VisPortChgd ohne Window." );
1015 :
1016 12754 : if ( rRect == VisArea() )
1017 0 : return;
1018 :
1019 : // Is someone spuriously rescheduling again?
1020 : SAL_WARN_IF(mbInEndAction, "sw.core", "Scrolling during EndAction");
1021 :
1022 : //First get the old visible page, so we don't have to look
1023 : //for it afterwards.
1024 12754 : const SwFrm *pOldPage = Imp()->GetFirstVisPage();
1025 :
1026 12754 : const SwRect aPrevArea( VisArea() );
1027 12754 : const bool bFull = aPrevArea.IsEmpty();
1028 12754 : maVisArea = rRect;
1029 12754 : SetFirstVisPageInvalid();
1030 :
1031 : //When there a PaintRegion still exists and the VisArea has changed,
1032 : //the PaintRegion is at least by now obsolete. The PaintRegion can
1033 : //have been created by RootFrm::Paint.
1034 38262 : if ( !mbInEndAction &&
1035 12754 : Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea() )
1036 0 : Imp()->DelRegion();
1037 :
1038 12754 : SET_CURR_SHELL( this );
1039 :
1040 12754 : bool bScrolled = false;
1041 :
1042 12754 : SwPostItMgr* pPostItMgr = GetPostItMgr();
1043 :
1044 12754 : if ( bFull )
1045 2668 : GetWin()->Invalidate();
1046 : else
1047 : {
1048 : //Calculate amount to be scrolled.
1049 10086 : const long nXDiff = aPrevArea.Left() - VisArea().Left();
1050 10086 : const long nYDiff = aPrevArea.Top() - VisArea().Top();
1051 :
1052 30204 : if( !nXDiff && !GetViewOptions()->getBrowseMode() &&
1053 20118 : (!Imp()->HasDrawView() || !Imp()->GetDrawView()->IsGridVisible() ) )
1054 : {
1055 : // If possible, don't scroll the application background
1056 : // (PaintDesktop). Also limit the left and right side of
1057 : // the scroll range to the pages.
1058 10059 : const SwPageFrm *pPage = static_cast<SwPageFrm*>(GetLayout()->Lower());
1059 10059 : if ( pPage->Frm().Top() > pOldPage->Frm().Top() )
1060 0 : pPage = static_cast<const SwPageFrm*>(pOldPage);
1061 10059 : SwRect aBoth( VisArea() );
1062 10059 : aBoth.Union( aPrevArea );
1063 10059 : const SwTwips nBottom = aBoth.Bottom();
1064 10059 : SwTwips nMinLeft = SAL_MAX_INT32;
1065 10059 : SwTwips nMaxRight= 0;
1066 :
1067 10059 : const bool bBookMode = GetViewOptions()->IsViewLayoutBookMode();
1068 :
1069 30772 : while ( pPage && pPage->Frm().Top() <= nBottom )
1070 : {
1071 10654 : SwRect aPageRect( pPage->GetBoundRect() );
1072 10654 : if ( bBookMode )
1073 : {
1074 0 : const SwPageFrm& rFormatPage = static_cast<const SwPageFrm*>(pPage)->GetFormatPage();
1075 0 : aPageRect.SSize() = rFormatPage.GetBoundRect().SSize();
1076 : }
1077 :
1078 : // OD 12.02.2003 #i9719#, #105645# - consider new border and shadow width
1079 10654 : if ( aPageRect.IsOver( aBoth ) )
1080 : {
1081 10363 : SwTwips nPageLeft = 0;
1082 10363 : SwTwips nPageRight = 0;
1083 10363 : const sw::sidebarwindows::SidebarPosition aSidebarPos = pPage->SidebarPosition();
1084 :
1085 10363 : if( aSidebarPos != sw::sidebarwindows::SidebarPosition::NONE )
1086 : {
1087 10363 : nPageLeft = aPageRect.Left();
1088 10363 : nPageRight = aPageRect.Right();
1089 : }
1090 :
1091 10363 : if( nPageLeft < nMinLeft )
1092 10057 : nMinLeft = nPageLeft;
1093 10363 : if( nPageRight > nMaxRight )
1094 10067 : nMaxRight = nPageRight;
1095 : //match with the draw objects
1096 : //take nOfst into account as the objects have been
1097 : //selected and have handles attached.
1098 10363 : if ( pPage->GetSortedObjs() )
1099 : {
1100 : const long nOfst = GetOut()->PixelToLogic(
1101 3073 : Size(Imp()->GetDrawView()->GetMarkHdlSizePixel()/2,0)).Width();
1102 11279 : for ( size_t i = 0; i < pPage->GetSortedObjs()->size(); ++i )
1103 : {
1104 8206 : SwAnchoredObject* pObj = (*pPage->GetSortedObjs())[i];
1105 : // ignore objects that are not actually placed on the page
1106 8206 : if (pObj->IsFormatPossible())
1107 : {
1108 8203 : const Rectangle &rBound = pObj->GetObjRect().SVRect();
1109 8203 : if (rBound.Left() != FAR_AWAY) {
1110 : // OD 03.03.2003 #107927# - use correct datatype
1111 8088 : const SwTwips nL = std::max( 0L, rBound.Left() - nOfst );
1112 8088 : if ( nL < nMinLeft )
1113 13 : nMinLeft = nL;
1114 8088 : if( rBound.Right() + nOfst > nMaxRight )
1115 12 : nMaxRight = rBound.Right() + nOfst;
1116 : }
1117 : }
1118 : }
1119 : }
1120 : }
1121 10654 : pPage = static_cast<const SwPageFrm*>(pPage->GetNext());
1122 : }
1123 10059 : Rectangle aRect( aPrevArea.SVRect() );
1124 10059 : aRect.Left() = nMinLeft;
1125 10059 : aRect.Right() = nMaxRight;
1126 10059 : if( VisArea().IsOver( aPrevArea ) && !mnLockPaint )
1127 : {
1128 263 : bScrolled = true;
1129 263 : maVisArea.Pos() = aPrevArea.Pos();
1130 263 : if ( SmoothScroll( nXDiff, nYDiff, &aRect ) )
1131 0 : return;
1132 263 : maVisArea.Pos() = rRect.Pos();
1133 : }
1134 : else
1135 9796 : GetWin()->Invalidate( aRect );
1136 : }
1137 27 : else if ( !mnLockPaint ) //will be released in Unlock
1138 : {
1139 14 : if( VisArea().IsOver( aPrevArea ) )
1140 : {
1141 12 : bScrolled = true;
1142 12 : maVisArea.Pos() = aPrevArea.Pos();
1143 12 : if ( SmoothScroll( nXDiff, nYDiff, 0 ) )
1144 0 : return;
1145 12 : maVisArea.Pos() = rRect.Pos();
1146 : }
1147 : else
1148 2 : GetWin()->Invalidate();
1149 : }
1150 : }
1151 :
1152 : // When tiled rendering, the map mode of the window is disabled, avoid
1153 : // enabling it here.
1154 12754 : if (!isTiledRendering())
1155 : {
1156 12746 : Point aPt( VisArea().Pos() );
1157 12746 : aPt.X() = -aPt.X(); aPt.Y() = -aPt.Y();
1158 12746 : MapMode aMapMode( GetWin()->GetMapMode() );
1159 12746 : aMapMode.SetOrigin( aPt );
1160 12746 : GetWin()->SetMapMode( aMapMode );
1161 : }
1162 :
1163 12754 : if ( HasDrawView() )
1164 : {
1165 12754 : Imp()->GetDrawView()->VisAreaChanged( GetWin() );
1166 12754 : Imp()->GetDrawView()->SetActualWin( GetWin() );
1167 : }
1168 12754 : GetWin()->Update();
1169 :
1170 12754 : if ( pPostItMgr ) // #i88070#
1171 : {
1172 12754 : pPostItMgr->Rescale();
1173 12754 : pPostItMgr->CalcRects();
1174 12754 : pPostItMgr->LayoutPostIts();
1175 : }
1176 :
1177 12754 : if ( !bScrolled && pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1178 242 : pPostItMgr->CorrectPositions();
1179 :
1180 12754 : if( Imp()->IsAccessible() )
1181 25 : Imp()->UpdateAccessible();
1182 : }
1183 :
1184 275 : bool SwViewShell::SmoothScroll( long lXDiff, long lYDiff, const Rectangle *pRect )
1185 : {
1186 : #if !defined(MACOSX) && !defined(ANDROID) && !defined(IOS)
1187 : // #i98766# - disable smooth scrolling for Mac
1188 :
1189 275 : const sal_uLong nColCnt = mpOut->GetColorCount();
1190 275 : long lMult = 1, lMax = LONG_MAX;
1191 275 : if ( nColCnt == 65536 )
1192 : {
1193 0 : lMax = 7000;
1194 0 : lMult = 2;
1195 : }
1196 275 : if ( nColCnt == 16777216 )
1197 : {
1198 0 : lMax = 5000;
1199 0 : lMult = 6;
1200 : }
1201 275 : else if ( nColCnt == 1 )
1202 : {
1203 0 : lMax = 3000;
1204 0 : lMult = 12;
1205 : }
1206 :
1207 : // #i75172# isolated static conditions
1208 275 : const bool bOnlyYScroll(!lXDiff && std::abs(lYDiff) != 0 && std::abs(lYDiff) < lMax);
1209 275 : const bool bAllowedWithChildWindows(GetWin()->GetWindowClipRegionPixel().IsNull());
1210 275 : const bool bSmoothScrollAllowed(bOnlyYScroll && mbEnableSmooth && GetViewOptions()->IsSmoothScroll() && bAllowedWithChildWindows);
1211 :
1212 275 : if(bSmoothScrollAllowed)
1213 : {
1214 0 : Imp()->bStopSmooth = false;
1215 :
1216 0 : const SwRect aOldVis( VisArea() );
1217 :
1218 : //create virtual device and set.
1219 0 : const Size aPixSz = GetWin()->PixelToLogic(Size(1,1));
1220 0 : VclPtrInstance<VirtualDevice> pVout( *GetWin() );
1221 0 : pVout->SetLineColor( GetWin()->GetLineColor() );
1222 0 : pVout->SetFillColor( GetWin()->GetFillColor() );
1223 0 : MapMode aMapMode( GetWin()->GetMapMode() );
1224 0 : pVout->SetMapMode( aMapMode );
1225 0 : Size aSize( maVisArea.Width()+2*aPixSz.Width(), std::abs(lYDiff)+(2*aPixSz.Height()) );
1226 0 : if ( pRect )
1227 0 : aSize.Width() = std::min(aSize.Width(), pRect->GetWidth()+2*aPixSz.Width());
1228 0 : if ( pVout->SetOutputSize( aSize ) )
1229 : {
1230 0 : mnLockPaint++;
1231 :
1232 : //First Paint everything in the virtual device.
1233 0 : SwRect aRect( VisArea() );
1234 0 : aRect.Height( aSize.Height() );
1235 0 : if ( pRect )
1236 : {
1237 0 : aRect.Pos().X() = std::max(aRect.Left(),pRect->Left()-aPixSz.Width());
1238 0 : aRect.Right( std::min(aRect.Right()+2*aPixSz.Width(), pRect->Right()+aPixSz.Width()));
1239 : }
1240 : else
1241 0 : aRect.SSize().Width() += 2*aPixSz.Width();
1242 0 : aRect.Pos().Y() = lYDiff < 0 ? aOldVis.Bottom() - aPixSz.Height()
1243 0 : : aRect.Top() - aSize.Height() + aPixSz.Height();
1244 0 : aRect.Pos().X() = std::max( 0L, aRect.Left()-aPixSz.Width() );
1245 0 : aRect.Pos() = GetWin()->PixelToLogic( GetWin()->LogicToPixel( aRect.Pos()));
1246 0 : aRect.SSize()= GetWin()->PixelToLogic( GetWin()->LogicToPixel( aRect.SSize()));
1247 0 : maVisArea = aRect;
1248 0 : const Point aPt( -aRect.Left(), -aRect.Top() );
1249 0 : aMapMode.SetOrigin( aPt );
1250 0 : pVout->SetMapMode( aMapMode );
1251 0 : OutputDevice *pOld = mpOut;
1252 0 : mpOut = pVout.get();
1253 :
1254 : {
1255 : // #i75172# To get a clean repaint, a new ObjectContact is needed here. Without, the
1256 : // repaint would not be correct since it would use the wrong DrawPage visible region.
1257 : // This repaint IS about painting something currently outside the visible part (!).
1258 : // For that purpose, AddWindowToPaintView is used which creates a new SdrPageViewWindow
1259 : // and all the necessary stuff. It's not cheap, but necessary here. Alone because repaint
1260 : // target really is NOT the current window.
1261 : // Also will automatically NOT use PreRendering and overlay (since target is VirtualDevice)
1262 0 : if(!HasDrawView())
1263 0 : MakeDrawView();
1264 0 : SdrView* pDrawView = GetDrawView();
1265 0 : pDrawView->AddWindowToPaintView(pVout);
1266 :
1267 : // clear mpWin during DLPrePaint2 to get paint preparation for mpOut, but set it again
1268 : // immediately afterwards. There are many decisions in SW which imply that Printing
1269 : // is used when mpWin == 0 (wrong but widely used).
1270 0 : vcl::Window* pOldWin = mpWin;
1271 0 : mpWin = 0;
1272 0 : DLPrePaint2(vcl::Region(aRect.SVRect()));
1273 0 : mpWin = pOldWin;
1274 :
1275 : // SW paint stuff
1276 0 : PaintDesktop(*GetOut(), aRect);
1277 0 : SwViewShell::mbLstAct = true;
1278 0 : GetLayout()->Paint( aRect );
1279 0 : SwViewShell::mbLstAct = false;
1280 :
1281 : // end paint and destroy ObjectContact again
1282 0 : DLPostPaint2(true);
1283 0 : pDrawView->DeleteWindowFromPaintView(pVout);
1284 : }
1285 :
1286 0 : mpOut = pOld;
1287 0 : maVisArea = aOldVis;
1288 :
1289 : //Now shift in parts and copy the new Pixel from the virtual device.
1290 :
1291 : // ??????????????????????
1292 : // or is it better to get the scrollfactor from the User
1293 : // as option?
1294 : // ??????????????????????
1295 0 : long lMaDelta = aPixSz.Height();
1296 0 : if ( std::abs(lYDiff) > ( maVisArea.Height() / 3 ) )
1297 0 : lMaDelta *= 6;
1298 : else
1299 0 : lMaDelta *= 2;
1300 :
1301 0 : lMaDelta *= lMult;
1302 :
1303 0 : if ( lYDiff < 0 )
1304 0 : lMaDelta = -lMaDelta;
1305 :
1306 0 : long lDiff = lYDiff;
1307 0 : while ( lDiff )
1308 : {
1309 : long lScroll;
1310 0 : if ( Imp()->bStopSmooth || std::abs(lDiff) <= std::abs(lMaDelta) )
1311 : {
1312 0 : lScroll = lDiff;
1313 0 : lDiff = 0;
1314 : }
1315 : else
1316 : {
1317 0 : lScroll = lMaDelta;
1318 0 : lDiff -= lMaDelta;
1319 : }
1320 :
1321 0 : const SwRect aTmpOldVis = VisArea();
1322 0 : maVisArea.Pos().Y() -= lScroll;
1323 0 : maVisArea.Pos() = GetWin()->PixelToLogic( GetWin()->LogicToPixel( VisArea().Pos()));
1324 0 : lScroll = aTmpOldVis.Top() - VisArea().Top();
1325 0 : if ( pRect )
1326 : {
1327 0 : Rectangle aTmp( aTmpOldVis.SVRect() );
1328 0 : aTmp.Left() = pRect->Left();
1329 0 : aTmp.Right()= pRect->Right();
1330 0 : GetWin()->Scroll( 0, lScroll, aTmp, ScrollFlags::Children);
1331 : }
1332 : else
1333 0 : GetWin()->Scroll( 0, lScroll, ScrollFlags::Children );
1334 :
1335 0 : const Point aTmpPt( -VisArea().Left(), -VisArea().Top() );
1336 0 : MapMode aTmpMapMode( GetWin()->GetMapMode() );
1337 0 : aTmpMapMode.SetOrigin( aTmpPt );
1338 0 : GetWin()->SetMapMode( aTmpMapMode );
1339 :
1340 0 : if ( Imp()->HasDrawView() )
1341 0 : Imp()->GetDrawView()->VisAreaChanged( GetWin() );
1342 :
1343 0 : SetFirstVisPageInvalid();
1344 0 : if ( !Imp()->bStopSmooth )
1345 : {
1346 0 : const bool bScrollDirectionIsUp(lScroll > 0);
1347 0 : Imp()->aSmoothRect = VisArea();
1348 :
1349 0 : if(bScrollDirectionIsUp)
1350 : {
1351 0 : Imp()->aSmoothRect.Bottom( VisArea().Top() + lScroll + aPixSz.Height());
1352 : }
1353 : else
1354 : {
1355 0 : Imp()->aSmoothRect.Top( VisArea().Bottom() + lScroll - aPixSz.Height());
1356 : }
1357 :
1358 0 : Imp()->bSmoothUpdate = true;
1359 0 : GetWin()->Update();
1360 0 : Imp()->bSmoothUpdate = false;
1361 :
1362 0 : if(!Imp()->bStopSmooth)
1363 : {
1364 : // start paint on logic base
1365 0 : const Rectangle aTargetLogic(Imp()->aSmoothRect.SVRect());
1366 0 : DLPrePaint2(vcl::Region(aTargetLogic));
1367 :
1368 : // get target rectangle in discrete pixels
1369 0 : OutputDevice& rTargetDevice = mpTargetPaintWindow->GetTargetOutputDevice();
1370 0 : const Rectangle aTargetPixel(rTargetDevice.LogicToPixel(aTargetLogic));
1371 :
1372 : // get source top-left in discrete pixels
1373 0 : const Point aSourceTopLeft(pVout->LogicToPixel(aTargetLogic.TopLeft()));
1374 :
1375 : // switch off MapModes
1376 0 : const bool bMapModeWasEnabledDest(rTargetDevice.IsMapModeEnabled());
1377 0 : const bool bMapModeWasEnabledSource(pVout->IsMapModeEnabled());
1378 0 : rTargetDevice.EnableMapMode(false);
1379 0 : pVout->EnableMapMode(false);
1380 :
1381 : rTargetDevice.DrawOutDev(
1382 : aTargetPixel.TopLeft(), aTargetPixel.GetSize(), // dest
1383 : aSourceTopLeft, aTargetPixel.GetSize(), // source
1384 0 : *pVout);
1385 :
1386 : // restore MapModes
1387 0 : rTargetDevice.EnableMapMode(bMapModeWasEnabledDest);
1388 0 : pVout->EnableMapMode(bMapModeWasEnabledSource);
1389 :
1390 : // end paint on logoc base
1391 0 : DLPostPaint2(true);
1392 : }
1393 : else
1394 0 : --mnLockPaint;
1395 : }
1396 0 : }
1397 0 : pVout.disposeAndClear();
1398 0 : GetWin()->Update();
1399 0 : if ( !Imp()->bStopSmooth )
1400 0 : --mnLockPaint;
1401 0 : SetFirstVisPageInvalid();
1402 0 : return true;
1403 : }
1404 0 : pVout.disposeAndClear();
1405 : }
1406 : #endif
1407 :
1408 275 : maVisArea.Pos().X() -= lXDiff;
1409 275 : maVisArea.Pos().Y() -= lYDiff;
1410 275 : if ( pRect )
1411 263 : GetWin()->Scroll( lXDiff, lYDiff, *pRect, ScrollFlags::Children);
1412 : else
1413 12 : GetWin()->Scroll( lXDiff, lYDiff, ScrollFlags::Children);
1414 275 : return false;
1415 : }
1416 :
1417 6070 : void SwViewShell::PaintDesktop(vcl::RenderContext& rRenderContext, const SwRect &rRect)
1418 : {
1419 6070 : if ( !GetWin() && !GetOut()->GetConnectMetaFile() )
1420 6070 : return; //for the printer we don't do anything here.
1421 :
1422 : //Catch exceptions, so that it doesn't look so surprising.
1423 : //Can e.g. happen during Idle.
1424 : //Unfortunately we must at any rate Paint the rectangles next to the pages,
1425 : //as these are not painted at VisPortChgd.
1426 6070 : bool bBorderOnly = false;
1427 6070 : const SwRootFrm *pRoot = GetLayout();
1428 6070 : if ( rRect.Top() > pRoot->Frm().Bottom() )
1429 : {
1430 3 : const SwFrm *pPg = pRoot->Lower();
1431 10 : while ( pPg && pPg->GetNext() )
1432 4 : pPg = pPg->GetNext();
1433 3 : if ( !pPg || !pPg->Frm().IsOver( VisArea() ) )
1434 2 : bBorderOnly = true;
1435 : }
1436 :
1437 6070 : const bool bBookMode = GetViewOptions()->IsViewLayoutBookMode();
1438 :
1439 6070 : SwRegionRects aRegion( rRect );
1440 :
1441 : //mod #i6193: remove sidebar area to avoid flickering
1442 6070 : const SwPostItMgr* pPostItMgr = GetPostItMgr();
1443 6070 : const SwTwips nSidebarWidth = pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ?
1444 8 : pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth() :
1445 6078 : 0;
1446 :
1447 6070 : if ( bBorderOnly )
1448 : {
1449 2 : const SwFrm *pPage =pRoot->Lower();
1450 2 : SwRect aLeft( rRect ), aRight( rRect );
1451 10 : while ( pPage )
1452 : {
1453 6 : long nTmp = pPage->Frm().Left();
1454 6 : if ( nTmp < aLeft.Right() )
1455 2 : aLeft.Right( nTmp );
1456 6 : nTmp = pPage->Frm().Right();
1457 6 : if ( nTmp > aRight.Left() )
1458 : {
1459 2 : aRight.Left( nTmp + nSidebarWidth );
1460 : }
1461 6 : pPage = pPage->GetNext();
1462 : }
1463 2 : aRegion.clear();
1464 2 : if ( aLeft.HasArea() )
1465 2 : aRegion.push_back( aLeft );
1466 2 : if ( aRight.HasArea() )
1467 2 : aRegion.push_back( aRight );
1468 : }
1469 : else
1470 : {
1471 6068 : const SwFrm *pPage = Imp()->GetFirstVisPage();
1472 : //Here we have to get the previous page since
1473 : //GetFirstVisPage return the current one but
1474 : //there is a portion of the previous page
1475 : //which is still visible
1476 6068 : if ( pPage->GetPrev() )
1477 197 : pPage = pPage->GetPrev();
1478 6068 : const SwTwips nBottom = rRect.Bottom();
1479 24940 : while ( pPage && !aRegion.empty() &&
1480 6622 : (pPage->Frm().Top() <= nBottom) )
1481 : {
1482 6182 : SwRect aPageRect( pPage->Frm() );
1483 6182 : if ( bBookMode )
1484 : {
1485 0 : const SwPageFrm& rFormatPage = static_cast<const SwPageFrm*>(pPage)->GetFormatPage();
1486 0 : aPageRect.SSize() = rFormatPage.Frm().SSize();
1487 : }
1488 :
1489 : const bool bSidebarRight =
1490 6182 : static_cast<const SwPageFrm*>(pPage)->SidebarPosition() == sw::sidebarwindows::SidebarPosition::RIGHT;
1491 6182 : aPageRect.Pos().X() -= bSidebarRight ? 0 : nSidebarWidth;
1492 6182 : aPageRect.SSize().Width() += nSidebarWidth;
1493 :
1494 6182 : if ( aPageRect.IsOver( rRect ) )
1495 6023 : aRegion -= aPageRect;
1496 :
1497 6182 : pPage = pPage->GetNext();
1498 : }
1499 : }
1500 6070 : if ( !aRegion.empty() )
1501 2148 : _PaintDesktop(rRenderContext, aRegion);
1502 : }
1503 :
1504 : // PaintDesktop is split in two, this part is also used by PreviewPage
1505 2148 : void SwViewShell::_PaintDesktop(vcl::RenderContext& /*rRenderContext*/, const SwRegionRects &rRegion)
1506 : {
1507 : // OD 2004-04-23 #116347#
1508 2148 : GetOut()->Push( PushFlags::FILLCOLOR|PushFlags::LINECOLOR );
1509 2148 : GetOut()->SetLineColor();
1510 :
1511 6276 : for ( auto &rRgn : rRegion )
1512 : {
1513 4128 : const Rectangle aRectangle(rRgn.SVRect());
1514 :
1515 : // #i93170#
1516 : // Here we have a real Problem. On the one hand we have the buffering for paint
1517 : // and overlay which needs an embracing pair of DLPrePaint2/DLPostPaint2 calls,
1518 : // on the other hand the MapMode is not set correctly when this code is executed.
1519 : // This is done in the users of this method, for each SWpage before painting it.
1520 : // Since the MapMode is not correct here, the call to DLPostPaint2 will paint
1521 : // existing FormControls due to the current MapMode.
1522 :
1523 : // There are basically three solutions for this:
1524 :
1525 : // (1) Set the MapMode correct, move the background painting to the users of
1526 : // this code
1527 :
1528 : // (2) Do no DLPrePaint2/DLPostPaint2 here; no SdrObjects are allowed to lie in
1529 : // the desktop region. Disadvantage: the desktop will not be part of the
1530 : // buffers, e.g. overlay. Thus, as soon as overlay will be used over the
1531 : // desktop, it will not work.
1532 :
1533 : // (3) expand DLPostPaint2 with a flag to signal if FormControl paints shall
1534 : // be done or not
1535 :
1536 : // Currently, (3) will be the best possible solution. It will keep overlay and
1537 : // buffering intact and work without MapMode for single pages. In the medium
1538 : // to long run, (1) will need to be used and the bool bPaintFormLayer needs
1539 : // to be removed again
1540 :
1541 : // #i68597# inform Drawinglayer about display change
1542 4128 : DLPrePaint2(vcl::Region(aRectangle));
1543 :
1544 : // #i75172# needed to move line/Fill color setters into loop since DLPrePaint2
1545 : // may exchange GetOut(), that's it's purpose. This happens e.g. at print preview.
1546 4128 : GetOut()->SetFillColor( SwViewOption::GetAppBackgroundColor());
1547 4128 : GetOut()->SetLineColor();
1548 4128 : GetOut()->DrawRect(aRectangle);
1549 :
1550 4128 : DLPostPaint2(false);
1551 : }
1552 :
1553 2148 : GetOut()->Pop();
1554 2148 : }
1555 :
1556 4691 : bool SwViewShell::CheckInvalidForPaint( const SwRect &rRect )
1557 : {
1558 4691 : if ( !GetWin() )
1559 0 : return false;
1560 :
1561 4691 : const SwPageFrm *pPage = Imp()->GetFirstVisPage();
1562 4691 : const SwTwips nBottom = VisArea().Bottom();
1563 4691 : const SwTwips nRight = VisArea().Right();
1564 4691 : bool bRet = false;
1565 18790 : while ( !bRet && pPage && !((pPage->Frm().Top() > nBottom) ||
1566 4704 : (pPage->Frm().Left() > nRight)))
1567 : {
1568 4704 : if ( pPage->IsInvalid() || pPage->IsInvalidFly() )
1569 80 : bRet = true;
1570 4704 : pPage = static_cast<const SwPageFrm*>(pPage->GetNext());
1571 : }
1572 :
1573 4691 : if ( bRet )
1574 : {
1575 : //Unfortunately Start/EndAction won't help here, as the Paint originated
1576 : //from GUI and so Clipping has been set against getting through.
1577 : //Ergo: do it all yourself (see ImplEndAction())
1578 80 : if ( Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea())
1579 0 : Imp()->DelRegion();
1580 :
1581 80 : SwLayAction aAction( GetLayout(), Imp() );
1582 80 : aAction.SetComplete( false );
1583 : // We increment the action counter to avoid a recursive call of actions
1584 : // e.g. from a SwFEShell::RequestObjectResize(..) in bug 95829.
1585 : // A recursive call of actions is no good idea because the inner action
1586 : // can't format frames which are locked by the outer action. This may
1587 : // cause and endless loop.
1588 80 : ++mnStartAction;
1589 80 : aAction.Action();
1590 80 : --mnStartAction;
1591 :
1592 80 : SwRegionRects *pRegion = Imp()->GetRegion();
1593 80 : if ( pRegion && aAction.IsBrowseActionStop() )
1594 : {
1595 : //only of interest when something has changed in the visible range
1596 0 : bool bStop = true;
1597 0 : for ( size_t i = 0; i < pRegion->size(); ++i )
1598 : {
1599 0 : const SwRect &rTmp = (*pRegion)[i];
1600 0 : if ( !(bStop = rTmp.IsOver( VisArea() )) )
1601 0 : break;
1602 : }
1603 0 : if ( bStop )
1604 : {
1605 0 : Imp()->DelRegion();
1606 0 : pRegion = 0;
1607 : }
1608 : }
1609 :
1610 80 : if ( pRegion )
1611 : {
1612 : //First Invert then Compress, never the other way round!
1613 3 : pRegion->Invert();
1614 3 : pRegion->Compress();
1615 3 : bRet = false;
1616 3 : if ( !pRegion->empty() )
1617 : {
1618 3 : SwRegionRects aRegion( rRect );
1619 6 : for ( size_t i = 0; i < pRegion->size(); ++i )
1620 3 : { const SwRect &rTmp = (*pRegion)[i];
1621 3 : if ( !rRect.IsInside( rTmp ) )
1622 : {
1623 2 : InvalidateWindows( rTmp );
1624 2 : if ( rTmp.IsOver( VisArea() ) )
1625 2 : { aRegion -= rTmp;
1626 2 : bRet = true;
1627 : }
1628 : }
1629 : }
1630 3 : if ( bRet )
1631 : {
1632 4 : for ( size_t i = 0; i < aRegion.size(); ++i )
1633 2 : GetWin()->Invalidate( aRegion[i].SVRect() );
1634 :
1635 2 : if ( rRect != VisArea() )
1636 : {
1637 : //rRect == VisArea is the special case for new or
1638 : //Shift-Ctrl-R, when it shouldn't be necessary to
1639 : //hold the rRect again in Document coordinates.
1640 2 : if ( maInvalidRect.IsEmpty() )
1641 2 : maInvalidRect = rRect;
1642 : else
1643 0 : maInvalidRect.Union( rRect );
1644 : }
1645 3 : }
1646 : }
1647 : else
1648 0 : bRet = false;
1649 3 : Imp()->DelRegion();
1650 : }
1651 : else
1652 77 : bRet = false;
1653 : }
1654 4691 : return bRet;
1655 : }
1656 :
1657 6252 : void SwViewShell::Paint(vcl::RenderContext& rRenderContext, const Rectangle &rRect)
1658 : {
1659 6252 : mpOut = &rRenderContext;
1660 6252 : if ( mnLockPaint )
1661 : {
1662 0 : if ( Imp()->bSmoothUpdate )
1663 : {
1664 0 : SwRect aTmp( rRect );
1665 0 : if ( !Imp()->aSmoothRect.IsInside( aTmp ) )
1666 0 : Imp()->bStopSmooth = true;
1667 : else
1668 : {
1669 0 : Imp()->aSmoothRect = aTmp;
1670 0 : return;
1671 : }
1672 : }
1673 : else
1674 0 : return;
1675 : }
1676 :
1677 6252 : if ( SwRootFrm::IsInPaint() )
1678 : {
1679 : //During the publication of a page at printing the Paint is buffered.
1680 1 : SwPaintQueue::Add( this, SwRect( rRect ) );
1681 1 : return;
1682 : }
1683 :
1684 : //With !nStartAction I try to protect me against erroneous code at other places.
1685 : //Hopefully it will not lead to problems!?
1686 6251 : if ( mbPaintWorks && !mnStartAction )
1687 : {
1688 4691 : if( GetWin() && GetWin()->IsVisible() )
1689 : {
1690 4691 : SwRect aRect( rRect );
1691 4691 : if ( mbPaintInProgress ) //Guard against double Paints!
1692 : {
1693 0 : GetWin()->Invalidate( rRect );
1694 0 : return;
1695 : }
1696 :
1697 4691 : mbPaintInProgress = true;
1698 4691 : SET_CURR_SHELL( this );
1699 4691 : SwRootFrm::SetNoVirDev( true );
1700 :
1701 : //We don't want to Clip to and fro, we trust that all are limited
1702 : //to the rectangle and only need to calculate the clipping once.
1703 : //The ClipRect is removed here once and not recovered, as externally
1704 : //no one needs it anymore anyway.
1705 : //Not when we paint a Metafile.
1706 4691 : if( !GetOut()->GetConnectMetaFile() && GetOut()->IsClipRegion())
1707 0 : GetOut()->SetClipRegion();
1708 :
1709 4691 : if ( IsPreview() )
1710 : {
1711 : //When useful, process or destroy the old InvalidRect.
1712 0 : if ( aRect.IsInside( maInvalidRect ) )
1713 0 : ResetInvalidRect();
1714 0 : SwViewShell::mbLstAct = true;
1715 0 : GetLayout()->Paint( aRect );
1716 0 : SwViewShell::mbLstAct = false;
1717 : }
1718 : else
1719 : {
1720 : //When one of the visible pages still has anything entered for
1721 : //Repaint, Repaint must be triggered.
1722 4691 : if ( !CheckInvalidForPaint( aRect ) )
1723 : {
1724 : // --> OD 2009-08-12 #i101192#
1725 : // start Pre/PostPaint encapsulation to avoid screen blinking
1726 4689 : const vcl::Region aRepaintRegion(aRect.SVRect());
1727 4689 : DLPrePaint2(aRepaintRegion);
1728 :
1729 : // <--
1730 4689 : PaintDesktop(rRenderContext, aRect);
1731 :
1732 : //When useful, process or destroy the old InvalidRect.
1733 4689 : if ( aRect.IsInside( maInvalidRect ) )
1734 930 : ResetInvalidRect();
1735 4689 : SwViewShell::mbLstAct = true;
1736 4689 : GetLayout()->Paint( aRect );
1737 4689 : SwViewShell::mbLstAct = false;
1738 : // --> OD 2009-08-12 #i101192#
1739 : // end Pre/PostPaint encapsulation
1740 4689 : DLPostPaint2(true);
1741 : // <--
1742 : }
1743 : }
1744 4691 : SwRootFrm::SetNoVirDev( false );
1745 4691 : mbPaintInProgress = false;
1746 4691 : UISizeNotify();
1747 4691 : }
1748 : }
1749 : else
1750 : {
1751 1560 : if ( maInvalidRect.IsEmpty() )
1752 1211 : maInvalidRect = SwRect( rRect );
1753 : else
1754 349 : maInvalidRect.Union( SwRect( rRect ) );
1755 :
1756 1560 : if ( mbInEndAction && GetWin() )
1757 : {
1758 949 : const vcl::Region aRegion(GetWin()->GetPaintRegion());
1759 1898 : RectangleVector aRectangles;
1760 949 : aRegion.GetRegionRectangles(aRectangles);
1761 :
1762 2023 : for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
1763 : {
1764 1074 : Imp()->AddPaintRect(*aRectIter);
1765 949 : }
1766 :
1767 : //RegionHandle hHdl( aRegion.BeginEnumRects() );
1768 : //Rectangle aRect;
1769 : //while ( aRegion.GetEnumRects( hHdl, aRect ) )
1770 : // Imp()->AddPaintRect( aRect );
1771 : //aRegion.EndEnumRects( hHdl );
1772 : }
1773 793 : else if ( SfxProgress::GetActiveProgress( GetDoc()->GetDocShell() ) &&
1774 182 : GetOut() == GetWin() )
1775 : {
1776 : // #i68597#
1777 182 : const vcl::Region aDLRegion(rRect);
1778 182 : DLPrePaint2(aDLRegion);
1779 :
1780 182 : mpOut->Push( PushFlags::FILLCOLOR|PushFlags::LINECOLOR );
1781 182 : mpOut->SetFillColor( Imp()->GetRetoucheColor() );
1782 182 : mpOut->SetLineColor();
1783 182 : mpOut->DrawRect( rRect );
1784 182 : mpOut->Pop();
1785 : // #i68597#
1786 182 : DLPostPaint2(true);
1787 : }
1788 : }
1789 : }
1790 :
1791 0 : void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contextHeight, int tilePosX, int tilePosY, long tileWidth, long tileHeight)
1792 : {
1793 : // SwViewShell's output device setup
1794 : // TODO clean up SwViewShell's approach to output devices (the many of
1795 : // them - mpBufferedOut, mpOut, mpWin, ...)
1796 0 : OutputDevice *pSaveOut = mpOut;
1797 0 : bool bTiledRendering = isTiledRendering();
1798 0 : setTiledRendering(true);
1799 0 : mbInLibreOfficeKitCallback = true;
1800 0 : mpOut = &rDevice;
1801 :
1802 : // resizes the virtual device so to contain the entrie context
1803 0 : rDevice.SetOutputSizePixel(Size(contextWidth, contextHeight));
1804 :
1805 : // setup the output device to draw the tile
1806 0 : MapMode aMapMode(rDevice.GetMapMode());
1807 0 : aMapMode.SetMapUnit(MAP_TWIP);
1808 0 : aMapMode.SetOrigin(Point(-tilePosX, -tilePosY));
1809 :
1810 : // Scaling. Must convert from pixels to twips. We know
1811 : // that VirtualDevices use a DPI of 96.
1812 0 : Fraction scaleX = Fraction(contextWidth, 96) * Fraction(1440L) / Fraction(tileWidth);
1813 0 : Fraction scaleY = Fraction(contextHeight, 96) * Fraction(1440L) / Fraction(tileHeight);
1814 0 : aMapMode.SetScaleX(scaleX);
1815 0 : aMapMode.SetScaleY(scaleY);
1816 0 : rDevice.SetMapMode(aMapMode);
1817 :
1818 : // Update this device in DrawLayer
1819 0 : if (Imp()->GetDrawView())
1820 : {
1821 0 : Imp()->GetDrawView()->AddWindowToPaintView(&rDevice);
1822 : }
1823 :
1824 : Rectangle aOutRect = Rectangle(Point(tilePosX, tilePosY),
1825 0 : rDevice.PixelToLogic(Size(contextWidth, contextHeight)));
1826 :
1827 : // Make the requested area visible -- we can't use MakeVisible as that will
1828 : // only scroll the contents, but won't zoom/resize if needed.
1829 : // Without this, items/text that are outside the visible area (in the SwView)
1830 : // won't be painted when rendering tiles (at least when using either the
1831 : // tiledrendering app, or the gtktiledviewer) -- although ultimately we
1832 : // probably want to fix things so that the SwView's area doesn't affect
1833 : // tiled rendering?
1834 0 : VisPortChgd(SwRect(aOutRect));
1835 :
1836 : // Invoke SwLayAction if layout is not yet ready.
1837 0 : CheckInvalidForPaint(aOutRect);
1838 :
1839 : // draw - works in logic coordinates
1840 0 : Paint(rDevice, aOutRect);
1841 :
1842 : // Remove this device in DrawLayer
1843 0 : if (Imp()->GetDrawView())
1844 : {
1845 0 : Imp()->GetDrawView()->DeleteWindowFromPaintView(&rDevice);
1846 : }
1847 :
1848 : // SwViewShell's output device tear down
1849 0 : mpOut = pSaveOut;
1850 0 : mbInLibreOfficeKitCallback = false;
1851 0 : setTiledRendering(bTiledRendering);
1852 0 : }
1853 :
1854 2761 : void SwViewShell::SetBrowseBorder( const Size& rNew )
1855 : {
1856 2761 : if( rNew != maBrowseBorder )
1857 : {
1858 2760 : maBrowseBorder = rNew;
1859 2760 : if ( maVisArea.HasArea() )
1860 0 : CheckBrowseView( false );
1861 : }
1862 2761 : }
1863 :
1864 223 : const Size& SwViewShell::GetBrowseBorder() const
1865 : {
1866 223 : return maBrowseBorder;
1867 : }
1868 :
1869 208 : sal_Int32 SwViewShell::GetBrowseWidth() const
1870 : {
1871 208 : const SwPostItMgr* pPostItMgr = GetPostItMgr();
1872 208 : if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1873 : {
1874 14 : Size aBorder( maBrowseBorder );
1875 14 : aBorder.Width() += maBrowseBorder.Width();
1876 14 : aBorder.Width() += pPostItMgr->GetSidebarWidth(true) + pPostItMgr->GetSidebarBorderWidth(true);
1877 14 : return maVisArea.Width() - GetOut()->PixelToLogic(aBorder).Width();
1878 : }
1879 : else
1880 194 : return maVisArea.Width() - 2 * GetOut()->PixelToLogic(maBrowseBorder).Width();
1881 : }
1882 :
1883 12368 : void SwViewShell::CheckBrowseView( bool bBrowseChgd )
1884 : {
1885 12368 : if ( !bBrowseChgd && !GetViewOptions()->getBrowseMode() )
1886 24705 : return;
1887 :
1888 16 : SET_CURR_SHELL( this );
1889 :
1890 : OSL_ENSURE( GetLayout(), "Layout not ready" );
1891 :
1892 : // When the Layout doesn't have a height yet, nothing is formatted.
1893 : // That leads to problems with Invalidate, e.g. when setting up an new View
1894 : // the content is inserted and formatted (regardless of empty VisArea).
1895 : // Therefore the pages must be roused for formatting.
1896 16 : if( !GetLayout()->Frm().Height() )
1897 : {
1898 1 : SwFrm* pPage = GetLayout()->Lower();
1899 3 : while( pPage )
1900 : {
1901 1 : pPage->_InvalidateSize();
1902 1 : pPage = pPage->GetNext();
1903 : }
1904 1 : return;
1905 : }
1906 :
1907 15 : LockPaint();
1908 15 : StartAction();
1909 :
1910 15 : SwPageFrm *pPg = static_cast<SwPageFrm*>(GetLayout()->Lower());
1911 15 : do
1912 15 : { pPg->InvalidateSize();
1913 15 : pPg->_InvalidatePrt();
1914 15 : pPg->InvaPercentLowers();
1915 15 : if ( bBrowseChgd )
1916 : {
1917 2 : pPg->PrepareHeader();
1918 2 : pPg->PrepareFooter();
1919 : }
1920 15 : pPg = static_cast<SwPageFrm*>(pPg->GetNext());
1921 : } while ( pPg );
1922 :
1923 : // When the size ratios in browse mode change,
1924 : // the Position and PrtArea of the Content and Tab frames must be Invalidated.
1925 15 : sal_uInt8 nInv = INV_PRTAREA | INV_TABLE | INV_POS;
1926 : // In case of browse mode change the ContentFrms need a size-Invalidate
1927 : // because of printer/screen formatting
1928 15 : if( bBrowseChgd )
1929 2 : nInv |= INV_SIZE | INV_DIRECTION;
1930 :
1931 15 : GetLayout()->InvalidateAllContent( nInv );
1932 :
1933 15 : SwFrm::CheckPageDescs( static_cast<SwPageFrm*>(GetLayout()->Lower()) );
1934 :
1935 15 : EndAction();
1936 15 : UnlockPaint();
1937 : }
1938 :
1939 135736395 : SwRootFrm *SwViewShell::GetLayout() const
1940 : {
1941 135736395 : return mpLayout.get();
1942 : }
1943 :
1944 1913868 : OutputDevice& SwViewShell::GetRefDev() const
1945 : {
1946 1913868 : OutputDevice* pTmpOut = 0;
1947 5735934 : if ( GetWin() &&
1948 1914746 : GetViewOptions()->getBrowseMode() &&
1949 878 : !GetViewOptions()->IsPrtFormat() )
1950 878 : pTmpOut = GetWin();
1951 1912990 : else if ( mpTmpRef )
1952 0 : pTmpOut = mpTmpRef;
1953 : else
1954 1912990 : pTmpOut = GetDoc()->getIDocumentDeviceAccess().getReferenceDevice( true );
1955 :
1956 1913868 : return *pTmpOut;
1957 : }
1958 :
1959 138 : const SwNodes& SwViewShell::GetNodes() const
1960 : {
1961 138 : return mpDoc->GetNodes();
1962 : }
1963 :
1964 3112 : void SwViewShell::DrawSelChanged()
1965 : {
1966 3112 : }
1967 :
1968 132470 : Size SwViewShell::GetDocSize() const
1969 : {
1970 132470 : Size aSz;
1971 132470 : const SwRootFrm* pRoot = GetLayout();
1972 132470 : if( pRoot )
1973 132470 : aSz = pRoot->Frm().SSize();
1974 :
1975 132470 : return aSz;
1976 : }
1977 :
1978 6446 : SfxItemPool& SwViewShell::GetAttrPool()
1979 : {
1980 6446 : return GetDoc()->GetAttrPool();
1981 : }
1982 :
1983 1167 : void SwViewShell::ApplyViewOptions( const SwViewOption &rOpt )
1984 : {
1985 :
1986 2334 : for(SwViewShell& rSh : GetRingContainer())
1987 1167 : rSh.StartAction();
1988 :
1989 1167 : ImplApplyViewOptions( rOpt );
1990 :
1991 : // With one layout per view it is not longer necessary
1992 : // to sync these "layout related" view options
1993 : // But as long as we have to disable "multiple layout"
1994 :
1995 2334 : for(SwViewShell& rSh : GetRingContainer())
1996 : {
1997 1167 : if(&rSh == this)
1998 1167 : continue;
1999 0 : SwViewOption aOpt( *rSh.GetViewOptions() );
2000 0 : aOpt.SetFieldName( rOpt.IsFieldName() );
2001 0 : aOpt.SetShowHiddenField( rOpt.IsShowHiddenField() );
2002 0 : aOpt.SetShowHiddenPara( rOpt.IsShowHiddenPara() );
2003 0 : aOpt.SetShowHiddenChar( rOpt.IsShowHiddenChar() );
2004 0 : aOpt.SetViewLayoutBookMode( rOpt.IsViewLayoutBookMode() );
2005 0 : aOpt.SetViewLayoutColumns( rOpt.GetViewLayoutColumns() );
2006 0 : aOpt.SetPostIts(rOpt.IsPostIts());
2007 0 : if ( !(aOpt == *rSh.GetViewOptions()) )
2008 0 : rSh.ImplApplyViewOptions( aOpt );
2009 0 : }
2010 : // End of disabled multiple window
2011 :
2012 2334 : for(SwViewShell& rSh : GetRingContainer())
2013 1167 : rSh.EndAction();
2014 1167 : }
2015 :
2016 1167 : void SwViewShell::ImplApplyViewOptions( const SwViewOption &rOpt )
2017 : {
2018 1167 : if (*mpOpt == rOpt)
2019 2 : return;
2020 :
2021 1166 : vcl::Window *pMyWin = GetWin();
2022 1166 : if( !pMyWin )
2023 : {
2024 : OSL_ENSURE( pMyWin, "SwViewShell::ApplyViewOptions: no window" );
2025 0 : return;
2026 : }
2027 :
2028 1166 : SET_CURR_SHELL( this );
2029 :
2030 1166 : bool bReformat = false;
2031 :
2032 1166 : if( mpOpt->IsShowHiddenField() != rOpt.IsShowHiddenField() )
2033 : {
2034 3 : static_cast<SwHiddenTextFieldType*>(mpDoc->getIDocumentFieldsAccess().GetSysFieldType( RES_HIDDENTXTFLD ))->
2035 6 : SetHiddenFlag( !rOpt.IsShowHiddenField() );
2036 3 : bReformat = true;
2037 : }
2038 1166 : if ( mpOpt->IsShowHiddenPara() != rOpt.IsShowHiddenPara() )
2039 : {
2040 : SwHiddenParaFieldType* pFieldType = static_cast<SwHiddenParaFieldType*>(GetDoc()->
2041 3 : getIDocumentFieldsAccess().GetSysFieldType(RES_HIDDENPARAFLD));
2042 3 : if( pFieldType && pFieldType->HasWriterListeners() )
2043 : {
2044 0 : SwMsgPoolItem aHint( RES_HIDDENPARA_PRINT );
2045 0 : pFieldType->ModifyNotification( &aHint, 0);
2046 : }
2047 3 : bReformat = true;
2048 : }
2049 1166 : if ( !bReformat && mpOpt->IsShowHiddenChar() != rOpt.IsShowHiddenChar() )
2050 : {
2051 2 : bReformat = GetDoc()->ContainsHiddenChars();
2052 : }
2053 :
2054 : // bReformat becomes true, if ...
2055 : // - fieldnames apply or not ...
2056 : // ( - SwEndPortion must _no_ longer be generated. )
2057 : // - Of course, the screen is something completely different than the printer ...
2058 1166 : bReformat = bReformat || mpOpt->IsFieldName() != rOpt.IsFieldName();
2059 :
2060 : // The map mode is changed, minima/maxima will be attended by UI
2061 1166 : if( mpOpt->GetZoom() != rOpt.GetZoom() && !IsPreview() )
2062 : {
2063 924 : MapMode aMode( pMyWin->GetMapMode() );
2064 1848 : Fraction aNewFactor( rOpt.GetZoom(), 100 );
2065 924 : aMode.SetScaleX( aNewFactor );
2066 924 : aMode.SetScaleY( aNewFactor );
2067 924 : pMyWin->SetMapMode( aMode );
2068 : // if not a reference device (printer) is used for formatting,
2069 : // but the screen, new formatting is needed for zoomfactor changes.
2070 924 : if( mpOpt->getBrowseMode() )
2071 927 : bReformat = true;
2072 : }
2073 :
2074 1166 : bool bBrowseModeChanged = false;
2075 1166 : if( mpOpt->getBrowseMode() != rOpt.getBrowseMode() )
2076 : {
2077 1 : bBrowseModeChanged = true;
2078 1 : bReformat = true;
2079 : }
2080 1165 : else if( mpOpt->getBrowseMode() && mpOpt->IsPrtFormat() != rOpt.IsPrtFormat() )
2081 0 : bReformat = true;
2082 :
2083 1166 : if ( HasDrawView() || rOpt.IsGridVisible() )
2084 : {
2085 1166 : if ( !HasDrawView() )
2086 0 : MakeDrawView();
2087 :
2088 1166 : SwDrawView *pDView = Imp()->GetDrawView();
2089 1166 : if ( pDView->IsDragStripes() != rOpt.IsCrossHair() )
2090 0 : pDView->SetDragStripes( rOpt.IsCrossHair() );
2091 :
2092 1166 : if ( pDView->IsGridSnap() != rOpt.IsSnap() )
2093 2 : pDView->SetGridSnap( rOpt.IsSnap() );
2094 :
2095 1166 : if ( pDView->IsGridVisible() != rOpt.IsGridVisible() )
2096 2 : pDView->SetGridVisible( rOpt.IsGridVisible() );
2097 :
2098 1166 : const Size &rSz = rOpt.GetSnapSize();
2099 1166 : pDView->SetGridCoarse( rSz );
2100 :
2101 : const Size aFSize
2102 2332 : ( rSz.Width() ? rSz.Width() / (rOpt.GetDivisionX()+1) : 0,
2103 3498 : rSz.Height()? rSz.Height()/ (rOpt.GetDivisionY()+1) : 0);
2104 1166 : pDView->SetGridFine( aFSize );
2105 1166 : Fraction aSnGrWdtX(rSz.Width(), rOpt.GetDivisionX() + 1);
2106 2332 : Fraction aSnGrWdtY(rSz.Height(), rOpt.GetDivisionY() + 1);
2107 1166 : pDView->SetSnapGridWidth( aSnGrWdtX, aSnGrWdtY );
2108 :
2109 : // set handle size to 9 pixels, always
2110 2332 : pDView->SetMarkHdlSizePixel(9);
2111 : }
2112 :
2113 1166 : bool bOnlineSpellChgd = mpOpt->IsOnlineSpell() != rOpt.IsOnlineSpell();
2114 :
2115 1166 : *mpOpt = rOpt; // First the options are taken.
2116 1166 : mpOpt->SetUIOptions(rOpt);
2117 :
2118 1166 : mpDoc->GetDocumentSettingManager().set(DocumentSettingId::HTML_MODE, 0 != ::GetHtmlMode(mpDoc->GetDocShell()));
2119 :
2120 1166 : if( bBrowseModeChanged )
2121 : {
2122 : // #i44963# Good occasion to check if page sizes in
2123 : // page descriptions are still set to (LONG_MAX, LONG_MAX) (html import)
2124 1 : mpDoc->CheckDefaultPageFormat();
2125 1 : CheckBrowseView( true );
2126 : }
2127 :
2128 1166 : pMyWin->Invalidate();
2129 1166 : if ( bReformat )
2130 : {
2131 : // Nothing helps, we need to send all ContentFrms a
2132 : // Prepare, we format anew:
2133 13 : StartAction();
2134 13 : Reformat();
2135 13 : EndAction();
2136 : }
2137 :
2138 1166 : if( bOnlineSpellChgd )
2139 : {
2140 1 : bool bOnlineSpl = rOpt.IsOnlineSpell();
2141 2 : for(SwViewShell& rSh : GetRingContainer())
2142 : {
2143 1 : if(&rSh == this)
2144 1 : continue;
2145 0 : rSh.mpOpt->SetOnlineSpell( bOnlineSpl );
2146 0 : vcl::Window *pTmpWin = rSh.GetWin();
2147 0 : if( pTmpWin )
2148 0 : pTmpWin->Invalidate();
2149 : }
2150 1166 : }
2151 :
2152 : }
2153 :
2154 2874 : void SwViewShell::SetUIOptions( const SwViewOption &rOpt )
2155 : {
2156 2874 : mpOpt->SetUIOptions(rOpt);
2157 : //the API-Flag of the view options is set but never reset
2158 : //it is required to set scroll bars in readonly documents
2159 2874 : if(rOpt.IsStarOneSetting())
2160 113 : mpOpt->SetStarOneSetting(true);
2161 :
2162 2874 : mpOpt->SetSymbolFont(rOpt.GetSymbolFont());
2163 2874 : }
2164 :
2165 0 : void SwViewShell::SetReadonlyOption(bool bSet)
2166 : {
2167 : //JP 01.02.99: at readonly flag query properly
2168 : // and if need be format; Bug 61335
2169 :
2170 : // Are we switching from readonly to edit?
2171 0 : if( bSet != mpOpt->IsReadonly() )
2172 : {
2173 : // so that the flags can be queried properly.
2174 0 : mpOpt->SetReadonly( false );
2175 :
2176 0 : bool bReformat = mpOpt->IsFieldName();
2177 :
2178 0 : mpOpt->SetReadonly( bSet );
2179 :
2180 0 : if( bReformat )
2181 : {
2182 0 : StartAction();
2183 0 : Reformat();
2184 0 : if ( GetWin() )
2185 0 : GetWin()->Invalidate();
2186 0 : EndAction();
2187 : }
2188 0 : else if ( GetWin() )
2189 0 : GetWin()->Invalidate();
2190 0 : if( Imp()->IsAccessible() )
2191 0 : Imp()->InvalidateAccessibleEditableState( false );
2192 : }
2193 0 : }
2194 :
2195 4 : void SwViewShell::SetPDFExportOption(bool bSet)
2196 : {
2197 4 : if( bSet != mpOpt->IsPDFExport() )
2198 : {
2199 4 : if( bSet && mpOpt->getBrowseMode() )
2200 0 : mpOpt->SetPrtFormat( true );
2201 4 : mpOpt->SetPDFExport(bSet);
2202 : }
2203 4 : }
2204 :
2205 0 : void SwViewShell::SetReadonlySelectionOption(bool bSet)
2206 : {
2207 0 : if( bSet != mpOpt->IsSelectionInReadonly() )
2208 : {
2209 0 : mpOpt->SetSelectionInReadonly(bSet);
2210 : }
2211 0 : }
2212 :
2213 347 : void SwViewShell::SetPrtFormatOption( bool bSet )
2214 : {
2215 347 : mpOpt->SetPrtFormat( bSet );
2216 347 : }
2217 :
2218 26820774 : void SwViewShell::UISizeNotify()
2219 : {
2220 26820774 : if ( mbDocSizeChgd )
2221 : {
2222 632 : mbDocSizeChgd = false;
2223 632 : bool bOld = bInSizeNotify;
2224 632 : bInSizeNotify = true;
2225 632 : ::SizeNotify( this, GetDocSize() );
2226 632 : bInSizeNotify = bOld;
2227 : }
2228 26820774 : }
2229 :
2230 348 : void SwViewShell::SetRestoreActions(sal_uInt16 nSet)
2231 : {
2232 : OSL_ENSURE(!GetRestoreActions()||!nSet, "multiple restore of the Actions ?");
2233 348 : Imp()->SetRestoreActions(nSet);
2234 348 : }
2235 174 : sal_uInt16 SwViewShell::GetRestoreActions() const
2236 : {
2237 174 : return Imp()->GetRestoreActions();
2238 : }
2239 :
2240 2685 : bool SwViewShell::IsNewLayout() const
2241 : {
2242 2685 : return GetLayout()->IsNewLayout();
2243 : }
2244 :
2245 12 : uno::Reference< ::com::sun::star::accessibility::XAccessible > SwViewShell::CreateAccessible()
2246 : {
2247 12 : uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc;
2248 :
2249 : // We require a layout and an XModel to be accessible.
2250 : OSL_ENSURE( mpLayout, "no layout, no access" );
2251 : OSL_ENSURE( GetWin(), "no window, no access" );
2252 :
2253 12 : if( mpDoc->getIDocumentLayoutAccess().GetCurrentViewShell() && GetWin() )
2254 12 : xAcc = Imp()->GetAccessibleMap().GetDocumentView();
2255 :
2256 12 : return xAcc;
2257 : }
2258 :
2259 : uno::Reference< ::com::sun::star::accessibility::XAccessible >
2260 0 : SwViewShell::CreateAccessiblePreview()
2261 : {
2262 : OSL_ENSURE( IsPreview(),
2263 : "Can't create accessible preview for non-preview SwViewShell" );
2264 :
2265 : // We require a layout and an XModel to be accessible.
2266 : OSL_ENSURE( mpLayout, "no layout, no access" );
2267 : OSL_ENSURE( GetWin(), "no window, no access" );
2268 :
2269 0 : if ( IsPreview() && GetLayout()&& GetWin() )
2270 : {
2271 0 : return Imp()->GetAccessibleMap().GetDocumentPreview(
2272 0 : PagePreviewLayout()->maPreviewPages,
2273 0 : GetWin()->GetMapMode().GetScaleX(),
2274 0 : GetLayout()->GetPageByPageNum( PagePreviewLayout()->mnSelectedPageNum ),
2275 0 : PagePreviewLayout()->maWinSize );
2276 : }
2277 0 : return NULL;
2278 : }
2279 :
2280 4931 : void SwViewShell::InvalidateAccessibleFocus()
2281 : {
2282 4931 : if( Imp() && Imp()->IsAccessible() )
2283 8 : Imp()->GetAccessibleMap().InvalidateFocus();
2284 4931 : }
2285 :
2286 : /**
2287 : * invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs #i27138#
2288 : */
2289 0 : void SwViewShell::InvalidateAccessibleParaFlowRelation( const SwTextFrm* _pFromTextFrm,
2290 : const SwTextFrm* _pToTextFrm )
2291 : {
2292 0 : if ( GetLayout() && GetLayout()->IsAnyShellAccessible() )
2293 : {
2294 0 : Imp()->_InvalidateAccessibleParaFlowRelation( _pFromTextFrm, _pToTextFrm );
2295 : }
2296 0 : }
2297 :
2298 : /**
2299 : * invalidate text selection for paragraphs #i27301#
2300 : */
2301 43524 : void SwViewShell::InvalidateAccessibleParaTextSelection()
2302 : {
2303 43524 : if ( GetLayout() && GetLayout()->IsAnyShellAccessible() )
2304 : {
2305 83 : Imp()->_InvalidateAccessibleParaTextSelection();
2306 : }
2307 43524 : }
2308 :
2309 : /**
2310 : * invalidate attributes for paragraphs #i88069#
2311 : */
2312 4590 : void SwViewShell::InvalidateAccessibleParaAttrs( const SwTextFrm& rTextFrm )
2313 : {
2314 4590 : if ( GetLayout() && GetLayout()->IsAnyShellAccessible() )
2315 : {
2316 0 : Imp()->_InvalidateAccessibleParaAttrs( rTextFrm );
2317 : }
2318 4590 : }
2319 :
2320 168 : SwAccessibleMap* SwViewShell::GetAccessibleMap()
2321 : {
2322 168 : if ( Imp()->IsAccessible() )
2323 : {
2324 0 : return &(Imp()->GetAccessibleMap());
2325 : }
2326 :
2327 168 : return 0;
2328 : }
2329 :
2330 2761 : void SwViewShell::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions)
2331 : {
2332 2761 : if(mpOpt->IsPagePreview() && !rAccessibilityOptions.GetIsForPagePreviews())
2333 : {
2334 0 : mpAccOptions->SetAlwaysAutoColor(false);
2335 0 : mpAccOptions->SetStopAnimatedGraphics(false);
2336 0 : mpAccOptions->SetStopAnimatedText(false);
2337 : }
2338 : else
2339 : {
2340 2761 : mpAccOptions->SetAlwaysAutoColor(rAccessibilityOptions.GetIsAutomaticFontColor());
2341 2761 : mpAccOptions->SetStopAnimatedGraphics(! rAccessibilityOptions.GetIsAllowAnimatedGraphics());
2342 2761 : mpAccOptions->SetStopAnimatedText(! rAccessibilityOptions.GetIsAllowAnimatedText());
2343 :
2344 : // Formular view
2345 : // Always set this option, not only if document is read-only:
2346 2761 : mpOpt->SetSelectionInReadonly(rAccessibilityOptions.IsSelectionInReadonly());
2347 : }
2348 2761 : }
2349 :
2350 3066 : ShellResource* SwViewShell::GetShellRes()
2351 : {
2352 3066 : return mpShellRes;
2353 : }
2354 :
2355 4 : void SwViewShell::SetCareWin( vcl::Window* pNew )
2356 : {
2357 4 : mpCareWindow = pNew;
2358 4 : }
2359 :
2360 70 : sal_uInt16 SwViewShell::GetPageCount() const
2361 : {
2362 70 : return GetLayout() ? GetLayout()->GetPageNum() : 1;
2363 : }
2364 :
2365 1 : const Size SwViewShell::GetPageSize( sal_uInt16 nPageNum, bool bSkipEmptyPages ) const
2366 : {
2367 1 : Size aSize;
2368 1 : const SwRootFrm* pTmpRoot = GetLayout();
2369 1 : if( pTmpRoot && nPageNum )
2370 : {
2371 : const SwPageFrm* pPage = static_cast<const SwPageFrm*>
2372 1 : (pTmpRoot->Lower());
2373 :
2374 2 : while( --nPageNum && pPage->GetNext() )
2375 0 : pPage = static_cast<const SwPageFrm*>( pPage->GetNext() );
2376 :
2377 1 : if( !bSkipEmptyPages && pPage->IsEmptyPage() && pPage->GetNext() )
2378 0 : pPage = static_cast<const SwPageFrm*>( pPage->GetNext() );
2379 :
2380 1 : aSize = pPage->Frm().SSize();
2381 : }
2382 1 : return aSize;
2383 : }
2384 :
2385 : // #i12836# enhanced pdf export
2386 0 : sal_Int32 SwViewShell::GetPageNumAndSetOffsetForPDF( OutputDevice& rOut, const SwRect& rRect ) const
2387 : {
2388 : OSL_ENSURE( GetLayout(), "GetPageNumAndSetOffsetForPDF assumes presence of layout" );
2389 :
2390 0 : sal_Int32 nRet = -1;
2391 :
2392 : // #i40059# Position out of bounds:
2393 0 : SwRect aRect( rRect );
2394 0 : aRect.Pos().X() = std::max( aRect.Left(), GetLayout()->Frm().Left() );
2395 :
2396 0 : const SwPageFrm* pPage = GetLayout()->GetPageAtPos( aRect.Center() );
2397 0 : if ( pPage )
2398 : {
2399 : OSL_ENSURE( pPage, "GetPageNumAndSetOffsetForPDF: No page found" );
2400 :
2401 0 : Point aOffset( pPage->Frm().Pos() );
2402 0 : aOffset.X() = -aOffset.X();
2403 0 : aOffset.Y() = -aOffset.Y();
2404 :
2405 0 : MapMode aMapMode( rOut.GetMapMode() );
2406 0 : aMapMode.SetOrigin( aOffset );
2407 0 : rOut.SetMapMode( aMapMode );
2408 :
2409 0 : nRet = pPage->GetPhyPageNum() - 1;
2410 : }
2411 :
2412 0 : return nRet;
2413 : }
2414 :
2415 : // --> PB 2007-05-30 #146850#
2416 13 : const BitmapEx& SwViewShell::GetReplacementBitmap( bool bIsErrorState )
2417 : {
2418 : BitmapEx** ppRet;
2419 13 : sal_uInt16 nResId = 0;
2420 13 : if( bIsErrorState )
2421 : {
2422 8 : ppRet = &mpErrorBmp;
2423 8 : nResId = RID_GRAPHIC_ERRORBMP;
2424 : }
2425 : else
2426 : {
2427 5 : ppRet = &mpReplaceBmp;
2428 5 : nResId = RID_GRAPHIC_REPLACEBMP;
2429 : }
2430 :
2431 13 : if( !*ppRet )
2432 : {
2433 3 : *ppRet = new BitmapEx( SW_RES( nResId ) );
2434 : }
2435 13 : return **ppRet;
2436 : }
2437 :
2438 28 : void SwViewShell::DeleteReplacementBitmaps()
2439 : {
2440 28 : DELETEZ( mpErrorBmp );
2441 28 : DELETEZ( mpReplaceBmp );
2442 28 : }
2443 :
2444 180380 : SwPostItMgr* SwViewShell::GetPostItMgr()
2445 : {
2446 180380 : SwView* pView = GetDoc()->GetDocShell() ? GetDoc()->GetDocShell()->GetView() : 0;
2447 180380 : if ( pView )
2448 174903 : return pView->GetPostItMgr();
2449 :
2450 5477 : return 0;
2451 : }
2452 :
2453 : /*
2454 : * Document Interface Access
2455 : */
2456 1228347 : const IDocumentSettingAccess* SwViewShell::getIDocumentSettingAccess() const { return &mpDoc->GetDocumentSettingManager(); }
2457 12283 : IDocumentSettingAccess* SwViewShell::getIDocumentSettingAccess() { return &mpDoc->GetDocumentSettingManager(); }
2458 952 : const IDocumentDeviceAccess* SwViewShell::getIDocumentDeviceAccess() const { return &mpDoc->getIDocumentDeviceAccess(); }
2459 8123 : IDocumentDeviceAccess* SwViewShell::getIDocumentDeviceAccess() { return &mpDoc->getIDocumentDeviceAccess(); }
2460 0 : const IDocumentMarkAccess* SwViewShell::getIDocumentMarkAccess() const { return mpDoc->getIDocumentMarkAccess(); }
2461 42 : IDocumentMarkAccess* SwViewShell::getIDocumentMarkAccess() { return mpDoc->getIDocumentMarkAccess(); }
2462 307992 : const IDocumentDrawModelAccess* SwViewShell::getIDocumentDrawModelAccess() const { return & mpDoc->getIDocumentDrawModelAccess(); }
2463 37817 : IDocumentDrawModelAccess* SwViewShell::getIDocumentDrawModelAccess() { return & mpDoc->getIDocumentDrawModelAccess(); }
2464 0 : const IDocumentRedlineAccess* SwViewShell::getIDocumentRedlineAccess() const { return &mpDoc->getIDocumentRedlineAccess(); }
2465 11 : IDocumentRedlineAccess* SwViewShell::getIDocumentRedlineAccess() { return &mpDoc->getIDocumentRedlineAccess(); }
2466 0 : const IDocumentLayoutAccess* SwViewShell::getIDocumentLayoutAccess() const { return &mpDoc->getIDocumentLayoutAccess(); }
2467 25 : IDocumentLayoutAccess* SwViewShell::getIDocumentLayoutAccess() { return &mpDoc->getIDocumentLayoutAccess(); }
2468 0 : IDocumentContentOperations* SwViewShell::getIDocumentContentOperations() { return &mpDoc->getIDocumentContentOperations(); }
2469 0 : IDocumentStylePoolAccess* SwViewShell::getIDocumentStylePoolAccess() { return &mpDoc->getIDocumentStylePoolAccess(); }
2470 53549340 : const IDocumentStatistics* SwViewShell::getIDocumentStatistics() const { return &mpDoc->getIDocumentStatistics(); }
2471 :
2472 0 : IDocumentUndoRedo & SwViewShell::GetIDocumentUndoRedo()
2473 0 : { return mpDoc->GetIDocumentUndoRedo(); }
2474 0 : IDocumentUndoRedo const& SwViewShell::GetIDocumentUndoRedo() const
2475 0 : { return mpDoc->GetIDocumentUndoRedo(); }
2476 :
2477 : // --> OD 2007-11-14 #i83479#
2478 0 : const IDocumentListItems* SwViewShell::getIDocumentListItemsAccess() const
2479 : {
2480 0 : return &mpDoc->getIDocumentListItems();
2481 : }
2482 :
2483 40 : const IDocumentOutlineNodes* SwViewShell::getIDocumentOutlineNodesAccess() const
2484 : {
2485 40 : return &mpDoc->getIDocumentOutlineNodes();
2486 177 : }
2487 :
2488 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|