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 #include "opbarcreation.h"
00104
00105
00106
00107 #include "transop.h"
00108
00109
00110 #include "slice.h"
00111
00112
00113 #include "userattr.h"
00114 #include "tmpltatr.h"
00115
00116 #include "progress.h"
00117
00118
00119
00120
00121
00122 #include "nbevcont.h"
00123 #include "attrbev.h"
00124 #include "opbevel.h"
00125
00126
00127 #include "ngcore.h"
00128 #include "ngitem.h"
00129 #include "ngprop.h"
00130 #include "ngsentry.h"
00131
00132 #include "layermsg.h"
00133 #include "sprdmsg.h"
00134
00135 #include "slicehelper.h"
00136
00137
00138 #include "fillramp.h"
00139 #include "objchge.h"
00140
00141 #include "extender.h"
00142 #include "nodetxts.h"
00143
00144 #include "nodetxts.h"
00145 #include "nodetxtl.h"
00146 #include "nodetext.h"
00147 #include "nodecntr.h"
00148
00149 #include "page.h"
00150
00151 #include "extender.h"
00152
00153
00154 #include "nodeshad.h"
00155
00156 #include "opdupbar.h"
00157
00158 #include "nodeblnd.h"
00159
00160 #ifdef _DEBUG
00161 #undef THIS_FILE
00162 static char BASED_CODE THIS_FILE[] = __FILE__;
00163 #endif
00164
00165 DECLARE_SOURCE("$Revision: 1282 $");
00166
00167 CC_IMPLEMENT_DYNCREATE(OpBarCreation, CarbonCopyOp)
00168
00169 #define new CAM_DEBUG_NEW
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 OpBarCreation::OpBarCreation(): CarbonCopyOp()
00184 {
00185 }
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203 BOOL OpBarCreation::Init()
00204 {
00205 return (RegisterOpDescriptor(0,
00206 _R(IDS_BARCREATIONOP),
00207 CC_RUNTIME_CLASS(OpBarCreation),
00208 OPTOKEN_BARCREATIONOP,
00209 OpBarCreation::GetState,
00210 0,
00211 _R(IDBBL_BARCREATIONOP),
00212 0,
00213 0,
00214 SYSTEMBAR_ILLEGAL,
00215 TRUE,
00216 FALSE,
00217 FALSE,
00218 0,
00219 (GREY_WHEN_NO_CURRENT_DOC) ));
00220 }
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 OpState OpBarCreation::GetState(String_256* UIDescription, OpDescriptor *Bob)
00235 {
00236 OpState OpSt;
00237
00238
00239 OpSt.Greyed = TRUE;
00240 Spread* pSpread = Document::GetSelectedSpread();
00241 if (pSpread && !pSpread->FindActiveLayer()->IsFrame())
00242 OpSt.Greyed = FALSE;
00243
00244 return(OpSt);
00245 }
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262 void OpBarCreation::DoWithParam(OpDescriptor* token, OpParam* pOpParam)
00263 {
00264
00265 if (pOpParam != NULL && DoStartSelOp(FALSE,TRUE))
00266 {
00267
00268
00269 BOOL ok = TRUE;
00270
00271
00272 NameGallery * pNameGallery = NameGallery::Instance();
00273 if (pNameGallery)
00274 {
00275 pNameGallery->m_TouchedBar = SliceHelper::GetBarNumberFromBarName(((OpParamBarCreation*)pOpParam)->m_BarName);
00276 }
00277
00278 if (((OpParamBarCreation*)pOpParam)->m_DelExistingState)
00279 {
00280 INT32 NewLayerNo = 0;
00281
00282 if (((OpParamBarCreation*)pOpParam)->m_WantMouse)
00283 NewLayerNo = 1;
00284 else if (((OpParamBarCreation*)pOpParam)->m_WantClicked)
00285 NewLayerNo = 2;
00286 else if (((OpParamBarCreation*)pOpParam)->m_WantSelected)
00287 NewLayerNo = 3;
00288
00289
00290 OpDelBar::DelBar(((OpParamBarCreation*)pOpParam)->m_BarName, NewLayerNo, this);
00291 }
00292
00293 if (((OpParamBarCreation*)pOpParam)->m_WantBackBar)
00294 {
00295
00296 if (((OpParamBarCreation*)pOpParam)->m_WantDefault)
00297 ok = CreateBarAndBackBar(pOpParam);
00298 else
00299 {
00300 ok = CreateBackBarFromSelection(pOpParam);
00301 if (ok)
00302 InformMessage(_R(IDS_BACKBAR_CREATED_OK));
00303 else
00304 InformWarning(_R(IDS_FAILLED_MAKE_BACKBAR));
00305 }
00306 }
00307 else
00308 {
00309 if (((OpParamBarCreation*)pOpParam)->m_FromSelection)
00310 ok = CreateOrEditBar(pOpParam);
00311 else
00312 ok = CreateFromDefaultState(pOpParam);
00313
00314 if (!ok)
00315 InformWarning(_R(IDS_FAILLED_MAKE_BAR));
00316 }
00317
00318 if (!ok)
00319 FailAndExecute();
00320
00321
00322 End();
00323
00324
00325 DialogBarOp::SetSystemStateChanged();
00326 DialogBarOp::UpdateStateOfAllBars();
00327 }
00328 else
00329 {
00330
00331 FailAndExecute();
00332 End();
00333 }
00334 }
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352 BOOL OpBarCreation::CreateOrEditBar (OpParam* pOpParam)
00353 {
00354 String_256 ActiveLayerStr(_R(IDS_ROLLOVER_DEFAULT));
00355 Spread* pSpread = Document::GetSelectedSpread();
00356 if (pSpread)
00357 {
00358 ActiveLayerStr = pSpread->FindActiveLayer()->GetLayerID();
00359 }
00360
00361 OpParamBarCreation* pBarParam = (OpParamBarCreation*)pOpParam;
00362 if (pBarParam->m_NoOfButtons > MAX_BUTTONS_IN_A_BAR)
00363 return FALSE;
00364
00365
00366 m_BarName = pBarParam->m_BarName;
00367 INT32 BarNo = SliceHelper::GetBarNumberFromBarName(m_BarName);
00368
00369
00370 m_RolloverName[DEFAULT].Load(_R(IDS_ROLLOVER_DEFAULT));
00371 m_RolloverName[MOUSE].Load(_R(IDS_ROLLOVER_MOUSE));
00372 m_RolloverName[CLICKED].Load(_R(IDS_ROLLOVER_CLICKED));
00373 m_RolloverName[SELECTED].Load(_R(IDS_ROLLOVER_SELECTED));
00374 m_RolloverName[BACKBAR].Load(_R(IDS_BACK_BAR));
00375
00376 INT32 NewLayerNo = 0;
00377
00378 if (pBarParam->m_WantMouse)
00379 NewLayerNo = 1;
00380 else if (pBarParam->m_WantClicked)
00381 NewLayerNo = 2;
00382 else if (pBarParam->m_WantSelected)
00383 NewLayerNo = 3;
00384
00385 List SelectionList;
00386 List DelList;
00387 Node * pNode = NULL;
00388
00389
00390 Range Sel(*(GetApplication()->FindSelection()));
00391
00392
00393 RangeControl rg = Sel.GetRangeControlFlags();
00394 rg.PromoteToParent = TRUE;
00395 Sel.Range::SetRangeControl(rg);
00396
00397
00398 if (Extender::ConvertQuickShapesInSelRangeToPaths(this, &Sel))
00399 {
00400 Sel = *(GetApplication()->FindSelection());
00401 rg = Sel.GetRangeControlFlags();
00402 rg.PromoteToParent = TRUE;
00403 Sel.Range::SetRangeControl(rg);
00404 }
00405
00406 if (Sel.IsEmpty())
00407 {
00408 InformWarning(_R(IDS_WARNING_NO_SEL_TEMPLATE));
00409 return FALSE;
00410 }
00411
00412
00413 ObjChangeFlags cFlags;
00414 cFlags.MultiReplaceNode = TRUE;
00415 cFlags.RegenerateNode = TRUE;
00416 ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
00417
00418
00419 if (!Sel.AllowOp(&ObjChange))
00420 return FALSE;
00421
00422
00423
00424 CleanSelection (&Sel, &SelectionList, &DelList, NewLayerNo);
00425
00426 if (SelectionList.IsEmpty())
00427 {
00428 InformWarning(_R(IDS_WARNING_NO_SEL_TEMPLATE));
00429 return FALSE;
00430 }
00431
00432
00433 Layer * pNewLayer = AddLayer(m_RolloverName[NewLayerNo], NewLayerNo);
00434
00435 if (!pNewLayer)
00436 return FALSE;
00437
00438
00439 SliceHelper::BuildListOfNodesInBar(&DelList, pNewLayer, m_BarName);
00440
00441
00442
00443 NodeListItem * pNodeListItem = (NodeListItem *)DelList.GetHead();
00444
00445 while(pNodeListItem)
00446 {
00447 Node *pParent = pNodeListItem->pNode;
00448
00449
00450
00451 if (IS_A(pParent, TemplateAttribute))
00452 {
00453 pParent = pParent->FindParent();
00454 pNodeListItem->pNode = pParent;
00455 }
00456
00457
00458 while (!IS_A(pParent->FindParent(), NodeGroup) && !pParent->FindParent()->IsLayer())
00459 {
00460 pParent = pParent->FindParent();
00461 pNodeListItem->pNode = pParent;
00462 }
00463
00464 pNodeListItem = (NodeListItem *)DelList.GetNext(pNodeListItem);
00465 }
00466
00467
00468 DocRect SelRect;
00469 SelRect.MakeEmpty();
00470 DocRect FullSelRect;
00471 FullSelRect.MakeEmpty();
00472
00473
00474 pNodeListItem = (NodeListItem *)SelectionList.GetHead();
00475
00476 while(pNodeListItem)
00477 {
00478
00479 DoLocaliseForAttrChange((NodeRenderableInk*) pNodeListItem->pNode, (AttrTypeSet *)NULL, (ObjectSet*) NULL);
00480
00481
00482 SelRect = SelRect.Union(SliceHelper::BoundingNodeSize(pNodeListItem->pNode));
00483 if (IS_A(pNodeListItem->pNode, NodeShadowController) || IS_A(pNodeListItem->pNode, TextStory))
00484 FullSelRect = FullSelRect.Union(SliceHelper::BoundingNodeSize(pNodeListItem->pNode));
00485 else
00486 FullSelRect = FullSelRect.Union(((NodeRenderableBounded*)(pNodeListItem->pNode))->GetBoundingRect());
00487
00488 pNodeListItem = (NodeListItem *)SelectionList.GetNext(pNodeListItem);
00489 }
00490
00491
00492 DocCoord SelCentre = SelRect.Centre();
00493
00494
00495 m_BarSelectionRect = SelRect;
00496 m_FinishedBarRect.MakeEmpty();
00497
00498
00499
00500
00501
00502
00503 BOOL LiveStretching = FALSE;
00504 BOOL IgnoreSettings = FALSE;
00505 INT32 m_ExistingButtonsInBar = 0;
00506 DocCoord oldbuttoncentres[MAX_BUTTONS_IN_A_BAR];
00507 TemplateAttribute ** m_ppFoundButton[MAX_BUTTONS_IN_A_BAR];
00508 for (INT32 temp = 0; temp < MAX_BUTTONS_IN_A_BAR; temp++)
00509 {
00510 m_ppFoundButton[temp] = NULL;
00511 }
00512
00513 SliceHelper::CountButtonsInBarScan(pNewLayer, (TemplateAttribute **) m_ppFoundButton, &m_ExistingButtonsInBar, m_BarName);
00514
00515 NodeBarProperty* pNodeBarProperty = (NodeBarProperty*) Document::GetCurrent()->GetSetSentinel()->FindBarProperty();
00516 BarDataType NewBarData = pNodeBarProperty->Bar(BarNo);
00517 if (pNodeBarProperty && BarNo < pNodeBarProperty->HowMany())
00518 {
00519 LiveStretching = NewBarData.IsLive;
00520 }
00521
00522 if (!LiveStretching || !NewBarData.RequiresShuffle)
00523 {
00524
00525
00526
00527 for (INT32 i = 0; i < pBarParam->m_NoOfButtons; i++)
00528 {
00529 List * pList = new List;
00530 DocRect ButtonRect;
00531 ButtonRect.MakeEmpty();
00532
00533 if (!((TemplateAttribute *) m_ppFoundButton[i]))
00534 {
00535 IgnoreSettings = TRUE;
00536 i = pBarParam->m_NoOfButtons;
00537 }
00538 else
00539 {
00540 SliceHelper::BuildListOfNodesInButton(pList, pNewLayer, ((TemplateAttribute *) m_ppFoundButton[i])->GetParam());
00541
00542 NodeListItem * pNodeListItem = NULL;
00543 if (pList)
00544 {
00545 pNodeListItem = (NodeListItem *)pList->GetHead();
00546 }
00547
00548 while(pNodeListItem)
00549 {
00550
00551 DoLocaliseForAttrChange((NodeRenderableInk*) pNodeListItem->pNode, (AttrTypeSet *)NULL, (ObjectSet*) NULL);
00552 ButtonRect = ButtonRect.Union(SliceHelper::BoundingNodeSize(pNodeListItem->pNode));
00553
00554 pNodeListItem = (NodeListItem *)pList->GetNext(pNodeListItem);
00555 }
00556
00557 oldbuttoncentres[i] = ButtonRect.Centre();
00558
00559 pList->DeleteAll();
00560 delete pList;
00561 }
00562 }
00563 }
00564
00565
00566
00567
00568
00569
00570
00571 String_256 Target = "";
00572 String_256 Extender = "";
00573 BOOL MakeItStretch = TRUE;
00574 BOOL TextStoryInSelection = FALSE;
00575 BYTE ExtenderFlags = 0;
00576
00577 DocRect TargetRect;
00578 DocRect ExtenderRect;
00579 DocRect TextRect;
00580 DocRect NoTextRect;
00581
00582
00583 pNodeListItem = (NodeListItem *)SelectionList.GetHead();
00584 Node * pTextStory = NULL;
00585
00586 INT32 RequiredLevel = 0;
00587 while (pNodeListItem && RequiredLevel < 2)
00588 {
00589 Node * pCurrent = pNodeListItem->pNode;
00590
00591 RequiredLevel = SliceHelper::FindTargetAndExtender(pCurrent, Target, Extender, RequiredLevel, &ExtenderFlags,
00592 &TargetRect, &ExtenderRect);
00593 pTextStory = SliceHelper::FindNextOfClass(pCurrent, pCurrent, CC_RUNTIME_CLASS(TextStory), TRUE);
00594 if (pTextStory)
00595 {
00596 TextStoryInSelection = TRUE;
00597 TextRect = TextRect.Union(SliceHelper::BoundingNodeSize(pCurrent));
00598
00599
00600 while (!pTextStory->IsLayer())
00601 {
00602 if (IS_A(pTextStory, NodeGroup))
00603 {
00604 InformWarning(_R(IDS_WARNING_GROUPED_TEXT));
00605 SelectionList.DeleteAll();
00606 DelList.DeleteAll();
00607 return FALSE;
00608 }
00609 pTextStory = pTextStory->FindParent();
00610 }
00611
00612 }
00613 else
00614 NoTextRect = NoTextRect.Union(SliceHelper::BoundingNodeSize(pCurrent));
00615
00616
00617 pNodeListItem = (NodeListItem *)SelectionList.GetNext(pNodeListItem);
00618 }
00619
00620
00621
00622 if (RequiredLevel > 1 || !TextStoryInSelection || NoTextRect.IsEmpty())
00623 MakeItStretch = FALSE;
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634 class ButtonDataType
00635 {
00636 public:
00637 DocCoord Translation;
00638 String_256 Name;
00639 BOOL HaveCreatedProperty;
00640 TextStory * pOriginalStory;
00641 String_256 Storytext;
00642 DocRect OriginalTextStoryDims;
00643 DocRect NewTextStoryDims;
00644 } ButtonData[MAX_BUTTONS_IN_A_BAR];
00645
00646 INT32 ButtonsInitialised = 0;
00647
00648
00649
00650 NameGallery * pNameGallery = NameGallery::Instance();
00651
00652 if (pNameGallery)
00653 {
00654 pNameGallery->FastUpdateNamedSetSizes();
00655
00656 SGUsedNames* pNames = pNameGallery->GetUsedNames();
00657 SGNameItem* pNameGalleryItem = pNames ? (SGNameItem*) pNames->GetChild() : NULL;
00658
00659
00660 while (pNameGalleryItem)
00661 {
00662 if (pNameGalleryItem->m_BarNumber == BarNo && !pNameGalleryItem->IsEmpty() && !pNameGalleryItem->IsABackBar())
00663 {
00664
00665 pNameGalleryItem->GetNameText(&(ButtonData[ButtonsInitialised].Name));
00666 ButtonData[ButtonsInitialised].HaveCreatedProperty = FALSE;
00667
00668
00669
00670
00671
00672
00673 BOOL LiveStretching = FALSE;
00674 NodeBarProperty* pNodeBarProperty = (NodeBarProperty*) Document::GetCurrent()->GetSetSentinel()->FindBarProperty();
00675 BarDataType NewBarData = pNodeBarProperty->Bar(BarNo);
00676 if (pNodeBarProperty && BarNo < pNodeBarProperty->HowMany())
00677 {
00678 LiveStretching = NewBarData.IsLive;
00679 }
00680
00681
00682 if ((!LiveStretching || !NewBarData.RequiresShuffle) && !IgnoreSettings)
00683 {
00684
00685
00686
00687 ButtonData[ButtonsInitialised].Translation.x = oldbuttoncentres[ButtonsInitialised].x - SelCentre.x;
00688 ButtonData[ButtonsInitialised].Translation.y = oldbuttoncentres[ButtonsInitialised].y - SelCentre.y;
00689 }
00690 else
00691 {
00692
00693 ButtonData[ButtonsInitialised].Translation.x = pNameGalleryItem->GetSetBounds().Centre().x - SelCentre.x;
00694 ButtonData[ButtonsInitialised].Translation.y = pNameGalleryItem->GetSetBounds().Centre().y - SelCentre.y;
00695 }
00696
00697 ButtonsInitialised++;
00698
00699 }
00700 pNameGalleryItem = (SGNameItem *) pNameGalleryItem->GetNext();
00701 }
00702 }
00703
00704
00705 INT32 listbuttonno = 0;
00706 for (;ButtonsInitialised < pBarParam->m_NoOfButtons; ButtonsInitialised++)
00707 {
00708
00709 SliceHelper::GetNextFreeButtonName(listbuttonno, &(ButtonData[ButtonsInitialised].Name));
00710 ButtonData[ButtonsInitialised].HaveCreatedProperty = FALSE;
00711
00712 if (ButtonsInitialised == 0)
00713 {
00714 ButtonData[ButtonsInitialised].Translation.x = 0;
00715 ButtonData[ButtonsInitialised].Translation.y = 0;
00716
00717 }
00718 else
00719 {
00720 if (pBarParam->m_IsVertical)
00721 {
00722 ButtonData[ButtonsInitialised].Translation.x = ButtonData[ButtonsInitialised-1].Translation.x;
00723
00724 ButtonData[ButtonsInitialised].Translation.y = ButtonData[ButtonsInitialised-1].Translation.y
00725 - pBarParam->m_Spacing - SelRect.Height();
00726
00727
00728 if (pBarParam->m_Spacing == 0 || pBarParam->m_Spacing >= 3750)
00729 ButtonData[ButtonsInitialised].Translation.y = (ButtonData[ButtonsInitialised].Translation.y /750)*750;
00730 }
00731 else
00732 {
00733 ButtonData[ButtonsInitialised].Translation.x = ButtonData[ButtonsInitialised-1].Translation.x
00734 + pBarParam->m_Spacing + SelRect.Width();
00735
00736 ButtonData[ButtonsInitialised].Translation.y = ButtonData[ButtonsInitialised-1].Translation.y;
00737
00738
00739 if (pBarParam->m_Spacing == 0 || pBarParam->m_Spacing >= 3750)
00740 ButtonData[ButtonsInitialised].Translation.x = (ButtonData[ButtonsInitialised].Translation.x /750)*750;
00741 }
00742 }
00743 }
00744
00745
00746 for (ButtonsInitialised = 0; ButtonsInitialised < pBarParam->m_NoOfButtons; ButtonsInitialised++)
00747 {
00748 ButtonData[ButtonsInitialised].pOriginalStory = SliceHelper::FindNextTextStoryToSync( NULL,
00749 pNewLayer,
00750 NULL,
00751 ButtonData[ButtonsInitialised].Name,
00752 "",
00753 TRUE);
00754
00755 if (ButtonData[ButtonsInitialised].pOriginalStory)
00756 ButtonData[ButtonsInitialised].Storytext = ButtonData[ButtonsInitialised].pOriginalStory->GetStoryAsString();
00757
00758
00759 ButtonData[ButtonsInitialised].OriginalTextStoryDims.MakeEmpty();
00760 ButtonData[ButtonsInitialised].NewTextStoryDims.MakeEmpty();
00761 }
00762
00763
00764 SliceHelper::ShowLayer(TRUE, pNewLayer, pSpread, this);
00765 LayerSGallery::MakeActiveLayer(pNewLayer, FALSE);
00766
00767
00768 Node * pTail = pNewLayer;
00769 AttachNodeDirection TailAttachDirection = FIRSTCHILD;
00770
00771 pNodeListItem = NULL;
00772 Trans2DMatrix Transformer;
00773
00774
00775
00776 INT32 but;
00777 for (but = 0; but < pBarParam->m_NoOfButtons; but++)
00778 {
00779
00780 pNodeListItem = (NodeListItem *)SelectionList.GetHead();
00781
00782
00783 Transformer.SetTransform( ButtonData[but].Translation.x,
00784 ButtonData[but].Translation.y);
00785
00786 while (pNodeListItem)
00787 {
00788 pNode = pNodeListItem->pNode;
00789 if (pNode)
00790 {
00791
00792
00793 Node* pTheCopy;
00794 BOOL ok;
00795
00796 CALL_WITH_FAIL(pNode->NodeCopy(&pTheCopy), this, ok);
00797
00798 if (ok && !DoInsertNewNode((NodeRenderableBounded *)pTheCopy, pTail, TailAttachDirection,
00799 TRUE,
00800 FALSE))
00801 {
00802 ok = FALSE;
00803 }
00804
00805 if (ok)
00806 {
00807
00808 pTheCopy->SetSelected(but == 0);
00809
00810
00811 ((NodeRenderableBounded *)pTheCopy)->Transform(Transformer);
00812 pTheCopy->AllowOp(&ObjChange);
00813 DoInvalidateNodeRegion((NodeRenderableBounded*) pTheCopy, TRUE, FALSE);
00814
00815
00816 m_FinishedBarRect = m_FinishedBarRect.Union(SliceHelper::BoundingNodeSize(pTheCopy));
00817
00818
00819 if (ButtonData[but].pOriginalStory && !ButtonData[but].Storytext.IsEmpty())
00820 {
00821 TextStory * pStory = (TextStory *) SliceHelper::FindNextOfClass(pTheCopy, pTheCopy, CC_RUNTIME_CLASS(TextStory), TRUE);
00822 while (pStory)
00823 {
00824
00825 Node * pNodeSetSentinel = Document::GetSelected()->GetSetSentinel();
00826 NodeBarProperty * pNodeBarProperty = (NodeBarProperty*) ((NodeSetSentinel *)pNodeSetSentinel)->FindBarProperty();
00827 INT32 alignment = pNodeBarProperty->Bar(BarNo).SameSize;
00828
00829
00830 DocRect OldRect = SliceHelper::BoundingNodeSize(pStory);
00831 BOOL changed = SliceHelper::SyncTextStories(pStory, ButtonData[but].pOriginalStory, this);
00832 if (changed)
00833 {
00834 DocRect NewRect = SliceHelper::BoundingNodeSize(pStory);
00835
00836 INT32 tx = OldRect.Centre().x - NewRect.Centre().x;
00837 INT32 ty = OldRect.Centre().y - NewRect.Centre().y;
00838
00839 if (alignment == 1)
00840 tx = OldRect.lox - NewRect.lox;
00841 else
00842 if (alignment == 2)
00843 tx = OldRect.hix - NewRect.hix;
00844
00845 Trans2DMatrix TextTransformer(tx, ty);
00846 pStory->Transform(TextTransformer);
00847
00848 if (alignment == 3)
00849 {
00850 NewRect.Translate(tx,ty);
00851 ButtonData[but].NewTextStoryDims = ButtonData[but].NewTextStoryDims.Union(NewRect);
00852 ButtonData[but].OriginalTextStoryDims = ButtonData[but].OriginalTextStoryDims.Union(OldRect);
00853 }
00854 }
00855
00856 pStory = (TextStory *) SliceHelper::FindNextOfClass(pStory, pTheCopy, CC_RUNTIME_CLASS(TextStory));
00857 }
00858 }
00859
00860
00861 if (!Target.IsEmpty())
00862 {
00863 TemplateAttribute * pTemplateAttribute = (TemplateAttribute *) SliceHelper::FindNextOfClass(pTheCopy, pTheCopy, CC_RUNTIME_CLASS(TemplateAttribute));
00864 while (pTemplateAttribute)
00865 {
00866 TemplateAttribute * pNextTemplateAttribute = (TemplateAttribute *) SliceHelper::FindNextOfClass(pTemplateAttribute, pTheCopy, CC_RUNTIME_CLASS(TemplateAttribute));
00867
00868 if (Target.CompareTo(pTemplateAttribute->GetParam()) == 0)
00869 {
00870
00871
00872
00873
00874 DoHideNode(pTemplateAttribute, TRUE);
00875 }
00876 else if (!Extender.IsEmpty() && Extender.CompareTo(pTemplateAttribute->GetParam()) == 0)
00877 {
00878
00879
00880
00881
00882
00883
00884 String_32 ExtenderPostfix;
00885 ExtenderPostfix.Load(_R(IDS_EXTENDER_POSTFIX));
00886 String_256 NewExtenderName = ButtonData[but].Name;
00887 NewExtenderName += ExtenderPostfix;
00888
00889 ApplyNameAttr(&NewExtenderName, pTheCopy, FALSE);
00890
00891
00892
00893 DoHideNode(pTemplateAttribute, TRUE);
00894
00895 if (!ButtonData[but].HaveCreatedProperty)
00896 {
00897 TRACE( _T("redef from existing data\n"));
00898
00899 DocRect TempTarget(TargetRect);
00900 TempTarget.Translate( ButtonData[but].Translation.x,
00901 ButtonData[but].Translation.y);
00902 DocRect TempExtender(ExtenderRect);
00903 TempExtender.Translate( ButtonData[but].Translation.x,
00904 ButtonData[but].Translation.y);
00905
00906
00907 SliceHelper::CreatePropertiesForSet(ButtonData[but].Name, m_BarName, TRUE, ExtenderFlags != 0, FALSE, ExtenderFlags,
00908 NewExtenderName, FALSE, &TempTarget, &TempExtender,
00909 this);
00910
00911
00912 SliceHelper::CreatePropertiesForSet(NewExtenderName, TEXT(""), FALSE, FALSE, FALSE, 0,
00913 TEXT(""), FALSE, NULL, NULL, this);
00914
00915 ButtonData[but].HaveCreatedProperty = TRUE;
00916 }
00917 }
00918 pTemplateAttribute = pNextTemplateAttribute;
00919 }
00920 }
00921
00922
00923 if (MakeItStretch)
00924 {
00925 if (IS_A(pTheCopy,TextStory) || SliceHelper::FindNextOfClass(pTheCopy, pTheCopy, CC_RUNTIME_CLASS(TextStory)))
00926 {
00927
00928
00929
00930
00931
00932
00933 String_32 ExtenderPostfix;
00934 ExtenderPostfix.Load(_R(IDS_EXTENDER_POSTFIX));
00935 String_256 NewExtenderName = ButtonData[but].Name;
00936 NewExtenderName += ExtenderPostfix;
00937
00938 ApplyNameAttr(&NewExtenderName, pTheCopy, FALSE);
00939
00940 if (!ButtonData[but].HaveCreatedProperty)
00941 {
00942 DocRect TempTarget(NoTextRect);
00943 TempTarget.Translate( ButtonData[but].Translation.x,
00944 ButtonData[but].Translation.y);
00945 DocRect TempExtender(TextRect);
00946 TempExtender.Translate( ButtonData[but].Translation.x,
00947 ButtonData[but].Translation.y);
00948
00949
00950 SliceHelper::CreatePropertiesForSet(ButtonData[but].Name, m_BarName, TRUE, pBarParam->m_ExtendFlags != 0, FALSE,
00951 pBarParam->m_ExtendFlags, NewExtenderName, FALSE,
00952 &TempTarget, &TempExtender, this);
00953
00954
00955 SliceHelper::CreatePropertiesForSet(NewExtenderName, m_BarName, FALSE, FALSE, FALSE, 0,
00956 TEXT(""), FALSE, NULL, NULL, this);
00957
00958 ButtonData[but].HaveCreatedProperty = TRUE;
00959 }
00960 }
00961 }
00962
00963
00964 ApplyNameAttr(&ButtonData[but].Name, pTheCopy);
00965
00966
00967
00968
00969 if (Extender.IsEmpty() && !ButtonData[but].HaveCreatedProperty && !MakeItStretch)
00970 {
00971 SliceHelper::CreatePropertiesForSet(ButtonData[but].Name, m_BarName, TRUE, FALSE, FALSE,
00972 0, TEXT(""), FALSE, NULL, NULL, this);
00973 ButtonData[but].HaveCreatedProperty = TRUE;
00974 }
00975
00976
00977 if (pTheCopy->IsCompound() && !pTheCopy->IsABlend())
00978 DoFactorOutCommonChildAttributes((NodeRenderableInk*) pTheCopy);
00979 else
00980 DoFactorOutAfterAttrChange((NodeRenderableInk*) pTheCopy, (AttrTypeSet *)NULL);
00981
00982
00983 TailAttachDirection = NEXT;
00984 pTail = pTheCopy;
00985 }
00986 }
00987
00988
00989 pNodeListItem = (NodeListItem *)SelectionList.GetNext(pNodeListItem);
00990 }
00991 }
00992
00993
00994 pNodeListItem = (NodeListItem *)SelectionList.GetHead();
00995 NodeListItem *pNodeListItemToDel = NULL;
00996
00997 while (pNodeListItem)
00998 {
00999 pNodeListItemToDel = pNodeListItem;
01000 pNodeListItem = (NodeListItem *)SelectionList.GetNext(pNodeListItem);
01001 SelectionList.RemoveItem((NodeListItem *)pNodeListItemToDel);
01002 delete pNodeListItemToDel;
01003 }
01004
01005
01006 pNodeListItem = (NodeListItem *)DelList.GetHead();
01007
01008 while(pNodeListItem)
01009 {
01010 Node *pParent = pNodeListItem->pNode;
01011
01012 BOOL HideIt = TRUE;
01013 NodeListItem * pPreviousNodeListItem = (NodeListItem *)DelList.GetHead();
01014
01015
01016
01017
01018 while (pPreviousNodeListItem && pPreviousNodeListItem != pNodeListItem && HideIt)
01019 {
01020
01021 if (pParent == pPreviousNodeListItem->pNode)
01022 {
01023 HideIt = FALSE;
01024
01025 }
01026
01027 pPreviousNodeListItem = (NodeListItem *)DelList.GetNext(pPreviousNodeListItem);
01028 }
01029
01030
01031 if (HideIt)
01032 {
01033 DoInvalidateNodeRegion((NodeRenderableBounded*) pParent, TRUE, FALSE);
01034 pParent->SetSelected(FALSE);
01035 DoHideNode(pParent, TRUE);
01036 }
01037
01038 pNodeListItem = (NodeListItem *)DelList.GetNext(pNodeListItem);
01039 }
01040
01041
01042 pNodeListItem = (NodeListItem *)DelList.GetHead();
01043 pNodeListItemToDel = NULL;
01044
01045 while(pNodeListItem)
01046 {
01047 pNodeListItemToDel = pNodeListItem;
01048 pNodeListItem = (NodeListItem *)DelList.GetNext(pNodeListItem);
01049 DelList.RemoveItem((NodeListItem *)pNodeListItemToDel);
01050 delete pNodeListItemToDel;
01051 }
01052
01053
01054
01055
01056
01057 for (but = 0; but < pBarParam->m_NoOfButtons; but++)
01058 {
01059 NodeSetSentinel * pNodeSetSentinel = Document::GetSelected()->GetSetSentinel();
01060 if (ButtonData[but].OriginalTextStoryDims != ButtonData[but].NewTextStoryDims)
01061 {
01062 NodeSetProperty * pProp = pNodeSetSentinel->FindPropertyNode(ButtonData[but].Name);
01063 NamedStretchProp* pStretchProp = pProp ? (NamedStretchProp*) pProp->GetProperty(NamedStretchProp::nIndex) : NULL;
01064
01065 if (pStretchProp)
01066 {
01067
01068 DocRect ButtonRect = TargetRect;
01069 if (ButtonRect.IsEmpty() || !ButtonRect.IsValid())
01070 ButtonRect = SelRect;
01071
01072 ButtonRect.Translate( ButtonData[but].Translation.x,
01073 ButtonData[but].Translation.y);
01074
01075 Node * pNode = SliceHelper::FindNextNameNode(pNewLayer, pNewLayer);
01076
01077 while (pNode)
01078 {
01079 Node * pParent = pNode->FindParent();
01080 if (!IS_A(pParent, TextStory) && ButtonData[but].Name.CompareTo(((TemplateAttribute *)pNode)->GetParam()) == 0)
01081
01082 Extender::Extend((NodeRenderableInk*) (pParent),
01083 pBarParam->m_ExtendFlags,
01084 pStretchProp->GetRefUnionTriggerBounds(),
01085 pStretchProp->GetRefTargetBounds(),
01086 ButtonData[but].NewTextStoryDims,
01087 ButtonData[but].OriginalTextStoryDims,
01088 ButtonRect,
01089 NULL,
01090 TRUE
01091 );
01092
01093 pNode = SliceHelper::FindNextNameNode(pNode, pNewLayer);
01094 }
01095 }
01096 }
01097 }
01098
01099
01100
01101 Layer* pActiveLayer = SliceHelper::FindLayerCalled(ActiveLayerStr);
01102 if (pActiveLayer != 0)
01103 LayerSGallery::MakeActiveLayer(pActiveLayer, FALSE);
01104
01105
01106 BROADCAST_TO_ALL(LayerMsg(pActiveLayer, LayerMsg::LayerReason::LAYER_VISIBILITY_CHANGED));
01107
01108
01109 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
01110 GetApplication()->UpdateSelection();
01111
01112 ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
01113 UpdateChangedNodes(&ObjChange);
01114
01115 return TRUE;
01116 }
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133 void OpBarCreation::Do(OpDescriptor* token)
01134 {
01135 OpParamBarCreation BarParam;
01136 DoWithParam(token, &BarParam);
01137 }
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152 Layer * OpBarCreation::AddLayer(String_256 LayerName, INT32 NewLayerNo)
01153 {
01154 Spread* pSpread = Document::GetSelectedSpread();
01155 if (pSpread == NULL)
01156 return NULL;
01157
01158
01159 Layer * pStandardLayer = SliceHelper::FindLayerCalled(LayerName);
01160 if (pStandardLayer)
01161 {
01162 LayerSGallery::MakeActiveLayer(pStandardLayer, FALSE);
01163 return pStandardLayer;
01164 }
01165
01166
01167 Layer* pLayer = NULL;
01168 Node* pContextNode= pSpread;
01169 AttachNodeDirection AttDir = FIRSTCHILD;
01170 LayerStatus NewStatus;
01171 NewStatus.StringLayerID = LayerName;
01172
01173
01174 Node * pNode = pSpread->FindFirstChild();
01175 while (pNode)
01176 {
01177
01178 if (IS_A(pNode, Page))
01179 {
01180 pContextNode = pNode;
01181 AttDir = NEXT;
01182 }
01183
01184 else if (pNode->IS_KIND_OF(Layer))
01185 {
01186 if (((Layer *)pNode)->IsBackground())
01187 {
01188 pContextNode = pNode;
01189 AttDir = NEXT;
01190 }
01191 }
01192
01193 pNode = pNode->FindNext();
01194 }
01195
01196
01197 BOOL FoundHigherLayer = FALSE;
01198 INT32 LayerToFind = NewLayerNo-1;
01199 while (!FoundHigherLayer && LayerToFind >= DEFAULT)
01200 {
01201 pStandardLayer = SliceHelper::FindLayerCalled(m_RolloverName[LayerToFind]);
01202 if (pStandardLayer)
01203 {
01204 FoundHigherLayer = TRUE;
01205
01206 pContextNode = pStandardLayer;
01207 AttDir = PREV;
01208 }
01209 else
01210 {
01211 LayerToFind--;
01212 }
01213 }
01214
01215
01216 ALLOC_WITH_FAIL(pLayer, (new Layer()), this);
01217 if (pLayer == NULL) return NULL;
01218
01219
01220 pLayer->SetLayerStatus(NewStatus);
01221
01222 if (DoInsertNewNode(pLayer,pContextNode,AttDir,FALSE))
01223 {
01224 LayerSGallery::MakeActiveLayer(pLayer, FALSE);
01225 }
01226
01227 return pLayer;
01228 }
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245 BOOL OpBarCreation::ApplyNameAttr(String_256 * pNameAttr, Node * pNode, BOOL UseBarName)
01246 {
01247 TemplateAttribute* pAttr = new TemplateAttribute( String_256(TEXT("ObjectName")),
01248 UseBarName ? m_BarName : "",
01249 *pNameAttr);
01250
01251 if (!pAttr) return FALSE;
01252
01253
01254 pAttr->AttachNode(pNode, FIRSTCHILD);
01255
01256 return TRUE;
01257 }
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276 void OpBarCreation::FindAttribColours(Node * pAttrNode, INT32 PercentColourChange, INT32 State)
01277 {
01278 if (pAttrNode->IsAnAttribute())
01279 {
01280
01281 if (PercentColourChange != 100 && pAttrNode->IsKindOf(CC_RUNTIME_CLASS(AttrFlatColourFill)))
01282 {
01283 DocColour* pdoccol = ((AttrFlatColourFill *)pAttrNode)->GetStartColour();
01284 ShiftColourValue(pdoccol, PercentColourChange);
01285 }
01286
01287 else if (PercentColourChange != 100 && pAttrNode->IsKindOf(CC_RUNTIME_CLASS(AttrFillGeometry)))
01288 {
01289 ColRampItem* pColItem;
01290 ColourRamp* pColRamp = ((AttrFillGeometry*)pAttrNode)->GetColourRamp();
01291 if (pColRamp != NULL)
01292 {
01293 pColItem = pColRamp->GetFirstCol();
01294 while (pColItem != NULL)
01295 {
01296 ShiftColourValue(pColItem->GetColourAddr(), PercentColourChange);
01297 pColItem = pColRamp->GetNextCol(pColItem);
01298 }
01299 }
01300
01301 DocColour* pdoccol = ((AttrFillGeometry *)pAttrNode)->GetStartColour();
01302 ShiftColourValue(pdoccol, PercentColourChange);
01303 pdoccol = ((AttrFillGeometry *)pAttrNode)->GetEndColour();
01304 ShiftColourValue(pdoccol, PercentColourChange);
01305 pdoccol = ((AttrFillGeometry *)pAttrNode)->GetEndColour2();
01306 ShiftColourValue(pdoccol, PercentColourChange);
01307 pdoccol = ((AttrFillGeometry *)pAttrNode)->GetEndColour3();
01308 ShiftColourValue(pdoccol, PercentColourChange);
01309 }
01310
01311 else if (State == SELECTED && pAttrNode->IsKindOf(CC_RUNTIME_CLASS(AttrBevelLightAngle)))
01312 {
01313
01314 INT32 angle = 135;
01315 Node * pParent = pAttrNode->FindParent();
01316 if (pParent->IsKindOf(CC_RUNTIME_CLASS(NodeBevelController)))
01317 {
01318 angle = (INT32)((NodeBevelController *)pAttrNode->FindParent())->m_LightAngle + 180;
01319 if (angle > 360) angle -= 360;
01320 }
01321 ((AttrBevelLightAngle *)pAttrNode)->SetValue(angle);
01322 }
01323 }
01324 else
01325 {
01326 Node * pChildNode = pAttrNode->FindFirstChild();
01327
01328 while (pChildNode)
01329 {
01330
01331 FindAttribColours(pChildNode, PercentColourChange, State);
01332 pChildNode = pChildNode->FindNext();
01333 }
01334 }
01335 }
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352 void OpBarCreation::ShiftColourValue(DocColour* pdoccol, INT32 PercentColourChange)
01353 {
01354 if (!pdoccol || pdoccol->IsTransparent())
01355 return;
01356
01357 INT32 h,s,v;
01358
01359 pdoccol->GetHSVValue(&h, &s, &v);
01360
01361
01362
01363 if (PercentColourChange != 0)
01364 {
01365 v -= PercentColourChange - 100;
01366 if (v < 0)
01367 {
01368 s -= v*2;
01369 if (s > 255) s = 255;
01370 v = 0;
01371 }
01372 else
01373 if (v > 255)
01374 {
01375 s -= (v-255)*2;
01376 if (s < 0) s = 0;
01377 v = 255;
01378 }
01379 }
01380 else
01381 {
01382 h += 35;
01383 if (h > 255)
01384 h -= 255;
01385 }
01386 pdoccol->SetHSVValue(h, s, v);
01387
01388 }
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400 NodeBarProperty* GetBarData()
01401 {
01402 return (NodeBarProperty*) Document::GetCurrent()->GetSetSentinel()->FindBarProperty();
01403 }
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417 BOOL OpBarCreation::CreateFromDefaultState (OpParam* pOpParam)
01418 {
01419
01420
01421 String_256 ActiveLayerStr(_R(IDS_ROLLOVER_DEFAULT));
01422 Spread* pSpread = Document::GetSelectedSpread();
01423 if (pSpread)
01424 {
01425 ActiveLayerStr = pSpread->FindActiveLayer()->GetLayerID();
01426 }
01427
01428 OpParamBarCreation* pBarParam = (OpParamBarCreation*)pOpParam;
01429
01430
01431 m_BarName = pBarParam->m_BarName;
01432
01433
01434 m_RolloverName[DEFAULT].Load(_R(IDS_ROLLOVER_DEFAULT));
01435 m_RolloverName[MOUSE].Load(_R(IDS_ROLLOVER_MOUSE));
01436 m_RolloverName[CLICKED].Load(_R(IDS_ROLLOVER_CLICKED));
01437 m_RolloverName[SELECTED].Load(_R(IDS_ROLLOVER_SELECTED));
01438 m_RolloverName[BACKBAR].Load(_R(IDS_BACK_BAR));
01439
01440 INT32 NewLayerNo = 0;
01441
01442 if (pBarParam->m_WantMouse)
01443 NewLayerNo = 1;
01444 else if (pBarParam->m_WantClicked)
01445 NewLayerNo = 2;
01446 else if (pBarParam->m_WantSelected)
01447 NewLayerNo = 3;
01448
01449
01450 Layer * pNewLayer = AddLayer(m_RolloverName[NewLayerNo], NewLayerNo);
01451
01452 if (!pNewLayer)
01453 return FALSE;
01454
01455
01456 SliceHelper::ShowLayer(TRUE, pNewLayer, pSpread, this);
01457
01458 Layer * pLayer = NULL;
01459
01460 List BarList;
01461
01462 pLayer = SliceHelper::FindLayerCalled(m_RolloverName[DEFAULT]);
01463
01464 if (!pLayer)
01465 return FALSE;
01466
01467
01468 ObjChangeFlags cFlags;
01469 cFlags.RegenerateNode = TRUE;
01470 ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
01471
01472
01473 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, m_BarName);
01474
01475
01476 NodeListItem * pNodeListItem = (NodeListItem *)BarList.GetHead();
01477 NodeListItem * pDelThisToo = NULL;
01478
01479 Node * pTail = pNewLayer;
01480 AttachNodeDirection TailAttachDirection = FIRSTCHILD;
01481
01482 while(pNodeListItem)
01483 {
01484 pDelThisToo = pNodeListItem;
01485 Node *pNode = pNodeListItem->pNode->FindParent();
01486 if (pNode)
01487 {
01488
01489
01490 Node* pTheCopy;
01491 BOOL ok = TRUE;
01492
01493 if (ok)
01494 CALL_WITH_FAIL(pNode->NodeCopy(&pTheCopy), this, ok);
01495
01496 if (ok && pBarParam->m_SuggestDesign)
01497 {
01498 INT32 ColShift = 100;
01499 if (NewLayerNo == MOUSE)
01500 ColShift = 40;
01501 else if (NewLayerNo == SELECTED)
01502 ColShift = 150;
01503 else if (NewLayerNo == CLICKED)
01504 ColShift = 0;
01505
01506 FindAttribColours(pTheCopy, ColShift, NewLayerNo);
01507 }
01508
01509 if (ok && !DoInsertNewNode((NodeRenderableBounded *)pTheCopy, pTail, TailAttachDirection,
01510 TRUE,
01511 FALSE))
01512 {
01513 ok = FALSE;
01514 }
01515
01516 if (ok)
01517 {
01518
01519
01520
01521 if (NewLayerNo == SELECTED && pBarParam->m_SuggestDesign)
01522 {
01523
01524 Node * pBev = SliceHelper::FindNextOfClass(pTheCopy, pTheCopy, CC_RUNTIME_CLASS(NodeBevelController), TRUE );
01525 if (pBev && !SliceHelper::FindNextOfClass(pTheCopy, pTheCopy, CC_RUNTIME_CLASS(AttrBevelLightAngle) ))
01526 {
01527
01528 AttrBevelLightAngle* pNewLightAttr = new AttrBevelLightAngle();
01529 if (pNewLightAttr)
01530 {
01531 pNewLightAttr->Value.m_LightAngle = 120;
01532
01533 pNewLightAttr->AttachNode(pTheCopy, FIRSTCHILD);
01534
01535 }
01536 }
01537 }
01538
01539
01540 pTheCopy->SetSelected(FALSE);
01541
01542
01543 pTheCopy->AllowOp(&ObjChange);
01544
01545
01546 TailAttachDirection = NEXT;
01547 pTail = pTheCopy;
01548 }
01549 }
01550
01551 pNodeListItem = (NodeListItem *)BarList.GetNext(pNodeListItem);
01552
01553
01554 BarList.RemoveItem((NodeListItem *)pDelThisToo);
01555 delete pDelThisToo;
01556 }
01557
01558
01559
01560 Layer* pActiveLayer = SliceHelper::FindLayerCalled(ActiveLayerStr);
01561 if (pActiveLayer != 0)
01562 LayerSGallery::MakeActiveLayer(pActiveLayer, FALSE);
01563
01564
01565 ShowState(NewLayerNo);
01566
01567
01568 BROADCAST_TO_ALL(LayerMsg(pActiveLayer, LayerMsg::LayerReason::LAYER_VISIBILITY_CHANGED));
01569 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
01570
01571 ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
01572 UpdateChangedNodes(&ObjChange);
01573
01574
01575
01576 GetApplication()->UpdateSelection();
01577 return TRUE;
01578 }
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589 BOOL OpBarCreation::CreateBackBarFromSelection (OpParam* pOpParam, BOOL Extend)
01590 {
01591 String_256 ActiveLayerStr(_R(IDS_ROLLOVER_DEFAULT));
01592 Spread* pSpread = Document::GetSelectedSpread();
01593 if (pSpread)
01594 {
01595 ActiveLayerStr = pSpread->FindActiveLayer()->GetLayerID();
01596 }
01597
01598 OpParamBarCreation* pBarParam = (OpParamBarCreation*)pOpParam;
01599
01600
01601 m_BarName = pBarParam->m_BarName;
01602
01603
01604 String_256 BackBarName = "";
01605 BackBarName.MakeMsg(_R(IDS_BACKBARNAME), SliceHelper::GetBarNumberFromBarName(m_BarName) +1);
01606
01607
01608 m_RolloverName[DEFAULT].Load(_R(IDS_ROLLOVER_DEFAULT));
01609 m_RolloverName[MOUSE].Load(_R(IDS_ROLLOVER_MOUSE));
01610 m_RolloverName[CLICKED].Load(_R(IDS_ROLLOVER_CLICKED));
01611 m_RolloverName[SELECTED].Load(_R(IDS_ROLLOVER_SELECTED));
01612 m_RolloverName[BACKBAR].Load(_R(IDS_BACK_BAR));
01613
01614 List SelectionList;
01615 List DelList;
01616
01617
01618 Range Sel(*(GetApplication()->FindSelection()));
01619
01620
01621 RangeControl rg = Sel.GetRangeControlFlags();
01622 rg.PromoteToParent = TRUE;
01623 Sel.Range::SetRangeControl(rg);
01624
01625
01626 if (Extender::ConvertQuickShapesInSelRangeToPaths(this, &Sel))
01627 {
01628 Sel = *(GetApplication()->FindSelection());
01629 rg = Sel.GetRangeControlFlags();
01630 rg.PromoteToParent = TRUE;
01631 Sel.Range::SetRangeControl(rg);
01632 }
01633
01634 if (Sel.IsEmpty())
01635 {
01636 InformWarning(_R(IDS_WARNING_NO_SEL_BACKBAR));
01637 return FALSE;
01638 }
01639
01640
01641 ObjChangeFlags cFlags;
01642 cFlags.MultiReplaceNode = TRUE;
01643 cFlags.RegenerateNode = TRUE;
01644 ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
01645
01646
01647 if (!Sel.AllowOp(&ObjChange))
01648 return FALSE;
01649
01650
01651 DocRect SelRect;
01652 SelRect.MakeEmpty();
01653
01654
01655
01656 CleanSelection (&Sel, &SelectionList, &DelList, BACKBAR);
01657 if (SelectionList.IsEmpty())
01658 {
01659 InformWarning(_R(IDS_WARNING_NO_SEL_BACKBAR));
01660 return FALSE;
01661 }
01662
01663
01664 NodeListItem * pNodeListItem = (NodeListItem *)SelectionList.GetHead();
01665 while(pNodeListItem)
01666 {
01667
01668 DoLocaliseForAttrChange((NodeRenderableInk*) pNodeListItem->pNode, (AttrTypeSet *)NULL, (ObjectSet*) NULL);
01669
01670
01671 SelRect = SelRect.Union(SliceHelper::BoundingNodeSize(pNodeListItem->pNode));
01672
01673 pNodeListItem = (NodeListItem *)SelectionList.GetNext(pNodeListItem);
01674 }
01675
01676
01677 Layer * pNewLayer = AddLayer(m_RolloverName[BACKBAR], BACKBAR);
01678
01679
01680 SliceHelper::BuildListOfNodesInBar(&DelList, pNewLayer, m_BarName);
01681
01682
01683 SliceHelper::ShowLayer(TRUE, pNewLayer, pSpread, this);
01684
01685 LayerSGallery::MakeActiveLayer(pNewLayer, FALSE);
01686
01687
01688 Node * pTail = pNewLayer;
01689 AttachNodeDirection TailAttachDirection = FIRSTCHILD;
01690
01691
01692 pNodeListItem = (NodeListItem *)SelectionList.GetHead();
01693 Node * pNode;
01694
01695 while (pNodeListItem)
01696 {
01697 pNode = pNodeListItem->pNode;
01698 if (pNode)
01699 {
01700
01701
01702 Node* pTheCopy;
01703 BOOL ok;
01704
01705 CALL_WITH_FAIL(pNode->NodeCopy(&pTheCopy), this, ok);
01706
01707 if (ok && !DoInsertNewNode((NodeRenderableBounded *)pTheCopy, pTail, TailAttachDirection,
01708 TRUE,
01709 FALSE))
01710 {
01711 ok = FALSE;
01712 }
01713
01714 if (ok)
01715 {
01716
01717 pTheCopy->SetSelected(TRUE);
01718
01719
01720 TemplateAttribute * pTemplateAttribute = (TemplateAttribute *) SliceHelper::FindNextOfClass(pTheCopy, pTheCopy, CC_RUNTIME_CLASS(TemplateAttribute));
01721 while (pTemplateAttribute)
01722 {
01723 TemplateAttribute * pNextTemplateAttribute = (TemplateAttribute *) SliceHelper::FindNextOfClass(pTemplateAttribute, pTheCopy, CC_RUNTIME_CLASS(TemplateAttribute));
01724
01725 if (SliceHelper::GetBarNumberFromBarName(pTemplateAttribute->GetQuestion()) >= 0)
01726 {
01727
01728
01729 DoHideNode(pTemplateAttribute, TRUE);
01730 }
01731
01732 pTemplateAttribute = pNextTemplateAttribute;
01733 }
01734
01735
01736 ApplyNameAttr(&BackBarName, pTheCopy);
01737
01738
01739 if (Extend)
01740 {
01741
01742 Extender::Extend((NodeRenderableInk*) (pTheCopy),
01743 pBarParam->m_ExtendFlags,
01744 m_BarSelectionRect,
01745 SelRect,
01746 m_FinishedBarRect,
01747 m_BarSelectionRect,
01748 SelRect,
01749 NULL,
01750 TRUE
01751 );
01752
01753
01754
01755 if (pTheCopy->IsABlend())
01756 ((NodeBlend*)(pTheCopy))->Reinit(FALSE);
01757 }
01758
01759
01760 if (pTheCopy->IsCompound() && !pTheCopy->IsABlend())
01761 DoFactorOutCommonChildAttributes((NodeRenderableInk*) pTheCopy);
01762 else
01763 DoFactorOutAfterAttrChange((NodeRenderableInk*) pTheCopy, (AttrTypeSet *)NULL);
01764
01765
01766 TailAttachDirection = NEXT;
01767 pTail = pTheCopy;
01768 }
01769 }
01770
01771
01772 pNodeListItem = (NodeListItem *)SelectionList.GetNext(pNodeListItem);
01773 }
01774
01775
01776
01777 SliceHelper::CreatePropertiesForSet(BackBarName, m_BarName, FALSE, pBarParam->m_ExtendFlags != 0, TRUE, pBarParam->m_ExtendFlags,
01778 TEXT(""), FALSE, &SelRect, Extend ? &m_BarSelectionRect : NULL, this);
01779
01780
01781 pNodeListItem = (NodeListItem *)SelectionList.GetHead();
01782 NodeListItem *pNodeListItemToDel = NULL;
01783
01784 while (pNodeListItem)
01785 {
01786 pNodeListItemToDel = pNodeListItem;
01787 pNodeListItem = (NodeListItem *)SelectionList.GetNext(pNodeListItem);
01788 SelectionList.RemoveItem((NodeListItem *)pNodeListItemToDel);
01789 delete pNodeListItemToDel;
01790 }
01791
01792
01793 pNodeListItem = (NodeListItem *)DelList.GetHead();
01794 pNodeListItemToDel = NULL;
01795
01796 while(pNodeListItem)
01797 {
01798 pNodeListItemToDel = pNodeListItem;
01799 Node *pParent = pNodeListItem->pNode;
01800
01801
01802
01803 if (IS_A(pParent, TemplateAttribute))
01804 pParent = pParent->FindParent();
01805
01806 if (pParent->FindParent())
01807 {
01808 DoInvalidateNodeRegion((NodeRenderableBounded*) pParent, TRUE, FALSE);
01809 pParent->SetSelected(FALSE);
01810 DoHideNode(pParent, TRUE);
01811 }
01812
01813 pNodeListItem = (NodeListItem *)DelList.GetNext(pNodeListItem);
01814 DelList.RemoveItem((NodeListItem *)pNodeListItemToDel);
01815 delete pNodeListItemToDel;
01816 }
01817
01818
01819
01820 Layer* pActiveLayer = SliceHelper::FindLayerCalled(ActiveLayerStr);
01821 if (pActiveLayer != 0)
01822 {
01823 LayerSGallery::MakeActiveLayer(pActiveLayer, FALSE);
01824 }
01825
01826
01827 BROADCAST_TO_ALL(LayerMsg(pActiveLayer, LayerMsg::LayerReason::LAYER_VISIBILITY_CHANGED));
01828
01829
01830 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
01831 GetApplication()->UpdateSelection();
01832
01833 ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
01834 UpdateChangedNodes(&ObjChange, pSpread);
01835 return TRUE;
01836 }
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852
01853 BOOL OpBarCreation::CleanSelection (Range * pSel, List * pSelectionList, List * pDeletionList, INT32 LayerNumToCreate)
01854 {
01855 Layer * pLayer = NULL;
01856 Node * pCurrent = pSel->FindFirst();
01857 Node * pParent = NULL;
01858 Spread* pSpread = Document::GetSelectedSpread();
01859 BOOL AllOk = TRUE;
01860 String_256 ButtonBeingEdited = "";
01861
01862
01863 while (pCurrent)
01864 {
01865
01866 pParent = pCurrent;
01867 while (!pParent->IsLayer())
01868 pParent = pParent->FindParent();
01869
01870 pLayer = (Layer *)pParent;
01871
01872 BOOL ok = FALSE;
01873
01874
01875 if (LayerNumToCreate >=0 && LayerNumToCreate <=4)
01876 {
01877 if (pLayer->GetLayerID() == m_RolloverName[LayerNumToCreate])
01878 ok = TRUE;
01879 }
01880
01881 if (!ok)
01882 {
01883 ok = TRUE;
01884
01885
01886 for (INT32 i = 0; i < 5; i++)
01887 {
01888 if (pLayer->GetLayerID() == m_RolloverName[i])
01889 {
01890 ok = FALSE;
01891 AllOk = FALSE;
01892 }
01893 }
01894
01895 if (!ok)
01896 {
01897
01898
01899 ok = TRUE;
01900
01901
01902
01903 Node * pAttr = SliceHelper::FindNextOfClass(pCurrent,pCurrent, CC_RUNTIME_CLASS(TemplateAttribute));
01904
01905 while (pAttr)
01906 {
01907 if (!SliceHelper::GetBarName((TemplateAttribute *)pAttr).IsEmpty())
01908 {
01909 ok = FALSE;
01910 break;
01911 }
01912
01913 pAttr = SliceHelper::FindNextOfClass(pAttr,pCurrent, CC_RUNTIME_CLASS(TemplateAttribute));
01914 }
01915 }
01916
01917 if (ok)
01918 {
01919 NodeListItem * pItem = new NodeListItem(pCurrent);
01920 pDeletionList->AddTail(pItem);
01921 }
01922 }
01923 else
01924
01925 {
01926
01927
01928
01929
01930
01931 Node * pAttr = SliceHelper::FindNextOfClass(pCurrent,pCurrent, CC_RUNTIME_CLASS(TemplateAttribute));
01932 BOOL FromThisBar = TRUE;
01933
01934 while (pAttr)
01935 {
01936 if (!SliceHelper::GetBarName((TemplateAttribute *)pAttr).IsEmpty())
01937 {
01938
01939 if (m_BarName.CompareTo(SliceHelper::GetBarName((TemplateAttribute *)pAttr)) != 0)
01940 {
01941 FromThisBar = FALSE;
01942 }
01943
01944 String_256 AttrSet = SliceHelper::GetSetNameFromAttrib(pAttr);
01945 if (ButtonBeingEdited.IsEmpty())
01946 {
01947 ButtonBeingEdited = AttrSet;
01948 break;
01949 }
01950 else if (ButtonBeingEdited == AttrSet || AttrSet.IsEmpty())
01951 {
01952 break;
01953 }
01954 else
01955 ok = FALSE;
01956 break;
01957 }
01958
01959 pAttr = SliceHelper::FindNextOfClass(pAttr,pCurrent, CC_RUNTIME_CLASS(TemplateAttribute));
01960 }
01961
01962 if (ok && FromThisBar)
01963 {
01964 NodeListItem * pItem = new NodeListItem(pCurrent);
01965 pDeletionList->AddTail(pItem);
01966 }
01967 }
01968
01969 if (ok)
01970 {
01971 NodeListItem * pItem = new NodeListItem(pCurrent);
01972 pSelectionList->AddTail(pItem);
01973 }
01974
01975
01976 pCurrent = pSel->FindNext(pCurrent);
01977 }
01978
01979 return AllOk;
01980 }
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995 void OpBarCreation::ShowState(INT32 ShowLayer)
01996 {
01997 OpShowState::ShowState(ShowLayer, this);
01998 }
01999
02000 BOOL OpBarCreation::CreateBarAndBackBar (OpParam* pOpParam)
02001 {
02002
02003
02004 Node * pBackObj = NULL;
02005
02006
02007 Range Sel(*(GetApplication()->FindSelection()));
02008
02009
02010 RangeControl rg = Sel.GetRangeControlFlags();
02011 rg.PromoteToParent = TRUE;
02012 Sel.Range::SetRangeControl(rg);
02013
02014 if (Sel.Count() < 2)
02015 return FALSE;
02016 else
02017 {
02018 pBackObj = Sel.FindFirst();
02019 pBackObj->SetSelected(FALSE);
02020 }
02021
02022
02023 BOOL ok = CreateOrEditBar(pOpParam);
02024
02025 if (!ok)
02026 {
02027 InformWarning(_R(IDS_FAILLED_MAKE_BAR));
02028 return FALSE;
02029 }
02030
02031
02032 NodeRenderableInk::DeselectAll(TRUE);
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047
02048 pBackObj->SetSelected(TRUE);
02049
02050 ok = CreateBackBarFromSelection(pOpParam, TRUE);
02051
02052 if (!ok)
02053 InformWarning(_R(IDS_FAILLED_MAKE_BACKBAR));
02054
02055 return ok;
02056 }
02057