LCOV - code coverage report
Current view: top level - sw/source/core/view - viewsh.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1244 0.0 %
Date: 2014-04-14 Functions: 0 108 0.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           0 : 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           0 : 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           0 :     if (rShell.GetWin())
     113             :     {
     114           0 :         Window& rWindow = *(rShell.GetWin());
     115           0 :         const Rectangle aRectanglePixel(rWindow.LogicToPixel(rRect.SVRect()));
     116           0 :         PaintTransparentChildren(rWindow, aRectanglePixel);
     117             :     }
     118           0 : }
     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           0 : void SwViewShell::PrePaint()
     129             : {
     130             :     // forward PrePaint event from VCL Window to DrawingLayer
     131           0 :     if(HasDrawView())
     132             :     {
     133           0 :         Imp()->GetDrawView()->PrePaint();
     134             :     }
     135           0 : }
     136             : 
     137           0 : void SwViewShell::DLPrePaint2(const Region& rRegion)
     138             : {
     139           0 :     if(mPrePostPaintRegions.empty())
     140             :     {
     141           0 :         mPrePostPaintRegions.push( rRegion );
     142             :         // #i75172# ensure DrawView to use DrawingLayer bufferings
     143           0 :         if ( !HasDrawView() )
     144           0 :             MakeDrawView();
     145             : 
     146             :         // Prefer window; if tot available, get mpOut (e.g. printer)
     147           0 :         mpPrePostOutDev = (GetWin() && !mbTiledRendering)? GetWin(): GetOut();
     148             : 
     149             :         // #i74769# use SdrPaintWindow now direct
     150           0 :         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           0 :         if(mpTargetPaintWindow->GetPreRenderDevice())
     155             :         {
     156           0 :             mpBufferedOut = mpOut;
     157           0 :             mpOut = &(mpTargetPaintWindow->GetTargetOutputDevice());
     158             :         }
     159             : 
     160             :         // remember original paint MapMode for wrapped FlyFrame paints
     161           0 :         maPrePostMapMode = mpOut->GetMapMode();
     162             :     }
     163             :     else
     164             :     {
     165             :         // region needs to be updated to the given one
     166           0 :         if( mPrePostPaintRegions.top() != rRegion )
     167           0 :             Imp()->GetDrawView()->UpdateDrawLayersRegion(mpPrePostOutDev, rRegion);
     168           0 :         mPrePostPaintRegions.push( rRegion );
     169             :     }
     170           0 : }
     171             : 
     172           0 : void SwViewShell::DLPostPaint2(bool bPaintFormLayer)
     173             : {
     174             :     OSL_ENSURE(!mPrePostPaintRegions.empty(), "SwViewShell::DLPostPaint2: Pre/PostPaint encapsulation broken (!)");
     175             : 
     176           0 :     if( mPrePostPaintRegions.size() > 1 )
     177             :     {
     178           0 :         Region current = mPrePostPaintRegions.top();
     179           0 :         mPrePostPaintRegions.pop();
     180           0 :         if( current != mPrePostPaintRegions.top())
     181           0 :             Imp()->GetDrawView()->UpdateDrawLayersRegion(mpPrePostOutDev, mPrePostPaintRegions.top());
     182           0 :         return;
     183             :     }
     184           0 :     mPrePostPaintRegions.pop(); // clear
     185           0 :     if(0 != mpTargetPaintWindow)
     186             :     {
     187             :         // #i74769# restore buffered OutDev
     188           0 :         if(mpTargetPaintWindow->GetPreRenderDevice())
     189             :         {
     190           0 :             mpOut = mpBufferedOut;
     191             :         }
     192             : 
     193             :         // #i74769# use SdrPaintWindow now direct
     194           0 :         Imp()->GetDrawView()->EndDrawLayers(*mpTargetPaintWindow, bPaintFormLayer);
     195           0 :         mpTargetPaintWindow = 0;
     196             :     }
     197             : }
     198             : // end of Pre/PostPaints
     199             : 
     200           0 : void SwViewShell::ImplEndAction( const sal_Bool bIdleEnd )
     201             : {
     202             :     // Nothing to do for the printer?
     203           0 :     if ( !GetWin() || IsPreview() )
     204             :     {
     205           0 :         mbPaintWorks = sal_True;
     206           0 :         UISizeNotify();
     207           0 :         return;
     208             :     }
     209             : 
     210           0 :     mbInEndAction = sal_True;
     211             :     //will this put the EndAction of the last shell in the sequence?
     212             : 
     213           0 :     SwViewShell::mbLstAct = sal_True;
     214           0 :     SwViewShell *pSh = (SwViewShell*)this->GetNext();
     215           0 :     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           0 :     const bool bIsShellForCheckViewLayout = ( this == GetLayout()->GetCurrShell() );
     227             : 
     228           0 :     SET_CURR_SHELL( this );
     229           0 :     if ( Imp()->HasDrawView() && !Imp()->GetDrawView()->areMarkHandlesHidden() )
     230           0 :         Imp()->StartAction();
     231             : 
     232           0 :     if ( Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea() )
     233           0 :         Imp()->DelRegion();
     234             : 
     235           0 :     const bool bExtraData = ::IsExtraData( GetDoc() );
     236             : 
     237           0 :     if ( !bIdleEnd )
     238             :     {
     239           0 :         SwLayAction aAction( GetLayout(), Imp() );
     240           0 :         aAction.SetComplete( sal_False );
     241           0 :         if ( mnLockPaint )
     242           0 :             aAction.SetPaint( sal_False );
     243           0 :         aAction.SetInputType( VCL_INPUT_KEYBOARD );
     244           0 :         aAction.Action();
     245             :     }
     246             : 
     247           0 :     if ( bIsShellForCheckViewLayout )
     248           0 :         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           0 :     if ( Imp()->GetRegion()     ||
     253           0 :          maInvalidRect.HasArea() ||
     254             :          bExtraData )
     255             :     {
     256           0 :         if ( !mnLockPaint )
     257             :         {
     258           0 :             SolarMutexGuard aGuard;
     259             : 
     260           0 :             sal_Bool bPaintsFromSystem = maInvalidRect.HasArea();
     261           0 :             GetWin()->Update();
     262           0 :             if ( maInvalidRect.HasArea() )
     263             :             {
     264           0 :                 if ( bPaintsFromSystem )
     265           0 :                     Imp()->AddPaintRect( maInvalidRect );
     266             : 
     267           0 :                 ResetInvalidRect();
     268           0 :                 bPaintsFromSystem = sal_True;
     269             :             }
     270           0 :             mbPaintWorks = sal_True;
     271             : 
     272           0 :             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           0 :             bool bShowCrsr = pRegion && IsA( TYPE(SwCrsrShell) );
     280           0 :             if( bShowCrsr )
     281           0 :                 ((SwCrsrShell*)this)->HideCrsrs();
     282             : 
     283           0 :             if ( pRegion )
     284             :             {
     285           0 :                 SwRootFrm* pCurrentLayout = GetLayout();
     286             : 
     287           0 :                 Imp()->pRegion = NULL;
     288             : 
     289             :                 //First Invert then Compress, never the other way round!
     290           0 :                 pRegion->Invert();
     291             : 
     292           0 :                 pRegion->Compress();
     293             : 
     294           0 :                 VirtualDevice *pVout = 0;
     295           0 :                 while ( !pRegion->empty() )
     296             :                 {
     297           0 :                     SwRect aRect( pRegion->back() );
     298           0 :                     pRegion->pop_back();
     299             : 
     300           0 :                     bool bPaint = true;
     301           0 :                     if ( IsEndActionByVirDev() )
     302             :                     {
     303             :                         //create virtual device and set.
     304           0 :                         if ( !pVout )
     305           0 :                             pVout = new VirtualDevice( *GetOut() );
     306           0 :                         MapMode aMapMode( GetOut()->GetMapMode() );
     307           0 :                         pVout->SetMapMode( aMapMode );
     308             : 
     309           0 :                         sal_Bool bSizeOK = sal_True;
     310             : 
     311           0 :                         Rectangle aTmp1( aRect.SVRect() );
     312           0 :                         aTmp1 = GetOut()->LogicToPixel( aTmp1 );
     313           0 :                         Rectangle aTmp2( GetOut()->PixelToLogic( aTmp1 ) );
     314           0 :                         if ( aTmp2.Left() > aRect.Left() )
     315           0 :                             aTmp1.Left() = std::max( 0L, aTmp1.Left() - 1L );
     316           0 :                         if ( aTmp2.Top() > aRect.Top() )
     317           0 :                             aTmp1.Top() = std::max( 0L, aTmp1.Top() - 1L );
     318           0 :                         aTmp1.Right() += 1;
     319           0 :                         aTmp1.Bottom() += 1;
     320           0 :                         aTmp1 = GetOut()->PixelToLogic( aTmp1 );
     321           0 :                         aRect = SwRect( aTmp1 );
     322             : 
     323           0 :                         const Size aTmp( pVout->GetOutputSize() );
     324           0 :                         if ( aTmp.Height() < aRect.Height() ||
     325           0 :                              aTmp.Width()  < aRect.Width() )
     326             :                         {
     327           0 :                             bSizeOK = pVout->SetOutputSize( aRect.SSize() );
     328             :                         }
     329           0 :                         if ( bSizeOK )
     330             :                         {
     331           0 :                             bPaint = false;
     332             : 
     333             :                             // --> OD 2007-07-26 #i79947#
     334             :                             // #i72754# start Pre/PostPaint encapsulation before mpOut is changed to the buffering VDev
     335           0 :                             const Region aRepaintRegion(aRect.SVRect());
     336           0 :                             DLPrePaint2(aRepaintRegion);
     337             :                             // <--
     338             : 
     339           0 :                             OutputDevice  *pOld = GetOut();
     340           0 :                             pVout->SetLineColor( pOld->GetLineColor() );
     341           0 :                             pVout->SetFillColor( pOld->GetFillColor() );
     342           0 :                             Point aOrigin( aRect.Pos() );
     343           0 :                             aOrigin.X() = -aOrigin.X(); aOrigin.Y() = -aOrigin.Y();
     344           0 :                             aMapMode.SetOrigin( aOrigin );
     345           0 :                             pVout->SetMapMode( aMapMode );
     346             : 
     347           0 :                             mpOut = pVout;
     348           0 :                             if ( bPaintsFromSystem )
     349           0 :                                 PaintDesktop( aRect );
     350           0 :                             pCurrentLayout->Paint( aRect );
     351           0 :                             pOld->DrawOutDev( aRect.Pos(), aRect.SSize(),
     352           0 :                                               aRect.Pos(), aRect.SSize(), *pVout );
     353           0 :                             mpOut = pOld;
     354             : 
     355             :                             // #i72754# end Pre/PostPaint encapsulation when mpOut is back and content is painted
     356           0 :                             DLPostPaint2(true);
     357           0 :                         }
     358             :                     }
     359           0 :                     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           0 :                         DLPrePaint2(Region(aRect.SVRect()));
     368             : 
     369           0 :                         if ( bPaintsFromSystem )
     370           0 :                             PaintDesktop( aRect );
     371           0 :                         pCurrentLayout->Paint( aRect );
     372             : 
     373             :                         // #i75172# end DrawingLayer paint
     374           0 :                         DLPostPaint2(true);
     375             :                     }
     376             : 
     377           0 :                     lcl_PaintTransparentFormControls(*this, aRect); // i#107365
     378             :                 }
     379             : 
     380           0 :                 delete pVout;
     381           0 :                 delete pRegion;
     382           0 :                 Imp()->DelRegion();
     383             :             }
     384           0 :             if( bShowCrsr )
     385           0 :                 ((SwCrsrShell*)this)->ShowCrsrs( sal_True );
     386             :         }
     387             :         else
     388             :         {
     389           0 :             Imp()->DelRegion();
     390           0 :             mbPaintWorks =  sal_True;
     391             :         }
     392             :     }
     393             :     else
     394           0 :         mbPaintWorks = sal_True;
     395             : 
     396           0 :     mbInEndAction = sal_False;
     397           0 :     SwViewShell::mbLstAct = sal_False;
     398           0 :     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           0 :     --mnStartAction;
     405           0 :     UISizeNotify();
     406           0 :     ++mnStartAction;
     407             : 
     408           0 :     if( Imp()->IsAccessible() )
     409           0 :         Imp()->FireAccessibleEvents();
     410             : }
     411             : 
     412           0 : void SwViewShell::ImplStartAction()
     413             : {
     414           0 :     mbPaintWorks = sal_False;
     415           0 :     Imp()->StartAction();
     416           0 : }
     417             : 
     418           0 : void SwViewShell::ImplLockPaint()
     419             : {
     420           0 :     if ( GetWin() && GetWin()->IsVisible() )
     421           0 :         GetWin()->EnablePaint( false ); //Also cut off the controls.
     422           0 :     Imp()->LockPaint();
     423           0 : }
     424             : 
     425           0 : void SwViewShell::ImplUnlockPaint( sal_Bool bVirDev )
     426             : {
     427           0 :     SET_CURR_SHELL( this );
     428           0 :     if ( GetWin() && GetWin()->IsVisible() )
     429             :     {
     430           0 :         if ( (bInSizeNotify || bVirDev ) && VisArea().HasArea() )
     431             :         {
     432             :             //Refresh with virtual device to avoid flickering.
     433           0 :             VirtualDevice *pVout = new VirtualDevice( *mpOut );
     434           0 :             pVout->SetMapMode( mpOut->GetMapMode() );
     435           0 :             Size aSize( VisArea().SSize() );
     436           0 :             aSize.Width() += 20;
     437           0 :             aSize.Height()+= 20;
     438           0 :             if( pVout->SetOutputSize( aSize ) )
     439             :             {
     440           0 :                 GetWin()->EnablePaint( true );
     441           0 :                 GetWin()->Validate();
     442             : 
     443           0 :                 Imp()->UnlockPaint();
     444           0 :                 pVout->SetLineColor( mpOut->GetLineColor() );
     445           0 :                 pVout->SetFillColor( mpOut->GetFillColor() );
     446             : 
     447             :                 // #i72754# start Pre/PostPaint encapsulation before mpOut is changed to the buffering VDev
     448           0 :                 const Region aRepaintRegion(VisArea().SVRect());
     449           0 :                 DLPrePaint2(aRepaintRegion);
     450             : 
     451           0 :                 OutputDevice *pOld = mpOut;
     452           0 :                 mpOut = pVout;
     453           0 :                 Paint( VisArea().SVRect() );
     454           0 :                 mpOut = pOld;
     455           0 :                 mpOut->DrawOutDev( VisArea().Pos(), aSize,
     456           0 :                                   VisArea().Pos(), aSize, *pVout );
     457             : 
     458             :                 // #i72754# end Pre/PostPaint encapsulation when mpOut is back and content is painted
     459           0 :                 DLPostPaint2(true);
     460             : 
     461           0 :                 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           0 :             delete pVout;
     470             :         }
     471             :         else
     472             :         {
     473           0 :             Imp()->UnlockPaint();
     474           0 :             GetWin()->EnablePaint( true );
     475           0 :             GetWin()->Invalidate( INVALIDATE_CHILDREN );
     476             :         }
     477             :     }
     478             :     else
     479           0 :         Imp()->UnlockPaint();
     480           0 : }
     481             : 
     482           0 : sal_Bool SwViewShell::AddPaintRect( const SwRect & rRect )
     483             : {
     484           0 :     bool bRet = false;
     485           0 :     SwViewShell *pSh = this;
     486           0 :     do
     487             :     {
     488           0 :         if( pSh->Imp() )
     489             :         {
     490           0 :         if ( pSh->IsPreview() && pSh->GetWin() )
     491           0 :             ::RepaintPagePreview( pSh, rRect );
     492             :         else
     493           0 :                 bRet |= pSh->Imp()->AddPaintRect( rRect );
     494             :         }
     495           0 :         pSh = (SwViewShell*)pSh->GetNext();
     496             :     } while ( pSh != this );
     497           0 :     return bRet;
     498             : }
     499             : 
     500           0 : void SwViewShell::InvalidateWindows( const SwRect &rRect )
     501             : {
     502           0 :     if ( !Imp()->IsCalcLayoutProgress() )
     503             :     {
     504           0 :         SwViewShell *pSh = this;
     505           0 :         do
     506             :         {
     507           0 :             if ( pSh->GetWin() )
     508             :             {
     509           0 :                 if ( pSh->IsPreview() )
     510           0 :                     ::RepaintPagePreview( pSh, rRect );
     511           0 :                 else if ( pSh->VisArea().IsOver( rRect ) )
     512           0 :                     pSh->GetWin()->Invalidate( rRect.SVRect() );
     513             :             }
     514           0 :             pSh = (SwViewShell*)pSh->GetNext();
     515             : 
     516             :         } while ( pSh != this );
     517             :     }
     518           0 : }
     519             : 
     520           0 : void SwViewShell::MakeVisible( const SwRect &rRect )
     521             : {
     522           0 :     if ( !VisArea().IsInside( rRect ) || IsScrollMDI( this, rRect ) || GetCareWin(*this) )
     523             :     {
     524           0 :         if ( !IsViewLocked() )
     525             :         {
     526           0 :             if( mpWin )
     527             :             {
     528           0 :                 const SwFrm* pRoot = GetLayout();
     529           0 :                 int nLoopCnt = 3;
     530             :                 long nOldH;
     531           0 :                 do{
     532           0 :                     nOldH = pRoot->Frm().Height();
     533           0 :                     StartAction();
     534           0 :                     ScrollMDI( this, rRect, USHRT_MAX, USHRT_MAX );
     535           0 :                     EndAction();
     536           0 :                 } 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           0 : }
     549             : 
     550           0 : Window* SwViewShell::CareChildWin(SwViewShell& rVSh)
     551             : {
     552           0 :     if(rVSh.mpSfxViewShell)
     553             :     {
     554           0 :         const sal_uInt16 nId = SvxSearchDialogWrapper::GetChildWindowId();
     555           0 :         SfxViewFrame* pVFrame = rVSh.mpSfxViewShell->GetViewFrame();
     556           0 :         const SfxChildWindow* pChWin = pVFrame->GetChildWindow( nId );
     557           0 :         Window *pWin = pChWin ? pChWin->GetWindow() : NULL;
     558           0 :         if ( pWin && pWin->IsVisible() )
     559           0 :             return pWin;
     560             :     }
     561           0 :     return NULL;
     562             : }
     563             : 
     564           0 : Point SwViewShell::GetPagePos( sal_uInt16 nPageNum ) const
     565             : {
     566           0 :     return GetLayout()->GetPagePos( nPageNum );
     567             : }
     568             : 
     569           0 : sal_uInt16 SwViewShell::GetNumPages()
     570             : {
     571             :     //It is possible that no layout exists when the method from
     572             :     //root-Ctor is called.
     573           0 :     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           0 : void SwViewShell::LayoutIdle()
     632             : {
     633           0 :     if( !mpOpt->IsIdle() || !GetWin() ||
     634           0 :         ( Imp()->HasDrawView() && Imp()->GetDrawView()->IsDragObj() ) )
     635           0 :         return;
     636             : 
     637             :     //No idle when printing is going on.
     638           0 :     SwViewShell *pSh = this;
     639           0 :     do
     640           0 :     {   if ( !pSh->GetWin() )
     641           0 :             return;
     642           0 :         pSh = (SwViewShell*)pSh->GetNext();
     643             : 
     644             :     } while ( pSh != this );
     645             : 
     646           0 :     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           0 :         SwSaveSetLRUOfst aSave( *SwTxtFrm::GetTxtCache(),
     657           0 :                              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           0 :         if(!Imp())
     663           0 :             return;
     664           0 :         SwLayIdle aIdle( GetLayout(), Imp() );
     665           0 :     }
     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           0 : void SwViewShell::Reformat()
     856             : {
     857           0 :     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           0 :     pFntCache->Flush( );
     863             : 
     864           0 :     if( GetLayout()->IsCallbackActionEnabled() )
     865             :     {
     866             : 
     867           0 :         StartAction();
     868           0 :         GetLayout()->InvalidateAllCntnt( INV_SIZE | INV_POS | INV_PRTAREA );
     869           0 :         EndAction();
     870           0 :     }
     871           0 : }
     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           0 : void SwViewShell::CalcLayout()
     882             : {
     883           0 :     SET_CURR_SHELL( this );
     884           0 :     SwWait aWait( *GetDoc()->GetDocShell(), true );
     885             : 
     886             :     //prepare and recover cache, so that it will not get fouled.
     887           0 :     SwSaveSetLRUOfst aSaveLRU( *SwTxtFrm::GetTxtCache(),
     888           0 :                                   SwTxtFrm::GetTxtCache()->GetCurMax() - 50 );
     889             : 
     890             :     //switch on Progress when none is running yet.
     891           0 :     const bool bEndProgress = SfxProgress::GetActiveProgress( GetDoc()->GetDocShell() ) == 0;
     892           0 :     if ( bEndProgress )
     893             :     {
     894           0 :         sal_uInt16 nEndPage = GetLayout()->GetPageNum();
     895           0 :         nEndPage += nEndPage * 10 / 100;
     896           0 :         ::StartProgress( STR_STATSTR_REFORMAT, 0, nEndPage, GetDoc()->GetDocShell() );
     897             :     }
     898             : 
     899           0 :     SwLayAction aAction( GetLayout(), Imp() );
     900           0 :     aAction.SetPaint( sal_False );
     901           0 :     aAction.SetStatBar( sal_True );
     902           0 :     aAction.SetCalcLayout( sal_True );
     903           0 :     aAction.SetReschedule( sal_True );
     904           0 :     GetDoc()->LockExpFlds();
     905           0 :     aAction.Action();
     906           0 :     GetDoc()->UnlockExpFlds();
     907             : 
     908             :     //the SetNewFldLst() on the Doc was cut off and must be fetched again
     909             :     //(see flowfrm.cxx, txtfld.cxx)
     910           0 :     if ( aAction.IsExpFlds() )
     911             :     {
     912           0 :         aAction.Reset();
     913           0 :         aAction.SetPaint( sal_False );
     914           0 :         aAction.SetStatBar( sal_True );
     915           0 :         aAction.SetReschedule( sal_True );
     916             : 
     917           0 :         SwDocPosUpdate aMsgHnt( 0 );
     918           0 :         GetDoc()->UpdatePageFlds( &aMsgHnt );
     919           0 :         GetDoc()->UpdateExpFlds(NULL, true);
     920             : 
     921           0 :         aAction.Action();
     922             :     }
     923             : 
     924           0 :     if ( VisArea().HasArea() )
     925           0 :         InvalidateWindows( VisArea() );
     926           0 :     if ( bEndProgress )
     927           0 :         ::EndProgress( GetDoc()->GetDocShell() );
     928           0 : }
     929             : 
     930           0 : void SwViewShell::SetFirstVisPageInvalid()
     931             : {
     932           0 :     SwViewShell *pSh = this;
     933           0 :     do
     934             :     {
     935           0 :         if ( pSh->Imp() )
     936           0 :             pSh->Imp()->SetFirstVisPageInvalid();
     937           0 :         pSh = (SwViewShell*)pSh->GetNext();
     938             : 
     939             :     } while ( pSh != this );
     940           0 : }
     941             : 
     942           0 : void SwViewShell::SizeChgNotify()
     943             : {
     944           0 :     if ( !mpWin )
     945           0 :         mbDocSizeChgd = sal_True;
     946           0 :     else if( ActionPend() || Imp()->IsCalcLayoutProgress() || mbPaintInProgress )
     947             :     {
     948           0 :         mbDocSizeChgd = sal_True;
     949             : 
     950           0 :         if ( !Imp()->IsCalcLayoutProgress() && ISA( SwCrsrShell ) )
     951             :         {
     952           0 :             const SwFrm *pCnt = ((SwCrsrShell*)this)->GetCurrFrm( sal_False );
     953             :             const SwPageFrm *pPage;
     954           0 :             if ( pCnt && 0 != (pPage = pCnt->FindPageFrm()) )
     955             :             {
     956           0 :                 sal_uInt16 nVirtNum = pPage->GetVirtPageNum();
     957           0 :                  const SvxNumberType& rNum = pPage->GetPageDesc()->GetNumType();
     958           0 :                 OUString sDisplay = rNum.GetNumStr( nVirtNum );
     959           0 :                 PageNumNotify( this, pCnt->GetPhyPageNum(), nVirtNum, sDisplay );
     960             :             }
     961             :         }
     962             :     }
     963             :     else
     964             :     {
     965           0 :         mbDocSizeChgd = sal_False;
     966           0 :         ::SizeNotify( this, GetDocSize() );
     967             :     }
     968           0 : }
     969             : 
     970           0 : void SwViewShell::VisPortChgd( const SwRect &rRect)
     971             : {
     972             :     OSL_ENSURE( GetWin(), "VisPortChgd ohne Window." );
     973             : 
     974           0 :     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           0 :     const SwFrm *pOldPage = Imp()->GetFirstVisPage();
     988             : 
     989           0 :     const SwRect aPrevArea( VisArea() );
     990           0 :     const sal_Bool bFull = aPrevArea.IsEmpty();
     991           0 :     maVisArea = rRect;
     992           0 :     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           0 :     if ( !mbInEndAction &&
     998           0 :          Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea() )
     999           0 :         Imp()->DelRegion();
    1000             : 
    1001           0 :     SET_CURR_SHELL( this );
    1002             : 
    1003           0 :     bool bScrolled = false;
    1004             : 
    1005           0 :     SwPostItMgr* pPostItMgr = GetPostItMgr();
    1006             : 
    1007           0 :     if ( bFull )
    1008           0 :         GetWin()->Invalidate();
    1009             :     else
    1010             :     {
    1011             :         //Calculate amount to be scrolled.
    1012           0 :         const long nXDiff = aPrevArea.Left() - VisArea().Left();
    1013           0 :         const long nYDiff = aPrevArea.Top()  - VisArea().Top();
    1014             : 
    1015           0 :         if( !nXDiff && !GetViewOptions()->getBrowseMode() &&
    1016           0 :             (!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           0 :             const SwPageFrm *pPage = (SwPageFrm*)GetLayout()->Lower();
    1022           0 :             if ( pPage->Frm().Top() > pOldPage->Frm().Top() )
    1023           0 :                 pPage = (SwPageFrm*)pOldPage;
    1024           0 :             SwRect aBoth( VisArea() );
    1025           0 :             aBoth.Union( aPrevArea );
    1026           0 :             const SwTwips nBottom = aBoth.Bottom();
    1027           0 :             SwTwips nMinLeft = LONG_MAX;
    1028           0 :             SwTwips nMaxRight= 0;
    1029             : 
    1030           0 :             const bool bBookMode = GetViewOptions()->IsViewLayoutBookMode();
    1031             : 
    1032           0 :             while ( pPage && pPage->Frm().Top() <= nBottom )
    1033             :             {
    1034           0 :                 SwRect aPageRect( pPage->GetBoundRect() );
    1035           0 :                 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           0 :                 if ( aPageRect.IsOver( aBoth ) )
    1043             :                 {
    1044           0 :                     SwTwips nPageLeft = 0;
    1045           0 :                     SwTwips nPageRight = 0;
    1046           0 :                     const sw::sidebarwindows::SidebarPosition aSidebarPos = pPage->SidebarPosition();
    1047             : 
    1048           0 :                     if( aSidebarPos != sw::sidebarwindows::SIDEBAR_NONE )
    1049             :                     {
    1050           0 :                         nPageLeft = aPageRect.Left();
    1051           0 :                         nPageRight = aPageRect.Right();
    1052             :                     }
    1053             : 
    1054           0 :                     if( nPageLeft < nMinLeft )
    1055           0 :                         nMinLeft = nPageLeft;
    1056           0 :                     if( nPageRight > nMaxRight )
    1057           0 :                         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           0 :                     if ( pPage->GetSortedObjs() )
    1062             :                     {
    1063             :                         const long nOfst = GetOut()->PixelToLogic(
    1064           0 :                             Size(Imp()->GetDrawView()->GetMarkHdlSizePixel()/2,0)).Width();
    1065           0 :                         for ( sal_uInt16 i = 0;
    1066           0 :                               i < pPage->GetSortedObjs()->Count(); ++i )
    1067             :                         {
    1068           0 :                             SwAnchoredObject* pObj = (*pPage->GetSortedObjs())[i];
    1069             :                             // ignore objects that are not actually placed on the page
    1070           0 :                             if (pObj->IsFormatPossible())
    1071             :                             {
    1072           0 :                                 const Rectangle &rBound = pObj->GetObjRect().SVRect();
    1073             :                                 // OD 03.03.2003 #107927# - use correct datatype
    1074           0 :                                 const SwTwips nL = std::max( 0L, rBound.Left() - nOfst );
    1075           0 :                                 if ( nL < nMinLeft )
    1076           0 :                                     nMinLeft = nL;
    1077           0 :                                 if( rBound.Right() + nOfst > nMaxRight )
    1078           0 :                                     nMaxRight = rBound.Right() + nOfst;
    1079             :                             }
    1080             :                         }
    1081             :                     }
    1082             :                 }
    1083           0 :                 pPage = (SwPageFrm*)pPage->GetNext();
    1084             :             }
    1085           0 :             Rectangle aRect( aPrevArea.SVRect() );
    1086           0 :             aRect.Left()  = nMinLeft;
    1087           0 :             aRect.Right() = nMaxRight;
    1088           0 :             if( VisArea().IsOver( aPrevArea ) && !mnLockPaint )
    1089             :             {
    1090           0 :                 bScrolled = true;
    1091           0 :                 maVisArea.Pos() = aPrevArea.Pos();
    1092           0 :                 if ( SmoothScroll( nXDiff, nYDiff, &aRect ) )
    1093           0 :                     return;
    1094           0 :                 maVisArea.Pos() = rRect.Pos();
    1095             :             }
    1096             :             else
    1097           0 :                 GetWin()->Invalidate( aRect );
    1098             :         }
    1099           0 :         else if ( !mnLockPaint ) //will be released in Unlock
    1100             :         {
    1101           0 :             if( VisArea().IsOver( aPrevArea ) )
    1102             :             {
    1103           0 :                 bScrolled = true;
    1104           0 :                 maVisArea.Pos() = aPrevArea.Pos();
    1105           0 :                 if ( SmoothScroll( nXDiff, nYDiff, 0 ) )
    1106           0 :                     return;
    1107           0 :                 maVisArea.Pos() = rRect.Pos();
    1108             :             }
    1109             :             else
    1110           0 :                 GetWin()->Invalidate();
    1111             :         }
    1112             :     }
    1113             : 
    1114           0 :     Point aPt( VisArea().Pos() );
    1115           0 :     aPt.X() = -aPt.X(); aPt.Y() = -aPt.Y();
    1116           0 :     MapMode aMapMode( GetWin()->GetMapMode() );
    1117           0 :     aMapMode.SetOrigin( aPt );
    1118           0 :     GetWin()->SetMapMode( aMapMode );
    1119           0 :     if ( HasDrawView() )
    1120             :     {
    1121           0 :         Imp()->GetDrawView()->VisAreaChanged( GetWin() );
    1122           0 :         Imp()->GetDrawView()->SetActualWin( GetWin() );
    1123             :     }
    1124           0 :     GetWin()->Update();
    1125             : 
    1126           0 :     if ( pPostItMgr ) // #i88070#
    1127             :     {
    1128           0 :         pPostItMgr->Rescale();
    1129           0 :         pPostItMgr->CalcRects();
    1130           0 :         pPostItMgr->LayoutPostIts();
    1131             :     }
    1132             : 
    1133           0 :     if ( !bScrolled && pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
    1134           0 :         pPostItMgr->CorrectPositions();
    1135             : 
    1136           0 :     if( Imp()->IsAccessible() )
    1137           0 :         Imp()->UpdateAccessible();
    1138             : }
    1139             : 
    1140           0 : 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           0 :     const sal_uLong nColCnt = mpOut->GetColorCount();
    1146           0 :     long lMult = 1, lMax = LONG_MAX;
    1147           0 :     if ( nColCnt == 65536 )
    1148             :     {
    1149           0 :         lMax = 7000;
    1150           0 :         lMult = 2;
    1151             :     }
    1152           0 :     if ( nColCnt == 16777216 )
    1153             :     {
    1154           0 :         lMax = 5000;
    1155           0 :         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           0 :     const bool bOnlyYScroll(!lXDiff && std::abs(lYDiff) != 0 && std::abs(lYDiff) < lMax);
    1165           0 :     const bool bAllowedWithChildWindows(GetWin()->GetWindowClipRegionPixel(WINDOW_GETCLIPREGION_NOCHILDREN|WINDOW_GETCLIPREGION_NULL).IsNull());
    1166           0 :     const bool bSmoothScrollAllowed(bOnlyYScroll && mbEnableSmooth && GetViewOptions()->IsSmoothScroll() &&  bAllowedWithChildWindows);
    1167             : 
    1168           0 :     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           0 :     maVisArea.Pos().X() -= lXDiff;
    1365           0 :     maVisArea.Pos().Y() -= lYDiff;
    1366           0 :     if ( pRect )
    1367           0 :         GetWin()->Scroll( lXDiff, lYDiff, *pRect, SCROLL_CHILDREN);
    1368             :     else
    1369           0 :         GetWin()->Scroll( lXDiff, lYDiff, SCROLL_CHILDREN);
    1370           0 :     return sal_False;
    1371             : }
    1372             : 
    1373           0 : void SwViewShell::PaintDesktop( const SwRect &rRect )
    1374             : {
    1375           0 :     if ( !GetWin() && !GetOut()->GetConnectMetaFile() )
    1376           0 :         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           0 :     bool bBorderOnly = false;
    1383           0 :     const SwRootFrm *pRoot = GetLayout();
    1384           0 :     if ( rRect.Top() > pRoot->Frm().Bottom() )
    1385             :     {
    1386           0 :         const SwFrm *pPg = pRoot->Lower();
    1387           0 :         while ( pPg && pPg->GetNext() )
    1388           0 :             pPg = pPg->GetNext();
    1389           0 :         if ( !pPg || !pPg->Frm().IsOver( VisArea() ) )
    1390           0 :             bBorderOnly = true;
    1391             :     }
    1392             : 
    1393           0 :     const bool bBookMode = GetViewOptions()->IsViewLayoutBookMode();
    1394             : 
    1395           0 :     SwRegionRects aRegion( rRect );
    1396             : 
    1397             :     //mod #i6193: remove sidebar area to avoid flickering
    1398           0 :     const SwPostItMgr* pPostItMgr = GetPostItMgr();
    1399           0 :     const SwTwips nSidebarWidth = pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ?
    1400           0 :                                   pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth() :
    1401           0 :                                   0;
    1402             : 
    1403           0 :     if ( bBorderOnly )
    1404             :     {
    1405           0 :         const SwFrm *pPage =pRoot->Lower();
    1406           0 :         SwRect aLeft( rRect ), aRight( rRect );
    1407           0 :         while ( pPage )
    1408             :         {
    1409           0 :             long nTmp = pPage->Frm().Left();
    1410           0 :             if ( nTmp < aLeft.Right() )
    1411           0 :                 aLeft.Right( nTmp );
    1412           0 :             nTmp = pPage->Frm().Right();
    1413           0 :             if ( nTmp > aRight.Left() )
    1414             :             {
    1415           0 :                 aRight.Left( nTmp + nSidebarWidth );
    1416             :             }
    1417           0 :             pPage = pPage->GetNext();
    1418             :         }
    1419           0 :         aRegion.clear();
    1420           0 :         if ( aLeft.HasArea() )
    1421           0 :             aRegion.push_back( aLeft );
    1422           0 :         if ( aRight.HasArea() )
    1423           0 :             aRegion.push_back( aRight );
    1424             :     }
    1425             :     else
    1426             :     {
    1427           0 :         const SwFrm *pPage = Imp()->GetFirstVisPage();
    1428           0 :         const SwTwips nBottom = rRect.Bottom();
    1429           0 :         while ( pPage && !aRegion.empty() &&
    1430           0 :                 (pPage->Frm().Top() <= nBottom) )
    1431             :         {
    1432           0 :             SwRect aPageRect( pPage->Frm() );
    1433           0 :             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           0 :                 static_cast<const SwPageFrm*>(pPage)->SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT;
    1441           0 :             aPageRect.Pos().X() -= bSidebarRight ? 0 : nSidebarWidth;
    1442           0 :             aPageRect.SSize().Width() += nSidebarWidth;
    1443             : 
    1444           0 :             if ( aPageRect.IsOver( rRect ) )
    1445           0 :                 aRegion -= aPageRect;
    1446             : 
    1447           0 :             pPage = pPage->GetNext();
    1448             :         }
    1449             :     }
    1450           0 :     if ( !aRegion.empty() )
    1451           0 :         _PaintDesktop( aRegion );
    1452             : }
    1453             : 
    1454             : // PaintDesktop is split in two, this part is also used by PreviewPage
    1455           0 : void SwViewShell::_PaintDesktop( const SwRegionRects &rRegion )
    1456             : {
    1457             :     // OD 2004-04-23 #116347#
    1458           0 :     GetOut()->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
    1459           0 :     GetOut()->SetLineColor();
    1460             : 
    1461           0 :     for ( sal_uInt16 i = 0; i < rRegion.size(); ++i )
    1462             :     {
    1463           0 :         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           0 :         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           0 :         GetOut()->SetFillColor( SwViewOption::GetAppBackgroundColor());
    1497           0 :         GetOut()->SetLineColor();
    1498           0 :         GetOut()->DrawRect(aRectangle);
    1499             : 
    1500           0 :         DLPostPaint2(false);
    1501             :     }
    1502             : 
    1503           0 :     GetOut()->Pop();
    1504           0 : }
    1505             : 
    1506           0 : sal_Bool SwViewShell::CheckInvalidForPaint( const SwRect &rRect )
    1507             : {
    1508           0 :     if ( !GetWin() )
    1509           0 :         return sal_False;
    1510             : 
    1511           0 :     const SwPageFrm *pPage = Imp()->GetFirstVisPage();
    1512           0 :     const SwTwips nBottom = VisArea().Bottom();
    1513           0 :     const SwTwips nRight  = VisArea().Right();
    1514           0 :     sal_Bool bRet = sal_False;
    1515           0 :     while ( !bRet && pPage && !((pPage->Frm().Top()  > nBottom) ||
    1516           0 :                                    (pPage->Frm().Left() > nRight)))
    1517             :     {
    1518           0 :         if ( pPage->IsInvalid() || pPage->IsInvalidFly() )
    1519           0 :             bRet = sal_True;
    1520           0 :         pPage = (SwPageFrm*)pPage->GetNext();
    1521             :     }
    1522             : 
    1523           0 :     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           0 :         if ( Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea())
    1529           0 :              Imp()->DelRegion();
    1530             : 
    1531           0 :         SwLayAction aAction( GetLayout(), Imp() );
    1532           0 :         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           0 :         ++mnStartAction;
    1539           0 :         aAction.Action();
    1540           0 :         --mnStartAction;
    1541             : 
    1542           0 :         SwRegionRects *pRegion = Imp()->GetRegion();
    1543           0 :         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           0 :         if ( pRegion )
    1561             :         {
    1562             :             //First Invert then Compress, never the other way round!
    1563           0 :             pRegion->Invert();
    1564           0 :             pRegion->Compress();
    1565           0 :             bRet = sal_False;
    1566           0 :             if ( !pRegion->empty() )
    1567             :             {
    1568           0 :                 SwRegionRects aRegion( rRect );
    1569           0 :                 for ( sal_uInt16 i = 0; i < pRegion->size(); ++i )
    1570           0 :                 {   const SwRect &rTmp = (*pRegion)[i];
    1571           0 :                     if ( !rRect.IsInside( rTmp ) )
    1572             :                     {
    1573           0 :                         InvalidateWindows( rTmp );
    1574           0 :                         if ( rTmp.IsOver( VisArea() ) )
    1575           0 :                         {   aRegion -= rTmp;
    1576           0 :                             bRet = sal_True;
    1577             :                         }
    1578             :                     }
    1579             :                 }
    1580           0 :                 if ( bRet )
    1581             :                 {
    1582           0 :                     for ( sal_uInt16 i = 0; i < aRegion.size(); ++i )
    1583           0 :                         GetWin()->Invalidate( aRegion[i].SVRect() );
    1584             : 
    1585           0 :                     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           0 :                         if ( maInvalidRect.IsEmpty() )
    1591           0 :                             maInvalidRect = rRect;
    1592             :                         else
    1593           0 :                             maInvalidRect.Union( rRect );
    1594             :                     }
    1595           0 :                 }
    1596             :             }
    1597             :             else
    1598           0 :                 bRet = sal_False;
    1599           0 :             Imp()->DelRegion();
    1600             :         }
    1601             :         else
    1602           0 :             bRet = sal_False;
    1603             :     }
    1604           0 :     return bRet;
    1605             : }
    1606             : 
    1607           0 : void SwViewShell::Paint(const Rectangle &rRect)
    1608             : {
    1609           0 :     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           0 :     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           0 :     if ( mbPaintWorks && !mnStartAction )
    1636             :     {
    1637           0 :         if( GetWin() && GetWin()->IsVisible() )
    1638             :         {
    1639           0 :             SwRect aRect( rRect );
    1640           0 :             if ( mbPaintInProgress ) //Guard against double Paints!
    1641             :             {
    1642           0 :                 GetWin()->Invalidate( rRect );
    1643           0 :                 return;
    1644             :             }
    1645             : 
    1646           0 :             mbPaintInProgress = sal_True;
    1647           0 :             SET_CURR_SHELL( this );
    1648           0 :             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           0 :             if( !GetOut()->GetConnectMetaFile() && GetOut()->IsClipRegion())
    1656           0 :                 GetOut()->SetClipRegion();
    1657             : 
    1658           0 :             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           0 :                 if ( !CheckInvalidForPaint( aRect ) )
    1672             :                 {
    1673             :                     // --> OD 2009-08-12 #i101192#
    1674             :                     // start Pre/PostPaint encapsulation to avoid screen blinking
    1675           0 :                     const Region aRepaintRegion(aRect.SVRect());
    1676           0 :                     DLPrePaint2(aRepaintRegion);
    1677             : 
    1678             :                     // <--
    1679           0 :                     PaintDesktop( aRect );
    1680             : 
    1681             :                     //When useful, process or destroy the old InvalidRect.
    1682           0 :                     if ( aRect.IsInside( maInvalidRect ) )
    1683           0 :                         ResetInvalidRect();
    1684           0 :                     SwViewShell::mbLstAct = sal_True;
    1685           0 :                     GetLayout()->Paint( aRect );
    1686           0 :                     SwViewShell::mbLstAct = sal_False;
    1687             :                     // --> OD 2009-08-12 #i101192#
    1688             :                     // end Pre/PostPaint encapsulation
    1689           0 :                     DLPostPaint2(true);
    1690             :                     // <--
    1691             :                 }
    1692             :             }
    1693           0 :             SwRootFrm::SetNoVirDev( sal_False );
    1694           0 :             mbPaintInProgress = sal_False;
    1695           0 :             UISizeNotify();
    1696           0 :         }
    1697             :     }
    1698             :     else
    1699             :     {
    1700           0 :         if ( maInvalidRect.IsEmpty() )
    1701           0 :             maInvalidRect = SwRect( rRect );
    1702             :         else
    1703           0 :             maInvalidRect.Union( SwRect( rRect ) );
    1704             : 
    1705           0 :         if ( mbInEndAction && GetWin() )
    1706             :         {
    1707           0 :             const Region aRegion(GetWin()->GetPaintRegion());
    1708           0 :             RectangleVector aRectangles;
    1709           0 :             aRegion.GetRegionRectangles(aRectangles);
    1710             : 
    1711           0 :             for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
    1712             :             {
    1713           0 :                 Imp()->AddPaintRect(*aRectIter);
    1714           0 :             }
    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           0 :         else if ( SfxProgress::GetActiveProgress( GetDoc()->GetDocShell() ) &&
    1723           0 :                   GetOut() == GetWin() )
    1724             :         {
    1725             :             // #i68597#
    1726           0 :             const Region aDLRegion(rRect);
    1727           0 :             DLPrePaint2(aDLRegion);
    1728             : 
    1729           0 :             mpOut->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
    1730           0 :             mpOut->SetFillColor( Imp()->GetRetoucheColor() );
    1731           0 :             mpOut->SetLineColor();
    1732           0 :             mpOut->DrawRect( rRect );
    1733           0 :             mpOut->Pop();
    1734             :             // #i68597#
    1735           0 :             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           0 : void SwViewShell::SetBrowseBorder( const Size& rNew )
    1892             : {
    1893           0 :     if( rNew != maBrowseBorder )
    1894             :     {
    1895           0 :         maBrowseBorder = rNew;
    1896           0 :         if ( maVisArea.HasArea() )
    1897           0 :             CheckBrowseView( sal_False );
    1898             :     }
    1899           0 : }
    1900             : 
    1901           0 : const Size& SwViewShell::GetBrowseBorder() const
    1902             : {
    1903           0 :     return maBrowseBorder;
    1904             : }
    1905             : 
    1906           0 : sal_Int32 SwViewShell::GetBrowseWidth() const
    1907             : {
    1908           0 :     const SwPostItMgr* pPostItMgr = GetPostItMgr();
    1909           0 :     if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
    1910             :     {
    1911           0 :         Size aBorder( maBrowseBorder );
    1912           0 :         aBorder.Width() += maBrowseBorder.Width();
    1913           0 :         aBorder.Width() += pPostItMgr->GetSidebarWidth(true) + pPostItMgr->GetSidebarBorderWidth(true);
    1914           0 :         return maVisArea.Width() - GetOut()->PixelToLogic(aBorder).Width();
    1915             :     }
    1916             :     else
    1917           0 :         return maVisArea.Width() - 2 * GetOut()->PixelToLogic(maBrowseBorder).Width();
    1918             : }
    1919             : 
    1920           0 : void SwViewShell::CheckBrowseView( sal_Bool bBrowseChgd )
    1921             : {
    1922           0 :     if ( !bBrowseChgd && !GetViewOptions()->getBrowseMode() )
    1923           0 :         return;
    1924             : 
    1925           0 :     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           0 :     if( !GetLayout()->Frm().Height() )
    1934             :     {
    1935           0 :         SwFrm* pPage = GetLayout()->Lower();
    1936           0 :         while( pPage )
    1937             :         {
    1938           0 :             pPage->_InvalidateSize();
    1939           0 :             pPage = pPage->GetNext();
    1940             :         }
    1941           0 :         return;
    1942             :     }
    1943             : 
    1944           0 :     LockPaint();
    1945           0 :     StartAction();
    1946             : 
    1947           0 :     SwPageFrm *pPg = (SwPageFrm*)GetLayout()->Lower();
    1948           0 :     do
    1949           0 :     {   pPg->InvalidateSize();
    1950           0 :         pPg->_InvalidatePrt();
    1951           0 :         pPg->InvaPercentLowers();
    1952           0 :         if ( bBrowseChgd )
    1953             :         {
    1954           0 :             pPg->PrepareHeader();
    1955           0 :             pPg->PrepareFooter();
    1956             :         }
    1957           0 :         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           0 :     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           0 :     if( bBrowseChgd )
    1966           0 :         nInv |= INV_SIZE | INV_DIRECTION;
    1967             : 
    1968           0 :     GetLayout()->InvalidateAllCntnt( nInv );
    1969             : 
    1970           0 :     SwFrm::CheckPageDescs( (SwPageFrm*)GetLayout()->Lower() );
    1971             : 
    1972           0 :     EndAction();
    1973           0 :     UnlockPaint();
    1974             : }
    1975             : 
    1976           0 : SwRootFrm *SwViewShell::GetLayout() const
    1977             : {
    1978           0 :     return mpLayout.get();
    1979             : }
    1980             : 
    1981           0 : OutputDevice& SwViewShell::GetRefDev() const
    1982             : {
    1983           0 :     OutputDevice* pTmpOut = 0;
    1984           0 :     if (  GetWin() &&
    1985           0 :           GetViewOptions()->getBrowseMode() &&
    1986           0 :          !GetViewOptions()->IsPrtFormat() )
    1987           0 :         pTmpOut = GetWin();
    1988           0 :     else if ( 0 != mpTmpRef )
    1989           0 :         pTmpOut = mpTmpRef;
    1990             :     else
    1991           0 :         pTmpOut = GetDoc()->getReferenceDevice( true );
    1992             : 
    1993           0 :     return *pTmpOut;
    1994             : }
    1995             : 
    1996           0 : const SwNodes& SwViewShell::GetNodes() const
    1997             : {
    1998           0 :     return mpDoc->GetNodes();
    1999             : }
    2000             : 
    2001           0 : void SwViewShell::DrawSelChanged()
    2002             : {
    2003           0 : }
    2004             : 
    2005           0 : Size SwViewShell::GetDocSize() const
    2006             : {
    2007           0 :     Size aSz;
    2008           0 :     const SwRootFrm* pRoot = GetLayout();
    2009           0 :     if( pRoot )
    2010           0 :         aSz = pRoot->Frm().SSize();
    2011             : 
    2012           0 :     return aSz;
    2013             : }
    2014             : 
    2015           0 : SfxItemPool& SwViewShell::GetAttrPool()
    2016             : {
    2017           0 :     return GetDoc()->GetAttrPool();
    2018             : }
    2019             : 
    2020           0 : void SwViewShell::ApplyViewOptions( const SwViewOption &rOpt )
    2021             : {
    2022             : 
    2023           0 :     SwViewShell *pSh = this;
    2024           0 :     do
    2025           0 :     {   pSh->StartAction();
    2026           0 :         pSh = (SwViewShell*)pSh->GetNext();
    2027             :     } while ( pSh != this );
    2028             : 
    2029           0 :     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           0 :     pSh = (SwViewShell*)this->GetNext();
    2035           0 :     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           0 :     pSh = this;
    2052           0 :     do
    2053           0 :     {   pSh->EndAction();
    2054           0 :         pSh = (SwViewShell*)pSh->GetNext();
    2055             :     } while ( pSh != this );
    2056             : 
    2057           0 : }
    2058             : 
    2059           0 : void SwViewShell::ImplApplyViewOptions( const SwViewOption &rOpt )
    2060             : {
    2061           0 :     if (*mpOpt == rOpt)
    2062           0 :         return;
    2063             : 
    2064           0 :     Window *pMyWin = GetWin();
    2065           0 :     if( !pMyWin )
    2066             :     {
    2067             :         OSL_ENSURE( pMyWin, "SwViewShell::ApplyViewOptions: no window" );
    2068           0 :         return;
    2069             :     }
    2070             : 
    2071           0 :     SET_CURR_SHELL( this );
    2072             : 
    2073           0 :     sal_Bool bReformat   = sal_False;
    2074             : 
    2075           0 :     if( mpOpt->IsShowHiddenField() != rOpt.IsShowHiddenField() )
    2076             :     {
    2077           0 :         ((SwHiddenTxtFieldType*)mpDoc->GetSysFldType( RES_HIDDENTXTFLD ))->
    2078           0 :                                             SetHiddenFlag( !rOpt.IsShowHiddenField() );
    2079           0 :         bReformat = sal_True;
    2080             :     }
    2081           0 :     if ( mpOpt->IsShowHiddenPara() != rOpt.IsShowHiddenPara() )
    2082             :     {
    2083           0 :         SwHiddenParaFieldType* pFldType = (SwHiddenParaFieldType*)GetDoc()->
    2084           0 :                                           GetSysFldType(RES_HIDDENPARAFLD);
    2085           0 :         if( pFldType && pFldType->GetDepends() )
    2086             :         {
    2087           0 :             SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
    2088           0 :             pFldType->ModifyNotification( &aHnt, 0);
    2089             :         }
    2090           0 :         bReformat = sal_True;
    2091             :     }
    2092           0 :     if ( !bReformat && mpOpt->IsShowHiddenChar() != rOpt.IsShowHiddenChar() )
    2093             :     {
    2094           0 :         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           0 :     bReformat = bReformat || mpOpt->IsFldName() != rOpt.IsFldName();
    2102             : 
    2103             :     // The map mode is changed, minima/maxima will be attended by UI
    2104           0 :     if( mpOpt->GetZoom() != rOpt.GetZoom() && !IsPreview() )
    2105             :     {
    2106           0 :         MapMode aMode( pMyWin->GetMapMode() );
    2107           0 :         Fraction aNewFactor( rOpt.GetZoom(), 100 );
    2108           0 :         aMode.SetScaleX( aNewFactor );
    2109           0 :         aMode.SetScaleY( aNewFactor );
    2110           0 :         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           0 :         if( mpOpt->getBrowseMode() )
    2114           0 :             bReformat = sal_True;
    2115             :     }
    2116             : 
    2117           0 :     bool bBrowseModeChanged = false;
    2118           0 :     if( mpOpt->getBrowseMode() != rOpt.getBrowseMode() )
    2119             :     {
    2120           0 :         bBrowseModeChanged = true;
    2121           0 :         bReformat = sal_True;
    2122             :     }
    2123           0 :     else if( mpOpt->getBrowseMode() && mpOpt->IsPrtFormat() != rOpt.IsPrtFormat() )
    2124           0 :         bReformat = sal_True;
    2125             : 
    2126           0 :     if ( HasDrawView() || rOpt.IsGridVisible() )
    2127             :     {
    2128           0 :         if ( !HasDrawView() )
    2129           0 :             MakeDrawView();
    2130             : 
    2131           0 :         SwDrawView *pDView = Imp()->GetDrawView();
    2132           0 :         if ( (pDView->IsDragStripes() ? 1 : 0) != rOpt.IsCrossHair() )
    2133           0 :             pDView->SetDragStripes( rOpt.IsCrossHair() );
    2134             : 
    2135           0 :         if ( (pDView->IsGridSnap() ? 1 : 0) != rOpt.IsSnap() )
    2136           0 :             pDView->SetGridSnap( rOpt.IsSnap() );
    2137             : 
    2138           0 :         if ( (pDView->IsGridVisible() ? 1 : 0) != rOpt.IsGridVisible() )
    2139           0 :             pDView->SetGridVisible( rOpt.IsGridVisible() );
    2140             : 
    2141           0 :         const Size &rSz = rOpt.GetSnapSize();
    2142           0 :         pDView->SetGridCoarse( rSz );
    2143             : 
    2144             :         const Size aFSize
    2145           0 :             ( rSz.Width() ? rSz.Width() / (rOpt.GetDivisionX()+1) : 0,
    2146           0 :               rSz.Height()? rSz.Height()/ (rOpt.GetDivisionY()+1) : 0);
    2147           0 :         pDView->SetGridFine( aFSize );
    2148           0 :         Fraction aSnGrWdtX(rSz.Width(), rOpt.GetDivisionX() + 1);
    2149           0 :         Fraction aSnGrWdtY(rSz.Height(), rOpt.GetDivisionY() + 1);
    2150           0 :         pDView->SetSnapGridWidth( aSnGrWdtX, aSnGrWdtY );
    2151             : 
    2152             :             // set handle size to 9 pixels, always
    2153           0 :             pDView->SetMarkHdlSizePixel(9);
    2154             :     }
    2155             : 
    2156           0 :     bool bOnlineSpellChgd = mpOpt->IsOnlineSpell() != rOpt.IsOnlineSpell();
    2157             : 
    2158           0 :     *mpOpt = rOpt;   // First the options are taken.
    2159           0 :     mpOpt->SetUIOptions(rOpt);
    2160             : 
    2161           0 :     mpDoc->set(IDocumentSettingAccess::HTML_MODE, 0 != ::GetHtmlMode(mpDoc->GetDocShell()));
    2162             : 
    2163           0 :     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           0 :         mpDoc->CheckDefaultPageFmt();
    2168           0 :         CheckBrowseView( sal_True );
    2169             :     }
    2170             : 
    2171           0 :     pMyWin->Invalidate();
    2172           0 :     if ( bReformat )
    2173             :     {
    2174             :         // Nothing helps, we need to send all CntntFrms a
    2175             :         // Prepare, we format anew:
    2176           0 :         StartAction();
    2177           0 :         Reformat();
    2178           0 :         EndAction();
    2179             :     }
    2180             : 
    2181           0 :     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           0 :     }
    2193             : 
    2194             : }
    2195             : 
    2196           0 : void SwViewShell::SetUIOptions( const SwViewOption &rOpt )
    2197             : {
    2198           0 :     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           0 :     if(rOpt.IsStarOneSetting())
    2202           0 :         mpOpt->SetStarOneSetting(sal_True);
    2203             : 
    2204           0 :     mpOpt->SetSymbolFont(rOpt.GetSymbolFont());
    2205           0 : }
    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           0 : void SwViewShell::SetPrtFormatOption( sal_Bool bSet )
    2256             : {
    2257           0 :     mpOpt->SetPrtFormat( bSet );
    2258           0 : }
    2259             : 
    2260           0 : void SwViewShell::UISizeNotify()
    2261             : {
    2262           0 :     if ( mbDocSizeChgd )
    2263             :     {
    2264           0 :         mbDocSizeChgd = sal_False;
    2265           0 :         bool bOld = bInSizeNotify;
    2266           0 :         bInSizeNotify = true;
    2267           0 :         ::SizeNotify( this, GetDocSize() );
    2268           0 :         bInSizeNotify = bOld;
    2269             :     }
    2270           0 : }
    2271             : 
    2272           0 : void    SwViewShell::SetRestoreActions(sal_uInt16 nSet)
    2273             : {
    2274             :     OSL_ENSURE(!GetRestoreActions()||!nSet, "multiple restore of the Actions ?");
    2275           0 :     Imp()->SetRestoreActions(nSet);
    2276           0 : }
    2277           0 : sal_uInt16  SwViewShell::GetRestoreActions() const
    2278             : {
    2279           0 :     return Imp()->GetRestoreActions();
    2280             : }
    2281             : 
    2282           0 : sal_Bool SwViewShell::IsNewLayout() const
    2283             : {
    2284           0 :     return GetLayout()->IsNewLayout();
    2285             : }
    2286             : 
    2287           0 : uno::Reference< ::com::sun::star::accessibility::XAccessible > SwViewShell::CreateAccessible()
    2288             : {
    2289           0 :     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           0 :     if( mpDoc->GetCurrentViewShell() && GetWin() )
    2296           0 :         xAcc = Imp()->GetAccessibleMap().GetDocumentView();
    2297             : 
    2298           0 :     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           0 : void SwViewShell::InvalidateAccessibleFocus()
    2323             : {
    2324           0 :     if( Imp()->IsAccessible() )
    2325           0 :         Imp()->GetAccessibleMap().InvalidateFocus();
    2326           0 : }
    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           0 : void SwViewShell::InvalidateAccessibleParaTextSelection()
    2344             : {
    2345           0 :     if ( GetLayout() && GetLayout()->IsAnyShellAccessible() )
    2346             :     {
    2347           0 :         Imp()->_InvalidateAccessibleParaTextSelection();
    2348             :     }
    2349           0 : }
    2350             : 
    2351             : /**
    2352             :  * invalidate attributes for paragraphs #i88069#
    2353             :  */
    2354           0 : void SwViewShell::InvalidateAccessibleParaAttrs( const SwTxtFrm& rTxtFrm )
    2355             : {
    2356           0 :     if ( GetLayout() && GetLayout()->IsAnyShellAccessible() )
    2357             :     {
    2358           0 :         Imp()->_InvalidateAccessibleParaAttrs( rTxtFrm );
    2359             :     }
    2360           0 : }
    2361             : 
    2362           0 : SwAccessibleMap* SwViewShell::GetAccessibleMap()
    2363             : {
    2364           0 :     if ( Imp()->IsAccessible() )
    2365             :     {
    2366           0 :         return &(Imp()->GetAccessibleMap());
    2367             :     }
    2368             : 
    2369           0 :     return 0;
    2370             : }
    2371             : 
    2372           0 : void SwViewShell::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions)
    2373             : {
    2374           0 :     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           0 :         mpAccOptions->SetAlwaysAutoColor(rAccessibilityOptions.GetIsAutomaticFontColor());
    2383           0 :         mpAccOptions->SetStopAnimatedGraphics(! rAccessibilityOptions.GetIsAllowAnimatedGraphics());
    2384           0 :         mpAccOptions->SetStopAnimatedText(! rAccessibilityOptions.GetIsAllowAnimatedText());
    2385             : 
    2386             :         // Formular view
    2387             :         // Always set this option, not only if document is read-only:
    2388           0 :         mpOpt->SetSelectionInReadonly(rAccessibilityOptions.IsSelectionInReadonly());
    2389             :     }
    2390           0 : }
    2391             : 
    2392           0 : ShellResource* SwViewShell::GetShellRes()
    2393             : {
    2394           0 :     return mpShellRes;
    2395             : }
    2396             : 
    2397           0 : void SwViewShell::SetCareWin( Window* pNew )
    2398             : {
    2399           0 :     mpCareWindow = pNew;
    2400           0 : }
    2401             : 
    2402           0 : sal_uInt16 SwViewShell::GetPageCount() const
    2403             : {
    2404           0 :     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           0 : const BitmapEx& SwViewShell::GetReplacementBitmap( bool bIsErrorState )
    2459             : {
    2460             :     BitmapEx** ppRet;
    2461           0 :     sal_uInt16 nResId = 0;
    2462           0 :     if( bIsErrorState )
    2463             :     {
    2464           0 :         ppRet = &mpErrorBmp;
    2465           0 :         nResId = RID_GRAPHIC_ERRORBMP;
    2466             :     }
    2467             :     else
    2468             :     {
    2469           0 :         ppRet = &mpReplaceBmp;
    2470           0 :         nResId = RID_GRAPHIC_REPLACEBMP;
    2471             :     }
    2472             : 
    2473           0 :     if( !*ppRet )
    2474             :     {
    2475           0 :         *ppRet = new BitmapEx( SW_RES( nResId ) );
    2476             :     }
    2477           0 :     return **ppRet;
    2478             : }
    2479             : 
    2480           0 : void SwViewShell::DeleteReplacementBitmaps()
    2481             : {
    2482           0 :     DELETEZ( mpErrorBmp );
    2483           0 :     DELETEZ( mpReplaceBmp );
    2484           0 : }
    2485             : 
    2486           0 : SwPostItMgr* SwViewShell::GetPostItMgr()
    2487             : {
    2488           0 :     SwView* pView =  GetDoc()->GetDocShell() ? GetDoc()->GetDocShell()->GetView() : 0;
    2489           0 :     if ( pView )
    2490           0 :         return pView->GetPostItMgr();
    2491             : 
    2492           0 :     return 0;
    2493             : }
    2494             : 
    2495             : /*
    2496             :  * Document Interface Access
    2497             :  */
    2498           0 : const IDocumentSettingAccess* SwViewShell::getIDocumentSettingAccess() const { return mpDoc; }
    2499           0 : IDocumentSettingAccess* SwViewShell::getIDocumentSettingAccess() { return mpDoc; }
    2500           0 : const IDocumentDeviceAccess* SwViewShell::getIDocumentDeviceAccess() const { return mpDoc; }
    2501           0 : IDocumentDeviceAccess* SwViewShell::getIDocumentDeviceAccess() { return mpDoc; }
    2502           0 : const IDocumentMarkAccess* SwViewShell::getIDocumentMarkAccess() const { return mpDoc->getIDocumentMarkAccess(); }
    2503           0 : IDocumentMarkAccess* SwViewShell::getIDocumentMarkAccess() { return mpDoc->getIDocumentMarkAccess(); }
    2504           0 : const IDocumentDrawModelAccess* SwViewShell::getIDocumentDrawModelAccess() const { return mpDoc; }
    2505           0 : IDocumentDrawModelAccess* SwViewShell::getIDocumentDrawModelAccess() { return mpDoc; }
    2506           0 : const IDocumentRedlineAccess* SwViewShell::getIDocumentRedlineAccess() const { return mpDoc; }
    2507           0 : IDocumentRedlineAccess* SwViewShell::getIDocumentRedlineAccess() { return mpDoc; }
    2508           0 : const IDocumentLayoutAccess* SwViewShell::getIDocumentLayoutAccess() const { return mpDoc; }
    2509           0 : IDocumentLayoutAccess* SwViewShell::getIDocumentLayoutAccess() { return mpDoc; }
    2510           0 : IDocumentContentOperations* SwViewShell::getIDocumentContentOperations() { return mpDoc; }
    2511           0 : IDocumentStylePoolAccess* SwViewShell::getIDocumentStylePoolAccess() { return mpDoc; }
    2512           0 : 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           0 : }
    2529             : 
    2530             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10