Files
libreoffice/sw/source/core/view/vnew.cxx

345 lines
10 KiB
C++
Raw Normal View History

2000-09-18 23:08:29 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 23:08:29 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 23:08:29 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 23:08:29 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 23:08:29 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 23:08:29 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 23:08:29 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 23:08:29 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
2000-09-18 23:08:29 +00:00
#include <sfx2/printer.hxx>
2001-07-23 16:20:51 +00:00
#include <rtl/logfile.hxx>
2000-09-18 23:08:29 +00:00
#include <doc.hxx>
#include <docsh.hxx>
#include <viewsh.hxx>
#include <rootfrm.hxx>
#include <viewimp.hxx>
#include <viewopt.hxx>
2010-10-01 21:57:36 +02:00
#include <txtfrm.hxx>
2000-09-18 23:08:29 +00:00
#include <notxtfrm.hxx>
#include <fntcache.hxx>
#include <docufld.hxx>
#include <ptqueue.hxx>
2010-10-01 21:57:36 +02:00
#include <dview.hxx>
2000-09-18 23:08:29 +00:00
#include <ndgrf.hxx>
#include <ndindex.hxx>
#include <accessibilityoptions.hxx>
2000-09-18 23:08:29 +00:00
void ViewShell::Init( const SwViewOption *pNewOpt )
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "ViewShell::Init" );
2001-07-23 16:20:51 +00:00
2000-09-18 23:08:29 +00:00
bDocSizeChgd = FALSE;
pFntCache->Flush( );
if( !pOpt )
{
pOpt = new SwViewOption;
if( pNewOpt )
{
*pOpt = *pNewOpt;
if( GetWin() && 100 != pOpt->GetZoom() )
{
MapMode aMode( pWin->GetMapMode() );
const Fraction aNewFactor( pOpt->GetZoom(), 100 );
aMode.SetScaleX( aNewFactor );
aMode.SetScaleY( aNewFactor );
pWin->SetMapMode( aMode );
}
}
}
SwDocShell* pDShell = pDoc->GetDocShell();
pDoc->set(IDocumentSettingAccess::HTML_MODE, 0 != ::GetHtmlMode( pDShell ) );
2000-09-18 23:08:29 +00:00
if( pDShell && pDShell->IsReadOnly() )
pOpt->SetReadonly( TRUE );
2001-07-23 16:20:51 +00:00
RTL_LOGFILE_CONTEXT_TRACE( aLog, "View::Init - before InitPrt" );
2010-10-01 21:57:36 +02:00
// #i82967#
OutputDevice* pPDFOut = 0;
2010-10-01 21:57:36 +02:00
if ( pOut && pOut->GetPDFWriter() )
pPDFOut = pOut;
2010-10-01 21:57:36 +02:00
// #i41075# Only setup the printer if we need one:
const IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
const bool bBrowseMode = pIDSA->get(IDocumentSettingAccess::BROWSE_MODE);
2009-06-04 08:23:53 +00:00
if( pPDFOut )
InitPrt( pPDFOut );
2010-10-01 21:57:36 +02:00
// #i44963# Good occasion to check if page sizes in page descriptions
// are still set to (LONG_MAX, LONG_MAX) (html import)
if ( !bBrowseMode )
{
pDoc->CheckDefaultPageFmt();
}
2001-07-23 16:20:51 +00:00
RTL_LOGFILE_CONTEXT_TRACE( aLog, "View::Init - after InitPrt" );
2000-09-18 23:08:29 +00:00
if( GetWin() )
{
pOpt->Init( GetWin() );
GetWin()->SetFillColor();
GetWin()->SetBackground();
GetWin()->SetLineColor();
}
//Layout erzeugen wenn es noch nicht vorhanden ist.
SwRootFrm* pRoot = GetDoc()->GetRootFrm();
if( !pRoot )
GetDoc()->SetRootFrm( pRoot = new SwRootFrm( pDoc->GetDfltFrmFmt(), this ) );
SizeChgNotify();
2010-10-01 21:57:36 +02:00
// #i31958#
// XForms mode: initialize XForms mode, based on design mode (draw view)
// MakeDrawView() requires layout
if( GetDoc()->isXForms() )
{
if( ! HasDrawView() )
MakeDrawView();
pOpt->SetFormView( ! GetDrawView()->IsDesignMode() );
}
2000-09-18 23:08:29 +00:00
}
ViewShell::ViewShell( SwDoc& rDocument, Window *pWindow,
const SwViewOption *pNewOpt, OutputDevice *pOutput,
long nFlags )
:
aBrowseBorder(),
pSfxViewShell( 0 ),
pImp( new SwViewImp( this ) ),
2000-09-18 23:08:29 +00:00
pWin( pWindow ),
pOut( pOutput ? pOutput
: pWindow ? (OutputDevice*)pWindow
: (OutputDevice*)rDocument.getPrinter( true )),
mpTmpRef( 0 ),
pOpt( 0 ),
pAccOptions( new SwAccessibilityOptions ),
2010-10-01 21:57:36 +02:00
mpTargetPaintWindow(0),
mpBufferedOut(0),
pDoc( &rDocument ),
2000-09-18 23:08:29 +00:00
nStartAction( 0 ),
nLockPaint( 0 ),
2010-10-01 21:57:36 +02:00
mnPrePostPaintCount(0L),
mpPrePostOutDev(0),
maPrePostMapMode()
2000-09-18 23:08:29 +00:00
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "ViewShell::SwViewShell" );
2001-07-23 16:20:51 +00:00
2010-10-01 21:57:36 +02:00
// #i26791# in order to suppress event handling in
// <SwDrawContact::Changed> during contruction of <ViewShell> instance
mbInConstructor = true;
2000-09-18 23:08:29 +00:00
bPaintInProgress = bViewLocked = bInEndAction = bFrameView =
bEndActionByVirDev = FALSE;
bPaintWorks = bEnableSmooth = TRUE;
bPreView = 0 !=( VSHELLFLAG_ISPREVIEW & nFlags );
2010-10-01 21:57:36 +02:00
// #i38810# Do not reset modified state of document, if it's already been modified.
const bool bIsDocModified( pDoc->IsModified() );
// <--
pDoc->acquire();
2000-09-18 23:08:29 +00:00
pOutput = pOut;
2010-10-01 21:57:36 +02:00
Init( pNewOpt );
2000-09-18 23:08:29 +00:00
pOut = pOutput;
2010-10-01 21:57:36 +02:00
// initialize print preview layout after layout is created in <ViewShell::Init(..)> - called above.
if ( bPreView )
{
pImp->InitPagePreviewLayout();
}
2000-09-18 23:08:29 +00:00
SET_CURR_SHELL( this );
((SwHiddenTxtFieldType*)pDoc->GetSysFldType( RES_HIDDENTXTFLD ))->
SetHiddenFlag( !pOpt->IsShowHiddenField() );
2000-09-18 23:08:29 +00:00
2010-10-01 21:57:36 +02:00
// #i38810#
if ( !pDoc->IsUndoNoResetModified() && !bIsDocModified )
{
2000-09-18 23:08:29 +00:00
pDoc->ResetModified();
}
2000-09-18 23:08:29 +00:00
if ( SwTxtFrm::GetTxtCache()->GetCurMax() < 2550 )
SwTxtFrm::GetTxtCache()->IncreaseMax( 100 );
if( pOpt->IsGridVisible() || getIDocumentDrawModelAccess()->GetDrawModel() )
2000-09-18 23:08:29 +00:00
Imp()->MakeDrawView();
2010-10-01 21:57:36 +02:00
// #i26791#
mbInConstructor = false;
2000-09-18 23:08:29 +00:00
}
ViewShell::ViewShell( ViewShell& rShell, Window *pWindow,
OutputDevice *pOutput, long nFlags ) :
Ring( &rShell ),
aBrowseBorder( rShell.aBrowseBorder ),
pSfxViewShell( 0 ),
pImp( new SwViewImp( this ) ),
2000-09-18 23:08:29 +00:00
pWin( pWindow ),
pOut( pOutput ? pOutput
: pWindow ? (OutputDevice*)pWindow
: (OutputDevice*)rShell.GetDoc()->getPrinter( true )),
mpTmpRef( 0 ),
2000-09-18 23:08:29 +00:00
pOpt( 0 ),
pAccOptions( new SwAccessibilityOptions ),
2010-10-01 21:57:36 +02:00
mpTargetPaintWindow(0),
mpBufferedOut(0),
pDoc( rShell.GetDoc() ),
2000-09-18 23:08:29 +00:00
nStartAction( 0 ),
nLockPaint( 0 ),
2010-10-01 21:57:36 +02:00
mnPrePostPaintCount(0L),
mpPrePostOutDev(0),
maPrePostMapMode()
2000-09-18 23:08:29 +00:00
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "ViewShell::SwViewShell" );
2010-10-01 21:57:36 +02:00
// #i26791# in order to suppress event handling in
// <SwDrawContact::Changed> during contruction of <ViewShell> instance
mbInConstructor = true;
2000-09-18 23:08:29 +00:00
bPaintWorks = bEnableSmooth = TRUE;
bPaintInProgress = bViewLocked = bInEndAction = bFrameView =
bEndActionByVirDev = FALSE;
bPreView = 0 !=( VSHELLFLAG_ISPREVIEW & nFlags );
2010-10-01 21:57:36 +02:00
2002-12-06 15:25:21 +00:00
if ( bPreView )
pImp->InitPagePreviewLayout();
2000-09-18 23:08:29 +00:00
SET_CURR_SHELL( this );
pDoc->acquire();
2000-09-18 23:08:29 +00:00
BOOL bModified = pDoc->IsModified();
pOutput = pOut;
2010-10-01 21:57:36 +02:00
Init( rShell.GetViewOptions() );
2000-09-18 23:08:29 +00:00
pOut = pOutput;
((SwHiddenTxtFieldType*)pDoc->GetSysFldType( RES_HIDDENTXTFLD ))->
SetHiddenFlag( !pOpt->IsShowHiddenField() );
2000-09-18 23:08:29 +00:00
if( !bModified && !pDoc->IsUndoNoResetModified() )
pDoc->ResetModified();
if ( SwTxtFrm::GetTxtCache()->GetCurMax() < 2550 )
SwTxtFrm::GetTxtCache()->IncreaseMax( 100 );
if( pOpt->IsGridVisible() || getIDocumentDrawModelAccess()->GetDrawModel() )
2000-09-18 23:08:29 +00:00
Imp()->MakeDrawView();
2010-10-01 21:57:36 +02:00
// #i26791#
mbInConstructor = false;
2000-09-18 23:08:29 +00:00
}
ViewShell::~ViewShell()
{
{
SET_CURR_SHELL( this );
bPaintWorks = FALSE;
2010-10-01 21:57:36 +02:00
// #i9684#Stopping the animated graphics is not
// necessary during printing or pdf export, because the animation
// has not been started in this case.
if( pDoc && GetWin() )
2000-09-18 23:08:29 +00:00
{
SwNodes& rNds = pDoc->GetNodes();
SwGrfNode *pGNd;
SwStartNode *pStNd;
SwNodeIndex aIdx( *rNds.GetEndOfAutotext().StartOfSectionNode(), 1 );
while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
{
aIdx++;
if ( 0 != ( pGNd = aIdx.GetNode().GetGrfNode() ) )
{
if( pGNd->IsAnimated() )
{
SwClientIter aIter( *pGNd );
for( SwFrm* pFrm = (SwFrm*)aIter.First( TYPE(SwFrm) );
pFrm; pFrm = (SwFrm*)aIter.Next() )
{
ASSERT( pFrm->IsNoTxtFrm(), "GraphicNode with Text?" );
((SwNoTxtFrm*)pFrm)->StopAnimation( pOut );
}
}
}
aIdx.Assign( *pStNd->EndOfSectionNode(), +1 );
}
GetDoc()->StopNumRuleAnimations( pOut );
}
2010-10-01 21:57:36 +02:00
delete pImp;
pImp = 0; // Set to zero, because ~SwFrm relies on it.
2000-09-18 23:08:29 +00:00
if ( pDoc )
{
if( !pDoc->release() )
2000-09-18 23:08:29 +00:00
delete pDoc, pDoc = 0;
else
pDoc->GetRootFrm()->ResetNewLayout();
}
delete pOpt;
if ( SwTxtFrm::GetTxtCache()->GetCurMax() > 250 )
SwTxtFrm::GetTxtCache()->DecreaseMax( 100 );
SwPaintQueue::Remove( this );
ASSERT( !nStartAction, "EndAction() pending." );
}
if ( pDoc )
GetLayout()->DeRegisterShell( this );
delete mpTmpRef;
delete pAccOptions;
2000-09-18 23:08:29 +00:00
}
2008-10-10 13:02:43 +00:00
BOOL ViewShell::HasDrawView() const
2000-09-18 23:08:29 +00:00
{
return Imp()->HasDrawView();
}
void ViewShell::MakeDrawView()
{
Imp()->MakeDrawView( );
}
SdrView* ViewShell::GetDrawView()
{
return Imp()->GetDrawView();
}
SdrView* ViewShell::GetDrawViewWithValidMarkList()
{
SwDrawView* pDView = Imp()->GetDrawView();
pDView->ValidateMarkList();
return pDView;
}