#include <impexpop.h>
Inheritance diagram for OpMenuExport:
Public Member Functions | |
void | Do (OpDescriptor *) |
Exports a file from the current document. Most of the work is now done by the DoWithParam. | |
void | DoWithParam (OpDescriptor *, OpParam *) |
Exports a file from the current document. | |
Static Public Member Functions | |
static BOOL | Init () |
Declares op descriptor for export operation. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
This item is always available, so long as a document is visible. | |
static void | SaveSelection () |
Saves the selection so it can be restored. | |
static void | NormaliseSelection () |
Fixes-up the selection for compound objects. | |
static void | RestoreSelection () |
Restores the selection given in m_pSelNodeList. | |
Static Public Attributes | |
static String_256 | DefaultExportFilterPath |
Protected Member Functions | |
void | CreateNamedSet (Filter *pFilter, const PathName &pthTarget) |
Creates a named export set from the selected objects and the export information passed to it. | |
BOOL | SetBitmapName (KernelBitmap *pTheBitmap, String_256 *DefaultName, BitmapExportParam *pExportParam=0) |
Interegates the bitmap for its name and dumps this into the given string. If there is an extension on the bitmap name then it will fix this to be correct for the filter that will be selected. If there is no extension then it will just append the correct extension onto the name. | |
Private Member Functions | |
CC_DECLARE_DYNCREATE (OpMenuExport) | |
Private Attributes | |
TCHAR * | FilterString |
Static Private Attributes | |
static UINT32 | SelectedFilterID = FILTERID_EXPORT_JPEG |
static INT32 | SelectedFilter = -1 |
static UINT32 | DefaultBitmapFilterID = FILTERID_EXPORT_JPEG |
static INT32 | SelectedBitmapFilter = -1 |
static List * | m_pSelNodeList = 0 |
Definition at line 212 of file impexpop.h.
|
|
|
Creates a named export set from the selected objects and the export information passed to it.
Definition at line 1504 of file impexpop.cpp. 01505 { 01506 PORTNOTETRACE("other", "CreateNamedSet - Do nothing - Use NgScan"); 01507 #if !defined(EXCLUDE_FROM_XARALX) 01508 // Try to create a named set for them based on the filename chosen. 01509 String_256 strName(pthTarget.GetFileName(FALSE)); 01510 NodeSetSentinel* pSentry = GetWorkingDoc()->GetSetSentinel(); 01511 NodeSetProperty* pSet = pSentry->FindPropertyNode(strName); 01512 01513 // This code used to first check if a set of that the name & path existed with the 01514 // same type, then if it could find such a set it would reuse it rather than creating 01515 // a new set (w/ a unique name). I have changed this so the type of the export does 01516 // not matter any more (Jonathan 2 January 2001). 01517 BOOL fMustCreateNewSet = TRUE; 01518 if (pSet != 0) 01519 { 01520 NamedExportProp* pProp = 01521 (NamedExportProp*) pSet->GetProperty(NamedExportProp::nIndex); 01522 if (/* pProp->GetFilter() != pFilter || */ 01523 pProp->GetPath().GetLocation() != pthTarget.GetLocation() || 01524 pProp->GetPath().GetFileName(FALSE) != pthTarget.GetFileName(FALSE)) 01525 { 01526 // Make the set name unique by appending ascending numerals. 01527 String_256 strBase = strName; 01528 INT32 nAppend = 2; 01529 while (pSentry->GetNameAttr(strName) != 0) 01530 strName.MakeMsg(_R(IDS_NAMEDLG_UNIQUE_MASK), &strBase, nAppend++); 01531 } 01532 else 01533 // Same name & same path - it must be the existing set that is 01534 // being referred to so don't make a new one, just update the properties of 01535 // the one that exists (used to include filter type when checking to see if 01536 // we can reuse the existing name but not any more). 01537 fMustCreateNewSet = FALSE; 01538 } 01539 01540 // If necessary, create a new named set of the selected objects. 01541 if (fMustCreateNewSet) 01542 { 01543 TRACEUSER( "JustinF", _T("Creating export set %s\n"), (LPCTSTR) strName); 01544 01545 // This is taken from the implementation of OpApplyNameToSel. 01546 AllowOpScan aosSel(this, &theSelectedObjects), 01547 aosSentinel(this, &theSetSentinel); 01548 01549 if (!aosSel.Scan() || 01550 !aosSentinel.Scan() || 01551 !DoStartSelOp(FALSE, FALSE) || 01552 !ApplySingleScan(this, &theSelectedObjects, strName).Scan() || 01553 !ApplySingleScan(this, &theSetSentinel, strName).Scan() || 01554 !ApplyPropScan(this, strName).Scan() || 01555 !aosSel.Update() || 01556 !aosSentinel.Update() || 01557 (pSet = pSentry->FindPropertyNode(strName)) == 0) 01558 { 01559 TRACEUSER( "JustinF", _T("OpMenuExport::CreateNamedSet: naming scan failed\n")); 01560 FailAndExecute(); 01561 return; 01562 } 01563 } 01564 01565 // Remember the export filter and the path to the target. 01566 NamedExportProp* pProp = 01567 (NamedExportProp*) pSet->GetProperty(NamedExportProp::nIndex); 01568 ERROR3IF(pProp == 0, "OpMenuExport::CreateNamedSet: no export property"); 01569 01570 pProp->SetFilter(pFilter); 01571 pProp->SetPath(pthTarget); 01572 pProp->SetDirty(); // Since the user has picked the graphic type it has been toutched and so in NOT a virgin 01573 01574 // Remember the options associated with the filter. 01575 // TODO: fix this one day so that all filters are supported. 01576 ERROR3IF(!pFilter->IS_KIND_OF(BaseBitmapFilter), 01577 "OpMenuExport::CreateNamedSet: not a bitmap filter"); 01578 BitmapExportOptions* pOptions = 01579 ((BaseBitmapFilter*) pFilter)->GetBitmapExportOptions(); 01580 pProp->SetOptions(pOptions); 01581 #endif 01582 }
|
|
Exports a file from the current document. Most of the work is now done by the DoWithParam.
Reimplemented from Operation. Definition at line 725 of file impexpop.cpp. 00726 { 00727 DoWithParam(OpDesc, 0); 00728 }
|
|
Exports a file from the current document.
Reimplemented from Operation. Definition at line 864 of file impexpop.cpp. 00865 { 00866 // DMc - need to do this so that compound nodes are treated appropriately 00867 SaveSelection(); 00868 NormaliseSelection(); 00869 00870 //Webster-Ranbirr-12\11\96 00871 #ifdef WEBSTER 00872 // Temp. variable to store the filter type. 00873 INT32 BitmapFilter = 0; 00874 #endif //webster 00875 00876 // zero is a bad state for this to be in so ensure its not in that state 00877 if (SelectedFilter == 0) SelectedFilter = -1; 00878 if (SelectedBitmapFilter == 0) SelectedBitmapFilter = -1; 00879 00880 ERROR3IF(pParam != 0 && !pParam->IS_KIND_OF(BitmapExportParam), 00881 "OpMenuExport::DoWithParam: OpParam passed is not a BitmapExportParam"); 00882 00883 // Check whether a parameter has been specified 00884 UINT32 Bpp = 0; 00885 BitmapExportParam* pExportParam = (BitmapExportParam*) pParam; 00886 if (pExportParam != 0) 00887 { 00888 // At present, this is only used to export the specifed bitmap so use a list 00889 // of bitmap filters. We need to limit the bitmap filters to ones that can support 00890 // the colour depth of the specified bitmap. 00891 // Recover the bitmap pointer from the parameter passed in 00892 KernelBitmap* pTheBitmap; 00893 if (pExportParam->GetBitmapCount() == 0 || 00894 (pTheBitmap = pExportParam->GetBitmap(0)) == 0) 00895 { 00896 ERROR2RAW("OpMenuExport::DoWithParam: no bitmaps, or null pointer"); 00897 FailAndExecute(); 00898 RestoreSelection(); 00899 End(); 00900 return; 00901 } 00902 00903 // If it is a 32 bpp bitmap then we do a conversion to 24. So really we should ask 00904 // the filters whether they like 24bpp files. Otherwise, just the BMP filter will say 00905 // yes. 00906 Bpp = pTheBitmap->GetBPP(); 00907 // if (Bpp == 32) Bpp = 24; 00908 00909 //Webster-Ranbirr-12\11\96 00910 /* #ifndef WEBSTER 00911 FilterString = BaseFileDialog::BuildFilterString( 00912 FALSE, 00913 DefaultBitmapFilterID, 00914 &SelectedBitmapFilter, 00915 CC_RUNTIME_CLASS(BitmapFilter), 00916 Bpp, 00917 pExportParam->GetBitmapCount()); 00918 #else 00919 */ // Save a reference to the last selected Filter, in case Cancel is entered. 00920 //BitmapFilter = SelectedBitmapFilter; 00921 00922 // Is this bitmap a compressed JPEG? 00923 BitmapSource* pSource = 0; 00924 BaseBitmapFilter* pDummyFilter; 00925 00926 BOOL OriginalSourcePresent = pTheBitmap->GetOriginalSource(&pSource,&pDummyFilter); 00927 if (OriginalSourcePresent) 00928 { 00929 DefaultBitmapFilterID = FILTERID_EXPORT_JPEG; 00930 SelectedBitmapFilter = 0; //FILTER_JPEG; 00931 } 00932 else 00933 { 00934 00935 } 00936 00937 FilterString = BaseFileDialog::BuildFilterString( 00938 FALSE, 00939 DefaultBitmapFilterID, 00940 &SelectedBitmapFilter, 00941 CC_RUNTIME_CLASS(BitmapFilter), 00942 Bpp, 00943 pExportParam->GetBitmapCount()); 00944 // #endif //webster 00945 } 00946 else 00947 { 00948 // Get the list of export filters using all filters available 00949 FilterString = BaseFileDialog::BuildFilterString( 00950 FALSE, 00951 SelectedFilterID, 00952 &SelectedFilter); 00953 } 00954 00955 if (FilterString == 0) 00956 { 00957 // Unable to build filter string - report error and finish operation. 00958 InformError(); 00959 FailAndExecute(); 00960 00961 // Finished the operation 00962 RestoreSelection(); 00963 End(); 00964 return; 00965 } 00966 00967 // Create the dialog box 00968 ExportFileDialog FDialog(FilterString); 00969 INT32 TheSelectedFilter = -1; 00970 String_256 DefaultName; 00971 00972 FDialog.SetTitle(_R(IDT_EXPORT_TITLE)); 00973 00974 // Note this ptr for use in JPEG export. 00975 // KernelBitmap* pBitmap = pExportParam->GetBitmap(0); 00976 // JPEGExportOptions::SetKernelBitmap(pBitmap); 00977 00978 if (pExportParam == 0) 00979 TheSelectedFilter = SelectedFilter; // Using all available filters 00980 else 00981 { 00982 // Exporting as a bitmap so fill in the name of the bitmap 00983 KernelBitmap* pTheBitmap = pExportParam->GetBitmap(0); 00984 00985 if (pTheBitmap->ActualBitmap) 00986 DefaultName = pTheBitmap->ActualBitmap->GetName(); 00987 else 00988 SetBitmapName(pTheBitmap, &DefaultName, pExportParam); 00989 00990 // Pass this name onto the dialog box 00991 FDialog.SetDefaultFileName(DefaultName); 00992 FDialog.ExportABitmap(TRUE, pTheBitmap); 00993 00994 // Now work out the selected index, if there is one 00995 TheSelectedFilter = SelectedBitmapFilter; 00996 } 00997 00998 // Select the desired filter, if the default i.e. -1 then set 1 as this is the first valid index. 00999 FDialog.SetSelectedFilterIndex(TheSelectedFilter != -1 ? TheSelectedFilter : 1); 01000 01001 // Select the desired path 01002 if (DefaultExportFilterPath.Length() > 0) 01003 FDialog.SetInitialDirectory(DefaultExportFilterPath); 01004 01005 // We maybe asking uses to specify a file name more than 01006 // once if theie first guess already exists 01007 PathName Path; 01008 Filter* pFilter; 01009 do 01010 { 01011 // 'Do' the dialog and get that filename that we require 01012 BOOL DlgResult = FDialog.OpenAndGetFileName(); 01013 if (!DlgResult) 01014 { 01015 //Webster-Ranbirr-12\11\96 01016 #ifdef WEBSTER 01017 // If cancel is entered then ensure that our filter 01018 // is set to the previous selected filter. 01019 SelectedBitmapFilter = BitmapFilter; 01020 #endif //webster 01021 01022 CCFree(FilterString); 01023 FilterString = 0; 01024 RestoreSelection(); 01025 End(); 01026 return; 01027 } 01028 01029 // Remember the filter for next time. 01030 TheSelectedFilter = FDialog.GetSelectedFilterIndex(); 01031 if (pExportParam == 0) 01032 SelectedFilter = TheSelectedFilter; // Using all available filters 01033 else 01034 SelectedBitmapFilter = TheSelectedFilter; // Exporting as a bitmap only 01035 01036 // Get the filename. 01037 FDialog.GetChosenFileName(&Path); 01038 01039 // Find the filter that the user chose 01040 for (pFilter = Filter::GetFirst(); 01041 pFilter != 0; 01042 pFilter = Filter::GetNext(pFilter)) 01043 { 01044 if( NULL == pFilter->pOILFilter ) 01045 continue; 01046 01047 if (pFilter->GetFlags().CanExport && 01048 pFilter->pOILFilter->Position == TheSelectedFilter) 01049 // This is the filter! 01050 break; 01051 } 01052 01053 if (pFilter == 0) 01054 { 01055 InformError(_R(IDT_CANT_FIND_FILTER)); 01056 01057 // Get rid of the filter string buffer 01058 CCFree(FilterString); 01059 FilterString = 0; 01060 RestoreSelection(); 01061 FailAndExecute(); 01062 End(); 01063 return; 01064 } 01065 01066 // This is now taken care of in FileDlgs.cpp on the ok as it then checks if the file 01067 // exists or not. If we do it here then this does not happen. 01068 // Unfortunately, chnages made to the string in the dialog do not filter through 01069 // and so we must fix it up here as well. 01070 // Always make sure that the filter's default extension is on if the user has not 01071 // specified an extension. 01072 // Get the OILFilter class to check the extension for the selected or default filter 01073 // matches 01074 if (!pFilter->pOILFilter->DoesExtensionOfPathNameMatch(&Path)) 01075 { 01076 // Extension is either blank or does not match the one supplied by the filter 01077 // Ask the OILFilter class to fix it for us 01078 pFilter->pOILFilter->FixExtensionOfPathName(&Path); 01079 } 01080 01081 // Ensure that the path is valid 01082 if (!Path.IsValid()) 01083 { 01084 InformError(); 01085 01086 // Get rid of the filter string buffer 01087 CCFree(FilterString); 01088 FilterString = 0; 01089 FailAndExecute(); 01090 RestoreSelection(); 01091 End(); 01092 return; 01093 } 01094 01095 // We must manually check the file doesn't exit here 01096 if( SGLibOil::FileExists( &Path ) ) 01097 { 01098 ErrorInfo Info; 01099 Info.ErrorMsg = _R(IDS_SAVEAS_OVERWRITE); 01100 Info.Button[0] = _R(IDS_OVERWRITE); 01101 Info.Button[1] = _R(IDB_SAVEAS); 01102 Info.Button[2] = _R(IDS_CANCEL); 01103 01104 UINT32 Answer = AskQuestion(&Info); 01105 01106 if (Answer==_R(IDS_OVERWRITE)) 01107 { 01108 // Just use the name the user selected to overwite the existing file 01109 break; 01110 } 01111 else if (Answer== _R(IDB_SAVEAS)) 01112 { 01113 // User wants to save as some other name 01114 continue; 01115 } 01116 else if (Answer==_R(IDS_CANCEL)) 01117 { 01118 // User has chosen to abort the operation 01119 End(); 01120 return; 01121 } 01122 else 01123 ERROR3("Unknown Answer from AskQuestion"); 01124 } 01125 } 01126 while( SGLibOil::FileExists( &Path ) ); 01127 01128 PORTNOTE("other", "Removed BmapPrevDlg usage" ) 01129 #if !defined(EXCLUDE_FROM_XARALX) 01130 // Need to set the path for the export dialog (used for image map stuff etc) 01131 BmapPrevDlg::m_pthExport = Path; 01132 #endif 01133 01134 // Extract directory name (minus terminating backslash) and remember for next time. 01135 DefaultExportFilterPath = Path.GetLocation(FALSE); 01136 01137 UINT32 TheSelectedFilterID = pFilter->FilterID; 01138 if (pExportParam == 0) 01139 SelectedFilterID = TheSelectedFilterID; // Using all available filters 01140 else 01141 DefaultBitmapFilterID = TheSelectedFilterID; // Exporting as a bitmap only 01142 01143 // If we are exporting using an EPS based filter and not the CamelotEPS or NativeEPS 01144 // filters then must warn the user that the EPS data does not save all info and question 01145 // whether they want to continue or not. 01146 // This used to use IS_KIND_OF VectorFilter before 29/4/96 but of course this 01147 // really wants to be for all the eps based filters and not all vector filters 01148 // Graeme (11-4-00) - Added FILTERID_AIEPS to stop the warnings when doing an 01149 // AI format export. After all, the AIEPS filter is probably better specified 01150 // these days than the other EPS filters. 01151 if (TheSelectedFilterID != FILTERID_CAMELOT_EPS && 01152 TheSelectedFilterID != FILTERID_NATIVE_EPS && 01153 TheSelectedFilterID != FILTERID_AIEPS 01154 && pFilter->IS_KIND_OF ( EPSFilter ) 01155 ) 01156 { 01157 // Warn the user that they are not exporting in Camelot EPS or native 01158 // format, and get them to confirm that this is what they want to do. 01159 // (We only do this for vector formats) 01160 ErrorInfo Info; 01161 Info.ErrorMsg = _R(IDT_EXPQUERY_NOTSURE); 01162 Info.Button[0] = _R(IDB_EXPQUERY_EXPORT); 01163 Info.Button[1] = _R(IDB_EXPQUERY_DONTEXPORT); 01164 if (UINT32(AskQuestion(&Info)) == _R(IDB_EXPQUERY_DONTEXPORT)) 01165 { 01166 // User decided not to export - abort. 01167 CCFree(FilterString); 01168 FilterString = 0; 01169 FailAndExecute(); 01170 RestoreSelection(); 01171 End(); 01172 return; 01173 } 01174 } 01175 01176 BOOL fExportedOk = FALSE; 01177 01179 // for the future "Options" button handling 01180 01181 // get the export options 01182 // what we need is for the export dlg to appear and give the user the chance 01183 // to fill in the export options 01184 // SMFIX 01185 01186 BitmapExportOptions* pOptions = NULL; 01187 if (pFilter->IS_KIND_OF(BaseBitmapFilter)) 01188 { 01189 if (BmapPrevDlg::m_pExportOptions) 01190 { 01191 delete BmapPrevDlg::m_pExportOptions; 01192 BmapPrevDlg::m_pExportOptions = 0; 01193 } 01194 01195 // only if it is a raster type and we are not saving from the gallery 01196 if (pExportParam == 0) 01197 { 01198 // set up with default attrib for this filter 01199 // and get the user to edit these default params in the export dlg (thats the FALSE param) 01200 PORTNOTE("other", "Use SetUpExportOptions to get defaults only and not do dialog" ) 01201 ((BaseBitmapFilter*) pFilter)->SetUpExportOptions(&pOptions, FALSE); 01202 // ((BaseBitmapFilter*) pFilter)->SetUpExportOptions(&pOptions, TRUE); 01203 // the dlg has been up and the user may have the graphic type 01204 // ask the dlg for the type that it used 01205 if (BmapPrevDlg::m_pExportOptions) 01206 pOptions = BmapPrevDlg::m_pExportOptions; 01207 // take responsibility for the export options away from the bmp preview dlg 01208 BmapPrevDlg::m_pExportOptions = 0; 01209 // the filter we want to export with will change too if the export options have changed type 01210 if (pOptions) 01211 { 01212 Filter * pOldFilter = pFilter; 01213 pFilter = pOptions->FindBitmapFilterForTheseExportOptions(); 01214 // change the export extent if we have changed filters 01215 if (pFilter && pFilter != pOldFilter) 01216 { 01217 // set the path extention 01218 Path.SetType(BmapPrevDlg::m_pthExport.GetType()); 01219 } 01220 else pFilter = pOldFilter; 01221 } 01222 01223 if (!pOptions || !pFilter) 01224 { 01225 // User decided not to export - abort. 01226 RemoveUneededReportedErrors(); 01227 CCFree(FilterString); 01228 FilterString = 0; 01229 FailAndExecute(); 01230 RestoreSelection(); 01231 End(); 01232 return; 01233 } 01234 01235 // do the odd details that a filter may need setting before it is ready to go (sjk 5/12/00) 01236 ((BaseBitmapFilter*) pFilter)->PostGetExportOptions(pOptions); 01237 } 01238 } 01239 01240 BOOL bFinished = FALSE; 01241 01242 // check if we can simply rename the temp file created during preview 01243 if (pOptions != 0 && pOptions->HasTempFile() && !pOptions->GetSeparateLayerFiles()) 01244 { 01245 // get the temp file name 01246 PathName TempPath = pOptions->GetPathName(); 01247 String_256 FinalName = Path.GetPath(); 01248 String_256 TempName = TempPath.GetPath(); 01249 01250 // delete the empty file, if one was created, and try to rename the file 01251 FileUtil::DeleteFile(&Path); 01252 /* 01253 #if defined(__WXGTK__) && FALSE != wxUSE_UNICODE 01254 char pszTempName[256]; 01255 char pszFinalName[256]; 01256 wcstombs( pszTempName, TempName, 256 ); 01257 wcstombs( pszFinalName, FinalName, 256 ); 01258 #else 01259 char* pszTempName = TempName; 01260 char* pszFinalName = FinalName; 01261 #endif 01262 bFinished = !rename(pszTempName, pszFinalName); 01263 */ 01264 // This should do the trick but I've left the old code in case 01265 bFinished = !camRename(TempName, FinalName); 01266 01267 if (bFinished) 01268 { 01269 fExportedOk = TRUE; 01270 // Only tell them if not special user cancelled error message 01271 RemoveUneededReportedErrors(); 01272 } 01273 } 01274 01275 // Set flag telling exporter that we are NOT exporting a temporary file! 01276 if(pOptions) 01277 pOptions->SetTempFileFlag(FALSE); 01278 01279 PORTNOTE( "export", "Removed image map code" ) 01280 #if !defined(EXCLUDE_FROM_XARALX) 01281 // Now export the image map if required 01282 if (pOptions && pOptions->GetSupportsImageMap() && pFilter->IS_KIND_OF(BaseBitmapFilter)) 01283 static_cast<BaseBitmapFilter *>(pFilter)->ExportImagemap(this, &Path, GetWorkingDoc()); 01284 #endif 01285 01286 if (pOptions != NULL) 01287 { 01288 //And if we should be exporting an HTML tag to the clipboard 01289 if (pOptions->ShouldPutHTMLTagOnClipboard() && pFilter->IS_KIND_OF(BaseBitmapFilter)) 01290 static_cast<BaseBitmapFilter *>(pFilter)->ExportHTMLTag(&Path); 01291 01292 PORTNOTE("other", "Removed DreamWeaver DesignNote code" ) 01293 #if 0 01294 // Do we want to make the extra dream weaver design notes file? 01295 if (pOptions->GetCanUseDesignNotes() && UsesDesignNotes()) 01296 { 01297 if( !lstrcmpi( Path.GetType(), _T("gif") ) || !lstrcmpi( Path.GetType(), _T("jpg") ) || 01298 !lstrcmpi( Path.GetType(), _T("bmp") ) || !lstrcmpi( Path.GetType(), _T("png") ) ) 01299 { 01300 wxString DocName( (TCHAR *)Document::GetCurrent()->GetLocation() ); 01301 DocName += _T("\\"); 01302 DocName += (TCHAR *)Document::GetCurrent()->GetPathName(); 01303 01304 if (DocName != _T("\\") ) 01305 { 01306 wxString GraphicFile( (const TCHAR *)Path.GetPath() ); 01307 01308 // create or modify a .mno forward source file 01309 CreateDesignNoteWithForwardSource(GraphicFile, DocName); 01310 } 01311 else 01312 { 01313 InformWarning (_R(IDS_NOTES_WARNING)); 01314 } 01315 } 01316 } 01317 #endif 01318 } 01319 01320 if (!bFinished) 01321 { 01322 // either no temp file, or failed to rename it, do normal export 01323 01325 01326 // First off, we have to try and open the file 01327 CCDiskFile theDiskFile(1024, FALSE, TRUE); 01328 try 01329 { 01330 /* File now opened up, if not already opened inside the DoExport functions in the filters 01331 // themselves. This means this is done after the export options and so the file is not trashed 01332 // until we start doing something to it. 01333 // Open up the file. This will create a zero length file just to make sure that it 01334 // is possible, i.e. we have write access. 01335 // Opened up here so that the filters do not need to know about opening the files and 01336 // closing them and so the preview filter can easily be used to append data into the 01337 // middle of the native and eps files. 01338 // Added 27/9/95 ios::trunc as exporting a bitmap or eps file to the same file twice 01339 // appended the data to the end of the file on Windows 95. 01340 if (!theDiskFile.open(Path, ios::in | ios::out | ios::binary | ios::trunc)) 01341 { 01342 // Failed to open the file... 01343 InformError(_R(IDT_EXPORT_NOTFOUND)); 01344 FailAndExecute(); 01345 End(); 01346 return; 01347 } */ 01348 01349 // Do we want a Preview Bitmap? 01350 if (pFilter->CanIncludePreviewBmp()) pFilter->IncludePreviewBmp(TRUE); 01351 01352 // Export the file 01353 if (pExportParam != 0) 01354 { 01355 ERROR3IF(!pFilter->IS_KIND_OF(BaseBitmapFilter), 01356 "OpMenuExport::not a bitmap filter"); 01357 BaseBitmapFilter* pBitmapFilter = (BaseBitmapFilter*) pFilter; 01358 01359 if (pExportParam->GetBitmapCount() != 1) 01360 fExportedOk = pBitmapFilter->DoExportBitmaps( 01361 this, // Export bitmaps 01362 &theDiskFile, 01363 &Path, 01364 pExportParam); 01365 else 01366 { 01368 // for the future "Options" button handling 01369 01370 if (pFilter->IS_KIND_OF(BaseBitmapFilter) && pOptions) 01371 fExportedOk = 01372 pBitmapFilter->DoExportBitmapWithOptions( 01373 this, // Export bitmap 01374 &theDiskFile, 01375 &Path, 01376 pExportParam->GetBitmap(0), 01377 pOptions); 01378 else 01380 01381 fExportedOk = pBitmapFilter->DoExportBitmap( 01382 this, // Export bitmap 01383 &theDiskFile, 01384 &Path, 01385 pExportParam->GetBitmap(0)); 01386 01387 } 01388 } 01389 else 01390 { 01392 // for the future "Options" button handling 01393 01394 if (pFilter->IS_KIND_OF(BaseBitmapFilter) && pOptions/*&& CCamApp::IsNewWindowsUI()*/) 01395 fExportedOk = ((BaseBitmapFilter*) pFilter)->DoExportWithOptions( 01396 this, // Export drawing 01397 &theDiskFile, 01398 &Path, 01399 GetWorkingDoc(), 01400 pOptions); 01401 else 01402 fExportedOk = pFilter->DoExport(this, // Export drawing 01403 &theDiskFile, 01404 &Path, 01405 GetWorkingDoc()); 01406 } 01407 01408 if (!fExportedOk) 01409 { 01410 if (Error::GetErrorNumber() == _R(IDN_USER_CANCELLED)) 01411 // Suppress the error if it was the 'user has cancelled one'. 01412 Error::ClearError(); 01413 else 01414 { 01415 // Something went a bit wrong - tell the user what it was. 01416 InformError(); 01417 pFilter->DeleteExportFile(&theDiskFile); 01418 } 01419 } 01420 01421 // We had better tell the filter we no longer want Previews 01422 if (pFilter->CanIncludePreviewBmp()) pFilter->IncludePreviewBmp(FALSE); 01423 01424 // close the file 01425 if (theDiskFile.isOpen()) theDiskFile.close(); 01426 } 01427 01428 // See if there was a file io error 01429 catch( CFileException e ) 01430 { 01431 // Report the error if no one else did 01432 RemoveUneededReportedErrors(); 01433 01434 // Make sure that the file is closed and deleted 01435 try 01436 { 01437 // First try and delete it (tries to close it first) and 01438 // double check to make sure it is closed. 01439 if (pFilter) pFilter->DeleteExportFile(&theDiskFile); 01440 if (theDiskFile.isOpen()) theDiskFile.close(); 01441 } 01442 catch(CFileException e) 01443 { 01444 // Failed to close the file - not much we can do about it really 01445 TRACE( _T("Failed to close file\n")); 01446 } 01447 01448 fExportedOk = FALSE; 01449 } 01450 01452 // for the future "Options" button handling 01453 } 01455 01456 // Get rid of the filter string buffer and restore the original selection. 01457 CCFree(FilterString); 01458 FilterString = 0; 01459 RestoreSelection(); 01460 01461 if (!fExportedOk) 01462 { 01463 // delete the export options 01464 if (pOptions) 01465 delete pOptions; 01466 01467 FailAndExecute(); 01468 End(); 01469 return; 01470 } 01471 01472 // TODO: did we export only the selection? 01473 BOOL fExportedSelection = FALSE; 01474 if (pFilter->IS_KIND_OF(BaseBitmapFilter) && pParam == 0 && pOptions) 01475 { 01476 fExportedSelection = (pOptions->GetSelectionType() == SELECTION); 01477 } 01478 01479 // Make named export sets from the user's exported selections. 01480 if (fExportedSelection) 01481 CreateNamedSet(pFilter, Path); // this will call Fail or Succeed 01482 else 01483 SucceedAndDiscard(); 01484 01485 // delete the export options 01486 if (pOptions) 01487 delete pOptions; 01488 01489 End(); 01490 }
|
|
This item is always available, so long as a document is visible.
Definition at line 1682 of file impexpop.cpp. 01683 { 01684 //Removed - Ranbir. 01685 //Fixes a bug. 01686 //We cannot set the Greyed.State to TRUE, as the Save button in the bitmap gallery 01687 //also relies on this getstate function. 01688 /* 01689 #ifdef WEBSTER 01690 // In Webster, we will grey out the Export option if there are no visible objects on the page 01691 OpState OpSt; 01692 String_256 DisableReason; 01693 01694 // Is there a selected spread? 01695 Spread * pSpread = Document::GetSelectedSpread(); 01696 if (pSpread) 01697 { 01698 DocRect VisibleRect = pSpread->GetPageVisibleBounds(); 01699 BOOL Empty = VisibleRect.IsEmpty(); 01700 if (!Empty) 01701 { 01702 // There's a visible rect, so there must be exportable objects, so don't grey out 01703 OpSt.Greyed = FALSE; 01704 } 01705 else 01706 { 01707 // No visible objects, so grey it out and say why 01708 OpSt.Greyed = TRUE; 01709 // Load reason why operation is disabled 01710 DisableReason = String_256(_R(IDS_NO_VISIBLE_OBJECTS)); 01711 if (pUIDescription) 01712 *pUIDescription = DisableReason; 01713 } 01714 } 01715 else 01716 { 01717 // No selected spread, so we are greyed 01718 OpSt.Greyed = TRUE; 01719 01720 // Load reason why operation is disabled 01721 DisableReason = String_256(_R(IDS_NO_DOC)); 01722 if (pUIDescription) 01723 *pUIDescription = DisableReason; 01724 } 01725 01726 return OpSt; 01727 01728 #else 01729 */ 01730 01731 OpState OpSt; 01732 01733 return OpSt; 01734 //#endif // WEBSTER 01735 }
|
|
Declares op descriptor for export operation.
Reimplemented from SimpleCCObject. Definition at line 680 of file impexpop.cpp. 00681 { 00682 // derived off operation so takes 16 parameters including the vertical counterpart 00683 BOOL InitOK; 00684 InitOK = RegisterOpDescriptor( 0, // Tool ID 00685 _R(IDT_EXPORT), // String resource ID 00686 CC_RUNTIME_CLASS(OpMenuExport), // Runtime class 00687 OPTOKEN_MENUEXPORT, // Token string 00688 GetState, // GetState function 00689 0, // help ID 00690 _R(IDBBL_FILEEXPORT), // bubble help 00691 _R(IDD_BARCONTROLSTORE), // resource ID 00692 _R(IDC_FILEEXPORT), // control ID 00693 SYSTEMBAR_FILE, // Bar ID 00694 TRUE, // Recieve system messages 00695 FALSE, // Smart duplicate operation 00696 FALSE, // Clean operation 00697 // 0, // No vertical counterpart 00698 _R(IDS_OPMENUEXPORT_ONE), // String for one copy only error 00699 DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC // Auto state flags 00700 ); 00701 if (!InitOK) return FALSE; 00702 00703 Camelot.DeclareSection(_T("Filters"), 5); 00704 Camelot.DeclarePref(_T("Filters"), _T("DefaultExportFilter"), &SelectedFilterID); 00705 Camelot.DeclarePref(_T("Filters"), _T("DefaultExportFilterPath"), &DefaultExportFilterPath); 00706 Camelot.DeclarePref(_T("Filters"), _T("DefaultBitmapFilter"), &DefaultBitmapFilterID); 00707 00708 return TRUE; 00709 }
|
|
Fixes-up the selection for compound objects.
Definition at line 770 of file impexpop.cpp. 00771 { 00772 // run through the range selecting all PromoteToParent nodes 00773 SelRange* pRng = GetApplication()->FindSelection(); 00774 if (pRng == 0) 00775 { 00776 ERROR3("No range in OpMenuExport::NormaliseSelection"); 00777 return; 00778 } 00779 00780 for (Node* pNode = pRng->FindFirst(FALSE); 00781 pNode != 0; 00782 pNode = pRng->FindNext(pNode, FALSE)) 00783 if (pNode->IsAnObject()) 00784 for (Node* pParent = pNode->FindParent(); 00785 pParent != 0 && pParent->IsAnObject(); 00786 pParent = pParent->FindParent()) 00787 if (pParent->ShouldITransformWithChildren()) 00788 { 00789 pParent->SetSelected(FALSE); 00790 pParent->SetSelected(TRUE); 00791 } 00792 00793 pRng->Update(); 00794 }
|
|
Restores the selection given in m_pSelNodeList.
Definition at line 808 of file impexpop.cpp. 00809 { 00810 SelRange* pRng = GetApplication()->FindSelection(); 00811 if (pRng == 0) 00812 { 00813 ERROR3("No range in OpMenuExport::RestoreSelection"); 00814 return; 00815 } 00816 00817 if (pRng->IsSelRangeGagged()) pRng->SetGag(FALSE); 00818 NodeRenderableInk::DeselectAll(FALSE, FALSE); 00819 00820 if (!m_pSelNodeList) 00821 { 00822 ERROR3("Sel node list not set up"); 00823 return; 00824 } 00825 00826 for (NodeListItem* pItem = (NodeListItem*) m_pSelNodeList->GetHead(); 00827 pItem != 0; 00828 pItem = (NodeListItem*) m_pSelNodeList->GetNext(pItem)) 00829 if (pItem->pNode != 0) pItem->pNode->SetSelected(TRUE); 00830 00831 m_pSelNodeList->DeleteAll(); 00832 delete m_pSelNodeList; 00833 m_pSelNodeList = 0; 00834 00835 RangeControl rg = pRng->GetRangeControlFlags(); 00836 rg.PromoteToParent = FALSE; 00837 pRng->Range::SetRangeControl(rg); 00838 pRng->Update(); 00839 // pRng->Update(TRUE); 00840 }
|
|
Saves the selection so it can be restored.
Definition at line 741 of file impexpop.cpp. 00742 { 00743 if (m_pSelNodeList) 00744 { 00745 m_pSelNodeList->DeleteAll(); 00746 delete m_pSelNodeList; 00747 m_pSelNodeList = 0; 00748 } 00749 00750 SelRange* pRng = GetApplication()->FindSelection(); 00751 if (pRng == 0) 00752 { 00753 ERROR3("No SelRange in OpMenuExport::SaveSelection"); 00754 return; 00755 } 00756 00757 pRng->SetGag(TRUE); 00758 m_pSelNodeList = pRng->MakeListOfNodes(FALSE); 00759 }
|
|
Interegates the bitmap for its name and dumps this into the given string. If there is an extension on the bitmap name then it will fix this to be correct for the filter that will be selected. If there is no extension then it will just append the correct extension onto the name.
Definition at line 1602 of file impexpop.cpp. 01604 { 01605 OILBitmap* pOilBitmap = pTheBitmap->ActualBitmap; 01606 if (pOilBitmap) 01607 { 01608 *DefaultName = pOilBitmap->GetName(); 01609 // We must add the extension on for the selected or default filter 01610 // Only add the extension if none is present already. 01611 // If an extension is present then check that it corresponds to the selected or default filter 01612 PathName TempPath(*DefaultName); 01613 String_32 Extension = TempPath.GetType(); 01614 01615 // Find the filter that the user chose 01616 Filter *pFilter = Filter::GetFirst(); 01617 while (pFilter != 0) 01618 { 01619 if ((pFilter->GetFlags().CanExport) && 01620 (pFilter->FilterID == DefaultBitmapFilterID)) 01621 // This is the filter! 01622 break; 01623 01624 // Try the next filter 01625 pFilter = Filter::GetNext(pFilter); 01626 } 01627 01628 if (pFilter && pFilter->pOILFilter) 01629 { 01630 // Get the OILFilter class to check the extension for the selected or default filter 01631 // matches 01632 if (!pFilter->pOILFilter->DoesExtensionOfPathNameMatch(&TempPath)) 01633 { 01634 // Extension is either blank or does not match the one supplied by the filter 01635 // Ask the OILFilter class to fix it for us 01636 pFilter->pOILFilter->FixExtensionOfPathName(&TempPath); 01637 // Now copy that back into the name 01638 *DefaultName = TempPath.GetPath(); 01639 } 01640 // If this was imported from a multi-image file 01641 // then we want to either bin the number or tag it on the end 01642 // Actually this whole practice is rather dubious since file names may 01643 // contain the search string. Wait for a proper fix to import bitmap! 01644 String_256 fileName = TempPath.GetFileName(FALSE); // without extension 01645 // Search for the image index and throw it away... 01646 String_32 searchString; 01647 searchString.MakeMsg(_R(IDS_BITMAP_NAME), "",""); 01648 INT32 index = fileName.Sub(searchString); 01649 if (index > 0) // it had a number...probably 01650 { 01651 if (pExportParam != 0 && pExportParam->GetBitmapCount() > 1) 01652 { 01653 // multiple bitmaps - throw away any numbering 01654 // oops...keeps the LHS (ignores #1 position) 01655 fileName.Left(&fileName, index); 01656 } 01657 else // single bitmap - tag the number on the end, no spaces 01658 { 01659 fileName.Remove(index, searchString.Length()); 01660 } 01661 TempPath.SetFileName(fileName); 01662 *DefaultName = TempPath.GetPath(); 01663 } 01664 } 01665 } 01666 01667 return TRUE; 01668 }
|
|
Definition at line 239 of file impexpop.h. |
|
Definition at line 232 of file impexpop.h. |
|
Definition at line 235 of file impexpop.h. |
|
Definition at line 241 of file impexpop.h. |
|
Definition at line 240 of file impexpop.h. |
|
Definition at line 238 of file impexpop.h. |
|
Definition at line 237 of file impexpop.h. |