#include <sgliboil.h>
Inheritance diagram for OpClipartImport:
Public Member Functions | |
OpClipartImport () | |
OpClipartImport constructor (Creates an undoable operation). | |
~OpClipartImport () | |
OpClipartImport destructor. | |
virtual void | Do (OpDescriptor *) |
virtual void | DoWithParam (OpDescriptor *pOp, OpParam *pClipartImportParam) |
Performs a clipart import / open depending on the parameters... Imports overlay the clipart on the existing document, Opens create a new page and import to that. | |
Static Public Member Functions | |
static BOOL | Init () |
Creates an OpDescriptor for an ClipartImport operation. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
Returns the OpState of the OpClipartImport operation. |
Definition at line 149 of file sgliboil.h.
|
OpClipartImport constructor (Creates an undoable operation).
Definition at line 235 of file sgliboil.cpp. 00235 : SelOperation() 00236 { 00237 OpFlags.HasOwnTimeIndicator = TRUE; // The OpMenuImport op has its own time indicator 00238 }
|
|
OpClipartImport destructor.
Definition at line 255 of file sgliboil.cpp.
|
|
Reimplemented from Operation. Reimplemented in OpAsynchClipartImport. Definition at line 324 of file sgliboil.cpp. 00325 { 00326 ERROR3("OpClipartImport does not provide a Do() function - Use DoWithParam"); 00327 End(); 00328 }
|
|
Performs a clipart import / open depending on the parameters... Imports overlay the clipart on the existing document, Opens create a new page and import to that.
Reimplemented from Operation. Reimplemented in OpAsynchClipartImport. Definition at line 347 of file sgliboil.cpp. 00348 { 00349 ClipartImportParam *pInfo = (ClipartImportParam *) pClipartImportParam; 00350 00351 if(pInfo == NULL) 00352 { 00353 ERROR3("OpClipartImport called with NULL info pointer"); 00354 FailAndExecute(); 00355 End(); 00356 return; 00357 } 00358 else 00359 { 00360 if(pInfo->File == NULL) 00361 { 00362 ERROR3("OpClipartImport called with NULL file pointer"); 00363 FailAndExecute(); 00364 End(); 00365 return; 00366 } 00367 } 00368 00369 PathName Path = *(pInfo->File); 00370 00371 if(!Path.IsValid()) 00372 { 00373 ERROR3("Filename is invalid"); 00374 //InformError(_R(IDT_IMPORT_NOTFOUND)); 00375 FailAndExecute(); 00376 End(); 00377 return; 00378 } 00379 00380 if(!pInfo->Import) 00381 { 00382 // Open / Load a file 00383 CCamApp *pApp = AfxGetApp(); 00384 BaseFileDialog::SelectedFilter = 0; 00385 00386 String_256 OpenPath((const TCHAR *)Path.GetPath()); 00387 // Error::ClearError(); 00388 00389 // Open a document 00390 CCamDoc* pDoc = (CCamDoc*) pApp->OpenDocumentFile((TCHAR *)OpenPath); 00391 00392 // Force the Ops 'Working Doc' to the selected one, in case the open 00393 // document thingy deleted the existing docs. 00394 if(pDoc != NULL) pOurDoc = Document::GetSelected(); 00395 00396 Document* pCurDoc = pDoc->GetKernelDoc(); 00397 00398 // And redraw the imported document 00399 //if(pCurDoc) pCurDoc->ForceRedraw(); 00400 00401 } 00402 else 00403 { 00404 // Can't import if no selected document (!) 00405 if(Document::GetSelected() == NULL) 00406 { 00407 ERROR3("No selected document"); 00408 //InformError(_R(IDT_IMPORT_NOTFOUND)); 00409 FailAndExecute(); 00410 End(); 00411 return; 00412 } 00413 00414 // Import a file 00415 UINT32 SelFilter = FILTERID_GENERIC; 00416 BOOL LayersImport = FALSE; 00417 00418 // Find the filter that the user chose 00419 Filter *pFilter = Filter::GetFirst(); 00420 00421 if(pFilter == NULL) 00422 return; 00423 00424 while (pFilter != NULL) 00425 { 00426 if ((pFilter->GetFlags().CanImport) && (pFilter->FilterID == SelFilter)) 00427 // This is the filter! 00428 break; 00429 00430 // Try the next filter 00431 pFilter = Filter::GetNext(pFilter); 00432 } 00433 00434 if (pFilter == NULL) 00435 { 00436 InformError(_R(IDT_CANT_FIND_FILTER)); 00437 FailAndExecute(); 00438 End(); 00439 return; 00440 } 00441 else 00442 { 00443 // If this is not a filter family, check for compatibility before asking 00444 // filter to load the file. 00445 // This means the user has chosen an explicit filter to handle the import 00446 if (!pFilter->IS_KIND_OF(FilterFamily)) 00447 { 00448 UINT32 Size = 1024; 00449 INT32 FileSize; 00450 ADDR FilterBuf = pFilter->LoadInitialSegment(Path, &Size, &FileSize); 00451 00452 // If there has been a problem in the load initial segment then fail now. 00453 if (FilterBuf == NULL) 00454 { 00455 // Tell the user about the problem and get out now while the goings good 00456 InformError(); 00457 FailAndExecute(); 00458 End(); 00459 return; 00460 } 00461 00462 // Inform any filters that we are about to do a HowCompatible call. 00463 // This would allow a set of filters which have common functionality hidden in a 00464 // filter that cannot import and cannot export handle this call and hence set 00465 // itself up. This would allow it to maybe cache a result which should only be 00466 // checked by the first filter in the group. 00467 pFilter->PreHowCompatible(); 00468 00469 // Change this to be less than 9 as the built in BMP filter returns 8 if it 00470 // is not too sure about the file and would like the AccusoftBMp filter to 00471 // load the file if it is present. 00472 if (pFilter->HowCompatible(Path, FilterBuf, Size, FileSize) < 9) 00473 { 00474 // Not 100% happy with this file - ask for confirmation. 00475 ErrorInfo Question; 00476 Question.ErrorMsg = _R(IDT_IMPQUERY_NOTSURE); 00477 Question.Button[0] = _R(IDB_IMPQUERY_IMPORT); 00478 Question.Button[1] = _R(IDB_IMPQUERY_DONTIMPORT); 00479 00480 if (AskQuestion(&Question) != _R(IDB_IMPQUERY_IMPORT)) 00481 { 00482 // User asked for this to be cancelled. 00483 TRACEUSER( "Richard", wxT("Filter compatibility was less than 10\n") ); 00484 00485 // Close the file, report the abort and finish. 00486 CCFree(FilterBuf); 00487 FailAndExecute(); 00488 InformMessage(_R(IDT_IMP_USERABORT)); 00489 End(); 00490 return; 00491 } 00492 } 00493 00494 // Get rid of initial file header 00495 CCFree(FilterBuf); 00496 } 00497 00498 // Start the selection operation 00499 if (DoStartSelOp(FALSE)) // We don't want to save the end selection status because 00500 // it will be restored automatically when the operation is 00501 // redone 00502 { 00503 // First off, we have to try and open the file 00504 CCDiskFile DiskFile(1024, FALSE, TRUE); 00505 00506 // Get pointer to current doc 'cos we'll need it several times... 00507 //Document* pCurDoc = Document::GetCurrent(); 00508 Document* pCurDoc; 00509 ImportPosition Pos; 00510 00511 if (pInfo->DropInfo) 00512 { 00513 // A specfic Import Position has been specified. 00514 // Get the document, spread, and position to import at. 00515 pCurDoc = pInfo->DropInfo->pDoc; 00516 00517 Pos.Position = pInfo->DropInfo->DropPos; 00518 Pos.pSpread = pInfo->DropInfo->pSpread; 00519 } 00520 else 00521 { 00522 pCurDoc = Document::GetSelected(); 00523 } 00524 00525 if(pCurDoc == NULL) 00526 { 00527 ERROR3("OpClipartImport::DoWithParam retrieved NULL selected doc"); 00528 return; 00529 } 00530 00531 TRY 00532 { 00533 if (!DiskFile.open(Path, ios::in | ios::binary)) 00534 { 00535 // Failed to open the file... 00536 TRACEUSER( "Richard", wxT("Failed to open file in ClipartImport Do") ); 00537 InformError(_R(IDT_IMPORT_NOTFOUND)); 00538 FailAndExecute(); 00539 End(); 00540 return; 00541 } 00542 00543 // Import the file and see if Something went a bit wrong - tell the user what it was. 00544 ImportPosition* ImportPos; 00545 if (pInfo->DropInfo) 00546 ImportPos = &Pos; // Import at a specific point. 00547 else 00548 { 00549 //Graham 15/7/97 00550 //Otherwise, put the imported object in the centre of the view 00551 //So get the current view 00552 DocView* pDocView=DocView::GetCurrent(); 00553 00554 //And find its centre import position 00555 Pos=pDocView->GetCentreImportPosition(); 00556 00557 ImportPos=&Pos; 00558 } 00559 00560 00561 00562 if (!pFilter->DoImport(this, &DiskFile, pCurDoc, FALSE, ImportPos)) 00563 { 00564 // Only tell them if not special user cancelled error message 00565 if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED)) 00566 InformError(); 00567 else 00568 Error::ClearError(); // otherwise remove the error so it won't get reported 00569 FailAndExecute(); 00570 End(); 00571 00572 // close the file 00573 if (DiskFile.isOpen()) 00574 DiskFile.close(); 00575 00576 return; 00577 } 00578 00579 // close the file 00580 if (DiskFile.isOpen()) 00581 DiskFile.close(); 00582 00583 } 00584 00585 // See if there was a file io error 00586 CATCH(CFileException, e) 00587 { 00588 // Report the error if no one else did 00589 if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED)) 00590 InformError(); 00591 else 00592 Error::ClearError(); // otherwise remove the error so it won't get reported 00593 00594 // Make sure that the file is closed 00595 TRY 00596 { 00597 if (DiskFile.isOpen()) 00598 DiskFile.close(); 00599 } 00600 CATCH(CFileException, e) 00601 { 00602 // Failed to close the file - not much we can do about it really 00603 } 00604 END_CATCH 00605 00606 // and fail 00607 FailAndExecute(); 00608 End(); 00609 return; 00610 } 00611 END_CATCH 00612 } 00613 } 00614 } 00615 00616 // grab the focus 00617 GetMainFrame()->SetActiveWindow(); 00618 // Finished the operation 00619 End(); 00620 }
|
|
Returns the OpState of the OpClipartImport operation.
Reimplemented in OpAsynchClipartImport. Definition at line 301 of file sgliboil.cpp. 00302 { 00303 //OpState OpSt; 00304 OpState OpSt; 00305 00306 return(OpSt); 00307 }
|
|
Creates an OpDescriptor for an ClipartImport operation.
Reimplemented from SimpleCCObject. Reimplemented in OpAsynchClipartImport. Definition at line 271 of file sgliboil.cpp. 00272 { 00273 OpBitmapImport::Init(); 00274 OpAsynchBitmapImport::Init(); 00275 00276 return RegisterOpDescriptor( 00277 0, // Tool ID 00278 _R(IDS_OPCLIPARTIMPORT), // String resource ID 00279 CC_RUNTIME_CLASS(OpClipartImport), // Runtime class 00280 OPTOKEN_OPCLIPARTIMPORT, // Token string 00281 OpClipartImport::GetState, // GetState function 00282 0, // Help ID 00283 0, // Bubble ID 00284 0, // Resource ID 00285 0 // Control ID 00286 // needs 'GREY_WHEN_NO_CURRENT_DOC' 00287 ); 00288 }
|