// this is called after each stage of processing, in order to (if appropriate) // copy the file from the temp directory to a user-designated location, and // to change the result-stream that is shown to this new file, rather than to // the original. The benefit of that step is so that if the user asks for the // file to be opened externally, the correct copy of the file is opened (not the // one in the temp directory). // nGoal is the users's goal // nStage is the stage that we just finished (e.g. CProcessingPrefs::kSourceAna) void CInputDoc::redirectOutputFile(int nGoal, int nStage, CPathDescriptor &originalOutPath, CPathDescriptor &newPath, CProcessStatus *pStatus) { // if we do have this flag kLeaveNonGoalsInTemp set, then only // continue if this stage is our final goal if((getProcessingPrefs()->m_dwFlags & CProcessingPrefs::kLeaveNonGoalsInTemp) && nGoal!=nStage) return; originalOutPath.copyTo(newPath); // now find the matching result stream and change it to point to this new copy int nCount = m_pProcessStatus->m_pResultStreams.GetSize(); for(int i=nCount-1; i >=0; i--) { CResultStream* p = m_pProcessStatus->m_pResultStreams.ElementAt(i); ASSERT(p); if(p->IsKindOf(RUNTIME_CLASS(CResultStreamFile))) { CResultStreamFile* pf = (CResultStreamFile*)p; if( pf->getPath() == originalOutPath) { pf->setPath(newPath); break; } } } }
// this function is called when each chunk is completed (so we can check the imported data // for any of our various error conditions (and use error icons if needed). DWORD CInputDocView::OnStreamInChunkComplete ( AsyncLoadRichEditCtrl* pCtrl, DWORD_PTR dwCookie, LPCTSTR szBuff ) { CInputDocView* pView = (CInputDocView*)dwCookie; // first of all, see if there was one of our error codes. LONG iTabIndex = ::GetWindowLong(pCtrl->GetSafeHwnd(), GWL_USERDATA); TC_ITEM tie; tie.mask = TCIF_PARAM; pView->m_tabCtrl.GetItem(iTabIndex,&tie); CResultStreamFile* pStream = (CResultStreamFile*)tie.lParam; if( !pStream ) { ASSERT(false); return -1; } if( pStream->IsError(szBuff) ) { switch( pStream->m_eTabLoadingIcon ) { case CResultStream::kLoadingErrorIcon1: pStream->m_eTabLoadingIcon = CResultStream::kLoadingErrorIcon2; break; case CResultStream::kLoadingErrorIcon2: pStream->m_eTabLoadingIcon = CResultStream::kLoadingErrorIcon3; break; case CResultStream::kLoadingIcon1: case CResultStream::kLoadingIcon2: case CResultStream::kLoadingIcon3: case CResultStream::kLoadingErrorIcon3: pStream->m_eTabLoadingIcon = CResultStream::kLoadingErrorIcon1; break; }; } else { switch( pStream->m_eTabLoadingIcon ) { case CResultStream::kLoadingIcon1: pStream->m_eTabLoadingIcon = CResultStream::kLoadingIcon2; break; case CResultStream::kLoadingIcon2: pStream->m_eTabLoadingIcon = CResultStream::kLoadingIcon3; break; case CResultStream::kLoadingIcon3: pStream->m_eTabLoadingIcon = CResultStream::kLoadingIcon1; break; }; } tie.mask = TCIF_IMAGE; tie.iImage = pStream->m_eTabLoadingIcon; pView->m_tabCtrl.SetItem(iTabIndex,&tie); // must invalidate the current tab so *it* get's repainted (after SetItem above, it goes away). pView->InvalidateCurTab(); return 0; }
void CInputDocView::addPanel(CResultStream* pStream, int id) #endif { CRect r;//(0,0, 100, 100); GetClientRect(&r); #ifndef rde270 // change the dimensions a little so we don't get the annoying non-repaint of m_tabCtrl // when we repaint the RECtrl after a chunk has been loaded offline. r.top = 21; AsyncLoadRichEditCtrl* pEC = new AsyncLoadRichEditCtrl; #else // rde270 r.top = 25; r.right -= 5; r.bottom -= 5; CRichEditCtrl* pEC = new CRichEditCtrl;//CPanelRichEditCtrl;// #endif // CEdit* pEC = new CEdit; m_pEditCtrls.Add(pEC); DWORD dwFlags = ECO_SAVESEL | ES_AUTOVSCROLL | ES_MULTILINE | ES_NOHIDESEL | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_VISIBLE | ES_WANTRETURN; #ifndef jdhhab621 // a hack to get a scrollbar for pc-patr. This could be generalized or put in the user's // control, but not without work that seems unjustified if it's just for pcpatr. if (pStream->getDescriptor()->getTabLabel().Find(_T("PATR")) != -1) dwFlags |= WS_HSCROLL | ES_AUTOHSCROLL; #endif // jdhhab261 pEC->Create(dwFlags, (RECT&)r, &m_tabCtrl, id); CFont* test = pStream->getFont(); pEC->SetFont(test); #ifndef rde270 // delay StreamIn until after setting up of the associated tab (because during StreamIn // our callback must have the pStream which is stored in the tab's lParam member. #else // rde270 // NOTE: I'm not clear on whether StreamIn is done with the stream when it returns; // it doesn't seem to delete it, but you'd think it would need // to keep it around so it can get at large files when the user // scrolls down; maybe not. Why it matters is, what if the cwCOOKIE // member points to a CResultsStream that I've deleted? // For now, I'm going to go on the assumption that the whole // file is read right here. pEC->StreamIn(SF_TEXT, pStream->getEditStreamIn()); // icon may be set in here // Set editing flags and limit CInputDoc* pDoc = (CInputDoc*) GetDocument(); if(id==kBasePanelID && pDoc->m_bBaseIsEditable) { pEC->SetReadOnly(FALSE); const long kMaxAddableChars = 2000; long l = pEC->GetTextLength() + kMaxAddableChars; pEC->LimitText(l); pEC->SetEventMask( ENM_KEYEVENTS| ENM_CHANGE );// want to know when the user changes something } else pEC->SetReadOnly(TRUE); #endif // rde270 /* ALL THIS WAS FOR CEDIT, NOT CRICHEDIT EDITSTREAM es = pStream->getEditStreamIn(); long sz = pEC->GetLimitText()-10; LPTSTR buff = new char [sz+1]; ASSERTX(buff); long actual; (es.pfnCallback)((DWORD)(pStream), (unsigned char*)buff, sz, &actual); buff[actual] = '\0'; CString sOverflowMsg = pStream->getOverflowMsg(); if(actual > sz - sOverflowMsg.GetLength()) { buff[sz-sOverflowMsg.GetLength()] = '\0'; CString s = buff; s += sOverflowMsg; pEC->SetWindowText(s); } else pEC->SetWindowText(buff); // make it close (es.pfnCallback)((DWORD)(pStream), (unsigned char*)buff, 0, &actual); delete buff; */ // make the tab for this item TC_ITEM tie; tie.mask = TCIF_TEXT |TCIF_PARAM ; tie.lParam = (LPARAM)pStream; tie.pszText = (LPTSTR) LPCTSTR(pStream->getDescriptor()->getTabLabel()); int iconEnum = pStream->getTabIconEnum(); if(iconEnum>=0) { tie.mask |= TCIF_IMAGE; tie.iImage = iconEnum; } #ifndef rde270 // save the inserted tab's index (so it can be accessed by knowing the EC). int nIndex = m_tabCtrl.InsertItem(99, &tie ); ::SetWindowLong(pEC->GetSafeHwnd(),GWL_USERDATA,nIndex); if( -1 == nIndex ) #else // rde270 if (-1 == m_tabCtrl.InsertItem(99, &tie )) #endif // rde270 { ASSERTX(FALSE); } else { //CToolTipCtrl* pTip = new CToolTipCtrl; //pTip->Create(this); // <--- or should it be the tab bar? //pTip-> CToolTipCtrl* pTip = m_tabCtrl.GetToolTips(); ASSERT(pTip); CRect r; m_tabCtrl.GetItemRect(m_tabCtrl.GetItemCount()-1, &r); CString s; s.Format(_T("%s"), (LPCTSTR)pStream->getToolTipText()); pTip->AddTool(&m_tabCtrl, s, &r, id); } #ifndef rde270 // moved 'StreamIn' here because we want the tab already setup for when we get the // 'finished-a-chunk' callback. // use the 'AsyncLoadRichEdit' to stream it in [load asynchronously so we don't kill // the UI for minutes (on big files).] #pragma message("If you subclass CResultStream with something besides CResultStreamFile, this'll break!") CResultStreamFile* pStreamFile = (CResultStreamFile*)pStream; // ASSERT(pStreamFile->IsKindOf(RUNTIME_CLASS(CResultStreamFile))); // this assert is what *should* be, but the various streams are from the processor DLLs // and for some reason IsKindOf doesn't appear to work across DLL boundaries. pEC->StreamIn(pStreamFile->getPath(), bSyncStreamIn, CInputDocView::OnStreamInChunkComplete, (DWORD_PTR)this); // Set editing flags and limit CInputDoc* pDoc = (CInputDoc*) GetDocument(); if(id==kBasePanelID && pDoc->m_bBaseIsEditable) { pEC->SetReadOnly(FALSE); const long kMaxAddableChars = 2000; long l = pEC->GetTextLength() + kMaxAddableChars; pEC->LimitText(l); pEC->SetEventMask( ENM_KEYEVENTS| ENM_CHANGE );// want to know when the user changes something // if the editable file was imported as UTF-16, then we must make it 'modified' so // it'll be saved as UTF-8 before processing (Ample, et al., can deal with UTF-8, // but not UTF-16). if( (pEC->FileEncoding() != eUTF8) && (pEC->FileEncoding() != eAnsi) ) GetDocument()->SetModifiedFlag(); } else pEC->SetReadOnly(TRUE); #endif // rde270 }