From ebc5777548dea42ed966a16c66d879b1485bbfb4 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Sun, 13 Jun 2010 15:22:56 +0200 Subject: CWS swlayoutrefactoring: #i81480#: enable sw code to use multiple layouts --- sw/source/core/layout/wsfrm.cxx | 108 ++++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 49 deletions(-) (limited to 'sw/source/core/layout/wsfrm.cxx') diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index ade3efd4e70d..5a8c8b00d7c9 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -43,8 +43,11 @@ #include #include #include +#include +#include #include #include +#include "viewopt.hxx" #include #include #include @@ -87,11 +90,12 @@ using namespace ::com::sun::star; |* |*************************************************************************/ -SwFrm::SwFrm( SwModify *pMod ) : +SwFrm::SwFrm( SwModify *pMod, SwFrm* pSib ) : SwClient( pMod ), // --> OD 2006-05-10 #i65250# mnFrmId( SwFrm::mnLastFrmId++ ), // <-- + mpRoot( pSib ? pSib->getRootFrm() : 0 ), pUpper( 0 ), pNext( 0 ), pPrev( 0 ), @@ -114,16 +118,6 @@ SwFrm::SwFrm( SwModify *pMod ) : bCompletePaint = bInfInvalid = TRUE; } - -ViewShell * SwFrm::GetShell() const -{ - const SwRootFrm *pRoot; - if ( 0 != (pRoot = FindRootFrm()) ) - return pRoot->GetCurrShell(); - return 0; -} - - void SwFrm::CheckDir( UINT16 nDir, BOOL bVert, BOOL bOnlyBiDi, BOOL bBrowse ) { if( FRMDIR_ENVIRONMENT == nDir || ( bVert && bOnlyBiDi ) ) @@ -173,9 +167,12 @@ void SwSectionFrm::CheckDirection( BOOL bVert ) { const SwFrmFmt* pFmt = GetFmt(); if( pFmt ) + { + const ViewShell *pSh = getRootFrm()->GetCurrShell(); + const BOOL bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode(); CheckDir(((SvxFrameDirectionItem&)pFmt->GetFmtAttr(RES_FRAMEDIR)).GetValue(), - bVert, sal_True, - pFmt->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) ); + bVert, sal_True, bBrowseMode ); + } else SwFrm::CheckDirection( bVert ); } @@ -184,9 +181,12 @@ void SwFlyFrm::CheckDirection( BOOL bVert ) { const SwFrmFmt* pFmt = GetFmt(); if( pFmt ) + { + const ViewShell *pSh = getRootFrm()->GetCurrShell(); + const BOOL bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode(); CheckDir(((SvxFrameDirectionItem&)pFmt->GetFmtAttr(RES_FRAMEDIR)).GetValue(), - bVert, sal_False, - pFmt->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) ); + bVert, sal_False, bBrowseMode ); + } else SwFrm::CheckDirection( bVert ); } @@ -195,9 +195,12 @@ void SwTabFrm::CheckDirection( BOOL bVert ) { const SwFrmFmt* pFmt = GetFmt(); if( pFmt ) + { + const ViewShell *pSh = getRootFrm()->GetCurrShell(); + const BOOL bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode(); CheckDir(((SvxFrameDirectionItem&)pFmt->GetFmtAttr(RES_FRAMEDIR)).GetValue(), - bVert, sal_True, - pFmt->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) ); + bVert, sal_True, bBrowseMode ); + } else SwFrm::CheckDirection( bVert ); } @@ -213,8 +216,9 @@ void SwCellFrm::CheckDirection( BOOL bVert ) if( pFmt && SFX_ITEM_SET == pFmt->GetItemState( RES_FRAMEDIR, TRUE, &pItem ) ) { const SvxFrameDirectionItem* pFrmDirItem = static_cast(pItem); - CheckDir( pFrmDirItem->GetValue(), bVert, sal_False, - pFmt->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) ); + const ViewShell *pSh = getRootFrm()->GetCurrShell(); + const BOOL bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode(); + CheckDir( pFrmDirItem->GetValue(), bVert, sal_False, bBrowseMode ); } else SwFrm::CheckDirection( bVert ); @@ -222,9 +226,10 @@ void SwCellFrm::CheckDirection( BOOL bVert ) void SwTxtFrm::CheckDirection( BOOL bVert ) { + const ViewShell *pSh = getRootFrm()->GetCurrShell(); + const BOOL bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode(); CheckDir( GetTxtNode()->GetSwAttrSet().GetFrmDir().GetValue(), bVert, - sal_True, - GetTxtNode()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) ); + sal_True, bBrowseMode ); } /************************************************************************* @@ -983,7 +988,7 @@ void SwCntntFrm::Cut() //er die Retouche uebernehmen. //Ausserdem kann eine Leerseite entstanden sein. else - { SwRootFrm *pRoot = FindRootFrm(); + { SwRootFrm *pRoot = getRootFrm(); if ( pRoot ) { pRoot->SetSuperfluous(); @@ -1392,7 +1397,8 @@ SwTwips SwFrm::AdjustNeighbourhood( SwTwips nDiff, BOOL bTst ) if ( !nDiff || !GetUpper()->IsFtnBossFrm() ) // nur innerhalb von Seiten/Spalten return 0L; - BOOL bBrowse = GetUpper()->GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE); + const ViewShell *pSh = getRootFrm()->GetCurrShell(); + const BOOL bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode(); //Der (Page)Body veraendert sich nur im BrowseMode, aber nicht wenn er //Spalten enthaelt. @@ -1406,16 +1412,16 @@ SwTwips SwFrm::AdjustNeighbourhood( SwTwips nDiff, BOOL bTst ) long nBrowseAdd = 0; if ( bBrowse && GetUpper()->IsPageFrm() ) // nur (Page)BodyFrms { - ViewShell *pSh = GetShell(); + ViewShell *pViewShell = getRootFrm()->GetCurrShell(); SwLayoutFrm *pUp = GetUpper(); long nChg; const long nUpPrtBottom = pUp->Frm().Height() - pUp->Prt().Height() - pUp->Prt().Top(); SwRect aInva( pUp->Frm() ); - if ( pSh ) + if ( pViewShell ) { - aInva.Pos().X() = pSh->VisArea().Left(); - aInva.Width( pSh->VisArea().Width() ); + aInva.Pos().X() = pViewShell->VisArea().Left(); + aInva.Width( pViewShell->VisArea().Width() ); } if ( nDiff > 0 ) { @@ -1425,7 +1431,7 @@ SwTwips SwFrm::AdjustNeighbourhood( SwTwips nDiff, BOOL bTst ) if ( !IsBodyFrm() ) { SetCompletePaint(); - if ( !pSh || pSh->VisArea().Height() >= pUp->Frm().Height() ) + if ( !pViewShell || pViewShell->VisArea().Height() >= pUp->Frm().Height() ) { //Ersteinmal den Body verkleinern. Der waechst dann schon //wieder. @@ -1455,12 +1461,12 @@ SwTwips SwFrm::AdjustNeighbourhood( SwTwips nDiff, BOOL bTst ) //mindestens so gross wie die VisArea. nChg = nDiff; long nInvaAdd = 0; - if ( pSh && !pUp->GetPrev() && - pUp->Frm().Height() + nDiff < pSh->VisArea().Height() ) + if ( pViewShell && !pUp->GetPrev() && + pUp->Frm().Height() + nDiff < pViewShell->VisArea().Height() ) { //Das heisst aber wiederum trotzdem, das wir geeignet invalidieren //muessen. - nChg = pSh->VisArea().Height() - pUp->Frm().Height(); + nChg = pViewShell->VisArea().Height() - pUp->Frm().Height(); nInvaAdd = -(nDiff - nChg); } @@ -1483,16 +1489,16 @@ SwTwips SwFrm::AdjustNeighbourhood( SwTwips nDiff, BOOL bTst ) if ( !bTst ) { //Unabhaengig von nChg - if ( pSh && aInva.HasArea() && pUp->GetUpper() ) - pSh->InvalidateWindows( aInva ); + if ( pViewShell && aInva.HasArea() && pUp->GetUpper() ) + pViewShell->InvalidateWindows( aInva ); } if ( !bTst && nChg ) { const SwRect aOldRect( pUp->Frm() ); pUp->Frm().SSize().Height() += nChg; pUp->Prt().SSize().Height() += nChg; - if ( pSh ) - pSh->Imp()->SetFirstVisPageInvalid(); + if ( pViewShell ) + pViewShell->Imp()->SetFirstVisPageInvalid(); if ( GetNext() ) GetNext()->_InvalidatePos(); @@ -1500,7 +1506,7 @@ SwTwips SwFrm::AdjustNeighbourhood( SwTwips nDiff, BOOL bTst ) //Ggf. noch ein Repaint ausloesen. const SvxGraphicPosition ePos = pUp->GetFmt()->GetBackground().GetGraphicPos(); if ( ePos != GPOS_NONE && ePos != GPOS_TILED ) - pSh->InvalidateWindows( pUp->Frm() ); + pViewShell->InvalidateWindows( pUp->Frm() ); if ( pUp->GetUpper() ) { @@ -1889,7 +1895,8 @@ SwTwips SwCntntFrm::GrowFrm( SwTwips nDist, BOOL bTst, BOOL bInfo ) nDist > (LONG_MAX - nFrmHeight ) ) nDist = LONG_MAX - nFrmHeight; - const BOOL bBrowse = GetUpper()->GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE); + const ViewShell *pSh = getRootFrm()->GetCurrShell(); + const BOOL bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode(); const USHORT nTmpType = bBrowse ? 0x2084: 0x2004; //Row+Cell, Browse mit Body if( !(GetUpper()->GetType() & nTmpType) && GetUpper()->HasFixSize() ) { @@ -2347,8 +2354,8 @@ void SwCntntFrm::_UpdateAttr( SfxPoolItem* pOld, SfxPoolItem* pNew, |* Letzte Aenderung MA 12. May. 95 |* |*************************************************************************/ -SwLayoutFrm::SwLayoutFrm( SwFrmFmt* pFmt ): - SwFrm( pFmt ), +SwLayoutFrm::SwLayoutFrm( SwFrmFmt* pFmt, SwFrm* pSib ): + SwFrm( pFmt, pSib ), pLower( 0 ) { const SwFmtFrmSize &rFmtSize = pFmt->GetFrmSize(); @@ -2411,7 +2418,8 @@ SwTwips SwLayoutFrm::InnerHeight() const |*************************************************************************/ SwTwips SwLayoutFrm::GrowFrm( SwTwips nDist, BOOL bTst, BOOL bInfo ) { - const BOOL bBrowse = GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE); + const ViewShell *pSh = getRootFrm()->GetCurrShell(); + const BOOL bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode(); const USHORT nTmpType = bBrowse ? 0x2084: 0x2004; //Row+Cell, Browse mit Body if( !(GetType() & nTmpType) && HasFixSize() ) return 0; @@ -2557,7 +2565,7 @@ SwTwips SwLayoutFrm::GrowFrm( SwTwips nDist, BOOL bTst, BOOL bInfo ) if( bMoveAccFrm && IsAccessibleFrm() ) { - SwRootFrm *pRootFrm = FindRootFrm(); + SwRootFrm *pRootFrm = getRootFrm(); if( pRootFrm && pRootFrm->IsAnyShellAccessible() && pRootFrm->GetCurrShell() ) { @@ -2577,7 +2585,8 @@ SwTwips SwLayoutFrm::GrowFrm( SwTwips nDist, BOOL bTst, BOOL bInfo ) |*************************************************************************/ SwTwips SwLayoutFrm::ShrinkFrm( SwTwips nDist, BOOL bTst, BOOL bInfo ) { - const BOOL bBrowse = GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE); + const ViewShell *pSh = getRootFrm()->GetCurrShell(); + const BOOL bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode(); const USHORT nTmpType = bBrowse ? 0x2084: 0x2004; //Row+Cell, Browse mit Body if( !(GetType() & nTmpType) && HasFixSize() ) return 0; @@ -2675,7 +2684,7 @@ SwTwips SwLayoutFrm::ShrinkFrm( SwTwips nDist, BOOL bTst, BOOL bInfo ) if( bMoveAccFrm && IsAccessibleFrm() ) { - SwRootFrm *pRootFrm = FindRootFrm(); + SwRootFrm *pRootFrm = getRootFrm(); if( pRootFrm && pRootFrm->IsAnyShellAccessible() && pRootFrm->GetCurrShell() ) { @@ -3330,10 +3339,9 @@ long SwLayoutFrm::CalcRel( const SwFmtFrmSize &rSz, BOOL ) const { const SwFrm *pRel = GetUpper(); long nRel = LONG_MAX; - const ViewShell *pSh = GetShell(); - if ( pRel->IsPageBodyFrm() && - GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) && - pSh && pSh->VisArea().Width()) + const ViewShell *pSh = getRootFrm()->GetCurrShell(); + const BOOL bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode(); + if( pRel->IsPageBodyFrm() && pSh && bBrowseMode && pSh->VisArea().Width() ) { nRel = pSh->GetBrowseWidth(); long nDiff = nRel - pRel->Prt().Width(); @@ -3434,7 +3442,9 @@ void SwLayoutFrm::FormatWidthCols( const SwBorderAttrs &rAttrs, BOOL bEnd = FALSE; BOOL bBackLock = FALSE; - SwViewImp *pImp = GetShell() ? GetShell()->Imp() : 0; + ViewShell *pSh = getRootFrm()->GetCurrShell(); + + SwViewImp *pImp = pSh ? pSh->Imp() : 0; { // Zugrunde liegender Algorithmus // Es wird versucht, eine optimale Hoehe fuer die Spalten zu finden. @@ -3949,7 +3959,7 @@ void SwRootFrm::InvalidateAllCntnt( BYTE nInv ) if( nInv & INV_PRTAREA ) { - ViewShell *pSh = GetShell(); + ViewShell *pSh = getRootFrm()->GetCurrShell(); if( pSh ) pSh->InvalidateWindows( Frm() ); } -- cgit v1.2.3