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