00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 #include "camtypes.h"
00101 #include "sglcart.h"
00102 #include <io.h>
00103
00104
00105
00106
00107 #include "sginit.h"
00108 #include "sglcart.h"
00109 #include "sglib.h"
00110 #include "sgmenu.h"
00111
00112
00113 #include "sglfills.h"
00114 #include "thumbmsg.h"
00115 #include "grnddib.h"
00116
00117
00118 #include "sgliboil.h"
00119
00120
00121
00122 #include "filedlgs.h"
00123
00124 #include "progress.h"
00125 #include "camelot.h"
00126 #include "dragmgr.h"
00127
00128
00129
00130 #include "scrcamvw.h"
00131
00132
00133 #include "sgscanf.h"
00134 #include "sglbase.h"
00135 #include "sgrmfile.h"
00136
00137 #include "keypress.h"
00138 #include "fileutil.h"
00139 #include "camdoc.h"
00140 #include "pathnmex.h"
00141
00142 #include "inetop.h"
00143 #include "camnet.h"
00144
00145
00146
00147
00148 #ifdef _BATCHING
00149 #define SAVEASWELL 1
00150
00151 #include <stdio.h>
00152
00153
00154 #include "page.h"
00155 #include "pagesize.h"
00156 #include "optspage.h"
00157
00158 #include "grid.h"
00159 #include "zoomops.h"
00160 #include "layer.h"
00161
00162 #include "collist.h"
00163 #include "colourix.h"
00164 #include "colormgr.h"
00165 #include "webop.h"
00166 #endif
00167
00168 #include "helpuser.h"
00169
00170
00171
00172 #include "resdll.h"
00173
00174 using namespace InetUtils;
00175
00176
00177
00178 CC_IMPLEMENT_DYNCREATE(LibClipartSGallery, LibraryGallery)
00179 CC_IMPLEMENT_DYNCREATE(OpDisplayLibClipartGallery, Operation)
00180 CC_IMPLEMENT_DYNCREATE(SGClipartItem, SGLibDisplayItem)
00181 CC_IMPLEMENT_DYNCREATE(GalleryClipartDragInfo, BitmapDragInformation)
00182 CC_IMPLEMENT_DYNAMIC(SGClipartDragTarget, SGListDragTarget)
00183 CC_IMPLEMENT_DYNAMIC(SGOilClipartDragTarget, WinoilDragTarget)
00184 CC_IMPLEMENT_DYNCREATE(OpLibGalClipTheme, OpDescriptor);
00185
00186
00187 #define new CAM_DEBUG_NEW
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205 String_256 LibClipartSGallery::ClipartPath = TEXT("D:\\clipart");
00206 String_256 LibClipartSGallery::WebThemePath = TEXT("D:\\themes");
00207 String_256 LibClipartSGallery::DefaultLibraryPath = ClipartPath;
00208
00209
00210 INT32 LibClipartSGallery::DefaultDisplayMode = 0;
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220 UINT32 LibClipartSGallery::DefaultSortKeys = 1;
00221
00222
00223 String_256 LibClipartSGallery::BatchSaveLocation = "";
00224
00225 BOOL LibClipartSGallery::DoSounds = TRUE;
00226
00227
00228 LibClipartSGallery *LibClipartSGallery::ThisGallery = NULL;
00229
00230 LibClipartSGallery* LibClipartSGallery::m_pInstance = 0;
00231
00232
00233 BOOL LibClipartSGallery::QuietStatus = FALSE;
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249 LibClipartSGallery::LibClipartSGallery()
00250 {
00251 LibClipartSGallery::ThisGallery = this;
00252 m_bDiscardWebFolders = FALSE;
00253
00254 CSize Size(((333 * 2) - 32) - 32, 256);
00255 SetGallerySize(Size);
00256 m_pInstance = this;
00257 m_nClipTheme = 0;
00258 m_bRedraw = false;
00259 }
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273 LibClipartSGallery::~LibClipartSGallery()
00274 {
00275 TRACEUSER( "Matt", _T("~LibClipartSGallery\n"));
00276
00277 OpenLibFiles.DeleteAll();
00278 LibClipartSGallery::ThisGallery = NULL;
00279 m_pInstance = 0;
00280 }
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291 LibClipartSGallery* LibClipartSGallery::Instance()
00292 {
00293 ERROR3IF(m_pInstance == 0, "LibClipartSGallery::Instance: no gallery");
00294 return m_pInstance;
00295 }
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312 BOOL LibClipartSGallery::Init(void)
00313 {
00314 TRACEUSER( "Matt", _T("Init clipart gallery\n"));
00315 #ifdef _BATCHING
00316
00317 GetApplication()->DeclareSection(TEXT("Batching"), 6);
00318 GetApplication()->DeclarePref(TEXT("Batching"), TEXT("OutputDirectory"), &LibClipartSGallery::BatchSaveLocation);
00319
00320 #endif
00321
00322 if (!OpClipartImport::Init())
00323 return(FALSE);
00324
00325 if (!OpAsynchClipartImport::Init())
00326 return(FALSE);
00327
00328
00329 return(TRUE);
00330 }
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356 BOOL LibClipartSGallery::PreCreate(void)
00357 {
00358 TRACEUSER( "Matt", _T("Precreating clipart window\n"));
00359
00360 if (DisplayTree == NULL)
00361 {
00362 DisplayTree = new SGDisplayRootScroll(this);
00363 if (DisplayTree == NULL)
00364 return(FALSE);
00365 }
00366
00367
00368 if(OpenLibFiles.IsEmpty())
00369 {
00370 if(!AddGRMGroups(SGLib_ClipArt))
00371 {
00372 String_256 sLoc = ClipartPath;
00373 String_256 sLoc2 = WebThemePath;
00374
00375
00376 String_256 sExePath;
00377 if(CResDll::GetExecutablePath((TCHAR*)sExePath))
00378 {
00379 INT32 oldi = GetClipTheme();
00380
00381 String_256 LibDirName;
00382 LibDirName.MakeMsg(_R(IDS_LIBRARIES_CLIPART_DIRNAME));
00383 ClipartPath = sExePath;
00384 ClipartPath += "\\";
00385 ClipartPath += LibDirName;
00386
00387 PathName ThisPath(ClipartPath);
00388 if(!SGLibOil::FileExists(&ThisPath))
00389 {
00390 SetClipTheme(0);
00391
00392 if(!ScanForLocation(SGLib_ClipArt, NULL))
00393 {
00394
00395
00396 ClipartPath = sLoc;
00397 }
00398 }
00399
00400 String_256 LibDirName2;
00401 LibDirName2.MakeMsg(_R(IDS_LIBRARIES_WEBTHEMES_DIRNAME));
00402 WebThemePath = sExePath;
00403 WebThemePath += "\\";
00404 WebThemePath += LibDirName2;
00405
00406 PathName ThisPath2(WebThemePath);
00407 if(!SGLibOil::FileExists(&ThisPath2))
00408 {
00409 SetClipTheme(0);
00410
00411 if(!ScanForLocation(SGLib_ClipArt_WebThemes, NULL))
00412 {
00413
00414
00415 WebThemePath = sLoc;
00416 }
00417 }
00418
00419 SetClipTheme(oldi);
00420 }
00421
00422 LibraryGallery::AddLibraryGroups(SGLib_ClipArt, &ClipartPath);
00423 LibraryGallery::AddLibraryGroups(SGLib_ClipArt_WebThemes, &WebThemePath);
00424 }
00425 }
00426
00427
00428 DisplayMode = LibClipartSGallery::DefaultDisplayMode;
00429
00430 return(TRUE);
00431 }
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 void LibClipartSGallery::SortGallery(void)
00453 {
00454
00455
00456
00457 if (GetClipTheme() == 0)
00458 {
00459 LibClipartSGallery::ClipartPath = LibClipartSGallery::DefaultLibraryPath;
00460 }
00461 else
00462 {
00463 LibClipartSGallery::WebThemePath = LibClipartSGallery::DefaultLibraryPath;
00464 }
00465
00466 LibraryGallery::SortGallery();
00467 }
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489 BOOL LibClipartSGallery::ApplyAction(SGActionType Action)
00490 {
00491
00492 if (DisplayTree == NULL)
00493 return(FALSE);
00494
00495 switch(Action)
00496 {
00497 case SGACTION_REDEFINE:
00498 break;
00499
00500 case SGACTION_APPLY:
00501 ImportClipart(TRUE, this);
00502 break;
00503
00504
00505
00506
00507
00508 case SGACTION_EDIT:
00509
00510 break;
00511
00512 case SGACTION_DELETE:
00513
00514 break;
00515
00516 case SGACTION_SETOPTIONS:
00517 {
00518 if (CurrentOptionsDlg == NULL)
00519 return(FALSE);
00520
00521 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_LARGE));
00522 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_FULLINFO));
00523 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_SMALL));
00524 }
00525 break;
00526
00527 case SGACTION_SETSORTMODE:
00528 {
00529 if (CurrentSortDlg == NULL)
00530 return(FALSE);
00531
00532 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_NAME));
00533 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_MEMORY));
00534 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_NAMELENGTH));
00535 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_FILETYPE));
00536 }
00537
00538 break;
00539
00540
00541 case SGACTION_DISPLAYMODECHANGED:
00542 if(DisplayMode >= 3) DisplayMode = 0;
00543 LibClipartSGallery::DefaultDisplayMode = DisplayMode;
00544 InvalidateCachedFormat();
00545 ReformatAndRedrawIfNecessary();
00546
00547 break;
00548
00549 default:
00550 return(SuperGallery::ApplyAction(Action));
00551 break;
00552 }
00553
00554 return(TRUE);
00555 }
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584 MsgResult LibClipartSGallery::Message(Msg* Message)
00585 {
00586
00587 static HANDLE handle = NULL;
00588 CString mutexName = "autorunMutex";
00589
00590
00591
00592
00593 if (DisplayTree == NULL)
00594 return(LibraryGallery::Message(Message));
00595
00596 if (IS_OUR_DIALOG_MSG(Message))
00597 {
00598 DialogMsg* Msg = (DialogMsg*)Message;
00599
00600 switch (Msg->DlgMsg)
00601 {
00602 case DIM_CREATE:
00603
00604
00605
00606
00607
00608
00609 handle = CreateMutex(NULL,TRUE,mutexName);
00610
00611
00612 SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYCLIPARTGALLERY, TRUE);
00613 GalleryAboutToReOpen();
00614 break;
00615
00616 case DIM_CANCEL:
00617
00618 if(handle != NULL)
00619 {
00620 CloseHandle(handle);
00621 }
00622
00623
00624 SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYCLIPARTGALLERY, FALSE);
00625
00626
00627 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::ThumbState::KILLCACHE, SGLib_ClipArt), DialogOp);
00628 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::ThumbState::KILLCACHE, SGLib_ClipArt_WebThemes), DialogOp);
00629 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::ThumbState::KILLCACHE, SGLib_Bitmap), DialogOp);
00630
00631 GalleryAboutToClose();
00632
00633 break;
00634
00635 case DIM_LFT_BN_CLICKED:
00636 switch (Msg->GadgetID)
00637 {
00638 case _R(IDC_LIBGAL_OPEN):
00639 ImportClipart(TRUE, this);
00640 break;
00641
00642 case _R(IDC_GALLERY_HELP):
00643 HelpUserTopic(_R(IDS_HELPPATH_Gallery_Clipart));
00644 break;
00645
00646
00647 case _R(IDC_LIBGAL_UPDATE):
00648 #ifdef _BATCHING
00649 LoadAndSave();
00650 #endif
00651 break;
00652
00653 case _R(IDC_LIBGAL_IMPORT):
00654 ImportClipart(FALSE, this);
00655 break;
00656
00657 case _R(IDC_LIBGAL_BROWSE):
00658 case _R(IDC_LIBGAL_ADD_CLIPART):
00659 BrowseClicked();
00660 break;
00661
00662 case _R(IDC_BMPGAL_SAVE):
00663 #ifdef _DEBUG
00664 {
00665 SGDisplayNode *Item = DisplayTree->FindNextSelectedItem(NULL);
00666 if(Item != NULL && Item->IsKindOf(CC_RUNTIME_CLASS(SGLibDisplayItem)))
00667 {
00668 SGLibDisplayItem *LibItem = (SGLibDisplayItem *)Item;
00669
00670 Library *Parent = LibItem->GetParentLibrary();
00671 if(Parent != NULL)
00672 {
00673 Error::SetError(0, TEXT("Renumber ID's ? (Doing this will mess external thumbnails up in a major way !)"), 0);
00674 INT32 ButtonPressed = InformWarning(0, _R(IDS_OK), _R(IDS_KEEP), _R(IDS_CANCEL), NULL);
00675
00676 if(ButtonPressed != 3)
00677 {
00678 PathName *Source = Parent->ReturnIndexLocation();
00679 PathName Dest(*Source);
00680 Dest.SetType((String_256)"BAK");
00681 SGLibOil::FileCopy(Source, &Dest);
00682 Parent->SaveIndexInDisplayedOrder(Source, (ButtonPressed == 1));
00683 }
00684 }
00685 }
00686 }
00687 #endif
00688 break;
00689
00690 default:
00691 break;
00692 }
00693
00694 #ifdef _PROFILE_REDRAW
00695 case DIM_REDRAW:
00696 if (Msg->GadgetID == GetListGadgetID())
00697 {
00698 ProfileRedraw((ReDrawInfoType*) Msg->DlgMsgParam);
00699 return(DialogBarOp::Message(Message));
00700 break;
00701 }
00702 break;
00703 #endif
00704 }
00705 }
00706 else if (MESSAGE_IS_A(Message, DocChangingMsg))
00707 {
00708 DocChangingMsg *Msg = (DocChangingMsg *) Message;
00709 switch (Msg->State)
00710 {
00711 case DocChangingMsg::DocState::SELCHANGED:
00712 if (Msg->pNewDoc == NULL)
00713 {
00714
00715
00716 SuperGallery::ShadeGallery(TRUE);
00717 }
00718 else
00719 {
00720
00721 SuperGallery::ShadeGallery(FALSE);
00722 SelectionHasChanged();
00723 }
00724 break;
00725 }
00726 }
00727 else if (MESSAGE_IS_A(Message, ThumbMessage) && DisplayTree != NULL)
00728 {
00729 ThumbMessage *Msg = (ThumbMessage *) Message;
00730
00731
00732 if(Msg->State == ThumbMessage::ThumbState::CACHESIZECHANGED)
00733 {
00734 FlushBackgroundRedraws();
00735 ForceRedrawOfList();
00736 }
00737 }
00738
00739 return(LibraryGallery::Message(Message));
00740 }
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761 BOOL LibClipartSGallery::BrowseClicked(void)
00762 {
00763 if (GetClipTheme() == 0)
00764 {
00765 return (LibraryGallery::BrowseClicked(&DefaultLibraryPath, SGLib_ClipArt, _R(IDS_REMOVE_OLD_GOUPS_CLIPART)));
00766 }
00767 else
00768 {
00769 return (LibraryGallery::BrowseClicked(&DefaultLibraryPath, SGLib_ClipArt_WebThemes, _R(IDS_REMOVE_OLD_GOUPS_CLIPART)));
00770 }
00771 }
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787 BOOL LibClipartSGallery::CanCreateIndexes(void)
00788 {
00789 return TRUE;
00790 }
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810 BOOL LibClipartSGallery::GetDefaults(String_256 *DefaultIndex, String_256 *IndexDesc, SGLibType *Type)
00811 {
00812 TRACEUSER( "Matt", _T("Getting defaults for clipart gallery\n"));
00813 if(DefaultIndex != NULL)
00814 {
00815
00816 if (GetClipTheme() == 0)
00817 {
00818 *DefaultIndex = _R(IDS_LIBRARIES_CLIPART_FILENAME);
00819 }
00820 else
00821 {
00822 *DefaultIndex = _R(IDS_LIBRARIES_WEBTHEMES_FILENAME);
00823 }
00824 }
00825
00826 if(IndexDesc != NULL)
00827 *IndexDesc = _R(IDS_LIBRARIES_CLIPART_DESC);
00828
00829 if(Type != NULL)
00830 {
00831
00832
00833
00834 if (GetClipTheme() == 0)
00835 {
00836 *Type = SGLib_ClipArt;
00837 }
00838 else
00839 {
00840 *Type = SGLib_ClipArt_WebThemes;
00841 }
00842 }
00843
00844 return TRUE;
00845 }
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861 BOOL LibClipartSGallery::GetLibraryDirectoryName(String_256 *LibDirName)
00862 {
00863 TRACEUSER( "Matt", _T("Getting library directory name for clipart gallery\n"));
00864 if (GetClipTheme() == 0)
00865 {
00866 LibDirName->MakeMsg(_R(IDS_LIBRARIES_CLIPART_DIRNAME));
00867 }
00868 else
00869 {
00870 LibDirName->MakeMsg(_R(IDS_LIBRARIES_WEBTHEMES_DIRNAME));
00871 }
00872 return TRUE;
00873 }
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889 BOOL LibClipartSGallery::CheckForIndexMatch(StringBase *Txt)
00890 {
00891 BOOL Match = FALSE;
00892
00893
00894 if(((Txt->Sub(String_8("A"))!=-1) || (Txt->Sub(String_8("a"))!=-1)) ) Match = TRUE;
00895 if(((Txt->Sub(String_8("B"))!=-1) || (Txt->Sub(String_8("b"))!=-1)) ) Match = TRUE;
00896
00897 return Match;
00898 }
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912 BOOL LibClipartSGallery::GetQuietStatus(void)
00913 {
00914 return LibClipartSGallery::QuietStatus;
00915 }
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929 void LibClipartSGallery::SetQuietStatus(BOOL Status)
00930 {
00931 LibClipartSGallery::QuietStatus = Status;
00932 }
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953 BOOL LibClipartSGallery::ScanForLocation(SGLibType Type, StringBase *Result)
00954 {
00955
00956 String_256 DriveName;
00957 BOOL AreWeXara = FALSE;
00958 String_256 XaraDrive;
00959
00960 BOOL Adjust = KeyPress::IsAdjustPressed();
00961 #ifndef _DEBUG
00962 Adjust = FALSE;
00963 #endif
00964
00965 if(SGLibOil::LocateCDROMDrive(this, Type, &DriveName, &AreWeXara, &XaraDrive, Adjust))
00966 {
00967 if(AreWeXara)
00968 DriveName = XaraDrive;
00969
00970 switch(Type)
00971 {
00972 case SGLib_ClipArt:
00973 case SGLib_ClipArt_WebThemes:
00974 case SGLib_Bitmap:
00975 {
00976 LibClipartSGallery::DefaultLibraryPath = DriveName;
00977 #ifdef _DEBUG
00978 if(Adjust)
00979 {
00980 LibClipartSGallery::DefaultLibraryPath += TEXT("Graphics\\XaraSt~1");
00981 }
00982 else
00983 #endif
00984 {
00985 String_256 LibDirName;
00986 GetLibraryDirectoryName(&LibDirName);
00987 LibClipartSGallery::DefaultLibraryPath += LibDirName;
00988 }
00989
00990 if(Result)
00991 *Result = LibClipartSGallery::DefaultLibraryPath;
00992
00993 if (GetClipTheme() == 0)
00994 {
00995 LibClipartSGallery::ClipartPath = LibClipartSGallery::DefaultLibraryPath;
00996 }
00997 else
00998 {
00999 LibClipartSGallery::WebThemePath = LibClipartSGallery::DefaultLibraryPath;
01000 }
01001
01002 return TRUE;
01003 }
01004
01005 }
01006 }
01007 return FALSE;
01008 }
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030 void LibClipartSGallery::HandleDragStart(DragMessage *DragMsg)
01031 {
01032
01033
01034 if (DragMsg->pInfo->IsKindOf(CC_RUNTIME_CLASS(GalleryClipartDragInfo)))
01035 SGClipartDragTarget *NewTarget = new SGClipartDragTarget(this, GetListGadgetID());
01036 else
01037 SuperGallery::HandleDragStart(DragMsg);
01038 }
01039
01040
01041
01042
01043 void LibClipartSGallery::ProfileRedraw(ReDrawInfoType *Param)
01044 {
01045 #ifdef _PROFILE_REDRAW
01046 RenderListBox(Param);
01047 #endif
01048 }
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068 BOOL LibClipartSGallery::ImportClipart(BOOL NewDocument, LibraryGallery* pSourceGallery)
01069 {
01070 TRACEUSER( "Matt", _T("Importing clipart in clipart gallery\n"));
01071 if (pSourceGallery->DisplayTree == NULL)
01072 {
01073 ERROR3("LibClipartSGallery::ImportClipart No display tree - bad !");
01074 return FALSE;
01075 }
01076
01077 if(Document::GetSelected() == NULL && !NewDocument)
01078 {
01079 return FALSE;
01080 }
01081
01082 BOOL ok = TRUE;
01083
01084
01085
01086
01087 SGDisplayNode *Item = pSourceGallery->DisplayTree->FindNextSelectedItem(NULL);
01088 String_256 ItemText;
01089
01090 while (Item != NULL)
01091 {
01092 if(Item->IsKindOf(CC_RUNTIME_CLASS(SGClipartItem)) || Item->IsKindOf(CC_RUNTIME_CLASS(SGFillsItem)))
01093 {
01094 Item->GetNameText(&ItemText);
01095
01096 if(Item->Flags.Selected)
01097 {
01098 PathName FileName;
01099 SGLibDisplayItem *ClipItem = (SGLibDisplayItem *) Item;
01100
01101
01102 ok = ClipItem->GetFileName(&FileName);
01103
01104 if(ok)
01105 {
01106
01107 if(FileName.GetFileName(FALSE) == (String_256)"Moo")
01108 {
01109 INT32 Size = ClipItem->GetFileSize(NULL);
01110 if(Size == 1080904)
01111 FileName.SetType("TIF");
01112 }
01113
01114 if(!FileName.IsValid(FileName.GetPath()))
01115 {
01116 ERROR3("LibClipartSGallery::ImportClipart - Filename is invalid");
01117 return FALSE;
01118 }
01119
01120
01121 String_256 FilePath((const TCHAR *)FileName.GetPath());
01122 String_256 LongFileName;
01123 BOOL LongPath = FileUtil::GetLongFileName((LPTSTR)FilePath, (LPTSTR)LongFileName, 255);
01124 if(LongPath)
01125 {
01126 FilePath = FileName.GetLocation(TRUE);
01127 FilePath += LongFileName;
01128 }
01129
01130
01131 Library* pLibrary = ClipItem->GetParentLibrary();
01132 if (!pLibrary)
01133 {
01134 ERROR3("Illegal NULL pointer");
01135 return FALSE;
01136 }
01137 BOOL bIsLocalFile;
01138 if (!pLibrary->IsWebLibrary())
01139 bIsLocalFile = TRUE;
01140 else
01141 bIsLocalFile = (_access((TCHAR*) FilePath, 0) != -1);
01142
01143 if(NewDocument)
01144 {
01145 if (bIsLocalFile)
01146 {
01147 CWinApp* pApp = AfxGetApp();
01148 BaseFileDialog::SelectedFilter = 0;
01149
01150
01151 CCamDoc* pDoc = (CCamDoc*) pApp->OpenDocumentFile((TCHAR *)FilePath);
01152
01153
01154 if(pDoc) pDoc->GetKernelDoc()->ForceRedraw();
01155 }
01156 else
01157 {
01158 goto ASYNCH_IMPORT;
01159 }
01160 }
01161 else
01162 {
01163
01164 if (bIsLocalFile)
01165 {
01166
01167 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpClipartImport));
01168
01169 if (pOpDesc != NULL)
01170 {
01171 ClipartImportParam Param;
01172
01173 PathName FullPathName(FilePath);
01174
01175
01176 Param.File = &FullPathName;
01177 Param.Import = !NewDocument;
01178 Param.Result = TRUE;
01179
01180
01181 pOpDesc->Invoke((OpParam *) &Param);
01182
01183 ok = Param.Result;
01184 if(!ok)
01185 {
01186 ERROR3("LibClipartSGallery::ImportClipart - Problem importing file");
01187 return FALSE;
01188 }
01189 }
01190 }
01191 else
01192 {
01193 ASYNCH_IMPORT:
01194 String_256 strFileURL = FilePath;
01195 pLibrary->LocalPath2URL(&strFileURL);
01196 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpAsynchClipartImport));
01197
01198 if (pOpDesc != NULL)
01199 {
01200 AsynchClipartImportParam* Param = new AsynchClipartImportParam;
01201 ERROR2IF(!Param, FALSE, "Memory allocation error");
01202
01203 Param->File.SetPathName((TCHAR *)FilePath);
01204 String_256 strDescription;
01205 ClipItem->GetNameText(&strDescription);
01206 Param->