LCOV - code coverage report
Current view: top level - sw/source/core/view - vnew.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 123 147 83.7 %
Date: 2014-04-11 Functions: 8 9 88.9 %
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 <sfx2/printer.hxx>
      21             : #include <doc.hxx>
      22             : #include <IDocumentUndoRedo.hxx>
      23             : #include <docsh.hxx>
      24             : #include <viewsh.hxx>
      25             : #include <rootfrm.hxx>
      26             : #include <viewimp.hxx>
      27             : #include <viewopt.hxx>
      28             : #include <txtfrm.hxx>
      29             : #include <notxtfrm.hxx>
      30             : #include <fntcache.hxx>
      31             : #include <docufld.hxx>
      32             : #include <ptqueue.hxx>
      33             : #include <dview.hxx>
      34             : #include <ndgrf.hxx>
      35             : #include <ndindex.hxx>
      36             : #include <accessibilityoptions.hxx>
      37             : #include <switerator.hxx>
      38             : 
      39        1752 : void SwViewShell::Init( const SwViewOption *pNewOpt )
      40             : {
      41        1752 :     mbDocSizeChgd = sal_False;
      42             : 
      43             :     // We play it save: Remove old font information whenever the printer
      44             :     // resolution or the zoom factor changes. For that, Init() and Reformat()
      45             :     // are the most secure places.
      46        1752 :      pFntCache->Flush( );
      47             : 
      48             :     // ViewOptions are created dynamically
      49             : 
      50        1752 :     if( !mpOpt )
      51             :     {
      52        1752 :         mpOpt = new SwViewOption;
      53             : 
      54             :         // ApplyViewOptions() does not need to be called
      55        1752 :         if( pNewOpt )
      56             :         {
      57        1752 :             *mpOpt = *pNewOpt;
      58             :             // Zoom factor needs to be set because there is no call to ApplyViewOptions() during
      59             :             // CTOR for performance reasons.
      60        1752 :             if( GetWin() && 100 != mpOpt->GetZoom() )
      61             :             {
      62           0 :                 MapMode aMode( mpWin->GetMapMode() );
      63           0 :                 const Fraction aNewFactor( mpOpt->GetZoom(), 100 );
      64           0 :                 aMode.SetScaleX( aNewFactor );
      65           0 :                 aMode.SetScaleY( aNewFactor );
      66           0 :                 mpWin->SetMapMode( aMode );
      67             :             }
      68             :         }
      69             :     }
      70             : 
      71        1752 :     SwDocShell* pDShell = mpDoc->GetDocShell();
      72        1752 :     mpDoc->set(IDocumentSettingAccess::HTML_MODE, 0 != ::GetHtmlMode( pDShell ) );
      73             :     // JP 02.02.99: Bug 61335 - set readonly flag at ViewOptions before creating layout. Otherwise,
      74             :     //                          one would have to reformat again.
      75             : 
      76        1752 :     if( pDShell && pDShell->IsReadOnly() )
      77           1 :         mpOpt->SetReadonly( sal_True );
      78             : 
      79             :     SAL_INFO( "sw.core", "View::Init - before InitPrt" );
      80             :     // --> FME 2007-11-06 #i82967#
      81        1752 :     OutputDevice* pPDFOut = 0;
      82             : 
      83        1752 :     if ( mpOut && mpOut->GetPDFWriter() )
      84           0 :         pPDFOut = mpOut;
      85             :     // <--
      86             : 
      87             :     // --> FME 2005-01-21 #i41075#
      88             :     // Only setup the printer if we need one:
      89        1752 :     const bool bBrowseMode = mpOpt->getBrowseMode();
      90        1752 :     if( pPDFOut )
      91           0 :         InitPrt( pPDFOut );
      92             :     // <--
      93             : 
      94             :     // --> FME 2005-03-16 #i44963# Good occasion to check if page sizes in
      95             :     // page descriptions are still set to (LONG_MAX, LONG_MAX) (html import)
      96        1752 :     if ( !bBrowseMode )
      97             :     {
      98        1749 :         mpDoc->CheckDefaultPageFmt();
      99             :     }
     100             :     // <--
     101             : 
     102             :     SAL_INFO( "sw.core", "View::Init - after InitPrt" );
     103        1752 :     if( GetWin() )
     104             :     {
     105        1732 :         mpOpt->Init( GetWin() );
     106        1732 :         GetWin()->SetFillColor();
     107        1732 :         GetWin()->SetBackground();
     108        1732 :         GetWin()->SetLineColor();
     109             :     }
     110             : 
     111             :     // Create a new layout, if there is no one available
     112        1752 :     if( !mpLayout )
     113             :     {
     114             :         // Here's the code which disables the usage of "multiple" layouts at the moment
     115             :         // If the problems with controls and groups objects are solved,
     116             :         // this code can be removed...
     117        1732 :         SwViewShell *pCurrShell = GetDoc()->GetCurrentViewShell();
     118        1732 :         if( pCurrShell )
     119           0 :             mpLayout = pCurrShell->mpLayout;
     120             :         // end of "disable multiple layouts"
     121        1732 :         if( !mpLayout )
     122             :         {
     123             :             // switched to two step construction because creating the layout in SwRootFrm needs a valid pLayout set
     124        1732 :             mpLayout = SwRootFrmPtr(new SwRootFrm( mpDoc->GetDfltFrmFmt(), this ));
     125        1732 :             mpLayout->Init( mpDoc->GetDfltFrmFmt() );
     126             :         }
     127             :     }
     128        1752 :     SizeChgNotify();
     129             : 
     130             :     // --> #i31958#
     131             :     // XForms mode: initialize XForms mode, based on design mode (draw view)
     132             :     //   MakeDrawView() requires layout
     133        1752 :     if( GetDoc()->isXForms() )
     134             :     {
     135           0 :         if( ! HasDrawView() )
     136           0 :             MakeDrawView();
     137           0 :         mpOpt->SetFormView( ! GetDrawView()->IsDesignMode() );
     138             :     }
     139             :     // <-- #i31958#
     140        1752 : }
     141             : 
     142             : /// CTor for the first Shell.
     143        1732 : SwViewShell::SwViewShell( SwDoc& rDocument, Window *pWindow,
     144             :                         const SwViewOption *pNewOpt, OutputDevice *pOutput,
     145             :                         long nFlags )
     146             :     :
     147             :     maBrowseBorder(),
     148             :     mpSfxViewShell( 0 ),
     149        1732 :     mpImp( new SwViewImp( this ) ),
     150             :     mpWin( pWindow ),
     151             :     mpOut( pOutput ? pOutput
     152             :                   : pWindow ? (OutputDevice*)pWindow
     153           0 :                             : (OutputDevice*)rDocument.getPrinter( true )),
     154             :     mpTmpRef( 0 ),
     155             :     mpOpt( 0 ),
     156        1732 :     mpAccOptions( new SwAccessibilityOptions ),
     157             :     mbShowHeaderSeparator( false ),
     158             :     mbShowFooterSeparator( false ),
     159             :     mbHeaderFooterEdit( false ),
     160             :     mbTiledRendering(false),
     161             :     mpTargetPaintWindow(0), // #i74769#
     162             :     mpBufferedOut(0), // #i74769#
     163             :     mpDoc( &rDocument ),
     164             :     mnStartAction( 0 ),
     165             :     mnLockPaint( 0 ),
     166             :     mbSelectAll(false),
     167             :     mpPrePostOutDev(0), // #i72754#
     168        5196 :     maPrePostMapMode()
     169             : {
     170             :     // OD 2004-06-01 #i26791# - in order to suppress event handling in
     171             :     // <SwDrawContact::Changed> during contruction of <SwViewShell> instance
     172        1732 :     mbInConstructor = true;
     173             : 
     174             :     mbPaintInProgress = mbViewLocked = mbInEndAction = mbFrameView =
     175        1732 :     mbEndActionByVirDev = sal_False;
     176        1732 :     mbPaintWorks = mbEnableSmooth = sal_True;
     177        1732 :     mbPreview = 0 !=( VSHELLFLAG_ISPREVIEW & nFlags );
     178             : 
     179             :     // --> OD 2005-02-11 #i38810# - Do not reset modified state of document,
     180             :     // if it's already been modified.
     181        1732 :     const bool bIsDocModified( mpDoc->IsModified() );
     182        1732 :     mpDoc->acquire();
     183        1732 :     pOutput = mpOut;
     184        1732 :     Init( pNewOpt );    // may change the Outdev (InitPrt())
     185        1732 :     mpOut = pOutput;
     186             : 
     187             :     // OD 28.03.2003 #108470# - initialize print preview layout after layout
     188             :     // is created in <SwViewShell::Init(..)> - called above.
     189        1732 :     if ( mbPreview )
     190             :     {
     191             :         // OD 12.12.2002 #103492# - init page preview layout
     192           0 :         mpImp->InitPagePreviewLayout();
     193             :     }
     194             : 
     195        1732 :     SET_CURR_SHELL( this );
     196             : 
     197        1732 :     ((SwHiddenTxtFieldType*)mpDoc->GetSysFldType( RES_HIDDENTXTFLD ))->
     198        3464 :         SetHiddenFlag( !mpOpt->IsShowHiddenField() );
     199             : 
     200             :     // In Init a standard FrmFmt is created.
     201             :     // --> OD 2005-02-11 #i38810#
     202        3464 :     if (   !mpDoc->GetIDocumentUndoRedo().IsUndoNoResetModified()
     203        1732 :         && !bIsDocModified )
     204             :     // <--
     205             :     {
     206        1731 :         mpDoc->ResetModified();
     207             :     }
     208             : 
     209             :     // extend format cache.
     210        1732 :     if ( SwTxtFrm::GetTxtCache()->GetCurMax() < 2550 )
     211        1732 :         SwTxtFrm::GetTxtCache()->IncreaseMax( 100 );
     212        1732 :     if( mpOpt->IsGridVisible() || getIDocumentDrawModelAccess()->GetDrawModel() )
     213        1317 :         Imp()->MakeDrawView();
     214             : 
     215             :     // OD 2004-06-01 #i26791#
     216        1732 :     mbInConstructor = false;
     217        1732 : }
     218             : 
     219             : /// CTor for further Shells on a document.
     220          20 : SwViewShell::SwViewShell( SwViewShell& rShell, Window *pWindow,
     221             :                         OutputDevice *pOutput, long nFlags ) :
     222             :     Ring( &rShell ),
     223             :     maBrowseBorder( rShell.maBrowseBorder ),
     224             :     mpSfxViewShell( 0 ),
     225          20 :     mpImp( new SwViewImp( this ) ),
     226             :     mpWin( pWindow ),
     227             :     mpOut( pOutput ? pOutput
     228             :                   : pWindow ? (OutputDevice*)pWindow
     229           0 :                             : (OutputDevice*)rShell.GetDoc()->getPrinter( true )),
     230             :     mpTmpRef( 0 ),
     231             :     mpOpt( 0 ),
     232          20 :     mpAccOptions( new SwAccessibilityOptions ),
     233             :     mbShowHeaderSeparator( false ),
     234             :     mbShowFooterSeparator( false ),
     235             :     mbHeaderFooterEdit( false ),
     236             :     mbTiledRendering(false),
     237             :     mpTargetPaintWindow(0), // #i74769#
     238             :     mpBufferedOut(0), // #i74769#
     239          20 :     mpDoc( rShell.GetDoc() ),
     240             :     mnStartAction( 0 ),
     241             :     mnLockPaint( 0 ),
     242             :     mbSelectAll(false),
     243             :     mpPrePostOutDev(0), // #i72754#
     244          80 :     maPrePostMapMode()
     245             : {
     246             :     // OD 2004-06-01 #i26791# - in order to suppress event handling in
     247             :     // <SwDrawContact::Changed> during contruction of <SwViewShell> instance
     248          20 :     mbInConstructor = true;
     249             : 
     250          20 :     mbPaintWorks = mbEnableSmooth = sal_True;
     251             :     mbPaintInProgress = mbViewLocked = mbInEndAction = mbFrameView =
     252          20 :     mbEndActionByVirDev = sal_False;
     253          20 :     mbPreview = 0 !=( VSHELLFLAG_ISPREVIEW & nFlags );
     254             :     // OD 12.12.2002 #103492#
     255          20 :     if( nFlags & VSHELLFLAG_SHARELAYOUT )
     256          20 :         mpLayout = rShell.mpLayout;
     257             : 
     258          20 :     SET_CURR_SHELL( this );
     259             : 
     260          20 :     mpDoc->acquire();
     261          20 :     sal_Bool bModified = mpDoc->IsModified();
     262             : 
     263          20 :     pOutput = mpOut;
     264          20 :     Init( rShell.GetViewOptions() ); // might change Outdev (InitPrt())
     265          20 :     mpOut = pOutput;
     266             : 
     267             :     // OD 12.12.2002 #103492#
     268          20 :     if ( mbPreview )
     269           0 :         mpImp->InitPagePreviewLayout();
     270             : 
     271          20 :     ((SwHiddenTxtFieldType*)mpDoc->GetSysFldType( RES_HIDDENTXTFLD ))->
     272          40 :             SetHiddenFlag( !mpOpt->IsShowHiddenField() );
     273             : 
     274             :     // In Init a standard FrmFmt is created.
     275          20 :     if( !bModified && !mpDoc->GetIDocumentUndoRedo().IsUndoNoResetModified() )
     276             :     {
     277          17 :         mpDoc->ResetModified();
     278             :     }
     279             : 
     280             :     // extend format cache.
     281          20 :     if ( SwTxtFrm::GetTxtCache()->GetCurMax() < 2550 )
     282          20 :         SwTxtFrm::GetTxtCache()->IncreaseMax( 100 );
     283          20 :     if( mpOpt->IsGridVisible() || getIDocumentDrawModelAccess()->GetDrawModel() )
     284          20 :         Imp()->MakeDrawView();
     285             : 
     286             :     // OD 2004-06-01 #i26791#
     287          20 :     mbInConstructor = false;
     288             : 
     289          20 : }
     290             : 
     291        3522 : SwViewShell::~SwViewShell()
     292             : {
     293             :     {
     294        1751 :         SET_CURR_SHELL( this );
     295        1751 :         mbPaintWorks = sal_False;
     296             : 
     297             :         // FME 2004-06-21 #i9684# Stopping the animated graphics is not
     298             :         // necessary during printing or pdf export, because the animation
     299             :         // has not been started in this case.
     300        1751 :         if( mpDoc && GetWin() )
     301             :         {
     302        1731 :             SwNodes& rNds = mpDoc->GetNodes();
     303             :             SwGrfNode *pGNd;
     304             : 
     305             :             SwStartNode *pStNd;
     306        1731 :             SwNodeIndex aIdx( *rNds.GetEndOfAutotext().StartOfSectionNode(), 1 );
     307        5683 :             while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
     308             :             {
     309        2221 :                 ++aIdx;
     310        2221 :                 if ( 0 != ( pGNd = aIdx.GetNode().GetGrfNode() ) )
     311             :                 {
     312         320 :                     if( pGNd->IsAnimated() )
     313             :                     {
     314           0 :                         SwIterator<SwFrm,SwGrfNode> aIter( *pGNd );
     315           0 :                         for( SwFrm* pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
     316             :                         {
     317             :                             OSL_ENSURE( pFrm->IsNoTxtFrm(), "GraphicNode with Text?" );
     318           0 :                             ((SwNoTxtFrm*)pFrm)->StopAnimation( mpOut );
     319           0 :                         }
     320             :                     }
     321             :                 }
     322        2221 :                 aIdx.Assign( *pStNd->EndOfSectionNode(), +1 );
     323             :             }
     324             : 
     325        1731 :             GetDoc()->StopNumRuleAnimations( mpOut );
     326             :         }
     327             : 
     328        1751 :         delete mpImp; // Delete first, so that the LayoutViews are destroyed.
     329        1751 :         mpImp = 0;   // Set to zero, because ~SwFrm relies on it.
     330             : 
     331        1751 :         if ( mpDoc )
     332             :         {
     333        1751 :             if( !mpDoc->release() )
     334           0 :                 delete mpDoc, mpDoc = 0;
     335             :             else
     336        1751 :                 GetLayout()->ResetNewLayout();
     337             :         }
     338             : 
     339        1751 :         delete mpOpt;
     340             : 
     341             :         // resize format cache.
     342        1751 :         if ( SwTxtFrm::GetTxtCache()->GetCurMax() > 250 )
     343        1751 :             SwTxtFrm::GetTxtCache()->DecreaseMax( 100 );
     344             : 
     345             :         // Remove from PaintQueue if necessary
     346        1751 :         SwPaintQueue::Remove( this );
     347             : 
     348        1751 :         OSL_ENSURE( !mnStartAction, "EndAction() pending." );
     349             :     }
     350             : 
     351        1751 :     if ( mpDoc )
     352             :     {
     353        1751 :         GetLayout()->DeRegisterShell( this );
     354        1751 :         if(mpDoc->GetCurrentViewShell()==this)
     355        1731 :             mpDoc->SetCurrentViewShell( this->GetNext()!=this ?
     356        3462 :             (SwViewShell*)this->GetNext() : NULL );
     357             :     }
     358             : 
     359        1751 :     delete mpTmpRef;
     360        1751 :     delete mpAccOptions;
     361        1771 : }
     362             : 
     363       33951 : sal_Bool SwViewShell::HasDrawView() const
     364             : {
     365       33951 :     return (Imp() && Imp()->HasDrawView()) ? 1 : 0;
     366             : }
     367             : 
     368         830 : void SwViewShell::MakeDrawView()
     369             : {
     370         830 :     Imp()->MakeDrawView( );
     371         830 : }
     372             : 
     373      130780 : SdrView* SwViewShell::GetDrawView()
     374             : {
     375      130780 :     return Imp()->GetDrawView();
     376             : }
     377             : 
     378           0 : SdrView* SwViewShell::GetDrawViewWithValidMarkList()
     379             : {
     380           0 :     SwDrawView* pDView = Imp()->GetDrawView();
     381           0 :     pDView->ValidateMarkList();
     382           0 :     return pDView;
     383             : }
     384             : 
     385             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10