OpMenuLoad Class Reference

Imports the specified file as NativeEPS. More...

#include <nativeop.h>

Inheritance diagram for OpMenuLoad:

SelOperation UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

virtual void DoWithParam (OpDescriptor *, OpParam *pOpParam)
 Loads a Camelot Native EPS file.
virtual BOOL MayChangeNodeBounds () const

Static Public Member Functions

static BOOL Init ()
 Registers the opdescriptor for the Native Load operation.
static OpState GetState (String_256 *, OpDescriptor *)
 Yet another annoying OpState function that does nothing.

Protected Member Functions

BOOL LoadFile (CCLexFile *pFileToLoad, UINT32 nPrefFilter)
 Tries to load the file specified. If it is not a Camelot file then it should report errors etc. Most of this function is actually looking for the Native Load/Save filter to try and load.

Detailed Description

Imports the specified file as NativeEPS.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/12/94

Definition at line 144 of file nativeop.h.


Member Function Documentation

void OpMenuLoad::DoWithParam OpDescriptor ,
OpParam pOpParam
[virtual]
 

Loads a Camelot Native EPS file.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/8/96
Parameters:
OpDescriptor - Not Used. [INPUTS] pOpParam->Param1 - a pointer to the NativeFileOpParams for this invokation.

Reimplemented from Operation.

Definition at line 240 of file nativeop.cpp.

00241 {
00242     // Extract the parameters.
00243     NativeFileOpParams* ppm = (NativeFileOpParams*)(void *)(pOpParam->Param1);
00244 
00245     // Try to load the file.
00246     ERROR3IF(!ppm->pFile, "Null CCLexFile* in OpMenuLoad::DoWithParam");
00247     ppm->fStatus = ppm->pFile && LoadFile(ppm->pFile, ppm->nPrefFilter);
00248     if (!ppm->fStatus) FailAndExecute();
00249 
00250     // Before we call End() we must ensure that CurrentDoc == SelectedDoc
00251     Document::GetSelected()->SetCurrent();
00252     End();
00253 }

OpState OpMenuLoad::GetState String_256 ,
OpDescriptor
[static]
 

Yet another annoying OpState function that does nothing.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/12/94

Definition at line 221 of file nativeop.cpp.

00222 {
00223     // Dunno
00224     OpState Blobby;
00225     return Blobby;
00226 }

BOOL OpMenuLoad::Init void   )  [static]
 

Registers the opdescriptor for the Native Load operation.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/12/94
Returns:
TRUE if it worked, FALSE if not.

Reimplemented from SimpleCCObject.

Definition at line 198 of file nativeop.cpp.

00199 {
00200     // Register this operations descriptor
00201     return RegisterOpDescriptor(0, _R(IDT_IMPORT), CC_RUNTIME_CLASS(OpMenuLoad),
00202                                 OPTOKEN_NATIVELOAD, GetState,
00203                                 0, _R(IDBBL_IMPORTFILEOP), 0,0,SYSTEMBAR_ILLEGAL,
00204                                 TRUE, FALSE, TRUE);
00205 
00206     return false;
00207 }

BOOL OpMenuLoad::LoadFile CCLexFile pFileToLoad,
UINT32  nPrefFilter
[protected]
 

Tries to load the file specified. If it is not a Camelot file then it should report errors etc. Most of this function is actually looking for the Native Load/Save filter to try and load.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> & JustinF
Date:
3/1/95
Parameters:
pFileToLoad - the file to load from. [INPUTS] nPreFilter - the ID of the filter to use
Returns:
TRUE if it worked, FALSE if it failed
See also:
OpMenuLoad; RecentFileOp

Definition at line 271 of file nativeop.cpp.

