#include <inetop.h>
Inheritance diagram for OpAsynchClipartImport:
Public Member Functions | |
OpAsynchClipartImport () | |
~OpAsynchClipartImport () | |
OpAsynchClipartImport destructor. | |
virtual void | Do (OpDescriptor *) |
virtual BOOL | OnIdleEvent () |
| |
virtual void | DoWithParam (OpDescriptor *pOp, OpParam *pAsynchClipartImportParam) |
Performs an asynch clipart import / open depending on the parameters Notes: In case the downloads succeeds, the actual clipart import will be done on the idle loop in order to avoid reentering the import code (potentially messy) in case of multiple symultaneous downloads. | |
virtual BOOL | OnDocChangingMsg (Document *pChangingDoc, DocChangingMsg::DocState State) |
Notifies us if the document we intend to import into is about to be destroyed, in which case we should abort the operation. | |
virtual void | End () |
overwrites Operation::End() to avoid having an ERROR2 (caused by Document::GetSelectedSpread() returning NULL) go off when Webster exits while an asynch clipart import is still in progress | |
Static Public Member Functions | |
static BOOL | Init () |
Creates an OpDescriptor for an AsynchClipartImport operation. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
Returns the OpState of the OpAsynchClipartImport operation. | |
Public Attributes | |
AsynchClipartImportParam * | pParam |
Protected Attributes | |
DOWNLOAD_HANDLE | m_hDownload |
Document * | m_pTargetDoc |
Document * | m_pCurrentSelDoc |
Definition at line 425 of file inetop.h.
|
Definition at line 536 of file inetop.cpp. 00537 { 00538 pParam = NULL; 00539 m_hDownload = 0; 00540 m_pTargetDoc = NULL; 00541 m_pCurrentSelDoc = NULL; 00542 GetApplication()->RegisterIdleProcessor(IDLEPRIORITY_LOW, this); 00543 }
|
|
OpAsynchClipartImport destructor.
Definition at line 560 of file inetop.cpp. 00561 { 00562 GetApplication()->RemoveIdleProcessor(IDLEPRIORITY_LOW, this); 00563 if (pParam) 00564 delete pParam; 00565 }
|
|
Reimplemented from OpClipartImport. Definition at line 653 of file inetop.cpp. 00654 { 00655 ERROR3("OpAsynchClipartImport does not provide a Do() function - Use DoWithParam"); 00656 End(); 00657 }
|
|
Performs an asynch clipart import / open depending on the parameters Notes: In case the downloads succeeds, the actual clipart import will be done on the idle loop in order to avoid reentering the import code (potentially messy) in case of multiple symultaneous downloads.
Reimplemented from OpClipartImport. Definition at line 682 of file inetop.cpp. 00683 { 00684 AsynchClipartImportParam *pInfo = (AsynchClipartImportParam*) pClipartImportParam; 00685 00686 if(pInfo == NULL) 00687 { 00688 ERROR3("OpAsynchClipartImport called with NULL info pointer"); 00689 goto FAIL; 00690 } 00691 else 00692 { 00693 if (!pInfo->File.IsValid() || pInfo->strURL.IsEmpty()) 00694 { 00695 ERROR3("Invalid file path or URL"); 00696 goto FAIL; 00697 } 00698 // Remember the document pointer 00699 m_pTargetDoc = Document::GetSelected(); 00700 m_pCurrentSelDoc = Document::GetSelected(); // target and selected are the same at this stage 00701 // Register the file for download 00702 DOWNLOADINFO downloadInfo; 00703 downloadInfo.strURL = pInfo->strURL; 00704 downloadInfo.strLocalFile = (String_256) pInfo->File.GetPath(); 00705 downloadInfo.nFileType = TYPE_CLIPART; 00706 downloadInfo.nPriority = AsynchDownload::PRIORITY_HIGH; 00707 downloadInfo.strDescription = pInfo->strDescription; 00708 downloadInfo.bHasProgressDlg = TRUE; 00709 downloadInfo.hwndNotifyWindow = 0; 00710 downloadInfo.lNotifyToken = 0; 00711 m_hDownload = InternetManager::RegisterDownload(&downloadInfo); 00712 if (!m_hDownload || m_hDownload == (DOWNLOAD_HANDLE) INVALID_HANDLE_VALUE) 00713 { 00714 ERROR3("Failed to register download"); 00715 goto FAIL; 00716 } 00717 pParam = pInfo; 00718 } 00719 return; 00720 00721 FAIL: 00722 FailAndExecute(); 00723 End(); 00724 }
|
|
overwrites Operation::End() to avoid having an ERROR2 (caused by Document::GetSelectedSpread() returning NULL) go off when Webster exits while an asynch clipart import is still in progress
Reimplemented from SelOperation. Definition at line 744 of file inetop.cpp. 00745 { 00746 if (Document::GetSelectedSpread()) 00747 Operation::End(); 00748 else 00749 EndOp(); 00750 }
|
|
Returns the OpState of the OpAsynchClipartImport operation.
Reimplemented from OpClipartImport. Definition at line 606 of file inetop.cpp. 00607 { 00608 OpState OpSt; 00609 return(OpSt); 00610 }
|
|
Creates an OpDescriptor for an AsynchClipartImport operation.
Reimplemented from OpClipartImport. Definition at line 580 of file inetop.cpp. 00581 { 00582 return RegisterOpDescriptor( 00583 0, // Tool ID 00584 _R(IDS_OPASYNCHCLIPARTIMPORT), // String resource ID 00585 CC_RUNTIME_CLASS(OpAsynchClipartImport), // Runtime class 00586 OPTOKEN_OPASYNCHCLIPARTIMPORT, // Token string 00587 OpAsynchClipartImport::GetState, // GetState function 00588 0, // Help ID 00589 0, // Bubble ID 00590 0, // Resource ID 00591 0 // Control ID 00592 ); 00593 }
|
|
Notifies us if the document we intend to import into is about to be destroyed, in which case we should abort the operation.
Reimplemented from MessageHandler. Definition at line 626 of file inetop.cpp. 00627 { 00628 if (pChangingDoc == m_pTargetDoc && State == DocChangingMsg::ABOUTTODIE) 00629 { 00630 // We end the operation, but don't abort the clipart download - it's up to the user to do that 00631 FailAndExecute(); 00632 End(); 00633 } 00634 return TRUE; 00635 }
|
|
Reimplemented from Operation. Definition at line 771 of file inetop.cpp. 00772 { 00773 ERROR2IF(!pParam, FALSE, "Unexpected NULL pointer"); 00774 switch (InternetManager::GetDownloadState(m_hDownload)) 00775 { 00776 case AsynchDownload::STATE_PENDING: 00777 // download pending, so we continue polling 00778 return TRUE; 00779 00780 case AsynchDownload::STATE_SUCCEEDED: 00781 { 00782 // file has transferred successfully, so we can proceed with a synchronous import/open operation 00783 if (pParam->Import) 00784 { 00785 if (m_pTargetDoc != Document::GetSelected()) 00786 { 00787 m_pCurrentSelDoc = Document::GetSelected(); 00788 Document::SetSelectedViewAndSpread(m_pTargetDoc); 00789 // If the target document is not selected yet we keep on polling until it is 00790 if (m_pTargetDoc != Document::GetSelected()) 00791 return TRUE; 00792 } 00793 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpClipartImport)); 00794 if (pOpDesc != NULL) 00795 { 00796 ClipartImportParam Param; 00797 // Set up the parameters which we require to import the clipart 00798 Param.File = &(pParam->File); 00799 Param.Import = pParam->Import; 00800 Param.Result = TRUE; 00801 if (pParam->bDropped) // if the file has been dropped on the page, get positioning informatiom 00802 Param.DropInfo = &(pParam->DropInfo); 00803 pOpDesc->Invoke((OpParam*) &Param); 00804 BOOL ok = Param.Result; 00805 if (!ok) 00806 { 00807 ERROR3("LibClipartSGallery::ImportClipart - Problem importing file"); 00808 } 00809 } 00810 if (m_pCurrentSelDoc != m_pTargetDoc) 00811 Document::SetSelectedViewAndSpread(m_pCurrentSelDoc); 00812 } 00813 else // open the file as new document 00814 { 00815 CWinApp* pApp = AfxGetApp(); 00816 BaseFileDialog::SelectedFilter = 0; 00817 // Open a document 00818 CCamDoc* pDoc = (CCamDoc*) pApp->OpenDocumentFile((TCHAR*) String_256(pParam->File.GetPath())); 00819 // And redraw the imported document 00820 if(pDoc) pDoc->GetKernelDoc()->ForceRedraw(); 00821 } 00822 if (LibFillsSGallery::ThisGallery) 00823 LibFillsSGallery::ThisGallery->SelectionHasChanged(); 00824 SucceedAndDiscard(); 00825 End(); 00826 return FALSE; 00827 } 00828 00829 case AsynchDownload::STATE_FAILED: 00830 { 00831 String_256 strTemp; 00832 strTemp.MakeMsg(_R(IDS_DOWNLOADFAILED), (TCHAR*) (String_256) GetStringField((UINT32) SGLib_ClipArt, _R(IDS_GALLERY_DESCRIPTIONS)), (TCHAR*) pParam->strDescription); 00833 Error::SetError(0, strTemp, 0); 00834 InformError(); 00835 goto FAIL; 00836 } 00837 00838 case AsynchDownload::STATE_ABORTED: 00839 { 00840 // no errror message as this state is the result of a user cancel 00841 goto FAIL; 00842 } 00843 00844 default: 00845 ERROR3("Error or unrecognized state"); 00846 goto FAIL; 00847 } 00848 00849 FAIL: 00850 FailAndDiscard(); 00851 End(); 00852 return FALSE; 00853 }
|
|
|
|
|
|
|
|
|