LCOV - code coverage report
Current view: top level - sw/source/core/view - viewsh.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 782 1244 62.9 %
Date: 2014-04-11 Functions: 68 108 63.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10