00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 #include "camtypes.h"
00105 #include "opshadow.h"
00106 #include "nodecont.h"
00107 #include "nodebmp.h"
00108 #include "nbevcont.h"
00109
00110 #ifdef BUILDSHADOWS
00111
00112
00113
00114
00115
00116 #include "nodeshad.h"
00117 #include "progress.h"
00118 #include "objchge.h"
00119 #include "nodetxts.h"
00120
00121 #include "fillattr2.h"
00122
00123
00124
00125
00126
00127
00128
00129
00130 #include "opbevel.h"
00131
00132
00133 #include "shadtool.h"
00134 #include "shadinfo.h"
00135
00136 #include "nodeblnd.h"
00137 #include "nodebldr.h"
00138 #include "blobs.h"
00139
00140 #include "slicehelper.h"
00141 #include "opliveeffects.h"
00142 #include "shadtool.h"
00143
00144 #include "colormgr.h"
00145
00146
00147 #include "ophist.h"
00148
00149 DECLARE_SOURCE( "$Revision: 1282 $" );
00150
00151 CC_IMPLEMENT_DYNCREATE(OpApplyShadow, SelOperation)
00152 CC_IMPLEMENT_DYNCREATE(OpChangeShadowType, SelOperation)
00153 CC_IMPLEMENT_DYNCREATE(OpRemoveShadow, SelOperation)
00154 CC_IMPLEMENT_DYNCREATE(ShadowPosition, OpParam)
00155 CC_IMPLEMENT_DYNCREATE(OpShadowPosition, SelOperation)
00156 CC_IMPLEMENT_DYNCREATE(ShadowPenumbra, OpParam)
00157 CC_IMPLEMENT_DYNCREATE(OpShadowPenumbra, SelOperation)
00158 CC_IMPLEMENT_DYNCREATE(OpShadowAngle, SelOperation)
00159 CC_IMPLEMENT_DYNCREATE(OpShadowHeightAndAngle, SelOperation)
00160 CC_IMPLEMENT_DYNCREATE(OpShadowHeight, SelOperation)
00161 CC_IMPLEMENT_DYNCREATE(OpGlowWidth, SelOperation)
00162 CC_IMPLEMENT_DYNCREATE(OpShadowScale, SelOperation)
00163 CC_IMPLEMENT_DYNCREATE(ChangePositionShadowAction, Action)
00164 CC_IMPLEMENT_DYNCREATE(ChangePenumbraSizeAction, Action)
00165 CC_IMPLEMENT_DYNCREATE(NodeShadowClick, OpParam)
00166 CC_IMPLEMENT_DYNCREATE(OpApplyAttribForShadows, OpApplyAttribToSelected)
00167 CC_IMPLEMENT_DYNCREATE(OpSaveShadowData, SelOperation)
00168 CC_IMPLEMENT_DYNCREATE(ChangeFloorShadowAngleAction, Action)
00169 CC_IMPLEMENT_DYNCREATE(ChangeFloorShadowHeightAction, Action)
00170 CC_IMPLEMENT_DYNCREATE(ChangeShadowTypeAction, Action)
00171 CC_IMPLEMENT_DYNCREATE(ChangeGlowWidthAction, Action)
00172 CC_IMPLEMENT_DYNCREATE(ChangeShadowScaleAction, Action)
00173 CC_IMPLEMENT_DYNCREATE(SaveShadowDataAction, Action)
00174 CC_IMPLEMENT_DYNCREATE(ShadowProfileOpParam, OpParam)
00175 CC_IMPLEMENT_DYNCREATE(OpChangeShadowProfile, SelOperation)
00176 CC_IMPLEMENT_DYNCREATE(ChangeProfileAction, Action)
00177 CC_IMPLEMENT_DYNCREATE(ShadowDarknessOpParam, OpParam)
00178 CC_IMPLEMENT_DYNCREATE(OpChangeShadowDarkness, SelOperation)
00179 CC_IMPLEMENT_DYNCREATE(ChangeShadowDarknessAction, Action)
00180
00181 #define new CAM_DEBUG_NEW
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194 BOOL OpApplyShadow::Declare()
00195 {
00196 BOOL ok = TRUE;
00197
00198
00199
00200 ParamOpDescriptor* pOD2 = new ParamOpDescriptor(OPTOKEN_APPLYSHADOW,
00201 CC_RUNTIME_CLASS(OpApplyShadow),
00202 OpApplyShadow::GetParamState);
00203 ok = ok && (pOD2!=NULL);
00204
00205 return ok;
00206 }
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217 OpApplyShadow::OpApplyShadow()
00218 {
00219 }
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 OpApplyShadow::~OpApplyShadow()
00231 {
00232 }
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 void OpApplyShadow::Do(OpDescriptor *pOpDesc)
00246 {
00247 ERROR2RAW("Don't call this!");
00248 End();
00249 }
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263 void OpApplyShadow::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
00264 {
00265
00266
00267 NodeShadowParam* pNSParam = (NodeShadowParam*)pParam;
00268
00269 INT32 InsertPos = pNSParam->StackPosition - 1;
00270
00271
00272
00273 SelRange* pSelRange = GetApplication()->FindSelection();
00274
00275 Range* pInitialRange = NULL;
00276
00277
00278 Tool* pTool = Tool::GetCurrent();
00279 Spread* pSpread = Document::GetSelectedSpread();
00280 if (pSpread != NULL && pTool != NULL && !pTool->AreToolBlobsRenderedOnSelection())
00281 pTool->RenderToolBlobs(pSpread, NULL);
00282
00283
00284 if (!DoStartSelOp(FALSE, FALSE))
00285 {
00286 End();
00287 return;
00288 }
00289
00290
00291 if (!DoInvalidateNodesRegions(*pSelRange, TRUE, FALSE, FALSE, FALSE))
00292 {
00293 End();
00294 return;
00295 }
00296
00297
00298 pSelRange->MakePartialSelectionWhole(FALSE);
00299
00300
00301 if (InsertPos==-1)
00302 {
00303
00304 pInitialRange = GetApplication()->FindSelection();
00305 }
00306 else
00307 {
00308 ENSURE(pNSParam->pPPStack, "Can't find EffectsStack");
00309 pInitialRange = pNSParam->pPPStack->GetLevelRange(&InsertPos);
00310 }
00311
00312
00313 if (pInitialRange==NULL)
00314 {
00315 ERROR3("Failed to get surface range to apply shadow too");
00316 FailAndExecute();
00317 End();
00318 return;
00319 }
00320
00321
00322
00323
00324 ListRange* pPPRange = NULL;
00325 pPPRange = DoApplyShadow(this, pInitialRange, pNSParam);
00326
00327
00328 if (pPPRange==NULL)
00329 {
00330 FailAndExecute();
00331 End();
00332 return;
00333 }
00334
00335
00336 DoInvalidateNodesRegions(*pSelRange, TRUE, FALSE, FALSE);
00337
00338
00339 if (pSpread != NULL && pTool != NULL && !pTool->AreToolBlobsRenderedOnSelection())
00340 pTool->RenderToolBlobs(pSpread, NULL);
00341
00342 End();
00343
00344
00345 Tool* pShadowTool = Tool::FindTool(TOOLID_SOFTSHADOW);
00346 if (pShadowTool && !pShadowTool->IsCurrent())
00347 {
00348 ((SoftShadowTool*)pShadowTool)->SetShadowEditRange(pPPRange, STACKPOS_TOP, TRUE);
00349 pShadowTool->SetCurrent();
00350 }
00351
00352
00353 delete pPPRange;
00354 pPPRange = NULL;
00355
00356 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::EFFECTSTACKCHANGED));
00357
00358 }
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375 ListRange* OpApplyShadow::DoApplyShadow(UndoableOperation* pOp, Range* pRange, NodeShadowParam* pNSParam)
00376 {
00377 ERROR3IF(pOp==NULL, "DoApplyShadow not given an operation to work in");
00378 ERROR3IF(pRange==NULL, "DoApplyShadow not given a range to work on");
00379
00380
00381
00382 ListRange* pNewRange = new ListRange();
00383 ENSURE(pNewRange, "DoApplyEffect can't create a ListRange");
00384 if (pNewRange==NULL)
00385 return NULL;
00386
00387 Node* pNode = pRange->FindFirst();
00388
00389
00390
00391 while (pNode)
00392 {
00393 NodeShadowController* pShadControl = DoApplyShadow(pOp, pNode, pNSParam);
00394 if (pShadControl)
00395 {
00396 pNewRange->AddNode(pShadControl);
00397
00398
00399 BOOL ok = pOp->DoFactorOutCommonChildAttributes(pShadControl);
00400 if (!ok)
00401 {
00402 delete pNewRange;
00403 return NULL;
00404 }
00405 }
00406 else
00407 {
00408 delete pNewRange;
00409 return NULL;
00410 }
00411
00412 pNode = pRange->FindNext(pNode);
00413 }
00414
00415 return pNewRange;
00416 }
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434 NodeShadowController* OpApplyShadow::DoApplyShadow(UndoableOperation* pOp, Node* pNode, NodeShadowParam* pNSParam, BOOL bSetSelected)
00435 {
00436 ERROR3IF(pOp==NULL, "DoApplyShadow not given an operation to work in");
00437 ERROR3IF(pNode==NULL, "DoApplyShadow not given a node to work on");
00438
00439 BOOL ok = TRUE;
00440 NodeShadowController* pShadControl = NULL;
00441
00442 ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
00443 ObjChangeParam ocp(OBJCHANGE_STARTING, flgs, NULL, pOp, OBJCHANGE_CALLEDBYOP);
00444
00445 if (pNode->AllowOp(&ocp))
00446 {
00447 ALLOC_WITH_FAIL(pShadControl, (new NodeShadowController()), pOp);
00448 if (pShadControl==NULL) goto ApplyShadowError;
00449
00450
00451 NodeShadow* pShadow = NULL;
00452 ALLOC_WITH_FAIL(pShadow, (new NodeShadow()), pOp);
00453 if (pShadow==NULL) goto ApplyShadowError;
00454
00455 ok = pOp->DoInsertNewNode(pShadControl, pNode, NEXT, FALSE, FALSE, FALSE, FALSE);
00456 if (!ok) goto ApplyShadowError;
00457
00458 ok = pOp->DoInvalidateNodeRegion(pShadControl, TRUE, FALSE, FALSE, FALSE);
00459 if (!ok) goto ApplyShadowError;
00460
00461
00462 AttrFlatColourFill * pAttr = NULL;
00463 ALLOC_WITH_FAIL(pAttr, new AttrFlatColourFill(pShadow, FIRSTCHILD), pOp);
00464 if (pAttr==NULL) goto ApplyShadowError;
00465
00466 DocColour ShadowCol;
00467
00468 if (pNSParam->m_Type == SHADOWTYPE_GLOW)
00469 AttributeManager::FindDefaultColour(ColourManager::GetCurrentColourList(),
00470 _R(IDS_REDNAME), &ShadowCol);
00471 else
00472 AttributeManager::FindDefaultColour(ColourManager::GetCurrentColourList(),
00473 _R(IDS_BLACKNAME), &ShadowCol);
00474 pAttr->SetStartColour(&ShadowCol);
00475
00476
00477 ok = pOp->DoMoveNode(pNode, pShadControl, LASTCHILD);
00478 if (!ok) goto ApplyShadowError;
00479
00480 pNode->SetSelected(FALSE);
00481
00482
00483 ok = pOp->DoInsertNewNode(pShadow, pShadControl, FIRSTCHILD, FALSE, FALSE, FALSE, FALSE);
00484 if (!ok) goto ApplyShadowError;
00485
00486
00487
00488 pShadControl->ReleaseCached(TRUE, FALSE);
00489 #ifdef NEW_SHADOW_RENDER
00490
00491 pShadControl->ReleaseStackedShadows();
00492
00493
00494 if (pNode->IsAShadowController())
00495 {
00496
00497 NodeShadowController* pPrevTopController = (NodeShadowController*) pNode;
00498
00499
00500
00501 NodeAttribute* pAttr = NodeAttribute::FindFirstAppliedAttr(pPrevTopController);
00502 while (pAttr && pAttr->IsEffectAttribute())
00503 {
00504 pOp->DoMoveNode(pAttr, pShadControl, LASTCHILD);
00505
00506 pAttr = NodeAttribute::FindFirstAppliedAttr(pPrevTopController);
00507 }
00508 }
00509 #endif
00510
00511 if (bSetSelected)
00512 pShadControl->FindBottomShadowController()->GetInkNodeFromController()->SetSelected(TRUE);
00513
00514 ok = pOp->DoInvalidateNodeRegion(pShadow, TRUE, FALSE, FALSE, FALSE);
00515 if (!ok) goto ApplyShadowError;
00516
00517
00518
00519 ok = pOp->DoFactorOutCommonChildAttributes(pShadControl);
00520 if (!ok) goto ApplyShadowError;
00521
00522
00523 pShadControl->SetPenumbraWidth(pNSParam->m_Blur);
00524 pShadControl->SetOffsetX(pNSParam->m_OffsetX);
00525 pShadControl->SetOffsetY(pNSParam->m_OffsetY);
00526 pShadControl->SetShadowType(pNSParam->m_Type);
00527 pShadControl->SetFloorShadowAngle(pNSParam->m_FloorShadowAngle);
00528 pShadControl->SetFloorShadowHeight((float)pNSParam->m_FloorShadowHeight);
00529 pShadControl->SetWallShadowScale((float)pNSParam->m_Scale);
00530 pShadControl->SetGlowWidth(pNSParam->m_GlowWidth);
00531 pShadControl->SetFeatherWidth(pNSParam->m_FeatherWidth);
00532 pShadow->SetBiasGain(pNSParam->m_Profile);
00533 pShadow->SetDarkness(pNSParam->m_dDarkness);
00534
00535
00536 ((pShadControl)->GetShadow())->GenerateShadow();
00537
00538
00539
00540
00541
00542 if (pNode->IsAnObject())
00543 {
00544 NodeRenderableInk* pInk = (NodeRenderableInk*)pNode;
00545 Node* pTestBlend = pShadControl->FindParent();
00546 if (pTestBlend != NULL && pTestBlend->IsABlend())
00547 ((NodeBlend*)pTestBlend)->ReinitialiseOnChildChanged(pOp, pInk, pShadControl);
00548 }
00549
00550
00551
00552
00553 ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
00554 flgs.RegenerateNode = TRUE;
00555 ObjChangeParam ocp2(OBJCHANGE_FINISHED, flgs, pShadControl, pOp, OBJCHANGE_CALLEDBYCHILD);
00556
00557 Node *pParent = pShadControl->FindParent();
00558
00559 while (pParent)
00560 {
00561 pParent->OnChildChange(&ocp2);
00562 pParent = pParent->FindParent();
00563 }
00564
00565
00566 SliceHelper::AddNamesToController(pOp, pShadControl);
00567 }
00568
00569 return pShadControl;
00570
00571 ApplyShadowError:
00572 delete pShadControl;
00573 return NULL;
00574 }
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590 OpState OpApplyShadow::GetState(String_256* Description, OpDescriptor*)
00591 {
00592 OpState Blobby;
00593
00594 Blobby.Greyed = FALSE;
00595
00596 return Blobby;
00597 }
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618 OpState OpApplyShadow::GetParamState(String_256* pstrDescription, OpDescriptor* pOpDesc, OpParam* pOpParam)
00619 {
00620
00621 OpState OpSt;
00622 OpSt.Greyed = FALSE;
00623
00624
00625
00626 return OpSt;
00627 }
00628
00629
00630
00631
00632
00633
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650 BOOL OpChangeShadowType::Declare()
00651 {
00652 BOOL ok = TRUE;
00653
00654
00655
00656 ParamOpDescriptor* pOD2 = new ParamOpDescriptor(OPTOKEN_CHANGESHADOWTYPE,
00657 CC_RUNTIME_CLASS(OpChangeShadowType),
00658 OpChangeShadowType::GetParamState);
00659 ok = ok && (pOD2!=NULL);
00660
00661 return ok;
00662 }
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673 OpChangeShadowType::OpChangeShadowType()
00674 {
00675 }
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686 OpChangeShadowType::~OpChangeShadowType()
00687 {
00688 }
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701 void OpChangeShadowType::Do(OpDescriptor *pOpDesc)
00702 {
00703 ERROR2RAW("Don't call this!");
00704 End();
00705 }
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719 void OpChangeShadowType::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
00720 {
00721
00722
00723 NodeShadowParam* pNSParam = (NodeShadowParam*)pParam;
00724
00725
00726
00727
00728
00729 Range Sel(*(GetApplication()->FindSelection()));
00730 RangeControl rc = Sel.GetRangeControlFlags();
00731 rc.PromoteToParent = TRUE;
00732 Sel.Range::SetRangeControl(rc);
00733
00734
00735
00736
00737 Tool* pTool = Tool::GetCurrent();
00738 Spread* pSpread = Document::GetSelectedSpread();
00739 if (pSpread != NULL && pTool != NULL && !pTool->AreToolBlobsRenderedOnSelection())
00740 pTool->RenderToolBlobs(pSpread, NULL);
00741
00742
00743 if (!DoStartSelOp(FALSE, FALSE))
00744 {
00745 End();
00746 return;
00747 }
00748
00749
00750 if (!DoInvalidateNodesRegions(Sel, TRUE, FALSE, FALSE, FALSE))
00751 {
00752 End();
00753 return;
00754 }
00755
00756
00757
00758
00759
00760
00761
00762 BOOL bOK = DoChangeShadowType(this, pNSParam);
00763
00764
00765 if (!bOK)
00766 {
00767 FailAndExecute();
00768 End();
00769 return;
00770 }
00771
00772
00773 DoInvalidateNodesRegions(*(GetApplication()->FindSelection()), TRUE, FALSE, FALSE, FALSE);
00774
00775
00776 if (pSpread != NULL && pTool != NULL && !pTool->AreToolBlobsRenderedOnSelection())
00777 pTool->RenderToolBlobs(pSpread, NULL);
00778
00779 End();
00780 }
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796 BOOL OpChangeShadowType::DoChangeShadowType(UndoableOperation* pOp, NodeShadowParam* pNSParam)
00797 {
00798 ERROR3IF(pOp==NULL, "DoChangeShadowType not given an operation to work in");
00799
00800
00801
00802 ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
00803 ObjChangeParam ocp(OBJCHANGE_STARTING, flgs, NULL, pOp, OBJCHANGE_CALLEDBYOP);
00804
00805 ENSURE(pNSParam->pShadowTool, "Op not given pointer to shadow tool");
00806 Range* pShadowRange = pNSParam->pShadowTool->GetShadowEditRange();
00807 Node* pNode = pShadowRange->FindFirst();
00808 if (pNode==NULL)
00809 {
00810 ERROR3("Nothing was selected in OpChangeShadowType");
00811 return FALSE;
00812 }
00813
00814 while (pNode)
00815 {
00816 ENSURE(pNode->IsAShadowController(), "Found unexpected node type");
00817 NodeShadowController* pController = (NodeShadowController*)pNode;
00818
00819 if (pController->GetShadowType() != pNSParam->m_Type)
00820 {
00821
00822
00823 pController->InvalidateBoundingRect();
00824
00825 {
00826
00827 pController->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
00828 pOp->DoInvalidateNodeRegion(pController, TRUE, FALSE, FALSE, FALSE);
00829 pOp->DoInvalidateRegion(pController->FindParentSpread(), pController->GetBlobBoundingRect());
00830 }
00831
00832 ChangeShadowTypeAction* Action = NULL;
00833 ChangeShadowTypeAction::Init(pOp, pOp->GetUndoActionList(), pController, pNSParam->m_Type, &Action);
00834
00835
00836 pController->InvalidateBoundingRect();
00837
00838 {
00839
00840 pController->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
00841 pOp->DoInvalidateNodeRegion(pController, TRUE, FALSE, FALSE, FALSE);
00842 pOp->DoInvalidateRegion(pController->FindParentSpread(), pController->GetBlobBoundingRect());
00843 }
00844 }
00845
00846 pNode = pShadowRange->FindNext(pNode);
00847 }
00848
00849 return TRUE;
00850 }
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863 OpState OpChangeShadowType::GetState(String_256* Description, OpDescriptor*)
00864 {
00865 OpState Blobby;
00866
00867 Blobby.Greyed = FALSE;
00868
00869 return Blobby;
00870 }
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890 OpState OpChangeShadowType::GetParamState(String_256* pstrDescription, OpDescriptor* pOpDesc, OpParam* pOpParam)
00891 {
00892
00893 OpState OpSt;
00894 OpSt.Greyed = FALSE;
00895
00896
00897
00898 return OpSt;
00899 }
00900
00901
00902
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916 OpRemoveShadow::OpRemoveShadow()
00917 {
00918 }
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929 OpRemoveShadow::~OpRemoveShadow()
00930 {
00931 }
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943 void OpRemoveShadow::DoWithParam(OpDescriptor *pOpDesc, OpParam* pParam)
00944 {
00945
00946 BeginSlowJob();
00947
00948
00949 NodeShadowParam* pNSParam = (NodeShadowParam*)pParam;
00950
00951 BOOL ok = TRUE;
00952
00953 if (ok) ok = DoStartSelOp(TRUE);
00954
00955 NodeBlend * pBlend = NULL;
00956 NodeBlender * pBlender = NULL;
00957 NodeRenderableInk * pRenderableNode = NULL;
00958
00959 BOOL bBlendBefore = FALSE;
00960 BOOL bBlendAfter = FALSE;
00961
00962 ENSURE(pNSParam->pShadowTool, "Op not given pointer to shadow tool");
00963
00964
00965
00966 ListRange* pShadowRange = new ListRange(pNSParam->pShadowTool->GetShadowEditRange());
00967 Node* pSCNode = pShadowRange->FindFirst();
00968 while (pSCNode)
00969 {
00970 if (pSCNode->IS_KIND_OF(NodeShadowController) && pSCNode->FindParent()!=NULL)
00971 {
00972 Node* pNode = pSCNode;
00973 NodeShadowController* pControl = (NodeShadowController*) pSCNode;
00974
00975
00976
00977 pBlender = (NodeBlender *)pNode->FindNext(CC_RUNTIME_CLASS(NodeBlender));
00978
00979 bBlendBefore = FALSE;
00980 bBlendAfter = FALSE;
00981
00982 if (pBlender)
00983 {
00984
00985 bBlendBefore = TRUE;
00986
00987 pBlend = (NodeBlend *)pBlender->FindParent();
00988 }
00989 else
00990 {
00991
00992 pBlender = (NodeBlender *)pNode->FindPrevious(CC_RUNTIME_CLASS(NodeBlender));
00993
00994 if (pBlender)
00995 {
00996 bBlendAfter = TRUE;
00997 pBlend = (NodeBlend *)pBlender->FindParent();
00998 }
00999 }
01000
01001
01002
01003
01004
01005
01006
01007
01008 if (ok) ok = DoLocaliseCommonAttributes((NodeShadowController *)pNode, TRUE);
01009
01010 NodeHidden* pNodeHidden;
01011 NodeShadowController* pNodeShadCont = (NodeShadowController*)pNode;
01012
01013
01014
01015 if (ok)
01016 SliceHelper::RemoveNamesFromController(this, pNodeShadCont);
01017
01018
01019
01020 if (ok)
01021 {
01022 pNodeShadCont->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
01023 ok = DoInvalidateNodeRegion(pNodeShadCont, TRUE, FALSE, FALSE, FALSE);
01024 }
01025
01026
01027 pNode = pNodeShadCont->FindFirstChild();
01028
01029 while (pNode != NULL && ok)
01030 {
01031 Node* pNext = pNode->FindNext();
01032
01033 if (pNode->IsAnObject() && !pNode->IS_KIND_OF(NodeShadow))
01034 ok = DoMoveNode(pNode,pNodeShadCont,PREV);
01035
01036 if (ok) pNode->SetSelected(TRUE);
01037 pNode = pNext;
01038 }
01039
01040
01041
01042 if (ok) pNodeShadCont->SetSelected(FALSE);
01043
01044 Node * pParent = pNodeShadCont->FindParent();
01045
01046 if (ok) ok = DoHideNode(pNodeShadCont,TRUE,&pNodeHidden,FALSE);
01047
01048 if (ok)
01049 {
01050
01051
01052 if (bBlendBefore)
01053 {
01054 if (InitBlendAction::InitOnBlender(this, GetUndoActionList(), pBlender, TRUE, TRUE) != AC_OK)
01055 {
01056 ERROR2RAW("Couldn't Initialise blend action");
01057 }
01058
01059
01060 pRenderableNode = (NodeRenderableInk *)pBlender->FindPrevious(CC_RUNTIME_CLASS(NodeRenderableInk));
01061
01062 if (pRenderableNode)
01063 {
01064 pBlender->Reinit(pRenderableNode, pBlender->GetNodeEnd(), FALSE);
01065 }
01066 }
01067 else if (bBlendAfter)
01068 {
01069 if (InitBlendAction::InitOnBlender(this, GetUndoActionList(), pBlender, TRUE, TRUE) != AC_OK)
01070 {
01071 ERROR2RAW("Couldn't Initialise blend action");
01072 }
01073
01074
01075 pRenderableNode = (NodeRenderableInk *)pBlender->FindNext(CC_RUNTIME_CLASS(NodeRenderableInk));
01076
01077 if (pRenderableNode)
01078 {
01079 pBlender->Reinit(pBlender->GetNodeStart(), pRenderableNode, FALSE);
01080 }
01081 }
01082
01083 if (pBlender)
01084 {
01085 NodeBlend* ptrBlend = (NodeBlend*) pBlender->FindParent ();
01086
01087 ERROR3IF (!IS_A (ptrBlend, NodeBlend), "NodeBlend is not a NodeBlend!");
01088
01089 BOOL done = FALSE;
01090 NodeBlender* ptrNode = ptrBlend->FindFirstBlender ();
01091
01092 while (!done)
01093 {
01094 if (ptrNode != pBlender)
01095 {
01096 if (ptrNode->GetNodeStart() == pControl)
01097 {
01098 if (InitBlendAction::InitOnBlender(this, GetUndoActionList(), ptrNode, TRUE, TRUE) != AC_OK)
01099 {
01100 ERROR2RAW("Couldn't Initialise blend action");
01101 }
01102
01103
01104
01105
01106 if (pRenderableNode)
01107 {
01108 ptrNode->Reinit(pRenderableNode, NULL, FALSE);
01109 }
01110 }
01111 if (ptrNode->GetNodeEnd() == pControl)
01112 {
01113 if (InitBlendAction::InitOnBlender(this, GetUndoActionList(), ptrNode, TRUE, TRUE) != AC_OK)
01114 {
01115 ERROR2RAW("Couldn't Initialise blend action");
01116 }
01117
01118
01119
01120
01121 if (pRenderableNode)
01122 {
01123 ptrNode->Reinit(NULL, pRenderableNode, FALSE);
01124 }
01125 }
01126 }
01127
01128 ptrNode = ptrBlend->FindNextBlender (ptrNode);
01129
01130 if (!ptrNode)
01131 {
01132 done = TRUE;
01133 }
01134 }
01135 }
01136 }
01137
01138
01139
01140 if (pParent->IsBounded())
01141 ((NodeRenderableBounded*)pParent)->InvalidateBoundingRect();
01142
01143
01144 if (ok)
01145 {
01146 ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
01147 flgs.DeleteNode = TRUE;
01148 flgs.RegenerateNode = TRUE;
01149 ObjChangeParam OP(OBJCHANGE_FINISHED, flgs, pNodeShadCont, this, OBJCHANGE_CALLEDBYCHILD);
01150
01151 while (pParent)
01152 {
01153 if (pParent->OnChildChange(&OP) != CC_OK)
01154 break;
01155
01156 if (pParent->IS_KIND_OF(NodeBlend))
01157 {
01158 ((NodeBlend *)pParent)->Deinit();
01159 ((NodeBlend *)pParent)->Reinit(FALSE);
01160 }
01161
01162 pParent = pParent->FindParent();
01163 }
01164 }
01165 }
01166
01167 pSCNode = pShadowRange->FindNext(pSCNode);
01168 }
01169
01170 if (pShadowRange)
01171 {
01172 delete pShadowRange;
01173 pShadowRange = NULL;
01174 }
01175
01176 if (!ok)
01177 FailAndExecute();
01178
01179 End();
01180 }
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193 BOOL OpRemoveShadow::Declare()
01194 {
01195 return (RegisterOpDescriptor(
01196 0,
01197 _R(IDS_REMOVESHADOWOP),
01198 CC_RUNTIME_CLASS(OpRemoveShadow),
01199 OPTOKEN_REMOVESHADOW,
01200 OpRemoveShadow::GetState));
01201
01202 }
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216 OpState OpRemoveShadow::GetState(String_256* Description, OpDescriptor*)
01217 {
01218 OpState Blobby;
01219
01220 return Blobby;
01221 }
01222
01223
01228
01229 ShadowPosition::ShadowPosition()
01230 {
01231 X = 0;
01232 Y = 0;
01233 m_bUpdateX = 0;
01234 m_bUpdateY = 0;
01235 m_pTool = NULL;
01236 }
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247 ShadowPosition::ShadowPosition(const INT32 x, const INT32 y,
01248 BOOL UpdateX, BOOL UpdateY, SoftShadowTool* pTool)
01249 {
01250 X = x;
01251 Y = y;
01252 m_bUpdateX = UpdateX;
01253 m_bUpdateY = UpdateY;
01254 m_pTool = pTool;
01255 }
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266 ShadowPosition::~ShadowPosition()
01267 {
01268 }
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282 OpShadowPosition::OpShadowPosition()
01283 {
01284 }
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297 OpShadowPosition::~OpShadowPosition()
01298 {
01299 }
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313 BOOL OpShadowPosition::Declare()
01314 {
01315 return (RegisterOpDescriptor(
01316 0,
01317 _R(IDS_POSITIONSHADOWOP),
01318 CC_RUNTIME_CLASS(OpShadowPosition),
01319 OPTOKEN_SHADOWPOSITION,
01320 OpShadowPosition::GetState));
01321 }
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334 void OpShadowPosition::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
01335 {
01336
01337 BeginSlowJob();
01338
01339 ShadowPosition *MyShadowPosition = (ShadowPosition *)pParam;
01340 ERROR3IF(MyShadowPosition == NULL, "Parameter block pointer was NULL");
01341
01342 if (MyShadowPosition == NULL)
01343 {
01344 End();
01345 return;
01346 }
01347
01348 ENSURE(MyShadowPosition->m_pTool, "Op not given pointer to shadow tool");
01349 Range* pShadowRange = MyShadowPosition->m_pTool->GetShadowEditRange();
01350 Node* pNode = pShadowRange->FindFirst();
01351 if (pNode==NULL)
01352 {
01353 ERROR3("Nothing was selected in OpShadowPosition");
01354 FailAndExecute();
01355 End();
01356 return;
01357 }
01358 while (pNode)
01359 {
01360 ENSURE(pNode->IsAShadowController(), "Found unexpected node type");
01361 NodeShadowController* pController = (NodeShadowController*)pNode;
01362
01363 ChangePositionShadowAction* pAction = NULL;
01364
01365
01366 pController->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
01367 DoInvalidateNodeRegion(pController->GetShadow(), TRUE, FALSE, FALSE, FALSE);
01368
01369
01370 ActionCode ac = ChangePositionShadowAction::Init(this,
01371 &UndoActions,pController,
01372 MyShadowPosition->X,
01373 MyShadowPosition->Y,
01374 MyShadowPosition->m_bUpdateX,
01375 MyShadowPosition->m_bUpdateY,
01376 &pAction
01377 );
01378 if (ac==AC_FAIL)
01379 {
01380 FailAndExecute();
01381 End();
01382 return;
01383 }
01384
01385
01386 pController->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
01387 DoInvalidateNodeRegion(pController->GetShadow(), TRUE, FALSE, FALSE, FALSE);
01388
01389
01390 ObjChangeFlags flgs(FALSE, FALSE, FALSE, TRUE);
01391 ObjChangeParam OP(OBJCHANGE_FINISHED, flgs, pController, this, OBJCHANGE_CALLEDBYOP);
01392 flgs.RegenerateNode = TRUE;
01393 Node * pNodeParent = pController->FindParent();
01394
01395 while (pNodeParent)
01396 {
01397 pNodeParent->OnChildChange(&OP);
01398
01399 pNodeParent = pNodeParent->FindParent();
01400 }
01401
01402 pNode = pShadowRange->FindNext(pNode);
01403 }
01404
01405 End();
01406 }
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420 OpState OpShadowPosition::GetState(String_256* Description, OpDescriptor*)
01421 {
01422 OpState Blobby;
01423
01424 return Blobby;
01425 }
01426
01427
01433
01434
01435 ShadowPenumbra::ShadowPenumbra()
01436 {
01437 P = 0;
01438 m_pTool = NULL;
01439 }
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453 ShadowPenumbra::~ShadowPenumbra()
01454 {
01455 }
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470 ShadowPenumbra::ShadowPenumbra(const INT32 p, SoftShadowTool* pTool)
01471 {
01472 P = p;
01473 m_pTool = pTool;
01474 }
01475
01476
01477 OpShadowPenumbra::OpShadowPenumbra()
01478 {
01479 }
01480
01481 OpShadowPenumbra::~OpShadowPenumbra()
01482 {
01483 }
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496 BOOL OpShadowPenumbra::Declare()
01497 {
01498 return (RegisterOpDescriptor(
01499 0,
01500 _R(IDS_PENUMBRASHADOWOP),
01501 CC_RUNTIME_CLASS(OpShadowPenumbra),
01502 OPTOKEN_SHADOWPENUMBRA,
01503 OpShadowPenumbra::GetState));
01504 }
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518 OpState OpShadowPenumbra::GetState(String_256* Description, OpDescriptor*)
01519 {
01520 OpState Blobby;
01521
01522 return Blobby;
01523 }
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537 void OpShadowPenumbra::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
01538 {
01539
01540 BeginSlowJob();
01541
01542 ShadowPenumbra *MyShadowPenumbra = (ShadowPenumbra *)pParam;
01543 ERROR3IF(MyShadowPenumbra == NULL, "Parameter block pointer was NULL");
01544
01545 if (MyShadowPenumbra == NULL)
01546 {
01547 End();
01548 return;
01549 }
01550
01551
01552 ENSURE(MyShadowPenumbra->m_pTool, "Op not given pointer to shadow tool");
01553 Range* pShadowRange = MyShadowPenumbra->m_pTool->GetShadowEditRange();
01554 Node* pNode = pShadowRange->FindFirst();
01555 if (pNode==NULL)
01556 {
01557 ERROR3("Nothing was selected in OpShadowPenumbra");
01558 FailAndExecute();
01559 End();
01560 return;
01561 }
01562 while (pNode)
01563 {
01564 ENSURE(pNode->IsAShadowController(), "Found unexpected node type");
01565 NodeShadowController* pController = (NodeShadowController*)pNode;
01566
01567 ChangePenumbraSizeAction* pAction = NULL;
01568
01569
01570
01571 pController->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
01572 DoInvalidateNodeRegion(pController, TRUE, FALSE, FALSE, FALSE);
01573
01574 ActionCode ac = ChangePenumbraSizeAction::Init(this,
01575 &UndoActions,
01576 pController,
01577 MyShadowPenumbra->P,
01578 &pAction
01579 );
01580 if (ac==AC_FAIL)
01581 {
01582 FailAndExecute();
01583 End();
01584 return;
01585 }
01586
01587
01588 pController->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
01589 DoInvalidateNodeRegion(pController, TRUE, FALSE, FALSE, FALSE);
01590
01591
01592 ObjChangeFlags flgs(FALSE, FALSE, FALSE, TRUE);
01593 ObjChangeParam OP(OBJCHANGE_FINISHED, flgs, pController, this, OBJCHANGE_CALLEDBYOP);
01594
01595 Node* pNodeParent = pController->FindParent();
01596
01597 while (pNodeParent)
01598 {
01599 pNodeParent->OnChildChange(&OP);
01600
01601 pNodeParent = pNodeParent->FindParent();
01602 }
01603
01604 pNode = pShadowRange->FindNext(pNode);
01605 }
01606
01607 End();
01608 }
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632 ChangePositionShadowAction::ChangePositionShadowAction()
01633 {
01634 m_pNodeShadowCont = NULL;
01635 m_OldPositionX = 0;
01636 m_OldPositionY = 0;
01637 m_bUpdateX = 0;
01638 m_bUpdateY = 0;
01639 }
01640
01641
01642
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672 ActionCode ChangePositionShadowAction::Init(Operation* pOp,
01673 ActionList* pActionList,
01674 NodeShadowController* pThisNodeShadow,
01675 MILLIPOINT NewOffsetX,
01676 MILLIPOINT NewOffsetY,
01677 BOOL UpdateX,
01678 BOOL UpdateY,
01679 ChangePositionShadowAction** ppNewAction,
01680 BOOL Reverse)
01681 {
01682 UINT32 ActSize = sizeof(ChangePositionShadowAction);
01683
01684 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,CC_RUNTIME_CLASS(ChangePositionShadowAction),(Action**)ppNewAction);
01685
01686 MILLIPOINT OldOffsetX = pThisNodeShadow->GetOffsetX();
01687 MILLIPOINT OldOffsetY = pThisNodeShadow->GetOffsetY();
01688
01689 if (Ac != AC_FAIL)
01690 {
01691 (*ppNewAction)->m_pNodeShadowCont = pThisNodeShadow;
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704 if (UpdateX)
01705 pThisNodeShadow->SetOffsetX(NewOffsetX);
01706 else
01707 NewOffsetX = pThisNodeShadow->GetOffsetX();
01708
01709 if (UpdateY)
01710 pThisNodeShadow->SetOffsetY(NewOffsetY);
01711 else
01712 NewOffsetY = pThisNodeShadow->GetOffsetY();
01713
01714
01715 (*ppNewAction)->m_OldPositionX = OldOffsetX;
01716 (*ppNewAction)->m_OldPositionY = OldOffsetY;
01717 (*ppNewAction)->m_bUpdateX = UpdateX;
01718 (*ppNewAction)->m_bUpdateY = UpdateY;
01719
01720 TRACEUSER( "DavidM", _T("Moving shadow by %d %d, %d %d\n"),
01721 NewOffsetX, NewOffsetY, OldOffsetX, OldOffsetY);
01722
01723 pThisNodeShadow->SetWallShadowOffset(DocCoord(NewOffsetX, NewOffsetY), TRUE);
01724 }
01725
01726 return Ac;
01727 }
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745 ActionCode ChangePositionShadowAction::Execute()
01746 {
01747 ActionCode Act;
01748 ChangePositionShadowAction* pAction;
01749
01750 Act = ChangePositionShadowAction::Init( pOperation,
01751 pOppositeActLst,
01752 m_pNodeShadowCont,
01753 m_OldPositionX, m_OldPositionY,
01754 m_bUpdateX, m_bUpdateY,
01755 &pAction,
01756 TRUE);
01757
01758
01759 if (Act != AC_FAIL)
01760 {
01761 (m_pNodeShadowCont)->SetOffsetX(m_OldPositionX);
01762 (m_pNodeShadowCont)->SetOffsetY(m_OldPositionY);
01763 }
01764
01765 return Act;
01766 }
01767
01768 ChangePositionShadowAction::~ChangePositionShadowAction()
01769 {
01770 }
01771
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793 ChangePenumbraSizeAction::ChangePenumbraSizeAction()
01794 {
01795 m_pNodeShadowCont = NULL;
01796 m_OldPenumbraSize = 0;
01797 }
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831 ActionCode ChangePenumbraSizeAction::Init(Operation* pOp,
01832 ActionList* pActionList,
01833 NodeShadowController* pThisNodeShadow,
01834 MILLIPOINT NewPenumbraSize,
01835 ChangePenumbraSizeAction** ppNewAction,
01836 BOOL bReverse,
01837 BOOL bCache)
01838 {
01839 UINT32 ActSize = sizeof(ChangePenumbraSizeAction);
01840
01841 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,CC_RUNTIME_CLASS(ChangePenumbraSizeAction),(Action**)ppNewAction);
01842
01843 Document * pDoc = Document::GetCurrent();
01844
01845 DocView * pView = DocView::GetCurrent();
01846
01847 Spread * pSpread = NULL;
01848
01849 if (Ac != AC_FAIL)
01850 {
01851
01852
01853 if (bReverse)
01854 {
01855 pActionList->RemoveItem(*ppNewAction);
01856 pActionList->AddHead(*ppNewAction);
01857 (*ppNewAction)->m_bCache = bCache;
01858 }
01859
01860 pSpread = (Spread *)pThisNodeShadow->FindParent(CC_RUNTIME_CLASS(Spread));
01861
01862 if (!pSpread)
01863 pSpread = Document::GetSelectedSpread();
01864
01865 if (pDoc)
01866 {
01867 if (pSpread)
01868 {
01869 pThisNodeShadow->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
01870 pDoc->ForceRedraw(pSpread, pThisNodeShadow->GetBoundingRect(FALSE, FALSE), FALSE, pThisNodeShadow, FALSE);
01871 }
01872 }
01873
01874 (*ppNewAction)->m_pNodeShadowCont = pThisNodeShadow;
01875 (*ppNewAction)->m_OldPenumbraSize = pThisNodeShadow->GetPenumbraWidth();
01876
01877 pThisNodeShadow->SetPenumbraWidth(NewPenumbraSize);
01878
01879
01880 if (pView && bCache)
01881 {
01882 GetApplication()->AddNodeToRegenList(pThisNodeShadow);
01883 }
01884 else
01885 {
01886 ((pThisNodeShadow)->GetShadow())->GenerateShadow();
01887 }
01888
01889 if (pDoc)
01890 {
01891 if (pSpread)
01892 {
01893 pThisNodeShadow->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
01894 pDoc->ForceRedraw(pSpread, pThisNodeShadow->GetBoundingRect(FALSE, FALSE), FALSE, pThisNodeShadow, FALSE);
01895 pDoc->ForceRedraw(pSpread, pThisNodeShadow->GetBoundingRect(TRUE, FALSE), FALSE, pThisNodeShadow, FALSE);
01896 }
01897 }
01898
01899 (*ppNewAction)->m_LastRect = (*ppNewAction)->m_pNodeShadowCont->GetBoundingRect();
01900 }
01901
01902 return Ac;
01903 }
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921 ActionCode ChangePenumbraSizeAction::Execute()
01922 {
01923 ActionCode Act;
01924 ChangePenumbraSizeAction* pAction;
01925
01926
01927 DocRect dr = m_LastRect;
01928
01929 Act = ChangePenumbraSizeAction::Init( pOperation,
01930 pOppositeActLst,
01931 m_pNodeShadowCont,
01932 m_OldPenumbraSize,
01933 &pAction, TRUE, m_bCache
01934 );
01935
01936 Spread * pSpread = NULL;
01937
01938 if (Act != AC_FAIL)
01939 {
01940 Document * pDoc = Document::GetCurrent();
01941
01942 pSpread = (Spread *)m_pNodeShadowCont->FindParent(CC_RUNTIME_CLASS(Spread));
01943
01944 if (!pSpread)
01945 pSpread = Document::GetSelectedSpread();
01946
01947 if (pDoc)
01948 {
01949 m_LastRect = m_pNodeShadowCont->GetBoundingRect();
01950
01951 if (pSpread)
01952 {
01953 pDoc->ForceRedraw(pSpread,
01954 m_LastRect, FALSE, m_pNodeShadowCont);
01955 }
01956 }
01957 }
01958
01959 return Act;
01960 }
01961
01962 ChangePenumbraSizeAction::~ChangePenumbraSizeAction()
01963 {
01964 }
01965
01966
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981
01982 NodeShadowClick::NodeShadowClick()
01983 {
01984 m_pNode = NULL;
01985 m_pTool = NULL;
01986 }
01987
01988 NodeShadowClick::NodeShadowClick(Node *p, SoftShadowTool* pTool)
01989 {
01990 m_pNode = p;
01991 m_pTool = pTool;
01992 }
01993
01994 NodeShadowClick::~NodeShadowClick()
01995 {
01996 }
01997
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020 BOOL OpApplyAttribForShadows::DoApply(Node* CurrentNode,
02021 NodeAttribute* Attrib,
02022 BOOL Mutate,
02023 BOOL InvalidateRegion,
02024 BOOL KeepExistingCols,
02025 BOOL* AttribWasRequired
02026 )
02027 {
02028 if (!CurrentNode->IsKindOf(CC_RUNTIME_CLASS(NodeShadowController)) ||
02029 (!Attrib->IsKindOf(CC_RUNTIME_CLASS(AttrFillGeometry)) &&
02030 !Attrib->IsKindOf(CC_RUNTIME_CLASS(AttrValueChange))))
02031 {
02032 return OpApplyAttrib::DoApply(CurrentNode, Attrib, Mutate, InvalidateRegion,
02033 KeepExistingCols, AttribWasRequired);
02034 }
02035
02036
02037 Node * pNode = CurrentNode->FindFirstChild();
02038
02039 BOOL bOk = TRUE;
02040
02041 while (pNode && bOk)
02042 {
02043 if (pNode->IsRenderable() && !pNode->IsAnAttribute())
02044 {
02045 if (!pNode->IsKindOf(CC_RUNTIME_CLASS(NodeShadow)))
02046 {
02047 bOk = OpApplyAttrib::DoApply(pNode, Attrib, Mutate, InvalidateRegion,
02048 KeepExistingCols, AttribWasRequired);
02049 }
02050 }
02051
02052 pNode = pNode->FindNext();
02053 }
02054
02055 return bOk;
02056 }
02057
02058
02059
02060
02061
02062
02063
02064
02065
02066
02067
02068
02069
02070
02071
02072
02073
02074 BOOL OpApplyAttribForShadows::Init()
02075 {
02076
02077 OpDescriptor* OpDesc = new OpDescriptor(
02078 0,
02079 _R(IDS_APPLYATTRIBOP),
02080 CC_RUNTIME_CLASS(OpApplyAttribForShadows),
02081 OPTOKEN_SHADOWATTRIB,
02082 OpApplyAttribToSelected::GetState);
02083
02084 ERRORIF(!OpDesc, _R(IDE_NOMORE_MEMORY), FALSE);
02085 return(OpDesc != NULL);
02086 }
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108 ChangeFloorShadowHeightAction::ChangeFloorShadowHeightAction()
02109 {
02110 m_pNodeShadowCont = NULL;
02111 m_LastHeight = 0;
02112 }
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146 ActionCode ChangeFloorShadowHeightAction::Init(Operation* pOp,
02147 ActionList* pActionList,
02148 NodeShadowController* pThisNodeShadow,
02149 double NewHeight,
02150 ChangeFloorShadowHeightAction** ppNewAction,
02151 BOOL bReverse,
02152 BOOL bCache)
02153 {
02154 UINT32 ActSize = sizeof(ChangeFloorShadowHeightAction);
02155
02156 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,
02157 CC_RUNTIME_CLASS(ChangeFloorShadowHeightAction),
02158 (Action**)ppNewAction);
02159
02160 Document * pDoc = Document::GetCurrent();
02161
02162 if (Ac != AC_FAIL)
02163 {
02164
02165
02166 if (bReverse)
02167 {
02168 pActionList->RemoveItem(*ppNewAction);
02169 pActionList->AddHead(*ppNewAction);
02170 }
02171
02172 (*ppNewAction)->m_pNodeShadowCont = pThisNodeShadow;
02173 (*ppNewAction)->m_LastHeight = pThisNodeShadow->GetFloorShadowHeight();
02174 (*ppNewAction)->m_bCache = bCache;
02175
02176 pThisNodeShadow->SetFloorShadowHeight((float)NewHeight);
02177
02178 if (pDoc)
02179 {
02180 pDoc->ForceRedraw(pThisNodeShadow->FindParentSpread(), pThisNodeShadow->GetBlobBoundingRect(), FALSE, pThisNodeShadow);
02181 }
02182
02183 pThisNodeShadow->RegenerateNode(NULL, FALSE);
02184
02185 if (pDoc)
02186 {
02187 pDoc->ForceRedraw(pThisNodeShadow->FindParentSpread(), pThisNodeShadow->GetBlobBoundingRect(), FALSE, pThisNodeShadow);
02188 }
02189
02190 (*ppNewAction)->m_LastRect = (*ppNewAction)->m_pNodeShadowCont->GetBoundingRect();
02191 }
02192
02193 return Ac;
02194 }
02195
02196
02197
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212 ActionCode ChangeFloorShadowHeightAction::Execute()
02213 {
02214 ActionCode Act;
02215 ChangeFloorShadowHeightAction* pAction;
02216
02217
02218 DocRect dr = m_LastRect;
02219
02220 Act = ChangeFloorShadowHeightAction::Init( pOperation,
02221 pOppositeActLst,
02222 m_pNodeShadowCont,
02223 m_LastHeight,
02224 &pAction,
02225 TRUE,
02226 m_bCache);
02227
02228 if (Act != AC_FAIL)
02229 {
02230 Document * pDoc = Document::GetCurrent();
02231
02232 if (pDoc)
02233 {
02234 m_LastRect = m_pNodeShadowCont->GetShadow()->GetBoundingRect();
02235 pDoc->ForceRedraw(m_pNodeShadowCont->GetShadow()->FindParentSpread(),
02236 m_LastRect, FALSE, m_pNodeShadowCont);
02237 }
02238 }
02239
02240 return Act;
02241 }
02242
02243 ChangeFloorShadowHeightAction::~ChangeFloorShadowHeightAction()
02244 {
02245 }
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267 ChangeFloorShadowAngleAction::ChangeFloorShadowAngleAction()
02268 {
02269 m_pNodeShadowCont = NULL;
02270 m_LastAngle = 0;
02271 }
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298
02299
02300
02301
02302
02303
02304
02305 ActionCode ChangeFloorShadowAngleAction::Init(Operation* pOp,
02306 ActionList* pActionList,
02307 NodeShadowController* pThisNodeShadow,
02308 INT32 NewAngle,
02309 ChangeFloorShadowAngleAction** ppNewAction,
02310 BOOL bReverse, BOOL bCache)
02311 {
02312 UINT32 ActSize = sizeof(ChangeFloorShadowAngleAction);
02313
02314 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,
02315 CC_RUNTIME_CLASS(ChangeFloorShadowAngleAction),
02316 (Action**)ppNewAction);
02317
02318
02319 Document * pDoc = Document::GetCurrent();
02320
02321 DocRect dr;
02322
02323 if (Ac != AC_FAIL)
02324 {
02325
02326
02327 if (bReverse)
02328 {
02329 pActionList->RemoveItem(*ppNewAction);
02330 pActionList->AddHead(*ppNewAction);
02331 }
02332
02333 (*ppNewAction)->m_pNodeShadowCont = pThisNodeShadow;
02334 (*ppNewAction)->m_LastAngle = (INT32)pThisNodeShadow->GetFloorShadowAngle();
02335 (*ppNewAction)->m_bCache = bCache;
02336
02337
02338 pThisNodeShadow->InvalidateBoundingRect();
02339
02340 dr = pThisNodeShadow->GetBoundingRect();
02341 TRACEUSER( "DavidM", _T("Rect before %d %d %d %d\n"),
02342 dr.lo.x, dr.lo.y, dr.hi.x, dr.hi.y);
02343
02344 pDoc->ForceRedraw(pThisNodeShadow->GetShadow()->FindParentSpread(),
02345 pThisNodeShadow->GetBoundingRect(), FALSE, pThisNodeShadow);
02346
02347 pThisNodeShadow->SetFloorShadowAngle(NewAngle);
02348
02349 pThisNodeShadow->RegenerateNode(NULL, bCache);
02350
02351 pThisNodeShadow->InvalidateBoundingRect();
02352
02353 dr= pThisNodeShadow->GetBoundingRect();
02354 TRACEUSER( "DavidM", _T("Rect after %d %d %d %d\n"),
02355 dr.lo.x, dr.lo.y, dr.hi.x, dr.hi.y);
02356
02357 pDoc->ForceRedraw(pThisNodeShadow->GetShadow()->FindParentSpread(),
02358 pThisNodeShadow->GetBoundingRect(), FALSE, pThisNodeShadow);
02359 }
02360
02361 return Ac;
02362 }
02363
02364
02365
02366
02367
02368
02369
02370
02371
02372
02373
02374
02375
02376
02377
02378
02379
02380 ActionCode ChangeFloorShadowAngleAction::Execute()
02381 {
02382 ActionCode Act;
02383 ChangeFloorShadowAngleAction* pAction;
02384
02385
02386 DocRect dr = m_LastRect;
02387
02388 Act = ChangeFloorShadowAngleAction::Init( pOperation,
02389 pOppositeActLst,
02390 m_pNodeShadowCont,
02391 m_LastAngle,
02392 &pAction,
02393 TRUE,
02394 m_bCache);
02395
02396 if (Act != AC_FAIL)
02397 {
02398 Document * pDoc = Document::GetCurrent();
02399
02400 if (pDoc)
02401 {
02402 m_LastRect = m_pNodeShadowCont->GetBoundingRect();
02403 pDoc->ForceRedraw(m_pNodeShadowCont->GetShadow()->FindParentSpread(),
02404 m_LastRect, FALSE, m_pNodeShadowCont);
02405 }
02406 }
02407
02408 return Act;
02409 }
02410
02411 ChangeFloorShadowAngleAction::~ChangeFloorShadowAngleAction()
02412 {
02413 }
02414
02415
02416
02417
02418
02419
02420
02421
02422
02423
02424
02425
02426
02427
02428
02429
02430
02431
02432
02433
02434
02435 ChangeShadowTypeAction::ChangeShadowTypeAction()
02436 {
02437 m_pNodeShadowCont = NULL;
02438 m_LastType = SHADOWTYPE_NONE;
02439 }
02440
02441
02442
02443
02444
02445
02446
02447
02448
02449
02450
02451
02452
02453
02454
02455
02456
02457
02458
02459
02460
02461
02462
02463
02464
02465
02466
02467
02468
02469
02470
02471
02472
02473 ActionCode ChangeShadowTypeAction::Init(Operation* pOp,
02474 ActionList* pActionList,
02475 NodeShadowController* pThisNodeShadow,
02476 ShadowType NewShadowType,
02477 ChangeShadowTypeAction** ppNewAction,
02478 BOOL bReverse)
02479 {
02480 UINT32 ActSize = sizeof(ChangeShadowTypeAction);
02481
02482 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,
02483 CC_RUNTIME_CLASS(ChangeShadowTypeAction),
02484 (Action**)ppNewAction);
02485
02486 Document * pDoc = Document::GetCurrent();
02487
02488 if (Ac != AC_FAIL)
02489 {
02490
02491
02492 if (bReverse)
02493 {
02494 pActionList->RemoveItem(*ppNewAction);
02495 pActionList->AddHead(*ppNewAction);
02496 }
02497
02498 if (pDoc)
02499 {
02500 pThisNodeShadow->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
02501 pDoc->ForceRedraw(pThisNodeShadow->FindParentSpread(),
02502 pThisNodeShadow->GetBlobBoundingRect(), FALSE, pThisNodeShadow, FALSE);
02503 }
02504
02505
02506 (*ppNewAction)->m_pNodeShadowCont = pThisNodeShadow;
02507 (*ppNewAction)->m_LastType = pThisNodeShadow->GetShadowType();
02508
02509 pThisNodeShadow->SetShadowType(NewShadowType);
02510
02511 pThisNodeShadow->RegenerateNode(NULL);
02512
02513 (*ppNewAction)->m_LastRect = (*ppNewAction)->m_pNodeShadowCont->GetBoundingRect();
02514
02515 if (pDoc)
02516 {
02517 pThisNodeShadow->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
02518 pDoc->ForceRedraw(pThisNodeShadow->FindParentSpread(),
02519 pThisNodeShadow->GetBlobBoundingRect(), FALSE, pThisNodeShadow, FALSE);
02520 }
02521 }
02522
02523 return Ac;
02524 }
02525
02526
02527
02528
02529
02530
02531
02532
02533
02534
02535
02536
02537
02538
02539
02540
02541
02542 ActionCode ChangeShadowTypeAction::Execute()
02543 {
02544 ActionCode Act;
02545 ChangeShadowTypeAction* pAction;
02546
02547
02548 DocRect dr = m_LastRect;
02549
02550 Act = ChangeShadowTypeAction::Init( pOperation,
02551 pOppositeActLst,
02552 m_pNodeShadowCont,
02553 m_LastType,
02554 &pAction);
02555
02556 if (Act != AC_FAIL)
02557 {
02558 Document * pDoc = Document::GetCurrent();
02559
02560 if (pDoc)
02561 {
02562 m_LastRect = m_pNodeShadowCont->GetBoundingRect();
02563 pDoc->ForceRedraw(m_pNodeShadowCont->GetShadow()->FindParentSpread(),
02564 m_LastRect, FALSE, m_pNodeShadowCont);
02565 }
02566 }
02567
02568 return Act;
02569 }
02570
02571 ChangeShadowTypeAction::~ChangeShadowTypeAction()
02572 {
02573 }
02574
02579
02580
02581
02582
02583
02584
02585
02586
02587
02588
02589
02590
02591
02592 OpShadowAngle::OpShadowAngle()
02593 {
02594 }
02595
02596
02597
02598
02599
02600
02601
02602
02603
02604
02605
02606
02607 OpShadowAngle::~OpShadowAngle()
02608 {
02609 }
02610
02611
02612
02613
02614
02615
02616
02617
02618
02619
02620
02621
02622
02623
02624
02625 BOOL OpShadowAngle::Declare()
02626 {
02627 return (RegisterOpDescriptor(
02628 0,
02629 _R(IDS_ANGLESHADOWOP),
02630 CC_RUNTIME_CLASS(OpShadowAngle),
02631 OPTOKEN_SHADOWANGLE,
02632 OpShadowAngle::GetState));
02633 }
02634
02635
02636
02637
02638
02639
02640
02641
02642
02643
02644
02645
02646
02647 void OpShadowAngle::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
02648 {
02649 BeginSlowJob();
02650 DoStartSelOp(TRUE);
02651
02652 NodeShadowParam* pNSParam = (NodeShadowParam *)pParam;
02653
02654 ENSURE(pNSParam->pShadowTool, "Op not given pointer to shadow tool");
02655 Range* pShadowRange = pNSParam->pShadowTool->GetShadowEditRange();
02656 Node* pNode = pShadowRange->FindFirst();
02657 if (pNode==NULL)
02658 {
02659 ERROR3("Nothing was selected in OpShadowAngle");
02660 FailAndExecute();
02661 End();
02662 return;
02663 }
02664
02665 while (pNode)
02666 {
02667 ENSURE(pNode->IsAShadowController(), "Found unexpected node type");
02668 NodeShadowController* pController = (NodeShadowController*)pNode;
02669
02670 pController->InvalidateBoundingRect();
02671
02672 pController->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
02673 DoInvalidateNodeRegion(pController, TRUE, FALSE, FALSE, FALSE);
02674
02675 ChangeFloorShadowAngleAction * pAction = NULL;
02676
02677 if (!ChangeFloorShadowAngleAction::Init(this, GetUndoActionList(), pController,
02678 (INT32)pNSParam->m_FloorShadowAngle, &pAction))
02679 {
02680 ERROR3("Change floor shadow angle action failed\n");
02681 }
02682
02683 pController->InvalidateBoundingRect();
02684
02685 pController->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
02686 DoInvalidateNodeRegion(pController, TRUE, FALSE, FALSE, FALSE);
02687
02688
02689 ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
02690 flgs.RegenerateNode = TRUE;
02691 ObjChangeParam OP(OBJCHANGE_FINISHED, flgs, pController, this, OBJCHANGE_CALLEDBYOP);
02692 Node * pParent = pController->FindParent();
02693
02694 while (pParent)
02695 {
02696 pParent->OnChildChange(&OP);
02697 pParent = pParent->FindParent();
02698 }
02699
02700 pNode = pShadowRange->FindNext(pNode);
02701 }
02702
02703 End();
02704 }
02705
02706
02707
02708
02709
02710
02711
02712
02713
02714
02715
02716
02717
02718 OpState OpShadowAngle::GetState(String_256* Description, OpDescriptor*)
02719 {
02720 OpState Blobby;
02721
02722 return Blobby;
02723 }
02724
02729
02730
02731
02732
02733
02734
02735
02736
02737
02738
02739
02740
02741
02742 OpShadowHeight::OpShadowHeight()
02743 {
02744 }
02745
02746
02747
02748
02749
02750
02751
02752
02753
02754
02755
02756
02757 OpShadowHeight::~OpShadowHeight()
02758 {
02759 }
02760
02761
02762
02763
02764
02765
02766
02767
02768
02769
02770
02771
02772
02773
02774
02775 BOOL OpShadowHeight::Declare()
02776 {
02777 return (RegisterOpDescriptor(
02778 0,
02779 _R(IDS_HEIGHTSHADOWOP),
02780 CC_RUNTIME_CLASS(OpShadowHeight),
02781 OPTOKEN_SHADOWHEIGHT,
02782 OpShadowHeight::GetState));
02783 }
02784
02785
02786
02787
02788
02789
02790
02791
02792
02793
02794
02795
02796
02797 void OpShadowHeight::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
02798 {
02799
02800 BeginSlowJob();
02801 DoStartSelOp(TRUE);
02802
02803 NodeShadowParam * pNSParam = (NodeShadowParam *)pParam;
02804
02805 ENSURE(pNSParam->pShadowTool, "Op not given pointer to shadow tool");
02806 Range* pShadowRange = pNSParam->pShadowTool->GetShadowEditRange();
02807 Node* pNode = pShadowRange->FindFirst();
02808 if (pNode==NULL)
02809 {
02810 ERROR3("Nothing was selected in OpShadowHeight");
02811 FailAndExecute();
02812 End();
02813 return;
02814 }
02815 while (pNode)
02816 {
02817 ENSURE(pNode->IsAShadowController(), "Found unexpected node type");
02818 NodeShadowController* pController = (NodeShadowController*)pNode;
02819
02820 pController->InvalidateBoundingRect();
02821
02822
02823 ChangeFloorShadowHeightAction * pAction = NULL;
02824
02825 ChangeFloorShadowHeightAction::Init(this, GetUndoActionList(), pController,
02826 pNSParam->m_FloorShadowHeight, &pAction);
02827
02828 pController->InvalidateBoundingRect();
02829
02830
02831
02832 ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
02833 flgs.RegenerateNode = TRUE;
02834 ObjChangeParam OP(OBJCHANGE_FINISHED, flgs, pController, this, OBJCHANGE_CALLEDBYOP);
02835 Node * pParent = pController->FindParent();
02836
02837 while (pParent)
02838 {
02839 pParent->OnChildChange(&OP);
02840 pParent = pParent->FindParent();
02841 }
02842
02843 pNode = pShadowRange->FindNext(pNode);
02844 }
02845
02846 End();
02847 }
02848
02849
02850
02851
02852
02853
02854
02855
02856
02857
02858
02859
02860
02861 OpState OpShadowHeight::GetState(String_256* Description, OpDescriptor*)
02862 {
02863 OpState Blobby;
02864
02865 return Blobby;
02866 }
02867
02872
02873
02874
02875
02876
02877
02878
02879
02880
02881
02882
02883
02884
02885 OpShadowScale::OpShadowScale()
02886 {
02887 }
02888
02889
02890
02891
02892
02893
02894
02895
02896
02897
02898
02899
02900 OpShadowScale::~OpShadowScale()
02901 {
02902 }
02903
02904
02905
02906
02907
02908
02909
02910
02911
02912
02913
02914
02915
02916
02917
02918 BOOL OpShadowScale::Declare()
02919 {
02920 return (RegisterOpDescriptor(
02921 0,
02922 _R(IDS_SCALESHADOWOP),
02923 CC_RUNTIME_CLASS(OpShadowScale),
02924 OPTOKEN_SHADOWSCALE,
02925 OpShadowScale::GetState));
02926 }
02927
02928
02929
02930
02931
02932
02933
02934
02935
02936
02937
02938
02939
02940 void OpShadowScale::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
02941 {
02942
02943 BeginSlowJob();
02944 DoStartSelOp(TRUE);
02945
02946 NodeShadowParam * pNSParam = (NodeShadowParam *)pParam;
02947
02948 ENSURE(pNSParam->pShadowTool, "Op not given pointer to shadow tool");
02949 Range* pShadowRange = pNSParam->pShadowTool->GetShadowEditRange();
02950 Node* pNode = pShadowRange->FindFirst();
02951 if (pNode==NULL)
02952 {
02953 ERROR3("Nothing was selected in OpShadowScale");
02954 FailAndExecute();
02955 End();
02956 return;
02957 }
02958 while (pNode)
02959 {
02960 ENSURE(pNode->IsAShadowController(), "Found unexpected node type");
02961 NodeShadowController* pController = (NodeShadowController*)pNode;
02962
02963 pController->InvalidateBoundingRect();
02964
02965
02966 ChangeShadowScaleAction * pAction = NULL;
02967
02968 ChangeShadowScaleAction::Init(this, GetUndoActionList(), pController,
02969 pNSParam->m_Scale, &pAction);
02970
02971 pController->InvalidateBoundingRect();
02972
02973
02974
02975 ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
02976 flgs.RegenerateNode = TRUE;
02977 ObjChangeParam OP(OBJCHANGE_FINISHED, flgs, pController, this, OBJCHANGE_CALLEDBYOP);
02978 Node * pParent = pController->FindParent();
02979
02980 while (pParent)
02981 {
02982 pParent->OnChildChange(&OP);
02983 pParent = pParent->FindParent();
02984 }
02985
02986 pNode = pShadowRange->FindNext(pNode);
02987 }
02988
02989 End();
02990 }
02991
02992
02993
02994
02995
02996
02997
02998
02999
03000
03001
03002
03003
03004 OpState OpShadowScale::GetState(String_256* Description, OpDescriptor*)
03005 {
03006 OpState Blobby;
03007
03008 return Blobby;
03009 }
03010
03011
03012
03013
03014
03015
03016
03017
03018
03019
03020
03021
03022
03023
03024
03025
03026
03027
03028
03029
03030
03031 ChangeShadowScaleAction::ChangeShadowScaleAction()
03032 {
03033 m_pNodeShadowCont = NULL;
03034 m_LastScale = 0;
03035 }
03036
03037
03038
03039
03040
03041
03042
03043
03044
03045
03046
03047
03048
03049
03050
03051
03052
03053
03054
03055
03056
03057
03058
03059
03060
03061
03062
03063
03064
03065
03066
03067
03068
03069 ActionCode ChangeShadowScaleAction::Init(Operation* pOp,
03070 ActionList* pActionList,
03071 NodeShadowController* pThisNodeShadow,
03072 double NewScale,
03073 ChangeShadowScaleAction** ppNewAction,
03074 BOOL bReverse)
03075 {
03076 UINT32 ActSize = sizeof(ChangeShadowScaleAction);
03077
03078 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,
03079 CC_RUNTIME_CLASS(ChangeShadowScaleAction),
03080 (Action**)ppNewAction);
03081
03082
03083 Document * pDoc = Document::GetCurrent();
03084
03085 DocRect dr;
03086
03087 if (Ac != AC_FAIL)
03088 {
03089
03090
03091 if (bReverse)
03092 {
03093 pActionList->RemoveItem(*ppNewAction);
03094 pActionList->AddHead(*ppNewAction);
03095 }
03096
03097 (*ppNewAction)->m_pNodeShadowCont = pThisNodeShadow;
03098 (*ppNewAction)->m_LastScale = pThisNodeShadow->GetWallShadowScale();
03099
03100
03101 pThisNodeShadow->InvalidateBoundingRect();
03102
03103 dr = pThisNodeShadow->GetBoundingRect();
03104 TRACEUSER( "DavidM", _T("Rect before %d %d %d %d\n"),
03105 dr.lo.x, dr.lo.y, dr.hi.x, dr.hi.y);
03106
03107 pDoc->ForceRedraw(pThisNodeShadow->GetShadow()->FindParentSpread(),
03108 pThisNodeShadow->GetShadow()->GetBoundingRect(), FALSE, pThisNodeShadow);
03109
03110 pThisNodeShadow->SetWallShadowScale((float)NewScale);
03111
03112 pThisNodeShadow->RegenerateNode(NULL);
03113
03114 pThisNodeShadow->InvalidateBoundingRect();
03115
03116 dr= pThisNodeShadow->GetBoundingRect();
03117 TRACEUSER( "DavidM", _T("Rect after %d %d %d %d\n"),
03118 dr.lo.x, dr.lo.y, dr.hi.x, dr.hi.y);
03119
03120 pDoc->ForceRedraw(pThisNodeShadow->GetShadow()->FindParentSpread(),
03121 pThisNodeShadow->GetShadow()->GetBoundingRect(), FALSE, pThisNodeShadow);
03122 }
03123
03124 return Ac;
03125 }
03126
03127
03128
03129
03130
03131
03132
03133
03134
03135
03136
03137
03138
03139
03140
03141
03142
03143 ActionCode ChangeShadowScaleAction::Execute()
03144 {
03145 ActionCode Act;
03146 ChangeShadowScaleAction* pAction;
03147
03148
03149 DocRect dr = m_LastRect;
03150
03151 Act = ChangeShadowScaleAction::Init( pOperation,
03152 pOppositeActLst,
03153 m_pNodeShadowCont,
03154 m_LastScale,
03155 &pAction);
03156
03157 if (Act != AC_FAIL)
03158 {
03159 Document * pDoc = Document::GetCurrent();
03160
03161 if (pDoc)
03162 {
03163 m_LastRect = m_pNodeShadowCont->GetBoundingRect();
03164 pDoc->ForceRedraw(m_pNodeShadowCont->GetShadow()->FindParentSpread(),
03165 m_LastRect, FALSE, m_pNodeShadowCont);
03166 }
03167 }
03168
03169 return Act;
03170 }
03171
03172 ChangeShadowScaleAction::~ChangeShadowScaleAction()
03173 {
03174 }
03175
03180
03181
03182
03183
03184
03185
03186
03187
03188
03189
03190
03191
03192
03193 OpShadowHeightAndAngle::OpShadowHeightAndAngle()
03194 {
03195 }
03196
03197
03198
03199
03200
03201
03202
03203
03204
03205
03206
03207
03208 OpShadowHeightAndAngle::~OpShadowHeightAndAngle()
03209 {
03210 }
03211
03212
03213
03214
03215
03216
03217
03218
03219
03220
03221
03222
03223
03224
03225
03226 BOOL OpShadowHeightAndAngle::Declare()
03227 {
03228 return (RegisterOpDescriptor(
03229 0,
03230 _R(IDS_HEIGHTANDANGLESHADOWOP),
03231 CC_RUNTIME_CLASS(OpShadowHeightAndAngle),
03232 OPTOKEN_SHADOWHEIGHTANDANGLE,
03233 OpShadowHeightAndAngle::GetState));
03234 }
03235
03236
03237
03238
03239
03240
03241
03242
03243
03244
03245
03246
03247
03248 void OpShadowHeightAndAngle::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
03249 {
03250 BeginSlowJob();
03251 DoStartSelOp(TRUE);
03252
03253 NodeShadowParam * pNSParam = (NodeShadowParam *)pParam;
03254
03255 ENSURE(pNSParam->pShadowTool, "Op not given pointer to shadow tool");
03256 Range* pShadowRange = pNSParam->pShadowTool->GetShadowEditRange();
03257 Node* pNode = pShadowRange->FindFirst();
03258 if (pNode==NULL)
03259 {
03260 ERROR3("Nothing was selected in OpShadowHeightAndAndle");
03261 FailAndExecute();
03262 End();
03263 return;
03264 }
03265 while (pNode)
03266 {
03267 ENSURE(pNode->IsAShadowController(), "Found unexpected node type");
03268 NodeShadowController* pController = (NodeShadowController*)pNode;
03269
03270 pController->InvalidateBoundingRect();
03271
03272
03273 ChangeFloorShadowAngleAction * pAction = NULL;
03274 ChangeFloorShadowHeightAction * pAction2 = NULL;
03275
03276
03277 if (!ChangeFloorShadowAngleAction::Init(this, GetUndoActionList(), pController,
03278 (INT32)pNSParam->m_FloorShadowAngle, &pAction, TRUE, TRUE))
03279 {
03280 ERROR3("Change floor shadow angle action failed\n");
03281 }
03282
03283 if (!ChangeFloorShadowHeightAction::Init(this, GetUndoActionList(), pController,
03284 pNSParam->m_FloorShadowHeight, &pAction2, TRUE, TRUE))
03285 {
03286 ERROR3("Change floor shadow angle action failed\n");
03287 }
03288
03289 pController->InvalidateBoundingRect();
03290
03291
03292
03293
03294 ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
03295 flgs.RegenerateNode = TRUE;
03296 ObjChangeParam OP(OBJCHANGE_FINISHED, flgs, pController, this, OBJCHANGE_CALLEDBYOP);
03297 Node * pParent = pController->FindParent();
03298
03299 while (pParent)
03300 {
03301 pParent->OnChildChange(&OP);
03302 pParent = pParent->FindParent();
03303 }
03304
03305 pNode = pShadowRange->FindNext(pNode);
03306 }
03307
03308 End();
03309
03310 }
03311
03312
03313
03314
03315
03316
03317
03318
03319
03320
03321
03322
03323
03324 OpState OpShadowHeightAndAngle::GetState(String_256* Description, OpDescriptor*)
03325 {
03326 OpState Blobby;
03327
03328 return Blobby;
03329 }
03330
03331
03332
03333
03334
03335
03336
03337
03338
03339
03340
03341
03342
03343
03344
03345
03346
03347
03348
03349
03350
03351 SaveShadowDataAction::SaveShadowDataAction()
03352 {
03353 m_pSelRange = NULL;
03354 }
03355
03356
03357
03358
03359
03360
03361
03362
03363
03364
03365
03366
03367
03368
03369
03370
03371
03372
03373
03374
03375
03376
03377
03378
03379
03380
03381
03382
03383
03384
03385
03386
03387 ActionCode SaveShadowDataAction::Init( Operation* pOp,
03388 ActionList* pActionList,
03389 Range &MyRange,
03390 SaveShadowDataAction** ppNewAction,
03391 BOOL bReverse)
03392 {
03393 UINT32 ActSize = sizeof(SaveShadowDataAction);
03394
03395 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,
03396 CC_RUNTIME_CLASS(SaveShadowDataAction),
03397 (Action**)ppNewAction);
03398
03399 ShadowDragData * pItem = NULL;
03400
03401 if (Ac != AC_FAIL)
03402 {
03403
03404
03405 if (bReverse)
03406 {
03407 pActionList->RemoveItem(*ppNewAction);
03408 pActionList->AddHead(*ppNewAction);
03409 }
03410
03411 (*ppNewAction)->m_LastRect = MyRange.GetBoundingRect();
03412
03413
03414 ALLOC_WITH_FAIL((*ppNewAction)->m_pSelRange, new Range(MyRange), pOp);
03415
03416 Node * pNode = (*ppNewAction)->m_pSelRange->FindFirst();
03417
03418 Spread *pSpread = NULL;
03419
03420 while (pNode)
03421 {
03422 pSpread = pNode->FindParentSpread();
03423
03424 if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeShadowController)))
03425 {
03426 ALLOC_WITH_FAIL(pItem, new ShadowDragData, pOp);
03427
03428 if (!pItem)
03429 {
03430 return AC_FAIL;
03431 }
03432
03433 pItem->PenumbraSize = ((NodeShadowController *)pNode)->GetPenumbraWidth();
03434 pItem->PositionShadowX = ((NodeShadowController *)pNode)->GetOffsetX();
03435 pItem->PositionShadowY = ((NodeShadowController *)pNode)->GetOffsetY();
03436 pItem->ShadowAngle = ((NodeShadowController *)pNode)->GetFloorShadowAngle();
03437 pItem->ShadowHeight = ((NodeShadowController *)pNode)->GetFloorShadowHeight();
03438 pItem->ShadowScale = ((NodeShadowController *)pNode)->GetWallShadowScale();
03439 pItem->GlowWidth = ((NodeShadowController *)pNode)->GetGlowWidth();
03440 pItem->FeatherWidth = ((NodeShadowController*)pNode)->GetFeatherWidth();
03441
03442 (*ppNewAction)->m_DataList.AddTail(pItem);
03443 }
03444
03445 pNode = (*ppNewAction)->m_pSelRange->FindNext(pNode);
03446 }
03447 }
03448
03449 return Ac;
03450 }
03451
03452
03453
03454
03455
03456
03457
03458
03459
03460
03461
03462
03463
03464
03465
03466
03467
03468 ActionCode SaveShadowDataAction::Execute()
03469 {
03470 ActionCode Act;
03471 SaveShadowDataAction* pAction;
03472
03473
03474 DocRect dr = m_LastRect;
03475
03476 Act = SaveShadowDataAction::Init( pOperation,
03477 pOppositeActLst,
03478 *m_pSelRange,
03479 &pAction);
03480
03481 Document * pDoc = Document::GetCurrent();
03482
03483 if (Act != AC_FAIL)
03484 {
03485 Node * pNode = m_pSelRange->FindFirst();
03486 ShadowDragData * pItem = (ShadowDragData *)m_DataList.GetHead();
03487
03488 while (pNode)
03489 {
03490 if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeShadowController)) && pItem)
03491 {
03492
03493 if (pDoc)
03494 {
03495 pDoc->ForceRedraw(pNode->FindParentSpread(), ((NodeShadowController *)pNode)->GetShadow()->GetBoundingRect(), TRUE, pNode);
03496 }
03497
03498 ((NodeShadowController *)pNode)->SetPenumbraWidth(pItem->PenumbraSize);
03499 ((NodeShadowController *)pNode)->SetOffsetX(pItem->PositionShadowX);
03500 ((NodeShadowController *)pNode)->SetOffsetY(pItem->PositionShadowY);
03501 ((NodeShadowController *)pNode)->SetFloorShadowAngle(pItem->ShadowAngle);
03502 ((NodeShadowController *)pNode)->SetFloorShadowHeight(pItem->ShadowHeight);
03503 ((NodeShadowController *)pNode)->SetWallShadowScale(pItem->ShadowScale);
03504 ((NodeShadowController *)pNode)->SetGlowWidth(pItem->GlowWidth);
03505 ((NodeShadowController*)pNode)->SetFeatherWidth(pItem->FeatherWidth);
03506
03507 TRACEUSER( "DavidM", _T("Setting floor shadow angle %d\n"), pItem->ShadowAngle);
03508
03509 pItem = (ShadowDragData *)m_DataList.GetNext(pItem);
03510
03511
03512 pNode->RegenerateNode(NULL, FALSE);
03513
03514
03515 if (pDoc)
03516 {
03517 pDoc->ForceRedraw(pNode->FindParentSpread(), ((NodeShadowController *)pNode)->GetShadow()->GetBoundingRect(), TRUE, pNode);
03518 }
03519
03520 GetApplication()->ServiceRendering();
03521 }
03522
03523 pNode = m_pSelRange->FindNext(pNode);
03524 }
03525 }
03526
03527 return Act;
03528 }
03529
03530 SaveShadowDataAction::~SaveShadowDataAction()
03531 {
03532 m_DataList.DeleteAll();
03533
03534 if (m_pSelRange)
03535 delete m_pSelRange;
03536 }
03537
03542
03543
03544
03545
03546
03547
03548
03549
03550
03551
03552
03553
03554
03555 OpSaveShadowData::OpSaveShadowData()
03556 {
03557 m_OpName = 0;
03558 }
03559
03560
03561
03562
03563
03564
03565
03566
03567
03568
03569
03570
03571 OpSaveShadowData::~OpSaveShadowData()
03572 {
03573 }
03574
03575
03576
03577
03578
03579
03580
03581
03582
03583
03584
03585
03586 void OpSaveShadowData::GetOpName(String_256 * pString)
03587 {
03588 if (pString && m_OpName != 0)
03589 {
03590 pString->Load(m_OpName);
03591 }
03592 }
03593
03594
03595
03596
03597
03598
03599
03600
03601
03602
03603
03604
03605
03606
03607
03608
03609 BOOL OpSaveShadowData::Declare()
03610 {
03611 return (RegisterOpDescriptor(
03612 0,
03613 _R(IDS_SAVESHADOWDATAOP),
03614 CC_RUNTIME_CLASS(OpSaveShadowData),
03615 OPTOKEN_SAVESHADOWDATA,
03616 OpSaveShadowData::GetState));
03617 }
03618
03619
03620
03621
03622
03623
03624
03625
03626
03627
03628
03629
03630
03631
03632 BOOL OpSaveShadowData::SaveShadowData(UndoableOperation * pOp)
03633 {
03634 Range MyRange(*(GetApplication()->FindSelection()));
03635
03636 RangeControl rg = MyRange.GetRangeControlFlags();
03637 rg.PromoteToParent = TRUE;
03638 MyRange.SetRangeControl(rg);
03639
03640 Spread * pSpread = Document::GetSelectedSpread();
03641
03642 SaveShadowDataAction * pAction = NULL;
03643
03644 if (SaveShadowDataAction::Init(pOp, pOp->GetUndoActionList(), MyRange, &pAction) != AC_OK)
03645 return FALSE;
03646
03647
03648 Node * pNode = MyRange.FindFirst();
03649 DocRect Bounds;
03650
03651 while (pNode)
03652 {
03653 if (pNode->IsAnObject())
03654 {
03655
03656
03657 Bounds = Bounds.Union(((NodeRenderableInk *)pNode)->GetBlobBoundingRect());
03658 }
03659
03660 pNode = MyRange.FindNext(pNode);
03661 }
03662
03663 BlobManager * pBlobMgr = GetApplication()->GetBlobManager();
03664
03665 if (pBlobMgr)
03666 {
03667 Bounds.Inflate(pBlobMgr->GetBlobSize());
03668 }
03669
03670 if (pSpread)
03671 {
03672 if (!pOp->DoInvalidateRegion(pSpread, Bounds))
03673 {
03674 return FALSE;
03675 }
03676 }
03677
03678 return TRUE;
03679 }
03680
03681
03682
03683
03684
03685
03686
03687
03688
03689
03690
03691
03692
03693
03694 void OpSaveShadowData::DoWithParam(OpDescriptor* pOp, OpParam * pParam)
03695 {
03696
03697 BeginSlowJob();
03698 DoStartSelOp(TRUE);
03699
03700 m_OpName = ((SaveShadowDataInfo *)pParam)->ID;
03701
03702 if (!SaveShadowData(this))
03703 {
03704 ERROR2RAW("Can't save shadow data");
03705 }
03706
03707 End();
03708 }
03709
03710
03711
03712
03713
03714
03715
03716
03717
03718
03719
03720
03721
03722 OpState OpSaveShadowData::GetState(String_256* Description, OpDescriptor*)
03723 {
03724 OpState Blobby;
03725
03726 return Blobby;
03727 }
03728
03729
03730
03731
03732
03733
03734
03735
03736
03737
03738
03739
03740
03741
03742
03743
03744
03745
03746
03747
03748
03749
03750 ChangeGlowWidthAction::ChangeGlowWidthAction()
03751 {
03752 m_pNodeShadowCont = NULL;
03753 m_LastWidth = 0;
03754 }
03755
03756
03757
03758
03759
03760
03761
03762
03763
03764
03765
03766
03767
03768
03769
03770
03771
03772
03773
03774
03775
03776
03777
03778
03779
03780
03781
03782
03783
03784
03785
03786
03787
03788 ActionCode ChangeGlowWidthAction::Init(Operation* pOp,
03789 ActionList* pActionList,
03790 NodeShadowController* pThisNodeShadow,
03791 INT32 NewWidth,
03792 ChangeGlowWidthAction** ppNewAction,
03793 BOOL bReverse, BOOL bCache)
03794 {
03795 UINT32 ActSize = sizeof(ChangeGlowWidthAction);
03796
03797 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,
03798 CC_RUNTIME_CLASS(ChangeGlowWidthAction),
03799 (Action**)ppNewAction);
03800
03801
03802 Document * pDoc = Document::GetCurrent();
03803
03804 DocRect dr;
03805
03806 if (Ac != AC_FAIL)
03807 {
03808
03809
03810 if (bReverse)
03811 {
03812 pActionList->RemoveItem(*ppNewAction);
03813 pActionList->AddHead(*ppNewAction);
03814 }
03815
03816 (*ppNewAction)->m_pNodeShadowCont = pThisNodeShadow;
03817 (*ppNewAction)->m_LastWidth = pThisNodeShadow->GetGlowWidth();
03818 (*ppNewAction)->m_bCache = bCache;
03819
03820
03821 pThisNodeShadow->InvalidateBoundingRect();
03822
03823 dr = pThisNodeShadow->GetBoundingRect();
03824 TRACEUSER( "DavidM", _T("Rect before %d %d %d %d\n"),
03825 dr.lo.x, dr.lo.y, dr.hi.x, dr.hi.y);
03826
03827 pDoc->ForceRedraw(pThisNodeShadow->GetShadow()->FindParentSpread(),
03828 pThisNodeShadow->GetShadow()->GetBoundingRect(), FALSE, pThisNodeShadow);
03829
03830 pThisNodeShadow->SetGlowWidth(NewWidth);
03831
03832 pThisNodeShadow->RegenerateNode(NULL, bCache);
03833
03834 pThisNodeShadow->InvalidateBoundingRect();
03835
03836 dr= pThisNodeShadow->GetBoundingRect();
03837 TRACEUSER( "DavidM", _T("Rect after %d %d %d %d\n"),
03838 dr.lo.x, dr.lo.y, dr.hi.x, dr.hi.y);
03839
03840 pDoc->ForceRedraw(pThisNodeShadow->GetShadow()->FindParentSpread(),
03841 pThisNodeShadow->GetShadow()->GetBoundingRect(), FALSE, pThisNodeShadow);
03842 }
03843
03844 return Ac;
03845 }
03846
03847
03848
03849
03850
03851
03852
03853
03854
03855
03856
03857
03858
03859
03860
03861
03862
03863 ActionCode ChangeGlowWidthAction::Execute()
03864 {
03865 ActionCode Act;
03866 ChangeGlowWidthAction* pAction;
03867
03868
03869 DocRect dr = m_LastRect;
03870
03871 Act = ChangeGlowWidthAction::Init( pOperation,
03872 pOppositeActLst,
03873 m_pNodeShadowCont,
03874 m_LastWidth,
03875 &pAction,
03876 TRUE,
03877 m_bCache);
03878
03879 if (Act != AC_FAIL)
03880 {
03881 Document * pDoc = Document::GetCurrent();
03882
03883 if (pDoc)
03884 {
03885 m_LastRect = m_pNodeShadowCont->GetBoundingRect();
03886
03887 pDoc->ForceRedraw(m_pNodeShadowCont->FindParentSpread(),
03888 m_LastRect, FALSE, m_pNodeShadowCont);
03889 }
03890 }
03891
03892 return Act;
03893 }
03894
03895 ChangeGlowWidthAction::~ChangeGlowWidthAction()
03896 {
03897 }
03898
03903
03904
03905
03906
03907
03908
03909
03910
03911
03912
03913
03914
03915
03916 OpGlowWidth::OpGlowWidth()
03917 {
03918 }
03919
03920
03921
03922
03923
03924
03925
03926
03927
03928
03929
03930
03931 OpGlowWidth::~OpGlowWidth()
03932 {
03933 }
03934
03935
03936
03937
03938
03939
03940
03941
03942
03943
03944
03945
03946
03947
03948
03949 BOOL OpGlowWidth::Declare()
03950 {
03951 return (RegisterOpDescriptor(
03952 0,
03953 _R(IDS_GLOWWIDTHOP),
03954 CC_RUNTIME_CLASS(OpGlowWidth),
03955 OPTOKEN_GLOWWIDTH,
03956 OpGlowWidth::GetState));
03957 }
03958
03959
03960
03961
03962
03963
03964
03965
03966
03967
03968
03969
03970
03971 void OpGlowWidth::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
03972 {
03973
03974 BeginSlowJob();
03975 DoStartSelOp(TRUE);
03976
03977 NodeShadowParam * pNSParam = (NodeShadowParam *)pParam;
03978
03979 ENSURE(pNSParam->pShadowTool, "Op not given pointer to shadow tool");
03980 Range* pShadowRange = pNSParam->pShadowTool->GetShadowEditRange();
03981 Node* pNode = pShadowRange->FindFirst();
03982 if (pNode==NULL)
03983 {
03984 ERROR3("Nothing was selected in OpShadowPenumbra");
03985 FailAndExecute();
03986 End();
03987 return;
03988 }
03989 while (pNode)
03990 {
03991 ENSURE(pNode->IsAShadowController(), "Found unexpected node type");
03992 NodeShadowController* pController = (NodeShadowController*)pNode;
03993
03994
03995
03996 pController->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
03997 DoInvalidateNodeRegion(pController, TRUE, FALSE, FALSE, FALSE);
03998
03999 ChangeGlowWidthAction * pAction = NULL;
04000
04001 ChangeGlowWidthAction::Init(this, GetUndoActionList(), pController,
04002 pNSParam->m_GlowWidth, &pAction);
04003
04004
04005 ObjChangeFlags flgs(FALSE, FALSE, FALSE, TRUE);
04006 ObjChangeParam OP(OBJCHANGE_FINISHED, flgs, pController, this, OBJCHANGE_CALLEDBYOP);
04007 Node * pNodeParent = pController->FindParent();
04008
04009 while (pNodeParent)
04010 {
04011 pNodeParent->OnChildChange(&OP);
04012
04013 pNodeParent = pNodeParent->FindParent();
04014 }
04015
04016
04017
04018 pController->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
04019 DoInvalidateNodeRegion(pController, TRUE, FALSE, FALSE, FALSE);
04020
04021 pNode = pShadowRange->FindNext(pNode);
04022 }
04023
04024 End();
04025 }
04026
04027
04028
04029
04030
04031
04032
04033
04034
04035
04036
04037
04038
04039 OpState OpGlowWidth::GetState(String_256* Description, OpDescriptor*)
04040 {
04041 OpState Blobby;
04042
04043 return Blobby;
04044 }
04045
04050
04051
04052
04053
04054
04055
04056
04057
04058
04059
04060
04061
04062
04063 OpChangeShadowProfile::OpChangeShadowProfile()
04064 {
04065 }
04066
04067
04068
04069
04070
04071
04072
04073
04074
04075
04076
04077
04078 OpChangeShadowProfile::~OpChangeShadowProfile()
04079 {
04080 }
04081
04082
04083
04084
04085
04086
04087
04088
04089
04090
04091
04092
04093
04094
04095
04096 BOOL OpChangeShadowProfile::Declare()
04097 {
04098 return (RegisterOpDescriptor(
04099 0,
04100 _R(IDS_SHADOWPROFILE),
04101 CC_RUNTIME_CLASS(OpChangeShadowProfile),
04102 OPTOKEN_SHADOWPROFILE,
04103 OpChangeShadowProfile::GetState));
04104 }
04105
04106
04107
04108
04109
04110
04111
04112
04113
04114
04115
04116
04117
04118 void OpChangeShadowProfile::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
04119 {
04120
04121 BeginSlowJob();
04122 DoStartSelOp(TRUE);
04123
04124
04125 CProfileBiasGain Profile;
04126
04127
04128 ShadowProfileOpParam * pProfileParam = (ShadowProfileOpParam *)pParam;
04129
04130 CProfileBiasGain OldGain;
04131
04132 ENSURE(pProfileParam->m_pTool, "Op not given pointer to shadow tool");
04133 Range* pShadowRange = pProfileParam->m_pTool->GetShadowEditRange();
04134 Node* pNode = pShadowRange->FindFirst();
04135
04136
04137
04138
04139 if (pNode==NULL)
04140 {
04141 FailAndExecute();
04142 End();
04143 return;
04144 }
04145
04146 while (pNode)
04147 {
04148 ENSURE(pNode->IsAShadowController(), "Found unexpected node type");
04149 NodeShadowController* pController = (NodeShadowController*)pNode;
04150 NodeShadow* pShadow = pController->GetShadow();
04151
04152
04153 ChangeProfileAction * pAction;
04154 ChangeProfileAction::Init(this, GetUndoActionList(), pShadow, pProfileParam->Profile, &pAction);
04155
04156 pNode = pShadowRange->FindNext(pNode);
04157 }
04158
04159 End();
04160 }
04161
04162
04163
04164
04165
04166
04167
04168
04169
04170
04171
04172
04173
04174 OpState OpChangeShadowProfile::GetState(String_256* Description, OpDescriptor*)
04175 {
04176 OpState Blobby;
04177
04178 return Blobby;
04179 }
04180
04181
04182
04183
04184
04185
04186
04187
04188
04189
04190
04191
04192
04193
04194
04195
04196
04197
04198
04199
04200
04201 ChangeProfileAction::ChangeProfileAction()
04202 {
04203 m_pNodeShadow = NULL;
04204 }
04205
04206
04207
04208
04209
04210
04211
04212
04213
04214
04215
04216
04217
04218
04219
04220
04221
04222
04223
04224
04225
04226
04227
04228
04229
04230
04231
04232
04233
04234
04235
04236
04237
04238 ActionCode ChangeProfileAction::Init( Operation* pOp,
04239 ActionList* pActionList,
04240 NodeShadow* pThisNodeShadow,
04241 CProfileBiasGain &Profile,
04242 ChangeProfileAction** ppNewAction,
04243 BOOL bReverse,
04244 BOOL bCache)
04245 {
04246 UINT32 ActSize = sizeof(ChangeProfileAction);
04247
04248 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,
04249 CC_RUNTIME_CLASS(ChangeProfileAction),
04250 (Action**)ppNewAction);
04251
04252 Document * pDoc = Document::GetCurrent();
04253
04254 DocRect dr;
04255
04256 if (Ac != AC_FAIL)
04257 {
04258
04259
04260 if (bReverse)
04261 {
04262 pActionList->RemoveItem(*ppNewAction);
04263 pActionList->AddHead(*ppNewAction);
04264 }
04265
04266 (*ppNewAction)->m_pNodeShadow = pThisNodeShadow;
04267 (*ppNewAction)->m_LastProfile = pThisNodeShadow->GetBiasGain();
04268
04269
04270 pThisNodeShadow->InvalidateBoundingRect();
04271
04272 pDoc->ForceRedraw(pThisNodeShadow->FindParentSpread(),
04273 pThisNodeShadow->GetBoundingRect(), FALSE, pThisNodeShadow);
04274
04275 pThisNodeShadow->SetBiasGain(Profile);
04276
04277 ((NodeShadowController*)pThisNodeShadow->GetParentController())->RegenerateNode(NULL, bCache);
04278
04279 pThisNodeShadow->InvalidateBoundingRect();
04280
04281 dr= ((NodeShadowController*)pThisNodeShadow->GetParentController())->GetBoundingRect();
04282 TRACEUSER( "DavidM", _T("Rect after %d %d %d %d\n"),
04283 dr.lo.x, dr.lo.y, dr.hi.x, dr.hi.y);
04284
04285 pDoc->ForceRedraw(pThisNodeShadow->FindParentSpread(),
04286 pThisNodeShadow->GetBoundingRect(), FALSE, pThisNodeShadow);
04287 }
04288
04289 return Ac;
04290 }
04291
04292
04293
04294
04295
04296
04297
04298
04299
04300
04301
04302
04303
04304
04305
04306
04307
04308
04309
04310
04311 void ChangeProfileAction::ChangeShadowProfileWithNoUndo (CProfileBiasGain &Profile, SoftShadowTool* pShadowTool)
04312 {
04313
04314 BeginSlowJob();
04315
04316
04317 CProfileBiasGain OldGain;
04318
04319 Document * pDoc = Document::GetCurrent();
04320
04321 ENSURE(pShadowTool, "Op not given pointer to shadow tool");
04322 Range* pShadowRange = pShadowTool->GetShadowEditRange();
04323 Node* pNode = pShadowRange->FindFirst();
04324 while (pNode)
04325 {
04326 ENSURE(pNode->IsAShadowController(), "Found unexpected node type");
04327 NodeShadowController* pController = (NodeShadowController*)pNode;
04328 NodeShadow* pThisNodeShadow = pController->GetShadow();
04329
04330 pThisNodeShadow->SetBiasGain(Profile);
04331
04332 pController->RegenerateNode(NULL, FALSE);
04333
04334 pThisNodeShadow->InvalidateBoundingRect();
04335
04336 pDoc->ForceRedraw(pThisNodeShadow->FindParentSpread(),
04337 pThisNodeShadow->GetBoundingRect(), FALSE, pThisNodeShadow);
04338
04339 pNode = pShadowRange->FindNext(pNode);
04340 }
04341
04342 EndSlowJob ();
04343
04344 if (pDoc->GetOpHistory ().CanRedo ())
04345 {
04346
04347 pDoc->GetOpHistory ().DeleteRedoableOps ();
04348
04349
04350 DialogBarOp::SetSystemStateChanged();
04351 DialogBarOp::UpdateStateOfAllBars();
04352 }
04353 }
04354
04355
04356
04357
04358
04359
04360
04361
04362
04363
04364
04365
04366
04367
04368
04369
04370
04371 ActionCode ChangeProfileAction::Execute()
04372 {
04373 ActionCode Act;
04374 ChangeProfileAction* pAction;
04375
04376 Act = ChangeProfileAction::Init( pOperation,
04377 pOppositeActLst,
04378 m_pNodeShadow,
04379 m_LastProfile,
04380 &pAction,
04381 TRUE,
04382 FALSE);
04383
04384 NodeCompound* pController = m_pNodeShadow->GetParentController();
04385
04386 if (Act != AC_FAIL)
04387 {
04388 Document * pDoc = Document::GetCurrent();
04389
04390 if (pDoc)
04391 {
04392 DocRect dr = pController->GetBoundingRect();
04393
04394 pDoc->ForceRedraw(pController->FindParentSpread(),
04395 dr, FALSE, pController);
04396 }
04397 }
04398
04399 return Act;
04400 }
04401
04402 ChangeProfileAction::~ChangeProfileAction()
04403 {
04404 }
04405
04410
04411
04412
04413
04414
04415
04416
04417
04418
04419
04420
04421
04422
04423 OpChangeShadowDarkness::OpChangeShadowDarkness()
04424 {
04425 }
04426
04427
04428
04429
04430
04431
04432
04433
04434
04435
04436
04437
04438 OpChangeShadowDarkness::~OpChangeShadowDarkness()
04439 {
04440 }
04441
04442
04443
04444
04445
04446
04447
04448
04449
04450
04451
04452
04453
04454
04455
04456 BOOL OpChangeShadowDarkness::Declare()
04457 {
04458 return (RegisterOpDescriptor(
04459 0,
04460 _R(IDS_SHADOWDARKNESS),
04461 CC_RUNTIME_CLASS(OpChangeShadowDarkness),
04462 OPTOKEN_SHADOWDARKNESS,
04463 OpChangeShadowDarkness::GetState));
04464 }
04465
04466
04467
04468
04469
04470
04471
04472
04473
04474
04475
04476
04477
04478 void OpChangeShadowDarkness::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
04479 {
04480
04481 BeginSlowJob();
04482 DoStartSelOp(TRUE);
04483
04484
04485 ShadowDarknessOpParam * pDarknessParam = (ShadowDarknessOpParam *)pParam;
04486
04487 ENSURE(pDarknessParam->m_pTool, "Op not given pointer to shadow tool");
04488 Range* pShadowRange = pDarknessParam->m_pTool->GetShadowEditRange();
04489 Node* pNode = pShadowRange->FindFirst();
04490 if (pNode==NULL)
04491 {
04492 ERROR3("Nothing was selected in OpChangeShadowDarkness");
04493 FailAndExecute();
04494 End();
04495 return;
04496 }
04497 while (pNode)
04498 {
04499 ENSURE(pNode->IsAShadowController(), "Found unexpected node type");
04500 NodeShadowController* pController = (NodeShadowController*)pNode;
04501 NodeShadow* pShadow = pController->GetShadow();
04502
04503
04504 ChangeShadowDarknessAction * pAction = NULL;
04505
04506 if (ChangeShadowDarknessAction::Init(this, this->GetUndoActionList(), pShadow,
04507 pDarknessParam->m_dDarkness, &pAction, FALSE, FALSE) != AC_OK)
04508 {
04509 FailAndExecute();
04510 End();
04511 return;
04512 }
04513
04514 pController->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
04515
04516 if (!DoInvalidateNodeRegion(pController, TRUE, FALSE, FALSE, FALSE))
04517 {
04518 FailAndExecute();
04519 End();
04520 return;
04521 }
04522
04523
04524
04525 ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
04526 flgs.RegenerateNode = TRUE;
04527 ObjChangeParam OP(OBJCHANGE_FINISHED, flgs, pController, this, OBJCHANGE_CALLEDBYCHILD);
04528
04529 Node *pParent = pController->FindParent();
04530 while (pParent)
04531 {
04532 pParent->OnChildChange(&OP);
04533 pParent = pParent->FindParent();
04534 }
04535
04536
04537 pNode = pShadowRange->FindNext(pNode);
04538 }
04539
04540 End();
04541 }
04542
04543
04544
04545
04546
04547
04548
04549
04550
04551
04552
04553
04554
04555 OpState OpChangeShadowDarkness::GetState(String_256* Description, OpDescriptor*)
04556 {
04557 OpState Blobby;
04558
04559 return Blobby;
04560 }
04561
04562
04563
04564
04565
04566
04567
04568
04569
04570
04571
04572
04573
04574
04575
04576
04577
04578
04579
04580
04581
04582 ChangeShadowDarknessAction::ChangeShadowDarknessAction()
04583 {
04584 m_pNodeShadow = NULL;
04585 }
04586
04587
04588
04589
04590
04591
04592
04593
04594
04595
04596
04597
04598
04599
04600
04601
04602
04603
04604
04605
04606
04607
04608
04609
04610
04611
04612
04613
04614
04615
04616
04617
04618
04619
04620
04621 ActionCode ChangeShadowDarknessAction::Init( Operation* pOp,
04622 ActionList* pActionList,
04623 NodeShadow* pThisNodeShadow,
04624 double dDarkness,
04625 ChangeShadowDarknessAction** NewAction,
04626 BOOL bReverse,
04627 BOOL bCache)
04628 {
04629 UINT32 ActSize = sizeof(ChangeShadowDarknessAction);
04630
04631 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,
04632 CC_RUNTIME_CLASS(ChangeShadowDarknessAction),
04633 (Action**)NewAction);
04634
04635 Document * pDoc = Document::GetCurrent();
04636
04637 DocRect dr;
04638
04639 if (Ac != AC_FAIL)
04640 {
04641 (*NewAction)->m_pNodeShadow = pThisNodeShadow;
04642
04643 double dOldDarkness = pThisNodeShadow->GetDarkness();
04644
04645 (*NewAction)->m_dLastDarkness = dOldDarkness;
04646
04647
04648 pThisNodeShadow->InvalidateBoundingRect();
04649
04650 pDoc->ForceRedraw(pThisNodeShadow->FindParentSpread(),
04651 pThisNodeShadow->GetBoundingRect(), FALSE, pThisNodeShadow);
04652
04653 pThisNodeShadow->SetDarkness(dDarkness);
04654
04655 pThisNodeShadow->InvalidateBoundingRect();
04656
04657 dr = pThisNodeShadow->GetParentController()->GetBoundingRect();
04658
04659 pDoc->ForceRedraw(pThisNodeShadow->FindParentSpread(),
04660 pThisNodeShadow->GetBoundingRect(), FALSE, pThisNodeShadow);
04661 }
04662
04663 return Ac;
04664 }
04665
04666
04667
04668
04669
04670
04671
04672
04673
04674
04675
04676
04677
04678
04679
04680
04681
04682 ActionCode ChangeShadowDarknessAction::Execute()
04683 {
04684 ActionCode Act;
04685 ChangeShadowDarknessAction* pAction;
04686
04687 Act = ChangeShadowDarknessAction::Init( pOperation,
04688 pOppositeActLst,
04689 m_pNodeShadow,
04690 m_dLastDarkness,
04691 &pAction,
04692 TRUE,
04693 FALSE);
04694
04695 NodeCompound* pController = m_pNodeShadow->GetParentController();
04696
04697 if (Act != AC_FAIL)
04698 {
04699 Document * pDoc = Document::GetCurrent();
04700
04701 if (pDoc)
04702 {
04703 DocRect dr = pController->GetBoundingRect();
04704
04705 pDoc->ForceRedraw(pController->FindParentSpread(),
04706 dr, FALSE, pController);
04707 }
04708 }
04709
04710 return Act;
04711 }
04712
04713 ChangeShadowDarknessAction::~ChangeShadowDarknessAction()
04714 {
04715 }
04716
04717
04718
04719
04720
04721
04722
04723
04724
04725
04726 #endif // BUILDSHADOWS