00272 {
00273     // Make sure we have a valid file to load.
00274 /*  TRACEUSER( "JustinF", _T("In OpMenuLoad::LoadFile(%p, %u)\n"),
00275                 (LPVOID) pFileToLoad, nPrefFilter);
00276 */  ERROR3IF(!pFileToLoad, "Null CCLexFile* in OpMenuLoad::LoadFile");
00277     
00278     // Find out the position of the filter selected by the user in the open dialog
00279     INT32 SelectedPos = 0;
00280 
00281 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00282     SelectedPos = BaseFileDialog::SelectedFilter;
00283 #endif
00284 
00285     // Go get the first filter in the list
00286     Filter* pFilter = Filter::GetFirst();
00287 
00288     // Do we know which filter was used? (we know nothing about things in the recent file
00289     // list).  If we don't, then use the preferred one, by default the generic filter.
00290     if (nPrefFilter != FILTERID_USERCHOICE || SelectedPos == 0)
00291     {
00292         // We know nothing. We will have to go and have a look at all the possibles
00293         // We will find the Filter Family and ask it to try and load the file.
00294         UINT32 nID = (nPrefFilter != FILTERID_USERCHOICE) ? nPrefFilter : FILTERID_GENERIC;
00295         while (pFilter != NULL && pFilter->FilterID != nID)
00296         {
00297             // Try the next filter
00298             pFilter = Filter::GetNext(pFilter);
00299         }
00300     }
00301     else
00302     {
00303         // We know which type of filter the user had selected in the file dialog
00304         // Find the filter that the user chose.
00305         while (pFilter != NULL)
00306         {
00307             // This is the filter?
00308             if (pFilter->GetFlags().CanImport &&
00309                 pFilter->pOILFilter->Position == SelectedPos)
00310                     break;
00311 
00312             // Try the next filter
00313             pFilter = Filter::GetNext(pFilter);
00314         }
00315     }
00316     
00317     // Check that the Filter existed
00318     if (pFilter == NULL)
00319     {
00320         // It did not...
00321         InformError(_R(IDT_CANT_FIND_FILTER));
00322         return FALSE;
00323     }
00324 
00325     // Get pointer to current doc 'cos we'll need it several times...
00326     Document* pCurDoc = Document::GetCurrent();
00327 
00328     // If this is not a filter family, check for compatibility before asking
00329     // filter to load the file.
00330     // This means the user has chosen an explicit filter to handle the import
00331     PathName Path = pFileToLoad->GetPathName();
00332     String_256 FilePath = Path.GetPath();
00333     // FilePath will be null if a pathname is not valid
00334     if (!pFilter->IS_KIND_OF(FilterFamily) && !FilePath.IsEmpty())
00335     {
00336         UINT32      Size = 1024;
00337         size_t      FileSize;
00338         ADDR        FilterBuf = pFilter->LoadInitialSegment(Path, &Size, &FileSize);
00339 
00340         // If there has been a problem in the load initial segment then fail now.
00341         if (FilterBuf == NULL)
00342         {
00343             // Tell the user about the problem and get out now while the goings good 
00344             InformError();
00345             return FALSE;
00346         }
00347 
00348         // Inform any filters that we are about to do a HowCompatible call.
00349         // This would allow a set of filters which have common functionality hidden in a
00350         // filter that cannot import and cannot export handle this call and hence set
00351         // itself up. This would allow it to maybe cache a result which should only be
00352         // checked by the first filter in the group. 
00353         pFilter->PreHowCompatible();
00354         
00355         // Change this to be less than 8 as the filters like the Accusoft forms return
00356         // 8 and 9 to make sure that they are last in the chain.
00357         if (pFilter->HowCompatible(Path, FilterBuf, Size, UINT32(FileSize)) < 8)
00358         {
00359             // Not 100% happy with this file - ask for confirmation.
00360             ErrorInfo Question;
00361             Question.ErrorMsg = _R(IDW_OPENQUERY_NOTSURE);
00362             Question.Button[0] = _R(IDB_OPENQUERY_OPEN);
00363             Question.Button[1] = _R(IDB_OPENQUERY_DONTOPEN);
00364 
00365             if ((ResourceID)AskQuestion(&Question) != _R(IDB_OPENQUERY_OPEN))
00366             {
00367                 // User asked for this to be cancelled.
00368                 TRACEUSER( "Tim", _T("Filter compatibility was less than 10\n"));
00369 
00370                 // Close the file, report the abort and finish.
00371                 CCFree(FilterBuf);
00372                 //InformMessage(_R(IDT_IMP_USERABORT));
00373                 return FALSE;
00374             }
00375         }
00376 
00377         // Get rid of initial file header
00378         CCFree(FilterBuf);
00379     }
00380 
00381     // we have to try and open the file
00382     try
00383     {
00384         // Found the Filter, so ask it to import the file please
00385         if (!pFilter->DoImport(this, pFileToLoad, pCurDoc))
00386         {
00387             // Something went a bit wrong - tell the user what it was.
00388             // Only tell them if not special user cancelled error message
00389             if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED))
00390             {
00391                 // Only supress the error if not the special user abort error
00392                 // ***** For now use the native EPS filter
00393                 if (pFilter->FilterID == FILTERID_NATIVE_EPS &&
00394                     Error::GetErrorNumber() != _R(IDT_IMPORT_USERABORT))
00395                 {
00396                     Error::ClearError();
00397                     InformError(_R(IDS_ERRORINARTFILE));
00398                 }
00399                 else
00400                 {
00401                     // Tell the user what the problem was
00402                     InformError();
00403                     wxMessageDialog dlg(
00404                         NULL,
00405                         _T( "Xara LX failed to load the design.\n\n")
00406                         _T( "This is an early demonstration version of the program which does ")
00407                         _T( "not yet support all of the data types that can appear in XAR designs."),
00408                         _T("Load failed"),
00409                         wxOK
00410                     );
00411                     dlg.ShowModal() ;
00412                 }
00413             }
00414             else
00415             {
00416                 // otherwise remove the error so it won't get reported
00417                 Error::ClearError();
00418             }
00419 
00420             // and fail
00421             return FALSE;
00422         }
00423 
00424     }
00425     // See if there was a file io errir
00426     catch( CFileException )
00427     {
00428         // Report the error if no one else did, otherwise clear it.
00429         if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED))
00430             InformError();
00431         else
00432             Error::ClearError();
00433 
00434         // and fail
00435         return FALSE;
00436     }
00437 
00438     // Success.
00439     return TRUE;
00440 }

virtual BOOL OpMenuLoad::MayChangeNodeBounds  )  const [inline, virtual]
 

Reimplemented from SelOperation.

Definition at line 155 of file nativeop.h.

00155 { return FALSE; }


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:58:26 2007 for Camelot by  doxygen 1.4.4