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 "opbevel.h"
00106
00107 #include "nodebmp.h"
00108
00109 #ifdef BUILDSHADOWS
00110
00111
00112
00113
00114
00115 #include "attrbev.h"
00116 #include "nodebev.h"
00117 #include "progress.h"
00118 #include "objchge.h"
00119
00120
00121
00122
00123
00124
00125 #include "nodetxts.h"
00126 #include "nodetxtl.h"
00127 #include "nodeblnd.h"
00128 #include "nodebldr.h"
00129 #include "nodemold.h"
00130 #include "mkshapes.h"
00131 #include "groupops.h"
00132
00133 #include "lineattr.h"
00134 #include "bevtool.h"
00135
00136
00137 #include "nodecont.h"
00138 #include "nodeshad.h"
00139 #include "opshadow.h"
00140 #include "textops.h"
00141
00142 #include "csrstack.h"
00143 #include "nodetxts.h"
00144 #include "nodeblnd.h"
00145 #include "ncntrcnt.h"
00146 #include "ndmldpth.h"
00147 #include "slicehelper.h"
00148 #include "opliveeffects.h"
00149 #include "nodeliveeffect.h"
00150 #include "ophist.h"
00151 #include "nbevcont.h"
00152 #include "nodetext.h"
00153
00154
00155
00156
00157
00158 DECLARE_SOURCE( "$Revision: 1752 $" );
00159
00160 CC_IMPLEMENT_DYNCREATE(OpCreateBevel, SelOperation)
00161 CC_IMPLEMENT_DYNCREATE(OpRemoveBevel, SelOperation)
00162 CC_IMPLEMENT_DYNCREATE(OpChangeBevelLightAngle, SelOperation)
00163 CC_IMPLEMENT_DYNCREATE(OpSelectBevel, Operation)
00164 CC_IMPLEMENT_DYNCREATE(BevelInfo, OpParam)
00165 CC_IMPLEMENT_DYNCREATE(RegenerateBevelAction, Action)
00166 CC_IMPLEMENT_DYNCREATE(RegenerateBevelBitmapAction, Action)
00167 CC_IMPLEMENT_DYNCREATE(ChangeLightAnglesAction, Action)
00168 CC_IMPLEMENT_DYNCREATE(RemoveBevelAttributesAction, Action)
00169
00170 #define new CAM_DEBUG_NEW
00171
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187 BOOL BevelTools::BuildListOfSelectedNodes(List *pList, const CCRuntimeClass * pClass,
00188 BOOL bPromoteToParents)
00189 {
00190 if (!pList || GetApplication()->FindSelection() == NULL)
00191 return FALSE;
00192
00193
00194 Range Sel(*(GetApplication()->FindSelection()));
00195 RangeControl rg = Sel.GetRangeControlFlags();
00196 rg.PromoteToParent = bPromoteToParents;
00197 Sel.Range::SetRangeControl(rg);
00198
00199 if (GetApplication()->FindSelection()->IsEmpty())
00200 return FALSE;
00201
00202 Node * pNode = Sel.FindFirst(FALSE);
00203
00204
00205
00206 while (pNode)
00207 {
00208 GetAllNodesUnderNode(pNode, pList, pClass);
00209
00210 pNode = Sel.FindNext(pNode, FALSE);
00211 }
00212
00213 if (pList->IsEmpty())
00214 return FALSE;
00215
00216 return TRUE;
00217 }
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233 BOOL BevelTools::GetAllNodesUnderNode(const Node * pNode, List * pList,
00234 const CCRuntimeClass * pClass, INT32 depth)
00235 {
00236 if (!pNode || !pList)
00237 return FALSE;
00238
00239
00240 if (pNode->IsBitmapEffect() && ((NodeBitmapEffect*)pNode)->IsLockedEffect())
00241 return TRUE;
00242
00243 const Node * pStartNode = pNode;
00244
00245 Node * pCurNode = pNode->FindFirstChild();
00246
00247
00248 NodeListItem * pItem = NULL;
00249
00250 if (!pCurNode)
00251 {
00252
00253 if (pStartNode->IsKindOf(pClass) && depth == 0 && !IsNodeInList(pList, pStartNode))
00254 {
00255 pItem = new NodeListItem;
00256
00257 if (pItem)
00258 {
00259 pItem->pNode = (Node *)pStartNode;
00260 pList->AddTail(pItem);
00261
00262 return TRUE;
00263 }
00264 }
00265
00266 return FALSE;
00267 }
00268
00269
00270 while (pCurNode)
00271 {
00272
00273 GetAllNodesUnderNode(pCurNode, pList, pClass, depth + 1);
00274
00275
00276 if (pCurNode->IsKindOf(pClass) && pCurNode->FindParent() &&
00277 !pCurNode->IsNodeHidden() && !IsNodeInList(pList, pCurNode))
00278 {
00279 pItem = new NodeListItem;
00280
00281 if (!pItem)
00282 {
00283 ERROR3("Can't create NodeListItem");
00284 return FALSE;
00285 }
00286
00287 pItem->pNode = pCurNode;
00288 pList->AddTail(pItem);
00289 }
00290
00291
00292 pCurNode = pCurNode->FindNext();
00293 }
00294
00295
00296 if (pStartNode->IsKindOf(pClass) && pStartNode->FindParent() &&
00297 !pStartNode->IsNodeHidden() && !IsNodeInList(pList, pStartNode))
00298 {
00299 pItem = new NodeListItem;
00300
00301 if (!pItem)
00302 {
00303 ERROR3("Can't create NodeListItem");
00304 return FALSE;
00305 }
00306
00307 pItem->pNode = (Node *)pStartNode;
00308 pList->AddTail(pItem);
00309 }
00310
00311 return TRUE;
00312 }
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323 BOOL BevelTools::IsNodeInList(List * pList, const Node * pNode)
00324 {
00325 NodeListItem * pItem = (NodeListItem * )pList->GetHead();
00326
00327 while (pItem)
00328 {
00329 if (pItem->pNode == pNode)
00330 return TRUE;
00331
00332 pItem = (NodeListItem * )pList->GetNext(pItem);
00333 }
00334
00335 return FALSE;
00336 }
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347 BOOL BevelTools::HasSelectedChild(NodeRenderableInk * pNode)
00348 {
00349 NodeRenderableInk * pStepNode = (NodeRenderableInk *)pNode->FindFirstDepthFirst();
00350
00351 while (pStepNode)
00352 {
00353 if (pStepNode->IsSelected() && pStepNode != pNode)
00354 {
00355 return TRUE;
00356 }
00357
00358 pStepNode = (NodeRenderableInk *)pStepNode->FindNextDepthFirst(pNode);
00359 }
00360
00361 return FALSE;
00362 }
00363
00364
00365
00366
00367
00368
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381 OpCreateBevel::OpCreateBevel()
00382 {
00383
00384 m_NameID = 0;
00385 }
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395 void OpCreateBevel::GetOpName(String_256 * pString)
00396 {
00397 if (pString && m_NameID != 0)
00398 pString->Load(m_NameID);
00399 }
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409 OpCreateBevel::~OpCreateBevel()
00410 {
00411
00412 }
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425 void OpCreateBevel::Do(OpDescriptor *pOpDesc)
00426 {
00427 }
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440 void OpCreateBevel::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
00441 {
00442 if (!pParam || !pOp)
00443 return;
00444
00445
00446 BevelInfo *pBevelInfo = (BevelInfo *)pParam;
00447
00448 if (pBevelInfo->m_Indent <= 0)
00449 {
00450
00451 return ;
00452 }
00453
00454 if (GetApplication()->FindSelection() == NULL)
00455 return;
00456
00457
00458 Node * pNextNode = NULL;
00459 NodeBevelController * pBevelControl = NULL;
00460
00461
00462 NodeHidden * pNodeHidden = NULL;
00463 Node * pCurrentNode = NULL;
00464
00465
00466 DocRect LastRect;
00467
00468
00469
00470
00471
00472
00473
00474
00475 Range * pSel = GetApplication()->FindSelection();
00476
00477 if (pSel->IsEmpty())
00478 return;
00479
00480
00481 BeginSlowJob();
00482 DoStartSelOp(TRUE, TRUE);
00483
00484 List BevelNodeList;
00485
00486
00487 BevelTools::BuildListOfSelectedNodes(&BevelNodeList, CC_RUNTIME_CLASS(NodeBevelController));
00488
00489 NodeListItem *pNodeListItem = (NodeListItem *)BevelNodeList.GetHead();
00490
00491 AttrBevelIndent* pAttrIndent = NULL;
00492 AttrBevelType* pAttrType = NULL;
00493 AttrBevelContrast* pAttrContrast = NULL;
00494 AttrBevelLightAngle* pAttrLightAngle = NULL;
00495 AttrBevelLightTilt* pAttrLightTilt = NULL;
00496 AttrJoinType* pAttrJointType = NULL;
00497
00498 HideNodeAction *pAction = NULL;
00499
00500 m_NameID = 0;
00501
00502 while (pNodeListItem)
00503 {
00504
00505 pBevelControl = (NodeBevelController *)pNodeListItem->pNode;
00506
00507
00508 if (!pBevelControl)
00509 {
00510 ERROR3("Can't find bevel control");
00511 BevelNodeList.DeleteAll();
00512 FailAndExecute();
00513 End();
00514 return;
00515 }
00516
00517
00518 pBevelControl->ReleaseCached();
00519 if (!DoInvalidateRegion(pBevelControl->FindParentSpread(),
00520 pBevelControl->GetBoundingRect(TRUE, FALSE)))
00521 {
00522 FailAndExecute();
00523 End();
00524 BevelNodeList.DeleteAll();
00525 return;
00526 }
00527
00528
00529
00530 if (pBevelInfo->m_bBevelIndentChanged || pBevelInfo->m_bBevelDirectionChanged)
00531 {
00532 if (pBevelControl->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelIndent),
00533 (NodeAttribute **)&pAttrIndent))
00534 {
00535 if (pAttrIndent)
00536 {
00537 if (pAttrIndent->IsADefaultAttr())
00538 {
00539 ALLOC_WITH_FAIL(pAttrIndent,
00540 new AttrBevelIndent(pBevelControl, FIRSTCHILD), this);
00541 pAttrIndent->Value.m_Indent = pBevelControl->m_Indent;
00542
00543 if (pBevelControl->m_bOuter)
00544 {
00545 pAttrIndent->Value.m_Indent = -pBevelControl->m_Indent;
00546 }
00547
00548 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pAttrIndent,
00549 FALSE, (Action **)&pAction, FALSE) != AC_OK)
00550 {
00551 FailAndExecute();
00552 End();
00553 BevelNodeList.DeleteAll();
00554 return;
00555 }
00556 }
00557 }
00558 }
00559 }
00560
00561 if (pBevelInfo->m_bBevelTypeChanged)
00562 {
00563 if (pBevelControl->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelType),
00564 (NodeAttribute **)&pAttrType))
00565 {
00566 if (pAttrType)
00567 {
00568 if (pAttrType->IsADefaultAttr())
00569 {
00570 ALLOC_WITH_FAIL(pAttrType,
00571 new AttrBevelType(pBevelControl, FIRSTCHILD), this);
00572 pAttrType->Value.m_Type = pBevelControl->m_BevelType;
00573
00574 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pAttrType,
00575 FALSE, (Action **)&pAction, FALSE) != AC_OK)
00576 {
00577 FailAndExecute();
00578 End();
00579 BevelNodeList.DeleteAll();
00580 return;
00581 }
00582 }
00583 }
00584 }
00585 }
00586
00587 if (pBevelInfo->m_bBevelLightAngleChanged)
00588 {
00589 if (pBevelControl->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelLightAngle),
00590 (NodeAttribute **)&pAttrLightAngle))
00591 {
00592 if (pAttrLightAngle)
00593 {
00594 if (pAttrLightAngle->IsADefaultAttr())
00595 {
00596 ALLOC_WITH_FAIL(pAttrLightAngle,
00597 new AttrBevelLightAngle(pBevelControl, FIRSTCHILD), this);
00598 pAttrLightAngle->Value.m_LightAngle = (INT32)pBevelControl->m_LightAngle;
00599
00600 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pAttrLightAngle,
00601 FALSE, (Action **)&pAction, FALSE) != AC_OK)
00602 {
00603 FailAndExecute();
00604 End();
00605 BevelNodeList.DeleteAll();
00606 return;
00607 }
00608 }
00609 }
00610 }
00611 }
00612
00613 if (pBevelInfo->m_bBevelLightTiltChanged)
00614 {
00615 if (pBevelControl->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelLightTilt),
00616 (NodeAttribute **)&pAttrLightTilt))
00617 {
00618 if (pAttrLightTilt)
00619 {
00620 if (pAttrLightTilt->IsADefaultAttr())
00621 {
00622 ALLOC_WITH_FAIL(pAttrLightTilt,
00623 new AttrBevelLightTilt(pBevelControl, FIRSTCHILD), this);
00624 pAttrLightTilt->Value.m_LightTilt = (INT32)pBevelControl->m_Tilt;
00625
00626 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pAttrLightTilt,
00627 FALSE, (Action **)&pAction, FALSE) != AC_OK)
00628 {
00629 FailAndExecute();
00630 End();
00631 BevelNodeList.DeleteAll();
00632 return;
00633 }
00634 }
00635 }
00636 }
00637 }
00638
00639
00640 if (pBevelInfo->m_bBevelContrastChanged)
00641 {
00642 if (pBevelControl->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelContrast),
00643 (NodeAttribute **)&pAttrContrast))
00644 {
00645 if (pAttrContrast)
00646 {
00647 if (pAttrContrast->IsADefaultAttr())
00648 {
00649 ALLOC_WITH_FAIL(pAttrContrast,
00650 new AttrBevelContrast(pBevelControl, FIRSTCHILD), this);
00651 pAttrContrast->Value.m_Contrast = pBevelControl->m_Contrast;
00652
00653 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pAttrContrast,
00654 FALSE, (Action **)&pAction, FALSE) != AC_OK)
00655 {
00656 FailAndExecute();
00657 End();
00658 BevelNodeList.DeleteAll();
00659 return;
00660 }
00661 }
00662 }
00663 }
00664 }
00665
00666
00667
00668 if (!DoLocaliseCommonAttributes(pBevelControl, TRUE, TRUE))
00669 {
00670 FailAndExecute();
00671 End();
00672 BevelNodeList.DeleteAll();
00673 return;
00674 }
00675
00676 BOOL bGenerateNode = FALSE;
00677
00678 pCurrentNode = pBevelControl->FindFirstDepthFirst();
00679
00680 while (pCurrentNode)
00681 {
00682 pNextNode = pCurrentNode->FindNextDepthFirst(pBevelControl);
00683
00684
00685
00686 if (pCurrentNode->IS_KIND_OF(AttrBevelIndent) && pBevelInfo->m_bBevelIndentChanged)
00687 {
00688 bGenerateNode = TRUE;
00689 ALLOC_WITH_FAIL(pAttrIndent, (new AttrBevelIndent()), this);
00690
00691
00692 MILLIPOINT Width = abs(pBevelInfo->m_Indent);
00693
00694 if (pBevelInfo->m_bBevelDirectionChanged)
00695 {
00696
00697
00698 if (pBevelInfo->m_bOuter)
00699 {
00700 Width = -Width;
00701 }
00702 }
00703 else
00704 {
00705
00706 if (((AttrBevelIndent *)pCurrentNode)->Value.m_Indent < 0)
00707 {
00708 Width = -Width;
00709 }
00710 }
00711
00712 if (Width > 0)
00713 {
00714
00715 MILLIPOINT MaxValue =
00716 ContourNodePathProcessor::GetMaxInnerContourWidth(pBevelControl);
00717
00718 if (Width > MaxValue)
00719 Width = MaxValue;
00720 }
00721
00722
00723 ((AttrBevelIndent *)pAttrIndent)->Value.m_Indent = Width;
00724
00725
00726 if (!DoHideNode(pCurrentNode, TRUE, &pNodeHidden))
00727 {
00728 FailAndExecute();
00729 End();
00730 BevelNodeList.DeleteAll();
00731 return;
00732 }
00733
00734
00735 pAttrIndent->AttachNode(pNodeHidden, NEXT);
00736
00737
00738 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pAttrIndent,
00739 FALSE, (Action **)&pAction, FALSE) != AC_OK)
00740 {
00741 FailAndExecute();
00742 End();
00743 BevelNodeList.DeleteAll();
00744 return;
00745 }
00746
00747 m_NameID = _R(IDS_CHANGEBEVELINDENTOPNAME);
00748 }
00749 else if (pCurrentNode->IS_KIND_OF(AttrBevelType) && pBevelInfo->m_bBevelTypeChanged)
00750 {
00751 ALLOC_WITH_FAIL(pAttrType, (new AttrBevelType()), this);
00752
00753 ((AttrBevelType *)pAttrType)->Value.m_Type = pBevelInfo->m_BevelType;
00754
00755
00756 if (!DoHideNode(pCurrentNode, TRUE, &pNodeHidden))
00757 {
00758 FailAndExecute();
00759 End();
00760 BevelNodeList.DeleteAll();
00761 return;
00762 }
00763
00764
00765 pAttrType->AttachNode(pNodeHidden, NEXT);
00766
00767
00768 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pAttrType,
00769 FALSE, (Action **)&pAction, FALSE) != AC_OK)
00770 {
00771 FailAndExecute();
00772 End();
00773 BevelNodeList.DeleteAll();
00774 return;
00775 }
00776
00777 m_NameID = _R(IDS_CHANGEBEVELTYPEOPNAME);
00778 }
00779 else if (pCurrentNode->IS_KIND_OF(AttrBevelIndent) && pBevelInfo->m_bBevelDirectionChanged)
00780 {
00781 bGenerateNode = TRUE;
00782 ALLOC_WITH_FAIL(pAttrIndent, (new AttrBevelIndent()), this);
00783
00784 if (pBevelInfo->m_bOuter)
00785 {
00786 ((AttrBevelIndent *)pAttrIndent)->Value.m_Indent =
00787 -abs(((AttrBevelIndent *)pCurrentNode)->Value.m_Indent);
00788 }
00789 else
00790 {
00791 ((AttrBevelIndent *)pAttrIndent)->Value.m_Indent =
00792 abs(((AttrBevelIndent *)pCurrentNode)->Value.m_Indent);
00793
00794
00795 MILLIPOINT MaxValue =
00796 ContourNodePathProcessor::GetMaxInnerContourWidth(pBevelControl);
00797
00798 if (((AttrBevelIndent *)pAttrIndent)->Value.m_Indent > MaxValue)
00799 ((AttrBevelIndent *)pAttrIndent)->Value.m_Indent = MaxValue;
00800 }
00801
00802
00803 if (!DoHideNode(pCurrentNode, TRUE, &pNodeHidden))
00804 {
00805 FailAndExecute();
00806 End();
00807 BevelNodeList.DeleteAll();
00808 return;
00809 }
00810
00811
00812 pAttrIndent->AttachNode(pNodeHidden, NEXT);
00813
00814
00815 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pAttrIndent,
00816 FALSE, (Action **)&pAction, FALSE) != AC_OK)
00817 {
00818 FailAndExecute();
00819 End();
00820 BevelNodeList.DeleteAll();
00821 return;
00822 }
00823
00824 if (pBevelInfo->m_bOuter)
00825 {
00826 m_NameID = _R(IDS_CHANGEBEVELTOOUTEROPNAME);
00827 }
00828 else
00829 {
00830 m_NameID = _R(IDS_CHANGEBEVELTOINNEROPNAME);
00831 }
00832 }
00833 else if (pCurrentNode->IS_KIND_OF(AttrBevelContrast) && pBevelInfo->m_bBevelContrastChanged)
00834 {
00835 ALLOC_WITH_FAIL(pAttrContrast, (new AttrBevelContrast()), this);
00836
00837 pAttrContrast->Value.m_Contrast = pBevelInfo->m_Contrast;
00838
00839
00840 if (!DoHideNode(pCurrentNode, TRUE, &pNodeHidden))
00841 {
00842 FailAndExecute();
00843 End();
00844 BevelNodeList.DeleteAll();
00845 return;
00846 }
00847
00848
00849 pAttrContrast->AttachNode(pNodeHidden, NEXT);
00850
00851
00852 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pAttrContrast,
00853 FALSE, (Action **)&pAction, FALSE) != AC_OK)
00854 {
00855 FailAndExecute();
00856 End();
00857 BevelNodeList.DeleteAll();
00858 return;
00859 }
00860
00861 m_NameID = _R(IDS_CHANGEBEVELCONTRASTOPNAME);
00862 }
00863 else if (pCurrentNode->IS_KIND_OF(AttrBevelLightAngle) && pBevelInfo->m_bBevelLightAngleChanged)
00864 {
00865 ALLOC_WITH_FAIL(pAttrLightAngle, (new AttrBevelLightAngle()), this);
00866
00867 pAttrLightAngle->Value.m_LightAngle = (INT32)pBevelInfo->m_LightAngle;
00868
00869
00870 if (!DoHideNode(pCurrentNode, TRUE, &pNodeHidden))
00871 {
00872 FailAndExecute();
00873 End();
00874 BevelNodeList.DeleteAll();
00875 return;
00876 }
00877
00878
00879 pAttrLightAngle->AttachNode(pNodeHidden, NEXT);
00880
00881
00882 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pAttrLightAngle,
00883 FALSE, (Action **)&pAction, FALSE) != AC_OK)
00884 {
00885 FailAndExecute();
00886 End();
00887 BevelNodeList.DeleteAll();
00888 return;
00889 }
00890
00891 m_NameID = _R(IDS_CHANGEBEVELLIGHTANGLEOPNAME);
00892 }
00893 else if (pCurrentNode->IS_KIND_OF(AttrBevelLightTilt) && pBevelInfo->m_bBevelLightTiltChanged)
00894 {
00895 ALLOC_WITH_FAIL(pAttrLightTilt, (new AttrBevelLightTilt()), this);
00896
00897 pAttrLightTilt->Value.m_LightTilt = (INT32)pBevelInfo->m_Tilt;
00898
00899
00900 if (!DoHideNode(pCurrentNode, TRUE, &pNodeHidden))
00901 {
00902 FailAndExecute();
00903 End();
00904 BevelNodeList.DeleteAll();
00905 return;
00906 }
00907
00908
00909 pAttrLightTilt->AttachNode(pNodeHidden, NEXT);
00910 pBevelControl->m_Tilt = pBevelInfo->m_Tilt;
00911
00912
00913 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pAttrLightTilt,
00914 FALSE, (Action **)&pAction, FALSE) != AC_OK)
00915 {
00916 FailAndExecute();
00917 End();
00918 BevelNodeList.DeleteAll();
00919 return;
00920 }
00921
00922 m_NameID = _R(IDS_CHANGEBEVELLIGHTTILTOPNAME);
00923 }
00924 else
00925 if (pCurrentNode->IS_KIND_OF(AttrJoinType) && pBevelInfo->m_bJointTypeChanged)
00926 {
00927 bGenerateNode = TRUE;
00928 ALLOC_WITH_FAIL(pAttrJointType, (new AttrJoinType()), this);
00929
00930 pAttrJointType->Value.JoinType = pBevelInfo->m_JointType;
00931
00932
00933 if (!DoHideNode(pCurrentNode, TRUE, &pNodeHidden))
00934 {
00935 FailAndExecute();
00936 End();
00937 BevelNodeList.DeleteAll();
00938 return;
00939 }
00940
00941
00942 pAttrJointType->AttachNode(pNodeHidden, NEXT);
00943
00944
00945 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pAttrJointType,
00946 FALSE, (Action **)&pAction, FALSE) != AC_OK)
00947 {
00948 FailAndExecute();
00949 End();
00950 BevelNodeList.DeleteAll();
00951 return;
00952 }
00953
00954 m_NameID = _R(IDS_CHANGEJOINTYPEOPNAME);
00955 }
00956
00957
00958
00959
00960
00961
00962
00963
00964 pCurrentNode = pNextNode;
00965 }
00966
00967 if (!DoFactorOutCommonChildAttributes(pBevelControl))
00968 {
00969 FailAndExecute();
00970 End();
00971
00972 BevelNodeList.DeleteAll();
00973 return;
00974 }
00975
00976
00977 if (bGenerateNode)
00978 {
00979 pBevelControl->RegenerateNode(this, FALSE, TRUE);
00980
00981
00982
00983 NodeAttribute* pNA = pBevelControl->FindFirstGeometryLinkedAttr();
00984 while(pNA)
00985 {
00986 pNA->LinkedNodeGeometryHasChanged(this);
00987 pNA = pNA->FindNextGeometryLinkedAttr();
00988 }
00989 }
00990 else
00991 {
00992
00993 pBevelControl->RegenerateBevelBitmap(this, TRUE);
00994 }
00995
00996 pBevelControl->InvalidateBoundingRect(TRUE);
00997 pBevelControl->ReleaseCached();
00998
00999
01000 if (!DoInvalidateRegion(pBevelControl->FindParentSpread(),
01001 pBevelControl->GetBoundingRect(TRUE, FALSE)))
01002 {
01003 FailAndExecute();
01004 End();
01005 BevelNodeList.DeleteAll();
01006 return;
01007 }
01008
01009 pNodeListItem= (NodeListItem *)BevelNodeList.GetNext(pNodeListItem);
01010 }
01011
01012
01013 GetApplication()->UpdateSelection();
01014
01015
01016
01017 if (!BevelNodeList.IsEmpty() && !pBevelInfo->m_bCreateNewBevels && !pBevelInfo->m_bBevelDirectionChanged)
01018 {
01019 ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
01020 ObjChangeParam OP(OBJCHANGE_FINISHED, flgs, NULL, this, OBJCHANGE_CALLEDBYOP);
01021
01022 pBevelControl->AllowOp(&OP);
01023 BevelNodeList.DeleteAll();
01024 End();
01025 return;
01026 }
01027
01028 EffectsStack* pStack = GetApplication()->FindSelection()->GetEffectsStack();
01029 ENSURE(pStack, "Argh!");
01030 Range* pSelList = pStack->GetBaseLevelRange();
01031 ENSURE(pSelList, "Argh!");
01032
01033 TextStory *pThisParentStory = NULL;
01034
01035
01036 ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
01037 ObjChangeParam OP(OBJCHANGE_STARTING, flgs, NULL, this, OBJCHANGE_CALLEDBYOP);
01038
01039
01040
01041 pSel->AllowOp(&OP);
01042
01043 BOOL bHasABevel = FALSE;
01044
01045
01046 Node* pNode = pSelList->FindFirst();
01047 while (pNode)
01048 {
01049
01050 BevelTools::GetAllNodesUnderNode(pNode, &BevelNodeList, CC_RUNTIME_CLASS(NodeBevel));
01051
01052 bHasABevel = !BevelNodeList.IsEmpty();
01053
01054 if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableInk)) &&
01055 !pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelController)) &&
01056 pNode->FindParent(CC_RUNTIME_CLASS(NodeBevelController)) == NULL &&
01057 pNode->AllowOp(&OP, FALSE) &&
01058 !bHasABevel)
01059 {
01060
01061
01062
01063
01064
01065 if (pNode->IsKindOf(CC_RUNTIME_CLASS(TextLine)) ||
01066 pNode->IsKindOf(CC_RUNTIME_CLASS(TextChar)))
01067 {
01068 pThisParentStory = (TextStory *)pNode->FindParent(CC_RUNTIME_CLASS(TextStory));
01069
01070 if (pThisParentStory)
01071 {
01072
01073 if (!(pThisParentStory->FindParent(CC_RUNTIME_CLASS(NodeBevelController))) &&
01074 !pThisParentStory->IsNodeHidden())
01075 {
01076 DoSelectNode(pThisParentStory);
01077 ApplyBevelToNode(pThisParentStory, pBevelInfo);
01078
01079 m_NameID = _R(IDS_CREATEBEVELOPNAME);
01080 }
01081 }
01082 else
01083 {
01084 ERROR3("No parent story found for text line/characters");
01085 }
01086 }
01087 else
01088 {
01089 if (pNode->AllowOp(&OP))
01090 {
01091 ApplyBevelToNode(pNode, pBevelInfo);
01092
01093 m_NameID = _R(IDS_CREATEBEVELOPNAME);
01094 }
01095 }
01096 }
01097 else if(bHasABevel)
01098 {
01099
01100
01101 NodeListItem* pItem = (NodeListItem *)BevelNodeList.GetHead();
01102 NodeBevelController* pControl = NULL;
01103 NodeBevel* pBevel = NULL;
01104
01105 while(pItem)
01106 {
01107 pControl = (NodeBevelController*)pItem->pNode;
01108 pBevel = pControl->GetBevelNode();
01109
01110 if(pControl && pBevel)
01111 {
01112 if(pBevelInfo->m_bOuter)
01113 {
01114 Node* pBeginBevel = pControl->FindFirstChild(CC_RUNTIME_CLASS(NodeBevelBegin));
01115
01116 if(pBeginBevel)
01117 {
01118 DoMoveNode(pBevel,pBeginBevel,NEXT);
01119 }
01120 else
01121 {
01122 DoMoveNode(pBevel,pControl,FIRSTCHILD);
01123 }
01124 }
01125 else
01126 {
01127 DoMoveNode(pBevel,pControl,LASTCHILD);
01128 }
01129 }
01130
01131 pItem = (NodeListItem *)BevelNodeList.GetNext(pItem);
01132 }
01133 }
01134 BevelNodeList.DeleteAll();
01135
01136 pNode = pSelList->FindNext(pNode);
01137 }
01138
01139
01140 delete pSelList;
01141
01142 GetApplication()->UpdateSelection();
01143
01144 End();
01145 }
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158 void OpCreateBevel::ApplyBevelToNode(Node * pNode, BevelInfo* pBevelInfo)
01159 {
01160 if (!pNode || !pBevelInfo)
01161 return;
01162
01163
01164
01165 if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelController)) ||
01166 pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevel)) ||
01167 pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelBegin)) ||
01168 pNode->NeedsParent(pNode->FindParent()))
01169 {
01170 return;
01171 }
01172
01173
01174 if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableInk)))
01175 DoDeselectNode((NodeRenderableInk *)pNode);
01176
01177
01178 BOOL ok = TRUE;
01179
01180 NodeBevelController * pBevelControl = NULL;
01181
01182 NodeBevelBegin * pBevelBegin = NULL;
01183 NodeBevel * pBevel = NULL;
01184 Node * pThisNode = NULL;
01185 Node * pNextNode = NULL;
01186
01187 ALLOC_WITH_FAIL(pBevelControl, (new NodeBevelController()), this);
01188 ok = (pBevelControl != NULL);
01189
01190
01191 if (ok)
01192 {
01193 ALLOC_WITH_FAIL(pBevel, (new NodeBevel()), this);
01194 ok = (pBevel != NULL);
01195 }
01196
01197 if (ok)
01198 {
01199 ALLOC_WITH_FAIL(pBevelBegin, (new NodeBevelBegin()), this);
01200 ok = (pBevelBegin != NULL);
01201 }
01202
01203 if(ok)
01204 {
01205 pBevel->m_Indent = pBevelInfo->m_Indent;
01206 pBevel->m_LightAngle = pBevelInfo->m_LightAngle;
01207 pBevel->m_BevelType = pBevelInfo->m_BevelType;
01208 pBevel->m_bOuter = pBevelInfo->m_bOuter;
01209
01210 pBevelControl->m_Indent = pBevelInfo->m_Indent;
01211 pBevelControl->m_LightAngle = pBevelInfo->m_LightAngle;
01212 pBevelControl->m_BevelType = pBevelInfo->m_BevelType;
01213 pBevelControl->m_bOuter = pBevelInfo->m_bOuter;
01214 }
01215
01216
01217 if (!pNode->IsKindOf(CC_RUNTIME_CLASS(NodeShadowController)))
01218 {
01219 if (ok) ok = DoInsertNewNode(pBevelControl, pNode, NEXT, TRUE, FALSE, FALSE, TRUE);
01220
01221 if (ok) ok = DoMoveNode(pNode, pBevelControl, FIRSTCHILD);
01222
01223 if (ok) ok = DoSelectNode((NodeRenderableInk *)pNode);
01224 }
01225 else
01226 {
01227 if (ok)
01228 {
01229 ok = DoInsertNewNode(pBevelControl, pNode, LASTCHILD, TRUE, FALSE, FALSE, TRUE);
01230
01231
01232 pThisNode = pNode->FindFirstChild();
01233
01234 while (pThisNode)
01235 {
01236 pNextNode = pThisNode->FindNext();
01237
01238 if (!pThisNode->IsKindOf(CC_RUNTIME_CLASS(NodeShadow)) && !pThisNode->IsNodeHidden() &&
01239 !pThisNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelController)))
01240 {
01241 if (!pThisNode->IsKindOf(CC_RUNTIME_CLASS(NodeAttribute)))
01242 {
01243 if (ok) ok = DoMoveNode(pThisNode, pBevelControl, FIRSTCHILD);
01244 if (ok) ok = DoSelectNode((NodeRenderableInk *)pThisNode);
01245 }
01246 }
01247
01248 pThisNode = pNextNode;
01249 }
01250 }
01251 }
01252
01253
01254 if (ok)
01255 ok = DoInsertNewNode(pBevelBegin, pBevelControl, FIRSTCHILD, TRUE, FALSE, FALSE, TRUE);
01256
01257
01258 if (ok)
01259 {
01260
01261 ok = DoInsertNewNode(pBevel, pBevelBegin, NEXT, TRUE, FALSE, FALSE, TRUE);
01262
01263
01264 }
01265
01266 NodeAttribute * pFillAttr = NULL;
01267 NodeAttribute * pTranspFillAttr = NULL;
01268 NodeAttribute * pFillMapping = NULL;
01269 NodeAttribute * pFillEffect = NULL;
01270 NodeAttribute * pTranspFillMapping = NULL;
01271 NodeAttribute * pJoinType = NULL;
01272
01273 if(ok)
01274 {
01275
01276 Node * pStepNode = pBevelControl->FindFirstDepthFirst();
01277
01278 while (pStepNode && pStepNode != (Node *)pBevelControl)
01279 {
01280 if (pStepNode->IsAnObject() && !pStepNode->IsCompound() && !pStepNode->NeedsParent(NULL))
01281 {
01282 if (!pStepNode->IS_KIND_OF(NodeMouldPath))
01283 {
01284 if (pStepNode->IsNodePath())
01285 {
01286
01287 if (pStepNode->FindParent())
01288 {
01289 if (!pStepNode->FindParent()->IS_KIND_OF(TextStory))
01290 {
01291 break;
01292 }
01293 }
01294 }
01295 else if(pStepNode->IsABitmap())
01296 {
01297
01298 BecomeA BecomeAReplace(BECOMEA_REPLACE, CC_RUNTIME_CLASS(NodePath), this, FALSE);
01299 pStepNode->DoBecomeA(&BecomeAReplace);
01300
01301
01302 pStepNode = pBevelControl->FindFirstChildInk();
01303 }
01304 else
01305 {
01306 break;
01307 }
01308 }
01309 }
01310
01311 pStepNode = pStepNode->FindNextDepthFirst(pBevelControl);
01312 }
01313
01314 if (pStepNode && pStepNode != (Node *)pBevelControl)
01315 {
01316 ((NodeRenderableInk *)pStepNode)->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillGeometry),&pFillAttr);
01317 ((NodeRenderableInk *)pStepNode)->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrTranspFillGeometry),&pTranspFillAttr);
01318 ((NodeRenderableInk *)pStepNode)->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillMapping),&pFillMapping);
01319 ((NodeRenderableInk *)pStepNode)->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillEffect),&pFillEffect);
01320 ((NodeRenderableInk *)pStepNode)->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrTranspFillMapping),&pTranspFillMapping);
01321 ((NodeRenderableInk *)pStepNode)->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrJoinType),&pJoinType);
01322 }
01323
01324 if (pFillAttr)
01325 pFillAttr->CopyNode(pBevel, FIRSTCHILD);
01326
01327 if (pTranspFillAttr)
01328 pTranspFillAttr->CopyNode(pBevel, FIRSTCHILD);
01329
01330 if (pFillMapping)
01331 pFillMapping->CopyNode(pBevel, FIRSTCHILD);
01332
01333 if (pFillEffect)
01334 pFillEffect->CopyNode(pBevel, FIRSTCHILD);
01335
01336 if (pTranspFillMapping)
01337 pTranspFillMapping->CopyNode(pBevel, FIRSTCHILD);
01338
01339 if (pJoinType)
01340 pJoinType->CopyNode(pBevel, FIRSTCHILD);
01341 }
01342
01343 if(ok && !pBevelInfo->m_bOuter)
01344 pBevel->MoveNode(pBevelControl,LASTCHILD);
01345
01346
01347 if (ok) ok = DoFactorOutCommonChildAttributes(pBevelControl);
01348
01349 if (!ok) FailAndExecute();
01350
01351
01352 DocRect InvalidBevelRect = pBevelControl->GetBoundingRect(TRUE, FALSE);
01353 pBevelControl->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
01354
01355 if (pBevelInfo->m_bOuter)
01356 {
01357 InvalidBevelRect.lo.x -= pBevelInfo->m_Indent;
01358 InvalidBevelRect.lo.y -= pBevelInfo->m_Indent;
01359 InvalidBevelRect.hi.x += pBevelInfo->m_Indent;
01360 InvalidBevelRect.hi.y += pBevelInfo->m_Indent;
01361 }
01362
01363 Spread * pSpread = Document::GetSelectedSpread();
01364
01365 if (pSpread)
01366 DoInvalidateRegion(pSpread, InvalidBevelRect);
01367
01368
01369 Document * pDoc = Document::GetCurrent();
01370
01371 if (pDoc)
01372 {
01373
01374 AttrBevelType * pType = NULL;
01375 AttrBevelLightAngle * pLightAngle = NULL;
01376 AttrBevelContrast * pContrast = NULL;
01377 AttrBevelIndent * pIndent = NULL;
01378 AttrBevelLightTilt * pTilt = NULL;
01379
01380 ALLOC_WITH_FAIL(pType, new AttrBevelType(pBevelControl, FIRSTCHILD), this);
01381 ALLOC_WITH_FAIL(pLightAngle, new AttrBevelLightAngle(pBevelControl, FIRSTCHILD), this);
01382 ALLOC_WITH_FAIL(pContrast, new AttrBevelContrast(pBevelControl, FIRSTCHILD), this);
01383 ALLOC_WITH_FAIL(pIndent, new AttrBevelIndent(pBevelControl, FIRSTCHILD), this);
01384 ALLOC_WITH_FAIL(pTilt, new AttrBevelLightTilt(pBevelControl, FIRSTCHILD), this);
01385
01386 if (pType)
01387 pType->Value.m_Type = pBevelInfo->m_BevelType;
01388
01389 if (pLightAngle)
01390 pLightAngle->Value.m_LightAngle = (INT32)pBevelInfo->m_LightAngle;
01391
01392 if (pContrast)
01393 pContrast->Value.m_Contrast = pBevelInfo->m_Contrast;
01394
01395 if (pIndent)
01396 pIndent->Value.m_Indent = pBevelInfo->m_Indent;
01397
01398 if (pTilt)
01399 pTilt->Value.m_LightTilt = (INT32)pBevelInfo->m_Tilt;
01400
01401 if (pBevelInfo->m_bOuter)
01402 {
01403 pIndent->Value.m_Indent = -pBevelInfo->m_Indent;
01404 }
01405 else
01406 {
01407
01408 MILLIPOINT MaxWidth = ContourNodePathProcessor::GetMaxInnerContourWidth(pBevelControl);
01409
01410 if (pBevelInfo->m_Indent < MaxWidth)
01411 pIndent->Value.m_Indent = pBevelInfo->m_Indent;
01412 else
01413 pIndent->Value.m_Indent = MaxWidth;
01414 }
01415 }
01416
01417
01418 NodeShadow * pShadow = NULL;
01419 NodeShadowController * pShadowCont = NULL;
01420
01421
01422 pBevelControl->CreateBevel();
01423
01424 SliceHelper::AddNamesToController(this,pBevelControl);
01425
01426 pBevelControl->SetSelected(TRUE);
01427 GetApplication()->UpdateSelection();
01428
01429 pBevel->InvalidateBoundingRect();
01430
01431
01432 ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
01433 flgs.RegenerateNode = TRUE;
01434 ObjChangeParam OP(OBJCHANGE_FINISHED, flgs, pNode, this, OBJCHANGE_CALLEDBYOP);
01435
01436
01437
01438
01439 NodeBlender * pBlender = NULL;
01440 NodeBlend * pBlend = NULL;
01441 NodeShadowController* pShadController = NULL;
01442
01443 if (!IS_A (pBevelControl->FindParent (), NodeShadowController))
01444 {
01445 pBlender = (NodeBlender *)pBevelControl->FindNext(CC_RUNTIME_CLASS(NodeBlender));
01446 }
01447 else
01448 {
01449 pShadController = (NodeShadowController*) pBevelControl->FindParent ();
01450 pBlender = (NodeBlender *)pBevelControl->FindParent ()->FindNext(CC_RUNTIME_CLASS(NodeBlender));
01451 }
01452
01453 if (pBlender)
01454 {
01455 pBlend = (NodeBlend *)pBlender->FindParent();
01456
01457 if (InitBlendAction::InitOnBlender(this, GetUndoActionList(), pBlender, TRUE, TRUE) != AC_OK)
01458 ERROR2RAW("Couldn't Initialise blend action");
01459
01460
01461 if (!pShadController)
01462 pBlender->Reinit(pBevelControl, pBlender->GetNodeEnd(), FALSE);
01463 else
01464 pBlender->Reinit(pShadController, pBlender->GetNodeEnd(), FALSE);
01465 }
01466 else
01467 {
01468
01469 pBlender = (NodeBlender *)pBevelControl->FindPrevious(CC_RUNTIME_CLASS(NodeBlender));
01470
01471 if (pBlender)
01472 {
01473 pBlend = (NodeBlend *)pBlender->FindParent();
01474
01475 if (InitBlendAction::InitOnBlender(this, GetUndoActionList(), pBlender, TRUE, TRUE) != AC_OK)
01476 ERROR2RAW("Couldn't Initialise blend action");
01477
01478 if (!pShadController)
01479 pBlender->Reinit(pBlender->GetNodeStart(), pBevelControl, FALSE);
01480 else
01481 pBlender->Reinit(pBlender->GetNodeStart(), pShadController, FALSE);
01482 }
01483 }
01484
01485 if (pBlender)
01486 {
01487 NodeBlend* ptrBlend = (NodeBlend*) pBlender->FindParent ();
01488
01489 ERROR3IF (!IS_A (ptrBlend, NodeBlend), "NodeBlend is not a NodeBlend!");
01490
01491 BOOL done = FALSE;
01492 NodeBlender* ptrNode = ptrBlend->FindFirstBlender ();
01493
01494 while (!done)
01495 {
01496 if (ptrNode != pBlender)
01497 {
01498 if (ptrNode->GetNodeStart () == pNode)
01499 {
01500 if (InitBlendAction::InitOnBlender(this, GetUndoActionList(), ptrNode, TRUE, TRUE) != AC_OK)
01501 ERROR2RAW("Couldn't Initialise blend action");
01502
01503 if (pBevelControl)
01504 {
01505 if (!pShadController)
01506 ptrNode->Reinit(pBevelControl, NULL, FALSE);
01507 else
01508 ptrNode->Reinit(pShadController, NULL, FALSE);
01509 }
01510 }
01511 if (ptrNode->GetNodeEnd () == pNode)
01512 {
01513 if (InitBlendAction::InitOnBlender(this, GetUndoActionList(), ptrNode, TRUE, TRUE) != AC_OK)
01514 ERROR2RAW("Couldn't Initialise blend action");
01515
01516 if (pBevelControl)
01517 {
01518 if (!pShadController)
01519 ptrNode->Reinit(NULL, pBevelControl, FALSE);
01520 else
01521 ptrNode->Reinit(NULL, pShadController, FALSE);
01522 }
01523 }
01524 }
01525
01526 ptrNode = ptrBlend->FindNextBlender (ptrNode);
01527
01528 if (!ptrNode)
01529 done = TRUE;
01530 }
01531 }
01532
01533 if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeShadowController)))
01534 {
01535 pShadowCont = (NodeShadowController *)pNode;
01536
01537 pShadow = pShadowCont->GetShadow();
01538
01539 pShadow->InvalidateBoundingRect();
01540 pShadow->GetParentController()->InvalidateBoundingRect();
01541 DoInvalidateNodeRegion(pShadow, TRUE);
01542 DoInvalidateNodeRegion(pShadow->GetParentController(), TRUE);
01543
01544 ChangePenumbraSizeAction * pAction = NULL;
01545
01546 ChangePenumbraSizeAction::Init(this,
01547 GetUndoActionList(),
01548 pShadowCont,
01549 pShadowCont->GetPenumbraWidth(),
01550 &pAction);
01551 }
01552 }
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565 NodeAttribute * OpCreateBevel::DoDepthSearchForFill(Node * pNode)
01566 {
01567 if (!pNode)
01568 return NULL;
01569
01570 while (pNode)
01571 {
01572 if (pNode->IsKindOf(CC_RUNTIME_CLASS(AttrFillGeometry)) &&
01573 !pNode->IsKindOf(CC_RUNTIME_CLASS(AttrStrokeColour)) &&
01574 !pNode->IsKindOf(CC_RUNTIME_CLASS(AttrStrokeTransp)) &&
01575 !pNode->IsKindOf(CC_RUNTIME_CLASS(AttrTranspFillGeometry)) &&
01576 !pNode->IsKindOf(CC_RUNTIME_CLASS(AttrValueChange)) &&
01577 !pNode->IsNodeHidden())
01578 {
01579 return (NodeAttribute *)pNode;
01580 }
01581
01582
01583 Node * pChild = pNode->FindFirstChild();
01584
01585 NodeAttribute * pAttr = DoDepthSearchForFill(pChild);
01586
01587 if (pAttr)
01588 return pAttr;
01589
01590 pNode = pNode->FindNext();
01591 }
01592
01593 return NULL;
01594 }
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607 void OpCreateBevel::ConvertToPaths(Node * pNode)
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
01633
01634
01635
01636 }
01637
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648
01649 BOOL OpCreateBevel::Declare()
01650 {
01651 return (RegisterOpDescriptor(
01652 0,
01653 _R(IDS_CREATEBEVELOP),
01654 CC_RUNTIME_CLASS(OpCreateBevel),
01655 OPTOKEN_CREATEBEVEL,
01656 OpCreateBevel::GetState));
01657
01658 }
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674 OpState OpCreateBevel::GetState(String_256* Description, OpDescriptor*)
01675 {
01676 OpState Blobby;
01677
01678
01679 OpCreateBevel * pBevelOp = new OpCreateBevel;
01680
01681 if (!pBevelOp)
01682 {
01683 ERROR3("Cannot create shadow op");
01684 Blobby.Greyed = TRUE;
01685 return Blobby;
01686 }
01687
01688 ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
01689 ObjChangeParam OP(OBJCHANGE_STARTING, flgs, NULL, pBevelOp, OBJCHANGE_CALLEDBYOP);
01690
01691 if (GetApplication()->FindSelection()->AllowOp(&OP, FALSE))
01692 {
01693 Blobby.Greyed = FALSE;
01694 }
01695 else
01696 {
01697 Blobby.Greyed = TRUE;
01698 delete pBevelOp;
01699 return Blobby;
01700 }
01701
01702 delete pBevelOp;
01703
01704 return Blobby;
01705 }
01706
01707
01712
01713
01714
01715
01716
01717
01718
01719
01720
01721 OpRemoveBevel::OpRemoveBevel()
01722 {
01723 }
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735 OpRemoveBevel::~OpRemoveBevel()
01736 {
01737 }
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747 void OpRemoveBevel::GetOpName(String_256 * pString)
01748 {
01749 if (pString)
01750 pString->Load(_R(IDS_REMOVEBEVELOPNAME));
01751 }
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766 void OpRemoveBevel::Do(OpDescriptor *pOpDesc)
01767 {
01768
01769 if (!NodeBevelController::SelectionHasBevelNode())
01770 return;
01771
01772
01773 ObjChangeFlags cFlags;
01774 ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
01775
01776
01777 Range Sel(*(GetApplication()->FindSelection()));
01778 RangeControl rg = Sel.GetRangeControlFlags();
01779 rg.PromoteToParent = TRUE;
01780 Sel.SetRangeControl(rg);
01781
01782 BOOL ok = TRUE;
01783
01784
01785 DoStartSelOp(TRUE, TRUE, TRUE, TRUE);
01786
01787
01788 ok = DoInvalidateNodesRegions(Sel,
01789 TRUE);
01790
01791 Node * pNode = NULL;
01792 Node * pNextNode = NULL;
01793
01794
01795 NodeHidden * pNodeHidden = NULL;
01796
01797 List AttribList;
01798 NodeListItem * pItem = NULL;
01799 NodeListItem * pNext = NULL;
01800
01801 DocRect dr;
01802
01803 Spread * pSpread = Document::GetSelectedSpread();
01804
01805
01806
01807 List BevelControllerList;
01808
01809
01810 BevelTools::BuildListOfSelectedNodes(&BevelControllerList,
01811 CC_RUNTIME_CLASS(NodeBevelController));
01812
01813
01814 pItem = (NodeListItem *)BevelControllerList.GetHead();
01815
01816 NodeShadowController * pShadControl = NULL;
01817
01818 NodeBlend * pBlend = NULL;
01819 NodeBlender * pBlender = NULL;
01820
01821 BOOL bBlendBefore = FALSE;
01822 BOOL bBlendAfter = FALSE;
01823
01824
01825 NodeRenderableInk *pRenderableNode = NULL;
01826
01827 while (pItem)
01828 {
01829 pNext = (NodeListItem *)BevelControllerList.GetNext(pItem);
01830
01831 NodeBevelController* pControl = (NodeBevelController*) pItem->pNode;
01832
01833 if (pControl)
01834 {
01835 SliceHelper::RemoveNamesFromController(this,pControl);
01836
01837
01838
01839 pBlender = (NodeBlender *)pItem->pNode->FindNext(CC_RUNTIME_CLASS(NodeBlender));
01840
01841 bBlendBefore = FALSE;
01842 bBlendAfter = FALSE;
01843
01844 if (pBlender)
01845 {
01846
01847 bBlendBefore = TRUE;
01848
01849 pBlend = (NodeBlend *)pBlender->FindParent();
01850 }
01851 else
01852 {
01853
01854 pBlender = (NodeBlender *)pItem->pNode->FindPrevious(CC_RUNTIME_CLASS(NodeBlender));
01855
01856 if (pBlender)
01857 {
01858 bBlendAfter = TRUE;
01859 pBlend = (NodeBlend *)pBlender->FindParent();
01860 }
01861 }
01862
01863
01864 if (ok) ok = DoRemoveAttrTypeFromSubtree(pItem->pNode, CC_RUNTIME_CLASS(AttrBevelIndent));
01865 if (ok) ok = DoRemoveAttrTypeFromSubtree(pItem->pNode, CC_RUNTIME_CLASS(AttrBevelLightAngle));
01866 if (ok) ok = DoRemoveAttrTypeFromSubtree(pItem->pNode, CC_RUNTIME_CLASS(AttrBevelType));
01867 if (ok) ok = DoRemoveAttrTypeFromSubtree(pItem->pNode, CC_RUNTIME_CLASS(AttrBevelContrast));
01868
01869
01870 Node * pParent = pItem->pNode->FindParent();
01871
01872 if (!pItem->pNode->IsNodeHidden() && pParent)
01873 {
01874 if (ok) ok = DoInvalidateNodeRegion((NodeRenderableInk *)pItem->pNode, TRUE);
01875
01876
01877 if (!DoLocaliseCommonAttributes((NodeRenderableInk *)pItem->pNode, TRUE))
01878 {
01879 FailAndExecute();
01880 End();
01881 BevelControllerList.DeleteAll();
01882
01883 return;
01884 }
01885
01886
01887
01888 pNode = pItem->pNode->FindLastChild();
01889
01890 while (pNode)
01891 {
01892 pNextNode = pNode->FindPrevious();
01893
01894 if (!pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevel)) &&
01895 !pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelBegin)) &&
01896 !pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelController)) &&
01897 !pNode->IsNodeHidden())
01898 {
01899 if (pNode->IsAnObject() && !pNode->IsAnAttribute())
01900 {
01901 if (ok)
01902 ok = DoMoveNode(pNode, pItem->pNode, NEXT);
01903
01904 if (ok)
01905 ok = DoSelectNode((NodeRenderableInk *)pNode);
01906 }
01907 else if (pNode->IsAnAttribute())
01908 {
01909
01910
01911
01912 if (pNode->IsAnObjectName())
01913 DoHideNode(pNode, FALSE);
01914 }
01915 }
01916
01917 pNode = pNextNode;
01918 }
01919
01920
01921 if (ok)
01922 ok = DoDeselectNode((NodeRenderableInk *)pItem->pNode);
01923
01924
01925 pShadControl =
01926 (NodeShadowController *)pItem->pNode->FindParent(CC_RUNTIME_CLASS(NodeShadowController));
01927
01928 if (ok)
01929 {
01930 pItem->pNode->AllowOp(&ObjChange);
01931 ok = DoHideNode((NodeBevelController *)pItem->pNode, TRUE, &pNodeHidden);
01932 }
01933
01934 if (pParent)
01935 {
01936 if (pParent->IsAnObject())
01937 {
01938 if (ok)
01939 ok = DoFactorOutCommonChildAttributes((NodeRenderableInk *)pParent, TRUE);
01940 }
01941 }
01942
01943
01944 if (bBlendBefore)
01945 {
01946 if (InitBlendAction::InitOnBlender(this, GetUndoActionList(), pBlender, TRUE, TRUE) != AC_OK)
01947 {
01948 ERROR2RAW("Couldn't Initialise blend action");
01949 }
01950
01951
01952 pRenderableNode = (NodeRenderableInk *)pBlender->FindPrevious(CC_RUNTIME_CLASS(NodeRenderableInk));
01953
01954 if (pRenderableNode)
01955 {
01956 pBlender->Reinit(pRenderableNode, pBlender->GetNodeEnd(), FALSE);
01957 }
01958 }
01959 else if (bBlendAfter)
01960 {
01961 if (InitBlendAction::InitOnBlender(this, GetUndoActionList(), pBlender, TRUE, TRUE) != AC_OK)
01962 {
01963 ERROR2RAW("Couldn't Initialise blend action");
01964 }
01965
01966
01967 pRenderableNode = (NodeRenderableInk *)pBlender->FindNext(CC_RUNTIME_CLASS(NodeRenderableInk));
01968
01969 if (pRenderableNode)
01970 {
01971 pBlender->Reinit(pBlender->GetNodeStart(), pRenderableNode, FALSE);
01972 }
01973 }
01974
01975 if (pBlender)
01976 {
01977 NodeBlend* ptrBlend = (NodeBlend*) pBlender->FindParent ();
01978
01979 ERROR3IF (!IS_A (ptrBlend, NodeBlend), "NodeBlend is not a NodeBlend!");
01980
01981 BOOL done = FALSE;
01982 NodeBlender* ptrNode = ptrBlend->FindFirstBlender ();
01983
01984 while (!done)
01985 {
01986 if (ptrNode != pBlender)
01987 {
01988 if (ptrNode->GetNodeStart () == pControl)
01989 {
01990 if (InitBlendAction::InitOnBlender(this, GetUndoActionList(), ptrNode, TRUE, TRUE) != AC_OK)
01991 {
01992 ERROR2RAW("Couldn't Initialise blend action");
01993 }
01994
01995 if (pRenderableNode)
01996 {
01997 ptrNode->Reinit(pRenderableNode, NULL, FALSE);
01998 }
01999 }
02000 if (ptrNode->GetNodeEnd () == pControl)
02001 {
02002 if (InitBlendAction::InitOnBlender(this, GetUndoActionList(), ptrNode, TRUE, TRUE) != AC_OK)
02003 {
02004 ERROR2RAW("Couldn't Initialise blend action");
02005 }
02006
02007 if (pRenderableNode)
02008 {
02009 ptrNode->Reinit(NULL, pRenderableNode, FALSE);
02010 }
02011 }
02012 }
02013
02014 ptrNode = ptrBlend->FindNextBlender (ptrNode);
02015
02016 if (!ptrNode)
02017 {
02018 done = TRUE;
02019 }
02020 }
02021 }
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035 }
02036 }
02037
02038
02039 pItem = pNext;
02040 }
02041
02042 BevelControllerList.DeleteAll();
02043
02044 if (!ok)
02045 {
02046 FailAndExecute();
02047 }
02048
02049 ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
02050 UpdateChangedNodes(&ObjChange, pSpread);
02051
02052 GetApplication()->UpdateSelection();
02053 End();
02054 }
02055
02056
02057
02058
02059
02060
02061
02062
02063
02064
02065
02066
02067
02068 BOOL OpRemoveBevel::Declare()
02069 {
02070 return (RegisterOpDescriptor(
02071 0,
02072 _R(IDS_REMOVEBEVELOP),
02073 CC_RUNTIME_CLASS(OpRemoveBevel),
02074 OPTOKEN_REMOVEBEVEL,
02075 OpRemoveBevel::GetState));
02076
02077 }
02078
02079
02080
02081
02082
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092 OpState OpRemoveBevel::GetState(String_256* Description, OpDescriptor*)
02093 {
02094 OpState Blobby;
02095
02096 return Blobby;
02097 }
02098
02099
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117 RegenerateBevelAction::RegenerateBevelAction()
02118 {
02119 m_pNodes = NULL;
02120 m_bCache = FALSE;
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
02147
02148
02149
02150
02151
02152 ActionCode RegenerateBevelAction::Init(Operation* pOp,
02153 ActionList* pActionList,
02154 List * pNodes,
02155 RegenerateBevelAction** ppNewAction,
02156 BOOL bCache)
02157 {
02158
02159 UINT32 ActSize = sizeof(RegenerateBevelAction);
02160
02161 ERROR2IF(!pOp->IS_KIND_OF(UndoableOperation), AC_FAIL, "Operation isn't undoable");
02162
02163 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,CC_RUNTIME_CLASS(RegenerateBevelAction),(Action**)ppNewAction);
02164
02165
02166 List * pCopyList = NULL;
02167 ALLOC_WITH_FAIL(pCopyList, new List, pOp);
02168 NodeListItem * pItem = (NodeListItem *)pNodes->GetHead();
02169 NodeListItem * pCopyItem = NULL;
02170
02171 while (pItem)
02172 {
02173 ALLOC_WITH_FAIL(pCopyItem, new NodeListItem, pOp);
02174 pCopyItem->pNode = pItem->pNode;
02175
02176 pCopyList->AddTail(pCopyItem);
02177
02178 pItem = (NodeListItem *)pNodes->GetNext(pItem);
02179 }
02180
02181 (*ppNewAction)->m_pNodes = pCopyList;
02182 (*ppNewAction)->m_bCache = bCache;
02183
02184 pItem = (NodeListItem *)pNodes->GetHead();
02185
02186 DocView * pView = DocView::GetCurrent();
02187
02188 if (Ac != AC_FAIL)
02189 {
02190 while (pItem)
02191 {
02192 if (pItem->pNode)
02193 {
02194 if (pItem->pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevel)))
02195 {
02196 NodeBevel* pBevel = (NodeBevel*)pItem->pNode;
02197 if (pView && bCache)
02198 {
02199 ASSERT(pBevel->FindParent());
02200 GetApplication()->AddNodeToRegenList(pBevel->FindParent());
02201 if (pBevel->FindParent()->IsBounded())
02202 ((NodeRenderableBounded*)pBevel->FindParent())->InvalidateBoundingRect(TRUE);
02203 }
02204 else
02205 {
02206 if (pBevel->FindParent(CC_RUNTIME_CLASS(Spread)))
02207 {
02208 ((NodeBevelController*)pBevel->GetParentController())->RegenerateNode(NULL, FALSE);
02209 }
02210 }
02211 }
02212 }
02213
02214 pItem = (NodeListItem *)pNodes->GetNext(pItem);
02215 }
02216 }
02217
02218
02219 pActionList->RemoveItem(*ppNewAction);
02220 pActionList->AddHead(*ppNewAction);
02221
02222 return Ac;
02223 }
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240 ActionCode RegenerateBevelAction::Execute()
02241 {
02242 ActionCode Act;
02243 RegenerateBevelAction* pAction;
02244
02245 Act = RegenerateBevelAction::Init( pOperation,
02246 pOppositeActLst,
02247 m_pNodes,
02248 &pAction,
02249 m_bCache);
02250
02251 if (Act != AC_FAIL)
02252 {
02253 }
02254
02255 return Act;
02256 }
02257
02258 RegenerateBevelAction::~RegenerateBevelAction()
02259 {
02260 if (m_pNodes)
02261 {
02262 m_pNodes->DeleteAll();
02263 delete m_pNodes;
02264 }
02265 }
02266
02268
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284 RegenerateBevelBitmapAction::RegenerateBevelBitmapAction()
02285 {
02286 m_pNodes = NULL;
02287 }
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298
02299
02300
02301
02302
02303
02304
02305
02306
02307
02308
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318
02319
02320 ActionCode RegenerateBevelBitmapAction::Init(Operation* pOp,
02321 ActionList* pActionList,
02322 List * pNodes,
02323 RegenerateBevelBitmapAction** ppNewAction)
02324 {
02325 UINT32 ActSize = sizeof(RegenerateBevelBitmapAction);
02326
02327 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,CC_RUNTIME_CLASS(RegenerateBevelBitmapAction),
02328 (Action**)ppNewAction);
02329
02330
02331 List * pCopyList = NULL;
02332 ALLOC_WITH_FAIL(pCopyList, new List, pOp);
02333 NodeListItem * pItem = (NodeListItem *)pNodes->GetHead();
02334 NodeListItem * pCopyItem = NULL;
02335
02336 while (pItem)
02337 {
02338 ALLOC_WITH_FAIL(pCopyItem, new NodeListItem, pOp);
02339 pCopyItem->pNode = pItem->pNode;
02340
02341 pCopyList->AddTail(pCopyItem);
02342
02343 pItem = (NodeListItem *)pNodes->GetNext(pItem);
02344 }
02345
02346 (*ppNewAction)->m_pNodes = pCopyList;
02347
02348 pItem = (NodeListItem *)pNodes->GetHead();
02349
02350
02351
02352 if (Ac != AC_FAIL)
02353 {
02354 while (pItem)
02355 {
02356 if (pItem->pNode)
02357 {
02358 if (pItem->pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevel)))
02359 {
02360 NodeBevel* pBevel = (NodeBevel*)pItem->pNode;
02361 NodeBevelController* pControl = (NodeBevelController*)pBevel->GetParentController();
02362
02363 if (pControl)
02364 {
02365 pControl->RegenerateBevelBitmap(NULL, TRUE);
02366 }
02367 }
02368 }
02369
02370 pItem = (NodeListItem *)pNodes->GetNext(pItem);
02371 }
02372 }
02373
02374
02375 pActionList->RemoveItem(*ppNewAction);
02376 pActionList->AddHead(*ppNewAction);
02377
02378 return Ac;
02379 }
02380
02381
02382
02383
02384
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395
02396 ActionCode RegenerateBevelBitmapAction::Execute()
02397 {
02398 ActionCode Act;
02399 RegenerateBevelBitmapAction* pAction;
02400
02401 Act = RegenerateBevelBitmapAction::Init( pOperation,
02402 pOppositeActLst,
02403 m_pNodes,
02404 &pAction);
02405
02406 if (Act != AC_FAIL)
02407 {
02408 }
02409
02410 return Act;
02411 }
02412
02413 RegenerateBevelBitmapAction::~RegenerateBevelBitmapAction()
02414 {
02415 if (m_pNodes)
02416 {
02417 m_pNodes->DeleteAll();
02418 delete m_pNodes;
02419 }
02420 }
02421
02422
02424
02425
02426
02427
02428
02429
02430
02431
02432
02433
02434
02435
02436
02437
02438
02439
02440 ChangeLightAnglesAction::ChangeLightAnglesAction()
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
02474
02475
02476
02477
02478
02479 ActionCode ChangeLightAnglesAction::Init( Operation* pOp,
02480 ActionList* pActionList,
02481 List * pNodes,
02482 INT32 NewAngle,
02483 INT32 OldAngle,
02484 ChangeLightAnglesAction** NewAction)
02485 {
02486 if (!pOp)
02487 return AC_FAIL;
02488
02489 if (!pOp->IsKindOf(CC_RUNTIME_CLASS(UndoableOperation)))
02490 return AC_FAIL;
02491
02492 UINT32 ActSize = sizeof(ChangeLightAnglesAction);
02493
02494 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,CC_RUNTIME_CLASS(ChangeLightAnglesAction),(Action**)NewAction);
02495
02496 if (Ac != AC_OK)
02497 return Ac;
02498
02499
02500
02501
02502 NodeListItem * pItem = NULL;
02503 NodeListItem * pNewItem = NULL;
02504
02505 pItem = (NodeListItem *)pNodes->GetHead();
02506
02507 AttrBevelLightAngle *pAttr = NULL;
02508
02509
02510 (*NewAction)->m_OldAngle = (INT32)OldAngle;
02511 (*NewAction)->m_NewAngle = (INT32)NewAngle;
02512
02513 List AttrList;
02514
02515
02516
02517
02518 NodeBevelController * pBevelNode = NULL;
02519 AttrBevelLightAngle * pAttrNode = NULL;
02520
02521 DocView * pView = DocView::GetCurrent();
02522
02523 while (pItem)
02524 {
02525 if (pItem->pNode)
02526 {
02527 if (pItem->pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelController)))
02528 {
02529
02530 pBevelNode = (NodeBevelController *)pItem->pNode;
02531
02532 ALLOC_WITH_FAIL(pNewItem, new NodeListItem, pOp);
02533 pNewItem->pNode = pItem->pNode;
02534 (*NewAction)->m_NodeList.AddTail(pNewItem);
02535
02536
02537
02538 if (pBevelNode->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelLightAngle),
02539 (NodeAttribute **)(&pAttrNode)))
02540 {
02541 if (!pAttrNode->IsADefaultAttr())
02542 {
02543
02544
02545 pAttrNode->Value.m_LightAngle = NewAngle;
02546 }
02547 else
02548 {
02549
02550
02551 ALLOC_WITH_FAIL(pAttr, new AttrBevelLightAngle(pBevelNode, FIRSTCHILD), pOp);
02552 pAttr->Value.m_LightAngle = NewAngle;
02553 }
02554 }
02555
02556
02557 pBevelNode->m_LightAngle = NewAngle;
02558
02559
02560 if (pBevelNode->GetBevelNode())
02561 {
02562 if (pView)
02563 {
02564 GetApplication()->AddNodeToRegenList(pBevelNode);
02565 }
02566 else
02567 {
02568 pBevelNode->GetBevelNode()->InvalidateMe();
02569 }
02570 }
02571
02572
02573
02574 }
02575 }
02576
02577 pItem = (NodeListItem *)pNodes->GetNext(pItem);
02578 }
02579
02580 return Ac;
02581 }
02582
02583
02584
02585
02586
02587
02588
02589
02590
02591
02592
02593
02594
02595
02596
02597
02598 ActionCode ChangeLightAnglesAction::Execute()
02599 {
02600 ActionCode Act = AC_OK;
02601 ChangeLightAnglesAction* pAction;
02602
02603 Act = ChangeLightAnglesAction::Init(pOperation,
02604 pOppositeActLst,
02605 &m_NodeList,
02606 m_OldAngle,
02607 m_NewAngle,
02608 &pAction);
02609
02610 if (Act != AC_FAIL)
02611 {
02612 INT32 angle = m_NewAngle;
02613 m_NewAngle = m_OldAngle;
02614 m_OldAngle = angle;
02615 }
02616
02617 return Act;
02618 }
02619
02620 ChangeLightAnglesAction::~ChangeLightAnglesAction()
02621 {
02622 m_NodeList.DeleteAll();
02623 }
02624
02626
02627
02628
02629
02630
02631
02632
02633
02634
02635
02636
02637
02638
02639
02640
02641
02642 RemoveBevelAttributesAction::RemoveBevelAttributesAction()
02643 {
02644 m_bShouldDo = FALSE;
02645 }
02646
02647
02648
02649
02650
02651
02652
02653
02654
02655
02656
02657
02658
02659
02660
02661
02662
02663
02664
02665
02666
02667
02668
02669
02670
02671
02672
02673
02674
02675
02676
02677
02678
02679 ActionCode RemoveBevelAttributesAction::Init( Operation* pOp,
02680 ActionList* pActionList,
02681 NodeRenderableInk * pNode,
02682 BOOL bShouldDo,
02683 RemoveBevelAttributesAction** NewAction)
02684 {
02685 if (!pOp)
02686 return AC_FAIL;
02687
02688 if (!pOp->IsKindOf(CC_RUNTIME_CLASS(UndoableOperation)))
02689 return AC_FAIL;
02690
02691 UINT32 ActSize = sizeof(RemoveBevelAttributesAction);
02692
02693 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,CC_RUNTIME_CLASS(RemoveBevelAttributesAction),(Action**)NewAction);
02694
02695 if (Ac != AC_OK)
02696 return Ac;
02697
02698
02699
02700 (*NewAction)->m_bShouldDo = bShouldDo;
02701 (*NewAction)->m_pNode = pNode;
02702
02703
02704
02705
02706
02707
02708
02709
02710 pActionList->RemoveItem(*NewAction);
02711 pActionList->AddHead(*NewAction);
02712
02713 return Ac;
02714 }
02715
02716
02717
02718
02719
02720
02721
02722
02723
02724
02725
02726
02727
02728
02729
02730
02731 ActionCode RemoveBevelAttributesAction::Execute()
02732 {
02733 ActionCode Act = AC_OK;
02734 RemoveBevelAttributesAction* pAction;
02735
02736 if (m_bShouldDo)
02737 {
02738 Act = RemoveBevelAttributesAction::Init(pOperation,
02739 pOppositeActLst,
02740 m_pNode,
02741 FALSE,
02742 &pAction);
02743 }
02744 else
02745 {
02746 Act = RemoveBevelAttributesAction::Init(pOperation,
02747 pOppositeActLst,
02748 m_pNode,
02749 TRUE,
02750 &pAction);
02751 }
02752
02753 NodeListItem * pItem = NULL;
02754
02755
02756 if (!m_bShouldDo && Act == AC_OK)
02757 {
02758
02759 pAction->m_AttrList.DeleteAll();
02760
02761
02762 Node * pChild = pAction->m_pNode->FindFirstDepthFirst();
02763 Node * pNext = NULL;
02764
02765 while (pChild && pChild != pAction->m_pNode)
02766 {
02767 pNext = pChild->FindNextDepthFirst(pAction->m_pNode);
02768
02769 if (pChild->IsAnAttribute())
02770 {
02771 if (pChild->IS_KIND_OF(AttrBevel))
02772 {
02773
02774
02775
02776 pItem = new NodeListItem(pChild);
02777
02778 pAction->m_AttrList.AddTail(pItem);
02779 }
02780 }
02781
02782 pChild = pNext;
02783 }
02784 }
02785 else
02786 {
02787 pItem = (NodeListItem *)m_AttrList.GetHead();
02788
02789 while (pItem)
02790 {
02791 pItem->pNode->AttachNode(m_pNode, FIRSTCHILD);
02792
02793 pItem = (NodeListItem *)m_AttrList.GetNext(pItem);
02794 }
02795
02796 m_AttrList.DeleteAll();
02797
02798 NodeBevelController * pController =
02799 (NodeBevelController *)m_pNode->FindParent(CC_RUNTIME_CLASS(NodeBevelController));
02800
02801 if (pController)
02802 pController->OptimiseAttributes();
02803
02804
02805 }
02806
02807 return Act;
02808 }
02809
02810 RemoveBevelAttributesAction::~RemoveBevelAttributesAction()
02811 {
02812 m_AttrList.DeleteAll();
02813 }
02814
02815
02816
02817
02818
02819
02820
02821
02822
02823
02824
02825
02826 OpChangeBevelLightAngle::OpChangeBevelLightAngle()
02827 {
02828
02829 }
02830
02831
02832
02833
02834
02835
02836
02837
02838
02839
02840
02841 OpChangeBevelLightAngle::~OpChangeBevelLightAngle()
02842 {
02843
02844 }
02845
02846
02847
02848
02849
02850
02851
02852
02853
02854
02855
02856
02857 BOOL OpChangeBevelLightAngle::Declare()
02858 {
02859 BOOL retn = (RegisterOpDescriptor(
02860 0,
02861 _R(IDS_CHANGEATTRIBUTE),
02862 CC_RUNTIME_CLASS(OpChangeBevelLightAngle),
02863 OPTOKEN_CHANGEATTRIBUTE,
02864 OpChangeBevelLightAngle::GetState));
02865 return retn;
02866
02867 }
02868
02869
02870
02871
02872
02873
02874
02875
02876
02877
02878
02879
02880 void OpChangeBevelLightAngle::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
02881 {
02882 if (!pOp || !pParam)
02883 {
02884 End();
02885 return;
02886 }
02887
02888 OpChangeLightAnglesParam * pAttrParam = (OpChangeLightAnglesParam *)pParam;
02889
02890 if (!pAttrParam->pNodes)
02891 {
02892 End();
02893 return;
02894 }
02895
02896 if (pAttrParam->pNodes->IsEmpty())
02897 {
02898 End();
02899 return;
02900 }
02901
02902
02903 BeginSlowJob(-1, TRUE);
02904
02905 DoStartSelOp(TRUE);
02906
02907 BOOL ok = TRUE;
02908
02909
02910 List * pNodes = pAttrParam->pNodes;
02911 NodeListItem * pItem = (NodeListItem *)pNodes->GetHead();
02912
02913 AttrBevelLightAngle * pLightAttr = NULL;
02914 AttrBevelLightAngle * pNewLightAttr = NULL;
02915
02916 NodeBevelController * pControl = NULL;
02917 NodeHidden * pHidden = NULL;
02918 Node * pThisNode = NULL;
02919 Node * pNextNode = NULL;
02920 HideNodeAction *pAction = NULL;
02921 List AttrList;
02922
02923
02924 while (pItem)
02925 {
02926 if (pItem->pNode)
02927 {
02928 if (pItem->pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelController)))
02929 {
02930
02931 pControl = (NodeBevelController *)pItem->pNode;
02932
02933 if (ok)
02934 ok = DoLocaliseForAttrChange(pControl, CC_RUNTIME_CLASS(AttrBevelLightAngle),
02935 NULL);
02936
02937 BevelTools::GetAllNodesUnderNode(pControl, &AttrList, CC_RUNTIME_CLASS(AttrBevelLightAngle));
02938
02939 if (AttrList.IsEmpty())
02940 {
02941 ALLOC_WITH_FAIL(pLightAttr, new AttrBevelLightAngle(pControl, FIRSTCHILD), this);
02942 pLightAttr->Value.m_LightAngle = (INT32)pControl->m_LightAngle;
02943
02944 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pLightAttr,
02945 FALSE, (Action **)&pAction, FALSE) != AC_OK)
02946 {
02947 FailAndExecute();
02948 End();
02949 return;
02950 }
02951 }
02952
02953 AttrList.DeleteAll();
02954
02955 pThisNode = pControl->FindFirstDepthFirst();
02956
02957 while (pThisNode && ok)
02958 {
02959 pNextNode = pThisNode->FindNextDepthFirst(pControl);
02960
02961 if (pThisNode->IsAnAttribute())
02962 {
02963 if (pThisNode->IS_KIND_OF(AttrBevelLightAngle))
02964 {
02965
02966 ALLOC_WITH_FAIL(pNewLightAttr, new AttrBevelLightAngle, this);
02967 pNewLightAttr->Value.m_LightAngle = pAttrParam->NewLightAngle;
02968
02969
02970 if (ok)
02971 ok = DoHideNode(pThisNode, FALSE, &pHidden);
02972
02973
02974 pNewLightAttr->AttachNode(pHidden, NEXT);
02975
02976 if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pNewLightAttr,
02977 FALSE, (Action **)&pAction, FALSE) != AC_OK)
02978 {
02979 ok = FALSE;
02980 }
02981 }
02982 }
02983
02984 pThisNode = pNextNode;
02985 }
02986
02987 if (ok)
02988 ok = DoFactorOutAfterAttrChange(pControl, CC_RUNTIME_CLASS(AttrBevelLightAngle));
02989
02990 pControl->RegenerateBevelBitmap(this, TRUE);
02991 }
02992 }
02993
02994 pItem = (NodeListItem *)pNodes->GetNext(pItem);
02995 }
02996
02997 if (!ok)
02998 {
02999 FailAndExecute();
03000 End();
03001 return;
03002 }
03003
03004 End();
03005 }
03006
03007
03008
03009
03010
03011
03012
03013
03014
03015
03016
03017
03018
03019
03020
03021
03022 OpState OpChangeBevelLightAngle::GetState(String_256* Description, OpDescriptor*)
03023 {
03024 OpState Blobby;
03025
03026 return Blobby;
03027 }
03028
03029
03030
03031
03032
03033
03034
03035
03036
03037
03038
03039
03040
03041 void OpChangeBevelLightAngle::GetOpName(String_256 * pString)
03042 {
03043 if (pString)
03044 pString->Load(_R(IDS_CHANGEBEVELLIGHTANGLEOPNAME));
03045 }
03046
03047
03048
03049
03050
03051
03052
03053
03054 OpSelectBevel::OpSelectBevel()
03055 {
03056
03057 }
03058
03059
03060
03061
03062
03063
03064
03065
03066
03067
03068 OpSelectBevel::~OpSelectBevel()
03069 {
03070
03071 }
03072
03073
03074
03075
03076
03077
03078
03079
03080
03081
03082
03083 BOOL OpSelectBevel::Declare()
03084 {
03085 BOOL retn = (RegisterOpDescriptor(
03086 0,
03087 _R(IDS_SELECTBEVEL),
03088 CC_RUNTIME_CLASS(OpSelectBevel),
03089 OPTOKEN_SELECTBEVEL,
03090 OpSelectBevel::GetState));
03091 return retn;
03092
03093 }
03094
03095
03096
03097
03098
03099
03100
03101
03102
03103
03104
03105
03106 void OpSelectBevel::Do(OpDescriptor* pOp)
03107 {
03108
03109 if (!pOp)
03110 {
03111 End();
03112 return;
03113 }
03114
03115 BeginSlowJob(-1, TRUE);
03116
03117 List ControllerList;
03118
03119
03120 BevelTools::BuildListOfSelectedNodes(&ControllerList, CC_RUNTIME_CLASS(NodeBevelController), TRUE);
03121
03122 if (ControllerList.IsEmpty())
03123 {
03124 End();
03125 return;
03126 }
03127
03128
03129 NodeRenderableInk::DeselectAll();
03130
03131
03132 NodeListItem * pItem = (NodeListItem *)ControllerList.GetHead();
03133 NodeBevel * pBevel = NULL;
03134
03135 while (pItem)
03136 {
03137 if (pItem->pNode)
03138 {
03139 pBevel = ((NodeBevelController *)pItem->pNode)->GetBevelNode();
03140
03141 if (pBevel)
03142 {
03143 pBevel->SetSelected(TRUE);
03144 }
03145 }
03146
03147 pItem = (NodeListItem *)ControllerList.GetNext(pItem);
03148 }
03149
03150
03151 ControllerList.DeleteAll();
03152
03153 GetApplication()->UpdateSelection();
03154
03155 End();
03156
03157
03158
03159 if (Tool::GetCurrentID() == TOOLID_BEVELTOOL)
03160 {
03161 BevelTool * pTool = (BevelTool *)Tool::GetCurrent();
03162 pTool->InvalidateToolBlobs();
03163 }
03164 }
03165
03166
03167
03168
03169
03170
03171
03172
03173
03174
03175
03176
03177
03178
03179
03180 OpState OpSelectBevel::GetState(String_256* Description, OpDescriptor*)
03181 {
03182 OpState Blobby;
03183
03184 return Blobby;
03185 }
03186
03187
03188
03189
03190 #endif
03191
03192
03193