#include <impexpop.h>
Inheritance diagram for OpDroppedFile:
Public Member Functions | |
void | DoWithParam (OpDescriptor *, OpParam *) |
This function should be over-ridden to perform an operation which requires parameters. | |
virtual BOOL | MayChangeNodeBounds () const |
Static Public Member Functions | |
static BOOL | Init () |
Declares op descriptor for drag'n'drop file operation. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
This item is always available, so long as a document is visible. |
Definition at line 290 of file impexpop.h.
|
This function should be over-ridden to perform an operation which requires parameters.
Reimplemented from Operation. Definition at line 1784 of file impexpop.cpp. 01785 { 01786 // Get the file list 01787 FileDropInfo* pFileInfo = (FileDropInfo*) pOpParam; 01788 List* pFileList = pFileInfo->GetFileList(); 01789 01790 #ifdef XAR_TREE_DIALOG 01791 CXFTreeDlg* pCXFTreeDlg = CXFTreeDlg::GetCurrentCXFTreeDlg(); 01792 if (pCXFTreeDlg != 0) 01793 { 01794 StringListItem* pItem = (StringListItem*)(pFileList->GetHead()); 01795 if (pItem) 01796 pCXFTreeDlg->ShowFile((TCHAR*)(pItem->GetString())); 01797 01798 End(); 01799 return; 01800 } 01801 #endif 01802 01803 #if FALSE 01804 #if _DEBUG 01805 CMXTreeDlg* pCMXTreeDlg = CMXTreeDlg::GetCurrentCMXTreeDlg(); 01806 if (pCMXTreeDlg != 0) 01807 { 01808 char PathBuf[PATH_BUF_SIZE]; 01809 PathBuf[0] = 0; 01810 01811 // Get the next filename 01812 UINT32 cBytes = DragQueryFile(hDrop, 0, PathBuf, PATH_BUF_SIZE); 01813 01814 pCMXTreeDlg->ShowFile(PathBuf); 01815 01816 End(); 01817 return; 01818 } 01819 #endif 01820 #endif 01821 // Make sure we have a generic filter! 01822 GenericFilter *pGenericFilter = Filter::GetGenericFilter(); 01823 01824 if (pGenericFilter == 0) 01825 { 01826 InformError(_R(IDT_CANT_FIND_FILTER)); 01827 FailAndExecute(); 01828 End(); 01829 return; 01830 } 01831 01832 // Get me a DocView! 01833 DocView *pDocView = DocView::GetCurrent(); 01834 // Sanity checks... 01835 if (pDocView == 0) 01836 { 01837 ERROR3("No current DocView while procesing drag'n'drop!"); 01838 // give the user a random error, should never happen but just in case give them some 01839 // indication that something has gone wrong. 01840 InformError(_R(IDT_CANT_FIND_FILTER)); 01841 FailAndExecute(); 01842 End(); 01843 // Exit cleanly 01844 return; 01845 } 01846 01847 // Find out where the files were dropped... 01848 WinCoord DropPoint = pFileInfo->GetDropPoint(); 01849 // DragQueryPoint(hDrop, &DropPoint); 01850 01851 // Turn this into Oil coordinates... 01852 OilCoord OilPos = DropPoint.ToOil(pDocView); 01853 01854 // ...find the spread in which the click happened... 01855 ImportPosition Pos; 01856 01857 Pos.pSpread = pDocView->FindEnclosingSpread(OilPos); 01858 if (Pos.pSpread == 0) 01859 { 01860 ERROR3("Could not find spread in which the drag'n'drop happened"); 01861 // give the user a random error, should never happen but just in case give them some 01862 // indication that something has gone wrong. 01863 InformError(_R(IDT_CANT_FIND_FILTER)); 01864 FailAndExecute(); 01865 End(); 01866 return; // Exit reasonably nicely 01867 } 01868 01869 // First of all convert the OilCoord into device coords 01870 Pos.Position = OilPos.ToDoc(Pos.pSpread, pDocView); 01871 01872 // Translate the coord to spread coords 01873 Pos.pSpread->DocCoordToSpreadCoord(&Pos.Position); 01874 01875 // Find out how many files were dropped 01876 // UINT32 cFiles = DragQueryFile(hDrop, (UINT32) -1, 0, 0); 01877 UINT32 cFiles = pFileList->GetCount(); 01878 01879 StringListItem* pItem = (StringListItem*)(pFileList->GetHead()); 01880 01881 // Load each file in turn... 01882 for (UINT32 iFile = 0; iFile < cFiles; iFile++) 01883 { 01884 // char PathBuf[PATH_BUF_SIZE]; 01885 // PathBuf[0] = 0; 01886 01887 // Get the next filename 01888 // UINT32 cBytes = DragQueryFile(hDrop, iFile, PathBuf, PATH_BUF_SIZE); 01889 01890 String_256 Str = pItem->GetString(); 01891 01892 // Check it's not too long 01893 // if (cBytes > (PATH_BUF_SIZE - 5)) 01894 // { 01895 // // Too long - inform user and try the next file. 01896 // Error::SetError(_R(IDT_FILENAME_TOO_LONG)); 01897 // InformError(); 01898 // } 01899 // else 01900 { 01901 // Import this file... 01902 // PathName Path(PathBuf); 01903 PathName Path(Str); 01904 // Ensure that the path is valid 01905 if ( !Path.IsValid() ) 01906 { 01907 // Pathname specified is invalid 01908 InformError(); 01909 FailAndExecute(); 01910 End(); 01911 return; 01912 } 01913 01914 // First off, we have to try and open the file 01915 CCDiskFile DiskFile(1024, FALSE, TRUE); 01916 01917 // Get pointer to current doc 'cos we'll need it several times... 01918 Document* pCurDoc = Document::GetCurrent(); 01919 01920 try 01921 { 01922 if (!DiskFile.open(Path, ios::in | ios::binary)) 01923 { 01924 // Failed to open the file... 01925 TRACEUSER( "Rik", _T("Failed to open file in MenuImport Do")); 01926 InformError(_R(IDT_IMPORT_NOTFOUND)); 01927 FailAndExecute(); 01928 End(); 01929 return; 01930 } 01931 01932 // Import the file and see if Something went a bit wrong - tell the user what it was. 01933 if (!pGenericFilter->DoImport(this, &DiskFile, pCurDoc, FALSE, &Pos)) 01934 { 01935 // Something went a bit wrong - tell the user what it was. 01936 // Only tell them if not special user cancelled error message 01937 if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED)) 01938 InformError(); 01939 else 01940 Error::ClearError(); // otherwise remove the error so it won't get reported 01941 FailAndExecute(); 01942 End(); 01943 01944 // Close the file again 01945 if (DiskFile.isOpen()) 01946 DiskFile.close(); 01947 01948 return; 01949 } 01950 01951 // Close the file again 01952 if (DiskFile.isOpen()) 01953 DiskFile.close(); 01954 01955 } 01956 01957 // See if there was a file io error 01958 catch(CFileException e) 01959 { 01960 // Report the error if no one else did 01961 if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED)) 01962 InformError(); 01963 else 01964 Error::ClearError(); // otherwise remove the error so it won't get reported 01965 01966 // Make sure that the file is closed 01967 try 01968 { 01969 if (DiskFile.isOpen()) 01970 DiskFile.close(); 01971 } 01972 catch(CFileException e) 01973 { 01974 // Failed to close the file - not much we can do about it really 01975 } 01976 01977 // and fail 01978 FailAndExecute(); 01979 01980 } 01981 } 01982 01983 // Get the next file name item 01984 pItem = (StringListItem*)(pFileList->GetNext(pItem)); 01985 } 01986 01987 // Finished the operation 01988 End(); 01989 01990 return; 01991 }
|
|
This item is always available, so long as a document is visible.
Definition at line 2005 of file impexpop.cpp. 02006 { 02007 OpState OpSt; 02008 02009 return OpSt; 02010 }
|
|
Declares op descriptor for drag'n'drop file operation.
Reimplemented from SimpleCCObject. Definition at line 1753 of file impexpop.cpp. 01754 { 01755 if (!RegisterOpDescriptor(0, 01756 _R(IDT_IMPORT), 01757 CC_RUNTIME_CLASS(OpDroppedFile), 01758 OPTOKEN_DROPPEDFILE, 01759 GetState, 01760 0, // help ID 01761 0, 01762 0)) // bitmap ID 01763 return FALSE; 01764 01765 return TRUE; 01766 }
|
|
Reimplemented from SelOperation. Definition at line 301 of file impexpop.h. 00301 { return FALSE; }
|