diff options
author | Valentin Kettner <vakevk+libreoffice@gmail.com> | 2014-08-15 19:09:49 +0200 |
---|---|---|
committer | Valentin Kettner <vakevk+libreoffice@gmail.com> | 2014-08-17 19:31:49 +0200 |
commit | 6af9c09ac21e9b94ffbf633c51dcfb4d8a87a5b6 (patch) | |
tree | 3857e2172ecc9edefae29923786a3cf554e61536 | |
parent | c2d3b7e4aa0480ed2c66b7240ef05cfff6a07125 (diff) |
Refactored SwDoc::GetEditShell .feature/refactor-god-objects
Removed its output paramater as GetCurrentViewShell should be
used instead and added a const version.
Change-Id: Iad8b57553b6e93e3472ce8c6905d08e8d49af770
38 files changed, 121 insertions, 116 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index e000a919063f..bb5e9fb941bc 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -444,7 +444,7 @@ private: const SwTxtFmtColl* pSplitColl, int nOutlineLevel = 0 ); // Update charts of given table. - void _UpdateCharts( const SwTable& rTbl, SwViewShell& rVSh ) const; + void _UpdateCharts( const SwTable& rTbl, SwViewShell const & rVSh ) const; bool _SelectNextRubyChars( SwPaM& rPam, SwRubyListEntry& rRubyEntry, sal_uInt16 nMode ); @@ -1345,8 +1345,9 @@ public: const SwAttrPool& GetAttrPool() const { return *mpAttrPool; } SwAttrPool& GetAttrPool() { return *mpAttrPool; } - // Search an EditShell or, if appropriate, a SwViewShell via layout. - SwEditShell* GetEditShell( SwViewShell** ppSh = 0 ) const; + // Search for an EditShell. + SwEditShell const * GetEditShell() const; + SwEditShell* GetEditShell(); ::sw::IShellCursorSupplier * GetIShellCursorSupplier(); // OLE 2.0-notification. @@ -1413,7 +1414,7 @@ public: // Query if URL was visited. // Query via Doc, if only a Bookmark has been given. // In this case the document name has to be set in front. - bool IsVisitedURL( const OUString& rURL ) const; + bool IsVisitedURL( const OUString& rURL ); // Save current values for automatic registration of exceptions in Autocorrection. void SetAutoCorrExceptWord( SwAutoCorrExceptWord* pNew ); diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx index 03c28dcc1769..f83b80671522 100644 --- a/sw/inc/node.hxx +++ b/sw/inc/node.hxx @@ -257,7 +257,7 @@ public: IDocumentListItems& getIDocumentListItems(); /// Is node in the visible area of the Shell? - bool IsInVisibleArea( SwViewShell* pSh = 0 ) const; + bool IsInVisibleArea( SwViewShell const * pSh = 0 ) const; /// Is node in an protected area? bool IsInProtectSect() const; /** Is node in something that is protected (range, frame, diff --git a/sw/inc/txtinet.hxx b/sw/inc/txtinet.hxx index 341762d4f8b5..8e70df02e96c 100644 --- a/sw/inc/txtinet.hxx +++ b/sw/inc/txtinet.hxx @@ -47,6 +47,7 @@ public: // get and set TxtNode pointer const SwTxtNode* GetpTxtNode() const { return m_pTxtNode; } inline const SwTxtNode& GetTxtNode() const; + inline SwTxtNode& GetTxtNode(); void ChgTxtNode( SwTxtNode* pNew ) { m_pTxtNode = pNew; } SwCharFmt* GetCharFmt(); @@ -68,6 +69,11 @@ inline const SwTxtNode& SwTxtINetFmt::GetTxtNode() const return *m_pTxtNode; } +inline SwTxtNode& SwTxtINetFmt::GetTxtNode() +{ + return const_cast<SwTxtNode&>( const_cast<SwTxtINetFmt const*>(this)->GetTxtNode() ); +} + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx index f1cf0f3a8c02..076a60f14b0d 100644 --- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx +++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx @@ -216,7 +216,6 @@ void DocumentLinksAdministrationManager::UpdateLinks( bool bUI ) SFX_CREATE_MODE_PREVIEW != eMode && !m_rSwdoc.GetDocShell()->IsPreview() ) { - SwViewShell* pVSh = 0; bool bAskUpdate = nLinkMode == MANUAL; bool bUpdate = true; switch(nUpdateDocMode) @@ -230,15 +229,8 @@ void DocumentLinksAdministrationManager::UpdateLinks( bool bUI ) SfxMedium* pMedium = m_rSwdoc.GetDocShell()->GetMedium(); SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0; Window* pDlgParent = pFrm ? &pFrm->GetWindow() : 0; - if( m_rSwdoc.getIDocumentLayoutAccess().GetCurrentViewShell() && !m_rSwdoc.GetEditShell( &pVSh ) && !pVSh ) - { - SwViewShell aVSh( m_rSwdoc, 0, 0 ); - SET_CURR_SHELL( &aVSh ); - GetLinkManager().UpdateAllLinks( bAskUpdate , true, false, pDlgParent ); - } - else - GetLinkManager().UpdateAllLinks( bAskUpdate, true, false, pDlgParent ); + GetLinkManager().UpdateAllLinks( bAskUpdate, true, false, pDlgParent ); } } } diff --git a/sw/source/core/doc/docchart.cxx b/sw/source/core/doc/docchart.cxx index 9d3d3db0989b..196fda16d6b7 100644 --- a/sw/source/core/doc/docchart.cxx +++ b/sw/source/core/doc/docchart.cxx @@ -23,6 +23,7 @@ #include <doc.hxx> #include <IDocumentChartDataProviderAccess.hxx> #include <IDocumentState.hxx> +#include <IDocumentLayoutAccess.hxx> #include <docary.hxx> #include <ndindex.hxx> #include <swtable.hxx> @@ -86,8 +87,7 @@ bool SwTable::IsTblComplexForChart( const OUString& rSelection ) const void SwDoc::DoUpdateAllCharts() { - SwViewShell* pVSh; - GetEditShell( &pVSh ); + SwViewShell* pVSh = getIDocumentLayoutAccess().GetCurrentViewShell(); if( pVSh ) { const SwFrmFmts& rTblFmts = *GetTblFrmFmts(); @@ -107,7 +107,7 @@ void SwDoc::DoUpdateAllCharts() } } -void SwDoc::_UpdateCharts( const SwTable& rTbl, SwViewShell& rVSh ) const +void SwDoc::_UpdateCharts( const SwTable& rTbl, SwViewShell const & rVSh ) const { OUString aName( rTbl.GetFrmFmt()->GetName() ); SwOLENode *pONd; @@ -135,8 +135,7 @@ void SwDoc::UpdateCharts( const OUString &rName ) const SwTable* pTmpTbl = SwTable::FindTable( FindTblFmtByName( rName ) ); if( pTmpTbl ) { - SwViewShell* pVSh; - GetEditShell( &pVSh ); + SwViewShell const * pVSh = getIDocumentLayoutAccess().GetCurrentViewShell(); if( pVSh ) _UpdateCharts( *pTmpTbl, *pVSh ); @@ -176,9 +175,6 @@ void SwDoc::SetTableName( SwFrmFmt& rTblFmt, const OUString &rNewName ) { pNd->SetChartTblName( rNewName ); - SwViewShell* pVSh; - GetEditShell( &pVSh ); - SwTable* pTable = SwTable::FindTable( &rTblFmt ); SwChartDataProvider *pPCD = getIDocumentChartDataProviderAccess().GetChartDataProvider(); if (pPCD) diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx index 5430bb6d51a6..074eafca4314 100644 --- a/sw/source/core/doc/doccorr.cxx +++ b/sw/source/core/doc/doccorr.cxx @@ -39,14 +39,14 @@ #define PCURSH ((SwCrsrShell*)_pStartShell) #define FOREACHSHELL_START( pEShell ) \ {\ - SwViewShell *_pStartShell = pEShell; \ + SwViewShell const *_pStartShell = pEShell; \ do { \ if( _pStartShell->IsA( TYPE( SwCrsrShell )) ) \ { #define FOREACHSHELL_END( pEShell ) \ } \ - } while((_pStartShell=(SwViewShell*)_pStartShell->GetNext())!= pEShell ); \ + } while((_pStartShell=(SwViewShell const*)_pStartShell->GetNext())!= pEShell ); \ } namespace @@ -259,7 +259,7 @@ void PaMCorrRel( const SwNodeIndex &rOldNode, const sal_Int32 nCntIdx = rNewPos.nContent.GetIndex() + nOffset; - SwCrsrShell* pShell = pDoc->GetEditShell(); + SwCrsrShell const* pShell = pDoc->GetEditShell(); if( pShell ) { FOREACHSHELL_START( pShell ) @@ -322,32 +322,33 @@ void SwDoc::CorrRel(const SwNodeIndex& rOldNode, ::PaMCorrRel(rOldNode, rNewPos, nOffset); } -SwEditShell* SwDoc::GetEditShell( SwViewShell** ppSh ) const +SwEditShell const * SwDoc::GetEditShell() const { - SwViewShell *pCurrentView = const_cast<SwViewShell*>( getIDocumentLayoutAccess().GetCurrentViewShell() ); + SwViewShell const *pCurrentView = getIDocumentLayoutAccess().GetCurrentViewShell(); // Layout and OLE shells should be available if( pCurrentView ) { - SwViewShell *pSh = pCurrentView, *pVSh = pSh; - if( ppSh ) - *ppSh = pSh; - + SwViewShell const *pFirstVSh = pCurrentView; + SwViewShell const *pCurrentVSh = pFirstVSh; // look for an EditShell (if it exists) do { - if( pSh->IsA( TYPE( SwEditShell ) ) ) - return (SwEditShell*)pSh; - - } while( pVSh != ( pSh = (SwViewShell*)pSh->GetNext() )); + if( pCurrentVSh->IsA( TYPE( SwEditShell ) ) ) + { + return (SwEditShell*)pCurrentVSh; + } + } while( pFirstVSh != ( pCurrentVSh = (SwViewShell*)pCurrentVSh->GetNext() )); } - else if( ppSh ) - *ppSh = 0; - return 0; } +SwEditShell* SwDoc::GetEditShell() +{ + return const_cast<SwEditShell*>( const_cast<SwDoc const *>( this )->GetEditShell() ); +} + ::sw::IShellCursorSupplier * SwDoc::GetIShellCursorSupplier() { - return GetEditShell(0); + return GetEditShell(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/htmltbl.cxx b/sw/source/core/doc/htmltbl.cxx index 1ac952637e8f..8ad649745a98 100644 --- a/sw/source/core/doc/htmltbl.cxx +++ b/sw/source/core/doc/htmltbl.cxx @@ -345,8 +345,7 @@ void SwHTMLTableLayout::GetAvail( sal_uInt16 nCol, sal_uInt16 nColSpan, sal_uInt16 SwHTMLTableLayout::GetBrowseWidthByVisArea( const SwDoc& rDoc ) { - SwViewShell *pVSh = 0; - rDoc.GetEditShell( &pVSh ); + SwViewShell const *pVSh = rDoc.getIDocumentLayoutAccess().GetCurrentViewShell(); if( pVSh ) { return (sal_uInt16)pVSh->GetBrowseWidth(); diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 4e21086a7b50..9baf0ce563f7 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -42,6 +42,7 @@ #include <IDocumentSettingAccess.hxx> #include <IDocumentStylePoolAccess.hxx> #include <IDocumentDeviceAccess.hxx> +#include <IDocumentLayoutAccess.hxx> #include <flyfrm.hxx> #include <flyfrms.hxx> #include <frmtool.hxx> @@ -579,8 +580,7 @@ void SwNoTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) bComplete = false; SwGrfNode* pNd = (SwGrfNode*) GetNode(); - SwViewShell *pVSh = 0; - pNd->GetDoc()->GetEditShell( &pVSh ); + SwViewShell *pVSh = pNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); if( pVSh ) { GraphicAttr aAttr; @@ -642,8 +642,7 @@ void SwNoTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) SwRect aRect( Frm() ); - SwViewShell *pVSh = 0; - pNd->GetDoc()->GetEditShell( &pVSh ); + SwViewShell *pVSh = pNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); if( !pVSh ) break; diff --git a/sw/source/core/doc/visiturl.cxx b/sw/source/core/doc/visiturl.cxx index ed3d72143502..dd0b9567f215 100644 --- a/sw/source/core/doc/visiturl.cxx +++ b/sw/source/core/doc/visiturl.cxx @@ -29,7 +29,7 @@ #include <editsh.hxx> #include <docsh.hxx> -SwURLStateChanged::SwURLStateChanged( const SwDoc* pD ) +SwURLStateChanged::SwURLStateChanged( SwDoc* pD ) : pDoc( pD ) { StartListening( *INetURLHistory::GetOrCreate() ); @@ -98,7 +98,7 @@ void SwURLStateChanged::Notify( SfxBroadcaster& , const SfxHint& rHint ) // Check if the URL has been visited before. Via the Doc, if only one Bookmark is set // We need to put the Doc's name before it! -bool SwDoc::IsVisitedURL( const OUString& rURL ) const +bool SwDoc::IsVisitedURL( const OUString& rURL ) { bool bRet = false; if( !rURL.isEmpty() ) diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 066b617ddb0d..b6473ac504fc 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -2248,7 +2248,7 @@ sal_uInt16 SwDoc::MergeTbl( SwPaM& rPam ) GetUndoManager().RemoveLastUndo()); if (pU && pU->GetRedlSaveCount()) { - SwEditShell *const pEditShell(GetEditShell(0)); + SwEditShell *const pEditShell(GetEditShell()); OSL_ASSERT(pEditShell); ::sw::UndoRedoContext context(*this, *pEditShell); static_cast<SfxUndoAction *>(pU)->UndoWithContext(context); diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 0fa16f167730..ed224d4e4640 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -357,7 +357,7 @@ SwTableNode* SwNode::FindTableNode() } /// Is the node located in the visible area of the Shell? -bool SwNode::IsInVisibleArea( SwViewShell* pSh ) const +bool SwNode::IsInVisibleArea( SwViewShell const * pSh ) const { bool bRet = false; const SwCntntNode* pNd; @@ -377,7 +377,7 @@ bool SwNode::IsInVisibleArea( SwViewShell* pSh ) const if( !pSh ) // Get the Shell from the Doc - GetDoc()->GetEditShell( &pSh ); + pSh = GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); if( pSh ) { diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 46ee7ab20ee0..683c2d27976e 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -39,6 +39,7 @@ #include <IDocumentFieldsAccess.hxx> #include <IDocumentStylePoolAccess.hxx> #include <IDocumentState.hxx> +#include <IDocumentLayoutAccess.hxx> #include <node.hxx> #include <pam.hxx> #include <frmtool.hxx> @@ -1195,8 +1196,8 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) pDoc->getIDocumentLinksAdministration().SetVisibleLinks( false ); SwPaM* pPam; - SwViewShell* pVSh = 0; - SwEditShell* pESh = pDoc->GetEditShell( &pVSh ); + SwViewShell* pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); + SwEditShell* pESh = pDoc->GetEditShell(); pDoc->getIDocumentFieldsAccess().LockExpFlds(); { // Insert an empty TextNode at the Section's start @@ -1446,8 +1447,8 @@ void SwIntrnlSectRefLink::Closed() for( sal_uInt16 n = rFmts.size(); n; ) if( rFmts[ --n ] == &rSectFmt ) { - SwViewShell* pSh; - SwEditShell* pESh = pDoc->GetEditShell( &pSh ); + SwViewShell* pSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); + SwEditShell* pESh = pDoc->GetEditShell(); if( pESh ) pESh->StartAllAction(); diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx index d7ea881fa22a..ddc3d1bf1ad1 100644 --- a/sw/source/core/docnode/swbaslnk.cxx +++ b/sw/source/core/docnode/swbaslnk.cxx @@ -36,6 +36,7 @@ #include <frmfmt.hxx> #include <doc.hxx> #include <IDocumentLinksAdministration.hxx> +#include <IDocumentLayoutAccess.hxx> #include <pam.hxx> #include <editsh.hxx> #include <swtable.hxx> @@ -191,8 +192,8 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) else if( pCntntNode->IsOLENode() ) bUpdate = true; - SwViewShell *pSh = 0; - SwEditShell* pESh = pDoc->GetEditShell( &pSh ); + SwViewShell *pSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); + SwEditShell* pESh = pDoc->GetEditShell(); if ( bUpdate && bGraphicPieceArrived && !(bSwapIn || bDontNotify) ) { @@ -288,9 +289,9 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) static bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfNd ) { bool bRet = false; - SwViewShell *pSh; + SwViewShell *pSh = pGrfNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); CurrShell *pCurr = 0; - if ( pGrfNd->GetDoc()->GetEditShell( &pSh ) ) + if ( pGrfNd->GetDoc()->GetEditShell() ) pCurr = new CurrShell( pSh ); Size aSz = pGrfNd->GetTwipSize(); diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 2533d89d6aa0..ed56e91f5c7a 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1063,7 +1063,7 @@ void SwDrawContact::Changed( const SdrObject& rObj, SwRootFrm *pTmpRoot = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); if ( pTmpRoot && pTmpRoot->IsCallbackActionEnabled() ) { - pDoc->GetEditShell( &pOrg ); + pOrg = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); pSh = pOrg; if ( pSh ) do diff --git a/sw/source/core/fields/ddefld.cxx b/sw/source/core/fields/ddefld.cxx index 1b0d916d4a1f..a46ed526304d 100644 --- a/sw/source/core/fields/ddefld.cxx +++ b/sw/source/core/fields/ddefld.cxx @@ -97,8 +97,8 @@ public: // no dependencies left? if( rFldType.GetDepends() && !rFldType.IsModifyLocked() && !ChkNoDataFlag() ) { - SwViewShell* pSh; - SwEditShell* pESh = rFldType.GetDoc()->GetEditShell( &pSh ); + SwViewShell* pSh = rFldType.GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); + SwEditShell* pESh = rFldType.GetDoc()->GetEditShell(); // Search for fields. If no valid found, disconnect. SwMsgPoolItem aUpdateDDE( RES_UPDATEDDETBL ); @@ -147,8 +147,8 @@ void SwIntrnlRefLink::Closed() if( rFldType.GetDoc() && !rFldType.GetDoc()->IsInDtor() ) { // advise goes, convert all fields into text? - SwViewShell* pSh; - SwEditShell* pESh = rFldType.GetDoc()->GetEditShell( &pSh ); + SwViewShell* pSh = rFldType.GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); + SwEditShell* pESh = rFldType.GetDoc()->GetEditShell(); if( pESh ) { pESh->StartAllAction(); diff --git a/sw/source/core/inc/drawfont.hxx b/sw/source/core/inc/drawfont.hxx index f95fc87df621..db58a47571dd 100644 --- a/sw/source/core/inc/drawfont.hxx +++ b/sw/source/core/inc/drawfont.hxx @@ -39,7 +39,7 @@ class SwDrawTextInfo { const SwTxtFrm* pFrm; OutputDevice* pOut; - SwViewShell* pSh; + SwViewShell const * pSh; const SwScriptInfo* pScriptInfo; Point m_aPos; OUString m_aText; @@ -102,7 +102,7 @@ public: bool m_bDrawSp: 1; #endif - SwDrawTextInfo( SwViewShell *pS, OutputDevice &rO, const SwScriptInfo* pSI, + SwDrawTextInfo( SwViewShell const *pS, OutputDevice &rO, const SwScriptInfo* pSI, const OUString &rSt, sal_Int32 nI, sal_Int32 nL, sal_uInt16 nW = 0, bool bB = false ) { @@ -164,7 +164,7 @@ public: pFrm = pNewFrm; } - SwViewShell *GetShell() const + SwViewShell const *GetShell() const { return pSh; } diff --git a/sw/source/core/inc/fntcache.hxx b/sw/source/core/inc/fntcache.hxx index 106b7076ecfa..10a7112320b3 100644 --- a/sw/source/core/inc/fntcache.hxx +++ b/sw/source/core/inc/fntcache.hxx @@ -88,7 +88,7 @@ public: DECL_FIXEDMEMPOOL_NEWDEL(SwFntObj) SwFntObj( const SwSubFont &rFont, const void* pOwner, - SwViewShell *pSh ); + SwViewShell const *pSh ); virtual ~SwFntObj(); @@ -122,13 +122,13 @@ public: class SwFntAccess : public SwCacheAccess { - SwViewShell *pShell; + SwViewShell const *pShell; protected: virtual SwCacheObj *NewObj( ) SAL_OVERRIDE; public: SwFntAccess( const void * &rMagic, sal_uInt16 &rIndex, const void *pOwner, - SwViewShell *pShell, + SwViewShell const *pShell, bool bCheck = false ); inline SwFntObj* Get() { return (SwFntObj*) SwCacheAccess::Get(); }; }; diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx index 0c1bc28c0fb4..ed1d5ff3083c 100644 --- a/sw/source/core/inc/swfont.hxx +++ b/sw/source/core/inc/swfont.hxx @@ -70,7 +70,7 @@ class SwSubFont : public SvxFont short _CheckKerning( ); - bool ChgFnt( SwViewShell *pSh, OutputDevice& rOut ); + bool ChgFnt( SwViewShell const *pSh, OutputDevice& rOut ); bool IsSymbol( SwViewShell *pSh ); sal_uInt16 GetAscent( SwViewShell *pSh, const OutputDevice& rOut ); sal_uInt16 GetHeight( SwViewShell *pSh, const OutputDevice& rOut ); @@ -173,7 +173,7 @@ public: SwFont( const SwAttrSet* pSet, const IDocumentSettingAccess* pIDocumentSettingAccess ); SwFont( const SwFont& rFont ); - inline void ChgFnt( SwViewShell *pSh, OutputDevice& rOut ) + inline void ChgFnt( SwViewShell const *pSh, OutputDevice& rOut ) { bPaintBlank = aSub[nActual].ChgFnt( pSh, rOut ); } ~SwFont(); @@ -340,7 +340,7 @@ public: Size GetCapitalSize( SwDrawTextInfo& rInf ) { return aSub[nActual].GetCapitalSize( rInf ); } - sal_Int32 GetCapitalBreak( SwViewShell* pSh, const OutputDevice* pOut, + sal_Int32 GetCapitalBreak( SwViewShell const* pSh, const OutputDevice* pOut, const SwScriptInfo* pScript, const OUString& rTxt, long nTextWidth, const sal_Int32 nIdx, const sal_Int32 nLen ); diff --git a/sw/source/core/inc/visiturl.hxx b/sw/source/core/inc/visiturl.hxx index e43fe77bd487..109b9b55cf80 100644 --- a/sw/source/core/inc/visiturl.hxx +++ b/sw/source/core/inc/visiturl.hxx @@ -26,9 +26,9 @@ class SwDoc; class SwURLStateChanged : public SfxListener { - const SwDoc* pDoc; + SwDoc* pDoc; public: - SwURLStateChanged( const SwDoc* pD ); + SwURLStateChanged( SwDoc* pD ); virtual ~SwURLStateChanged(); virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE; diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx index ebc0f27a2f3f..9f0a359dd885 100644 --- a/sw/source/core/layout/pagedesc.cxx +++ b/sw/source/core/layout/pagedesc.cxx @@ -31,6 +31,7 @@ #include <frmtool.hxx> #include <doc.hxx> #include <poolfmt.hrc> +#include <IDocumentLayoutAccess.hxx> #include <IDocumentStylePoolAccess.hxx> #include <poolfmt.hxx> #include <switerator.hxx> @@ -176,8 +177,7 @@ void SwPageDesc::RegisterChange() { return; } - SwViewShell* pSh = 0L; - pDoc->GetEditShell( &pSh ); + SwViewShell* pSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); if ( !pSh ) { return; diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index 104cd4d2edc7..d7f648f3713e 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -325,7 +325,7 @@ class SwMinMaxArgs { public: OutputDevice* pOut; - SwViewShell* pSh; + SwViewShell const * pSh; sal_uLong &rMin; sal_uLong &rMax; sal_uLong &rAbsMin; @@ -333,7 +333,7 @@ public: long nWordWidth; long nWordAdd; sal_Int32 nNoLineBreak; - SwMinMaxArgs( OutputDevice* pOutI, SwViewShell* pShI, sal_uLong& rMinI, sal_uLong &rMaxI, sal_uLong &rAbsI ) + SwMinMaxArgs( OutputDevice* pOutI, SwViewShell const * pShI, sal_uLong& rMinI, sal_uLong &rMaxI, sal_uLong &rAbsI ) : pOut( pOutI ), pSh( pShI ), rMin( rMinI ), rMax( rMaxI ), rAbsMin( rAbsI ) { nRowWidth = nWordWidth = nWordAdd = 0; nNoLineBreak = COMPLETE_STRING; } void Minimum( long nNew ) const { if( (long)rMin < nNew ) rMin = nNew; } @@ -550,8 +550,7 @@ static void lcl_MinMaxNode( SwFrmFmt* pNd, SwMinMaxNodeArgs* pIn ) void SwTxtNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rMax, sal_uLong& rAbsMin, OutputDevice* pOut ) const { - SwViewShell* pSh = 0; - GetDoc()->GetEditShell( &pSh ); + SwViewShell const * pSh = GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); if( !pOut ) { if( pSh ) @@ -781,9 +780,8 @@ void SwTxtNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rMa sal_uInt16 SwTxtNode::GetScalingOfSelectedText( sal_Int32 nStt, sal_Int32 nEnd ) const { - SwViewShell* pSh = NULL; + SwViewShell const * pSh = GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); OutputDevice* pOut = NULL; - GetDoc()->GetEditShell( &pSh ); if ( pSh ) pOut = &pSh->GetRefDev(); diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 38b1f6c076d0..142938fcf09b 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -93,7 +93,7 @@ void SwFntCache::Flush( ) SwCache::Flush( ); } -SwFntObj::SwFntObj(const SwSubFont &rFont, const void *pOwn, SwViewShell *pSh) +SwFntObj::SwFntObj(const SwSubFont &rFont, const void *pOwn, SwViewShell const *pSh) : SwCacheObj((void*)pOwn) , aFont(rFont) , pScrFont(NULL) @@ -2184,7 +2184,7 @@ sal_Int32 SwFntObj::GetCrsrOfst( SwDrawTextInfo &rInf ) } SwFntAccess::SwFntAccess( const void* &rMagic, - sal_uInt16 &rIndex, const void *pOwn, SwViewShell *pSh, + sal_uInt16 &rIndex, const void *pOwn, SwViewShell const *pSh, bool bCheck ) : SwCacheAccess( *pFntCache, rMagic, rIndex ), pShell( pSh ) diff --git a/sw/source/core/txtnode/fntcap.cxx b/sw/source/core/txtnode/fntcap.cxx index 0f6e535a3e2a..5621ce8fa290 100644 --- a/sw/source/core/txtnode/fntcap.cxx +++ b/sw/source/core/txtnode/fntcap.cxx @@ -207,7 +207,7 @@ void SwDoGetCapitalBreak::Do() } } -sal_Int32 SwFont::GetCapitalBreak( SwViewShell* pSh, const OutputDevice* pOut, +sal_Int32 SwFont::GetCapitalBreak( SwViewShell const * pSh, const OutputDevice* pOut, const SwScriptInfo* pScript, const OUString& rTxt, long const nTextWidth, const sal_Int32 nIdx, const sal_Int32 nLen ) { diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx index 49a57b7d09f3..ee98443f1e0f 100644 --- a/sw/source/core/txtnode/swfont.cxx +++ b/sw/source/core/txtnode/swfont.cxx @@ -970,7 +970,7 @@ bool SwSubFont::IsSymbol( SwViewShell *pSh ) return aFntAccess.Get()->IsSymbol(); } -bool SwSubFont::ChgFnt( SwViewShell *pSh, OutputDevice& rOut ) +bool SwSubFont::ChgFnt( SwViewShell const *pSh, OutputDevice& rOut ) { if ( pLastFont ) pLastFont->Unlock(); diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx index 59f8234f68cf..818454eb9620 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -121,7 +121,7 @@ SwCharFmt* SwTxtINetFmt::GetCharFmt() if (!rFmt.GetValue().isEmpty()) { - const SwDoc* pDoc = GetTxtNode().GetDoc(); + SwDoc* pDoc = GetTxtNode().GetDoc(); if( !IsVisitedValid() ) { SetVisited( pDoc->IsVisitedURL( rFmt.GetValue() ) ); diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 1c972ed70746..01d3a47320ae 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -31,6 +31,7 @@ #include <IDocumentFieldsAccess.hxx> #include <IDocumentStatistics.hxx> #include <IDocumentStylePoolAccess.hxx> +#include <IDocumentLayoutAccess.hxx> #include <IDocumentState.hxx> #include <hints.hxx> #include <fmtfld.hxx> @@ -2309,7 +2310,13 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, // (has to be already formatted) SwDoc *pDoc = m_pImpl->m_pDoc; SwViewShell *pViewShell = 0; - SwEditShell *pEditShell = pDoc ? pDoc->GetEditShell( &pViewShell ) : 0; + SwEditShell *pEditShell = 0; + if( pDoc ) + { + pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); + pEditShell = pDoc->GetEditShell(); + } + if (pEditShell) pEditShell->CalcLayout(); else if (pViewShell) // a page preview has no SwEditShell it should only have a view shell diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index 517c7ec2f905..b6a7c5f3bfbf 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -30,6 +30,7 @@ #include <ndtxt.hxx> #include <doc.hxx> #include <docsh.hxx> +#include <IDocumentLayoutAccess.hxx> #include <IDocumentStylePoolAccess.hxx> #include <viewsh.hxx> #include <viewimp.hxx> @@ -384,8 +385,7 @@ uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getNextPara() SwTxtNode* pRet = 0; if ( mbAutomatic ) { - SwViewShell* pViewShell = 0; - mpDoc->GetEditShell( &pViewShell ); + SwViewShell* pViewShell = mpDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); SwPageFrm* pCurrentPage = pViewShell ? pViewShell->Imp()->GetFirstVisPage() : 0; SwPageFrm* pStartPage = pCurrentPage; diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 99802a72a1cc..00baf17aad6d 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -39,6 +39,7 @@ #include <shellres.hxx> #include <viewsh.hxx> #include <doc.hxx> +#include <IDocumentLayoutAccess.hxx> #include <docary.hxx> #include <poolfmt.hxx> #include <poolfmt.hrc> @@ -1245,7 +1246,13 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, void lcl_CalcLayout(SwDoc *pDoc) { SwViewShell *pViewShell = 0; - SwEditShell* pEditShell = pDoc ? pDoc->GetEditShell(&pViewShell) : 0; + SwEditShell* pEditShell = 0; + if( pDoc ) + { + pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); + pEditShell = pDoc->GetEditShell(); + } + if (pEditShell) { pEditShell->CalcLayout(); diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx index 8c8032ddc128..636e228b19c8 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -77,6 +77,7 @@ // FOOTNOTES #include "doc.hxx" #include <IDocumentSettingAccess.hxx> +#include <IDocumentLayoutAccess.hxx> #include "swerror.h" #include "charatr.hxx" #include "paratr.hxx" @@ -2250,8 +2251,7 @@ void SwHTMLWriter::OutCSS1_FrmFmtBackground( const SwFrmFmt& rFrmFmt ) if( pDoc->getIDocumentSettingAccess().get(IDocumentSettingAccess::HTML_MODE) || pDoc->getIDocumentSettingAccess().get(IDocumentSettingAccess::BROWSE_MODE)) { - SwViewShell *pVSh = 0; - pDoc->GetEditShell( &pVSh ); + SwViewShell *pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); if ( pVSh && COL_TRANSPARENT != pVSh->GetViewOptions()->GetRetoucheColor().GetColor()) aColor = pVSh->GetViewOptions()->GetRetoucheColor().GetColor(); diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx index 3419ea64bc42..a6555ccb8a68 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -60,6 +60,7 @@ #include <com/sun/star/form/XImageProducerSupplier.hpp> #include <com/sun/star/form/XForm.hpp> #include <doc.hxx> +#include <IDocumentLayoutAccess.hxx> #include <pam.hxx> #include <swtable.hxx> #include <fmtanchr.hxx> @@ -645,8 +646,7 @@ void SwHTMLParser::SetControlSize( const uno::Reference< drawing::XShape >& rSha // das auch vom SwXShape implementiert wird. uno::Reference< beans::XPropertySet > xPropSet( rShape, UNO_QUERY ); - SwViewShell *pVSh; - pDoc->GetEditShell( &pVSh ); + SwViewShell *pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); if( !pVSh && !nEventId ) { // If there is no view shell by now and the doc shell is an internal @@ -664,7 +664,7 @@ void SwHTMLParser::SetControlSize( const uno::Reference< drawing::XShape >& rSha pTempViewFrame = SfxViewFrame::LoadHiddenDocument( *pDocSh, 0 ); CallStartAction(); - pDoc->GetEditShell( &pVSh ); + pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); } } diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx index f478cf719e36..ad1c8ae074fa 100644 --- a/sw/source/filter/html/htmlforw.cxx +++ b/sw/source/filter/html/htmlforw.cxx @@ -54,6 +54,7 @@ #include <viewsh.hxx> #include "pam.hxx" #include "doc.hxx" +#include <IDocumentLayoutAccess.hxx> #include <IDocumentDrawModelAccess.hxx> #include "ndtxt.hxx" #include "flypos.hxx" @@ -671,8 +672,7 @@ const SdrObject *SwHTMLWriter::GetHTMLControl( const SwDrawFrmFmt& rFmt ) static void GetControlSize( const SdrObject& rSdrObj, Size& rSz, SwDoc *pDoc ) { - SwViewShell *pVSh = 0; - pDoc->GetEditShell( &pVSh ); + SwViewShell *pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); if( !pVSh ) return; diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx index 0e027c613b48..1d3ce77c58ea 100644 --- a/sw/source/filter/html/htmltabw.cxx +++ b/sw/source/filter/html/htmltabw.cxx @@ -40,6 +40,7 @@ #include <fmtsrnd.hxx> #include <frmatr.hxx> #include <doc.hxx> +#include <IDocumentLayoutAccess.hxx> #include <pam.hxx> #include <ndtxt.hxx> #include <swrect.hxx> @@ -1111,8 +1112,7 @@ Writer& OutHTML_SwTblNode( Writer& rWrt, SwTableNode & rNode, #ifdef DBG_UTIL { - SwViewShell *pSh; - rWrt.pDoc->GetEditShell( &pSh ); + SwViewShell *pSh = rWrt.pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); if ( pSh && pSh->GetViewOptions()->IsTest1() ) pLayout = 0; } diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 2d701fa8c357..2fb5df48cb07 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -79,6 +79,7 @@ #include <doc.hxx> #include <IDocumentUndoRedo.hxx> #include <IDocumentSettingAccess.hxx> +#include <IDocumentLayoutAccess.hxx> #include <IDocumentLinksAdministration.hxx> #include <IDocumentRedlineAccess.hxx> #include <IDocumentFieldsAccess.hxx> @@ -2543,7 +2544,7 @@ SwViewShell *SwHTMLParser::CallStartAction( SwViewShell *pVSh, bool bChkPtr ) #if OSL_DEBUG_LEVEL > 0 SwViewShell *pOldVSh = pVSh; #endif - pDoc->GetEditShell( &pVSh ); + pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); #if OSL_DEBUG_LEVEL > 0 OSL_ENSURE( !pVSh || !pOldVSh || pOldVSh == pVSh, "CallStartAction: Wer hat die SwViewShell ausgetauscht?" ); if( pOldVSh && !pVSh ) @@ -2567,8 +2568,7 @@ SwViewShell *SwHTMLParser::CallEndAction( bool bChkAction, bool bChkPtr ) { if( bChkPtr ) { - SwViewShell *pVSh = 0; - pDoc->GetEditShell( &pVSh ); + SwViewShell *pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); OSL_ENSURE( !pVSh || pActionViewShell == pVSh, "CallEndAction: Wer hat die SwViewShell ausgetauscht?" ); #if OSL_DEBUG_LEVEL > 0 @@ -2633,8 +2633,7 @@ SwViewShell *SwHTMLParser::CallEndAction( bool bChkAction, bool bChkPtr ) SwViewShell *SwHTMLParser::CheckActionViewShell() { - SwViewShell *pVSh = 0; - pDoc->GetEditShell( &pVSh ); + SwViewShell *pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); OSL_ENSURE( !pVSh || pActionViewShell == pVSh, "CheckActionViewShell: Wer hat die SwViewShell ausgetauscht?" ); #if OSL_DEBUG_LEVEL > 0 diff --git a/sw/source/filter/ww8/docxexportfilter.cxx b/sw/source/filter/ww8/docxexportfilter.cxx index 6696ae0da372..9e3524e85b66 100644 --- a/sw/source/filter/ww8/docxexportfilter.cxx +++ b/sw/source/filter/ww8/docxexportfilter.cxx @@ -25,6 +25,7 @@ #include <editsh.hxx> #include <pam.hxx> #include <unotxdoc.hxx> +#include <IDocumentLayoutAccess.hxx> #include <cppuhelper/implementationentry.hxx> @@ -51,8 +52,7 @@ bool DocxExportFilter::exportDocument() return false; // update layout (if present), for SwWriteTable - SwViewShell* pViewShell = NULL; - pDoc->GetEditShell(&pViewShell); + SwViewShell* pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); if (pViewShell != NULL) pViewShell->CalcLayout(); diff --git a/sw/source/filter/ww8/rtfexportfilter.cxx b/sw/source/filter/ww8/rtfexportfilter.cxx index a683e279f58e..7774a2267e85 100644 --- a/sw/source/filter/ww8/rtfexportfilter.cxx +++ b/sw/source/filter/ww8/rtfexportfilter.cxx @@ -21,6 +21,7 @@ #include <rtfexport.hxx> #include <docsh.hxx> +#include <IDocumentLayoutAccess.hxx> #include <editsh.hxx> #include <unotxdoc.hxx> @@ -60,8 +61,7 @@ sal_Bool RtfExportFilter::filter(const uno::Sequence< beans::PropertyValue >& aD } // fdo#37161 - update layout (if present), for SwWriteTable - SwViewShell* pViewShell = NULL; - pDoc->GetEditShell(&pViewShell); + SwViewShell* pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); if (pViewShell != NULL) pViewShell->CalcLayout(); diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 69689ec4767b..2f720f4af174 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -3414,8 +3414,7 @@ void WW8Export::PrepareStorage() sal_uLong SwWW8Writer::WriteStorage() { // #i34818# - update layout (if present), for SwWriteTable - SwViewShell* pViewShell = NULL; - pDoc->GetEditShell( &pViewShell ); + SwViewShell* pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); if( pViewShell != NULL ) pViewShell->CalcLayout(); diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx index 15ed86ba956c..44781a6cd877 100644 --- a/sw/source/uibase/app/apphdl.cxx +++ b/sw/source/uibase/app/apphdl.cxx @@ -68,6 +68,7 @@ #include <glosdoc.hxx> #include <doc.hxx> #include <IDocumentUndoRedo.hxx> +#include <IDocumentLayoutAccess.hxx> #include <IDocumentFieldsAccess.hxx> #include <cfgitems.hxx> #include <prtopt.hxx> @@ -802,9 +803,8 @@ void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, sal { if( pObjSh->IsA(TYPE(SwDocShell)) ) { - const SwDoc* pDoc = ((SwDocShell*)pObjSh)->GetDoc(); - SwViewShell* pVSh = 0; - pDoc->GetEditShell( &pVSh ); + SwDoc* pDoc = ((SwDocShell*)pObjSh)->GetDoc(); + SwViewShell* pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); if ( pVSh ) pVSh->ChgNumberDigits(); } diff --git a/sw/source/uibase/app/swmodul1.cxx b/sw/source/uibase/app/swmodul1.cxx index 800ec2dce1dc..aaa607cbf7a1 100644 --- a/sw/source/uibase/app/swmodul1.cxx +++ b/sw/source/uibase/app/swmodul1.cxx @@ -621,8 +621,7 @@ void SwModule::CheckSpellChanges( bool bOnlineSpelling, if ( pTmp->getIDocumentLayoutAccess().GetCurrentViewShell() ) { pTmp->SpellItAgainSam( bInvalid, bOnlyWrong, bSmartTags ); - SwViewShell* pViewShell = 0; - pTmp->GetEditShell( &pViewShell ); + SwViewShell* pViewShell = pTmp->getIDocumentLayoutAccess().GetCurrentViewShell(); if ( bSmartTags && pViewShell && pViewShell->GetWin() ) pViewShell->GetWin()->Invalidate(); } |