OpApplyLiveEffect Class Reference

Operation to apply Bitmap Effect to the selection. See also:. More...

#include <opliveeffects.h>

Inheritance diagram for OpApplyLiveEffect:

OpLiveEffect SelOperation UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

virtual void GetOpName (String_256 *pstrOpName)
virtual void DoWithParam (OpDescriptor *pOpDesc, OpParam *pOpParam)
 Insert a new LiveEffect attribute in the stack above the selected object(s).
virtual BOOL MayChangeNodeBounds () const

Static Public Member Functions

static OpState GetParamState (String_256 *pstrDescription, OpDescriptor *pOpDesc, OpParam *pOpParam)
 Return state of the specified LiveEffect (name in pstrDescription) being applied to the selection (taking into account the current position in the LiveEffect Stack.

Private Member Functions

 CC_DECLARE_DYNCREATE (OpApplyLiveEffect)

Detailed Description

Operation to apply Bitmap Effect to the selection. See also:.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/09/2004

Definition at line 330 of file opliveeffects.h.


Member Function Documentation

OpApplyLiveEffect::CC_DECLARE_DYNCREATE OpApplyLiveEffect   )  [private]
 

void OpApplyLiveEffect::DoWithParam OpDescriptor pOpDesc,
OpParam pOpParam
[virtual]
 

Insert a new LiveEffect attribute in the stack above the selected object(s).

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/09/2004
Parameters:
[INPUTS] 
[OUTPUTS] 
Returns:

Errors: See also:

Reimplemented from OpLiveEffect.

Definition at line 2710 of file opliveeffects.cpp.

