textacts.cpp

Go to the documentation of this file.
00001 // $Id: textacts.cpp 751 2006-03-31 15:43: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 // Actions used by text operations
00099 
00100 /*
00101 */
00102 
00103 #include "camtypes.h"
00104 #include "textacts.h"
00105 
00106 // Code headers
00107 #include "nodetext.h"
00108 #include "ndtxtpth.h"
00109 
00110 // Resource headers
00111 
00112 
00113 DECLARE_SOURCE("$Revision: 751 $");
00114 
00115 CC_IMPLEMENT_DYNCREATE(BaseTextAction, Action)
00116 CC_IMPLEMENT_DYNCREATE(StoreCharCodeAction, BaseTextAction)
00117 CC_IMPLEMENT_DYNCREATE(StoreKernCodeAction, BaseTextAction)
00118 CC_IMPLEMENT_DYNCREATE(ReversePathAction, BaseTextAction)
00119 CC_IMPLEMENT_DYNCREATE(MatrixRemoveFromPathAction, BaseTextAction)
00120 CC_IMPLEMENT_DYNCREATE(MatrixFitToPathAction, BaseTextAction)
00121 
00122 #define new CAM_DEBUG_NEW
00123 
00124 
00125 
00126 /********************************************************************************************
00127 >   BaseTextAction::BaseTextAction()
00128 
00129     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00130     Created:    15/5/95
00131     Purpose:    Constructor - initialises the member variables
00132 ********************************************************************************************/
00133 BaseTextAction::BaseTextAction()
00134 {
00135     pStory = NULL;
00136 }
00137 
00138 
00139 
00141 // StoreCharCodeAction
00142 
00143 /********************************************************************************************
00144 >   StoreCharCodeAction::StoreCharCodeAction()
00145 
00146     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00147     Created:    15/5/95
00148     Purpose:    Constructor - initialises the member variables
00149 ********************************************************************************************/
00150 StoreCharCodeAction::StoreCharCodeAction()
00151 {
00152     pChar = NULL;
00153     CharCode = 0;
00154 }
00155 
00156 
00157 /********************************************************************************************
00158 >   StoreCharCodeAction::~StoreCharCodeAction()
00159 
00160     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00161     Created:    15/5/95
00162     Purpose:    Destructor
00163 ********************************************************************************************/
00164 StoreCharCodeAction::~StoreCharCodeAction()
00165 {
00166 }
00167 
00168 
00169 /********************************************************************************************
00170 >   virtual ActionCode StoreCharCodeAction::Execute()
00171 
00172     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00173     Created:    15/5/95
00174     Purpose:    Called during undo/redo to restore a character code to a particular character
00175                 Inserts StoreCharCodeAction to restore the current character code then
00176                 sets it to the value in the action
00177 ********************************************************************************************/
00178 ActionCode StoreCharCodeAction::Execute()
00179 {
00180     // Check the member variables
00181     ERROR2IF(pStory == NULL, AC_FAIL, "The TextStory pointer is NULL");
00182     ERROR2IF(pChar == NULL, AC_FAIL, "TextChar pointer is NULL");
00183 
00184     // Insert an action to restore the character code to its current value on redo
00185     ActionCode ActCode;
00186     ActCode = StoreCharCodeAction::Init(pOperation, pOppositeActLst, pStory, pChar);
00187 
00188     // Now set the character code the old value
00189     if (ActCode != AC_FAIL)
00190         pChar->SetUnicodeValue(CharCode);
00191 
00192     return ActCode;
00193 }
00194 
00195 
00196 /********************************************************************************************
00197 >   static ActionCode StoreCharCodeAction::Init(Operation* pOp,
00198                                                 ActionList* pActionList,
00199                                                 TextStory* pTextStory,
00200                                                 TextChar* pTextChar)
00201     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00202     Created:    15/5/95
00203     Inputs:     pOp - points to the operation to add the action to
00204                 pActionList - points to the action list to add the action to
00205                 pTextStory - points to the story containing pChar
00206                 pTextChar - points to the character to store the character code of
00207     Outputs:    Constructs a StoreCharCodeAction, initialises it and inserts in into the action list
00208     Returns:    An action code depending on the success of this function
00209     Purpose:    Called to constuct a StoreCharCodeAction, set it up and and insert it into
00210                 an operations action list
00211     Errors:     Checks the parameters
00212 ********************************************************************************************/
00213 ActionCode StoreCharCodeAction::Init(Operation* pOp, ActionList* pActionList, TextStory* pTextStory, TextChar* pTextChar)
00214 {
00215     // Check the parameters
00216     ERROR2IF(pOp == NULL, AC_FAIL, "The operation pointer is NULL");
00217     ERROR2IF(pActionList == NULL, AC_FAIL, "The action list pointer is NULL");
00218     ERROR2IF(pTextStory == NULL, AC_FAIL, "The TextStory pointer is NULL");
00219     ERROR2IF(pTextChar == NULL, AC_FAIL, "TextChar pointer is NULL");
00220 
00221     // Create a new action and insert it in the action list
00222     UINT32 ActSize = sizeof(StoreCharCodeAction);
00223     StoreCharCodeAction* pNewAction = NULL;
00224     ActionCode Ac = Action::Init( pOp, pActionList, ActSize, CC_RUNTIME_CLASS(StoreCharCodeAction), (Action**)&pNewAction);
00225 
00226     // Set the members of the new action
00227     if ((Ac == AC_OK) && (pNewAction != NULL))
00228     {
00229         pNewAction->pStory = pTextStory;
00230         pNewAction->pChar = pTextChar;
00231         pNewAction->CharCode = pTextChar->GetUnicodeValue();
00232     }
00233 
00234     return Ac;
00235 }
00236 
00237 
00238 /********************************************************************************************
00239 >   static BOOL StoreCharCodeAction::DoStoreCharacterCode(Operation* pOp,
00240                                                           ActionList* pActionList,
00241                                                           TextChar* pTextChar)
00242     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00243     Created:    15/5/95
00244     Inputs:     pOp - points to the operation to add the action to
00245                 pActionList - points to the action list to add the action to
00246                 pTextChar - points to the character to store the character code of
00247     Outputs:    Adds an action to the operations action list
00248     Returns:    TRUE/FALSE for success/failure
00249     Purpose:    Before changing a characters UniCode value in your op, call this function to
00250                 store the characters current value so it is restored on undo
00251     Errors:     Checks on parameters and structure of TextStory
00252 ********************************************************************************************/
00253 BOOL StoreCharCodeAction::DoStoreCharacterCode( Operation* pOp, ActionList* pActionList, TextChar* pTextChar)
00254 {
00255     // Check the parameters
00256     ERROR2IF(pOp == NULL, AC_FAIL, "The operation pointer is NULL");
00257     ERROR2IF(pActionList == NULL, AC_FAIL, "The action list pointer is NULL");
00258     ERROR2IF(pTextChar == NULL, AC_FAIL, "TextChar pointer is NULL");
00259 
00260     // Get a pointer to the characters parent TextStory
00261     TextStory* pParentStory = (TextStory*)pTextChar->FindParent(CC_RUNTIME_CLASS(TextStory));
00262     ERROR2IF(pParentStory == NULL, AC_FAIL, "TextChar has no parent TextStory");
00263 
00264     // Insert the action
00265     ActionCode Ac;
00266     Ac = Init(pOp, pActionList, pParentStory, pTextChar);
00267 
00268     return (Ac != AC_FAIL);
00269 }
00270 
00271 
00272 
00274 // StoreKernCodeAction
00275 
00276 /********************************************************************************************
00277 >   StoreKernCodeAction::StoreKernCodeAction()
00278 
00279     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00280     Created:    15/5/95
00281     Purpose:    Constructor - initialises the member variables
00282 ********************************************************************************************/
00283 StoreKernCodeAction::StoreKernCodeAction()
00284 {
00285     pKernCode = NULL;
00286     KernValue = DocCoord(0,0);
00287 }
00288 
00289 
00290 /********************************************************************************************
00291 >   StoreKernCodeAction::~StoreKernCodeAction()
00292 
00293     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00294     Created:    15/5/95
00295     Purpose:    Destructor
00296 ********************************************************************************************/
00297 StoreKernCodeAction::~StoreKernCodeAction()
00298 {
00299 }
00300 
00301 
00302 /********************************************************************************************
00303 >   virtual ActionCode StoreKernCodeAction::Execute()
00304 
00305     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00306     Created:    15/5/95
00307     Purpose:    Called during undo/redo to restore a kern code value
00308                 Inserts a StoreKernCodeAction to restore the current kern value then
00309                 sets it to the value in the action
00310 ********************************************************************************************/
00311 ActionCode StoreKernCodeAction::Execute()
00312 {
00313     // Check the member variables
00314     ERROR2IF(pStory == NULL, AC_FAIL, "The TextStory pointer is NULL");
00315     ERROR2IF(pKernCode == NULL, AC_FAIL, "TextChar pointer is NULL");
00316 
00317     // Insert an action to restore the kern code to its current value on redo
00318     ActionCode ActCode;
00319     ActCode = StoreKernCodeAction::Init(pOperation, pOppositeActLst, pStory, pKernCode);
00320 
00321     // Now set the kern code the old value
00322     if (ActCode != AC_FAIL)
00323         pKernCode->SetValue(KernValue);
00324 
00325     return ActCode;
00326 }
00327 
00328 
00329 /********************************************************************************************
00330 >   static ActionCode StoreKernCodeAction::Init(Operation* pOp,
00331                                                 ActionList* pActionList,
00332                                                 TextStory* pTextStory,
00333                                                 KernCode* pKern)
00334     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00335     Created:    15/5/95
00336     Inputs:     pOp - points to the operation to add the action to
00337                 pActionList - points to the action list to add the action to
00338                 pTextStory - points to the story containing pChar
00339                 pKernCode - points to the kern code to store the value of
00340     Outputs:    Constructs a StoreKernCodeAction, initialises it and inserts in into the action list
00341     Returns:    An action code depending on the success of this function
00342     Purpose:    Called to constuct a StoreKernCodeAction, set it up and and insert it into
00343                 an operations action list
00344     Errors:     Checks the parameters
00345 ********************************************************************************************/
00346 ActionCode StoreKernCodeAction::Init(Operation* pOp, ActionList* pActionList, TextStory* pTextStory, KernCode* pKern)
00347 {
00348     // Check the parameters
00349     ERROR2IF(pOp == NULL, AC_FAIL, "The operation pointer is NULL");
00350     ERROR2IF(pActionList == NULL, AC_FAIL, "The action list pointer is NULL");
00351     ERROR2IF(pTextStory == NULL, AC_FAIL, "The TextStory pointer is NULL");
00352     ERROR2IF(pKern == NULL, AC_FAIL, "KernCode pointer is NULL");
00353 
00354     // Create a new action and insert it in the action list
00355     UINT32 ActSize = sizeof(StoreKernCodeAction);
00356     StoreKernCodeAction* pNewAction = NULL;
00357     ActionCode Ac = Action::Init( pOp, pActionList, ActSize, CC_RUNTIME_CLASS(StoreKernCodeAction), (Action**)&pNewAction);
00358 
00359     // Set the members of the new action
00360     if ((Ac == AC_OK) && (pNewAction != NULL))
00361     {
00362         pNewAction->pStory = pTextStory;
00363         pNewAction->pKernCode = pKern;
00364         pNewAction->KernValue = pKern->GetValue();
00365     }
00366 
00367     return Ac;
00368 }
00369 
00370 
00371 /********************************************************************************************
00372 >   static BOOL StoreKernCodeAction::DoStoreKernValue(Operation* pOp,
00373                                                       ActionList* pActionList,
00374                                                       KernCode* pKern)
00375     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00376     Created:    15/5/95
00377     Inputs:     pOp - points to the operation to add the action to
00378                 pActionList - points to the action list to add the action to
00379                 pKern - points to the kern code to store the value of
00380     Outputs:    Adds an action to the operations action list
00381     Returns:    TRUE/FALSE for success/failure
00382     Purpose:    Before changing a kern code value in your op, call this function to store the
00383                 current value so it is restored on undo
00384     Errors:     Checks on parameters and structure of TextStory
00385 ********************************************************************************************/
00386 BOOL StoreKernCodeAction::DoStoreKernValue( Operation* pOp, ActionList* pActionList, KernCode* pKern)
00387 {
00388     // Check the parameters
00389     ERROR2IF(pOp == NULL, AC_FAIL, "The operation pointer is NULL");
00390     ERROR2IF(pActionList == NULL, AC_FAIL, "The action list pointer is NULL");
00391     ERROR2IF(pKern == NULL, AC_FAIL, "TextChar pointer is NULL");
00392 
00393     // Get a pointer to the characters parent TextStory
00394     TextStory* pParentStory = (TextStory*)pKern->FindParent(CC_RUNTIME_CLASS(TextStory));
00395     ERROR2IF(pParentStory == NULL, AC_FAIL, "TextChar has no parent TextStory");
00396 
00397     // Insert the action
00398     ActionCode Ac;
00399     Ac = Init(pOp, pActionList, pParentStory, pKern);
00400 
00401     return (Ac != AC_FAIL);
00402 }
00403 
00404 
00405 
00407 // ReversePathAction
00408 
00409 /********************************************************************************************
00410 >   ReversePathAction::ReversePathAction()
00411 
00412     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00413     Created:    16/5/95
00414     Purpose:    Constructor - initialises the member variables
00415 ********************************************************************************************/
00416 ReversePathAction::ReversePathAction()
00417 {
00418 }
00419 
00420 
00421 /********************************************************************************************
00422 >   ReversePathAction::~ReversePathAction()
00423 
00424     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00425     Created:    16/5/95
00426     Purpose:    Destructor
00427 ********************************************************************************************/
00428 ReversePathAction::~ReversePathAction()
00429 {
00430 }
00431 
00432 
00433 /********************************************************************************************
00434 >   virtual ActionCode ReversePathAction::Execute()
00435 
00436     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00437     Created:    16/5/95
00438     Purpose:    Called during undo/redo to reverse the path inside a TextStory
00439                 Inserts a similar action into the opposite action list then reverses the path
00440 ********************************************************************************************/
00441 ActionCode ReversePathAction::Execute()
00442 {
00443     // Check the member variables
00444     ERROR2IF(pStory == NULL, AC_FAIL, "The TextStory pointer is NULL");
00445     ERROR2IF(pOperation == NULL, AC_FAIL, "The operation pointer is NULL(!)");
00446 
00447     // Insert an action to reverse the path again on redo
00448     ActionCode ActCode;
00449     ActCode = ReversePathAction::Init(pOperation, pOppositeActLst, pStory);
00450 
00451     // Now reverse the path
00452     if (ActCode != AC_FAIL)
00453         pStory->ReverseTextOnPath();
00454 
00455     return ActCode;
00456 }
00457 
00458 
00459 /********************************************************************************************
00460 >   static ActionCode ReversePathAction::Init(Operation* pOp,
00461                                                 ActionList* pActionList,
00462                                                 TextStory* pTextStory)
00463     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00464     Created:    16/5/95
00465     Inputs:     pOp - points to the operation to add the action to
00466                 pActionList - points to the action list to add the action to
00467                 pTextStory - points to the story containing pChar
00468     Outputs:    Constructs a ReversePathAction, initialises it and inserts in into the action list
00469     Returns:    An action code depending on the success of this function
00470     Purpose:    Called to constuct a ReversePathAction, set it up and and insert it into
00471                 an operations action list
00472     Errors:     Checks the parameters
00473 ********************************************************************************************/
00474 ActionCode ReversePathAction::Init(Operation* pOp, ActionList* pActionList, TextStory* pTextStory)
00475 {
00476     // Check the parameters
00477     ERROR2IF(pOp == NULL, AC_FAIL, "The operation pointer is NULL");
00478     ERROR2IF(pActionList == NULL, AC_FAIL, "The action list pointer is NULL");
00479     ERROR2IF(pTextStory == NULL, AC_FAIL, "The TextStory pointer is NULL");
00480 
00481     // Create a new action and insert it in the action list
00482     UINT32 ActSize = sizeof(ReversePathAction);
00483     ReversePathAction* pNewAction = NULL;
00484     ActionCode Ac = Action::Init( pOp, pActionList, ActSize, CC_RUNTIME_CLASS(ReversePathAction), (Action**)&pNewAction);
00485 
00486     // Set the members of the new action
00487     if ((Ac == AC_OK) && (pNewAction != NULL))
00488         pNewAction->pStory = pTextStory;
00489 
00490     return Ac;
00491 }
00492 
00493 
00494 /********************************************************************************************
00495 >   static BOOL ReversePathAction::DoReversePath(Operation* pOp,
00496                                                  ActionList* pActionList,
00497                                                  TextStory* pTextStory)
00498     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00499     Created:    16/5/95
00500     Inputs:     pOp - points to the operation to add the action to
00501                 pActionList - points to the action list to add the action to
00502                 pTextStory - points to the TextStory to reverse the path in
00503     Outputs:    Adds an action to the operations action list
00504     Returns:    TRUE/FALSE for success/failure
00505     Purpose:    Call this function to reverse the "Text on a path" path in a your op.  It
00506                 inserts an action to undo the change, then reverses the path for you
00507     Errors:     Checks on parameters and structure of TextStory
00508 ********************************************************************************************/
00509 BOOL ReversePathAction::DoReversePath(Operation* pOp, ActionList* pActionList, TextStory* pTextStory)
00510 {
00511     // Check the parameters
00512     ERROR2IF(pOp == NULL, FALSE, "The operation pointer is NULL");
00513     ERROR2IF(pActionList == NULL, FALSE, "The action list pointer is NULL");
00514     ERROR2IF(pTextStory == NULL, FALSE, "The TextStory pointer is NULL");
00515     ERROR3IF(pTextStory->GetTextPath() == NULL, "TextStory was not on a path");
00516 
00517     // Insert an action to restore the path on undo (just reverse it back)
00518     ActionCode ActCode;
00519     ActCode = ReversePathAction::Init(pOp, pActionList, pTextStory);
00520 
00521     // Now reverse the path
00522     if (ActCode != AC_FAIL)
00523         pTextStory->ReverseTextOnPath();
00524 
00525     return (ActCode != AC_FAIL);
00526 }
00527 
00528 
00529 
00531 // MatrixFitToPathAction
00532 
00533 /********************************************************************************************
00534 >   MatrixFitToPathAction::MatrixFitToPathAction()
00535 
00536     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00537     Created:    19/5/95
00538     Purpose:    Constructor - initialises the member variables
00539 ********************************************************************************************/
00540 MatrixFitToPathAction::MatrixFitToPathAction()
00541 {
00542 }
00543 
00544 
00545 /********************************************************************************************
00546 >   MatrixFitToPathAction::~MatrixFitToPathAction()
00547 
00548     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00549     Created:    19/5/95
00550     Purpose:    Destructor
00551 ********************************************************************************************/
00552 MatrixFitToPathAction::~MatrixFitToPathAction()
00553 {
00554 }
00555 
00556 
00557 /********************************************************************************************
00558 >   virtual ActionCode MatrixFitToPathAction::Execute()
00559 
00560     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00561     Created:    19/5/95
00562     Purpose:    Called during undo/redo to restore the TextStory matrices
00563                 Inserts an opposite action into the opposite action list then changes the
00564                 matrices
00565 ********************************************************************************************/
00566 ActionCode MatrixFitToPathAction::Execute()
00567 {
00568     // Check the member variables
00569     ERROR2IF(pStory == NULL, AC_FAIL, "The TextStory pointer is NULL");
00570     ERROR2IF(pOperation == NULL, AC_FAIL, "The operation pointer is NULL(!)");
00571 
00572     // Insert an action to reverse the path again on redo
00573     ActionCode ActCode;
00574     ActCode = MatrixRemoveFromPathAction::Init(pOperation, pOppositeActLst, pStory);
00575 
00576     // Now set the matrices
00577     if (ActCode != AC_FAIL)
00578         pStory->MatrixFitToPath();
00579 
00580     return ActCode;
00581 }
00582 
00583 
00584 /********************************************************************************************
00585 >   static ActionCode MatrixFitToPathAction::Init(Operation* pOp,
00586                                                 ActionList* pActionList,
00587                                                 TextStory* pTextStory)
00588     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00589     Created:    19/5/95
00590     Inputs:     pOp - points to the operation to add the action to
00591                 pActionList - points to the action list to add the action to
00592                 pTextStory - points to the story containing pChar
00593     Outputs:    Constructs a MatrixFitToPathAction, initialises it and inserts in into the action list
00594     Returns:    An action code depending on the success of this function
00595     Purpose:    Called to constuct a MatrixFitToPathAction, set it up and and insert it into
00596                 an operations action list
00597     Errors:     Checks the parameters
00598 ********************************************************************************************/
00599 ActionCode MatrixFitToPathAction::Init(Operation* pOp, ActionList* pActionList, TextStory* pTextStory)
00600 {
00601     // Check the parameters
00602     ERROR2IF(pOp == NULL, AC_FAIL, "The operation pointer is NULL");
00603     ERROR2IF(pActionList == NULL, AC_FAIL, "The action list pointer is NULL");
00604     ERROR2IF(pTextStory == NULL, AC_FAIL, "The TextStory pointer is NULL");
00605 
00606     // Create a new action and insert it in the action list
00607     UINT32 ActSize = sizeof(MatrixFitToPathAction);
00608     MatrixFitToPathAction* pNewAction = NULL;
00609     ActionCode Ac = Action::Init( pOp, pActionList, ActSize, CC_RUNTIME_CLASS(MatrixFitToPathAction), (Action**)&pNewAction);
00610 
00611     // Set the members of the new action
00612     if ((Ac == AC_OK) && (pNewAction != NULL))
00613         pNewAction->pStory = pTextStory;
00614 
00615     return Ac;
00616 }
00617 
00618 
00619 /********************************************************************************************
00620 >   static BOOL MatrixFitToPathAction::DoMatrixRemoveFromPath(Operation* pOp,
00621                                                               ActionList* pActionList,
00622                                                               TextStory* pTextStory)
00623     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00624     Created:    19/5/95
00625     Inputs:     pOp - points to the operation to add the action to
00626                 pActionList - points to the action list to add the action to
00627                 pTextStory - points to the TextStory to reverse the path in
00628     Outputs:    Adds an action to the operations action list
00629     Returns:    TRUE/FALSE for success/failure
00630     Purpose:    Call this function when removing text from a path.  It sets the story matrix
00631                 to the character matrix and sets the character matrix to unity.  It also
00632                 inserts an action to reverse these changes.
00633     Errors:     Checks on parameters and structure of TextStory
00634 ********************************************************************************************/
00635 BOOL MatrixFitToPathAction::DoMatrixRemoveFromPath(Operation* pOp, ActionList* pActionList, TextStory* pTextStory)
00636 {
00637     // Check the parameters
00638     ERROR2IF(pOp == NULL, FALSE, "The operation pointer is NULL");
00639     ERROR2IF(pActionList == NULL, FALSE, "The action list pointer is NULL");
00640     ERROR2IF(pTextStory == NULL, FALSE, "The TextStory pointer is NULL");
00641 
00642     // Insert an action to restore matrices on undo 
00643     ActionCode ActCode;
00644     ActCode = MatrixFitToPathAction::Init(pOp, pActionList, pTextStory);
00645 
00646     // Now set the matrices
00647     if (ActCode != AC_FAIL)
00648         pTextStory->MatrixRemoveFromPath();
00649 
00650     return (ActCode != AC_FAIL);
00651 }
00652 
00653 
00654 
00656 // MatrixRemoveFromPathAction
00657 
00658 /********************************************************************************************
00659 >   MatrixRemoveFromPathAction::MatrixRemoveFromPathAction()
00660 
00661     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00662     Created:    19/5/95
00663     Purpose:    Constructor - initialises the member variables
00664 ********************************************************************************************/
00665 MatrixRemoveFromPathAction::MatrixRemoveFromPathAction()
00666 {
00667 }
00668 
00669 
00670 /********************************************************************************************
00671 >   MatrixRemoveFromPathAction::~MatrixRemoveFromPathAction()
00672 
00673     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00674     Created:    19/5/95
00675     Purpose:    Destructor
00676 ********************************************************************************************/
00677 MatrixRemoveFromPathAction::~MatrixRemoveFromPathAction()
00678 {
00679 }
00680 
00681 
00682 /********************************************************************************************
00683 >   virtual ActionCode MatrixRemoveFromPathAction::Execute()
00684 
00685     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00686     Created:    19/5/95
00687     Purpose:    Called during undo/redo to restore the TextStory matrices
00688                 Inserts an opposite action into the opposite action list then changes the
00689                 matrices
00690 ********************************************************************************************/
00691 ActionCode MatrixRemoveFromPathAction::Execute()
00692 {
00693     // Check the member variables
00694     ERROR2IF(pStory == NULL, AC_FAIL, "The TextStory pointer is NULL");
00695     ERROR2IF(pOperation == NULL, AC_FAIL, "The operation pointer is NULL(!)");
00696 
00697     // Insert an action to reverse the path again on redo
00698     ActionCode ActCode;
00699     ActCode = MatrixFitToPathAction::Init(pOperation, pOppositeActLst, pStory);
00700 
00701     // Now set the matrices
00702     if (ActCode != AC_FAIL)
00703         pStory->MatrixRemoveFromPath();
00704 
00705     return ActCode;
00706 }
00707 
00708 
00709 /********************************************************************************************
00710 >   static ActionCode MatrixRemoveFromPathAction::Init(Operation* pOp,
00711                                                 ActionList* pActionList,
00712                                                 TextStory* pTextStory)
00713     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00714     Created:    19/5/95
00715     Inputs:     pOp - points to the operation to add the action to
00716                 pActionList - points to the action list to add the action to
00717                 pTextStory - points to the story containing pChar
00718     Outputs:    Constructs a MatrixRemoveFromPathAction, initialises it and inserts in into
00719                 the action list
00720     Returns:    An action code depending on the success of this function
00721     Purpose:    Called to constuct a MatrixRemoveFromPathAction, set it up and and insert it
00722                 into an operations action list
00723     Errors:     Checks the parameters
00724 ********************************************************************************************/
00725 ActionCode MatrixRemoveFromPathAction::Init(Operation* pOp, ActionList* pActionList, TextStory* pTextStory)
00726 {
00727     // Check the parameters
00728     ERROR2IF(pOp == NULL, AC_FAIL, "The operation pointer is NULL");
00729     ERROR2IF(pActionList == NULL, AC_FAIL, "The action list pointer is NULL");
00730     ERROR2IF(pTextStory == NULL, AC_FAIL, "The TextStory pointer is NULL");
00731 
00732     // Create a new action and insert it in the action list
00733     UINT32 ActSize = sizeof(MatrixRemoveFromPathAction);
00734     MatrixRemoveFromPathAction* pNewAction = NULL;
00735     ActionCode Ac = Action::Init( pOp, pActionList, ActSize, CC_RUNTIME_CLASS(MatrixRemoveFromPathAction), (Action**)&pNewAction);
00736 
00737     // Set the members of the new action
00738     if ((Ac == AC_OK) && (pNewAction != NULL))
00739         pNewAction->pStory = pTextStory;
00740 
00741     return Ac;
00742 }
00743 
00744 
00745 /********************************************************************************************
00746 >   static BOOL MatrixRemoveFromPathAction::DoMatrixFitToPath(Operation* pOp,
00747                                                               ActionList* pActionList,
00748                                                               TextStory* pTextStory)
00749     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00750     Created:    19/5/95
00751     Inputs:     pOp - points to the operation to add the action to
00752                 pActionList - points to the action list to add the action to
00753                 pTextStory - points to the TextStory to reverse the path in
00754     Outputs:    Adds an action to the operations action list
00755     Returns:    TRUE/FALSE for success/failure
00756     Purpose:    Call this function when fitting text to a path.  It sets the character matrix
00757                 to the story matrix and sets the story matrix to unity.  It also inserts an
00758                 action to reverse these changes.
00759     Errors:     Checks on parameters and structure of TextStory
00760 ********************************************************************************************/
00761 BOOL MatrixRemoveFromPathAction::DoMatrixFitToPath(Operation* pOp, ActionList* pActionList, TextStory* pTextStory)
00762 {
00763     // Check the parameters
00764     ERROR2IF(pOp == NULL, FALSE, "The operation pointer is NULL");
00765     ERROR2IF(pActionList == NULL, FALSE, "The action list pointer is NULL");
00766     ERROR2IF(pTextStory == NULL, FALSE, "The TextStory pointer is NULL");
00767 
00768     // Insert an action to restore matrices on undo 
00769     ActionCode ActCode;
00770     ActCode = MatrixRemoveFromPathAction::Init(pOp, pActionList, pTextStory);
00771 
00772     // Now set the matrices
00773     if (ActCode != AC_FAIL)
00774         pTextStory->MatrixFitToPath();
00775 
00776     return (ActCode != AC_FAIL);
00777 }

Generated on Sat Nov 10 03:47:08 2007 for Camelot by  doxygen 1.4.4