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 #include "camtypes.h"
00104
00105 #include "ngcore.h"
00106 #include "ngdialog.h"
00107 #include "ngitem.h"
00108 #include "ngprop.h"
00109 #include "ngscan.h"
00110 #include "ngsentry.h"
00111 #include "ngsetop.h"
00112
00113
00114
00115 #include "keypress.h"
00116
00117
00118
00119
00120 #include "userattr.h"
00121 #include "tmpltatr.h"
00122
00123 #include "impexpop.h"
00124 #include "bitfilt.h"
00125
00126 #include "ophist.h"
00127
00128
00129
00130
00131 #ifdef _DEBUG
00132 #undef THIS_FILE
00133 static char BASED_CODE THIS_FILE[] = __FILE__;
00134 #endif
00135
00136 DECLARE_SOURCE("$Revision: 1282 $");
00137
00138 CC_IMPLEMENT_DYNCREATE(OpSelectSet, Operation);
00139 CC_IMPLEMENT_DYNCREATE(OpSelectUnionSets, Operation);
00140 CC_IMPLEMENT_DYNCREATE(OpSelectIntersectSets, Operation);
00141 CC_IMPLEMENT_DYNCREATE(OpApplyNamesToSel, SelOperation);
00142 CC_IMPLEMENT_DYNCREATE(OpApplyNamesToOne, UndoableOperation);
00143 CC_IMPLEMENT_DYNCREATE(OpApplyNameToNone, UndoableOperation);
00144 CC_IMPLEMENT_DYNCREATE(OpDeleteNamesFromAll, UndoableOperation);
00145 CC_IMPLEMENT_DYNCREATE(OpRenameAll, UndoableOperation);
00146 CC_IMPLEMENT_DYNCREATE(OpRemoveNamesFromSel, SelOperation);
00147 CC_IMPLEMENT_DYNCREATE(OpRedefineNamesAsSel, SelOperation);
00148 CC_IMPLEMENT_DYNCREATE(OpExportSets, Operation);
00149 CC_IMPLEMENT_DYNCREATE(OpChangeSetProperty, UndoableOperation);
00150 CC_IMPLEMENT_DYNCREATE(OpChangeBarProperty, UndoableOperation);
00151 CC_IMPLEMENT_DYNCREATE(OpChangeBarExtends, UndoableOperation);
00152
00153
00154 #define new CAM_DEBUG_NEW
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169 void OpSelectSet::DoWithParam(OpDescriptor*, OpParam* pParam)
00170 {
00171 SelectScan((SGNameItem*)(void *) pParam->Param1, (SelectScan::Change) (INT32) pParam->Param2).Scan();
00172 End();
00173 }
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 OpState OpSelectUnionSets::GetState(String_256*, OpDescriptor*)
00186 {
00187 INT32 nTotal;
00188 NameGallery::Instance()->GetHighlightCount(&nTotal, 0);
00189 return OpState(FALSE, nTotal < 1);
00190 }
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203 void OpSelectUnionSets::Do(OpDescriptor*)
00204 {
00205 SelectUnionScan::Change option = SelectUnionScan::SELECT_EXCLUSIVE;
00206 if( KeyPress::IsGalleryCtrlPressed() )
00207 option = SelectUnionScan::DESELECT;
00208 SelectUnionScan( option ).Scan();
00209 End();
00210 }
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 OpState OpSelectIntersectSets::GetState(String_256*, OpDescriptor*)
00223 {
00224 INT32 nTotal;
00225 NameGallery::Instance()->GetHighlightCount(&nTotal, 0);
00226 return OpState(FALSE, nTotal < 2);
00227 }
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240 void OpSelectIntersectSets::Do(OpDescriptor*)
00241 {
00242 SelectUnionScan option = SelectUnionScan::SELECT_EXCLUSIVE;
00243 if( KeyPress::IsGalleryCtrlPressed() )
00244 option = SelectUnionScan::DESELECT;
00245 SelectUnionScan( option ).Scan();
00246 End();
00247 }
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260 OpState OpApplyNamesToSel::GetState(String_256*, OpDescriptor*)
00261 {
00262 INT32 nTotal, nNames;
00263 NameGallery::Instance()->GetHighlightCount(&nTotal, &nNames);
00264 return OpState(FALSE, GetApplication()->FindSelection()->IsEmpty()
00265 || nNames < 1 || nTotal > nNames);
00266 }
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278 void OpApplyNamesToSel::Do(OpDescriptor*)
00279 {
00280 AllowOpScan aosSel(this, &theSelectedObjects),
00281 aosSentinel(this, &theSetSentinel);
00282
00283 if (!aosSel.Scan() ||
00284 !aosSentinel.Scan() ||
00285 !DoStartSelOp(TRUE, TRUE) ||
00286 !ApplyScan(this, &theSelectedObjects).Scan() ||
00287 !ApplyScan(this, &theSetSentinel).Scan() ||
00288 !aosSel.Update() ||
00289 !aosSentinel.Update())
00290 {
00291 FailAndExecute();
00292 }
00293
00294 End();
00295 }
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310 void OpApplyNamesToSel::DoWithParam(OpDescriptor*, OpParam* pParam)
00311 {
00312 ERROR3IF(pParam->Param1 == 0, "OpApplyNamesToSel::DoWithParam: null argument");
00313 const StringBase& strName = *((const StringBase*)(void *) pParam->Param1);
00314
00315 AllowOpScan aosSel(this, &theSelectedObjects),
00316 aosSentinel(this, &theSetSentinel);
00317
00318 if (!aosSel.Scan() ||
00319 !aosSentinel.Scan() ||
00320 !DoStartSelOp(TRUE, TRUE) ||
00321 !ApplySingleScan(this, &theSelectedObjects, strName).Scan() ||
00322 !ApplySingleScan(this, &theSetSentinel, strName).Scan() ||
00323 !ApplyPropScan(this, strName).Scan() ||
00324 !aosSel.Update() ||
00325 !aosSentinel.Update())
00326 {
00327 FailAndExecute();
00328 }
00329
00330 End();
00331 }
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344 OpState OpApplyNamesToOne::GetState(String_256*, OpDescriptor*)
00345 {
00346 INT32 nTotal, nNames;
00347 NameGallery::Instance()->GetHighlightCount(&nTotal, &nNames);
00348 return OpState(FALSE, nNames < 1 || nTotal > nNames);
00349 }
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364 void OpApplyNamesToOne::DoWithParam(OpDescriptor*, OpParam* pParam)
00365 {
00366 ERROR3IF(pParam->Param1 == 0, "OpApplyNamesToOne::DoWithParam: null argument");
00367 Node* pNode = (Node*)(void *) pParam->Param1;
00368
00369 SingleNodeSource theObject(pNode);
00370 AllowOpScan aosObj(this, &theObject),
00371 aosSentinel(this, &theSetSentinel);
00372
00373 if (!aosObj.Scan() ||
00374 !aosSentinel.Scan() ||
00375 !ApplyScan(this, &theObject).Scan() ||
00376 !ApplyScan(this, &theSetSentinel).Scan() ||
00377 !aosObj.Update() ||
00378 !aosSentinel.Update())
00379 {
00380 FailAndExecute();
00381 }
00382
00383 End();
00384 }
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400 void OpApplyNameToNone::DoWithParam(OpDescriptor*, OpParam* pParam)
00401 {
00402 ERROR3IF(pParam->Param1 == 0, "OpApplyNameToNone::DoWithParam: null argument");
00403 const StringBase& strName = *((const StringBase*)(void *) pParam->Param1);
00404
00405 AllowOpScan aosSentinel(this, &theSetSentinel);
00406
00407 if (!aosSentinel.Scan() ||
00408 !ApplySingleScan(this, &theSetSentinel, strName).Scan() ||
00409 !ApplyPropScan(this, strName).Scan() ||
00410 !aosSentinel.Update())
00411 {
00412 FailAndExecute();
00413 }
00414
00415 End();
00416 }
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430 void OpDeleteNamesFromAll::Do(OpDescriptor*)
00431 {
00432 AllowOpScan aosDoc(this, &theSelectedDocument);
00433
00434 if (!aosDoc.Scan() ||
00435 !HidePropScan(this).Scan() ||
00436 !HideScan(this, &theSelectedDocument).Scan() ||
00437 !aosDoc.Update())
00438 {
00439 FailAndExecute();
00440 }
00441
00442 End();
00443 }
00444
00445
00446
00447
00448 void RenameSetInstance(const String_256 & str, const String_256 & NewStr, UndoableOperation *pOp, Spread * pSpread)
00449 {
00450
00451 if (str.CompareTo(NewStr) == 0)
00452 return;
00453
00454 if (pOp == NULL || pSpread == NULL)
00455 return;
00456
00457 SliceHelper::PurgeUseOfSetName(str, pOp, &NewStr);
00458 Node * pTop = (Node *) pSpread;
00459 BOOL again = TRUE;
00460 Node * pNodeSetSentinel = pOp->GetWorkingDoc()->GetSetSentinel();
00461
00462
00463 Node * pNode = SliceHelper::FindNextNameNode(pTop, pTop);
00464 do
00465 {
00466 while (pNode)
00467 {
00468 if (str.CompareTo(((TemplateAttribute *)pNode)->GetParam()) == 0)
00469 {
00470
00471
00472 BOOL FoundLikeSibling = FALSE;
00473 Node * pSib;
00474 for ( pSib = pNode->FindParent()->FindFirstChild(CC_RUNTIME_CLASS(TemplateAttribute));
00475 pSib != NULL;
00476 pSib = pSib->FindNext(CC_RUNTIME_CLASS(TemplateAttribute)) )
00477 {
00478 if (NewStr.CompareTo(((TemplateAttribute *)pSib)->GetParam()) == 0)
00479 FoundLikeSibling = TRUE;
00480 }
00481
00482
00483 TemplateAttribute* pta = NULL;
00484 if (!FoundLikeSibling)
00485 {
00486 ALLOC_WITH_FAIL(pta, (new TemplateAttribute(TA_NAME, ((TemplateAttribute *)pNode)->GetQuestion(), NewStr)), pOp);
00487 if (pta)
00488 {
00489 pta->AttachNode(pNode, PREV);
00490
00491 HideNodeAction* pHideAct;
00492 if (AC_FAIL == HideNodeAction::Init(pOp, pOp->GetUndoActions(),
00493 pta, TRUE, (Action**) &pHideAct))
00494 {
00495 delete pta;
00496 pta = NULL;
00497 }
00498 }
00499 }
00500
00501 Node * pDelMe = pNode;
00502 pNode = SliceHelper::FindNextNameNode(pNode, pTop);
00503
00504
00505 pOp->DoHideNode(pDelMe, FALSE);
00506 }
00507 else
00508 pNode = SliceHelper::FindNextNameNode(pNode, pTop);
00509 }
00510
00511 again = pTop != pNodeSetSentinel;
00512 pTop = pNodeSetSentinel;
00513 pNode = SliceHelper::FindNextNameNode(pTop, pTop);
00514 } while (again);
00515
00516
00517
00518
00519
00520 BOOL propertyrenamed = FALSE;
00521 NodeSetProperty * pNodeSetProperty = (NodeSetProperty *) pNodeSetSentinel->FindFirstChild(CC_RUNTIME_CLASS(NodeSetProperty));
00522 while (pNodeSetProperty && !propertyrenamed)
00523 {
00524 if ((pNodeSetProperty->GetName() == str) && (!pNodeSetProperty->IsNodeHidden()))
00525 {
00526 propertyrenamed = TRUE;
00527 pOp->DoHideNode(pNodeSetProperty, FALSE);
00528 }
00529 pNodeSetProperty = (NodeSetProperty *) pNodeSetProperty->FindNext(CC_RUNTIME_CLASS(NodeSetProperty));
00530 }
00531 }
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547 void OpRenameAll::DoWithParam(OpDescriptor*, OpParam* pParam)
00548 {
00549 ERROR3IF(pParam->Param1 == 0, "OpRenameAll::DoWithParam: null argument");
00550 const StringBase& strNewName = *((const StringBase*) (void *) pParam->Param1);
00551 Spread * pSpread = Document::GetSelectedSpread();
00552 if (pSpread == NULL)
00553 {
00554 FailAndExecute();
00555 End();
00556 return;
00557 }
00558
00559
00560
00561 NodeSetProperty* pCopyPropNode = 0;
00562 NamedExportProp* pNewExport = 0;
00563
00564
00565 INT32 nNames;
00566 NameGallery::Instance()->GetHighlightCount(0, &nNames);
00567 if (nNames == 1)
00568 {
00569
00570
00571 String_256 str;
00572 NameGallery::Instance()->GetUsedNames()->FindNextSelectedItem()->GetNameText(&str);
00573 pCopyPropNode = GetWorkingDoc()->GetSetSentinel()->FindPropertyNode(str);
00574 if (pCopyPropNode != 0)
00575 {
00576
00577
00578 ALLOC_WITH_FAIL(pNewExport,
00579 (NamedExportProp*) SGNameProp::CreateDefault(strNewName,
00580 NamedExportProp::nIndex),
00581 this);
00582 if (pNewExport == 0)
00583 {
00584 FailAndExecute();
00585 End();
00586 return;
00587 }
00588
00589
00590 NamedExportProp* pOldExport =
00591 (NamedExportProp*) pCopyPropNode->GetProperty(NamedExportProp::nIndex);
00592 ERROR3IF(pOldExport == 0, "OpRenameAll::DoWithParam: no export property");
00593
00594
00595 pNewExport->SetFilter(pOldExport->GetFilter());
00596 pNewExport->SetOptions(pOldExport->GetOptions());
00597
00598 String_256 strPath(pOldExport->GetPath().GetLocation(TRUE));
00599 strPath += pNewExport->GetPath().GetFileName(TRUE);
00600 pNewExport->SetPath(PathName(strPath));
00601 }
00602 }
00603
00604 SGNameItem* pNameGalleryItem = (SGNameItem*) NameGallery::Instance()->GetUsedNames()->GetChild();
00605
00606 while (pNameGalleryItem)
00607 {
00608 if (pNameGalleryItem->IsSelected())
00609 {
00610 String_256 str;
00611 pNameGalleryItem->GetNameText(&str);
00612
00613
00614 RenameSetInstance(str, *((const String_256 *) (void *) pParam->Param1), this, pSpread);
00615 }
00616
00617 pNameGalleryItem = (SGNameItem *) pNameGalleryItem->GetNext();
00618 }
00619
00620
00621
00622 AllowOpScan aosDoc(this, &theSelectedDocument);
00623
00624 BOOL ok = aosDoc.Scan();
00625
00626 if (ok)
00627 ok = ApplyPropScan(this, strNewName, pCopyPropNode).Scan();
00628
00629 if (ok)
00630 ok = HidePropScan(this).Scan();
00631
00632
00633
00634
00635
00636 NameGallery * pNameGallery = NameGallery::Instance();
00637 pNameGallery->FastUpdateNamedSetSizes();
00638
00639 if (ok)
00640 ok = aosDoc.Update();
00641
00642 if (!ok)
00643 {
00644 FailAndExecute();
00645 End();
00646 return;
00647 }
00648
00649
00650 if (pNewExport != 0)
00651 {
00652
00653 pCopyPropNode = GetWorkingDoc()->GetSetSentinel()->FindPropertyNode(strNewName);
00654 if (pCopyPropNode != 0) delete pCopyPropNode->SetProperty(pNewExport);
00655 }
00656
00657 End();
00658 }
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671 void OpRemoveNamesFromSel::Do(OpDescriptor*)
00672 {
00673 AllowOpScan aosSel(this, &theSelectedObjects);
00674
00675 if (!aosSel.Scan() ||
00676 !DoStartSelOp(TRUE, TRUE) ||
00677 !HideScan(this, &theSelectedObjects).Scan() ||
00678 !aosSel.Update())
00679 {
00680 FailAndExecute();
00681 }
00682
00683 End();
00684 }
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701 void OpRedefineNamesAsSel::Do(OpDescriptor*)
00702 {
00703 AllowOpScan aosSel(this, &theSelectedObjects),
00704 aosUnsel(this, &theUnselectedObjects),
00705 aosSentinel(this, &theSetSentinel);
00706
00707 if (!aosSel.Scan() ||
00708 !aosUnsel.Scan() ||
00709 !aosSentinel.Scan() ||
00710 !DoStartSelOp(TRUE, TRUE) ||
00711 !HideScan(this, &theSelectedDocument).Scan() ||
00712 !ApplyScan(this, &theSelectedObjects).Scan() ||
00713 !ApplyScan(this, &theSetSentinel).Scan() ||
00714 !aosSel.Update() ||
00715 !aosUnsel.Update() ||
00716 !aosSentinel.Update())
00717 {
00718 FailAndExecute();
00719 }
00720
00721 End();
00722 }
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734 OpState OpExportSets::GetState(String_256*, OpDescriptor*)
00735 {
00736 INT32 nTotal, nNames;
00737 NameGallery::Instance()->GetHighlightCount(&nTotal, &nNames);
00738 return OpState(FALSE, nNames < 1);
00739 }
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752 void OpExportSets::Do(OpDescriptor*)
00753 {
00754
00755
00756 if (ExportHighlightedIter(this).ForEach() != 0) InformError();
00757 End();
00758 }
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772 OpExportSets::ExportHighlightedIter::ExportHighlightedIter(OpExportSets* pOp)
00773 : NameItemIter(NameItemIter::HIGHLIGHTED_NAMES),
00774 m_pOp(pOp)
00775 {
00776
00777 OpMenuExport::SaveSelection();
00778 }
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790 OpExportSets::ExportHighlightedIter::~ExportHighlightedIter()
00791 {
00792
00793 OpMenuExport::RestoreSelection();
00794
00795
00796 if (!m_strExtErrors.IsEmpty())
00797 {
00798
00799 String_256 str;
00800 m_strExtErrors.toUpper();
00801 str.MakeMsg(_R(IDS_NAMEGAL_EXT_ERROR), &m_strExtErrors);
00802 Error::SetError(0, str, 0);
00803 InformWarning();
00804 }
00805 }
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817 BOOL OpExportSets::ExportHighlightedIter::Do(SGNameItem* pItem)
00818 {
00819
00820 if (pItem->IsEmpty()) return TRUE;
00821
00822
00823 NamedExportProp* pProp = (NamedExportProp*) pItem->GetProperty(NamedExportProp::nIndex);
00824 ERROR3IF(pProp == 0, "ExportHighlightedIter::Do: no export property");
00825
00826
00827 if (pProp->IsVirgin())
00828 {
00829 if ( !pProp->ExportPropertiesToLocationDlg(pItem) )
00830 return FALSE;
00831
00832
00833
00834 pProp = (NamedExportProp*) pItem->GetProperty(NamedExportProp::nIndex);
00835 }
00836
00837 if (pProp->GetFilter() == 0 || !pProp->GetPath().IsValid())
00838 {
00839
00840 String_256 str;
00841 pItem->GetNameText(&str);
00842 PathName pth(str);
00843
00844 if (!m_strExtErrors.IsEmpty()) m_strExtErrors += String(_R(IDS_NAMEGAL_EXT_COMMA));
00845 m_strExtErrors += pth.GetType();
00846 return TRUE;
00847 }
00848
00849
00850 if (!SelectScan(pItem, SelectScan::SELECT_EXCLUSIVE, TRUE).Scan()) return FALSE;
00851
00852
00853 OpMenuExport::NormaliseSelection();
00854
00855
00856 CCDiskFile theFile;
00857 if (!theFile.open(pProp->GetPath().GetPath(), ios::in | ios::out | ios::binary))
00858 return FALSE;
00859
00860
00861 BOOL fOk = FALSE;
00862 if (pProp->GetFilter()->IS_KIND_OF(BaseBitmapFilter))
00863 {
00864
00865
00866 pProp->GetOptions()->BitmapSourceHasChanged();
00867
00868 fOk = ((BaseBitmapFilter*) pProp->GetFilter())->DoExportWithOptions(
00869 m_pOp,
00870 &theFile,
00871 &pProp->GetPath(),
00872 m_pOp->GetWorkingDoc(),
00873 pProp->GetOptions());
00874 }
00875
00876
00877 theFile.close();
00878 return fOk;
00879 }
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894 void OpChangeSetProperty::DoWithParam(OpDescriptor*, OpParam* pParam)
00895 {
00896
00897 ERROR3IF(pParam == 0 || pParam->Param1 == 0, "OpChangeSetProperty::DoWithParam: no input");
00898 const StringBase& strName = *(((StringBase**) (void *) pParam->Param1)[0]);
00899 StringBase* pstrNewName = ((StringBase**) (void *) pParam->Param1)[1];
00900 SGNameProp* pProp = (SGNameProp*) (void *) pParam->Param2;
00901
00902
00903 NodeSetSentinel* pSentry = GetWorkingDoc()->GetSetSentinel();
00904 NodeSetProperty* pOldSetNode = pSentry->FindPropertyNode(strName);
00905 ERROR3IF(pOldSetNode == 0, "OpChangeSetProperty::DoWithParam: can't find NodeSetProperty");
00906 if (pOldSetNode != 0 && !DoHideNode(pOldSetNode, TRUE, 0, TRUE))
00907 {
00908 FailAndExecute();
00909 End();
00910 return;
00911 }
00912
00913
00914 NodeSetProperty* pNewSetNode;
00915 ALLOC_WITH_FAIL(pNewSetNode,
00916 (new NodeSetProperty(pstrNewName != 0 ? *pstrNewName : strName)),
00917 this);
00918 if (pNewSetNode == 0)
00919 {
00920 FailAndExecute();
00921 End();
00922 return;
00923 }
00924
00925
00926 NodeSetProperty* fOk=NULL;
00927
00928 ALLOC_WITH_FAIL(fOk, ((pNewSetNode->CopyProperties(pOldSetNode))?pNewSetNode:NULL), this);
00929 if (!fOk)
00930 {
00931 FailAndExecute();
00932 End();
00933 return;
00934 }
00935
00936
00937 SGNameProp* pOldProp = pNewSetNode->SetProperty(pProp);
00938 if (pOldProp != 0) delete pOldProp;
00939
00940
00941 pProp->SetDirty();
00942
00943
00944 ERROR3IF(pSentry->FindPropertyNode(pNewSetNode->GetName()) != 0,
00945 "OpChangeSetProperty::DoWithParam: property node already exists");
00946 pNewSetNode->AttachNode(pSentry, LASTCHILD);
00947 HideNodeAction* pHideAct;
00948 if (AC_FAIL == HideNodeAction::Init(this, GetUndoActions(), pNewSetNode,
00949 TRUE, (Action**) &pHideAct))
00950 {
00951 delete pNewSetNode;
00952 FailAndExecute();
00953 End();
00954 return;
00955 }
00956
00957
00958
00959 if (pstrNewName != 0)
00960 {
00961 RenameSetInstance(strName, *pstrNewName, this, Document::GetSelectedSpread());
00962 }
00963
00964 End();
00965 }
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979 void OpChangeBarProperty::DoWithParam(OpDescriptor*, OpParam* pParam)
00980 {
00981
00982 ERROR3IF(pParam == 0, "OpChangeBarProperty::DoWithParam: no parameter");
00983 OpChangeBarPropParam* pInput = (OpChangeBarPropParam*) (pParam);
00984 NodeBarProperty* pProp = pInput->m_Prop;
00985 ERROR3IF(pInput == 0 || pProp == 0, "OpChangeBarProperty::DoWithParam: no property");
00986
00987
00988 m_BarIndex = -1;
00989 m_MakingLive = FALSE;
00990
00991
00992 if (!DoChangeBarProperty(this, pInput->m_nIndex, pProp, pInput->m_pbdtInfo, &m_MakingLive))
00993 {
00994 FailAndExecute();
00995 End();
00996 return;
00997 }
00998
00999
01000
01001
01002
01003 NameGallery* pNameGallery = NameGallery::Instance();
01004 if (pNameGallery != 0)
01005 {
01006
01007 pNameGallery->PreTriggerEdit(this, 0, (Node*) 0);
01008
01009
01010 pNameGallery->m_TouchedBar = pInput->m_nIndex;
01011 m_BarIndex = pInput->m_nIndex;
01012 }
01013
01014
01015 End();
01016 }
01017
01018 BOOL OpChangeBarProperty::DoChangeBarProperty(UndoableOperation * pOp, INT32 Index, NodeBarProperty* pProp, const BarDataType * pBarData, BOOL * pMadeLive)
01019 {
01020 if (pMadeLive)
01021 *pMadeLive = FALSE;
01022
01023 if (!pOp || !pProp || !pBarData)
01024 return FALSE;
01025
01026
01027 NodeBarProperty* pCopy;
01028 ALLOC_WITH_FAIL(pCopy, ((NodeBarProperty*) pProp->SimpleCopy()), pOp);
01029 if (pCopy == 0)
01030 {
01031 return FALSE;
01032 }
01033
01034
01035 pCopy->AttachNode(pOp->GetWorkingDoc()->GetSetSentinel(), LASTCHILD);
01036 HideNodeAction* pHideAct;
01037 if (AC_FAIL == HideNodeAction::Init(pOp, pOp->GetUndoActions(), pCopy,
01038 TRUE, (Action**) &pHideAct))
01039 {
01040 delete pCopy;
01041 return FALSE;
01042 }
01043
01044
01045 if (Index >= (INT32)pCopy->HowMany())
01046 pCopy->Add(*pBarData);
01047 else
01048 {
01049 BOOL MakingLive = !pCopy->Bar(Index).IsLive && pBarData->IsLive;
01050 BarDataType* pCopyData = &pCopy->Bar(Index);
01051 *pCopyData = *pBarData;
01052 if (pMadeLive)
01053 *pMadeLive = MakingLive;
01054 }
01055
01056
01057 if (!pOp->DoHideNode(pProp, TRUE, 0, TRUE))
01058 {
01059 return FALSE;
01060 }
01061
01062 return TRUE;
01063 }
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078 void OpChangeBarExtends::DoWithParam(OpDescriptor*, OpParam* pParam)
01079 {
01080
01081 ERROR3IF(pParam == 0, "OpChangeBarExtends::DoWithParam: no parameter");
01082 INT32 idBars = (INT32) pParam->Param1;
01083 BYTE nMode = (BYTE) pParam->Param2;
01084 SGUsedNames* pNames = NameGallery::Instance()->GetUsedNames();
01085 ERROR3IF(pNames == 0, "OpChangeBarExtends::DoWithParam: no set names");
01086 NodeSetSentinel* pSentry = GetWorkingDoc()->GetSetSentinel();
01087
01088
01089 for (SGNameItem* pItem = (SGNameItem*) pNames->GetChild();
01090 pItem != 0;
01091 pItem = (SGNameItem*) pItem->GetNext())
01092 if (pItem->m_BarNumber == idBars)
01093 {
01094
01095
01096 String_256 strName;
01097 pItem->GetNameText(&strName);
01098 NodeSetProperty* pOldSetNode = pSentry->FindPropertyNode(strName);
01099 ERROR3IF(pOldSetNode == 0,
01100 "OpChangeBarExtends::DoWithParam: can't find NodeSetProperty");
01101
01102
01103 NodeSetProperty* pNewSetNode;
01104 ALLOC_WITH_FAIL(pNewSetNode,
01105 ((NodeSetProperty*) pOldSetNode->SimpleCopy()),
01106 this);
01107 if (pNewSetNode == 0)
01108 {
01109 FailAndExecute();
01110 End();
01111 return;
01112 }
01113
01114
01115 NamedStretchProp* pProp =
01116 (NamedStretchProp*) pNewSetNode->GetProperty(NamedStretchProp::nIndex);
01117 ERROR3IF(pProp == 0, "OpChangeBarExtends::DoWithParam: no property");
01118 pProp->SetStretchType(nMode);
01119
01120
01121 pProp->SetDirty();
01122
01123
01124 pNewSetNode->AttachNode(pSentry, LASTCHILD);
01125 HideNodeAction* pHideAct;
01126 if (AC_FAIL == HideNodeAction::Init(this, GetUndoActions(), pNewSetNode,
01127 TRUE, (Action**) &pHideAct))
01128 {
01129 delete pNewSetNode;
01130 FailAndExecute();
01131 End();
01132 return;
01133 }
01134
01135
01136 if (!DoHideNode(pOldSetNode, TRUE, 0, TRUE))
01137 {
01138 FailAndExecute();
01139 End();
01140 return;
01141 }
01142 }
01143
01144
01145 End();
01146 }
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161 BOOL InitNamingSystem()
01162 {
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196 return OpSelectSet::RegisterOpDescriptor(
01197 0,
01198 _R(IDS_NAMEOP_SELECT_SET),
01199 CC_RUNTIME_CLASS(OpSelectSet),
01200 OPTOKEN_SELECT_SET,
01201 0,
01202 0,
01203 _R(IDBBL_NAMEOP_SELECT_SET),
01204 0,
01205 0,
01206 SYSTEMBAR_ILLEGAL,
01207 FALSE,
01208 FALSE,
01209 TRUE,
01210 0,
01211 0,
01212 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
01213
01214 && OpSelectUnionSets::RegisterOpDescriptor(
01215 0,
01216 _R(IDS_NAMEOP_SELECT_UNION_SETS),
01217 CC_RUNTIME_CLASS(OpSelectUnionSets),
01218 OPTOKEN_SELECT_UNION_SETS,
01219 OpSelectUnionSets::GetState,
01220 0,
01221 _R(IDBBL_NAMEOP_SELECT_UNION_SETS))
01222
01223 && OpSelectIntersectSets::RegisterOpDescriptor(
01224 0,
01225 _R(IDS_NAMEOP_SELECT_INTERSECT_SETS),
01226 CC_RUNTIME_CLASS(OpSelectIntersectSets),
01227 OPTOKEN_SELECT_INTERSECT_SETS,
01228 OpSelectIntersectSets::GetState,
01229 0,
01230 _R(IDBBL_NAMEOP_SELECT_INTERSECT_SETS))
01231
01232 && OpApplyNamesToSel::RegisterOpDescriptor(
01233 0,
01234 _R(IDS_NAMEOP_APPLY_NAMES_TO_SEL),
01235 CC_RUNTIME_CLASS(OpApplyNamesToSel),
01236 OPTOKEN_APPLY_NAMES_TO_SEL,
01237 OpApplyNamesToSel::GetState,
01238 0,
01239 _R(IDBBL_NAMEOP_APPLY_NAMES_TO_SEL))
01240
01241 && OpApplyNamesToSel::RegisterOpDescriptor(
01242 0,
01243 _R(IDS_NAMEOP_APPLY_NAME_TO_SEL),
01244 CC_RUNTIME_CLASS(OpApplyNamesToSel),
01245 OPTOKEN_APPLY_NAME_TO_SEL,
01246 0,
01247 _R(IDBBL_NAMEOP_APPLY_NAME_TO_SEL),
01248 0,
01249 0,
01250 0,
01251 SYSTEMBAR_ILLEGAL,
01252 FALSE,
01253 FALSE,
01254 FALSE,
01255 0,
01256 GREY_WHEN_NO_SELECTION | DONT_GREY_WHEN_SELECT_INSIDE)
01257
01258 && OpApplyNamesToOne::RegisterOpDescriptor(
01259 0,
01260 _R(IDS_NAMEOP_APPLY_NAMES_TO_ONE),
01261 CC_RUNTIME_CLASS(OpApplyNamesToOne),
01262 OPTOKEN_APPLY_NAMES_TO_ONE,
01263 OpApplyNamesToOne::GetState,
01264 0,
01265 _R(IDBBL_NAMEOP_APPLY_NAMES_TO_ONE))
01266
01267 && OpApplyNameToNone::RegisterOpDescriptor(
01268 0,
01269 _R(IDS_NAMEOP_APPLY_NAME_TO_NONE),
01270 CC_RUNTIME_CLASS(OpApplyNameToNone),
01271 OPTOKEN_APPLY_NAME_TO_NONE,
01272 0,
01273 _R(IDBBL_NAMEOP_APPLY_NAME_TO_NONE),
01274 0,
01275 0,
01276 0,
01277 SYSTEMBAR_ILLEGAL,
01278 FALSE,
01279 FALSE,
01280 FALSE,
01281 0,
01282 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
01283
01284 && OpDeleteNamesFromAll::RegisterOpDescriptor(
01285 0,
01286 _R(IDS_NAMEOP_DELETE_NAMES_FROM_ALL),
01287 CC_RUNTIME_CLASS(OpDeleteNamesFromAll),
01288 OPTOKEN_DELETE_NAMES_FROM_ALL,
01289 OpApplyNamesToOne::GetState,
01290 0,
01291 _R(IDBBL_NAMEOP_DELETE_NAMES_FROM_ALL))
01292
01293 && OpRenameAll::RegisterOpDescriptor(
01294 0,
01295 _R(IDS_NAMEOP_RENAME_ALL),
01296 CC_RUNTIME_CLASS(OpRenameAll),
01297 OPTOKEN_RENAME_ALL,
01298 OpApplyNamesToOne::GetState,
01299 0,
01300 _R(IDBBL_NAMEOP_RENAME_ALL))
01301
01302 && OpRemoveNamesFromSel::RegisterOpDescriptor(
01303 0,
01304 _R(IDS_NAMEOP_REMOVE_NAMES_FROM_SEL),
01305 CC_RUNTIME_CLASS(OpRemoveNamesFromSel),
01306 OPTOKEN_REMOVE_NAMES_FROM_SEL,
01307 OpApplyNamesToSel::GetState,
01308 0,
01309 _R(IDBBL_NAMEOP_REMOVE_NAMES_FROM_SEL))
01310
01311 && OpRedefineNamesAsSel::RegisterOpDescriptor(
01312 0,
01313 _R(IDS_NAMEOP_REDEFINE_NAMES_AS_SEL),
01314 CC_RUNTIME_CLASS(OpRedefineNamesAsSel),
01315 OPTOKEN_REDEFINE_NAMES_AS_SEL,
01316 OpApplyNamesToSel::GetState,
01317 0,
01318 _R(IDBBL_NAMEOP_REDEFINE_NAMES_AS_SEL))
01319
01320 && OpExportSets::RegisterOpDescriptor(
01321 0,
01322 _R(IDS_NAMEOP_EXPORT_SETS),
01323 CC_RUNTIME_CLASS(OpExportSets),
01324 OPTOKEN_EXPORT_SETS,
01325 OpExportSets::GetState,
01326 0,
01327 _R(IDBBL_NAMEOP_EXPORT_SETS))
01328
01329 && OpChangeSetProperty::RegisterOpDescriptor(
01330 0,
01331 _R(IDS_NAMEOP_CHANGE_SET_PROPERTY),
01332 CC_RUNTIME_CLASS(OpChangeSetProperty),
01333 OPTOKEN_CHANGE_SET_PROPERTY,
01334 0,
01335 _R(IDBBL_NAMEOP_CHANGE_SET_PROPERTY),
01336 0,
01337 0,
01338 0,
01339 SYSTEMBAR_ILLEGAL,
01340 FALSE,
01341 FALSE,
01342 FALSE,
01343 0,
01344 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
01345
01346 && OpChangeBarProperty::RegisterOpDescriptor(
01347 0,
01348 _R(IDS_NAMEOP_CHANGE_BAR_PROPERTY),
01349 CC_RUNTIME_CLASS(OpChangeBarProperty),
01350 OPTOKEN_CHANGE_BAR_PROPERTY,
01351 0,
01352 _R(IDBBL_NAMEOP_CHANGE_BAR_PROPERTY),
01353 0,
01354 0,
01355 0,
01356 SYSTEMBAR_ILLEGAL,
01357 FALSE,
01358 FALSE,
01359 FALSE,
01360 0,
01361 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
01362
01363 && OpChangeBarExtends::RegisterOpDescriptor(
01364 0,
01365 _R(IDS_NAMEOP_CHANGE_BAR_EXTENDS),
01366 CC_RUNTIME_CLASS(OpChangeBarExtends),
01367 OPTOKEN_CHANGE_BAR_EXTENDS,
01368 0,
01369 _R(IDBBL_NAMEOP_CHANGE_BAR_EXTENDS),
01370 0,
01371 0,
01372 0,
01373 SYSTEMBAR_ILLEGAL,
01374 FALSE,
01375 FALSE,
01376 FALSE,
01377 0,
01378 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
01379
01380 && NameObjectsDlg::Init()
01381
01382 && NameObjectsDlg::RegisterOpDescriptor(
01383 0,
01384 _R(IDS_NAMEOP_NAME_OBJECTS_DLG),
01385 CC_RUNTIME_CLASS(NameObjectsDlg),
01386 OPTOKEN_NAME_OBJECTS_DLG,
01387 0,
01388 0,
01389 _R(IDBBL_NAMEOP_NAME_OBJECTS_DLG),
01390 0,
01391 0,
01392 SYSTEMBAR_ILLEGAL,
01393 TRUE,
01394 FALSE,
01395 TRUE,
01396 0,
01397 _R(IDS_NAMEDLG_ONE_INSTANCE),
01398 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
01399
01400 && RenameObjectsDlg::RegisterOpDescriptor(
01401 0,
01402 _R(IDS_NAMEOP_RENAME_OBJECTS_DLG),
01403 CC_RUNTIME_CLASS(RenameObjectsDlg),
01404 OPTOKEN_RENAME_OBJECTS_DLG,
01405 OpApplyNamesToOne::GetState,
01406 0,
01407 _R(IDBBL_NAMEOP_RENAME_OBJECTS_DLG));
01408 }