cpyact.cpp

Go to the documentation of this file.
00001 // $Id: cpyact.cpp 1282 2006-06-09 09:46:49Z alex $
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 // Implementation of CopyObjectsToClipboardAction
00099 /*
00100 */
00101 
00102 #include "camtypes.h"
00103 #include "cpyact.h"
00104 #include "clipint.h" // Internal clipboard
00105 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 #include "ophist.h"
00107 
00108 DECLARE_SOURCE($Revision: 1282 $);
00109 
00110 CC_IMPLEMENT_DYNCREATE( CopyObjectsToClipboardAction, Action )
00111 
00112 
00113 #define new CAM_DEBUG_NEW
00114 
00115 /********************************************************************************************
00116 
00117 >   CopyObjectsToClipboardAction::CopyObjectsToClipboardAction()
00118 
00119     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00120     Created:    14/9/93
00121     Inputs:     -
00122     Outputs:    -
00123     Returns:    -
00124     Purpose:    CopyObjectsToClipboardAction constructor
00125     Errors:     -
00126     SeeAlso:    -
00127 
00128 ********************************************************************************************/
00129     
00130 CopyObjectsToClipboardAction::CopyObjectsToClipboardAction()
00131 {
00132 }
00133 
00134 /********************************************************************************************
00135 
00136 >   CopyObjectsToClipboardAction::~CopyObjectsToClipboardAction()
00137 
00138     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00139     Created:    14/9/93
00140     Inputs:     -
00141     Outputs:    -
00142     Returns:    -
00143     Purpose:    CopyObjectsToClipboardAction destructor
00144     Errors:     -
00145     SeeAlso:    -
00146 
00147 ********************************************************************************************/
00148    
00149              
00150 CopyObjectsToClipboardAction::~CopyObjectsToClipboardAction() 
00151 {
00152 }   
00153 
00154 
00155 /********************************************************************************************
00156 
00157 >   virtual ActionCode CopyObjectsToClipboardAction::Execute()
00158 
00159     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00160     Created:    16/8/93
00161     Inputs:     -
00162     Outputs:    ActionCode indicating if the action was successfully executed or not
00163     Returns:    -
00164     Purpose:    Executes the CopyObjectsToClipboardAction which when executed on an undo list
00165                 does nothing except spawn a redo  CopyObjectsToClipboardAction
00166 
00167                 When executed on a redo action list copies all objects to the clipboard
00168     Errors:     -
00169     SeeAlso:    -
00170     
00171     
00172 ********************************************************************************************/
00173  
00174 ActionCode CopyObjectsToClipboardAction::Execute()
00175 {  
00176     ActionCode ActCode;  
00177     
00178     // Create the twin action 
00179     CopyObjectsToClipboardAction* CpyObjAct; 
00180 
00181     if ( (ActCode = CopyObjectsToClipboardAction::Init(pOperation, 
00182                                               pOppositeActLst, 
00183                                               NodeRange, 
00184                                               (Action**)(&CpyObjAct)))
00185         != AC_FAIL)  
00186     {   
00187         // Is this a redo action ?
00188         if  (pOppositeActLst == pOperation->GetUndoActionList())
00189         {
00190             BOOL CopiedOK; 
00191         
00192             // After the operation ends we will need to inform all DocComponents in the clipboard
00193             // of the outcome.
00194             pOperation->InformDocComponentsOfOperationsOutcome(InternalClipboard::Instance()); 
00195 
00196             // Inform all DocComponents in the clipboard that a copy is about to take place
00197             BOOL ok;
00198             CALL_WITH_FAIL(InternalClipboard::Instance()->StartComponentCopy(), pOperation, ok)
00199             if (!ok)
00200             {
00201                 // Start Component copy has failed so abort operation
00202                 // Note that AbortComponentCopy will get called in the ops end method
00203                 return AC_FAIL;
00204             } 
00205 
00206 
00207             // Copy the selection to the clipboard
00208             CALL_WITH_FAIL(InternalClipboard::CopyObjects(NodeRange, pOperation), pOperation, CopiedOK)
00209 
00210             if (!CopiedOK)
00211             {
00212                 return AC_FAIL; 
00213             }
00214 
00215             // Now try and copy accross the component data
00216             CALL_WITH_FAIL(InternalClipboard::CopyComponentData(GetWorkingDoc()),
00217                                                                 pOperation,
00218                                                                 CopiedOK)
00219             if (!CopiedOK) return AC_FAIL; 
00220         }
00221         // else do nothing
00222     };  
00223                     
00224     return ActCode;
00225 }     
00226 
00227 
00228 /********************************************************************************************
00229 
00230 >   static ActionCode CopyObjectsToClipboardAction::Init(Operation* const pOp, 
00231                                                 ActionList* pActionList, 
00232                                                 Range NodeRange, 
00233                                                 Action** NewAction) 
00234     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00235     Created:    14/9/93  
00236     
00237     Inputs:     pOp: The operation to which the action should be added
00238                 
00239                 pActionList: The action list in the operation object
00240                 
00241                              
00242                 NodeRange:   The range of nodes to copy 
00243 
00244 
00245     Outputs:    NewAction:   A pointer to the action if it could be allocated. 
00246 
00247     Returns:    AC_FAIL:     There was not enough room in the operation history for the 
00248                              action and the user did not wish to continue. Usually 
00249                              End() should be called in this situation. 
00250                          
00251                 AC_NORECORD: There was not enough room in the operation history for
00252                              the action, but the user requested that he wished to 
00253                              continue without undo. 
00254                 
00255                 AC_OK      : The action was successfully initialised and added to the 
00256                              operation. 
00257                          
00258                            
00259     Purpose:    To check that there is sufficient room for the action in the operation
00260                 history, and if there is, then to add the action to the operations 
00261                 action list. 
00262                 
00263                 The function calls the Action::Init function passing the runtime class 
00264                 of a CopyObjectsToClipboardAction.
00265     Errors:     -
00266     SeeAlso:    Action::Init
00267 
00268 ********************************************************************************************/
00269 
00270 ActionCode CopyObjectsToClipboardAction::Init(Operation* const pOp, 
00271                                      ActionList* pActionList, 
00272                                      Range NodeRange, 
00273                                      Action** NewAction) 
00274 
00275 { 
00276     ActionCode Ac = (Action::Init(pOp,
00277                                   pActionList,
00278                                   sizeof(CopyObjectsToClipboardAction),
00279                                   CC_RUNTIME_CLASS(CopyObjectsToClipboardAction), 
00280                                   NewAction));   
00281                            
00282     if (Ac != AC_FAIL)
00283         if (*NewAction != NULL)  
00284         {
00285             // Store the range and transform in the action 
00286             ((CopyObjectsToClipboardAction*)(*NewAction))->NodeRange = NodeRange;
00287         }
00288                 
00289     return (Ac); 
00290 } 
00291 

Generated on Sat Nov 10 03:44:55 2007 for Camelot by  doxygen 1.4.4