menuops.cpp

Go to the documentation of this file.
00001 // $Id: menuops.cpp 1739 2006-09-05 11:07:16Z luke $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 /********************************************************************************************
00100 
00101     menuops.cpp - This module provides a set of menu Operation classes which are used in the
00102     OIL Menu Module when the Menu System is being built. 
00103 
00104 ********************************************************************************************/
00105 
00106 
00107 #include "camtypes.h"
00108 
00109 //#import "WebFileUpdater_1_1.dll"
00110 //using namespace WEBFILEUPDATERLib;
00111 
00112 //#import "XMUpload_1_3.dll"
00113 #define E_XM_CONNECTCANCELLED   ( 0x80041000 )
00114 //using namespace XMUPLOADLib;
00115 
00116 
00117 #include "camelot.h"
00118 //#include "mainfrm.h"
00119 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00120 //#include "camdoctp.h"
00121 #include "camdoc.h"
00122 
00123 #include "menuops.h"
00124 #include "menucmds.h"
00125 //#include "ensure.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00126 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00127 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00128 #include "toollist.h"
00129 //#include "selop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00130 
00131 //#include "mario.h"
00132 #include "helpids.h"
00133 #include "bubbleid.h"
00134 //#include "barsdlgs.h"
00135 #include "dlgmgr.h"
00136 #include "combshps.h"
00137 //#include "markn.h"
00138 #include "shapeops.h"
00139 //#include "peter.h"
00140 //#include "will.h"
00141 //#include "justin.h"
00142 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00143 #include "csrstack.h"
00144 //#include "tooldlg.h"
00145 #include "progress.h"
00146 //#include "ollie.h"
00147 //#include "justin3.h"
00148 //#include "camnet.h"
00149 
00150 //#include "resimmap.h" //For new template stuff
00151 #include "sgliboil.h"   //For file exists function
00152 #include "fileutil.h"   //For file util function
00153 //#include "rik.h"      //For _R(IDS_DEFAULTDOCNAME)
00154 
00155 //#include "group.h"        // for blends - in camtypes.h [AUTOMATICALLY REMOVED]
00156 //#include "simon.h"        // for the sub menu stuff
00157 
00158 //#include "webdialog.h"    // specials/update dialogs
00159 //#include "webdialogdlg.h" // specials/update dialogs
00160 //#include "registerdialog.h"   // register dialog
00161 //#include "resdll.h"           // resource / locale methods
00162 #include "product.h"
00163 //#include "helpdownload.h"
00164 //#include "phil.h"
00165 //#include "registry.h"
00166 //#include "register.h"
00167 //#include "liveeffectres.h"
00168 #include "tmplmngr.h"
00169 
00170 #if (_OLE_VER >= 0x200)
00171     #include "srvritem.h"
00172 #endif
00173 
00174 //#ifdef WEBSTER
00175 #define INC_WEB_MENU_ITEMS
00176 //#endif // WEBSTER
00177 
00178 //Webster_Ranbir_12\11\96
00179 #ifdef INC_WEB_MENU_ITEMS
00180 BOOL HelpOps::CDHelpOn = FALSE;
00181 #endif //INC_WEB_MENU_ITEMS
00182 
00183 BOOL ViewOps::DoFullScreen = FALSE;
00184 
00185 #if !defined(EXCLUDE_FROM_RALPH)
00186 
00187 /******************************************************************************************
00188 
00189 >       void DUMMYOP(TEXT,TOKEN)
00190 
00191     Author:         Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00192     Created:        29/03/94
00193     Purpose:        MACRO
00194                 Construct an OpDescriptor for a menu item which does not do anything.
00195                 I.E. It's just a way of creating menu items before they have any
00196                 Operations to connect to...
00197                 
00198 ******************************************************************************************/
00199 
00200 #define DUMMYOP(TEXT,TOKEN) {\
00201     BOOL blobby = RegisterOpDescriptor(\
00202                                         0,\
00203                                         TEXT,\
00204                                         CC_RUNTIME_CLASS(DummyOp),\
00205                                         TOKEN,\
00206                                         DummyOp::GetState,\
00207                                         0,      /* help ID */\
00208                                         0,  /* bubble help ID */\
00209                                         0,      /* resource ID */\
00210                                         0       /* control ID */\
00211                                         );\
00212     ERRORIF(!blobby, _R(IDE_NOMORE_MEMORY), FALSE);\
00213     }
00214 
00215 
00216 
00217 
00218 /******************************************************************************************
00219 
00220 >       void REGOP(MENU,NAME,CLASS)
00221 
00222     Author:         Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00223     Created:        20/04/94
00224     Purpose:        MACRO
00225                 DON'T USE THIS MACRO! Use either BTNOP or CTRLOP from opdesc.h instead.
00226                 Construct a complete OpDescriptor given three simple parameters. The
00227                 parameters are used to build all the various resource IDs required by the
00228                 call to RegisterOpDescriptor. Each use of this macro replaces the following
00229                 code;
00230                 
00231                 BOOL Blobby = RegisterOpDescriptor(
00232                                                     0, 
00233                                                     _R(IDS_FILE_OPEN),
00234                                                     CC_RUNTIME_CLASS(DocOps), 
00235                                                     OPTOKEN_FILEOPEN,
00236                                                     DocOps::GetState,
00237                                                     HID_FILE_OPEN,
00238                                                     _R(IDBBL_FILEOPENOP),
00239                                                     _R(IDD_BARCONTROLSTORE),
00240                                                     _R(IDC_BTN_FILEOPEN),
00241                                                     SYSTEMBAR_FILE,
00242                                                     TRUE // ReceiveMessages
00243                                                     );
00244                 ERRORIF(!Blobby, _R(IDE_NOMORE_MEMORY), FALSE);
00245     SeeAlso:        BTNOP, CTRLOP
00246 
00247 ******************************************************************************************/
00248 
00249 #define REGOP(MENU,NAME,OPCLASS)\
00250     {\
00251         BOOL Blobby = RegisterOpDescriptor(\
00252                         0,\
00253                         _R(IDS_ ## MENU ## _ ## NAME),      /*NORESOURCEFIX*/ \
00254                         CC_RUNTIME_CLASS(OPCLASS),\
00255                         OPTOKEN_ ## MENU ## NAME,\
00256                         OPCLASS::GetState,\
00257                         HID_ ## MENU ## _ ## NAME,\
00258                         _R(IDBBL_ ## MENU ## NAME ## OP),   /*NORESOURCEFIX*/ \
00259                         _R(IDD_BARCONTROLSTORE),\
00260                         _R(IDC_BTN_ ## MENU ## NAME)        /*NORESOURCEFIX*/,\
00261                         SYSTEMBAR_ ## MENU,\
00262                         TRUE\
00263                       );\
00264         ERRORIF(!Blobby, _R(IDE_NOMORE_MEMORY), FALSE);\
00265     }
00266 
00267 
00268 
00269 
00270 CC_IMPLEMENT_DYNCREATE  (DocOps,                Operation)
00271 CC_IMPLEMENT_DYNCREATE  (MenuPopupOps,  Operation)
00272 CC_IMPLEMENT_DYNCREATE  (HelpOps,               Operation)
00273 CC_IMPLEMENT_DYNCREATE  (WindowOps,             Operation)
00274 CC_IMPLEMENT_DYNCREATE  (ViewOps,               Operation)
00275 CC_IMPLEMENT_DYNCREATE  (OpExit,                Operation)
00276 CC_IMPLEMENT_DYNCREATE  (OpUpdate,              Operation)
00277 CC_IMPLEMENT_DYNCREATE  (OpRegister,            Operation)
00278 CC_IMPLEMENT_DYNCREATE  (DummyOp,               Operation)
00279 #endif
00280 
00281 CC_IMPLEMENT_DYNCREATE  (OpToolSelect,  Operation)
00282 
00283 // This will get Camelot to display the filename and linenumber of any memory allocations
00284 // that are not released at program exit
00285 #define new CAM_DEBUG_NEW
00286 
00287 
00288 //********************************************************************************************
00289 //                                                                      TOOL SELECTION OPERATION
00290 /********************************************************************************************
00291 
00292 >       OpToolSelect::OpToolSelect(): Operation()
00293 
00294     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
00295     Created:        20/8/93
00296     Inputs:         -
00297     Outputs:        -
00298     Returns:        -
00299     Purpose:        Constructs a new OpToolSelect object: setting default operation flags, and 
00300                 adding it to the Live list. 
00301     Errors:         -
00302     SeeAlso:        -
00303 
00304 ********************************************************************************************/
00305      
00306 OpToolSelect::OpToolSelect(): Operation()
00307 {                 
00308 }
00309 
00310 
00311 /********************************************************************************************
00312 
00313 >       BOOL OpToolSelect::Init()
00314 
00315     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
00316     Created:        16/8/93
00317     Inputs:         -
00318     Outputs:        -
00319     Returns:        -
00320     Purpose:        Create OpDescriptors for each of the Tools available
00321     Errors:         -
00322     SeeAlso:        -
00323 
00324 ********************************************************************************************/
00325 
00326 BOOL OpToolSelect::Init()
00327 {
00328     // Get the first tool in the tool list
00329     ToolListItem* ToolItem = Tool::GetFirstTool();
00330 
00331     ToolInfo *Info = new ToolInfo;
00332     if (Info == NULL)
00333         return FALSE;
00334 
00335     while (ToolItem != NULL)
00336     {
00337         Tool* ATool = ToolItem->m_pTool;
00338         
00339         //Get Tool Info
00340         Info->BubbleID=0;
00341         ATool->Describe(Info);
00342     
00343     // Set up OpToken
00344     String OpToken;
00345     camSnprintf( OpToken, 16, _T("TOOL%u"), (Info->ID) );
00346     
00347     // Create an instance of the ToolOpDescriptor
00348         ToolOpDescriptor* ToolOp = new ToolOpDescriptor(
00349                                                         Info->ID,
00350                                                         Info->TextID,
00351                                                         CC_RUNTIME_CLASS(OpToolSelect), 
00352                                                         OpToken,
00353                                                         OpToolSelect::GetState,
00354                                                         0,                                              /* Help ID */
00355                                                         Info->BubbleID
00356                                                         );
00357 
00358         ERRORIF(!ToolOp, _R(IDE_NOMORE_MEMORY), FALSE);
00359         
00360         //Get the next item in the tool list
00361         ToolItem = Tool::GetNextTool(ToolItem);
00362     }
00363 
00364     delete Info;
00365 
00366     return TRUE;
00367 }
00368 
00369 /********************************************************************************************
00370 
00371 >       OpState OpToolSelect::GetState(String_256* UIDescription, OpDescriptor*  ToolOp)
00372 
00373     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
00374     Created:        16/8/93
00375     Inputs:         String* pointer to a string description of menu item
00376                 OpDescriptor* that describes a Tool
00377     Outputs:        None
00378     Returns:        OpState describing the state of the Tool.
00379     Purpose:        Is called to update the state of tool represented by
00380                 OpDescriptor.
00381     Errors:         None
00382 
00383 ********************************************************************************************/
00384 
00385 OpState OpToolSelect::GetState(String_256* UIDescription, OpDescriptor* ToolOp)
00386 { 
00387     OpState mState;
00388     
00389     UINT32 ToolId = ToolOp->GetToolID();
00390 
00391     ENSURE(Tool::Find(ToolId) != NULL, "Tool Id does not exist!");
00392         
00393     Tool* thisTool = ((Tool::Find(ToolId))->m_pTool);
00394     
00395     if (thisTool ==((Tool::Find(ToolId))->m_pTool)->GetCurrent())
00396     mState.Ticked = TRUE;
00397     else
00398     mState.Ticked = FALSE;
00399 
00400     mState.Greyed = FALSE;
00401     
00402     return mState; 
00403 }
00404 
00405 /********************************************************************************************
00406 
00407 >       void OpToolSelect::Do(OpDescriptor* ToolOp)
00408 
00409     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
00410     Created:        16/8/93
00411     Inputs:         OpDescriptor representing a Tool
00412     Purpose:        Sets the currently active tool based on the tool OpDescriptor passed in.
00413     Errors:         None
00414 
00415 
00416 ********************************************************************************************/
00417 /*
00418 Technical Notes:
00419 ********************************************************************************************/
00420 
00421 void OpToolSelect::Do(OpDescriptor* ToolOp)
00422 {
00423     UINT32 ToolId = ToolOp->GetToolID();
00424 
00425     ENSURE(Tool::Find(ToolId) != NULL, "Tool Id does not exist!");
00426     ToolListItem * pItem = NULL;
00427     pItem = Tool::Find(ToolId);
00428     if(pItem)
00429       pItem->m_pTool->SetCurrent();
00430     
00431     //((Tool::Find(ToolId))->pTool)->SetCurrent();
00432     
00433     End();
00434 }
00435 
00436 #if !defined(EXCLUDE_FROM_RALPH)
00437 
00438 
00439 //*****************************************************************************************
00440 //                                                                      EXIT OPERATION
00441 
00442 /********************************************************************************************
00443 
00444 >       OpState DocOps::GetState(String_256* UIDescription, OpDescriptor* pOp)
00445 
00446     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
00447     Created:        11/8/93
00448     Inputs:         String - representing the operation description which may be updated
00449                 OpDescriptor - To help update the state
00450     Outputs:        -
00451     Returns:        -
00452     Purpose:        Find the state of the various DocOps operations.
00453     Errors:         -
00454     SeeAlso:        -
00455 
00456 ********************************************************************************************/
00457 
00458 OpState DocOps::GetState(String_256* UIDescription, OpDescriptor* pOp)
00459 {
00460     // File/New and File/Open are always available.
00461     if (pOp->Token == String(OPTOKEN_FILENEW) ||
00462         pOp->Token == String(OPTOKEN_FILEOPEN))
00463     {
00464         return OpState(FALSE, FALSE);
00465     }
00466 
00467     //Graham 20/10/97: New template commands
00468     if (pOp->Token == String(OPTOKEN_FILENEW_DRAWING))
00469     {
00470         //We need to change the name of the command to the name of the
00471         //default template file, converted so the first character
00472         //is upper case and the rest is lower
00473         PathName pathDefaultDrawingTemplate = CTemplateManager::GetDefaultDrawingTemplate();
00474 
00475         String_256 strToReturn=pathDefaultDrawingTemplate.GetFileName(FALSE);
00476 
00477         if (strToReturn.IsEmpty())
00478             strToReturn.Load(_R(IDS_NEWTEMPLATES_DEFAULTNAMEFORDRAWINGMENUITEM));
00479 
00480         strToReturn.toTitle();
00481 
00482 PORTNOTE("other", "Mangle file name to replace _'s with spaces")
00483         strToReturn.SwapChar( _T('_'), _T(' ') );
00484 
00485         *UIDescription=strToReturn;
00486         
00487         return OpState(FALSE, FALSE);
00488     }
00489 
00490     if (pOp->Token == String(OPTOKEN_FILENEW_ANIMATION))
00491     {
00492 PORTNOTE("other", "Remove template existance check - too annoying while it's not there!")
00493 #ifndef EXCLUDE_FROM_XARALX
00494         //Does the default animation template exist?
00495         PathName pathDefaultAnimationTemplate=GetDefaultAnimationTemplate();
00496         BOOL fFileExists=SGLibOil::FileExists(&pathDefaultAnimationTemplate);
00497 
00498         TRACEUSER( "jlh92", _T("Template Anim = %s, %d\n"), PCTSTR(pathDefaultAnimationTemplate.GetPath()), fFileExists );
00499 
00500         String_256 strToReturn=pathDefaultAnimationTemplate.GetFileName(FALSE);
00501 
00502         if (strToReturn.IsEmpty())
00503             strToReturn.Load(_R(IDS_NEWTEMPLATES_DEFAULTNAMEFORANIMATIONMENUITEM));
00504 
00505         strToReturn.toTitle();
00506 
00507         *UIDescription=strToReturn;
00508 #else
00509         BOOL fFileExists = FALSE;
00510 #endif
00511 
00512         //If not, grey the menu item
00513         return OpState(FALSE, !fFileExists, TRUE);
00514     }
00515 
00516     if (pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE1) ||
00517         pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE2) ||
00518         pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE3) ||
00519         pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE4) ||
00520         pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE5) ||
00521         pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE6) ||
00522         pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE7) ||
00523         pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE8) ||
00524         pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE9) ||
00525         pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE10))
00526     {
00527         //Now find out which template in that path we want
00528         //(This code isn't particularly pleasant)
00529         INT32           iPositionOfFCharacter = pOp->Token.FindNextChar( 'F', 0 );
00530         TRACEUSER( "jlh92", _T("Token = %s(%d)\n"), PCTSTR(pOp->Token), iPositionOfFCharacter );
00531         String_256      strNumberOfTemplate;
00532         pOp->Token.Left( &strNumberOfTemplate, iPositionOfFCharacter );
00533 
00534         // Convert the template ordinal into the template name
00535         TCHAR*          pszTmp;
00536         INT32           iNumberOfTemplate = camStrtol( (TCHAR *)strNumberOfTemplate, &pszTmp, 10 );
00537         String_256      strNameOfFile;
00538         CTemplateManager& TemplateManager( GetApplication()->GetTemplateManager() );
00539         bool            fSuccess = TemplateManager.GetTemplateFilename( iNumberOfTemplate, &strNameOfFile );
00540 
00541         // Don't allow any errors set while searching to propagate outside this scope
00542         Error::ClearError();
00543 
00544         // Tell the menu item to remove itsled if we don't have the template
00545         if( !fSuccess )
00546             return OpState(FALSE, FALSE, TRUE);
00547 
00548         //We've found a file. So strip the .xar from the name and capitalize, as follows...
00549         PathName        pathTemplates;
00550         pathTemplates.SetFileNameAndType( strNameOfFile );
00551         *UIDescription = pathTemplates.GetFileName(FALSE);
00552         UIDescription->toTitle();
00553 
00554         return OpState(FALSE, FALSE, FALSE);
00555     }
00556     
00557     // File/SaveAll is only available if there is a document that is "dirty".
00558     if (pOp->Token == String(OPTOKEN_FILESAVEALL))
00559     {
00560         // Are any open non-embedded document's modified?
00561         wxDocManager   *pDocManager = AfxGetApp().GetDocumentManager();
00562         wxList         &lstDocuemnt = pDocManager->GetDocuments();
00563         wxNode         *pNode = lstDocuemnt.GetFirst();         
00564         while( NULL != pNode )
00565         {
00566             CCamDoc    *pDoc = (CCamDoc *)pNode->GetData();
00567 
00568 PORTNOTE("other","Removed OLE usage")
00569 #ifndef EXCLUDE_FROM_XARALX
00570 #if (_OLE_VER >= 0x200)
00571             // Don't consider embedded documents for file-saving commands.
00572             if (pDoc->IsEmbedded()) continue;
00573 #endif
00574 #endif
00575     
00576             // Is this document "dirty" (and not embedded)?
00577             if( pDoc->IsModified() )
00578                 return OpState(FALSE, FALSE);
00579 
00580             // Get the next document template.
00581             pNode = pNode->GetNext();
00582         }
00583 
00584         // If we get here there are no dirty documents.
00585         UIDescription->Load(_R(IDS_FILE_SAVE_ALL_NONE_CHANGED_GREYED));
00586         return OpState(FALSE, TRUE);
00587     }
00588 
00589     // Get the selected document(s).
00590     Document* pKernelDoc = Document::GetSelected();
00591     CCamDoc* pOilDoc = (pKernelDoc) ? pKernelDoc->GetOilDoc() : 0;
00592     
00593     // If there isn't one then none of the other File options are available.
00594     if (!pOilDoc)
00595     {
00596         // This knocks out the rest when there are no docs open.
00597         UIDescription->Load(_R(IDS_FILE_NO_DOC_GREYED));
00598         return OpState(FALSE, TRUE);
00599     }
00600 
00601     // Work out the state of File/Save.
00602     if (pOp->Token == String(OPTOKEN_FILESAVE))
00603     {
00604         // By default this is available.
00605         BOOL fGreyed = FALSE;
00606         pOp->EnableHotKey();
00607 #if (_OLE_VER >= 0x200)
00608         // If we're embedding a document, replace "Save..." with "Update..." and disable that HotKey
00609         if (pOilDoc->IsEmbedded())
00610         {
00611             UIDescription->MakeMsg(_R(IDS_FILE_UPDATE), (LPCTSTR) pOilDoc->GetContainerName());
00612             pOp->DisableHotKey();
00613         }
00614         else
00615 #endif
00616         // Disabled because we're not modified?
00617         if (!pOilDoc->IsModified())
00618         {
00619             fGreyed = TRUE;
00620             UIDescription->Load(_R(IDS_FILE_SAVE_NOT_CHANGED_GREYED));
00621         }
00622 
00623         // Return state.
00624         return OpState(FALSE, fGreyed);
00625     }
00626 
00627     // Work out the state of File/Close.
00628     if (pOp->Token == String(OPTOKEN_FILECLOSE))
00629     {
00630         // By default this is available.
00631         BOOL fGreyed = FALSE;
00632 
00633     #if (_OLE_VER >= 0x200)
00634         // Work out what to show for OLE server File/Close.
00635         if (pOilDoc->IsEmbedded())
00636         {
00637             // The doc is embedded.  If we are in server mode then the Close
00638             // option should be greyed.  If we aren't in server mode then
00639             // change the text to "Close And Return To ...".
00640             if (!AfxOleGetUserCtrl())
00641             {
00642                 // In server mode.  Disable the menu option.
00643                 fGreyed = TRUE;
00644                 UIDescription->Load(_R(IDS_FILE_CLOSE_SERVER_MODE_GREYED));
00645             }
00646             else
00647             {
00648                 // User control.  Enable the option and change the text of the
00649                 // Close option to show return.
00650                 UIDescription->MakeMsg(_R(IDS_FILE_CLOSE_AND_RETURN),
00651                                        (LPCTSTR) pOilDoc->GetContainerName());
00652             }
00653         }
00654     #endif
00655 
00656         // Not embeddding - use the default text for the menu option.
00657         return OpState(FALSE, fGreyed);
00658     }
00659     
00660     // Work out File/SaveAs (SaveCopyAs), which is always available (if there's a
00661     // selected document).
00662 #if (_OLE_VER >= 0x200)
00663     if (pOp->Token == String(OPTOKEN_FILESAVEAS))
00664     {
00665         // If we are enabled and embedding then change the menu to Save Copy As.
00666         if (pOilDoc->IsEmbedded()) UIDescription->Load(_R(IDS_FILE_SAVE_COPY_AS));
00667     }
00668 #endif
00669 
00670     // If we get here we're available.
00671     return OpState(FALSE, FALSE);
00672 }                                    
00673 
00674 
00675 
00676 /********************************************************************************************
00677 >       OpState OpExit::GetState(String_256* UIDescription, OpDescriptor*)
00678 
00679     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
00680     Created:        11/8/93
00681     Inputs:         String - representing the operation description which may be updated
00682                 OpDescriptor - To help update the state
00683     Returns:        The OpState describing this Exit Operation.
00684     Purpose:        Find the state of the OpExit operation.
00685 ********************************************************************************************/
00686 
00687 OpState OpExit::GetState(String_256* UIDescription, OpDescriptor*)
00688 {
00689 PORTNOTE("other","Removed OLE usage")
00690 #ifndef EXCLUDE_FROM_XARALX
00691 #if (_OLE_VER >= 0x200)
00692 
00693     // Get the user's document, if any.
00694     Document* pKernelDoc = Document::GetSelected();
00695     CCamDoc* pOilDoc = (pKernelDoc != 0) ? pKernelDoc->GetOilDoc() : 0;
00696 
00697     // Get the associated OpDescriptor.
00698     OpDescriptor* pDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_EXIT);
00699     ERROR3IF(!pDesc, "Null OpDescriptor* in OpExit::GetState");
00700 
00701     // Is the selected document embedded in an OLE container etc?
00702     if (pOilDoc && pOilDoc->IsServer())
00703     {
00704         // The selected document is embedded, we know the specific container.
00705         UIDescription->MakeMsg(_R(IDS_FILE_EXIT_AND_RETURN),
00706                                 (LPCTSTR) pOilDoc->GetContainerName());
00707     }
00708     else if (CCamSrvrItem::HowMany() > 0)
00709     {
00710         // Are there any embedded docs?
00711         POSITION posTpl = AfxGetApp()->GetFirstDocTemplatePosition();
00712         CDocTemplate* pTemplate = AfxGetApp()->GetNextDocTemplate(posTpl);
00713         POSITION posDoc = pTemplate->GetFirstDocPosition();
00714         while (posDoc)
00715         {
00716             // Skip docs that aren't active OLE items.
00717             CCamDoc* pDoc = (CCamDoc*) pTemplate->GetNextDoc(posDoc);
00718             if (pDoc->IsServer())
00719             {
00720                 // The selected document is not embedded but some other is,
00721                 // we know only the word 'host' for this ...
00722                 UIDescription->MakeMsg(_R(IDS_FILE_EXIT_AND_RETURN),
00723                                        (LPCTSTR) String_64(_R(IDS_DEFAULT_HOST_NAME)));
00724                 break;
00725             }
00726         }
00727             
00728     }
00729 
00730 #endif
00731 #endif
00732 
00733     // This option is always available.
00734     return OpState(FALSE, FALSE);
00735 }
00736 
00737 
00738 
00739 /******************************************************************************************
00740 
00741 >       OpExit::OpExit()
00742 
00743     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
00744     Created:        20/8/93
00745     Inputs:         -
00746     Outputs:        -
00747     Returns:        -
00748     Purpose:        Constructs a new opExit object: setting default operation flags, and 
00749                 adding it to the Live list. 
00750     Errors:         -
00751     SeeAlso:        -
00752 
00753 ******************************************************************************************/
00754 
00755 OpExit::OpExit(): Operation()
00756 {
00757     // We don't show the progress indicator cos it may have been destroyed
00758     OpFlags.HasOwnTimeIndicator = TRUE;     
00759 }
00760 
00761 
00762 
00763 /******************************************************************************************
00764 
00765 >       void OpExit::Do(OpDescriptor*)
00766 
00767     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
00768     Created:        12/8/93
00769     Inputs:         An Operation Descriptor
00770     Outputs:        -
00771     Returns:        -
00772     Purpose:        Actually "DO" a Exit Application operation.
00773     Errors:         -
00774     SeeAlso:        -
00775 
00776 ********************************************************************************************/
00777 /*
00778 Technical Notes:
00779 ********************************************************************************************/
00780 
00781 void OpExit::Do(OpDescriptor*)
00782 {
00783 
00784     // CGS:  we need to clear out all intermediate blend steps ....
00785     // NOTE:  this clears out all 'built-up' intermediate data
00786     // it clears out both 'render' and 'becomea'
00787 
00788     NodeGroup::KillAllBlendBecomeAConsLists (TRUE);
00789 
00790     GetApplication ()->ResetRealDownload ();    // how dare they!
00791     
00792     // This op is not related to a document.
00793     pOurDoc = NULL;
00794 
00795 PORTNOTE("other","Removed InternetManager usage")
00796 #ifndef EXCLUDE_FROM_XARALX
00797 //  InternetManager::OnExitInstance(); // this should be called as early as possible
00798 #endif
00799 
00800     ExitAction(); 
00801 
00802     End();
00803 }
00804 
00805 
00806 
00807 /********************************************************************************************
00808 
00809 >       BOOL OpExit::Init()
00810 
00811     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
00812     Created:        11/8/93
00813     Inputs:         -
00814     Outputs:        -
00815     Returns:        -
00816     Purpose:        Create an OpDescriptor for the EXIT operation
00817     Errors:         -
00818     SeeAlso:        -
00819 
00820 ********************************************************************************************/
00821 
00822 BOOL OpExit::Init()
00823 {   
00824     return (RegisterOpDescriptor(0, 
00825                                 _R(IDS_APP_EXIT),
00826                                 CC_RUNTIME_CLASS(OpExit), 
00827                                 OPTOKEN_EXIT,
00828                                 OpExit::GetState,
00829                                 HID_APP_EXIT,
00830                                 _R(IDBBL_EXITOP),
00831                                 _R(IDD_BARCONTROLSTORE),    /* resource ID */
00832                                 _R(IDC_BTN_FILEEXIT)                /* control ID */
00833                                 )
00834             );
00835 }
00836 
00837 //********************************************************************************************
00838 //                                                      MENU POPUP OPERATIONS
00839 /********************************************************************************************
00840 
00841 >       MenuPopupOps::MenuPopupOps(): Operation()
00842 
00843     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
00844     Created:        20/8/93
00845     Inputs:         -
00846     Outputs:        -
00847     Returns:        -
00848     Purpose:        Constructs a new MenuPopupOps object: setting default operation flags, and 
00849                 adding it to the Live list. 
00850     Errors:         -
00851     SeeAlso:        -
00852 
00853 ********************************************************************************************/
00854      
00855 MenuPopupOps::MenuPopupOps(): Operation()
00856 {                 
00857 }
00858 
00859 /********************************************************************************************
00860 
00861 >       void MenuPopupOps::Do(OpDescriptor*)
00862 
00863     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
00864     Created:        12/8/93
00865     Inputs:         An Operation Descriptor
00866     Outputs:        -
00867     Returns:        -
00868     Purpose:        Actually "DO" a Exit Application operation.
00869     Errors:         -
00870     SeeAlso:        -
00871 
00872 ********************************************************************************************/
00873 /*
00874 Technical Notes:
00875 ********************************************************************************************/
00876 
00877 void MenuPopupOps::Do(OpDescriptor* WhichOp)
00878 {
00879     End();
00880 }
00881 
00882 
00883 /********************************************************************************************
00884 
00885 >       OpState MenuPopupOps::GetState(String_256* UIDescription, OpDescriptor*)
00886 
00887     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
00888     Created:        11/8/93
00889     Inputs:         String - representing the operation description which may be updated
00890                 OpDescriptor - To help update the state
00891     Outputs:        -
00892     Returns:        -
00893     Purpose:        Find the state of the MenuPopupOps operation.
00894     Errors:         -
00895     SeeAlso:        -
00896 
00897 ********************************************************************************************/
00898 
00899 OpState MenuPopupOps::GetState(String_256* UIDescription, OpDescriptor*)
00900 {
00901     return OpState(FALSE, FALSE);
00902 }                                    
00903 
00904 
00905 /********************************************************************************************
00906 
00907 >       BOOL MenuPopupOps::Init()
00908 
00909     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
00910     Created:        11/8/93
00911     Inputs:         -
00912     Outputs:        -
00913     Returns:        -
00914     Purpose:        Create OpDescriptors for the each submenu operation in here.
00915     Errors:         -
00916     SeeAlso:        -
00917 
00918 ********************************************************************************************/
00919 
00920 BOOL MenuPopupOps::Init()
00921 {
00922     // The following Opdescriptors do not need to be created using the usual
00923     // RegisterOpDescriptor function because they cannot be invoked by the user and they
00924     // are not connected to controls on the button bars.
00925     OpDescriptor* FileOp = new OpDescriptor(
00926                                             0, 
00927                                             _R(IDS_FILE_MENU),
00928                                             CC_RUNTIME_CLASS(MenuPopupOps), 
00929                                             OPTOKEN_FILE_MENU,
00930                                             MenuPopupOps::GetState,
00931                                             0,      /* help ID */
00932                                             _R(IDBBL_FILEOP),
00933                                             0       /* bitmap ID */);
00934     ERRORIF(!FileOp, _R(IDE_NOMORE_MEMORY), FALSE);
00935 
00936     OpDescriptor* EditOp = new OpDescriptor(
00937                                             0, 
00938                                             _R(IDS_EDIT_MENU),
00939                                             CC_RUNTIME_CLASS(MenuPopupOps), 
00940                                             OPTOKEN_EDIT_MENU,
00941                                             MenuPopupOps::GetState,
00942                                             0,      /* help ID */
00943                                             _R(IDBBL_EDITOP),
00944                                             0       /* bitmap ID */);
00945     ERRORIF(!EditOp, _R(IDE_NOMORE_MEMORY), FALSE);
00946 
00947     OpDescriptor* AttrOp = new OpDescriptor(
00948                                             0, 
00949                                             _R(IDS_ATTRIBUTE_MENU),
00950                                             CC_RUNTIME_CLASS(MenuPopupOps), 
00951                                             OPTOKEN_ATTRIBUTE_MENU,
00952                                             MenuPopupOps::GetState,
00953                                             0,      /* help ID */
00954                                             0,
00955                                             0       /* bitmap ID */);
00956     ERRORIF(!AttrOp, _R(IDE_NOMORE_MEMORY), FALSE);
00957 
00958     OpDescriptor* HelpOp = new OpDescriptor(
00959                                             0, 
00960                                             _R(IDS_HELP_MENU),
00961                                             CC_RUNTIME_CLASS(MenuPopupOps), 
00962                                             OPTOKEN_HELP_MENU,
00963                                             MenuPopupOps::GetState,
00964                                             0,      /* help ID */
00965                                             _R(IDBBL_HELPOP),
00966                                             0       /* bitmap ID */);
00967     ERRORIF(!HelpOp, _R(IDE_NOMORE_MEMORY), FALSE);
00968 
00969     OpDescriptor* WindowOp = new OpDescriptor(
00970                                                 0, 
00971                                                 _R(IDS_WINDOW_MENU),
00972                                                 CC_RUNTIME_CLASS(MenuPopupOps), 
00973                                                 OPTOKEN_WINDOW_MENU,
00974                                                 MenuPopupOps::GetState,
00975                                                 0,      /* help ID */
00976                                                 _R(IDBBL_WINDOWOP),
00977                                                 0       /* bitmap ID */);
00978     ERRORIF(!WindowOp, _R(IDE_NOMORE_MEMORY), FALSE);
00979 
00980     OpDescriptor* UtilsOp = new OpDescriptor(
00981                                             0, 
00982                                             _R(IDS_UTILS_MENU),
00983                                             CC_RUNTIME_CLASS(MenuPopupOps), 
00984                                             OPTOKEN_UTILS_MENU,
00985                                             MenuPopupOps::GetState,
00986                                             0,      /* help ID */
00987                                             0,
00988                                             0       /* bitmap ID */);
00989     ERRORIF(!UtilsOp, _R(IDE_NOMORE_MEMORY), FALSE);
00990 
00991     OpDescriptor* ArrangeOp = new OpDescriptor(     
00992                                                 0, 
00993                                                 _R(IDS_ARRANGE_MENU),
00994                                                 CC_RUNTIME_CLASS(MenuPopupOps), 
00995                                                 OPTOKEN_ARRANGE_MENU,
00996                                                 MenuPopupOps::GetState,
00997                                                 0,      /* help ID */
00998                                                 0,  /* Bubble help ID */
00999                                                 0       /* bitmap ID */);
01000     ERRORIF(!ArrangeOp, _R(IDE_NOMORE_MEMORY), FALSE);
01001 
01002     OpDescriptor* DebugOp = new OpDescriptor(       
01003                                                 0, 
01004                                                 _R(IDS_DEBUG_MENU),
01005                                                 CC_RUNTIME_CLASS(MenuPopupOps), 
01006                                                 OPTOKEN_DEBUG_MENU,
01007                                                 MenuPopupOps::GetState,
01008                                                 0,      /* help ID */
01009                                                 0,  /* Bubble help ID */
01010                                                 0       /* bitmap ID */);
01011     ERRORIF(!DebugOp, _R(IDE_NOMORE_MEMORY), FALSE);
01012 
01013     OpDescriptor* QualityOp = new OpDescriptor(     
01014                                                 0, 
01015                                                 _R(IDS_QUALITY_MENU),
01016                                                 CC_RUNTIME_CLASS(MenuPopupOps), 
01017                                                 OPTOKEN_QUALITY_MENU,
01018                                                 MenuPopupOps::GetState,
01019                                                 0,      /* help ID */
01020                                                 0,  /* Bubble help ID */
01021                                                 0       /* bitmap ID */);
01022     ERRORIF(!QualityOp, _R(IDE_NOMORE_MEMORY), FALSE);
01023 
01024     OpDescriptor* BarsOp = new OpDescriptor(        
01025                                                 0, 
01026                                                 _R(IDS_BARS_CONFIG),
01027                                                 CC_RUNTIME_CLASS(MenuPopupOps), 
01028                                                 OPTOKEN_BARS_MENU,
01029                                                 MenuPopupOps::GetState,
01030                                                 0,      /* help ID */
01031                                                 0,  /* Bubble help ID */
01032                                                 0       /* bitmap ID */);
01033     ERRORIF(!BarsOp, _R(IDE_NOMORE_MEMORY), FALSE);
01034 
01035     OpDescriptor* CombineOp = new OpDescriptor(     
01036                                                 0, 
01037                                                 _R(IDS_COMBINE_MENU),
01038                                                 CC_RUNTIME_CLASS(MenuPopupOps), 
01039                                                 OPTOKEN_COMBINESHAPES,
01040                                                 MenuPopupOps::GetState,
01041                                                 0,      /* help ID */
01042                                                 0,  /* Bubble help ID */
01043                                                 0       /* bitmap ID */);
01044     ERRORIF(!CombineOp, _R(IDE_NOMORE_MEMORY), FALSE);
01045 
01046     OpDescriptor* NumSidesOp = new OpDescriptor(    
01047                                                 0, 
01048                                                 _R(IDS_QUICKSHAPES_NUMBERSIDES),
01049                                                 CC_RUNTIME_CLASS(MenuPopupOps), 
01050                                                 OPTOKEN_QUICKSHAPE_NUMBERSIDES,
01051                                                 MenuPopupOps::GetState,
01052                                                 0,      /* help ID */
01053                                                 0,  /* Bubble help ID */
01054                                                 0       /* bitmap ID */);
01055     ERRORIF(!NumSidesOp, _R(IDE_NOMORE_MEMORY), FALSE);
01056 
01057 
01058 PORTNOTE("other","Removed bitmap effects usage")
01059 #ifndef EXCLUDE_FROM_XARALX
01060     OpDescriptor* EditEffectOp = new OpDescriptor(     
01061                                                 0, 
01062                                                 _R(IDS_EDITEFFECT_MENU),
01063                                                 CC_RUNTIME_CLASS(MenuPopupOps), 
01064                                                 OPTOKEN_EDITEFFECTS,
01065                                                 MenuPopupOps::GetState,
01066                                                 0,      // help ID
01067                                                 0,      // Bubble help ID
01068                                                 0 );    // bitmap ID
01069     ERRORIF(!EditEffectOp, _R(IDE_NOMORE_MEMORY), FALSE);
01070 #endif
01071     return TRUE;
01072 }
01073 
01074 //********************************************************************************************
01075 //                                                      FILE OPEN, CLOSE, NEW, SAVE OPERATION
01076 
01077 /********************************************************************************************
01078 
01079 >       DocOps::DocOps(): Operation()
01080 
01081     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01082     Created:        20/8/93
01083     Inputs:         -
01084     Outputs:        -
01085     Returns:        -
01086     Purpose:        Constructs a new DocOps object: setting default operation flags, and 
01087                 adding it to the Live list. 
01088     Errors:         -
01089     SeeAlso:        -
01090 
01091 ********************************************************************************************/
01092      
01093 DocOps::DocOps(): Operation()
01094 {                 
01095 }
01096 
01097 /********************************************************************************************
01098 
01099 >       void DocOps::Do(OpDescriptor*)
01100 
01101     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01102     Created:        12/8/93
01103     Inputs:         An Operation Descriptor
01104     Outputs:        -
01105     Returns:        -
01106     Purpose:        Actually "DO" a Exit Application operation.
01107     Errors:         -
01108     SeeAlso:        -
01109 
01110 ********************************************************************************************/
01111 /*
01112 Technical Notes:
01113 ********************************************************************************************/
01114 
01115 void DocOps::Do(OpDescriptor* WhichOp)
01116 {
01117     if ((WhichOp->Token) ==  String(OPTOKEN_FILEOPEN))
01118         FileOpenAction(); 
01119     else if ((WhichOp->Token) == String(OPTOKEN_FILENEW))
01120         FileNewAction(); 
01121     else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_DRAWING))
01122         FileNewAction(); 
01123     else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_ANIMATION))
01124         FileNewAnimationAction(); 
01125     else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE1))
01126         FileNewTemplateAction(1); 
01127     else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE2))
01128         FileNewTemplateAction(2); 
01129     else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE3))
01130         FileNewTemplateAction(3); 
01131     else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE4))
01132         FileNewTemplateAction(4); 
01133     else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE5))
01134         FileNewTemplateAction(5); 
01135     else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE6))
01136         FileNewTemplateAction(6); 
01137     else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE7))
01138         FileNewTemplateAction(7); 
01139     else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE8))
01140         FileNewTemplateAction(8); 
01141     else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE9))
01142         FileNewTemplateAction(9); 
01143     else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE10))
01144         FileNewTemplateAction(10); 
01145     else if ((WhichOp->Token) == String(OPTOKEN_FILECLOSE))
01146     {
01147         // Close the file
01148         FileCloseAction();
01149 
01150         // Always set the working doc to NULL, otherwise we try to indirect it in End().
01151         // (This is safe even if the document doesn't close (e.g. modified) because we
01152         // don't do much clean-up after a successful or failed document close op - we
01153         // basically just delete the operation.
01154         pOurDoc = NULL;
01155     }
01156     else if ((WhichOp->Token) == String(OPTOKEN_FILESAVE))
01157         FileSaveAction(); 
01158     else if ((WhichOp->Token) == String(OPTOKEN_FILESAVEAS))
01159         FileSaveAsAction();
01160     else if ((WhichOp->Token) == String(OPTOKEN_FILESAVEALL))
01161     {
01162         // Save all modified documents
01163         FileSaveAllAction();
01164     }
01165     End();
01166 }
01167 
01168 
01169 
01170 /********************************************************************************************
01171 
01172 >       BOOL DocOps::Init()
01173 
01174     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01175     Created:        11/8/93
01176     Inputs:         -
01177     Outputs:        -
01178     Returns:        -
01179     Purpose:        Create OpDescriptors for the each file operation
01180     Errors:         -
01181     SeeAlso:        -
01182 
01183 ********************************************************************************************/
01184 
01185 BOOL DocOps::Init()
01186 {
01187     REGOP(FILE,OPEN,DocOps)
01188     REGOP(FILE,CLOSE,DocOps)
01189     REGOP(FILE,NEW,DocOps)
01190     REGOP(FILE,SAVE,DocOps)
01191     REGOP(FILE,SAVEAS,DocOps)
01192 
01193     REGOP(FILE,NEW_DRAWING,DocOps)
01194     REGOP(FILE,NEW_ANIMATION,DocOps)
01195     REGOP(FILE,NEW_TEMPLATE1,DocOps)
01196     REGOP(FILE,NEW_TEMPLATE2,DocOps)
01197     REGOP(FILE,NEW_TEMPLATE3,DocOps)
01198     REGOP(FILE,NEW_TEMPLATE4,DocOps)
01199     REGOP(FILE,NEW_TEMPLATE5,DocOps)
01200     REGOP(FILE,NEW_TEMPLATE6,DocOps)
01201     REGOP(FILE,NEW_TEMPLATE7,DocOps)
01202     REGOP(FILE,NEW_TEMPLATE8,DocOps)
01203     REGOP(FILE,NEW_TEMPLATE9,DocOps)
01204     REGOP(FILE,NEW_TEMPLATE10,DocOps)
01205     
01206     BOOL ok = RegisterOpDescriptor(
01207                     0,
01208                     _R(IDS_FILE_SAVEALL),
01209                     CC_RUNTIME_CLASS(DocOps),
01210                     OPTOKEN_FILESAVEALL,
01211                     DocOps::GetState,
01212                     0,                                      // Help
01213                     _R(IDBBL_FILESAVEALL),      // Bubble ID
01214                     _R(IDD_BARCONTROLSTORE),
01215                     _R(IDC_FILESAVEALL),        // Button ID
01216                     SYSTEMBAR_FILE,         // Bar ID
01217                     TRUE                            // Recieve system messages
01218                     );
01219     ERRORIF(!ok, _R(IDE_NOMORE_MEMORY), FALSE);
01220     
01221     return TRUE;
01222 }
01223 
01224 
01225 
01226 //********************************************************************************************
01227 //                                                      HELP USING & HELP INDEX OPERATION
01228 
01229 /********************************************************************************************
01230 
01231 >       HelpOps::HelpOps(): Operation()
01232 
01233     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01234     Created:        23/8/93
01235     Inputs:         -
01236     Outputs:        -
01237     Returns:        -
01238     Purpose:        Constructs a new HelpOps object: setting default operation flags, and 
01239                 adding it to the Live list. 
01240     Errors:         -
01241     SeeAlso:        -
01242 
01243 ********************************************************************************************/
01244      
01245 HelpOps::HelpOps(): Operation()
01246 {                 
01247 }
01248 
01249 /********************************************************************************************
01250 
01251 >       void HelpOps::Do(OpDescriptor*)
01252 
01253     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01254     Created:        12/8/93
01255     Inputs:         An Operation Descriptor
01256     Outputs:        -
01257     Returns:        -
01258     Purpose:        Actually "DO" a Exit Application operation.
01259     Errors:         -
01260     SeeAlso:        -
01261 
01262 ********************************************************************************************/
01263 /*
01264 Technical Notes:
01265 ********************************************************************************************/
01266 
01267 void HelpOps::Do(OpDescriptor* WhichOp)
01268 {
01269     if ((WhichOp->Token) ==  String(OPTOKEN_HELPUSING))
01270         HelpUsingAction(); 
01271     else if ((WhichOp->Token) == String(OPTOKEN_HELPINDEX))
01272         HelpIndexAction();
01273     else if (WhichOp->Token == String(OPTOKEN_HELPTOOLS))
01274         HelpToolsAction();
01275     else if (WhichOp->Token == String(OPTOKEN_HELPGALLERIES))
01276         HelpGalleriesAction();
01277     else if (WhichOp->Token == String(OPTOKEN_HELPDEMOS))
01278     {
01279     #ifndef WEBSTER
01280         HelpDemosAction();
01281     #else   // webster
01282         WebsterDemos();
01283     #endif //webster
01284     }
01285     else if (WhichOp->Token == String(OPTOKEN_HELPPLAYER))
01286     {
01287         HelpPlayerAction();
01288     }
01289     else if (WhichOp->Token == String(OPTOKEN_HELPTECHSUPPORT))
01290         HelpTechSupportAction();
01291 //Webster_Ranbir_12\11\96
01292 #ifdef INC_WEB_MENU_ITEMS
01293     else if (WhichOp->Token == String(OPTOKEN_XARAX_FORUM))
01294         HelpXaraForumAction();
01295     else if (WhichOp->Token == String(OPTOKEN_WEBSTER_HOME_PAGE))
01296         HelpWebsterHomePage();
01297     else if (WhichOp->Token == String(OPTOKEN_XARA_HOME_PAGE))
01298         HelpXaraHomePage();
01299     else if (WhichOp->Token == String(OPTOKEN_HINTS_AND_TIPS_PAGES))
01300         WebsterHelpPages();
01301     else if (WhichOp->Token == String(OPTOKEN_XARA_PURCHASE_PAGE))
01302         HelpXaraPurchasePage();
01303 //Webster_Ranbir_12\11\96
01304 #endif //INC_WEB_MENU_ITEMS
01305 
01306 #ifdef INC_WEB_MENU_ITEMS
01307     else if (WhichOp->Token == String(OPTOKEN_WEBLINK))
01308         if(GetCDHelpOn())
01309             SetWebsterReg(FALSE);
01310         else
01311             SetWebsterReg(TRUE);
01312 #endif  //INC_WEB_MENU_ITEMS    
01313 
01314 #ifdef STANDALONE
01315     else if ((WhichOp->Token) == String(OPTOKEN_HELPSPEC))
01316         HelpSpecAction(); 
01317 #endif
01318     
01319     End();
01320 }                 
01321 
01322 
01323 /********************************************************************************************
01324 
01325 >       OpState HelpOps::GetState(String_256* UIDescription, OpDescriptor*)
01326 
01327     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01328     Created:        11/8/93
01329     Inputs:         String - representing the operation description which may be updated
01330                 OpDescriptor - To help update the state
01331     Outputs:        -
01332     Returns:        -
01333     Purpose:        Find the state of the HelpOps operation.
01334     Errors:         -
01335     SeeAlso:        -
01336 
01337 ********************************************************************************************/
01338 
01339 OpState HelpOps::GetState(String_256* UIDescription, OpDescriptor* OpDesc)
01340 {
01341     //Webster_Ranbir_12\11\96
01342 #ifdef INC_WEB_MENU_ITEMS
01343     if (OpDesc->Token == String(OPTOKEN_WEBLINK))       
01344     {
01345         OpState Opst;
01346         BOOL RegistryFlag = IsCDROMOn();
01347         if(RegistryFlag)
01348         {
01349             Opst.Ticked = TRUE;
01350             SetCDHelpOn(TRUE);
01351         }
01352         else
01353         {
01354             Opst.Ticked = FALSE;
01355             SetCDHelpOn(FALSE);
01356         }
01357         return Opst;
01358     }
01359     else
01360 #endif //INC_WEB_MENU_ITEMS
01361         return OpState(FALSE, FALSE);
01362 }                                    
01363 
01364 
01365 /********************************************************************************************
01366 
01367 >       BOOL HelpOps::Init()
01368 
01369     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01370     Created:        11/8/93
01371     Inputs:         -
01372     Outputs:        -
01373     Returns:        -
01374     Purpose:        Create OpDescriptors for the each file operation
01375     Errors:         -
01376     SeeAlso:        -
01377 
01378 ********************************************************************************************/
01379 
01380 #define HID_HELP_TOOLS                          (0)
01381 #define HID_HELP_GALLERIES                      (0)
01382 #define HID_HELP_DEMOS                          (0)
01383 #define HID_HELP_PLAYER                         (0)
01384 #define HID_HELP_TECHSUPPORT            (0)
01385 
01386 BOOL HelpOps::Init()
01387 {
01388     REGOP(HELP,USING,HelpOps)
01389     /* OpDescriptor* UsingOp = new OpDescriptor(
01390                                             0, 
01391                                             _R(IDS_HELP_USING),
01392                                             CC_RUNTIME_CLASS(HelpOps), 
01393                                             OPTOKEN_HELPUSING,
01394                                             HelpOps::GetState,
01395                                             HID_HELP_USING,
01396                                             _R(IDBBL_HELPUSINGOP),
01397                                             0 );
01398 
01399     ERRORIF(!UsingOp, _R(IDE_NOMORE_MEMORY), FALSE);*/
01400 
01401     // REGOP(HELP, INDEX, HelpOps)
01402     OpDescriptor* IndexOp = new OpDescriptor(
01403                                                 0, 
01404                                                 _R(IDS_HELP_TOPICS),
01405                                                 CC_RUNTIME_CLASS(HelpOps), 
01406                                                 OPTOKEN_HELPINDEX,
01407                                                 HelpOps::GetState,
01408                                                 HID_HELP_INDEX,
01409                                                 _R(IDBBL_HELPINDEXOP),
01410                                                 0 );
01411 
01412     ERRORIF(!IndexOp, _R(IDE_NOMORE_MEMORY), FALSE);
01413 
01414     // REGOP(HELP, DEMOS, HelpOps);
01415     OpDescriptor* DemosOp = new OpDescriptor(
01416                                                 0, 
01417                                                 _R(IDS_HELP_MOVIES),
01418                                                 CC_RUNTIME_CLASS(HelpOps), 
01419                                                 OPTOKEN_HELPDEMOS,
01420                                                 HelpOps::GetState,
01421                                                 HID_HELP_DEMOS,
01422                                                 _R(IDBBL_HELPDEMOSOP),
01423                                                 0 );
01424 
01425     ERRORIF(!DemosOp, _R(IDE_NOMORE_MEMORY), FALSE);
01426     
01427     // REGOP(HELP, PLAYER, HelpPlayer);
01428     OpDescriptor* PlayerOp = new OpDescriptor(
01429                                                 0, 
01430                                                 _R(IDS_HELP_PLAYER),
01431                                                 CC_RUNTIME_CLASS(HelpOps), 
01432                                                 OPTOKEN_HELPPLAYER,
01433                                                 HelpOps::GetState,
01434                                                 HID_HELP_PLAYER,
01435                                                 _R(IDBBL_HELPPLAYEROP),
01436                                                 0 );
01437 
01438     ERRORIF(!PlayerOp, _R(IDE_NOMORE_MEMORY), FALSE);
01439 
01440     //Webster_Ranbir_12\11\96
01441 #ifdef INC_WEB_MENU_ITEMS
01442 
01443     OpDescriptor* WebsOp = new OpDescriptor(
01444                                                 0, 
01445                                                 _R(IDS_XARA_WEB),               
01446                                                 CC_RUNTIME_CLASS(HelpOps), 
01447                                                 OPTOKEN_XARA_WEB_MENU,      
01448                                                 HelpOps::GetState,
01449                                                 0,
01450                                                 0,
01451                                                 0 );
01452 
01453     ERRORIF(!WebsOp, _R(IDE_NOMORE_MEMORY), FALSE);
01454 
01455 
01456     OpDescriptor* ForumOp = new OpDescriptor(
01457                                                 0,
01458                                                 _R(IDS_XARAX_FORUM),
01459                                                 CC_RUNTIME_CLASS(HelpOps),
01460                                                 OPTOKEN_XARAX_FORUM,
01461                                                 HelpOps::GetState,
01462                                                 0,
01463                                                 0,
01464                                                 0 );
01465 
01466     ERRORIF(!ForumOp, _R(IDE_NOMORE_MEMORY), FALSE);
01467 
01468 
01469     OpDescriptor* WebsHomePageOp = new OpDescriptor(
01470                                                 0, 
01471                                                 _R(IDS_WEBSTER_HOME_PAGE),                  
01472                                                 CC_RUNTIME_CLASS(HelpOps), 
01473                                                 OPTOKEN_WEBSTER_HOME_PAGE,
01474                                                 HelpOps::GetState,
01475                                                 0,
01476                                                 0,
01477                                                 0 );
01478 
01479     ERRORIF(!WebsHomePageOp, _R(IDE_NOMORE_MEMORY), FALSE);
01480 
01481 
01482     OpDescriptor* XaraHomePageOp = new OpDescriptor(
01483                                                 0, 
01484                                                 _R(IDS_XARA_HOME_PAGE),                 
01485                                                 CC_RUNTIME_CLASS(HelpOps), 
01486                                                 OPTOKEN_XARA_HOME_PAGE,
01487                                                 HelpOps::GetState,
01488                                                 0,
01489                                                 0,
01490                                                 0 );
01491 
01492     ERRORIF(!XaraHomePageOp, _R(IDE_NOMORE_MEMORY), FALSE);
01493 
01494 
01495     OpDescriptor* XaraPurchasePageOp = new OpDescriptor(
01496                                                 0, 
01497                                                 _R(IDS_XARA_PURCHASE_PAGE),                 
01498                                                 CC_RUNTIME_CLASS(HelpOps), 
01499                                                 OPTOKEN_XARA_PURCHASE_PAGE,
01500                                                 HelpOps::GetState,
01501                                                 0,
01502                                                 0,
01503                                                 0 );
01504 
01505     ERRORIF(!XaraPurchasePageOp, _R(IDE_NOMORE_MEMORY), FALSE);
01506 
01507     OpDescriptor* HintsAndTipsPagesOp = new OpDescriptor(
01508                                                 0, 
01509                                                 _R(IDS_HINTS_AND_TIPS_PAGES),                   
01510                                                 CC_RUNTIME_CLASS(HelpOps), 
01511                                                 OPTOKEN_HINTS_AND_TIPS_PAGES,
01512                                                 HelpOps::GetState,
01513                                                 0,
01514                                                 0,
01515                                                 0 );
01516 
01517     ERRORIF(!HintsAndTipsPagesOp, _R(IDE_NOMORE_MEMORY), FALSE);
01518 
01519 
01520 
01521     OpDescriptor* WebLink = new OpDescriptor(
01522                                                 0, 
01523                                                 _R(IDS_WEBLINK),                
01524                                                 CC_RUNTIME_CLASS(HelpOps), 
01525                                                 OPTOKEN_WEBLINK,
01526                                                 HelpOps::GetState,
01527                                                 0,
01528                                                 0,
01529                                                 0 );
01530 
01531     ERRORIF(!WebLink, _R(IDE_NOMORE_MEMORY), FALSE);
01532 
01533 #endif // INC_WEB_MENU_ITEMS
01534 
01535     REGOP(HELP, TOOLS, HelpOps);
01536     REGOP(HELP, GALLERIES, HelpOps);
01537 
01538     REGOP(HELP, TECHSUPPORT, HelpOps);
01539 
01540 #ifdef STANDALONE
01541     REGOP(HELP,SPEC,HelpOps)
01542 #endif
01543 
01544     return TRUE;
01545 }
01546 
01547 //********************************************************************************************
01548 //                                                      WINDOW MENU OPERATIONS
01549 
01550 /********************************************************************************************
01551 
01552 >       WindowOps::WindowOps(): Operation()
01553 
01554     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01555     Created:        23/8/93
01556     Inputs:         -
01557     Outputs:        -
01558     Returns:        -
01559     Purpose:        Constructs a new WindowOps object: setting default operation flags, and 
01560                 adding it to the Live list. 
01561     Errors:         -
01562     SeeAlso:        -
01563 
01564 ********************************************************************************************/
01565      
01566 WindowOps::WindowOps(): Operation()
01567 {                 
01568 }
01569 
01570 /********************************************************************************************
01571 
01572 >       void WindowOps::Do(OpDescriptor*)
01573 
01574     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01575     Created:        12/8/93
01576     Inputs:         An Operation Descriptor
01577     Outputs:        -
01578     Returns:        -
01579     Purpose:        Actually "DO" a Exit Application operation.
01580     Errors:         -
01581     SeeAlso:        -
01582 
01583 ********************************************************************************************/
01584 /*
01585 Technical Notes:
01586 ********************************************************************************************/
01587 
01588 void WindowOps::Do(OpDescriptor* WhichOp)
01589 {
01590     if( WhichOp->Token == String( OPTOKEN_NEXTDOCUMENT ) )
01591         WindowNextDcocument( true );
01592     else if( WhichOp->Token == String( OPTOKEN_LASTDOCUMENT ) )
01593         WindowNextDcocument( false );
01594     
01595     PORTNOTETRACE("other","WindowOps::Do - do nothing");
01596 #ifndef EXCLUDE_FROM_XARALX
01597     else if ((WhichOp->Token) ==  String(OPTOKEN_WINDOWNEWVIEW))
01598         WindowNewAction(); 
01599     else if ((WhichOp->Token) == String(OPTOKEN_WINDOWARRANGE))
01600         WindowArrangeAction(); 
01601     else if ((WhichOp->Token) == String(OPTOKEN_WINDOWCASCADE))
01602         WindowCascadeAction(); 
01603     else if ((WhichOp->Token) == String(OPTOKEN_WINDOWTILE))
01604         WindowTileHorzAction(); 
01605 //    else if ((WhichOp->Token) == String(OPTOKEN_WINDOWTILE_H))
01606 //              WindowTileHorzAction(); 
01607 //    else if ((WhichOp->Token) == String(OPTOKEN_WINDOWTILE_V))
01608 //              WindowTileVertAction(); 
01609 #endif
01610     End();
01611 }                 
01612 
01613 
01614 /********************************************************************************************
01615 
01616 >       OpState WindowOps::GetState(String_256* UIDescription, OpDescriptor*)
01617 
01618     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01619     Created:        11/8/93
01620     Inputs:         String - representing the operation description which may be updated
01621                 OpDescriptor - To help update the state
01622     Outputs:        -
01623     Returns:        -
01624     Purpose:        Find the state of the WindowOps operation.
01625     Errors:         -
01626     SeeAlso:        -
01627 
01628 ********************************************************************************************/
01629 
01630 OpState WindowOps::GetState(String_256* UIDescription, OpDescriptor*)
01631 {
01632     PORTNOTETRACE("other","WindowOps::GetState - do nothing");
01633 #ifndef EXCLUDE_FROM_XARALX
01634     return WindowCmdState();
01635 #else
01636     return OpState();
01637 #endif
01638 }                                    
01639 
01640 
01641 /********************************************************************************************
01642 
01643 >       BOOL WindowOps::Init()
01644 
01645     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01646     Created:        11/8/93
01647     Inputs:         -
01648     Outputs:        -
01649     Returns:        -
01650     Purpose:        Create OpDescriptors for the each file operation
01651     Errors:         -
01652     SeeAlso:        -
01653 
01654 ********************************************************************************************/
01655 
01656 BOOL WindowOps::Init()
01657 {
01658 PORTNOTETRACE("other","WindowOps::Do - do nothing");
01659 #ifndef EXCLUDE_FROM_XARALX
01660     REGOP(WINDOW,NEWVIEW,WindowOps)
01661     /*OpDescriptor* NewOp = new OpDescriptor (
01662                                             0, 
01663                                             _R(IDS_WINDOW_NEW_VIEW),
01664                                             CC_RUNTIME_CLASS(WindowOps), 
01665                                             OPTOKEN_WINDOWNEWVIEW,
01666                                             WindowOps::GetState,
01667                                             HID_WINDOW_NEW,
01668                                             _R(IDBBL_WINDOWNEWOP),
01669                                             0 );
01670 
01671     ERRORIF(!NewOp, _R(IDE_NOMORE_MEMORY), FALSE);*/
01672 
01673     REGOP(WINDOW,ARRANGE,WindowOps)
01674     /*OpDescriptor* ArrangeOp = new OpDescriptor(
01675                                                 0, 
01676                                                 _R(IDS_WINDOW_ARRANGE),
01677                                                 CC_RUNTIME_CLASS(WindowOps), 
01678                                                 OPTOKEN_WINDOWARRANGE,
01679                                                 WindowOps::GetState,
01680                                                 HID_WINDOW_ARRANGE,
01681                                                 _R(IDBBL_WINDOWARRANGEOP),
01682                                                 0);
01683 
01684     ERRORIF(!ArrangeOp, _R(IDE_NOMORE_MEMORY), FALSE);*/
01685 
01686     REGOP(WINDOW,CASCADE,WindowOps)
01687     /*OpDescriptor* CascadeOp = new OpDescriptor(
01688                                             0, 
01689                                             _R(IDS_WINDOW_CASCADE),
01690                                             CC_RUNTIME_CLASS(WindowOps), 
01691                                             OPTOKEN_WINDOWCASCADE,
01692                                             WindowOps::GetState,
01693                                             HID_WINDOW_CASCADE,
01694                                             _R(IDBBL_WINDOWCASCADEOP),
01695                                             0);
01696 
01697     ERRORIF(!CascadeOp, _R(IDE_NOMORE_MEMORY), FALSE);*/
01698 
01699     REGOP(WINDOW,TILE,WindowOps)
01700     /*OpDescriptor* TileOp = new OpDescriptor(
01701                                                 0, 
01702                                                 _R(IDS_WINDOW_TILE),
01703                                                 CC_RUNTIME_CLASS(WindowOps), 
01704                                                 OPTOKEN_WINDOWTILE,
01705                                                 WindowOps::GetState,
01706                                                 HID_WINDOW_TILE_VERT,
01707                                                 _R(IDBBL_TILEVERTICALOP),
01708                                                 0);
01709     ERRORIF(!TileOp, _R(IDE_NOMORE_MEMORY), FALSE);*/
01710 #endif
01711     
01712     // REGOP(HELP, PLAYER, HelpPlayer);
01713     OpDescriptor* NextDocumentOp = new OpDescriptor(
01714                                                 0, 
01715                                                 _R(IDS_NEXTDOCUMENT),
01716                                                 CC_RUNTIME_CLASS(WindowOps), 
01717                                                 OPTOKEN_NEXTDOCUMENT,
01718                                                 WindowOps::GetState,
01719                                                 0,
01720                                                 _R(IDBBL_NEXTDOCUMENT),
01721                                                 0 );
01722 
01723     ERRORIF(!NextDocumentOp, _R(IDE_NOMORE_MEMORY), FALSE);
01724 
01725     // REGOP(HELP, PLAYER, HelpPlayer);
01726     OpDescriptor* LastDocumentOp = new OpDescriptor(
01727                                                 0, 
01728                                                 _R(IDS_LASTDOCUMENT),
01729                                                 CC_RUNTIME_CLASS(WindowOps), 
01730                                                 OPTOKEN_LASTDOCUMENT,
01731                                                 WindowOps::GetState,
01732                                                 0,
01733                                                 _R(IDBBL_LASTDOCUMENT),
01734                                                 0 );
01735 
01736     ERRORIF(!LastDocumentOp, _R(IDE_NOMORE_MEMORY), FALSE);
01737 
01738     return TRUE;
01739 }
01740 
01741 //********************************************************************************************
01742 //                                                      VIEW MENU OPERATIONS
01743 
01744 /********************************************************************************************
01745 
01746 >       ViewOps::ViewOps(): Operation()
01747 
01748     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01749     Created:        23/8/93
01750     Inputs:         -
01751     Outputs:        -
01752     Returns:        -
01753     Purpose:        Constructs a new ViewOps object: setting default operation flags, and 
01754                 adding it to the Live list. 
01755     Errors:         -
01756     SeeAlso:        -
01757 
01758 ********************************************************************************************/
01759      
01760 ViewOps::ViewOps(): Operation()
01761 {                 
01762 }
01763 
01764 /********************************************************************************************
01765 
01766 >       virtual BOOL ViewOps::OnIdleEvent(void)
01767 
01768     Author:         Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
01769     Created:        4/6/95
01770     Inputs:         -
01771     Returns:        FALSE if it's OK to call low-priority idles (i.e. if I'm not busy this turn)
01772 
01773     Purpose:        Delays going into full screen mode until we are out of the broadcast loop
01774                 makes BarOp deletion safe
01775 
01776 ********************************************************************************************/
01777 
01778 BOOL ViewOps::OnIdleEvent(void)
01779 {
01780     if(DoFullScreen)
01781     {
01782         Progress::Start(FALSE);         // Start an hourglass with no delay
01783 
01784 PORTNOTE("other","Removed ViewFullScreenAction usage")
01785 #ifndef EXCLUDE_FROM_XARALX
01786         ViewFullScreenAction(); 
01787 #endif
01788             // Deregister for idles, because we should not be getting them now
01789         GetApplication()->RemoveIdleProcessor(IDLEPRIORITY_HIGH, this);
01790 
01791         End();
01792         DoFullScreen = FALSE;
01793         
01794 #ifndef STANDALONE
01795 PORTNOTE("other","Removed ToolbarDlg usage")
01796 #ifndef EXCLUDE_FROM_XARALX
01797         // no ToolbarDlg on standalone versions
01798         ToolbarDlg * pToolbarDlg = ToolbarDlg::GetToolbarDlg();
01799         if(pToolbarDlg)
01800             pToolbarDlg->ShowToolbarList();
01801 #endif
01802 #endif          
01803         Progress::Stop();                       // Stop the hourglass again
01804     }
01805     return(FALSE);          // And let the low-priority idle handlers do their stuff
01806 }
01807 
01808 
01809 
01810 
01811 /********************************************************************************************
01812 
01813 >       void ViewOps::Do(OpDescriptor*)
01814 
01815     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01816     Created:        12/8/93
01817     Inputs:         An Operation Descriptor
01818     Outputs:        -
01819     Returns:        -
01820     Purpose:        Actually "DO" a Exit Application operation.
01821     Errors:         -
01822     SeeAlso:        -
01823 
01824 ********************************************************************************************/
01825 /*
01826 Technical Notes:
01827 ********************************************************************************************/
01828 
01829 void ViewOps::Do(OpDescriptor* WhichOp)
01830 {
01831     DoFullScreen = FALSE;
01832     if ((WhichOp->Token) == String(OPTOKEN_VIEWFULLSCREEN))
01833     {
01834         // make sure there isn't a processor registered
01835         GetApplication()->RemoveIdleProcessor(IDLEPRIORITY_HIGH, this);
01836         // register the idle handler
01837         GetApplication()->RegisterIdleProcessor(IDLEPRIORITY_HIGH, this);
01838         DoFullScreen = TRUE;
01839         // if we End() now the idle loop will fall over.
01840         return;                                        // DONT END() !!!! 
01841     }
01842 
01843     if ((WhichOp->Token) ==  String(OPTOKEN_VIEWTOOLBAR))
01844         ViewToolBarAction(); 
01845     else if ((WhichOp->Token) == String(OPTOKEN_VIEWSTATUSBAR))
01846         ViewStatusBarAction(); 
01847     else if ((WhichOp->Token) == String(OPTOKEN_VIEWCOLOURBAR))
01848         ViewColourBarAction();
01849     else if ((WhichOp->Token) == String(OPTOKEN_VIEWSCROLLBARS))
01850         ViewScrollBarsAction();
01851     else if ((WhichOp->Token) == String(OPTOKEN_VIEWRULERS))
01852         ViewRulersAction();
01853 
01854     End();
01855 }                 
01856 
01857 
01858 /********************************************************************************************
01859 
01860 >       OpState ViewOps::GetState(String_256* UIDescription, OpDescriptor*)
01861 
01862     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01863     Created:        11/8/93
01864     Inputs:         String - representing the operation description which may be updated
01865                 OpDescriptor - To help update the state
01866     Outputs:        -
01867     Returns:        -
01868     Purpose:        Find the state of the ViewOps operation.
01869     Errors:         -
01870     SeeAlso:        -
01871 
01872 ********************************************************************************************/
01873 
01874 OpState ViewOps::GetState(String_256* UIDescription, OpDescriptor* WhichOp)
01875 {
01876     if ((WhichOp->Token) ==  String(OPTOKEN_VIEWTOOLBAR))
01877         return ViewToolBarState();
01878     else if ((WhichOp->Token) == String(OPTOKEN_VIEWSTATUSBAR))
01879         return ViewStatusBarState();
01880     else if ((WhichOp->Token) == String(OPTOKEN_VIEWCOLOURBAR))
01881         return ViewColourBarState();
01882     else if ((WhichOp->Token) == String(OPTOKEN_VIEWFULLSCREEN))
01883         return ViewFullScreenState();
01884     else if ((WhichOp->Token) == String(OPTOKEN_VIEWSCROLLBARS))
01885         return ViewScrollBarsState();
01886     else if ((WhichOp->Token) == String(OPTOKEN_VIEWRULERS))
01887         return ViewRulersState();
01888 
01889     return OpState(FALSE, FALSE);
01890 }                                    
01891 
01892 
01893 /********************************************************************************************
01894 
01895 >       BOOL ViewOps::Init()
01896 
01897     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
01898     Created:        11/8/93
01899     Inputs:         -
01900     Outputs:        -
01901     Returns:        -
01902     Purpose:        Create OpDescriptors for the each file operation
01903     Errors:         -
01904     SeeAlso:        -
01905 
01906 ********************************************************************************************/
01907 
01908 BOOL ViewOps::Init()
01909 {
01910     /*OpDescriptor* ToolOp = new OpDescriptor(
01911                                             0, 
01912                                             _R(IDS_VIEW_TOOLBAR),
01913                                             CC_RUNTIME_CLASS(ViewOps), 
01914                                             OPTOKEN_VIEWTOOLBAR,
01915                                             ViewOps::GetState,
01916                                             HID_VIEW_TOOLBAR,
01917                                             _R(IDBBL_VIEWTOOLBAROP),
01918                                             0 );
01919 
01920     ERRORIF(!ToolOp, _R(IDE_NOMORE_MEMORY), FALSE);*/
01921 
01922     REGOP(VIEW,STATUSBAR,ViewOps)
01923     OpDescriptor* ColourOp = new OpDescriptor(
01924                                                 0, 
01925                                                 _R(IDS_VIEW_COLOURBAR),
01926                                                 CC_RUNTIME_CLASS(ViewOps), 
01927                                                 OPTOKEN_VIEWCOLOURBAR,
01928                                                 ViewOps::GetState,
01929                                                 0,
01930                                                 0,
01931                                                 0,
01932                                                 0,
01933                                                 TRUE,
01934                                                 FALSE,              // Smart
01935                                                 TRUE,               // Clean
01936                                                 0,                  // OneOpenInstID
01937                                                 0,                  // AutoStateFlags
01938                                                 TRUE                // fCheckable
01939                                                 );
01940 
01941     ERRORIF(!ColourOp, _R(IDE_NOMORE_MEMORY), FALSE);
01942 
01943 /*
01944     OpDescriptor* FullScreenOp = new OpDescriptor(
01945                                                 0, 
01946                                                 _R(IDS_VIEW_FULLSCREEN),
01947                                                 CC_RUNTIME_CLASS(ViewOps), 
01948                                                 OPTOKEN_VIEWFULLSCREEN,
01949                                                 ViewOps::GetState,
01950                                                 0,
01951                                                 0,
01952                                                 0,0,TRUE  );
01953 */
01954 PORTNOTETRACE("other","ViewOps::Init - do nothing");
01955 #ifndef EXCLUDE_FROM_XARALX
01956     BOOL FullScreenOp = RegisterOpDescriptor(
01957                                                 0,
01958                                                 _R(IDS_VIEW_FULLSCREEN),
01959                                                 CC_RUNTIME_CLASS(ViewOps),
01960                                                 OPTOKEN_VIEWFULLSCREEN,
01961                                                 ViewOps::GetState,
01962                                                 HID_VIEW_FULLSCREEN,
01963                                                 _R(IDBBL_VIEWFULLSCREENOP),
01964                                                 _R(IDD_BARCONTROLSTORE),
01965                                                 _R(IDC_BTN_VIEWFULLSCREEN),
01966                                                 SYSTEMBAR_VIEW,
01967                                                 TRUE
01968                                               );
01969 
01970 //      REGOP(VIEW,FULLSCREEN,ViewOps)
01971     ERRORIF(!FullScreenOp, _R(IDE_NOMORE_MEMORY), FALSE);
01972 #endif
01973 
01974     OpDescriptor* ScrollBarsOp = new OpDescriptor(
01975                                                 0, 
01976                                                 _R(IDS_VIEW_SCROLLBARS),
01977                                                 CC_RUNTIME_CLASS(ViewOps), 
01978                                                 OPTOKEN_VIEWSCROLLBARS,
01979                                                 ViewOps::GetState,
01980                                                 0,
01981                                                 0,
01982                                                 0,
01983                                                 0,
01984                                                 TRUE,
01985                                                 FALSE,              // Smart
01986                                                 TRUE,               // Clean
01987                                                 0,                  // OneOpenInstID
01988                                                 0,                  // AutoStateFlags
01989                                                 TRUE                // fCheckable
01990                                                 );
01991 
01992     ERRORIF(!ScrollBarsOp, _R(IDE_NOMORE_MEMORY), FALSE);
01993 
01994     
01995     OpDescriptor* RulerOp = new OpDescriptor(
01996                                                 0, 
01997                                                 _R(IDS_VIEW_RULERS),
01998                                                 CC_RUNTIME_CLASS(ViewOps), 
01999                                                 OPTOKEN_VIEWRULERS,
02000                                                 ViewOps::GetState,
02001                                                 0,
02002                                                 _R(IDBBL_PAGERULERS),
02003                                                 _R(IDD_BARCONTROLSTORE),
02004                                                 _R(IDC_PAGERULERS),
02005                                                 TRUE,               // ReceiveMessages
02006                                                 FALSE,              // Smart
02007                                                 TRUE,               // Clean
02008                                                 0,                  // OneOpenInstID
02009                                                 0,                  // AutoStateFlags
02010                                                 TRUE                // fCheckable
02011                                                 );
02012 
02013     ERRORIF(!RulerOp, _R(IDE_NOMORE_MEMORY), FALSE);
02014     //REGOP(VIEW,COLOURBAR,ViewOps)
02015     return TRUE;
02016 }
02017 
02018 
02019 
02020 
02021 //*****************************************************************************************
02022 //                                                                      Dummy OPERATION
02023 
02024 /******************************************************************************************
02025 
02026 >       DummyOp::DummyOp()
02027 
02028     Author:         Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
02029     Created:        29/03/94
02030     Inputs:         -
02031     Outputs:        -
02032     Returns:        -
02033     Purpose:        Constructs a new DummyOp object: setting default operation flags, and 
02034                 adding it to the Live list. 
02035     Errors:         -
02036     SeeAlso:        -
02037 
02038 ********************************************************************************************/
02039      
02040 DummyOp::DummyOp(): Operation()
02041 {                 
02042 }
02043 
02044 
02045 
02046 /******************************************************************************************
02047 
02048 >       void DummyOp::Do(OpDescriptor*)
02049 
02050     Author:         Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
02051     Created:        29/03/94
02052     Inputs:         An Operation Descriptor
02053     Outputs:        -
02054     Returns:        -
02055     Purpose:        Actually "DO" a Dummy operation.
02056     Errors:         -
02057     SeeAlso:        -
02058 
02059 ******************************************************************************************/
02060 
02061 void DummyOp::Do(OpDescriptor*)
02062 {
02063     End();
02064 }
02065 
02066 
02067 /********************************************************************************************
02068 
02069 >       OpState DummyOp::GetState(String_256* UIDescription, OpDescriptor*)
02070 
02071     Author:         Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
02072     Created:        29/03/94
02073     Inputs:         String - representing the operation description which may be updated
02074                 OpDescriptor - To help update the state
02075     Outputs:        -
02076     Returns:        -
02077     Purpose:        Find the state of the DummyOp operation. This will always be greyed!
02078     Errors:         -
02079     SeeAlso:        -
02080 
02081 ********************************************************************************************/
02082 
02083 OpState DummyOp::GetState(String_256* UIDescription, OpDescriptor*)
02084 {
02085     return OpState( FALSE, TRUE );  // Never ticked, always greyed
02086 }
02087 
02088 /********************************************************************************************
02089 
02090 >       BOOL DummyOp::Init()
02091 
02092     Author:         Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
02093     Created:        11/8/93
02094     Inputs:         -
02095     Outputs:        -
02096     Returns:        -
02097     Purpose:        Create an OpDescriptor for the Dummy operation
02098     Errors:         -
02099     SeeAlso:        -
02100 
02101 ********************************************************************************************/
02102 
02103 BOOL DummyOp::Init()
02104 {
02105     DUMMYOP( _R(IDS_DO_NOTHING),                OPTOKEN_DO_NOTHING);
02106 
02107 //      DUMMYOP(_R(IDS_FILE_SAVEALL),               OPTOKEN_FILESAVEALL);
02108     DUMMYOP(_R(IDS_FILE_MERGE),                 OPTOKEN_FILEMERGE);
02109 //      DUMMYOP(_R(IDS_FILE_INFO),                  OPTOKEN_FILEINFO);
02110 //      DUMMYOP(_R(IDS_FILE_OPTIONS),               OPTOKEN_FILEOPTIONS);
02111 //      DUMMYOP(_R(IDS_UNITDLG),                    OPTOKEN_UNITDLG);
02112 //      DUMMYOP(_R(IDS_EDIT_DELETE),                OPTOKEN_EDITDELETE);
02113 //      DUMMYOP(_R(IDS_EDIT_SELECT_ALL),    OPTOKEN_EDITSELECTALL);
02114 //      DUMMYOP(_R(IDS_EDIT_SELECT_NONE),   OPTOKEN_EDITSELECTNONE);
02115 //      DUMMYOP(_R(IDS_EDIT_DUPLICATE),             OPTOKEN_EDITDUPLICATE);
02116 //      DUMMYOP(_R(IDS_EDIT_CLONE),                 OPTOKEN_EDITCLONE);
02117     DUMMYOP(_R(IDS_EDIT_OBJECT_INFO),   OPTOKEN_EDITOBJECTINFO);
02118     DUMMYOP(_R(IDS_ATTR_FONT),                  OPTOKEN_ATTRFONT);
02119     DUMMYOP(_R(IDS_ATTR_LINE),                  OPTOKEN_ATTRLINE);
02120     DUMMYOP(_R(IDS_ATTR_FILL),                  OPTOKEN_ATTRFILL);
02121     DUMMYOP(_R(IDS_ATTR_STYLE),                 OPTOKEN_ATTRSTYLE);
02122 //      DUMMYOP(_R(IDS_ARRANGE_UP_LAYER),   OPTOKEN_ARRANGEUPLAYER);
02123 //      DUMMYOP(_R(IDS_ARRANGE_UP_TOP),             OPTOKEN_ARRANGEUPTOP);
02124 //      DUMMYOP(_R(IDS_ARRANGE_UP_ONE),             OPTOKEN_ARRANGEUPONE);
02125 //      DUMMYOP(_R(IDS_ARRANGE_DOWN_ONE),   OPTOKEN_ARRANGEDOWNONE);
02126 //      DUMMYOP(_R(IDS_ARRANGE_DOWN_BOTTOM),OPTOKEN_ARRANGEDOWNBOTTOM);
02127 //      DUMMYOP(_R(IDS_ARRANGE_DOWN_LAYER), OPTOKEN_ARRANGEDOWNLAYER);
02128 //      DUMMYOP(_R(IDS_ARRANGE_ALIGNMENT),  OPTOKEN_ARRANGEALIGNMENT);
02129 //      DUMMYOP(_R(IDS_ARRANGE_PULL_GRID),  OPTOKEN_ARRANGEPULLGRID);
02130     DUMMYOP(_R(IDS_MAKEMASK),   OPTOKEN_MAKEMASK);
02131     DUMMYOP(_R(IDS_MASKINSIDE), OPTOKEN_MASKINSIDE);
02132 //      DUMMYOP(_R(IDS_ARRANGE_JOIN_SHAPES),        OPTOKEN_ARRANGEJOINSHAPES);
02133 //      DUMMYOP(_R(IDS_ARRANGE_BREAK_SHAPES),       OPTOKEN_ARRANGEBREAKSHAPES);
02134 //      DUMMYOP(_R(IDS_ARRANGE_MAKE_SHAPES),        OPTOKEN_ARRANGEMAKESHAPES);
02135 //      DUMMYOP(_R(IDS_UTIL_COLOUR),                OPTOKEN_UTILCOLOUR);
02136     DUMMYOP(_R(IDS_UTIL_CUSTOMIZE),             OPTOKEN_UTILCUSTOMIZE);
02137 //      DUMMYOP(_R(IDS_UTIL_OPTIONS),               OPTOKEN_UTILOPTIONS);
02138 //      DUMMYOP(_R(IDS_WINDOW_NEW_VIEW),            OPTOKEN_WINDOWNEWVIEW);
02139     DUMMYOP(_R(IDS_WINDOW_EASY_MDI),            OPTOKEN_WINDOWEASYMDI);
02140 //      DUMMYOP(_R(IDS_WINDOW_TOOLBARS),            OPTOKEN_WINDOWTOOLBARS);
02141     DUMMYOP(_R(IDS_WINDOW_RULERS),              OPTOKEN_WINDOWRULERS);
02142 //      DUMMYOP(_R(IDS_WINDOW_GRIDS),                       OPTOKEN_WINDOWGRIDS);
02143 //      DUMMYOP(_R(IDS_WINDOW_SNAP),                        OPTOKEN_WINDOWSNAP);
02144     DUMMYOP(_R(IDS_WINDOW_BORDERS),             OPTOKEN_WINDOWBORDERS);
02145     DUMMYOP(_R(IDS_WINDOW_QUALITY),             OPTOKEN_WINDOWQUALITY);
02146     DUMMYOP(_R(IDS_WINDOW_SEPARATION),  OPTOKEN_WINDOWSEPARATION);
02147 //      DUMMYOP(_R(IDS_EDIT_CUT),                   OPTOKEN_EDITCUT);
02148 //      DUMMYOP(_R(IDS_EDIT_COPY),                  OPTOKEN_EDITCOPY);
02149 //      DUMMYOP(_R(IDS_EDIT_PASTE),                 OPTOKEN_EDITPASTE);
02150     DUMMYOP(_R(IDS_EDIT_PASTE_LINK),    OPTOKEN_EDITPASTESPECIAL);
02151     DUMMYOP(_R(IDS_EDIT_OLE_INSERT),    OPTOKEN_EDITOLEINSERT);
02152     DUMMYOP(_R(IDS_EDIT_OLE_LINKS),             OPTOKEN_EDITOLELINKS);
02153     DUMMYOP(_R(IDS_EDIT_OLE_OBJECT),    OPTOKEN_EDITOLEOBJECT);
02154 //      DUMMYOP(_R(IDS_QUALITY_ANTI_ALIASED),       OPTOKEN_QUALITYANTIALIASED);
02155 //      DUMMYOP(_R(IDS_QUALITY_NORMAL),                     OPTOKEN_QUALITYNORMAL);
02156 //      DUMMYOP(_R(IDS_QUALITY_SIMPLE),                     OPTOKEN_QUALITYSIMPLE);
02157 //      DUMMYOP(_R(IDS_QUALITY_OUTLINE),            OPTOKEN_QUALITYOUTLINE);
02158 
02159     DUMMYOP(_R(IDS_GALLERIES_SUB_OP),    OPTOKEN_GALLERIES_SUBMENU);
02160     DUMMYOP(_R(IDS_ANIMATION_SUB_OP),    OPTOKEN_ANIMATION_SUBMENU);
02161     return (TRUE);
02162 }
02163 
02164 
02165 
02166 
02167 String_256 OpUpdate::IndexBaseURL = _T("http://xara.xaraonline.com/XaraX2/WebFiles/");
02168 String_32 OpUpdate::IndexLeafName = _T("index.xml");
02169 
02170 /********************************************************************************************
02171 
02172 >   OpUpdate::OpUpdate(): Operation()
02173 
02174     Author:         Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02175     Created:        09/3/04
02176     Inputs:         
02177     Purpose:        OpUpdate constructor
02178 
02179 ********************************************************************************************/
02180 
02181 OpUpdate::OpUpdate(): Operation()
02182 {}
02183 
02184 /********************************************************************************************
02185 
02186 >   void OpUpdate::DoWithParam(OpDescriptor*, OpParam* pOpParam)
02187 
02188     Author:         Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02189     Created:        09/3/04
02190     Inputs:         OpParam - (BOOL) Param1 Whether the request was from the user or automatic
02191     Purpose:        Show the Update or Special boards
02192 
02193 ********************************************************************************************/
02194 
02195 void OpUpdate::DoWithParam(OpDescriptor*, OpParam* pOpParam)
02196 {
02197     PORTNOTETRACE("other","OpUpdate::DoWithParam - do nothing");
02198 #ifndef EXCLUDE_FROM_XARALX
02199     BOOL forcedByUser = (BOOL)pOpParam->Param1;
02200 
02201     if (!forcedByUser)
02202     {
02203         // This is an automatic (background) check
02204         CheckForNewFiles();
02205 
02206         // update takes priority over specials - don't show both
02207 
02208         if (!UpdateDontShowAgain)
02209         {
02210             CWebDialogDlg webdlg(TRUE, _T("UpgradeLX.web"), TRUE, NULL, 0, FALSE);
02211             webdlg.DoModal();
02212             UpdateDontShowAgain = webdlg.DontShowAgain();
02213         }
02214         else if (!SpecialsDontShowAgain)
02215         {
02216             CWebDialogDlg webdlg(TRUE, GetSpecialsFile());
02217             webdlg.DoModal();
02218             SpecialsDontShowAgain = webdlg.DontShowAgain();
02219         }
02220     }
02221     else
02222         Progress::Start(FALSE, _R(IDS_UPDATING_SPECIALS), -1);
02223 
02224     // kick off the web updater to find new versions of the files 
02225     // (to appear the next time we run)
02226     BOOL bOK = UpdateFiles(forcedByUser);
02227 
02228     if (forcedByUser)
02229         Progress::Stop();
02230 
02231     if (bOK && forcedByUser)
02232     {
02233         // This is a deliberate (foreground) check, so we must show the user something...
02234         CheckForNewFiles();
02235 
02236         // Don't show the "DontShowAgain" flag
02237         // Don't show the window's surround
02238         // Do show the "follow up" message
02239         CWebDialogDlg webdlg(FALSE, _T("UpgradeLX.web"), FALSE, NULL, 0, TRUE);
02240         webdlg.DoModal();
02241 // Don't change the state of the DontShowAgain flag because we didn't show it...
02242 //      UpdateDontShowAgain = webdlg.DontShowAgain();
02243     }
02244 
02245     // If invoked deliberately by the user then tag the HelpAndSupport downloads onto
02246     // the end of this operation...
02247     if (forcedByUser)
02248     {
02249         HelpDownloadOp::CheckForNewFiles(forcedByUser);
02250     } 
02251 #endif
02252     End();
02253 }
02254 
02255 /********************************************************************************************
02256 
02257 >   void OpUpdate::Do(OpDescriptor*)
02258 
02259     Author:         Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02260     Created:        09/3/04
02261     Returns:        
02262     Purpose:        The default operation is called from the menu
02263 
02264 ********************************************************************************************/
02265 
02266 void OpUpdate::Do(OpDescriptor* od)
02267 {
02268 PORTNOTETRACE("other","OpUpdate::Do - do nothing");
02269 #ifndef EXCLUDE_FROM_XARALX
02270     this->DoWithParam(od,&OpParam((INT32) TRUE, NULL));
02271 #endif
02272 }
02273 
02274 /********************************************************************************************
02275 
02276 >   static variables used in preferences
02277 
02278 ********************************************************************************************/
02279 
02280 BOOL        OpUpdate::UpdateDontShowAgain = TRUE;
02281 BOOL        OpUpdate::SpecialsDontShowAgain = TRUE;
02282 INT32           OpUpdate::UpdateFileDate = 0;
02283 INT32           OpUpdate::SpecialsFileDate = 0;
02284 
02285 
02286 /********************************************************************************************
02287 
02288 >   BOOL OpUpdate::Init()
02289 
02290     Author:         Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02291     Created:        09/3/04
02292     Returns:        TRUE / FALSE
02293     Purpose:        Initialise the Update operation and preferences
02294 
02295 ********************************************************************************************/
02296 
02297 BOOL OpUpdate::Init()
02298 {
02299 PORTNOTETRACE("other","OpUpdate::Init - do nothing");
02300 #ifndef EXCLUDE_FROM_XARALX
02301     if (! 
02302         RegisterOpDescriptor(
02303             0, 
02304             _T( _R(IDS_APP_UPDATE) ),
02305             CC_RUNTIME_CLASS(OpUpdate), 
02306             OPTOKEN_UPDATE,
02307             OpUpdate::GetState
02308         )
02309     )
02310     {
02311         return FALSE;
02312     }
02313     if (!Camelot.DeclareSection(TEXT("Update"), 12) // 12 because HelpDownloadOp also puts 6 entris here...
02314         || !Camelot.DeclarePref(TEXT("Update"), TEXT("UpdateDontShowAgain"), &UpdateDontShowAgain)
02315         || !Camelot.DeclarePref(TEXT("Update"), TEXT("SpecialsDontShowAgain"), &SpecialsDontShowAgain)
02316         || !Camelot.DeclarePref(TEXT("Update"), TEXT("UpdateFileDate"), &UpdateFileDate)
02317         || !Camelot.DeclarePref(TEXT("Update"), TEXT("SpecialsFileDate"), &SpecialsFileDate)
02318         || !Camelot.DeclarePref(TEXT("Update"), TEXT("WebFilesIndexLeafName"), &IndexLeafName)
02319 
02320 // Only allow the base URL to be configurable in DEBUG builds
02321 // Thus the value assigned to IndexBaseURL above is hardwired into Release builds
02322 #ifdef _DEBUG
02323         || !Camelot.DeclarePref(TEXT("Update"), TEXT("WebFilesBaseURL"), &IndexBaseURL)
02324 #endif
02325         )
02326     {
02327         return FALSE;
02328     }
02329 #endif
02330 
02331     return TRUE;
02332 }
02333 
02334 /****************************************************************************
02335 
02336 >   void OpUpdate::CheckForNewFiles()
02337 
02338     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02339     Created:    19/3/2004
02340     Purpose:    record change of version of update/specials in preferences data
02341                 to be shown at next appropriate time
02342 
02343 ****************************************************************************/
02344 
02345 void OpUpdate::CheckForNewFiles()
02346 {
02347     PORTNOTETRACE("other","OpUpdate::CheckForNewFiles - do nothing");
02348 #ifndef EXCLUDE_FROM_XARALX
02349     // *** Important note *** For updating this code to Win64, ensure that
02350     // the 64 bit time_t value is NOT truncated to (32bit) integer.
02351 
02352     String_256 sUpgradeFile = GetWebFilePath(_T("UpgradeLX.web"));
02353     String_256 sSpecialsFileName = GetSpecialsFile();
02354     String_256 sSpecialsFilePath = GetWebFilePath(sSpecialsFileName);
02355 
02356     CFileStatus status;
02357 
02358     if (CFile::GetStatus(sUpgradeFile, status))
02359     {
02360         if (status.m_mtime.GetTime() > UpdateFileDate)
02361         {
02362             // only force the update check if it is NOT the installed file
02363             if (UpdateFileDate != 0)
02364                 UpdateDontShowAgain = FALSE;
02365 
02366             UpdateFileDate = status.m_mtime.GetTime();
02367         }
02368     }
02369     if (CFile::GetStatus(sSpecialsFilePath, status))
02370     {
02371         if (status.m_mtime.GetTime() > SpecialsFileDate)
02372         {
02373             SpecialsDontShowAgain = FALSE;
02374             SpecialsFileDate = status.m_mtime.GetTime();
02375         }
02376     }
02377 #endif
02378 }
02379 
02380 /****************************************************************************
02381 
02382 >   String_256 OpUpdate::GetSpecialsFile()
02383 
02384     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02385     Created:    19/3/2004
02386     Purpose:    Get the specials file name, which varies according to
02387                 whether the user is running the Free Trial or not.
02388 
02389 ****************************************************************************/
02390 
02391 String_256 OpUpdate::GetSpecialsFile()
02392 {
02393     String_256 SpecialsFile;
02394 
02395     SpecialsFile = _T("SpecialsLX.web");
02396 
02397     return SpecialsFile;
02398 }
02399 
02400 
02401 /****************************************************************************
02402 
02403     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02404     Purpose:    Returns the base .web file path 
02405 
02406 ****************************************************************************/
02407 
02408 String_256 OpUpdate::GetWebFileRoot()
02409 {
02410     String_256 exepath;
02411 PORTNOTETRACE("other","OpUpdate::GetWebFileRoot - do nothing");
02412 #ifndef EXCLUDE_FROM_XARALX
02413     
02414 PORTNOTE("other","Removed CResDll usage")
02415 #ifndef EXCLUDE_FROM_XARALX
02416     CResDll::GetExecutablePath(exepath);
02417 #endif
02418     return String_256(exepath) + _T("\\WebFiles");
02419 #else
02420     return exepath;
02421 #endif
02422 
02423 /*
02424 // Save into AppData folder in Documents and Settings:
02425     DWORD CSInfo = CSIDL_APPDATA|CSIDL_FLAG_CREATE;
02426 
02427     String_256 sPartialPath(_T(""),MAX_PATH);
02428     TCHAR* Path = sPartialPath.GetBuffer(MAX_PATH);
02429     SHGetFolderPath(NULL, CSInfo, NULL, 0, Path);
02430     sPartialPath.ReleaseBuffer();
02431     String_256 sPath;
02432     sPath.Format("%s\\Xara\\%s\\%s", sPartialPath, PROGRAM_NAME, _T("\\WebFiles"));
02433 
02434     return sPath;
02435 */
02436 }
02437 
02438 /****************************************************************************
02439 
02440 >   String_256 GetWebFilePath(TCHAR *ReturnBuffer)
02441 
02442     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02443     Created:    23/3/2004
02444     Purpose:    Returns the full .web file path for a given .web file. Reverts
02445                 to ENG default if locale scoped file not found.
02446 
02447 ****************************************************************************/
02448 
02449 String_256 OpUpdate::GetWebFilePath(LPCTSTR filename)
02450 {
02451     String_256          webfilepath;
02452 
02453     PORTNOTETRACE("other","OpUpdate::GetWebFilePath - do nothing");
02454 #ifndef EXCLUDE_FROM_XARALX
02455     CFileStatus         TempStatus;
02456 
02457     // the path to the locale scoped file  ...
02458     webfilepath = GetWebFileRoot() + _T("\\") + CResDll::GetCurrentLocale();
02459     webfilepath += _T("\\") + String_256(filename);
02460 
02461     // if it doesn't exist, revert to the ENG default folder
02462     if (!CFile::GetStatus(webfilepath, TempStatus))
02463     {
02464         webfilepath = GetWebFileRoot() + _T("\\ENG\\") + String_256(filename);
02465     }
02466     TRACEUSER( "Marc", _T("webfilepath = %s\n"),webfilepath);
02467 #endif
02468     return webfilepath;
02469 }
02470 
02471 
02472 /****************************************************************************
02473 
02474 >   BOOL OpUpdate::UpdateFiles() 
02475 
02476     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02477     Created:    23/3/2004
02478     Purpose:    Call the WebFileUpdater to download any new files from
02479                 our servers
02480 
02481 ****************************************************************************/
02482 
02483 BOOL OpUpdate::UpdateFiles(BOOL bForeground) 
02484 {
02485     return UpdateFiles(bForeground, GetWebFileRoot(), GetUpdateURL(), (String_256)IndexLeafName, _T("UpdateMessages"));
02486 }
02487 
02488 
02489 /****************************************************************************
02490 
02491 >   BOOL OpUpdate::UpdateFiles(BOOL bForeground,
02492                                 const String_256& strClientFolder,
02493                                 const String_256& strURL,
02494                                 const String_256& strIndexLeafName,
02495                                 const String_256& strRegKeyName
02496                                 )
02497 
02498     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02499     Created:    23/3/2004
02500     Purpose:    Call the WebFileUpdater to download any new files from
02501                 our servers
02502 
02503 ****************************************************************************/
02504 
02505 BOOL OpUpdate::UpdateFiles(BOOL bForeground,
02506                             const String_256& strClientFolder,
02507                             const String_256& strURL,
02508                             const String_256& strIndexLeafName,
02509                             const String_256& strRegKeyName
02510                             )
02511 {
02512     PORTNOTETRACE("other","OpUpdate::UpdateFiles - do nothing");
02513 #ifndef EXCLUDE_FROM_XARALX
02514     WEBFILEUPDATERLib::IWebFileUpdaterPtr pWebFileUpdater;
02515     HRESULT hr = pWebFileUpdater.CreateInstance(__uuidof(WebFileUpdater));
02516     ERROR2IF(FAILED(hr), FALSE, "Failed To create WebFileUpdater object");
02517 
02518     pWebFileUpdater->put_ClientFolder(_bstr_t(strClientFolder));
02519     pWebFileUpdater->put_ServerURL(_bstr_t(strURL));
02520     pWebFileUpdater->put_IndexName(_bstr_t(strIndexLeafName));
02521 
02522 #ifndef _DEBUG
02523     // Don't let the WFU know about it's stored state in debug builds
02524     // This forces it to download a file every time - good for debugging
02525     //
02526     // Must ensure that the key exists because WFU doesn't create it if it's missing
02527     // (And doesn't DO ANYTHING if it's missing!)
02528     HKEY hKey = CreateRegKey(hAppStateRegKey, strRegKeyName);
02529     if (hKey)
02530     {
02531         // If ServerCheck doesn't exist yet, GetRegDword returns 0
02532         if (GetRegDword(hKey, _T("ServerCheck"))==0)
02533             SetRegDword(hKey, _T("ServerCheck"), 0);
02534         CloseRegKey(hKey);
02535 
02536         String_256 strFullRegKeyPath = _T(PRODUCT_REGISTRYKEY_USERPATH) + strRegKeyName;
02537         pWebFileUpdater->put_RegistryKeyPath(_bstr_t(strFullRegKeyPath));
02538     }
02539 #endif
02540 
02541     hr = pWebFileUpdater->raw_Update((BSTR)NULL, !bForeground);
02542     if (FAILED(hr))
02543     {
02544         UINT32 idMessage = 0;
02545 
02546 //      if (hr==E_XM_CLIENTFOLDERREADONLY)
02547         if (hr==0x80041008)
02548             idMessage = _R(IDS_WARN_PROGRAMFOLDER_READONLY);
02549 //      else if (hr==E_XM_CLIENTFOLDERUNAVAILABLE)
02550         else if (hr==0x80041009)
02551             idMessage = _R(IDS_WARN_PROGRAMFOLDER_UNAVAILABLE);
02552 //      else if (hr==E_XM_COULDNOTWRITEINDEX)
02553         else if (hr==0x80041007)
02554             idMessage = _R(IDS_WARN_PROGRAMFOLDER_NOTWRITABLE);
02555 
02556         if (idMessage!=0)
02557         {
02558             if (bForeground)
02559                 idMessage = idMessage+1;        // NOTE! Message IDs must be interleaved correctly!
02560             ErrorInfo error;
02561             error.ErrorMsg = idMessage;
02562             error.Button[0] = _R(IDS_CONTINUE);
02563             INT32 ret = InformWarning(&error);
02564         }
02565         else if (bForeground)
02566         {
02567 //          String_256 strError(_T(""));
02568 //          strError.Format(_T("Failed to contact xara.com or failed to read update information (0x%08x)."),e.Error());
02569 //          ::MessageBox(NULL, strError, PRODUCT_NAME, MB_OK);
02570             ErrorInfo error;
02571             error.ErrorMsg = _R(IDE_FAILEDTOUPDATEHANDS);
02572             error.Button[0] = _R(IDS_CONTINUE);
02573             INT32 ret = InformWarning(&error);
02574         }
02575         return FALSE;
02576     }
02577 #endif
02578     return TRUE;
02579 }
02580 
02581 
02582 /****************************************************************************
02583 
02584 >   String_256 OpUpdate::GetUpdateURL()
02585 
02586     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02587     Created:    14/4/2004
02588     Purpose:    returns the Update URL. 
02589     Notes:      The update URL is scoped to the Major product version
02590                 to minimise the number of update folders required
02591 
02592 ****************************************************************************/
02593 
02594 String_256 OpUpdate::GetUpdateURL()
02595 {
02596 PORTNOTETRACE("other","OpUpdate::GetUpdateURL() - do nothing");
02597 #ifndef EXCLUDE_FROM_XARALX
02598     String_256 sTemp;
02599     sTemp = IndexBaseURL;
02600     sTemp += PRODUCT_RETAIL_VERSION_NO;
02601     LPCTSTR szURL = sTemp;
02602     String_256 strURLEnc(szURL);
02603     DWORD dwLen = camStrlen(szURL) * 3; // max buffer length for encoded URL
02604 
02605     // Since the version may include illegal URL characters, canonicalise it.
02606     InternetCanonicalizeUrl(szURL, strURLEnc.GetBuffer(dwLen), &dwLen, 0);
02607     strURLEnc.ReleaseBuffer();
02608 
02609     return strURLEnc;
02610 #else
02611     return String_256(_T(""));
02612 #endif
02613 }
02614 
02615 /****************************************************************************
02616 
02617     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02618     Created:    11/5/2004
02619     Purpose:    Constructor for OpRegister
02620 
02621 ****************************************************************************/
02622 
02623 OpRegister::OpRegister(): Operation()
02624 {}
02625 
02626 BOOL    OpRegister::RegisteredOnline = FALSE;
02627 PORTNOTE("other","OpRegister removed use of DATE type");
02628 #ifndef EXCLUDE_FROM_XARALX
02629 DATE    OpRegister::LastCheck = (DATE)1.0;
02630 #endif
02631 INT32       OpRegister::DaysBetweenAutoChecks = 5 ;
02632 
02633 /****************************************************************************
02634 
02635     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02636     Created:    11/5/2004
02637     Inputs:     (BOOL)OpParam->Param1 - User requested registration 
02638     Purpose:    Either the user requested to register or it is an auto-check.
02639 
02640 ****************************************************************************/
02641 
02642 void OpRegister::DoWithParam(OpDescriptor*, OpParam* pOpParam)
02643 {
02644 PORTNOTETRACE("other","OpRegister::DoWithParam - do nothing");
02645 #ifndef EXCLUDE_FROM_XARALX
02646     BOOL Requested = (BOOL)pOpParam->Param1;
02647     if(Requested)
02648     {
02649         if(RegisterOnline())
02650         {
02651             put_HasRegistered(TRUE);
02652         }
02653     }
02654     else
02655     {
02656         // an auto-check only prompts the user if it's long enough since we last nagged them
02657         if(!get_HasRegistered())
02658         {
02659             COleDateTimeSpan ts = COleDateTime::GetCurrentTime() - COleDateTime(LastCheck);
02660             INT32 DaysSinceLastCheck = ts.GetTotalDays();
02661             if( DaysSinceLastCheck >= DaysBetweenAutoChecks )
02662             {
02663                 CRegisterDialog RegisterDlg;
02664                 switch(RegisterDlg.DoModal())
02665                 {
02666                 case IDOK:
02667                     if(RegisterOnline())
02668                     {
02669                         put_HasRegistered(TRUE);
02670                     }
02671                     break;
02672                 case IDCANCEL:
02673                 default:
02674                     {
02675                         LastCheck = COleDateTime::GetCurrentTime().m_dt;
02676                     }
02677                     break;
02678                 }
02679             }
02680         }
02681     }
02682 #endif
02683 }
02684 
02685 /****************************************************************************
02686 
02687     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02688     Created:    11/5/2004
02689     Purpose:    The default Register operation called from the menu
02690 
02691 ****************************************************************************/
02692 
02693 void OpRegister::Do(OpDescriptor* od)
02694 {
02695     OpParam temp((INT32) TRUE, (void *)NULL);
02696     this->DoWithParam(od, &temp);
02697 }
02698 
02699 /****************************************************************************
02700 
02701     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02702     Created:    11/5/2004
02703     Purpose:    Register an OpDescriptor
02704 
02705 ****************************************************************************/
02706 
02707 BOOL OpRegister::Init()
02708 {
02709 PORTNOTETRACE("other","OpRegister::Init - do nothing");
02710 #ifndef EXCLUDE_FROM_XARALX
02711     if (! 
02712         RegisterOpDescriptor(
02713             0, 
02714             _R(IDS_REGISTER_MENUTEXT),
02715             CC_RUNTIME_CLASS(OpRegister), 
02716             OPTOKEN_REGISTER,
02717             OpRegister::GetState
02718         )
02719     )
02720     {
02721         return FALSE;
02722     }
02723     if (!Camelot.DeclareSection(TEXT("Register"), 2)    
02724         || !Camelot.DeclarePref(TEXT("Register"), TEXT("LastCheck"), &LastCheck)
02725         )
02726     {
02727         return FALSE;
02728     }
02729 #endif
02730 
02731     return TRUE;
02732 }
02733 
02734 /****************************************************************************
02735 
02736     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02737     Created:    11/5/2004
02738     Purpose:    returns the serial number stored in the registry
02739 
02740 ****************************************************************************/
02741 
02742 String_256 OpRegister::GetSerialNumber()
02743 {
02744     // We now use a registry key to hold serial number data, so use that if available. If not then
02745     // display nothing.
02746     String_256      serialNumber = "";
02747 
02748 PORTNOTETRACE("other","OpRegister::getSerialNumber - do nothing");
02749 #ifndef EXCLUDE_FROM_XARALX
02750 
02751     HKEY        hKey = NULL;
02752     INT32           i;
02753     char        unlockCode[32];
02754     DWORD       dwType = REG_SZ;
02755     DWORD       dwSize = sizeof(unlockCode);
02756 
02757     // Initialise unlock code buffer.
02758     for(i=0;i<32;i++)
02759     {
02760         unlockCode[i] = NULL;
02761     }
02762 
02763     // Open the key.
02764     hKey = OpenRegKey(HKEY_CLASSES_ROOT,SERIALNO_REGPATH);
02765     if(hKey != NULL)
02766     {
02767         GetRegValue(hKey,"ulc",&dwType,unlockCode,&dwSize);
02768 
02769         serialNumber = unlockCode;
02770 
02771         // Close the key.
02772         RegCloseKey(hKey);
02773     }
02774 #endif
02775 
02776     return serialNumber;
02777 }
02778 
02779 
02780 /****************************************************************************
02781 
02782     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02783     Created:    18/Aug/2005
02784     Purpose:    Read registry value to find out if the user has registered. This
02785                 is no longer a Pref but stored with the serial number key so that 
02786                 it persists when the product is uninstalled
02787 
02788 ****************************************************************************/
02789 
02790 BOOL OpRegister::get_HasRegistered()
02791 {
02792 PORTNOTETRACE("other","OpRegister::get_HasRegistered - do nothing - always registered?");
02793 #ifndef EXCLUDE_FROM_XARALX
02794     // Open the key.
02795     HKEY    hKey = OpenRegKey(HKEY_CLASSES_ROOT,SERIALNO_REGPATH);
02796     BOOL    bRegistered = GetRegBool(hKey,TEXT("HasRegistered"));
02797     CloseRegKey(hKey);
02798     return bRegistered;
02799 #else
02800     return TRUE;
02801 #endif
02802 }
02803 
02804 /****************************************************************************
02805 
02806     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02807     Created:    18/Aug/2005
02808     Purpose:    Write registry value to find out if the user has registered. 
02809 
02810 ****************************************************************************/
02811 
02812 void OpRegister::put_HasRegistered(BOOL bHasRegistered)
02813 {
02814 PORTNOTETRACE("other","OpRegister::get_HasRegistered - do nothing - always registered?");
02815 #ifndef EXCLUDE_FROM_XARALX
02816     HKEY    hKey = OpenRegKey(HKEY_CLASSES_ROOT,SERIALNO_REGPATH);
02817     SetRegBool(hKey, TEXT("HasRegistered"), bHasRegistered);
02818     CloseRegKey(hKey);
02819 #endif
02820 }
02821 
02822 
02823 
02824 /****************************************************************************
02825 
02826     Author:     Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
02827     Created:    11/5/2004
02828     Purpose:    Creates a StratusClient to actually perform online registration
02829 
02830 ****************************************************************************/
02831 
02832 BOOL OpRegister::RegisterOnline()
02833 {
02834 PORTNOTETRACE("other","OpRegister::RegsiterOnline - do nothing");
02835 #ifndef EXCLUDE_FROM_XARALX
02836     BOOL RegSuccess = FALSE; 
02837     IStratusClient2Ptr pStratusClient;
02838     HRESULT hr = pStratusClient.CreateInstance(__uuidof(StratusClient_1_0_2)) ;
02839     ERROR2IF(FAILED(hr), FALSE, "Stratus Client didn't create") ;
02840 
02841     pStratusClient->put_ParentWindow((INT32)(GetMainFrame()->GetSafeHwnd()));
02842     pStratusClient->put_SerialNumber(_bstr_t(OpRegister::GetSerialNumber())) ;
02843     pStratusClient->put_RegistryKey(_bstr_t(_T("\\" PRODUCT_REGISTRYKEY_FULLPATH "Connect")));
02844     pStratusClient->put_HintText(_bstr_t(_T("")));// need to blank the default
02845     pStratusClient->put_ShowStorePassword(FALSE) ;
02846     pStratusClient->put_ConnectButtonText(_bstr_t(String_256((LPCSTR)_R(IDS_REGISTER_BUTTON))));
02847     pStratusClient->put_ConnectTitle(_bstr_t(String_256((LPCSTR)_R(IDS_REGISTER_TITLE))));
02848     pStratusClient->put_JoinTitle(_bstr_t(String_256((LPCSTR)_R(IDS_REGISTER_TITLE))));
02849     pStratusClient->put_ConnectText(_bstr_t(String_256((LPCSTR)_R(IDS_REGISTER_MAINTEXT))));
02850     pStratusClient->put_JoinText(_bstr_t(String_256((LPCSTR)_R(IDS_REGISTER_JOINTEXT))));
02851 
02852     try
02853     {
02854         // registration succeeds if the sign-in method is successfully invoked
02855         pStratusClient->SignIn((BSTR)NULL,(BSTR)NULL);
02856         RegSuccess = TRUE;
02857     }
02858     catch(_com_error e)
02859     {
02860         if (e.Error() != E_XM_CONNECTCANCELLED)
02861         {
02862             String_256 strError;
02863             strError.Format(String_256((LPCSTR)_R(IDS_REGISTER_CONNECTPROBLEM)),e.Error());
02864             ::MessageBox(NULL, strError, PRODUCT_NAME, MB_OK);
02865         }
02866     }
02867 
02868     if(RegSuccess)
02869         ::MessageBox(NULL, String_256((LPCSTR)_R(IDS_REGISTER_REGSUCCESS)), PRODUCT_NAME, MB_OK);
02870 
02871     return RegSuccess;
02872 #else
02873     return TRUE;
02874 #endif
02875 }
02876 
02877 
02878 #endif

Generated on Sat Nov 10 03:45:42 2007 for Camelot by  doxygen 1.4.4