Commits

Anonymous committed dbcc975

sw33bf06: #i112577#: SwPaM::Find: apply patch by cmc: fix null ViewShell crash

  • Participants
  • Parent commits c4368c2

Comments (0)

Files changed (1)

File sw/source/core/crsr/findtxt.cxx

 #include <viewsh.hxx>
 #include <vcl/window.hxx>
 
-#define POSTITMGR ((ViewShell*)pNode->GetDoc()->GetDocShell()->GetWrtShell())->GetPostItMgr()
-
 using namespace ::com::sun::star;
 using namespace util;
 
 
 			}
 
+            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)
 				{
 							--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;
 				}
 				else
 				{
-                    POSTITMGR->SetActiveSidebarWin(0);
+                    pPostItMgr->SetActiveSidebarWin(0);
 				}
 			}
 
 						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;