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->strDescription = _T("'");
01207 Param->strDescription += strDescription;
01208 Param->strDescription += _T("'");
01209 Param->strURL = strFileURL;
01210 Param->Import = !NewDocument;
01211 Param->bDropped = FALSE;
01212
01213 pOpDesc->Invoke((OpParam*) Param);
01214 }
01215 }
01216 }
01217 }
01218 }
01219 }
01220 Item = SGDisplayRoot::FindNextItemInTree(Item);
01221 }
01222
01223 return TRUE;
01224 }
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245 BOOL LibClipartSGallery::LoadAndSave(void)
01246 {
01247
01248 #ifdef _BATCHING
01249
01250 if (DisplayTree == NULL)
01251 {
01252 ERROR3("LibClipartSGallery::LoadAndSave No display tree - bad !");
01253 return FALSE;
01254 }
01255
01256
01257 PageTab PTab;
01258 if(!PTab.Init())
01259 {
01260 ERROR3("Can't init page resizing stuff...");
01261 return FALSE;
01262 }
01263
01264
01265
01266 SGDisplayNode *Item = DisplayTree->FindNextSelectedItem(NULL);
01267
01268 String_256 ItemText;
01269
01270 while (Item != NULL)
01271 {
01272 if(Item->IsKindOf(CC_RUNTIME_CLASS(SGClipartItem)))
01273 {
01274 Item->GetNameText(&ItemText);
01275
01276
01277 if(Item->Flags.Selected || TRUE)
01278 {
01279 PathName FileName;
01280 SGLibDisplayItem *ClipItem = (SGLibDisplayItem *) Item;
01281
01282 BOOL ok = TRUE;
01283
01284
01285 ok = ClipItem->GetFileName(&FileName);
01286
01287
01288 String_8 Ending;
01289 if(ok) Ending = FileName.GetType();
01290 if(ok) Ending.toLower();
01291 if( ok)
01292 {
01293
01294 CWinApp* pApp = AfxGetApp();
01295 BaseFileDialog::SelectedFilter = 0;
01296
01297 if(!FileName.IsValid(FileName.GetPath()))
01298 {
01299 ERROR3("Filename is invalid");
01300 }
01301
01302 String_256 Path(FileName.GetPath());
01303
01304
01305 String_256 OutputPath(LibClipartSGallery::BatchSaveLocation);
01306
01307
01308 if(OutputPath.Length() == 0)
01309 OutputPath = Path;
01310 else
01311 {
01312 if(OutputPath[OutputPath.Length()-1] != '\\')
01313 OutputPath += TEXT("\\");
01314 OutputPath += FileName.GetFileName(TRUE);
01315 }
01316
01317 PathName OutputPathART(OutputPath);
01318 OutputPathART.SetType((String_256)"XAR");
01319 String_256 SavePath(OutputPathART.GetPath());
01320
01321 Error::ClearError();
01322
01323
01324
01325
01326
01327 MonotonicTime Time;
01328 INT32 OpenTime = Time.Sample();
01329 INT32 InitialSize = SGLibOil::FileSize(&FileName);
01330
01331
01332
01333
01334 #ifndef SAVEASWELL
01335 FILE *FP = _tfopen("C:\\load.txt", "a");
01336 if(FP != NULL)
01337 {
01338 _ftprintf(FP, "Loading: %s\r\n", (TCHAR *)Path);
01339 fclose(FP);
01340 }
01341 #endif
01342
01343
01344 CCamDoc* pDoc = (CCamDoc*) pApp->OpenDocumentFile((TCHAR *)Path);
01345
01346
01347 #ifndef SAVEASWELL
01348
01349 if(pDoc == NULL)
01350 {
01351 FP = _tfopen("C:\\batch.txt", "a");
01352 if(FP != NULL)
01353 {
01354 _ftprintf(FP, "Problems: %s\r\n", (TCHAR *)Path);
01355 fclose(FP);
01356 }
01357 }
01358 else
01359 {
01360 Error::ClearError();
01361
01362 ((CCamDoc *) (((CMDIFrameWnd *)
01363 ((AfxGetApp())->m_pMainWnd))->MDIGetActive()
01364 )->GetActiveDocument()
01365 )->OnFileClose();
01366 }
01367 Error::ClearError();
01368
01369 #else
01370 OpenTime = Time.Sample() - OpenTime;
01371
01372 if (pDoc != NULL)
01373 {
01374 INT32 Pass = 0;
01375
01376
01377
01378
01379
01380
01381 #if 0
01382 Document* OurDocument = pDoc->GetKernelDoc();
01383 Spread* OurSpread = OurDocument->FindFirstSpread();
01384 Page* CurrentPage = OurSpread->FindFirstPageInSpread();
01385
01386 if(OurDocument == NULL || OurSpread == NULL || CurrentPage == NULL)
01387 {
01388 Error::SetError(0, String_256("NULL Page/Spread/Doc in batcher..."), 0);
01389 InformWarning(0, _R(IDS_OK), NULL);
01390 Error::ClearError();
01391 }
01392 else
01393 {
01394 OurDocument->SetCurrent();
01395
01396
01397 Layer* pLayer = OurSpread->FindFirstLayer();
01398
01399 INT32 Count = 0;
01400 while(pLayer)
01401 {
01402 Node* pNode = pLayer->FindFirstChild();
01403 BOOL ChildFound = FALSE;
01404
01405 while (pNode != NULL && !ChildFound)
01406 {
01407 ChildFound = pNode->IsBounded();
01408 pNode = pNode->FindNext();
01409 }
01410
01411 Layer *tLayer = pLayer->FindNextLayer();
01412
01413 if(!ChildFound)
01414 pLayer->UnlinkNodeFromTree();
01415 else
01416 {
01417 pLayer->SetVisible(TRUE);
01418 pLayer->SetLocked(FALSE);
01419 Count ++;
01420 }
01421
01422 pLayer = tLayer;
01423 }
01424
01425
01426 if(Count == 1)
01427 {
01428 Layer* pLayer = OurSpread->FindFirstLayer();
01429 if(pLayer)
01430 pLayer->SetLayerID(String_256("Clipart"));
01431 }
01432
01433
01434
01435
01436
01437
01438 DocRect OurItemRect = OurSpread->GetBoundingRect();
01439 DocRect OurPageRect = CurrentPage->GetPageRect();
01440
01441 if (AppPrefsDlg::pPageSizesList != NULL)
01442 {
01443 PageId PageChosen = A4;
01444 MILLIPOINT Width;
01445 MILLIPOINT Height;
01446 AppPrefsDlg::pPageSizesList->GetSizeFromPageId(PageChosen, &Width, &Height);
01447
01448
01449 if( ((OurItemRect.Width() > OurItemRect.Height()) && (OurPageRect.Width() < OurPageRect.Height()))
01450 || ((OurItemRect.Width() < OurItemRect.Height()) && (OurPageRect.Width() > OurPageRect.Height())) )
01451 {
01452 MILLIPOINT Tmp = Width;
01453 Width = Height;
01454 Height = Tmp;
01455 }
01456
01457 TRACEUSER( "Richard", _T("width %d height %d in MP\n"),Width,Height);
01458
01459
01460 PageResizeInfo Param;
01461
01462
01463 Param.Height = Height;
01464 Param.Width = Width;
01465
01466 MILLIPOINT Margin = Width / 2;
01467 if(Height < Width)
01468 Margin = Height / 2;
01469
01470 Param.Margin = Margin;
01471 Param.Bleed = 0;
01472 Param.Portrait = (Width < Height);
01473 Param.Dps = FALSE;
01474 Param.ShowDropShadow = TRUE;
01475
01476
01477
01478
01479
01480
01481 Param.pSpread = OurSpread;
01482 OptionsTabs::SetCurrentDocAndSpread(OurDocument);
01483
01484
01485 PTab.InvokeResizeAndCentre(&Param);
01486
01487
01488 LibClipartSGallery::DefaultSortKeys = TRUE;
01489
01490
01491 OpZoomDescriptor::FakeInvoke(OPTOKEN_ZOOMDRAWING);
01492
01493 LibClipartSGallery::DefaultSortKeys = FALSE;
01494
01495 OurDocument->ForceRedraw();
01496 }
01497 }
01498
01499
01500
01501 OurDocument = pDoc->GetKernelDoc();
01502 OurSpread = OurDocument->FindFirstSpread();
01503 CurrentPage = OurSpread->FindFirstPageInSpread();
01504
01505 DocRect OurItemRect = OurSpread->GetBoundingRect();
01506 DocRect OurPageRect = CurrentPage->GetPageRect();
01507
01508 BOOL PossiblyOutsidePage = FALSE;
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519 Document *TheDoc = OurDocument;
01520
01521 ColourList *ParentList = TheDoc->GetIndexedColours();
01522
01523 INT32 TotalItems = ParentList->GetCount();
01524 INT32 DeletedItems = 0;
01525
01526 IndexedColour **KillList = new IndexedColourPtr[TotalItems+1];
01527 if (KillList != NULL)
01528 {
01529
01530 DWORD KillIndex = 0;
01531 IndexedColour *Ptr = ParentList->GetUndeletedHead();
01532
01533 while (Ptr != NULL)
01534 {
01535 if(!Ptr->IsInUse())
01536 {
01537 DeletedItems++;
01538 KillList[KillIndex++] = Ptr;
01539 }
01540
01541 Ptr = ParentList->GetUndeletedNext(Ptr);
01542 }
01543
01544 KillList[KillIndex] = NULL;
01545
01546
01547 ColourManager::HideColours(ParentList, KillList, TRUE);
01548
01549
01550
01551 delete [] KillList;
01552 }
01553
01554
01555 if(TotalItems == DeletedItems)
01556 {
01557
01558
01559
01560
01561 PathName FileName((String_256)"C:\\pal.art");
01562 if(SGLibOil::FileExists(&FileName))
01563 {
01564
01565 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpClipartImport));
01566
01567 if (pOpDesc != NULL)
01568 {
01569 ClipartImportParam Param;
01570
01571
01572 Param.File = &FileName;
01573 Param.Import = TRUE;
01574 Param.Result = TRUE;
01575
01576
01577 pOpDesc->Invoke((OpParam *) &Param);
01578
01579 ok = Param.Result;
01580
01581 if(!ok)
01582 {
01583 ERROR3("Batching... Problem importing file");
01584 return FALSE;
01585 }
01586 }
01587 }
01588
01589
01590 }
01591
01592 #endif
01593 INT32 CloseTime = Time.Sample();
01594
01595 BOOL Worked = TRUE;
01596 #if 0 //#ifndef NEW_NATIVE_FILTER
01597
01598 Worked = pDoc->OnSaveDocument((TCHAR *)SavePath) && Worked;
01599 Error::ClearError();
01600
01601 INT32 FinalSize = SGLibOil::FileSize(&OutputPathART);
01602 CloseTime = Time.Sample() - CloseTime;
01603 #endif
01604 #if 0 // Save a document, but ensure it is in the old format!
01605 Worked = pDoc->OnSaveVersion1Document((TCHAR *)SavePath) && Worked;
01606 Error::ClearError();
01607
01608 INT32 FinalSize = SGLibOil::FileSize(&OutputPathART);
01609 CloseTime = Time.Sample() - CloseTime;
01610
01611 #endif
01612
01613 PathName path(SavePath);
01614
01615 #if 0 // Do an Export of the file as a version 2 Native file
01616 path.SetType(TEXT("CXN"));
01617 path.SetType(TEXT("xar"));
01618 CCDiskFile file(path, ios::out | ios::binary | ios::trunc);
01619 BOOL NativeExportWorked = InvokeNativeFileOp(OPTOKEN_SAVEASNATIVEV2, &file, FILTERID_NATIVE);
01620 Error::ClearError();
01621 Worked = NativeExportWorked && Worked;
01622 #endif
01623 #if 0 // Do an Export of the file as a Web file
01624 path.SetType(TEXT("web"));
01625 CCDiskFile webfile(path, ios::out | ios::binary | ios::trunc);
01626 BOOL WebExportWorked = InvokeNativeFileOp(OPTOKEN_NATIVESAVE, &webfile, FILTERID_WEB);
01627 Error::ClearError();
01628 Worked = WebExportWorked && Worked;
01629 #endif
01630 #if 1 // Rename the file as a munged 8.3 file if saving in the same place - none of this is wheat germ and shouldn't
01631
01632 if (LibClipartSGallery::BatchSaveLocation.Length() == 0)
01633 {
01634
01635
01636
01637
01638
01639 BOOL RenameWorked = FALSE;
01640 String_256 TempName = FileName.GetLocation();
01641
01642 char * temmmmmp = _tempnam( TempName, TEXT("~XARA") );
01643 if( temmmmmp != NULL )
01644 {
01645
01646 TempName = temmmmmp;
01647
01648 free( temmmmmp );
01649 temmmmmp = NULL;
01650
01651 if ( 0 == rename( FileName.GetPath(), TempName ) )
01652 {
01653
01654
01655 RenameWorked = !rename( TempName, FileName.GetPath() );
01656 }
01657 }
01658 Worked = RenameWorked && Worked;
01659 }
01660 else
01661 {
01662
01663 path.SetType(TEXT("web"));
01664 CCDiskFile webfile(path, ios::out | ios::binary | ios::trunc);
01665 BOOL WebExportWorked = InvokeNativeFileOp(OPTOKEN_NATIVESAVE, &webfile, FILTERID_WEB);
01666 Error::ClearError();
01667 Worked = WebExportWorked && Worked;
01668 }
01669 #endif
01670 #if 1 // Do an Export of the file as a png thumbnail file to the "XaraInfo" directory
01671
01672 Document* OurDocument = pDoc->GetKernelDoc();
01673 PORTNOTE("spread", "Multi-spread warning!")
01674 Spread* OurSpread = OurDocument->FindFirstSpread();
01675 Layer* pLayer = OurSpread->FindFirstLayer();
01676 DocRect Bounds;
01677 while (pLayer != NULL)
01678 {
01679 Bounds = Bounds.Union(pLayer->GetBoundingRect());
01680 pLayer = pLayer->FindNextLayer();
01681 }
01682
01683 INT32 d = Bounds.Width();
01684 if (Bounds.Height() > d)
01685 d = Bounds.Height();
01686
01687 if (d < (72000*2))
01688 {
01689 CCamDoc* pCCamDoc = OurDocument->GetOilDoc();
01690 pCCamDoc->ScaleContents(5.0,5.0);
01691 }
01692
01693
01694 String_256 ThumbPathStr = path.GetLocation();
01695 ThumbPathStr += String_16(_R(IDS_LIBRARIES_XARAINFO_DIRNAME));
01696 ThumbPathStr += TEXT("\\");
01697 ThumbPathStr += path.GetFileName();
01698
01699 path = PathName(ThumbPathStr);
01700
01701 path.SetType(TEXT("png"));
01702 CCDiskFile thumbfile(path, ios::out | ios::binary | ios::trunc);
01703 BOOL ThumbExportWorked = InvokeNativeFileOp(OPTOKEN_NATIVESAVE, &thumbfile, FILTERID_PREVIEW_PNG);
01704 Error::ClearError();
01705 Worked = ThumbExportWorked && Worked;
01706 #endif
01707
01708
01709
01710 if(Worked)
01711 ((CCamDoc *) (((CMDIFrameWnd *)
01712 ((AfxGetApp())->m_pMainWnd))->MDIGetActive()
01713 )->GetActiveDocument()
01714 )->OnFileClose();
01715
01716 Error::ClearError();
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726 if(!Worked)
01727 {
01728 FILE *FP = _tfopen("C:\\batch.txt", "a");
01729 if(FP != NULL)
01730 {
01731 _ftprintf(FP, "Problems saving: %s\r\n", (TCHAR *)Path);
01732 fclose(FP);
01733 }
01734 }
01735 else
01736 {
01737 #if 0
01738 if(PossiblyOutsidePage)
01739 {
01740 FILE *FP = _tfopen("C:\\batch.txt", "a");
01741 if(FP != NULL)
01742 {
01743 _ftprintf(FP, "Possibly outside: %s\r\n", (TCHAR *)Path);
01744 fclose(FP);
01745 }
01746 }
01747 #endif
01748 }
01749 }
01750 else
01751 {
01752 FILE *FP = _tfopen("C:\\batch.txt", "a");
01753 if(FP != NULL)
01754 {
01755 _ftprintf(FP, "Problems loading: %s\r\n", (TCHAR *)Path);
01756 fclose(FP);
01757 }
01758 }
01759 #endif //SAVEASWELL
01760
01761 }
01762 }
01763
01764 }
01765
01766 Item = SGDisplayRoot::FindNextItemInTree(Item);
01767 }
01768
01769 #endif
01770 return TRUE;
01771 }
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802 SGDisplayItem *LibClipartSGallery::AddLibraryItem(SGDisplayGroup *LibraryGroup, Library *ParentLib, LibraryIndex ItemIndex, BOOL bNew)
01803 {
01804 TRACEUSER( "Matt", _T("Add library item called in clipart gallery\n"));
01805 ERROR3IF(LibraryGroup == NULL || ParentLib == NULL,
01806 "SuperGallery::AddLibraryItem - NULL params are illegal");
01807
01808 ERROR3IF(LibraryGroup->GetParentLibrary() != ParentLib,
01809 "SuperGallery::AddLibraryitem - The DisplayGroup is not for the same library!");
01810
01811
01812
01813 SGClipartItem *NewItem = new SGClipartItem(ItemIndex, bNew);
01814
01815
01816
01817 if((ParentLib->Title != NULL) && (ParentLib->Title->Sub((String_8)"Studio") == 0))
01818 {
01819 String_256 TmpPath;
01820 BOOL ok = ParentLib->GetFilename(ItemIndex, &TmpPath, FALSE);
01821
01822 if(ok)
01823 {
01824 INT32 Size = NewItem->GetFileSize(ParentLib);
01825 if(Size == 113852)
01826 {
01827 String_256 TmpPath;
01828 BOOL ok = ParentLib->GetFilename(ItemIndex, &TmpPath, FALSE);
01829
01830 if(TmpPath == (String_16)"Rolex.art")
01831 {
01832 delete NewItem;
01833 NewItem = FALSE;
01834 }
01835 }
01836 }
01837 }
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848 if (NewItem != NULL)
01849 LibraryGroup->AddItem(NewItem);
01850
01851 return(NewItem);
01852 }
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868 void LibClipartSGallery::ModeHasChanged(void)
01869 {
01870 TRACEUSER( "Matt", _T("MODE has changed called in clipart gallery\n"));
01871 if (DisplayTree == NULL)
01872 {
01873 return;
01874 }
01875
01876 INT32 libindex = 0;
01877
01878
01879 LibraryFile* pLibFile = (LibraryFile*) OpenLibFiles.GetHead();
01880 while (pLibFile)
01881 {
01882 Library* pLib = (Library*) pLibFile->Libraries.GetHead();
01883
01884 while (pLib)
01885 {
01886 if ((pLib->Type == SGLib_ClipArt) && (GetClipTheme() != 0))
01887 {
01888 pLib->ParentGroup->Flags.Invisible = true;
01889 pLib->ParentGroup->Flags.CanSelect = false;
01890 pLib->ParentGroup->Flags.Selected = false;
01891 pLib->ParentGroup->Flags.Folded = true;
01892 }
01893 else if ((pLib->Type == SGLib_ClipArt_WebThemes) && (GetClipTheme() != 1))
01894 {
01895 pLib->ParentGroup->Flags.Invisible = true;
01896 pLib->ParentGroup->Flags.CanSelect = false;
01897 pLib->ParentGroup->Flags.Selected = false;
01898 pLib->ParentGroup->Flags.Folded = true;
01899 }
01900 else
01901 {
01902 pLib->ParentGroup->Flags.Invisible = false;
01903 pLib->ParentGroup->Flags.CanSelect = true;
01904 }
01905
01906 pLib = (Library*) pLibFile->Libraries.GetNext(pLib);
01907 }
01908
01909 pLibFile = (LibraryFile*) OpenLibFiles.GetNext(pLibFile);
01910 }
01911
01912 ReformatNow(true);
01913 }
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930 void LibClipartSGallery::SelectionHasChanged(void)
01931 {
01932 TRACEUSER( "Matt", _T("Selection has changed called in clipart gallery\n"));
01933 if (DisplayTree == NULL)
01934 return;
01935
01936 INT32 Count = DisplayTree->GetSelectedItemCount();
01937
01938 EnableGadget(_R(IDC_LIBGAL_OPEN), (Count > 0));
01939 #ifdef _BATCHING
01940 EnableGadget(_R(IDC_LIBGAL_UPDATE), (Count > 0));
01941 #endif
01942
01943 #ifndef STANDALONE
01944 EnableGadget(_R(IDC_LIBGAL_IMPORT), (Count > 0) && Document::GetSelected() != NULL);
01945 #else
01946 EnableGadget(_R(IDC_LIBGAL_IMPORT), FALSE);
01947 #endif
01948
01949 EnableGadget(_R(IDC_LIBGAL_ADD_CLIPART), TRUE);
01950
01951
01952
01953 LibraryGallery::SelectionHasChanged();
01954 }
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968 void LibClipartSGallery::DoShadeGallery(BOOL ShadeIt)
01969 {
01970 if (DisplayTree == NULL)
01971 return;
01972
01973
01974 EnableGadget(_R(IDC_GALLERY_MENU), TRUE);
01975
01976 if(ShadeIt)
01977 {
01978 EnableGadget(_R(IDC_LIBGAL_IMPORT), FALSE);
01979 }
01980
01981 EnableGadget(_R(IDC_LIBGAL_ADD_CLIPART), TRUE);
01982
01983
01984 LibraryGallery::DoShadeGallery(ShadeIt);
01985 }
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001 BOOL LibClipartSGallery::CanSearchKeywords(void)
02002 {
02003 return(TRUE);
02004 }
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021 void LibClipartSGallery::WorkOutSectionName(String_256 *Section)
02022 {
02023 if(Section)
02024 *Section = _R(IDS_SGLCART_SECTION_NAME);
02025 }
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044 SGDisplayGroup *LibClipartSGallery::AddLibraryGroup(Library *LibraryToDisplay, INT32 NumItems)
02045 {
02046 TRACEUSER( "Matt", _T("Add library group called in clipart gallery\n"));
02047 ERROR3IF(LibraryToDisplay == NULL, "LibClipartSGallery::AddLibraryGroup - NULL parameter is illegal");
02048
02049 if (DisplayTree == NULL)
02050 {
02051 ERROR3("LibClipartSGallery::AddLibraryGroup called before the DisplayTree was initialised!");
02052 return(NULL);
02053 }
02054
02055
02056 m_bRedraw = true;
02057 SGLibGroup *TheGroup = (SGLibGroup *)DisplayTree->FindSubtree(this, NULL, LibraryToDisplay);
02058
02059 if (TheGroup == NULL)
02060 {
02061
02062 TheGroup = new SGLibGroup(this, NULL, LibraryToDisplay);
02063
02064 if (TheGroup == NULL)
02065 return(NULL);
02066
02067
02068 if (((GetClipTheme() == 0) && (LibraryToDisplay->Type == SGLib_ClipArt_WebThemes)) || ((GetClipTheme() == 1) && (LibraryToDisplay->Type == SGLib_ClipArt)))
02069 {
02070 TheGroup->Flags.Invisible = true;
02071 TheGroup->Flags.CanSelect = false;
02072 }
02073 DisplayTree->AddItem(TheGroup);
02074 TRACEUSER( "Matt", _T("...Add library group has just added the item to the display tree\n"));
02075 }
02076 else
02077 {
02078 if (((GetClipTheme() == 0) && (LibraryToDisplay->Type == SGLib_ClipArt_WebThemes)) || ((GetClipTheme() == 1) && (LibraryToDisplay->Type == SGLib_ClipArt)))
02079 {
02080 TheGroup->Flags.Invisible = true;
02081 TheGroup->Flags.CanSelect = false;
02082 }
02083
02084 TheGroup->DestroySubtree(FALSE);
02085 }
02086
02087 return(TheGroup);
02088 }
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132 SGDisplayItem *LibClipartSGallery::CopyDisplayItem(SGDisplayItem *SourceItem,
02133 SGDisplayGroup *DestGroup, SGDisplayItem *TargetPosition)
02134 {
02135 TRACEUSER( "Matt", _T("Copy display item called in clipart gallery\n"));
02136 if(SourceItem == NULL || DestGroup == NULL)
02137 {
02138 ERROR3("LibClipartSGallery::CopyDisplayItem -> Illegal NULL param");
02139 return NULL;
02140 }
02141
02142
02143 if(DestGroup->IsKindOf(CC_RUNTIME_CLASS(SGLibGroup)))
02144 {
02145 SGDisplayNode *SourceGroup = SourceItem->GetParent();
02146 if((SGDisplayGroup *)SourceGroup != DestGroup)
02147 {
02148
02149 InformError(_R(IDS_CLIPART_BETWEEN_GROUPS), _R(IDS_OK));
02150 Error::ClearError();
02151 }
02152 }
02153
02154 return(NULL);
02155 }
02156
02157
02158
02159
02160
02161
02162
02163
02164
02165
02166
02167
02168
02169
02170
02171
02172
02173
02174
02175 BOOL LibClipartSGallery::InitMenuCommands(void)
02176 {
02177 TRACEUSER( "Matt", _T("Clipart Gallery InitMenuCommands() called\n"));
02178 static BOOL MenusInitialised = FALSE;
02179
02180 BOOL ok = TRUE;
02181
02182 if (!MenusInitialised)
02183 {
02184
02185
02186
02187 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Find, _R(IDS_SGMENU_FIND));
02188 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Sort, _R(IDS_SGMENU_SORT));
02189 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Properties, _R(IDS_SGMENU_PROPERTIES));
02190
02191
02192 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Add, _R(IDS_SGMENU_ADDCLIPART));
02193 ok = ok && InitMenuCommand((StringBase *) &SGCmd_EmptyClipartCache, _R(IDS_SGMENU_EMPTYCLIPARTCACHE));
02194
02195
02196 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Open, _R(IDS_SGMENU_OPEN));
02197 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Import, _R(IDS_SGMENU_IMPORT));
02198 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Remove, _R(IDS_SGMENU_REMOVE));
02199
02200
02201 ok = ok && InitMenuCommand((StringBase *) &SGCmd_FoldGroup, _R(IDS_SGMENU_FOLD));
02202 ok = ok && InitMenuCommand((StringBase *) &SGCmd_UnfoldGroup, _R(IDS_SGMENU_UNFOLD));
02203
02204 ok = ok && InitMenuCommand((StringBase *) &SGCmd_NextGroup, _R(IDS_SGMENU_NEXTGROUP));
02205 ok = ok && InitMenuCommand((StringBase *) &SGCmd_PrevGroup, _R(IDS_SGMENU_PREVGROUP));
02206
02207
02208 MenusInitialised = TRUE;
02209 }
02210
02211 return(ok);
02212 }
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234 BOOL LibClipartSGallery::BuildCommandMenu(GalleryContextMenu *TheMenu, SGMenuID MenuID)
02235 {
02236 BOOL ok = TRUE;
02237
02238 if (MenuID == SGMENU_OPTIONS)
02239 {
02240
02241 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Add);
02242 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_EmptyClipartCache, TRUE);
02243
02244 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Find);
02245 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Sort);
02246 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Properties);
02247 }
02248 else
02249 {
02250
02251 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Open);
02252 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Import);
02253 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Remove, TRUE);
02254
02255 SGDisplayGroup *TheGroup = FindCommandGroup();
02256 if (TheGroup == NULL || !TheGroup->Flags.Folded)
02257 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_FoldGroup);
02258 else
02259 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_UnfoldGroup);
02260
02261 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_PrevGroup);
02262 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_NextGroup);
02263 }
02264
02265 return(ok);
02266 }
02267
02268
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296 OpState LibClipartSGallery::GetCommandState(StringBase *CommandID, String_256 *ShadeReason)
02297 {
02298 OpState State;
02299
02300 if (*CommandID == SGCmd_Add)
02301 return(State);
02302
02303 if (*CommandID == SGCmd_EmptyClipartCache)
02304 {
02305 if (m_bDiscardWebFolders)
02306 State.Greyed = TRUE;
02307 return (State);
02308 }
02309
02310 if (*CommandID == SGCmd_Open || *CommandID == SGCmd_Import)
02311 {
02312 if (GetSelectedItemCount() < 1)
02313 {
02314 State.Greyed = TRUE;
02315 ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSEL));
02316 }
02317 }
02318 else if (*CommandID == SGCmd_Remove)
02319 {
02320 if (GetSelectedGroupCount() < 1)
02321 {
02322 State.Greyed = TRUE;
02323 ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSELGROUP));
02324 }
02325 }
02326 else if (*CommandID == SGCmd_Properties)
02327 {
02328 if (!m_lstPendingThumbs.empty())
02329 {
02330 State.Greyed = TRUE;
02331 ShadeReason->MakeMsg(_R(IDS_SGSHADE_DOWNLOADING));
02332 }
02333 }
02334 else
02335 return(SuperGallery::GetCommandState(CommandID, ShadeReason));
02336
02337 return(State);
02338 }
02339
02340
02341
02342
02343
02344
02345
02346
02347
02348
02349
02350
02351
02352
02353
02354
02355
02356
02357
02358
02359
02360
02361
02362
02363
02364 void LibClipartSGallery::DoCommand(StringBase *CommandID)
02365 {
02366 if (*CommandID == SGCmd_Open)
02367 ImportClipart(TRUE, this);
02368 else if (*CommandID == SGCmd_Import)
02369 ImportClipart(FALSE, this);
02370 else if (*CommandID == SGCmd_Add)
02371 BrowseClicked();
02372 else if (*CommandID == SGCmd_EmptyClipartCache)
02373 {
02374 RemoveWebFolders(SGLib_ClipArt);
02375 }
02376 else if (*CommandID == SGCmd_Remove)
02377 {
02378 RemoveSelectedLibraries(TRUE);
02379 UpdateGRMFile();
02380 }
02381 else
02382 SuperGallery::DoCommand(CommandID);
02383 }
02384
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395 INT32 LibClipartSGallery::GetClipTheme() const
02396 {
02397 return m_nClipTheme;
02398 }
02399
02400
02401
02402
02403
02404
02405
02406
02407
02408
02409
02410
02411
02412 INT32 LibClipartSGallery::SetClipTheme(INT32 nNewIndex)
02413 {
02414 ERROR3IF(0 > nNewIndex, "LibClipartSGallery::SetClipTheme: index out of range");
02415 INT32 n = m_nClipTheme;
02416 m_nClipTheme = nNewIndex;
02417 return n;
02418 }
02419
02420
02421
02422
02423
02424
02425
02426
02427
02428
02429
02430
02431
02432
02433
02434
02435
02436
02437
02438
02439
02440
02441 BOOL OpDisplayLibClipartGallery::Init()
02442 {
02443
02444 ERRORIF(new OpLibGalClipTheme == 0, _R(IDE_NOMORE_MEMORY), FALSE);
02445
02446 return (RegisterOpDescriptor(
02447 0,
02448 _R(IDS_DISPLAY_CLIPART_GALLERY),
02449 CC_RUNTIME_CLASS(OpDisplayLibClipartGallery),
02450 OPTOKEN_DISPLAYCLIPARTGALLERY,
02451 OpDisplayLibClipartGallery::GetState,
02452 0,
02453 _R(IDBBL_DISPLAY_CLIPART_GALLERY),
02454 0 ));
02455 }
02456
02457
02458
02459
02460
02461
02462
02463
02464
02465
02466
02467
02468
02469
02470
02471
02472 OpState OpDisplayLibClipartGallery::GetState(String_256* UIDescription, OpDescriptor*)
02473 {
02474 OpState OpSt;
02475
02476
02477 DialogBarOp* pDialogBarOp = FindGallery();
02478 if (pDialogBarOp != NULL)
02479 OpSt.Ticked = pDialogBarOp->IsVisible();
02480
02481
02482 return(OpSt);
02483 }
02484
02485
02486
02487
02488
02489
02490
02491
02492
02493
02494
02495
02496
02497
02498
02499
02500
02501
02502
02503
02504 void OpDisplayLibClipartGallery::Do(OpDescriptor*)
02505 {
02506 TRACEUSER( "Matt", _T("OpDisplayLibClipartGallery::Do called\n"));
02507 DialogBarOp *pDialogBarOp = FindGallery();
02508
02509 if (pDialogBarOp != NULL)
02510 {
02511
02512 pDialogBarOp->SetVisibility( !pDialogBarOp->IsVisible() );
02513
02514
02515 SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYCLIPARTGALLERY, pDialogBarOp->IsVisible());
02516
02517
02518 if(pDialogBarOp->IsVisible() == FALSE)
02519 {
02520
02521 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::ThumbState::KILLCACHE, SGLib_ClipArt), DialogOp);
02522 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::ThumbState::KILLCACHE, SGLib_ClipArt_WebThemes), DialogOp);
02523 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::ThumbState::KILLCACHE, SGLib_Bitmap), DialogOp);
02524
02525
02526 if(LibClipartSGallery::ThisGallery != NULL)
02527 {
02528 LibClipartSGallery::ThisGallery->GalleryAboutToClose();
02529 }
02530 else
02531 {
02532 ERROR3("Clipart gallery seems to have been closed before I could reclaim my memory");
02533 }
02534
02535 }
02536
02537
02538
02539
02540
02541
02542
02543 }
02544
02545 End();
02546 }
02547
02548
02549
02550
02551
02552
02553
02554
02555
02556
02557
02558
02559
02560
02561
02562
02563
02564
02565
02566
02567
02568
02569 DialogBarOp *OpDisplayLibClipartGallery::FindGallery(void)
02570 {
02571 String_32 Name = _R(IDS_SGLCART_GALLERY_NAME);
02572 DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(Name);
02573
02574 if (pDialogBarOp != NULL)
02575 {
02576 if (pDialogBarOp->GetRuntimeClass() == CC_RUNTIME_CLASS(LibClipartSGallery))
02577 return(pDialogBarOp);
02578
02579 ERROR3("Got the Clipart gallery but it's not of the LibClipartSGallery class");
02580 }
02581 else
02582 {
02583 ERROR3("Can't find the Clipart gallery in bars.ini!\n");
02584 }
02585
02586 return(NULL);
02587 }
02588
02589
02590
02591
02592
02593
02594
02595
02596
02597
02598
02599
02600
02601
02602
02603
02604
02605
02606
02607 LibDisplayType SGClipartItem::GetDisplayType(SGMiscInfo *MiscInfo)
02608 {
02609 switch(MiscInfo->DisplayMode)
02610 {
02611 case 2:
02612 return LibDisplay_SmallThumbText;
02613 break;
02614 case 1:
02615 return LibDisplay_FullInfo;
02616 break;
02617 case 0:
02618 default:
02619 return LibDisplay_LargeThumbTextUnder;
02620 break;
02621 }
02622
02623 return LibDisplay_LargeThumbTextUnder;
02624 }
02625
02626
02627
02628
02629
02630
02631
02632
02633
02634
02635
02636
02637
02638
02639
02640
02641 SGClipartItem::SGClipartItem(LibraryIndex LibraryIndexToDisplay, BOOL bNew) :
02642 SGLibDisplayItem(LibraryIndexToDisplay, bNew)
02643 {
02644 }
02645
02646
02647
02648 SGClipartItem::SGClipartItem()
02649 {
02650 }
02651
02652 SGClipartItem::~SGClipartItem()
02653 {
02654 TRACEUSER( "Matt", _T("~SGClipartItem called\n"));
02655 }
02656
02657
02658
02659
02660
02661
02662
02663
02664
02665
02666
02667
02668
02669
02670
02671
02672
02673
02674
02675
02676
02677
02678
02679
02680
02681
02682
02683
02684
02685
02686
02687
02688
02689
02690
02691
02692
02693
02694
02695
02696
02697
02698
02699
02700
02701
02702
02703
02704
02705
02706
02707
02708
02709
02710 BOOL SGClipartItem::HandleEvent(SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo)
02711 {
02712 switch (EventType)
02713 {
02714 case SGEVENT_MOUSECLICK:
02715 {
02716 SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);
02717
02718 if (Mouse != NULL && FormatRect.ContainsCoord(Mouse->Position))
02719 {
02720 if(LibClipartSGallery::DoSounds)
02721 {
02722 Library *Lib = GetParentLibrary();
02723 if (Lib != NULL)
02724 {
02725 String_64 Key("Sample");
02726 String_256 SampleString;
02727 Lib->GetSingleField(TheLibraryIndex, &Key, &SampleString);
02728 if(SampleString.Length() > 2)
02729 {
02730 String_256 SubPath = Lib->SubLibPath->GetPath();
02731 BOOL Done = SGLibOil::PlayRandomSample(&SampleString, &SubPath);
02732 ERROR3IF(!Done, "Problems playing sample");
02733 }
02734 }
02735 }
02736
02737 INT32 XSize=0, YSize=0;
02738 if(SGLibDisplayItem::StartDrag(EventType, EventInfo, MiscInfo, &XSize, &YSize))
02739 {
02740 GalleryClipartDragInfo *DragClipart;
02741 DragClipart = new GalleryClipartDragInfo(this, Mouse, MiscInfo,
02742 Mouse->MenuClick, XSize, YSize);
02743 if (DragClipart != NULL)
02744 DragManagerOp::StartDrag(DragClipart, GetListWindow());
02745 else
02746 {
02747 if(LibClipartSGallery::TmpDraggingBitmap != NULL)
02748 {
02749 delete LibClipartSGallery::TmpDraggingBitmap;
02750 LibClipartSGallery::TmpDraggingBitmap = NULL;
02751 }
02752 }
02753 }
02754 return TRUE;
02755 }
02756 }
02757 }
02758
02759 return(SGLibDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo));
02760 }
02761
02762
02763
02764
02765
02766
02767
02768
02769
02770
02771
02772
02773
02774
02775
02776 SGClipartDragTarget::SGClipartDragTarget(DialogOp *TheDialog, CGadgetID TheGadget)
02777 : SGListDragTarget(TheDialog, TheGadget)
02778 {
02779 ERROR3IF(!TheDialog->IsKindOf(CC_RUNTIME_CLASS(LibClipartSGallery)),
02780 "You can only use SGClipartDragTargets with LibClipartSGallery dialogues!");
02781 }
02782
02783
02784
02785
02786
02787
02788
02789
02790
02791
02792
02793
02794
02795
02796
02797
02798
02799
02800
02801
02802
02803
02804
02805
02806 BOOL SGClipartDragTarget::ProcessEvent(DragEventType Event, DragInformation *pDragInfo,
02807 OilCoord *pMousePos, KeyPress* pKeyPress)
02808 {
02809 TRACEUSER( "Matt", _T("SGClipartDragTarget::ProcessEvent called\n"));
02810 if (!pDragInfo->IsKindOf(CC_RUNTIME_CLASS(BitmapDragInformation)))
02811 return(FALSE);
02812
02813 SGDisplayNode *DraggedNode = NULL;
02814 BOOL IsSimpleBitmapDrag = TRUE;
02815
02816 if (IS_A(pDragInfo, GalleryClipartDragInfo))
02817 {
02818 DraggedNode = ((GalleryClipartDragInfo *)pDragInfo)->GetDraggedClipart();
02819 IsSimpleBitmapDrag = FALSE;
02820 }
02821
02822 if (DraggedNode != NULL)
02823 {
02824 switch(Event)
02825 {
02826 case DRAGEVENT_COMPLETED:
02827 HandleDragCompleted((SuperGallery *) TargetDialog,
02828 DraggedNode, pMousePos, IsSimpleBitmapDrag);
02829 return(TRUE);
02830
02831
02832 case DRAGEVENT_MOUSESTOPPED:
02833 case DRAGEVENT_MOUSEMOVED:
02834 case DRAGEVENT_MOUSEIDLE:
02835 {
02836
02837
02838 SuperGallery *ParentGallery = (SuperGallery *) TargetDialog;
02839 if (ParentGallery != NULL && pMousePos != NULL && DraggedNode != NULL)
02840 {
02841
02842 DocCoord MousePos(pMousePos->x, pMousePos->y);
02843 SGDisplayNode *DestNode = ParentGallery->FindNodeUnderPointer(&MousePos);
02844
02845 if(DestNode != NULL)
02846 {
02847 SGDisplayNode *DestGroup = DestNode->GetParent();
02848 SGDisplayNode *SourceGroup = DraggedNode->GetParent();
02849
02850 if(DestGroup != NULL && SourceGroup != NULL)
02851 {
02852
02853 if(SourceGroup == DestGroup)
02854 return(DetermineCursorShape(ParentGallery, DraggedNode, pMousePos));
02855 }
02856 }
02857 }
02858 }
02859
02860
02861 CurrentCursorID = _R(IDC_DRAGGING_COLOUR);
02862 return TRUE;
02863 }
02864 }
02865
02866
02867 return(FALSE);
02868 }
02869
02870
02871
02872
02873
02874
02875
02876
02877
02878
02879
02880
02881 GalleryClipartDragInfo::GalleryClipartDragInfo()
02882 {
02883 ERROR3("Default GalleryClipartDragInfo constructor called");
02884 }
02885
02886
02887
02888
02889
02890
02891
02892
02893
02894
02895
02896
02897
02898 GalleryClipartDragInfo::~GalleryClipartDragInfo()
02899 {
02900 TRACEUSER( "Richard", _T("~GalleryClipartDragInfo called\n"));
02901
02902 if(LibraryGallery::TmpDraggingBitmap != NULL)
02903 {
02904 delete LibraryGallery::TmpDraggingBitmap;
02905 LibraryGallery::TmpDraggingBitmap = NULL;
02906 }
02907 }
02908
02909
02910
02911
02912
02913
02914
02915
02916
02917
02918
02919
02920
02921
02922
02923
02924
02925
02926
02927
02928
02929
02930 GalleryClipartDragInfo::GalleryClipartDragInfo(SGClipartItem *pSourceItem,
02931 SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo,
02932 BOOL IsAdjust, INT32 XSize, INT32 YSize)
02933 : BitmapDragInformation(LibraryGallery::TmpDraggingBitmap,
02934
02935 XSize, YSize, 0, 0, IsAdjust)
02936 {
02937 SourceItem = pSourceItem;
02938 MouseInfo = *pMouseInfo;
02939 MiscInfo = *pMiscInfo;
02940 }
02941
02942
02943
02944
02945
02946
02947
02948
02949
02950
02951
02952
02953
02954
02955
02956
02957
02958
02959
02960
02961 void GalleryClipartDragInfo::OnClick(INT32 Flags ,POINT Point)
02962 {
02963 TRACEUSER( "Matt", _T("GalleryClipartDragInfo::OnClick called\n"));
02964 if (SourceItem != NULL)
02965 SourceItem->DragWasReallyAClick(&MouseInfo, &MiscInfo);
02966 }
02967
02968
02969
02970
02971
02972
02973
02974
02975
02976
02977
02978
02979 UINT32 GalleryClipartDragInfo::GetCursorID(DragTarget* pDragTarget)
02980 {
02981 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
02982 {
02983 PageDropInfo PageDropInfo;
02984 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
02985
02986 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
02987 ObjectDragTarget TargetHit = PageDropInfo.TargetHit;
02988
02989 if (pObjectHit)
02990 TargetHit = NO_TARGET;
02991
02992 switch (TargetHit)
02993 {
02994 case NO_TARGET:
02995 return _R(IDC_CANDROPONPAGE);
02996 };
02997
02998 return _R(IDC_CANDROPONPAGE);
02999 }
03000
03001 return _R(IDC_CANTDROP);
03002 }
03003
03004
03005
03006
03007
03008
03009
03010
03011
03012
03013
03014
03015 BOOL GalleryClipartDragInfo::GetStatusLineText(String_256 * TheText, DragTarget* pDragTarget)
03016 {
03017 ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
03018
03019 if (TheBitmap == NULL || TheBitmap->ActualBitmap == NULL)
03020 return FALSE;
03021
03022 String_256 DragString;
03023 String_256 ItemName;
03024 SourceItem->GetNameText(&ItemName);
03025
03026
03027 DragString.MakeMsg(_R(IDS_CLIPART_DRAGGING), (TCHAR *)ItemName);
03028
03029 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
03030 {
03031 DragString += String_8(_R(IDS_SGDFONTS_STAT_COLON_SEP));
03032
03033 PageDropInfo PageDropInfo;
03034 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
03035
03036 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
03037 ObjectDragTarget TargetHit = PageDropInfo.TargetHit;
03038
03039 if (pObjectHit)
03040 TargetHit = NO_TARGET;
03041
03042 switch (TargetHit)
03043 {
03044 case NO_TARGET:
03045 {
03046
03047 String_64 DropToThis(_R(IDS_CLIPART_DROP));
03048 DragString += DropToThis;
03049 break;
03050 }
03051 };
03052
03053 *TheText = DragString;
03054 return TRUE;
03055 }
03056
03057 *TheText = DragString;
03058 return TRUE;
03059 }
03060
03061
03062
03063
03064
03065
03066
03067
03068
03069
03070
03071
03072
03073
03074 BOOL GalleryClipartDragInfo::OnPageDrop(ViewDragTarget* pDragTarget)
03075 {
03076 PageDropInfo PageDropInfo;
03077 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
03078
03079 PathName FileName;
03080 SGLibDisplayItem *ClipItem = SourceItem;
03081
03082 BOOL ok = ClipItem->GetFileName(&FileName);
03083
03084 if(ok)
03085 {
03086
03087 if(FileName.GetFileName(FALSE) == (String_256)"Moo")
03088 {
03089 INT32 Size = ClipItem->GetFileSize(NULL);
03090 if(Size == 1080904)
03091 FileName.SetType("TIF");
03092 }
03093
03094 if(!FileName.IsValid(FileName.GetPath()))
03095 {
03096 ERROR3("LibClipartSGallery::ImportClipart - Filename is invalid");
03097 return FALSE;
03098 }
03099
03100
03101 String_256 FilePath((const TCHAR *)FileName.GetPath());
03102 String_256 LongFileName;
03103 BOOL LongPath = FileUtil::GetLongFileName((LPTSTR)FilePath, (LPTSTR)LongFileName, 255);
03104 if(LongPath)
03105 {
03106 FilePath = FileName.GetLocation(TRUE);
03107 FilePath += LongFileName;
03108 }
03109
03110 #ifdef STANDALONE
03111 CWinApp* pApp = AfxGetApp();
03112 BaseFileDialog::SelectedFilter = 0;
03113
03114
03115 CCamDoc* pDoc = (CCamDoc*) pApp->OpenDocumentFile((TCHAR *)FilePath);
03116
03117
03118 if(pDoc) pDoc->GetKernelDoc()->ForceRedraw();
03119 #else
03120
03121
03122 Library* pLibrary = ClipItem->GetParentLibrary();
03123 if (!pLibrary)
03124 {
03125 ERROR3("Illegal NULL pointer");
03126 return FALSE;
03127 }
03128 BOOL bIsLocalFile;
03129 if (!pLibrary->IsWebLibrary())
03130 bIsLocalFile = TRUE;
03131 else
03132 bIsLocalFile = (_access((TCHAR*) FilePath, 0) != -1);
03133
03134
03135
03136 if (bIsLocalFile)
03137 {
03138 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpClipartImport));
03139
03140 if (pOpDesc != NULL)
03141 {
03142 ClipartImportParam Param;
03143
03144
03145 PathName FullPathName((TCHAR *)FilePath);
03146 Param.File = &FullPathName;
03147
03148 Param.Import = TRUE;
03149 if(PageDropInfo.pDoc == NULL)
03150 Param.Import = FALSE;
03151
03152 Param.Result = TRUE;
03153 Param.DropInfo = &PageDropInfo;
03154
03155
03156 pOpDesc->Invoke((OpParam *) &Param);
03157
03158 ok = Param.Result;
03159
03160 if(!ok)
03161 {
03162 ERROR3("LibClipartSGallery::ImportClipart - Problem importing file");
03163 return FALSE;
03164 }
03165 }
03166 }
03167 else
03168 {
03169 String_256 strFileURL = FilePath;
03170 pLibrary->LocalPath2URL(&strFileURL);
03171 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpAsynchClipartImport));
03172 if (pOpDesc != NULL)
03173 {
03174 AsynchClipartImportParam* Param = new AsynchClipartImportParam;
03175 ERROR2IF(!Param, FALSE, "Memory allocation error");
03176
03177 Param->File.SetPathName((TCHAR *)FilePath);
03178 Param->strURL = strFileURL;
03179 String_256 strDescription;
03180 ClipItem->GetNameText(&strDescription);
03181 Param->strDescription = _T("'");
03182 Param->strDescription += strDescription;
03183 Param->strDescription += _T("'");
03184 Param->bDropped = TRUE;
03185 Param->Import = (PageDropInfo.pDoc == NULL) ? FALSE : TRUE;
03186 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&Param->DropInfo);
03187 pOpDesc->Invoke((OpParam *) Param);
03188 }
03189 }
03190 #endif
03191 }
03192
03193 return TRUE;
03194 }
03195
03196
03197
03198
03199
03200
03201
03202
03203
03204
03205
03206
03207
03208
03209
03210
03211
03212 BOOL GalleryClipartDragInfo::OnMainFrameDrop(DragTarget* pDragTarget)
03213 {
03214 SGLibDisplayItem* ClipItem = (SGLibDisplayItem*) SourceItem;
03215 String_256 ItemText;
03216
03217 if (ClipItem->IsKindOf(CC_RUNTIME_CLASS(SGClipartItem)))
03218 {
03219 ClipItem->GetNameText(&ItemText);
03220 PathName FileName;
03221
03222
03223 BOOL ok = ClipItem->GetFileName(&FileName);
03224
03225 if(ok)
03226 {
03227
03228 if(FileName.GetFileName(FALSE) == (String_256)"Moo")
03229 {
03230 INT32 Size = ClipItem->GetFileSize(NULL);
03231 if(Size == 1080904)
03232 FileName.SetType("TIF");
03233 }
03234
03235 if(!FileName.IsValid(FileName.GetPath()))
03236 {
03237 ERROR3("LibClipartSGallery::ImportClipart - Filename is invalid");
03238 return FALSE;
03239 }
03240
03241
03242 String_256 FilePath((const TCHAR *)FileName.GetPath());
03243 String_256 LongFileName;
03244 BOOL LongPath = FileUtil::GetLongFileName((LPTSTR)FilePath, (LPTSTR)LongFileName, 255);
03245 if(LongPath)
03246 {
03247 FilePath = FileName.GetLocation(TRUE);
03248 FilePath += LongFileName;
03249 }
03250
03251
03252 Library* pLibrary = ClipItem->GetParentLibrary();
03253 if (!pLibrary)
03254 {
03255 ERROR3("Illegal NULL pointer");
03256 return FALSE;
03257 }
03258 BOOL bIsLocalFile;
03259 if (!pLibrary->IsWebLibrary())
03260 bIsLocalFile = TRUE;
03261 else
03262 bIsLocalFile = (_access((TCHAR*) FilePath, 0) != -1);
03263
03264 if (bIsLocalFile)
03265 {
03266 CWinApp* pApp = AfxGetApp();
03267 BaseFileDialog::SelectedFilter = 0;
03268
03269
03270 CCamDoc* pDoc = (CCamDoc*) pApp->OpenDocumentFile((TCHAR *)FilePath);
03271
03272
03273 if(pDoc) pDoc->GetKernelDoc()->ForceRedraw();
03274 }
03275 else
03276 {
03277 String_256 strFileURL = FilePath;
03278 pLibrary->LocalPath2URL(&strFileURL);
03279 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpAsynchClipartImport));
03280 if (pOpDesc != NULL)
03281 {
03282 AsynchClipartImportParam* Param = new AsynchClipartImportParam;
03283 ERROR2IF(!Param, FALSE, "Memory allocation error");
03284
03285 Param->File.SetPathName((TCHAR *)FilePath);
03286 String_256 strDescription;
03287 ClipItem->GetNameText(&strDescription);
03288 Param->strDescription = _T("'");
03289 Param->strDescription += strDescription;
03290 Param->strDescription += _T("'");
03291 Param->strURL = strFileURL;
03292 Param->Import = FALSE;
03293 Param->bDropped = FALSE;
03294
03295 pOpDesc->Invoke((OpParam*) Param);
03296 }
03297 }
03298 }
03299 return TRUE;
03300 }
03301 return FALSE;
03302 }
03303
03304
03305
03306
03307
03308
03309
03310
03311
03312
03313
03314
03315
03316
03317
03318
03319
03320
03321 SGOilClipartDragTarget::SGOilClipartDragTarget(HWND TheWindow, CRect *ClientArea)
03322 : WinoilDragTarget(TheWindow, ClientArea)
03323 {
03324 }
03325
03326
03327
03328
03329
03330
03331
03332
03333
03334
03335
03336
03337 UINT32 SGOilClipartDragTarget::GetCursorID()
03338 {
03339 return _R(IDC_CANDROPONPAGE);
03340 }
03341
03342
03343
03344
03345
03346
03347
03348
03349
03350
03351
03352
03353
03354
03355 BOOL SGOilClipartDragTarget::GetStatusLineText(String_256 * TheText)
03356 {
03357 ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
03358
03359 DragInformation *pDragInfo = DragManagerOp::GetCurrentDragInfo();
03360 if (pDragInfo == NULL || !pDragInfo->IsKindOf(CC_RUNTIME_CLASS(GalleryClipartDragInfo)))
03361 return(FALSE);
03362 SGClipartItem *pClipartItem = ((GalleryClipartDragInfo *)pDragInfo)->SourceItem;
03363
03364 String_256 DragString;
03365 String_256 ItemName;
03366 pClipartItem->GetNameText(&ItemName);
03367
03368
03369 DragString.MakeMsg(_R(IDS_CLIPART_DRAGGING), (TCHAR *)ItemName);
03370 DragString += String_8(_R(IDS_SGDFONTS_STAT_COLON_SEP));
03371 DragString += String_256(_R(IDS_CLIPART_OPEN_DROP));
03372
03373 *TheText = DragString;
03374 return TRUE;
03375 }
03376
03377
03378
03379
03380
03381
03382
03383
03384
03385
03386
03387
03388
03389
03390 BOOL SGOilClipartDragTarget::ProcessEvent(DragEventType Event,
03391 DragInformation *pDragInfo, CPoint *pMousePos, KeyPress* pKeyPress)
03392 {
03393 if (!pDragInfo->IsKindOf(CC_RUNTIME_CLASS(GalleryClipartDragInfo)))
03394 return(FALSE);
03395
03396 SGDisplayNode *DraggedNode = NULL;
03397 BOOL IsSimpleClipartDrag = TRUE;
03398
03399 if (IS_A(pDragInfo, GalleryClipartDragInfo))
03400 {
03401 DraggedNode = ((GalleryClipartDragInfo *)pDragInfo)->GetDraggedClipart();
03402 IsSimpleClipartDrag = FALSE;
03403 }
03404
03405 if (DraggedNode != NULL)
03406 {
03407 switch(Event)
03408 {
03409 case DRAGEVENT_COMPLETED:
03410 {
03411
03412 return(((GalleryClipartDragInfo *)pDragInfo)->OnMainFrameDrop(this));
03413 }
03414
03415 case DRAGEVENT_MOUSESTOPPED:
03416 case DRAGEVENT_MOUSEMOVED:
03417 case DRAGEVENT_MOUSEIDLE:
03418 return(TRUE);
03419 }
03420 }
03421
03422
03423 return(FALSE);
03424 }
03425
03426
03427
03428
03429
03430
03431
03432
03433
03434
03435
03436
03437
03438
03439
03440
03441
03442
03443
03444
03445
03446
03447
03448
03449
03450
03451
03452
03453
03454
03455
03456
03457
03458
03459
03460
03461
03462
03463 OpLibGalClipTheme::OpLibGalClipTheme()
03464 : OpDescriptor(0,
03465 _R(IDS_LIBGAL_CLIPTHEME),
03466 CC_RUNTIME_CLASS(OpLibGalClipTheme),
03467 OPTOKEN_LIBGAL_CLIPTHEME,
03468 OpDisplayLibClipartGallery::GetState,
03469 0,
03470 _R(IDBBL_LIBGAL_CLIPTHEME),
03471 0,
03472 _R(IDC_LIBGAL_CLIPTHEME),
03473 TRUE)
03474 {
03475
03476 }
03477
03478
03479
03480
03481
03482
03483
03484
03485
03486
03487
03488
03489
03490 void OpLibGalClipTheme::OnControlCreate(OpDescControlCreateMsg* pCreateMsg)
03491 {
03492
03493
03494 pCreateMsg->pDlgOp->SetStringGadgetValue(
03495 pCreateMsg->SetGadgetID, &String(_R(IDS_LIBGAL_CLIPTHEME_CLIPART)));
03496 pCreateMsg->pDlgOp->SetStringGadgetValue(
03497 pCreateMsg->SetGadgetID, &String(_R(IDS_LIBGAL_CLIPTHEME_WEBTHEME)));
03498
03499
03500 pCreateMsg->pDlgOp->SetComboListLength(pCreateMsg->SetGadgetID);
03501 UpdateGadgets();
03502 }
03503
03504
03505
03506
03507
03508
03509
03510
03511
03512
03513
03514
03515
03516
03517 void OpLibGalClipTheme::OnSelectionChange(OpDescControlMsg* pSelChangedMsg, List*)
03518 {
03519 LibClipartSGallery::Instance()->m_bRedraw = TRUE;
03520
03521
03522 INT32 i = pSelChangedMsg->pDlgOp->GetSelectedValueIndex(pSelChangedMsg->SetGadgetID);
03523 if (i == -1)
03524 {
03525 LibClipartSGallery::Instance()->m_bRedraw = FALSE;
03526 i = LibClipartSGallery::Instance()->GetClipTheme();
03527 }
03528
03529
03530 if (i != LibClipartSGallery::Instance()->GetClipTheme())
03531 {
03532
03533
03534 if (i == 1)
03535 {
03536 LibClipartSGallery::ClipartPath = LibClipartSGallery::DefaultLibraryPath;
03537 LibClipartSGallery::DefaultLibraryPath = LibClipartSGallery::WebThemePath;
03538 }
03539 else
03540 {
03541 LibClipartSGallery::WebThemePath = LibClipartSGallery::DefaultLibraryPath;
03542 LibClipartSGallery::DefaultLibraryPath = LibClipartSGallery::ClipartPath;
03543 }
03544
03545
03546 LibClipartSGallery::Instance()->SetClipTheme((INT32) i);
03547 UpdateGadgets();
03548
03549
03550 if (LibClipartSGallery::Instance()->m_bRedraw)
03551 {
03552 LibClipartSGallery::Instance()->ModeHasChanged();
03553 LibClipartSGallery::Instance()->SelectionHasChanged();
03554 LibClipartSGallery::Instance()->ForceRedrawOfList();
03555 }
03556 }
03557 }
03558
03559
03560
03561
03562
03563
03564
03565
03566
03567
03568
03569
03570 void OpLibGalClipTheme::UpdateGadgets()
03571 {
03572
03573 List theGadgets;
03574 if (BuildGadgetList(&theGadgets))
03575 {
03576
03577 INT32 nVal = LibClipartSGallery::Instance()->GetClipTheme();
03578 for (GadgetListItem* pgli = (GadgetListItem*) theGadgets.GetHead();
03579 pgli != 0;
03580 pgli = (GadgetListItem*) theGadgets.GetNext(pgli))
03581 {
03582
03583 pgli->pDialogBarOp->SetSelectedValueIndex(pgli->gidGadgetID, nVal);
03584 }
03585
03586
03587 theGadgets.DeleteAll();
03588 }
03589 }
03590
03591
03592
03593
03594
03595
03596
03597
03598
03599
03600
03601
03602
03603
03604
03605
03606
03607
03608 BOOL LibClipartSGallery::OnGetButtonClicked()
03609 {
03610
03611 if (!InternetManager::AttemptConnection())
03612 {
03613 InformError(_R(IDS_NOTCONNECTED), _R(IDS_OK));
03614 return FALSE;
03615 }
03616
03617
03618 ResumeThumbnailDownloading();
03619 ForceRedrawOfList();
03620
03621 if (OpAddWebFolders::Success[SGLib_ClipArt] && OpAddWebFolders::Success[SGLib_ClipArt_WebThemes] && !m_bDiscardWebFolders)
03622 {
03623
03624 ModeHasChanged();
03625 SelectionHasChanged();
03626 ReformatAndRedrawIfNecessary();
03627
03628
03629 return TRUE;
03630 }
03631 m_bDiscardWebFolders = FALSE;
03632
03633
03634
03635 String_256 strIndexURL(GetStringField((UINT32) SGLib_ClipArt, _R(IDS_MAININDEXURL)));
03636
03637
03638 String_256 strTempFile;
03639 GetTempInetDir(&strTempFile);
03640 strTempFile += GetStringField((UINT32) SGLib_ClipArt, _R(IDS_TMPFILES));
03641
03642 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpAddWebFolders));
03643 if (pOpDesc != NULL)
03644 {
03645 TRACEUSER( "Matt", _T("Starting Download of Clipart\n"));
03646 AddWebFoldersParam* Param = new AddWebFoldersParam;
03647 ERROR2IF(!Param, FALSE, "Memory allocation error");
03648
03649 Param->localFile.SetPathName((TCHAR *) strTempFile);
03650 Param->strURL = strIndexURL;
03651 Param->pLibGal = this;
03652 Param->type = SGLib_ClipArt;
03653
03654
03655 pOpDesc->Invoke((OpParam*) Param);
03656 TRACEUSER( "Matt", _T("Invoked Download of Clipart\n"));
03657 }
03658 else
03659 {
03660 ERROR3("OpAddWebFolders not found");
03661 return FALSE;
03662 }
03663
03664
03665 String_256 strIndexWebThemesURL(_R(IDS_CLIPART_WEBTHEMES_URL));
03666 String_256 strTempFileWebThemes;
03667 GetTempInetDir(&strTempFileWebThemes);
03668 strTempFileWebThemes += String_256(_R(IDS_CLIPART_WEBTHEMES_TEMPFILE));
03669
03670 OpDescriptor* pOpDescWebThemes = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpAddWebFolders));
03671 if (pOpDescWebThemes != NULL)
03672 {
03673 TRACEUSER( "Matt", _T("Starting Download of Web Themes\n"));
03674 AddWebFoldersParam* ParamWebThemes = new AddWebFoldersParam;
03675 ERROR2IF(!ParamWebThemes, FALSE, "Memory allocation error");
03676
03677 ParamWebThemes->localFile.SetPathName((TCHAR *) strTempFileWebThemes);
03678 ParamWebThemes->strURL = strIndexWebThemesURL;
03679 ParamWebThemes->pLibGal = this;
03680 ParamWebThemes->type = SGLib_ClipArt_WebThemes;
03681
03682
03683 pOpDescWebThemes->Invoke((OpParam*) ParamWebThemes);
03684 TRACEUSER( "Matt", _T("Invoked Download of Web Themes\n"));
03685 }
03686 else
03687 {
03688 ERROR3("OpAddWebFolders not found");
03689 return FALSE;
03690 }
03691
03692
03693
03694
03695 return TRUE;
03696 }
03697
03698
03699
03700
03701
03702
03703
03704
03705
03706
03707
03708
03709
03710
03711
03712
03713 BOOL LibClipartSGallery::RemoveWebFolders(SGLibType type)
03714 {
03715 TRACEUSER( "Matt", _T("REMOVING WEB FOLDERS! in Clipart gallery\n"));
03716 if (AskQuestion(_R(IDS_WARNREMOVE), _R(IDS_EMPTY), _R(IDS_CANCEL)) == _R(IDS_CANCEL))
03717 return FALSE;
03718
03719 String_256 strLocation;
03720 GetAppDataPath(&strLocation);
03721 strLocation += GetStringField(SGLib_ClipArt, _R(IDS_CACHEDIR));
03722
03723 BOOL ok = true;
03724
03725 if (_access((TCHAR*) strLocation, 0) != -1)
03726 {
03727 DownloadCache::Traverse(strLocation, TRUE);
03728 DownloadCache::Refresh();
03729 SelectionHasChanged();
03730 }
03731 else
03732 {
03733 ok = FALSE;
03734 }
03735
03736 GetAppDataPath(&strLocation);
03737 strLocation += GetStringField(SGLib_ClipArt_WebThemes, _R(IDS_CACHEDIR));
03738 if (_access((TCHAR*) strLocation, 0) != -1)
03739 {
03740 DownloadCache::Traverse(strLocation, TRUE);
03741 DownloadCache::Refresh();
03742 SelectionHasChanged();
03743 }
03744 else
03745 {
03746 ok = FALSE;
03747 }
03748
03749 return ok;
03750 }