02711 {
02712     BOOL ok = FALSE;
02713 
02714     OpLiveEffectParam* pLEOpParam = NULL;
02715     if (pOpParam->IsKindOf(CC_RUNTIME_CLASS(OpLiveEffectParam)))
02716         pLEOpParam = (OpLiveEffectParam*) pOpParam;
02717 
02718     INT32 InsertPos = pLEOpParam->StackPosition;        // We want to find the surface below the current pos
02719     if (pLEOpParam->StackPosition<STACKPOS_TOP)
02720         InsertPos = InsertPos - 1;                  // We want to find the surface below the current pos
02721                                                     // because we are going to insert above that surface
02722 
02723     // Remember some details for later on when the Op ends successfully
02724     m_strEffectID = pLEOpParam->strOpUnique;
02725     m_iStackPos = InsertPos;
02726     if (m_strEffectID.IsEmpty())
02727     {
02728         End();
02729         return;
02730     }
02731 
02732     // obtain the current selection.
02733     SelRange* pSelRange = GetApplication()->FindSelection();
02734 
02735     Range* pInitialRange = NULL;
02736 
02737     // render blobs off for tools which don't automatically redraw their blobs.
02738     Tool* pTool = Tool::GetCurrent();
02739     Spread* pSpread = Document::GetSelectedSpread();
02740     if (pSpread != NULL && pTool != NULL && !pTool->AreToolBlobsRenderedOnSelection())
02741         pTool->RenderToolBlobs(pSpread, NULL);
02742 
02743     // record the current selection state and if required, render off any selection blobs.
02744     if (!DoStartSelOp(FALSE, FALSE))
02745     {
02746         End();
02747         return;
02748     }
02749 
02750     // We need to allow modeless editors to open even when there is no selection so that
02751     // they will remain open while the user changes the selection
02752     // So we must avoid calling AllowOp in that case because it returns bOK = FALSE for empty selections
02753     if (!(pLEOpParam->bReUseEditor && pSelRange->IsEmpty()))
02754     {
02755         // Ask the range whether it's OK to do the transform...
02756         // Get an ObjChangeParam ready, so we can ask op permission from nodes.
02757         ObjChangeFlags cFlags(NULL, TRUE, NULL, NULL, NULL, NULL, NULL, TRUE);  // ReplaceNode & RegenerateNode
02758         ObjChangeParam ObjChange(OBJCHANGE_STARTING, cFlags, NULL, this);
02759         BOOL bOK = pSelRange->AllowOp(&ObjChange);
02760         if (!bOK)
02761         {
02762             End();
02763             return;
02764         }
02765     }
02766 
02767     // invalidate the region bounding the selection.
02768     if (!DoInvalidateNodesRegions(*pSelRange, TRUE, FALSE, FALSE, FALSE))
02769     {
02770         End();
02771         return;
02772     }
02773 
02774     // Force text subselection up to the whole parent text object
02775     pSelRange->MakePartialSelectionWhole(FALSE, FALSE, TRUE);
02776 
02777     // Get a list of the LiveEffects we will be working on
02778     ENSURE(m_pLERange==NULL, "!");
02779     if (InsertPos==-1)
02780     {
02781         // We are to apply the LiveEFfects to the selection
02782         pInitialRange = GetApplication()->FindSelection();
02783         m_iStackPos = 0;
02784     }
02785     else
02786     {
02787         ENSURE(pLEOpParam->pPPStack, "Can't find EffectsStack");
02788         pInitialRange = pLEOpParam->pPPStack->GetLevelRange(&InsertPos);
02789         m_iStackPos = InsertPos+1;          // Remember some details for later on when the Op ends successfully
02790                                             // (New stack pos refers to item to be shown in UI after successful insertion)
02791     }
02792 
02793     // Check whether we can edit an existing effect or whether we have to apply a new one
02794     if (pInitialRange==NULL)
02795     {
02796         ERROR3("If this happens, the UI logic disagrees with the Op about what the Op can do");
02797         FailAndExecute();
02798         End();
02799         return;
02800     }
02801 
02802     // Need to add a new LiveEffects node to the selection
02803     // Decide whether we need to create a group or can apply to
02804     // each selected object individually
02805     if (pLEOpParam && !pLEOpParam->bIsDestructive)
02806     {
02807         if (NodeBitmapEffect::DefaultLocked)
02808             m_pLERange = DoApplyLiveEffect(pInitialRange, pLEOpParam->strOpUnique, pLEOpParam->strMenuText, NodeBitmapEffect::DefaultLockedPixelsPerInch, pLEOpParam->pEditsList, TRUE, TRUE);
02809         else
02810             m_pLERange = DoApplyLiveEffect(pInitialRange, pLEOpParam->strOpUnique, pLEOpParam->strMenuText, NodeBitmapEffect::DefaultLivePixelsPerInch, pLEOpParam->pEditsList, FALSE, TRUE);
02811     }
02812     else
02813     {
02814         // Destructive effects can only be applied on the top of the stack
02815         // because of the grouping that they do
02816         if (!IsTopOfStack(pLEOpParam->pPPStack, pLEOpParam->StackPosition))                     // InsertPos?
02817         {
02818             InformWarning(_R(IDS_LE_DESTRUCTIVE_APPLY_TOP), _R(IDS_CONTINUE));
02819             FailAndExecute();
02820             End();
02821             return;
02822         }
02823         else
02824         {
02825             m_pLERange = DoApplyLockedEffect(pInitialRange, pLEOpParam->strOpUnique, pLEOpParam->strMenuText, NodeBitmapEffect::DefaultLockedPixelsPerInch, NULL, TRUE);
02826         }
02827     }
02828     m_bAppliedNewEffects = (m_pLERange!=NULL);
02829 
02830     // We should now have a decent list of LiveEffect nodes...
02831     if (pLEOpParam->pEditsList==NULL)
02832     {
02833         // Mark all LiveEffects as untouched at this stage for change detection later on...
02834         SetChanged(FALSE);
02835 
02836         // Make sure we've got all the bitmaps we need to proceed
02837         ok = EnsureLiveEffectOriginalBitmaps();
02838         if (!ok)
02839         {
02840             FailAndExecute();
02841             End();
02842             return;
02843         }
02844         
02845         // OK, LiveEffects nodes are in the tree and have the original bitmaps that we need
02846         //
02847         // Now decide which bitmap to pass to XPE
02848         NodeBitmapEffect* pLE = NULL;
02849         if (m_pLERange)
02850         {
02851             Node* pNode = m_pLERange->FindLast();
02852             while (pNode && !(pNode->IsBitmapEffect() && ((NodeBitmapEffect*)pNode)->CanGenerateBitmap()))
02853                 pNode = m_pLERange->FindPrev(pNode);
02854 
02855             if (pNode==NULL)
02856             {
02857                 FailAndExecute();
02858                 End();
02859                 return;
02860             }
02861 
02862             pLE = (NodeBitmapEffect*)pNode;
02863         }
02864 
02865         // ----------------------------------------------
02866         // This is the important bit!
02867         //
02868         // Pass the sample bitmap to the XPE for editing
02869         // REMEMBER! This is only starting an edit - the results won't be known until later
02870         //
02871         ok = XPEHost::EditLiveEffect(this, pLE, pLEOpParam->strOpUnique, pLEOpParam->bReUseEditor);
02872         if (!ok)
02873         {
02874             FailAndExecute();
02875             End();
02876             return;
02877         }
02878 
02879         GetApplication()->FindSelection()->Update();
02880 
02881         // DON'T end the operation!
02882         // It is INT32-running (wait for someone to call DoEndEdit...)
02883     }
02884     else
02885     {
02886         // invalidate the (new) region bounding the selection.
02887         DoInvalidateNodesRegions(*pSelRange, TRUE, FALSE, FALSE);
02888 
02889         // render blobs back on if the current tool doesn't automatically redraw its blobs.
02890         if (pSpread != NULL && pTool != NULL && !pTool->AreToolBlobsRenderedOnSelection())
02891             pTool->RenderToolBlobs(pSpread, NULL);
02892 
02893 ObjChangeFlags cFlags(NULL, TRUE, NULL, NULL, NULL, NULL, NULL, TRUE);
02894 ObjChangeParam ObjChange(OBJCHANGE_FINISHED, cFlags, NULL, this);
02895 BOOL ok = UpdateChangedNodes(&ObjChange);
02896 
02897         BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::EFFECTSTACKCHANGED)); 
02898 
02899         // Tell the selrange that things have changed!
02900         GetApplication()->FindSelection()->Update();
02901 
02902         End();
02903     }
02904 }

