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 #include "camtypes.h"
00103
00104
00105
00106 #include "transop.h"
00107
00108
00109 #include "slice.h"
00110
00111
00112 #include "userattr.h"
00113 #include "tmpltatr.h"
00114
00115 #include "progress.h"
00116
00117
00118
00119 #include "ngcore.h"
00120 #include "ngitem.h"
00121 #include "ngprop.h"
00122 #include "ngsentry.h"
00123
00124 #include "slicehelper.h"
00125 #include "opdupbar.h"
00126 #include "slicetool.h"
00127
00128 #include "nodetxtl.h"
00129 #include "objchge.h"
00130 #include "sprdmsg.h"
00131
00132 #ifdef _DEBUG
00133 #undef THIS_FILE
00134 static char BASED_CODE THIS_FILE[] = __FILE__;
00135 #endif
00136
00137 DECLARE_SOURCE("$Revision: 1282 $");
00138
00139 CC_IMPLEMENT_DYNCREATE(OpDuplicateBar, CarbonCopyOp)
00140 CC_IMPLEMENT_DYNCREATE(OpShortenBar, CarbonCopyOp)
00141 CC_IMPLEMENT_DYNCREATE(OpDelBar, CarbonCopyOp)
00142 CC_IMPLEMENT_DYNCREATE(OpShowState, UndoableOperation)
00143
00144
00145 #define new CAM_DEBUG_NEW
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 OpDuplicateBar::OpDuplicateBar(): CarbonCopyOp()
00161 {
00162 m_ExistingButtonsInBar = 0;
00163 }
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 BOOL OpDuplicateBar::Init()
00182 {
00183 return (RegisterOpDescriptor(0,
00184 _R(IDS_BARDUPLICATIONOP),
00185 CC_RUNTIME_CLASS(OpDuplicateBar),
00186 OPTOKEN_BARDUPLICATIONOP,
00187 OpDuplicateBar::GetState,
00188 0,
00189 0,
00190 0,
00191 0,
00192 SYSTEMBAR_ILLEGAL,
00193 TRUE,
00194 FALSE,
00195 FALSE,
00196 0,
00197 (GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE) ));
00198 }
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212 OpState OpDuplicateBar::GetState(String_256* UIDescription, OpDescriptor *Bob)
00213 {
00214 OpState OpSt;
00215
00216
00217 OpSt.Greyed = TRUE;
00218 Spread* pSpread = Document::GetSelectedSpread();
00219 if (pSpread && !pSpread->FindActiveLayer()->IsFrame())
00220 OpSt.Greyed = FALSE;
00221
00222 return(OpSt);
00223 }
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243 void OpDuplicateBar::DoWithParam(OpDescriptor* token, OpParam* pOpParam)
00244 {
00245 if (DoStartSelOp(FALSE,TRUE))
00246 {
00247
00248 DuplicateBar(((OpParamBarDuplication *)pOpParam)->m_OldBarName,
00249 ((OpParamBarDuplication *)pOpParam)->m_NewBarName,
00250 ((OpParamBarDuplication *)pOpParam)->m_ButtonsToAdd,
00251 ((OpParamBarDuplication *)pOpParam)->m_Spacing,
00252 ((OpParamBarDuplication *)pOpParam)->m_IsHoriz);
00253
00254
00255
00256 End();
00257
00258 DialogBarOp::SetSystemStateChanged();
00259 DialogBarOp::UpdateStateOfAllBars();
00260
00261 }
00262 else
00263 {
00264 FailAndExecute();
00265 End();
00266 }
00267 }
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293 void OpDuplicateBar::DuplicateBar(String_256 &OriginalBarName, String_256 &NewBarName, INT32 ButtonsToAdd, INT32 Spacing, BOOL IsHoriz)
00294 {
00295
00296
00297
00298
00299
00300
00301 ASSERT (ButtonsToAdd > 0);
00302
00303 String_256 templayer;
00304 Layer * pLayer = NULL;
00305
00306 List BarList;
00307
00308 templayer.Load(_R(IDS_ROLLOVER_DEFAULT));
00309 pLayer = SliceHelper::FindLayerCalled(templayer);
00310 Layer * pDefLayer = pLayer;
00311 if (pLayer)
00312 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, OriginalBarName);
00313
00314 templayer.Load(_R(IDS_ROLLOVER_MOUSE));
00315 pLayer = SliceHelper::FindLayerCalled(templayer);
00316 if (pLayer)
00317 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, OriginalBarName);
00318
00319 templayer.Load(_R(IDS_ROLLOVER_CLICKED));
00320 pLayer = SliceHelper::FindLayerCalled(templayer);
00321 if (pLayer)
00322 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, OriginalBarName);
00323
00324 templayer.Load(_R(IDS_ROLLOVER_SELECTED));
00325 pLayer = SliceHelper::FindLayerCalled(templayer);
00326 if (pLayer)
00327 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, OriginalBarName);
00328
00329
00330
00331
00332
00333
00334 NodeListItem *pNodeListItem = (NodeListItem *)BarList.GetHead();
00335 NodeListItem *pDelThisToo = NULL;
00336
00337
00338 m_ExistingButtonsInBar = 0;
00339 SliceHelper::CountButtonsInBarScan(pDefLayer, (TemplateAttribute **) m_ppFoundButton, &m_ExistingButtonsInBar, OriginalBarName);
00340
00341 templayer = ((TemplateAttribute *) m_ppFoundButton[0])->GetParam();
00342
00343 DocRect BarDim;
00344 DocRect FirstButtonDim;
00345
00346 BarDim.MakeEmpty();
00347 FirstButtonDim.MakeEmpty();
00348
00349 while(pNodeListItem)
00350 {
00351 Node* pNode = pNodeListItem->pNode->FindParent();
00352 if (pNode)
00353 {
00354 BarDim = BarDim.Union(((NodeRenderableBounded *) pNode)->GetBoundingRect());
00355 if (templayer.CompareTo(((TemplateAttribute *)pNodeListItem->pNode)->GetParam()) == 0)
00356 FirstButtonDim = FirstButtonDim.Union(((NodeRenderableBounded *) pNode)->GetBoundingRect());
00357 }
00358 pNodeListItem = (NodeListItem *)BarList.GetNext(pNodeListItem);
00359 }
00360
00361
00362 Trans2DMatrix Transformer;
00363
00364
00365 if (BarDim.hix - BarDim.lox + FirstButtonDim.hix - FirstButtonDim.lox >
00366 BarDim.hiy - BarDim.loy + FirstButtonDim.hiy - FirstButtonDim.loy)
00367 Transformer.SetTransform(0, BarDim.loy - BarDim.hiy);
00368 else
00369 Transformer.SetTransform(BarDim.hix - BarDim.lox, 0);
00370
00371
00372 String_256 TempButtonName;
00373 INT32 i = 0, listbuttonno = 0;
00374 for (i = 0; i < MAX_BUTTONS_IN_A_BAR; i++)
00375 {
00376 m_ButtonNumberList[i] = i;
00377 if (i < max(m_ExistingButtonsInBar, ButtonsToAdd))
00378 {
00379
00380 SliceHelper::GetNextFreeButtonName(listbuttonno);
00381
00382 m_ButtonNumberList[i] = listbuttonno;
00383 }
00384 }
00385
00386
00387 pNodeListItem = (NodeListItem *)BarList.GetHead();
00388 String_256 Name = "";
00389
00390
00391 ObjChangeFlags cFlags;
00392
00393 ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
00394
00395 while(pNodeListItem)
00396 {
00397 pDelThisToo = pNodeListItem;
00398 Node *pNode = pNodeListItem->pNode;
00399 if (pNode && pNode->AllowOp(&ObjChange))
00400 {
00401 if (ButtonsToAdd == 0)
00402 {
00403 Node * NewNode = CopyBarMember(pNode, OriginalBarName, NewBarName, &Transformer);
00404 if (NewNode)
00405 NewNode->AllowOp(&ObjChange);
00406 }
00407 else
00408 {
00409
00410 Name = ((TemplateAttribute *)pNode)->GetParam();
00411
00412
00413 if (Name.CompareTo(((TemplateAttribute *) m_ppFoundButton[0])->GetParam()) == 0)
00414 for (i = 0; i < ButtonsToAdd; i++)
00415 {
00416
00417 if (IsHoriz)
00418 Transformer.SetTransform(BarDim.hix - BarDim.lox + (i+1)*(Spacing) + i*(FirstButtonDim.hix - FirstButtonDim.lox), 0);
00419 else
00420 Transformer.SetTransform(0, BarDim.loy - BarDim.hiy - ((i+1)*(Spacing) + i*( FirstButtonDim.hiy - FirstButtonDim.loy)));
00421
00422 Node * NewNode = CopyBarMember(pNode, OriginalBarName, OriginalBarName, &Transformer, &i);
00423 if (NewNode)
00424 NewNode->AllowOp(&ObjChange);
00425 }
00426 }
00427 }
00428
00429 pNodeListItem = (NodeListItem *)BarList.GetNext(pNodeListItem);
00430
00431
00432 BarList.RemoveItem((NodeListItem *)pDelThisToo);
00433 delete pDelThisToo;
00434 }
00435
00436
00437 NameGallery * pNameGallery = NameGallery::Instance();
00438 if (pNameGallery)
00439 {
00440 pNameGallery->m_TouchedBar = SliceHelper::GetBarNumberFromBarName(NewBarName);
00441 }
00442
00443 ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
00444 UpdateChangedNodes(&ObjChange);
00445
00446
00447 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
00448
00449 }
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478 Node* OpDuplicateBar::CopyBarMember(Node * pNode, const String_256 &OriginalBarName, const String_256 &NewBarName, Trans2DMatrix * pTransformer, const INT32 * pKnownButtonIndex)
00479 {
00480
00481 Node* pTheCopy;
00482
00483
00484
00485
00486 Node* pCurrent = pNode->FindParent();
00487 BOOL CopiedOK = TRUE;
00488
00489 String_256 Target = "";
00490 String_256 Extender = "";
00491 DocRect rTarget;
00492 DocRect rExtender;
00493 BYTE ExtenderFlags = 0;
00494 INT32 RequiredLevel = 0;
00495 RequiredLevel = SliceHelper::FindTargetAndExtender(pCurrent, Target, Extender, RequiredLevel, &ExtenderFlags, &rTarget, &rExtender);
00496
00497
00498
00499
00500
00501 Node * pInsertPt = pCurrent->FindParent();
00502 while (!pInsertPt->IsLayer())
00503 pInsertPt = pInsertPt->FindParent();
00504
00505
00506 CALL_WITH_FAIL(pCurrent->NodeCopy(&pTheCopy), this, CopiedOK);
00507 if (!CopiedOK) return NULL;
00508
00509
00510 DoInsertNewNode((NodeRenderableBounded *)pTheCopy, pInsertPt, LASTCHILD,
00511 TRUE,
00512 FALSE);
00513
00514 pTheCopy->SetSelected(FALSE);
00515
00516
00517
00518
00519
00520 Node* pAttrib = pTheCopy->FindFirstChild();
00521 Node* pNext = NULL;
00522
00523 BOOL goon = TRUE;
00524 while(pAttrib && goon)
00525 {
00526 pNext = pAttrib->FindNext();
00527 if (pAttrib->IsAnAttribute())
00528 {
00529 if (IS_A(pAttrib, TemplateAttribute))
00530 {
00531 String_256 ButtonName = ((TemplateAttribute *)pAttrib)->GetParam();
00532 String_256 AttrName = ((TemplateAttribute *)pAttrib)->GetQuestion();
00533
00534
00535 BOOL IsBarButton = (OriginalBarName.CompareTo(AttrName) == 0);
00536 BOOL IsExtender = (ButtonName.CompareTo(Extender) == 0);
00537
00538 if (IsBarButton || IsExtender)
00539 {
00540 String_256 NewButtonName = "";
00541
00542 if (pKnownButtonIndex)
00543 NewButtonName.MakeMsg(_R(IDS_BUTTONNAME), m_ButtonNumberList[*pKnownButtonIndex]);
00544 else
00545 NewButtonName = GetNewButtonName(ButtonName);
00546
00547 String_256 ExtenderPostfix;
00548 ExtenderPostfix.Load(_R(IDS_EXTENDER_POSTFIX));
00549 String_256 NewExtenderName = NewButtonName;
00550 NewExtenderName += ExtenderPostfix;
00551
00552 TemplateAttribute* pNewAttr = new TemplateAttribute(String_256(TEXT("ObjectName")),
00553 IsBarButton ? NewBarName : "",
00554 IsBarButton ? NewButtonName : NewExtenderName);
00555
00556 if (pNewAttr)
00557 {
00558 pNewAttr->AttachNode(pTheCopy, FIRSTCHILD);
00559
00560 if (IsBarButton)
00561 {
00562 if (!Target.IsEmpty() && RequiredLevel > 1)
00563
00564 SliceHelper::CreatePropertiesForSet(NewButtonName, NewBarName, TRUE, TRUE, FALSE, ExtenderFlags,
00565 NewExtenderName, FALSE, &rTarget, &rExtender, this);
00566 else
00567 SliceHelper::CreatePropertiesForSet(NewButtonName, NewBarName, TRUE, FALSE, FALSE, 0,
00568 TEXT(""), FALSE, NULL, NULL, this);
00569
00570
00571
00572 SliceHelper::MakeTriggerLikeExample(NewButtonName, ButtonName);
00573 }
00574 else
00575 {
00576 SliceHelper::CreatePropertiesForSet(NewExtenderName, TEXT(""), FALSE, FALSE, FALSE, 0,
00577 TEXT(""), FALSE, NULL, NULL, this);
00578
00579
00580
00581 SliceHelper::MakeTriggerLikeExample(NewExtenderName, Extender, &Target);
00582 }
00583
00584 DoHideNode(pAttrib, TRUE);
00585 }
00586 }
00587 }
00588 }
00589
00590 pAttrib = pNext;
00591 }
00592
00593
00594 ((NodeRenderableBounded *)pTheCopy)->Transform(*pTransformer);
00595
00596 return pTheCopy;
00597 }
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611 String_256 OpDuplicateBar::GetNewButtonName(String_256 &Name)
00612 {
00613 String_256 TempButtonName;
00614 INT32 butno = -1;
00615 INT32 i = 0;
00616 for (i = 0; butno < 0 && i < m_ExistingButtonsInBar; i++)
00617 {
00618 if (Name.CompareTo(((TemplateAttribute *) m_ppFoundButton[i])->GetParam()) == 0)
00619 butno = i;
00620 }
00621
00622
00623 if (butno < 0)
00624 {
00625 String_256 ExtenderPostfix;
00626 ExtenderPostfix.Load(_R(IDS_EXTENDER_POSTFIX));
00627
00628 for (i = 0; butno < 0 && i < m_ExistingButtonsInBar; i++)
00629 {
00630 TempButtonName = ((TemplateAttribute *) m_ppFoundButton[i])->GetParam();
00631 TempButtonName += ExtenderPostfix;
00632
00633 if (Name.CompareTo(TempButtonName) == 0)
00634 butno = i;
00635 }
00636 }
00637
00638 if (butno < 0)
00639 butno = m_ExistingButtonsInBar;
00640
00641 TempButtonName.MakeMsg(_R(IDS_BUTTONNAME), m_ButtonNumberList[butno]);
00642 return TempButtonName;
00643 }
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662 OpShortenBar::OpShortenBar(): CarbonCopyOp()
00663 {
00664 }
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682 BOOL OpShortenBar::Init()
00683 {
00684 return (RegisterOpDescriptor(0,
00685 _R(IDS_BARDUPLICATIONOP),
00686 CC_RUNTIME_CLASS(OpShortenBar),
00687 OPTOKEN_SHORTENBAROP,
00688 OpShortenBar::GetState,
00689 0,
00690 0,
00691 0,
00692 0,
00693 SYSTEMBAR_ILLEGAL,
00694 TRUE,
00695 FALSE,
00696 FALSE,
00697 0,
00698 (GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE) ));
00699 }
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713 OpState OpShortenBar::GetState(String_256* UIDescription, OpDescriptor *Bob)
00714 {
00715 OpState OpSt;
00716
00717
00718 OpSt.Greyed = TRUE;
00719 Spread* pSpread = Document::GetSelectedSpread();
00720 if (pSpread && !pSpread->FindActiveLayer()->IsFrame())
00721 OpSt.Greyed = FALSE;
00722
00723 return(OpSt);
00724 }
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740 void OpShortenBar::DoWithParam(OpDescriptor* token, OpParam* pOpParam)
00741 {
00742 if (DoStartSelOp(FALSE,TRUE))
00743 {
00744
00745 TrimBarDownToThisManyButtons(((OpParamShortenBar *)pOpParam)->m_BarName,
00746 ((OpParamShortenBar *)pOpParam)->m_NoOfButtons);
00747
00748
00749 End();
00750
00751 DialogBarOp::SetSystemStateChanged();
00752 DialogBarOp::UpdateStateOfAllBars();
00753
00754 }
00755 else
00756 {
00757 FailAndExecute();
00758 End();
00759 }
00760 }
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776 BOOL OpShortenBar::TrimBarDownToThisManyButtons(const StringBase &BarName, INT32 NewNoOfButtons)
00777 {
00778
00779 String_256 templayer;
00780 templayer.Load(_R(IDS_ROLLOVER_DEFAULT));
00781
00782
00783
00784
00785 Layer * pDef = SliceHelper::FindLayerCalled(templayer);
00786
00787 if (!pDef) return FALSE;
00788
00789 INT32 NumberOfButtons = 0;
00790
00791
00792
00793
00794 TemplateAttribute ** ppFoundButton[MAX_BUTTONS_IN_A_BAR];
00795 DocRect ButtonRect[MAX_BUTTONS_IN_A_BAR];
00796 BYTE Order[MAX_BUTTONS_IN_A_BAR];
00797
00798
00799
00800 SliceHelper::CountButtonsInBarScan(pDef, (TemplateAttribute **) ppFoundButton, &NumberOfButtons, BarName);
00801
00802 if (NumberOfButtons == 0 || NumberOfButtons <= NewNoOfButtons ) return FALSE;
00803
00804
00805
00806
00807
00808
00809
00810 Layer * pLayer = NULL;
00811
00812 List BarList;
00813
00814 templayer.Load(_R(IDS_ROLLOVER_DEFAULT));
00815 pLayer = SliceHelper::FindLayerCalled(templayer);
00816 if (pLayer)
00817 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, BarName);
00818
00819 templayer.Load(_R(IDS_ROLLOVER_MOUSE));
00820 pLayer = SliceHelper::FindLayerCalled(templayer);
00821 if (pLayer)
00822 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, BarName);
00823
00824 templayer.Load(_R(IDS_ROLLOVER_CLICKED));
00825 pLayer = SliceHelper::FindLayerCalled(templayer);
00826 if (pLayer)
00827 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, BarName);
00828
00829 templayer.Load(_R(IDS_ROLLOVER_SELECTED));
00830 pLayer = SliceHelper::FindLayerCalled(templayer);
00831 if (pLayer)
00832 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, BarName);
00833
00834
00835 String_256 ButtonName = "";
00836 NodeListItem *pNodeListItem = NULL;
00837 NodeListItem *pDelThisToo = NULL;
00838 Node *pNode = NULL;
00839 Node *pParent = NULL;
00840
00841 INT32 i = 0;
00842
00843
00844 for (i = 0; i < NumberOfButtons; i++)
00845 {
00846 Order[i] = i;
00847
00848 ButtonName = ((TemplateAttribute *) ppFoundButton[i])->GetParam();
00849 pNodeListItem = (NodeListItem *)BarList.GetHead();
00850 ButtonRect[i].MakeEmpty();
00851
00852 while(pNodeListItem)
00853 {
00854 pNode = pNodeListItem->pNode;
00855 if (pNode)
00856 {
00857 pParent = pNode->FindParent();
00858 if (pParent && ButtonName.CompareTo(((TemplateAttribute *)pNode)->GetParam()) == 0)
00859 {
00860
00861 ButtonRect[i] = ButtonRect[i].Union(((NodeRenderableBounded *)pParent)->GetBoundingRect());
00862 }
00863 }
00864
00865 pNodeListItem = (NodeListItem *)BarList.GetNext(pNodeListItem);
00866 }
00867 }
00868
00869
00870 for (i = 0; i < NumberOfButtons; i++)
00871 {
00872 for (INT32 j = i+1; j < NumberOfButtons; j++)
00873 {
00874 if (ButtonRect[Order[j]].hiy > ButtonRect[Order[i]].hiy)
00875 {
00876 BYTE t = Order[j];
00877 Order[j] = Order[i];
00878 Order[i] = t;
00879 }
00880 else
00881 if (ButtonRect[Order[j]].hiy == ButtonRect[Order[i]].hiy &&
00882 ButtonRect[Order[j]].lox < ButtonRect[Order[i]].lox)
00883 {
00884 BYTE t = Order[j];
00885 Order[j] = Order[i];
00886 Order[i] = t;
00887 }
00888 }
00889 }
00890
00891
00892 pNodeListItem = (NodeListItem *)BarList.GetHead();
00893 pParent = NULL;
00894
00895 ObjChangeFlags cFlags(TRUE);
00896 ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
00897
00898
00899 while(pNodeListItem)
00900 {
00901 pDelThisToo = pNodeListItem;
00902
00903
00904
00905
00906
00907 pParent = pNodeListItem->pNode->FindParent();
00908 if (pParent)
00909 {
00910 ButtonName = ((TemplateAttribute *)pNodeListItem->pNode)->GetParam();
00911
00912 for (i = NewNoOfButtons; i < NumberOfButtons; i++)
00913 {
00914 if (ButtonName.CompareTo(((TemplateAttribute *) ppFoundButton[Order[i]])->GetParam()) == 0
00915 && pParent->AllowOp(&ObjChange))
00916 {
00917
00918 DoInvalidateNodeRegion((NodeRenderableBounded*) pParent, TRUE, FALSE);
00919
00920
00921 pParent->SetSelected(FALSE);
00922 DoHideNode(pParent, TRUE);
00923
00924 i = NumberOfButtons;
00925 }
00926 }
00927 }
00928
00929 pNodeListItem = (NodeListItem *)BarList.GetNext(pNodeListItem);
00930
00931
00932 BarList.RemoveItem((NodeListItem *)pDelThisToo);
00933 delete pDelThisToo;
00934 }
00935
00936
00937 NameGallery * pNameGallery = NameGallery::Instance();
00938 if (pNameGallery)
00939 {
00940 pNameGallery->m_TouchedBar = SliceHelper::GetBarNumberFromBarName(BarName);
00941 }
00942
00943 ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
00944 UpdateChangedNodes(&ObjChange);
00945
00946 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
00947
00948 return TRUE;
00949 }
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960 OpDelBar::OpDelBar(): CarbonCopyOp()
00961 {
00962 }
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977 BOOL OpDelBar::Init()
00978 {
00979 return (RegisterOpDescriptor(0,
00980 _R(IDS_DEL_BAR),
00981 CC_RUNTIME_CLASS(OpDelBar),
00982 OPTOKEN_DELBAROP,
00983 OpDelBar::GetState,
00984 0,
00985 0,
00986 0,
00987 0,
00988 SYSTEMBAR_ILLEGAL,
00989 TRUE,
00990 FALSE,
00991 FALSE,
00992 0,
00993 (GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE) ));
00994 }
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007 OpState OpDelBar::GetState(String_256* UIDescription, OpDescriptor *Bob)
01008 {
01009 OpState OpSt;
01010
01011
01012 OpSt.Greyed = TRUE;
01013 Spread* pSpread = Document::GetSelectedSpread();
01014 if (pSpread && !pSpread->FindActiveLayer()->IsFrame())
01015 OpSt.Greyed = FALSE;
01016
01017 return(OpSt);
01018 }
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032 void OpDelBar::DoWithParam(OpDescriptor* token, OpParam* pOpParam)
01033 {
01034 if (DoStartSelOp(FALSE,TRUE))
01035 {
01036
01037 DelBar(((OpParamDelBar *)pOpParam)->m_BarName, ((OpParamDelBar *)pOpParam)->m_State, this);
01038
01039
01040 End();
01041
01042 DialogBarOp::SetSystemStateChanged();
01043 DialogBarOp::UpdateStateOfAllBars();
01044
01045 }
01046 else
01047 {
01048 FailAndExecute();
01049 End();
01050 }
01051 }
01052
01053 BOOL OpDelBar::DelBar(const StringBase &BarName, INT32 State, UndoableOperation * pOp)
01054 {
01055 String_256 templayer;
01056 Layer * pLayer = NULL;
01057
01058
01059 ObjChangeFlags cFlags;
01060 cFlags.DeleteNode = TRUE;
01061 ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,pOp);
01062
01063 List BarList;
01064
01065 templayer.Load(_R(IDS_ROLLOVER_DEFAULT));
01066 pLayer = SliceHelper::FindLayerCalled(templayer);
01067 Layer * pDefLayer = pLayer;
01068 if ((State == 0 || State == 5 ) && pLayer)
01069 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, BarName);
01070
01071 templayer.Load(_R(IDS_ROLLOVER_MOUSE));
01072 pLayer = SliceHelper::FindLayerCalled(templayer);
01073 if ((State == 1 || State == 5 ) && pLayer)
01074 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, BarName);
01075
01076 templayer.Load(_R(IDS_ROLLOVER_CLICKED));
01077 pLayer = SliceHelper::FindLayerCalled(templayer);
01078 if ((State == 2 || State == 5 ) && pLayer)
01079 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, BarName);
01080
01081 templayer.Load(_R(IDS_ROLLOVER_SELECTED));
01082 pLayer = SliceHelper::FindLayerCalled(templayer);
01083 if ((State == 3 || State == 5 ) && pLayer)
01084 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, BarName);
01085
01086 templayer.Load(_R(IDS_BACK_BAR));
01087 pLayer = SliceHelper::FindLayerCalled(templayer);
01088 if ((State == 4 || State == 5 ) && pLayer)
01089 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, BarName);
01090
01091
01092
01093
01094
01095 NodeListItem *pNodeListItem = (NodeListItem *)BarList.GetHead();
01096
01097 while (pNodeListItem)
01098 {
01099 NodeListItem *pNextNodeListItem = (NodeListItem *)BarList.GetNext(pNodeListItem);
01100
01101 Node * pNode = pNodeListItem->pNode->FindParent();
01102
01103 if (pNode && pNode->AllowOp(&ObjChange))
01104 {
01105 pOp->DoInvalidateNodeRegion((NodeRenderableBounded*) pNode, TRUE, FALSE);
01106 pOp->DoHideNode(pNode, TRUE);
01107 }
01108
01109
01110 BarList.RemoveItem((NodeListItem *)pNodeListItem);
01111 delete pNodeListItem;
01112
01113 pNodeListItem = pNextNodeListItem;
01114 }
01115
01116 ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,pOp);
01117 pOp->UpdateChangedNodes(&ObjChange);
01118
01119 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
01120
01121 return TRUE;
01122 }
01123
01124
01125
01126
01127 OpShowState::OpShowState(): UndoableOperation()
01128 {
01129 }
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144 BOOL OpShowState::Init()
01145 {
01146 return (RegisterOpDescriptor(0,
01147 _R(IDS_SHOWSTATEOP),
01148 CC_RUNTIME_CLASS(OpShowState),
01149 OPTOKEN_SHOWSTATE,
01150 OpShowState::GetState,
01151 0,
01152 0,
01153 0,
01154 0,
01155 SYSTEMBAR_ILLEGAL,
01156 TRUE,
01157 FALSE,
01158 FALSE,
01159 0,
01160 (GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE) ));
01161 }
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174 OpState OpShowState::GetState(String_256* UIDescription, OpDescriptor *Bob)
01175 {
01176 OpState OpSt;
01177
01178
01179 OpSt.Greyed = TRUE;
01180 Spread* pSpread = Document::GetSelectedSpread();
01181 if (pSpread && !pSpread->FindActiveLayer()->IsFrame())
01182 OpSt.Greyed = FALSE;
01183
01184 return(OpSt);
01185 }
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198 void OpShowState::DoWithParam(OpDescriptor* token, OpParam* pOpParam)
01199 {
01200
01201 ShowState(pOpParam->Param1, this);
01202
01203
01204 End();
01205
01206 DialogBarOp::SetSystemStateChanged();
01207 DialogBarOp::UpdateStateOfAllBars();
01208 }
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222 void OpShowState::ShowState(INT32 ShowLayer, UndoableOperation * pOp)
01223 {
01224 Spread* pSelSpread = Document::GetSelectedSpread();
01225 if (pSelSpread == NULL)
01226 return;
01227
01228 String_32 StateName[4];
01229
01230 StateName[DEFAULT].Load(_R(IDS_ROLLOVER_DEFAULT));
01231 StateName[MOUSE].Load(_R(IDS_ROLLOVER_MOUSE));
01232 StateName[CLICKED].Load(_R(IDS_ROLLOVER_CLICKED));
01233 StateName[SELECTED].Load(_R(IDS_ROLLOVER_SELECTED));
01234
01235 Layer * pLayer = pSelSpread->FindFirstLayer();
01236
01237 Layer * pLayerTopLayer = NULL;
01238 BOOL ActiveLayerIsAState = FALSE;
01239 BOOL SetAnActiveLayer = FALSE;
01240
01241 DocRect InvalidRect;
01242
01243 InvalidRect.MakeEmpty();
01244
01245 while (pLayer)
01246 {
01247 BOOL IsStateLayer = FALSE;
01248 INT32 i = 0;
01249 for (i = 0; i < 4 ; i++)
01250 {
01251 if (pLayer->GetLayerID().CompareTo(StateName[i]) == 0)
01252 {
01253 IsStateLayer = TRUE;
01254 if (ShowLayer == 4
01255 || ShowLayer == i)
01256 {
01257 if (!pLayer->IsVisible())
01258 {
01259 if (pOp)
01260 SliceHelper::ShowLayer(TRUE, pLayer, pSelSpread, pOp);
01261 else
01262 pLayer->SetVisible(TRUE);
01263
01264 InvalidRect = InvalidRect.Union(pLayer->GetBoundingRect());
01265 }
01266 }
01267 else
01268 {
01269 if (pLayer->IsVisible())
01270 {
01271 if (pOp)
01272 SliceHelper::ShowLayer(FALSE, pLayer, pSelSpread, pOp);
01273 else
01274 pLayer->SetVisible(FALSE);
01275
01276 InvalidRect = InvalidRect.Union(pLayer->GetBoundingRect());
01277
01278
01279
01280 }
01281 }
01282
01283 if (pLayer->IsActive())
01284 ActiveLayerIsAState = TRUE;
01285 }
01286 }
01287
01288 if (pLayer->IsVisible() && !IsStateLayer)
01289 pLayerTopLayer = pLayer;
01290
01291 pLayer = pLayer->FindNextLayer();
01292 }
01293 }