LCOV - code coverage report
Current view: top level - sw/source/core/view - viewimp.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 212 0.0 %
Date: 2014-04-14 Functions: 0 26 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 "crsrsh.hxx"
      21             : #include "rootfrm.hxx"
      22             : #include "pagefrm.hxx"
      23             : #include "viewimp.hxx"
      24             : #include "viewopt.hxx"
      25             : #include "flyfrm.hxx"
      26             : #include "frmfmt.hxx"
      27             : #include "layact.hxx"
      28             : #include "swregion.hxx"
      29             : #include "dflyobj.hxx"
      30             : #include "dview.hxx"
      31             : #include <tools/shl.hxx>
      32             : #include <swmodule.hxx>
      33             : #include <svx/svdpage.hxx>
      34             : #include <accmap.hxx>
      35             : 
      36             : // OD 12.12.2002 #103492#
      37             : #include <pagepreviewlayout.hxx>
      38             : 
      39             : #include <comcore.hrc>
      40             : #include <svx/svdundo.hxx>
      41             : #include <IDocumentLayoutAccess.hxx>
      42             : #include <IDocumentDrawModelAccess.hxx>
      43             : #include <IDocumentDeviceAccess.hxx>
      44             : #include <IDocumentSettingAccess.hxx>
      45             : 
      46           0 : void SwViewImp::Init( const SwViewOption *pNewOpt )
      47             : {
      48             :     OSL_ENSURE( pDrawView, "SwViewImp::Init without DrawView" );
      49             :     //Create PageView if it doesn't exist
      50           0 :     SwRootFrm *pRoot = pSh->GetLayout();
      51           0 :     if ( !pSdrPageView )
      52             :     {
      53           0 :         IDocumentDrawModelAccess* pIDDMA = pSh->getIDocumentDrawModelAccess();
      54           0 :         if ( !pRoot->GetDrawPage() )
      55           0 :             pRoot->SetDrawPage( pIDDMA->GetDrawModel()->GetPage( 0 ) );
      56             : 
      57           0 :         if ( pRoot->GetDrawPage()->GetSize() != pRoot->Frm().SSize() )
      58           0 :             pRoot->GetDrawPage()->SetSize( pRoot->Frm().SSize() );
      59             : 
      60           0 :         pSdrPageView = pDrawView->ShowSdrPage( pRoot->GetDrawPage());
      61             :         // OD 26.06.2003 #108784# - notify drawing page view about invisible
      62             :         // layers.
      63           0 :         pIDDMA->NotifyInvisibleLayers( *pSdrPageView );
      64             :     }
      65           0 :     pDrawView->SetDragStripes( pNewOpt->IsCrossHair() );
      66           0 :     pDrawView->SetGridSnap( pNewOpt->IsSnap() );
      67           0 :     pDrawView->SetGridVisible( pNewOpt->IsGridVisible() );
      68           0 :     const Size &rSz = pNewOpt->GetSnapSize();
      69           0 :     pDrawView->SetGridCoarse( rSz );
      70             :     const Size aFSize
      71           0 :             ( rSz.Width() ? rSz.Width() /std::max(short(1),pNewOpt->GetDivisionX()):0,
      72           0 :               rSz.Height()? rSz.Height()/std::max(short(1),pNewOpt->GetDivisionY()):0);
      73           0 :      pDrawView->SetGridFine( aFSize );
      74           0 :     Fraction aSnGrWdtX(rSz.Width(), pNewOpt->GetDivisionX() + 1);
      75           0 :     Fraction aSnGrWdtY(rSz.Height(), pNewOpt->GetDivisionY() + 1);
      76           0 :     pDrawView->SetSnapGridWidth( aSnGrWdtX, aSnGrWdtY );
      77             : 
      78           0 :     if ( pRoot->Frm().HasArea() )
      79           0 :         pDrawView->SetWorkArea( pRoot->Frm().SVRect() );
      80             : 
      81           0 :     if ( GetShell()->IsPreview() )
      82           0 :         pDrawView->SetAnimationEnabled( false );
      83             : 
      84           0 :     pDrawView->SetUseIncompatiblePathCreateInterface( false );
      85             : 
      86             :     // set handle size to 9 pixels, always
      87           0 :     pDrawView->SetMarkHdlSizePixel(9);
      88           0 : }
      89             : 
      90             : /// CTor for the core internals
      91           0 : SwViewImp::SwViewImp( SwViewShell *pParent ) :
      92             :     pSh( pParent ),
      93             :     pDrawView( 0 ),
      94             :     pSdrPageView( 0 ),
      95             :     pFirstVisPage( 0 ),
      96             :     pRegion( 0 ),
      97             :     pLayAct( 0 ),
      98             :     pIdleAct( 0 ),
      99             :     pAccMap( 0 ),
     100             :     pSdrObjCached(NULL),
     101             :     bFirstPageInvalid( true ),
     102             :     bResetHdlHiddenPaint( false ),
     103             :     bSmoothUpdate( false ),
     104             :     bStopSmooth( false ),
     105             :     nRestoreActions( 0 ),
     106             :     // OD 12.12.2002 #103492#
     107           0 :     mpPgPreviewLayout( 0 )
     108             : {
     109           0 : }
     110             : 
     111           0 : SwViewImp::~SwViewImp()
     112             : {
     113           0 :     delete pAccMap;
     114             : 
     115             :     // OD 12.12.2002 #103492#
     116           0 :     delete mpPgPreviewLayout;
     117             : 
     118             :     //JP 29.03.96: after ShowSdrPage  HideSdrPage must also be executed!!!
     119           0 :     if( pDrawView )
     120           0 :          pDrawView->HideSdrPage();
     121             : 
     122           0 :     delete pDrawView;
     123             : 
     124           0 :     DelRegion();
     125             : 
     126             :     OSL_ENSURE( !pLayAct, "Have action for the rest of your life." );
     127             :     OSL_ENSURE( !pIdleAct,"Be idle for the rest of your life." );
     128           0 : }
     129             : 
     130           0 : void SwViewImp::DelRegion()
     131             : {
     132           0 :     DELETEZ(pRegion);
     133           0 : }
     134             : 
     135           0 : bool SwViewImp::AddPaintRect( const SwRect &rRect )
     136             : {
     137           0 :     if ( rRect.IsOver( pSh->VisArea() ) )
     138             :     {
     139           0 :         if ( !pRegion )
     140           0 :             pRegion = new SwRegionRects( pSh->VisArea() );
     141           0 :         (*pRegion) -= rRect;
     142           0 :         return true;
     143             :     }
     144           0 :     return false;
     145             : }
     146             : 
     147           0 : void SwViewImp::CheckWaitCrsr()
     148             : {
     149           0 :     if ( pLayAct )
     150           0 :         pLayAct->CheckWaitCrsr();
     151           0 : }
     152             : 
     153           0 : bool SwViewImp::IsCalcLayoutProgress() const
     154             : {
     155           0 :     return pLayAct && pLayAct->IsCalcLayout();
     156             : }
     157             : 
     158           0 : bool SwViewImp::IsUpdateExpFlds()
     159             : {
     160           0 :     if ( pLayAct && pLayAct->IsCalcLayout() )
     161             :     {
     162           0 :         pLayAct->SetUpdateExpFlds();
     163           0 :         return true;
     164             :     }
     165           0 :     return false;
     166             : }
     167             : 
     168           0 : void SwViewImp::SetFirstVisPage()
     169             : {
     170           0 :     if ( pSh->mbDocSizeChgd && pSh->VisArea().Top() > pSh->GetLayout()->Frm().Height() )
     171             :     {
     172             :         //We are in an action and because of erase actions the VisArea is
     173             :         //after the first visible page.
     174             :         //To avoid excessive formatting, hand back the last page.
     175           0 :         pFirstVisPage = (SwPageFrm*)pSh->GetLayout()->Lower();
     176           0 :         while ( pFirstVisPage && pFirstVisPage->GetNext() )
     177           0 :             pFirstVisPage = (SwPageFrm*)pFirstVisPage->GetNext();
     178             :     }
     179             :     else
     180             :     {
     181           0 :         const SwViewOption* pSwViewOption = GetShell()->GetViewOptions();
     182           0 :         const bool bBookMode = pSwViewOption->IsViewLayoutBookMode();
     183             : 
     184           0 :         SwPageFrm *pPage = (SwPageFrm*)pSh->GetLayout()->Lower();
     185           0 :         SwRect aPageRect = pPage->GetBoundRect();
     186           0 :         while ( pPage && !aPageRect.IsOver( pSh->VisArea() ) )
     187             :         {
     188           0 :             pPage = (SwPageFrm*)pPage->GetNext();
     189           0 :             if ( pPage )
     190             :             {
     191           0 :                 aPageRect = pPage->GetBoundRect();
     192           0 :                 if ( bBookMode && pPage->IsEmptyPage() )
     193             :                 {
     194           0 :                     const SwPageFrm& rFormatPage = pPage->GetFormatPage();
     195           0 :                     aPageRect.SSize() = rFormatPage.GetBoundRect().SSize();
     196             :                 }
     197             :             }
     198             :         }
     199           0 :         pFirstVisPage = pPage ? pPage : (SwPageFrm*)pSh->GetLayout()->Lower();
     200             :     }
     201           0 :     bFirstPageInvalid = false;
     202           0 : }
     203             : 
     204           0 : void SwViewImp::MakeDrawView()
     205             : {
     206           0 :     IDocumentDrawModelAccess* pIDDMA = GetShell()->getIDocumentDrawModelAccess();
     207             : 
     208             :     // the else here is not an error, _MakeDrawModel() calls this method again
     209             :     // after the DrawModel is created to create DrawViews for all shells...
     210           0 :     if( !pIDDMA->GetDrawModel() )
     211             :     {
     212           0 :         pIDDMA->_MakeDrawModel();
     213             :     }
     214             :     else
     215             :     {
     216           0 :         if ( !pDrawView )
     217             :         {
     218             :             // #i72809#
     219             :             // Discussed with FME, he also thinks that the getPrinter is old and not correct. When i got
     220             :             // him right, it anyways returns GetOut() when it's a printer, but NULL when not. He suggested
     221             :             // to use GetOut() and check the existing cases.
     222             :             // Check worked well. Took a look at viewing, printing, PDF export and print preview with a test
     223             :             // document which has an empty 2nd page (right page, see bug)
     224           0 :             OutputDevice* pOutDevForDrawView = GetShell()->GetWin();
     225             : 
     226           0 :             if(!pOutDevForDrawView)
     227             :             {
     228           0 :                 pOutDevForDrawView = GetShell()->GetOut();
     229             :             }
     230             : 
     231           0 :             pDrawView = new SwDrawView( *this, pIDDMA->GetDrawModel(), pOutDevForDrawView);
     232             :         }
     233             : 
     234           0 :         GetDrawView()->SetActiveLayer(OUString("Heaven"));
     235           0 :         const SwViewOption* pSwViewOption = GetShell()->GetViewOptions();
     236           0 :         Init(pSwViewOption);
     237             : 
     238             :         // #i68597# If document is read-only, we will not profit from overlay,
     239             :         // so switch it off.
     240           0 :         if (pDrawView->IsBufferedOverlayAllowed())
     241             :         {
     242           0 :             if(pSwViewOption->IsReadonly())
     243             :             {
     244           0 :                 pDrawView->SetBufferedOverlayAllowed(false);
     245             :             }
     246             :         }
     247             :     }
     248           0 : }
     249             : 
     250           0 : Color SwViewImp::GetRetoucheColor() const
     251             : {
     252           0 :     Color aRet( COL_TRANSPARENT );
     253           0 :     const SwViewShell &rSh = *GetShell();
     254           0 :     if ( rSh.GetWin() )
     255             :     {
     256           0 :         if ( rSh.GetViewOptions()->getBrowseMode() &&
     257           0 :              COL_TRANSPARENT != rSh.GetViewOptions()->GetRetoucheColor().GetColor() )
     258           0 :             aRet = rSh.GetViewOptions()->GetRetoucheColor();
     259           0 :         else if(rSh.GetViewOptions()->IsPagePreview()  &&
     260           0 :                     !SW_MOD()->GetAccessibilityOptions().GetIsForPagePreviews())
     261           0 :             aRet.SetColor(COL_WHITE);
     262             :         else
     263           0 :             aRet = SwViewOption::GetDocColor();
     264             :     }
     265           0 :     return aRet;
     266             : }
     267             : 
     268             : // create page preview layout
     269           0 : void SwViewImp::InitPagePreviewLayout()
     270             : {
     271             :     OSL_ENSURE( pSh->GetLayout(), "no layout - page preview layout can not be created.");
     272           0 :     if ( pSh->GetLayout() )
     273           0 :         mpPgPreviewLayout = new SwPagePreviewLayout( *pSh, *(pSh->GetLayout()) );
     274           0 : }
     275             : 
     276           0 : void SwViewImp::UpdateAccessible()
     277             : {
     278             :     // We require a layout and an XModel to be accessible.
     279           0 :     IDocumentLayoutAccess* pIDLA = GetShell()->getIDocumentLayoutAccess();
     280           0 :     Window *pWin = GetShell()->GetWin();
     281             :     OSL_ENSURE( GetShell()->GetLayout(), "no layout, no access" );
     282             :     OSL_ENSURE( pWin, "no window, no access" );
     283             : 
     284           0 :     if( IsAccessible() && pIDLA->GetCurrentViewShell() && pWin )
     285           0 :         GetAccessibleMap().GetDocumentView();
     286           0 : }
     287             : 
     288           0 : void SwViewImp::DisposeAccessible( const SwFrm *pFrm,
     289             :                                    const SdrObject *pObj,
     290             :                                    bool bRecursive )
     291             : {
     292             :     OSL_ENSURE( !pFrm || pFrm->IsAccessibleFrm(), "frame is not accessible" );
     293           0 :     SwViewShell *pVSh = GetShell();
     294           0 :     SwViewShell *pTmp = pVSh;
     295           0 :     do
     296             :     {
     297           0 :         if( pTmp->Imp()->IsAccessible() )
     298           0 :             pTmp->Imp()->GetAccessibleMap().Dispose( pFrm, pObj, 0, bRecursive );
     299           0 :         pTmp = (SwViewShell *)pTmp->GetNext();
     300             :     } while ( pTmp != pVSh );
     301           0 : }
     302             : 
     303           0 : void SwViewImp::MoveAccessible( const SwFrm *pFrm, const SdrObject *pObj,
     304             :                                 const SwRect& rOldFrm )
     305             : {
     306             :     OSL_ENSURE( !pFrm || pFrm->IsAccessibleFrm(), "frame is not accessible" );
     307           0 :     SwViewShell *pVSh = GetShell();
     308           0 :     SwViewShell *pTmp = pVSh;
     309           0 :     do
     310             :     {
     311           0 :         if( pTmp->Imp()->IsAccessible() )
     312           0 :             pTmp->Imp()->GetAccessibleMap().InvalidatePosOrSize( pFrm, pObj, 0,
     313           0 :                                                                  rOldFrm );
     314           0 :         pTmp = (SwViewShell *)pTmp->GetNext();
     315             :     } while ( pTmp != pVSh );
     316           0 : }
     317             : 
     318           0 : void SwViewImp::InvalidateAccessibleFrmContent( const SwFrm *pFrm )
     319             : {
     320             :     OSL_ENSURE( pFrm->IsAccessibleFrm(), "frame is not accessible" );
     321           0 :     SwViewShell *pVSh = GetShell();
     322           0 :     SwViewShell *pTmp = pVSh;
     323           0 :     do
     324             :     {
     325           0 :         if( pTmp->Imp()->IsAccessible() )
     326           0 :             pTmp->Imp()->GetAccessibleMap().InvalidateContent( pFrm );
     327           0 :         pTmp = (SwViewShell *)pTmp->GetNext();
     328             :     } while ( pTmp != pVSh );
     329           0 : }
     330             : 
     331           0 : void SwViewImp::InvalidateAccessibleCursorPosition( const SwFrm *pFrm )
     332             : {
     333           0 :     if( IsAccessible() )
     334           0 :         GetAccessibleMap().InvalidateCursorPosition( pFrm );
     335           0 : }
     336             : 
     337           0 : void SwViewImp::InvalidateAccessibleEditableState( bool bAllShells,
     338             :                                                       const SwFrm *pFrm )
     339             : {
     340           0 :     if( bAllShells )
     341             :     {
     342           0 :         SwViewShell *pVSh = GetShell();
     343           0 :         SwViewShell *pTmp = pVSh;
     344           0 :         do
     345             :         {
     346           0 :             if( pTmp->Imp()->IsAccessible() )
     347           0 :                 pTmp->Imp()->GetAccessibleMap().InvalidateStates( ACC_STATE_EDITABLE, pFrm );
     348           0 :             pTmp = (SwViewShell *)pTmp->GetNext();
     349             :         } while ( pTmp != pVSh );
     350             :     }
     351           0 :     else if( IsAccessible() )
     352             :     {
     353           0 :         GetAccessibleMap().InvalidateStates( ACC_STATE_EDITABLE, pFrm );
     354             :     }
     355           0 : }
     356             : 
     357           0 : void SwViewImp::InvalidateAccessibleRelationSet( const SwFlyFrm *pMaster,
     358             :                                                  const SwFlyFrm *pFollow )
     359             : {
     360           0 :     SwViewShell *pVSh = GetShell();
     361           0 :     SwViewShell *pTmp = pVSh;
     362           0 :     do
     363             :     {
     364           0 :         if( pTmp->Imp()->IsAccessible() )
     365           0 :             pTmp->Imp()->GetAccessibleMap().InvalidateRelationSet( pMaster,
     366           0 :                                                                    pFollow );
     367           0 :         pTmp = (SwViewShell *)pTmp->GetNext();
     368             :     } while ( pTmp != pVSh );
     369           0 : }
     370             : 
     371             : /// invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
     372           0 : void SwViewImp::_InvalidateAccessibleParaFlowRelation( const SwTxtFrm* _pFromTxtFrm,
     373             :                                                        const SwTxtFrm* _pToTxtFrm )
     374             : {
     375           0 :     if ( !_pFromTxtFrm && !_pToTxtFrm )
     376             :     {
     377             :         // No text frame provided. Thus, nothing to do.
     378           0 :         return;
     379             :     }
     380             : 
     381           0 :     SwViewShell* pVSh = GetShell();
     382           0 :     SwViewShell* pTmp = pVSh;
     383           0 :     do
     384             :     {
     385           0 :         if ( pTmp->Imp()->IsAccessible() )
     386             :         {
     387           0 :             if ( _pFromTxtFrm )
     388             :             {
     389           0 :                 pTmp->Imp()->GetAccessibleMap().
     390           0 :                             InvalidateParaFlowRelation( *_pFromTxtFrm, true );
     391             :             }
     392           0 :             if ( _pToTxtFrm )
     393             :             {
     394           0 :                 pTmp->Imp()->GetAccessibleMap().
     395           0 :                             InvalidateParaFlowRelation( *_pToTxtFrm, false );
     396             :             }
     397             :         }
     398           0 :         pTmp = (SwViewShell *)pTmp->GetNext();
     399             :     } while ( pTmp != pVSh );
     400             : }
     401             : 
     402             : /// invalidate text selection for paragraphs
     403           0 : void SwViewImp::_InvalidateAccessibleParaTextSelection()
     404             : {
     405           0 :     SwViewShell* pVSh = GetShell();
     406           0 :     SwViewShell* pTmp = pVSh;
     407           0 :     do
     408             :     {
     409           0 :         if ( pTmp->Imp()->IsAccessible() )
     410             :         {
     411           0 :             pTmp->Imp()->GetAccessibleMap().InvalidateTextSelectionOfAllParas();
     412             :         }
     413             : 
     414           0 :         pTmp = (SwViewShell *)pTmp->GetNext();
     415             :     } while ( pTmp != pVSh );
     416           0 : }
     417             : 
     418             : /// invalidate attributes for paragraphs
     419           0 : void SwViewImp::_InvalidateAccessibleParaAttrs( const SwTxtFrm& rTxtFrm )
     420             : {
     421           0 :     SwViewShell* pVSh = GetShell();
     422           0 :     SwViewShell* pTmp = pVSh;
     423           0 :     do
     424             :     {
     425           0 :         if ( pTmp->Imp()->IsAccessible() )
     426             :         {
     427           0 :             pTmp->Imp()->GetAccessibleMap().InvalidateAttr( rTxtFrm );
     428             :         }
     429             : 
     430           0 :         pTmp = (SwViewShell *)pTmp->GetNext();
     431             :     } while ( pTmp != pVSh );
     432           0 : }
     433             : 
     434             : // OD 15.01.2003 #103492# - method signature change due to new page preview functionality
     435           0 : void SwViewImp::UpdateAccessiblePreview( const std::vector<PreviewPage*>& _rPreviewPages,
     436             :                                          const Fraction&  _rScale,
     437             :                                          const SwPageFrm* _pSelectedPageFrm,
     438             :                                          const Size&      _rPreviewWinSize )
     439             : {
     440           0 :     if( IsAccessible() )
     441           0 :         GetAccessibleMap().UpdatePreview( _rPreviewPages, _rScale,
     442           0 :                                           _pSelectedPageFrm, _rPreviewWinSize );
     443           0 : }
     444             : 
     445           0 : void SwViewImp::InvalidateAccessiblePreviewSelection( sal_uInt16 nSelPage )
     446             : {
     447           0 :     if( IsAccessible() )
     448           0 :         GetAccessibleMap().InvalidatePreviewSelection( nSelPage );
     449           0 : }
     450             : 
     451           0 : SwAccessibleMap *SwViewImp::CreateAccessibleMap()
     452             : {
     453             :     OSL_ENSURE( !pAccMap, "accessible map exists" );
     454           0 :     pAccMap = new SwAccessibleMap( GetShell() );
     455           0 :     return pAccMap;
     456             : }
     457             : 
     458           0 : void SwViewImp::FireAccessibleEvents()
     459             : {
     460           0 :     if( IsAccessible() )
     461           0 :         GetAccessibleMap().FireEvents();
     462           0 : }
     463             : 
     464             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10