void OpApplyLiveEffect::GetOpName String_256 pstrOpName  )  [virtual]
 

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/09/2004
Parameters:
[INPUTS] 
[OUTPUTS] 
Returns:

Errors: See also:

Reimplemented from Operation.

Definition at line 2689 of file opliveeffects.cpp.

02690 {
02691     *pstrOpName = String_256(_R(IDS_LE_OPAPPLY));
02692 }

OpState OpApplyLiveEffect::GetParamState String_256 pstrDescription,
OpDescriptor pOpDesc,
OpParam pOpParam
[static]
 

Return state of the specified LiveEffect (name in pstrDescription) being applied to the selection (taking into account the current position in the LiveEffect Stack.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/09/2004
Parameters:
[INPUTS] 
[OUTPUTS] 
Returns:

Errors: See also:

Definition at line 2653 of file opliveeffects.cpp.

02654 {
02655     // default is an unticked, *GREYED*, on-menu state.
02656     OpState OpSt;
02657     OpSt.Greyed = FALSE;
02658 
02659     if (XPEHost::IsEditSessionRunning())
02660     {
02661         OpSt.Greyed = TRUE;
02662         *pstrDescription = String_256(_R(IDS_LE_EDIT_RUNNING));
02663     }
02664     else if (GetApplication()->FindSelection()->FindFirst()==NULL)
02665     {
02666         OpSt.Greyed = TRUE;
02667         *pstrDescription = String_256(_R(IDS_LE_NOTHING_SELECTED));
02668     }
02669 
02670     return OpSt;
02671 }

virtual BOOL OpApplyLiveEffect::MayChangeNodeBounds  )  const [inline, virtual]
 

Reimplemented from SelOperation.

Definition at line 345 of file opliveeffects.h.

00345 { return TRUE; }


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:57:28 2007 for Camelot by  doxygen 1.4.4