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

Generated by: LCOV version 1.10