From 513cbeb409f73108ba1a8455ceb04f8aa03b2b63 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 1 Jul 2010 18:09:48 +0200 Subject: sw33bf06: #i112577#: SwPaM::Find: apply patch by cmc: fix null ViewShell crash --- sw/source/core/crsr/findtxt.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'sw') diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx index 9fd6dd0516e9..4a0697692975 100644 --- a/sw/source/core/crsr/findtxt.cxx +++ b/sw/source/core/crsr/findtxt.cxx @@ -53,8 +53,6 @@ #include #include -#define POSTITMGR ((ViewShell*)pNode->GetDoc()->GetDocShell()->GetWrtShell())->GetPostItMgr() - using namespace ::com::sun::star; using namespace util; @@ -333,9 +331,13 @@ BYTE SwPaM::Find( const SearchOptions& rSearchOpt, BOOL bSearchInNotes , utl::Te } + SwDocShell *const pDocShell = pNode->GetDoc()->GetDocShell(); + ViewShell *const pWrtShell = (pDocShell) ? (ViewShell*)(pDocShell->GetWrtShell()) : 0; + SwPostItMgr *const pPostItMgr = (pWrtShell) ? pWrtShell->GetPostItMgr() : 0; + xub_StrLen aStart = 0; // do we need to finish a note? - if (POSTITMGR->HasActiveSidebarWin()) + if (pPostItMgr && pPostItMgr->HasActiveSidebarWin()) { if (bSearchInNotes) { @@ -347,7 +349,7 @@ BYTE SwPaM::Find( const SearchOptions& rSearchOpt, BOOL bSearchInNotes , utl::Te --aNumberPostits; } //search inside and finsih and put focus back into the doc - if (POSTITMGR->FinishSearchReplace(rSearchOpt,bSrchForward)) + if (pPostItMgr->FinishSearchReplace(rSearchOpt,bSrchForward)) { bFound = true ; break; @@ -355,7 +357,7 @@ BYTE SwPaM::Find( const SearchOptions& rSearchOpt, BOOL bSearchInNotes , utl::Te } else { - POSTITMGR->SetActiveSidebarWin(0); + pPostItMgr->SetActiveSidebarWin(0); } } @@ -391,7 +393,7 @@ BYTE SwPaM::Find( const SearchOptions& rSearchOpt, BOOL bSearchInNotes , utl::Te if ( (bSrchForward && (GetPostIt(aLoop + aIgnore,pHts) < pHts->Count()) ) || ( !bSrchForward && (aLoop!=0) )) { const SwTxtAttr* pTxtAttr = bSrchForward ? (*pHts)[GetPostIt(aLoop+aIgnore,pHts)] : (*pHts)[GetPostIt(aLoop+aIgnore-1,pHts)]; - if ( POSTITMGR->SearchReplace(((SwTxtFld*)pTxtAttr)->GetFld(),rSearchOpt,bSrchForward) ) + if ( pPostItMgr && pPostItMgr->SearchReplace(((SwTxtFld*)pTxtAttr)->GetFld(),rSearchOpt,bSrchForward) ) { bFound = true ; break; -- cgit v1.2.3