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
00106
00107
00108 #include "toollist.h"
00109
00110 #include "attrappl.h"
00111 #include "optsmsgs.h"
00112
00113 #include "qualattr.h"
00114
00115 #include "nodetext.h"
00116
00117 #include "helpuser.h"
00118 #include "filltool.h"
00119 #include "ndoptmz.h"
00120 #include "colormgr.h"
00121 #include "attrmap.h"
00122 #include "isetattr.h"
00123 #include "strkattr.h"
00124 #include "unicdman.h"
00125 #include "fontman.h"
00126
00127
00128
00129 #include "userattr.h"
00130 #include "webattr.h"
00131
00132 #include "nodeshad.h"
00133
00134
00135 #include "attrbev.h"
00136 #include "nodeshad.h"
00137 #include "brshattr.h"
00138 #include "fthrattr.h"
00139 #include "clipattr.h"
00140 #include "lineattr.h"
00141 #include "coldlog.h"
00142
00143
00144 #include "cxftags.h"
00145 #include "ophist.h"
00146
00147 DECLARE_SOURCE("$Revision: 1445 $");
00148
00149 CC_IMPLEMENT_DYNAMIC(CurrentAttrChangedMsg, Msg)
00150
00151
00152 #define new CAM_DEBUG_NEW
00153
00154 const INT32 AttributeTableGranularity = 20;
00155
00156
00157
00158
00159 #ifdef WEBSTER
00160
00161 BOOL AttributeManager::LastAttrAppliedBecomesCurrent =1;
00162 #else
00163
00164 BOOL AttributeManager::LastAttrAppliedBecomesCurrent = 0;
00165 #endif // WEBSTER
00166
00167
00168
00169 #ifdef WEBSTER
00170 BOOL AttributeManager::AskBeforeSettingCurrentAttr =0;
00171 #else
00172 BOOL AttributeManager::AskBeforeSettingCurrentAttr =1;
00173 #endif // WEBSTER
00174
00175 BOOL AttributeManager::SendMessages = 1;
00176
00177 BOOL AttributeManager::ShouldAskAboutContoneColours = 1;
00178 BOOL AttributeManager::HaveAskedAboutContoneColours = 0;
00179 BOOL AttributeManager::UserCancelledContoneColours = 0;
00180
00181
00182 UINT32 AttributeManager::AttributeTableSize = 0;
00183 UINT32 AttributeManager::NumAttributes = 0;
00184 AttributeEntry *AttributeManager::DefaultAttrValues = NULL;
00185 NodeTypeEntry *AttributeManager::DefaultNodeAttrs = NULL;
00186
00187
00188
00189
00190 DocColour AttributeManager::DefaultBlack = DocColour(0L, 0L, 0L);
00191 DocColour AttributeManager::DefaultWhite = DocColour(255L, 255L, 255L);
00192
00193 NodeRenderableInk* AttributeManager::pLastNodeAppliedTo = NULL;
00194 DocRect AttributeManager::LastAppliedBounds = DocRect(0,0,0,0);
00195
00196
00197 static BOOL UseLastAttrApplied = FALSE;
00198
00199 AttributeManager::AttributeManager()
00200 {
00201 }
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235 #define COL_ACCURACY (0.001)
00236
00237 void AttributeManager::FindDefaultColour(ColourList *ColList,
00238 UINT32 NameResID,
00239 DocColour *Result)
00240 {
00241 ERROR3IF(Result == NULL, "AttrMgr: FindDefaultColour - NULL Result param is illegal");
00242 if (Result == NULL)
00243 return;
00244
00245
00246 ColourRGBT DesiredDef;
00247 ColourHSVT DefaultDef;
00248 ColourCMYK CMYKBlack;
00249 ColourCMYK CMYKWhite;
00250
00251 DesiredDef.Red = DesiredDef.Green = DesiredDef.Blue = DesiredDef.Transparent = 0;
00252 DefaultDef.Hue = DefaultDef.Saturation = DefaultDef.Value = DefaultDef.Transparent = 0;
00253 CMYKBlack.Cyan = CMYKBlack.Magenta = CMYKBlack.Yellow = 0;
00254 CMYKBlack.Key = FIXED24(1.0);
00255 CMYKWhite.Cyan = CMYKWhite.Magenta = CMYKWhite.Yellow = CMYKWhite.Key = 0;
00256
00257
00258 if (NameResID ==_R(IDS_BLACKNAME))
00259
00260 *Result = DocColour(COLOURMODEL_CMYK, (ColourGeneric *) &CMYKBlack);
00261 else if (NameResID == _R(IDS_WHITENAME))
00262
00263 {
00264 *Result = DocColour(COLOURMODEL_CMYK, (ColourGeneric *) &CMYKWhite);
00265
00266 DesiredDef.Red = DesiredDef.Green = DesiredDef.Blue = FIXED24(1.0);
00267 DefaultDef.Value = FIXED24(1.0);
00268 }
00269 else if (NameResID == _R(IDS_REDNAME))
00270 {
00271 DesiredDef.Red = FIXED24(1.0);
00272 DefaultDef.Saturation = DefaultDef.Value = FIXED24(1.0);
00273 }
00274 else if (NameResID == _R(IDS_YELLOWNAME))
00275 {
00276 DesiredDef.Red = DesiredDef.Green = FIXED24(1.0);
00277 DefaultDef.Hue = FIXED24(1.0 / 6.0);
00278 DefaultDef.Saturation = DefaultDef.Value = FIXED24(1.0);
00279 }
00280 else
00281 {
00282
00283 *Result = DocColour(COLOURMODEL_HSVT, (ColourGeneric *) &DefaultDef);
00284 }
00285
00286 if (ColList != NULL)
00287 {
00288
00289 ColourContext *CCRGB = ColourContext::GetGlobalDefault(COLOURMODEL_RGBT);
00290 if (CCRGB == NULL)
00291 {
00292 ERROR3("AttrMgr: FindDefault Colour - Failed to get RGB Colour Context");
00293 return;
00294 }
00295
00296
00297
00298 IndexedColour *NewDefault = (IndexedColour *) ColList->GetHead();
00299 ColourRGBT RGBDef;
00300
00301 while (NewDefault != NULL)
00302 {
00303 if (!NewDefault->IsDeleted())
00304 {
00305
00306
00307 CCRGB->ConvertColour(NewDefault, (ColourGeneric *) &RGBDef);
00308
00309 if ((ABS(RGBDef.Red - DesiredDef.Red)) <= FIXED24(COL_ACCURACY) &&
00310 (ABS(RGBDef.Green - DesiredDef.Green)) <= FIXED24(COL_ACCURACY) &&
00311 (ABS(RGBDef.Blue - DesiredDef.Blue)) <= FIXED24(COL_ACCURACY))
00312 break;
00313 }
00314
00315 NewDefault = (IndexedColour *) ColList->GetNext(NewDefault);
00316 }
00317
00318
00319 if (NewDefault == NULL)
00320 {
00321 if (NameResID == _R(IDS_BLACKNAME))
00322 NewDefault = new INDEXEDCOLOUR_CMYK(&CMYKBlack);
00323 else if (NameResID == _R(IDS_WHITENAME))
00324 NewDefault = new INDEXEDCOLOUR_CMYK(&CMYKWhite);
00325 else
00326 NewDefault = new INDEXEDCOLOUR_HSVT(&DefaultDef);
00327
00328 if (NewDefault == NULL)
00329 {
00330 ERROR3("AttrMgr: FindDefaultColour failed to generate new default IndexedColour");
00331 return;
00332 }
00333
00334
00335 String_64 ColourName;
00336 ColourName.Load ( NameResID );
00337
00338 NewDefault->SetName ( ColourName );
00339
00340
00341 ColList->AddItem(NewDefault);
00342 }
00343
00344 if (NewDefault != NULL)
00345 Result->MakeRefToIndexedColour(NewDefault);
00346 }
00347
00348
00349 }
00350 #undef COL_ACCURACY
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 BOOL AttributeManager::InitInstance()
00374 {
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386 String_256 strGraphic( _R(IDS_GRAPHIC) );
00387 CreateCurrentAttributeGroup( CC_RUNTIME_CLASS(NodeRenderableInk), (CCRuntimeClass *)NULL,
00388 strGraphic );
00389
00390
00391
00392 AttrFlatColourFill* Attr1 = new AttrFlatColourFill;
00393 if (Attr1 == NULL)
00394 return FALSE;
00395
00396
00397
00398
00399
00400 DocColour DefWhite;
00401
00402
00403 FindDefaultColour(NULL,
00404 _R(IDS_WHITENAME), &DefWhite);
00405 DocColour DefBlack;
00406
00407
00408 FindDefaultColour(NULL,
00409 _R(IDS_BLACKNAME), &DefBlack);
00410
00411 Attr1->SetStartColour(&DefBlack);
00412 Attr1->SetEndColour(&DefWhite);
00413
00414 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), Attr1, FALSE, TRUE);
00415
00416
00417
00418 AttrFlatTranspFill* Attr4 = new AttrFlatTranspFill;
00419 if (Attr4 == NULL)
00420 return FALSE;
00421
00422 UINT32 Transp = 0;
00423 Attr4->SetStartTransp(&Transp);
00424 Attr4->SetEndTransp(&Transp);
00425 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), Attr4, FALSE, TRUE);
00426
00427
00428
00429
00430 AttrFillMappingLinear* FillMapp = new AttrFillMappingLinear;
00431 if (FillMapp == NULL)
00432 return FALSE;
00433 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), FillMapp, FALSE, TRUE);
00434
00435
00436
00437
00438
00439 AttrTranspFillMappingLinear* TranspFillMapp = new AttrTranspFillMappingLinear;
00440 if (TranspFillMapp == NULL)
00441 return FALSE;
00442 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), TranspFillMapp, FALSE, TRUE);
00443
00444
00445
00446
00447
00448 AttrFillEffectFade* Attr5 = new AttrFillEffectFade;
00449 if (Attr5 == NULL)
00450 return FALSE;
00451 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), Attr5, FALSE, TRUE);
00452
00453
00454
00455
00456 AttrStrokeColour* Attr2 = new AttrStrokeColour;
00457 if (Attr2 == NULL)
00458 return FALSE;
00459 Attr2->Value.Colour = DefBlack;
00460
00461 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), Attr2, FALSE, TRUE);
00462
00463
00464
00465
00466 AttrStrokeTransp* Attr6 = new AttrStrokeTransp;
00467 if (Attr6 == NULL)
00468 return FALSE;
00469 Attr6->Value.Transp = 0;
00470 Attr6->Value.TranspType = TT_Mix;
00471 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), Attr6, FALSE, TRUE);
00472
00473
00474
00475
00476
00477 AttrLineWidth* Attr3 = new AttrLineWidth;
00478 if (Attr3 == NULL)
00479 return FALSE;
00480
00481 Attr3->Value.LineWidth = 500;
00482 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), Attr3, FALSE, TRUE);
00483
00484
00485
00486
00487
00488
00489 AttrStartArrow* StartArrow = new AttrStartArrow;
00490 if (StartArrow == NULL)
00491 return FALSE;
00492
00493 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), StartArrow, FALSE, TRUE);
00494
00495
00496
00497
00498
00499
00500 AttrEndArrow* EndArrow = new AttrEndArrow;
00501 if (EndArrow == NULL)
00502 return FALSE;
00503
00504 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), EndArrow, FALSE, TRUE);
00505
00506
00507
00508
00509
00510
00511 AttrStartCap* StCaps = new AttrStartCap;
00512 if (StCaps == NULL)
00513 return FALSE;
00514
00515 StCaps->Value.StartCap = LineCapButt;
00516
00517 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), StCaps, FALSE, TRUE);
00518
00519
00520
00521
00522 AttrJoinType* JoinType = new AttrJoinType;
00523 if (JoinType == NULL)
00524 return FALSE;
00525
00526 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), JoinType, FALSE, TRUE);
00527
00528
00529
00530
00531 AttrMitreLimit* MitreLimit = new AttrMitreLimit;
00532 if (MitreLimit == NULL)
00533 return FALSE;
00534
00535 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), MitreLimit, FALSE, TRUE);
00536
00537
00538
00539
00540 AttrUser* User = new AttrUser;
00541 if (User == NULL)
00542 return FALSE;
00543
00544 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), User, FALSE, TRUE);
00545
00546
00547
00548
00549 AttrWebAddress* WebAddress = new AttrWebAddress;
00550 if (WebAddress == NULL)
00551 return FALSE;
00552
00553 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), WebAddress, FALSE, TRUE);
00554
00555
00556
00557
00558
00559
00560
00561 AttrWindingRule* WindingRule = new AttrWindingRule;
00562 if (WindingRule == NULL)
00563 return FALSE;
00564
00565 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), WindingRule, FALSE, TRUE);
00566
00567
00568
00569
00570 AttrDashPattern* DashPattern = new AttrDashPattern;
00571 if (DashPattern == NULL)
00572 return FALSE;
00573
00574 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), DashPattern, FALSE, TRUE);
00575
00576
00577
00578
00579 {
00580 AttrOverprintLine *OPAttr = new AttrOverprintLine;
00581 if (OPAttr == NULL)
00582 return FALSE;
00583
00584 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), OPAttr, FALSE, TRUE);
00585 }
00586
00587
00588
00589 {
00590 AttrOverprintFill *OPAttr = new AttrOverprintFill;
00591 if (OPAttr == NULL)
00592 return FALSE;
00593
00594 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), OPAttr, FALSE, TRUE);
00595 }
00596
00597
00598
00599 {
00600 AttrPrintOnAllPlates *POAPAttr = new AttrPrintOnAllPlates;
00601 if (POAPAttr == NULL)
00602 return FALSE;
00603
00604 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), POAPAttr, FALSE, TRUE);
00605 }
00606
00607
00608 #ifdef VECTOR_STROKING // Neville 6/8/97
00609
00610
00611
00612 AttrStrokeType* pStroke = new AttrStrokeType;
00613 if (pStroke == NULL)
00614 return FALSE;
00615
00616 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), pStroke, FALSE, TRUE);
00617
00618
00619
00620
00621
00622 AttrVariableWidth* pVarWidth = new AttrVariableWidth;
00623 if (pVarWidth == NULL)
00624 return FALSE;
00625
00626 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), pVarWidth, FALSE, TRUE);
00627
00628
00629 AttrBevelIndent* pBevelIndent = new AttrBevelIndent;
00630 if (pBevelIndent == NULL)
00631 return FALSE;
00632
00633 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), pBevelIndent, FALSE, TRUE);
00634
00635 AttrBevelLightAngle* pBevelLightAngle = new AttrBevelLightAngle;
00636 if (pBevelLightAngle == NULL)
00637 return FALSE;
00638
00639 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), pBevelLightAngle, FALSE, TRUE);
00640
00641 AttrBevelContrast* pBevelContrast = new AttrBevelContrast;
00642 if (pBevelContrast == NULL)
00643 return FALSE;
00644
00645 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), pBevelContrast, FALSE, TRUE);
00646
00647 AttrBevelLightTilt* pBevelTilt = new AttrBevelLightTilt;
00648 if (pBevelTilt == NULL)
00649 return FALSE;
00650
00651 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), pBevelTilt, FALSE, TRUE);
00652
00653 AttrBevelType* pBevelType = new AttrBevelType;
00654 if (pBevelType == NULL)
00655 return FALSE;
00656
00657 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), pBevelType, FALSE, TRUE);
00658
00659
00660
00661 AttrBrushType* pBrushType = new AttrBrushType;
00662 if (pBrushType == NULL)
00663 return FALSE;
00664
00665 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), pBrushType, FALSE, TRUE);
00666
00667 #endif // VECTOR_STROKING
00668
00669
00670 AttrFeather* pFeather = new AttrFeather;
00671 if (pFeather == NULL)
00672 return FALSE;
00673
00674 UpdateCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), pFeather, FALSE, TRUE);
00675
00676
00677
00678
00679
00680 String_256 strText( _R(IDS_TEXT) );
00681 CreateCurrentAttributeGroup( CC_RUNTIME_CLASS(BaseTextClass),
00682 CC_RUNTIME_CLASS(NodeRenderableInk),
00683 strText );
00684
00685
00686
00687
00688
00689
00690
00691
00692 AttrTxtFontTypeface* FntAttr = new AttrTxtFontTypeface;
00693 if (FntAttr == NULL)
00694 return FALSE;
00695
00696 PORTNOTETRACE("text", "Japanese default font disabled");
00697 #ifndef EXCLUDE_FROM_XARALX
00698
00699 if (UnicodeManager::IsDBCSOS())
00700 {
00701
00702
00703 String_64 FontName = wxT("\x82\x6c\x82\x72 \x82\x6f\x83\x53\x83\x56\x83\x62\x83\x4e");
00704
00705 FONTMANAGER->CacheNamedFont(&FontName, FC_UNDEFINED);
00706 FntAttr->Value.HTypeface = FONTMANAGER->GetFontHandle(&FontName, FC_UNDEFINED);
00707 }
00708 #endif
00709
00710 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), FntAttr, FALSE, TRUE);
00711
00712
00713
00714
00715
00716 AttrTxtBold* BoldAttr = new AttrTxtBold;
00717 if (BoldAttr == NULL)
00718 return FALSE;
00719
00720 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), BoldAttr, FALSE, TRUE);
00721
00722
00723
00724
00725
00726 AttrTxtItalic* ItalicAttr = new AttrTxtItalic;
00727 if (ItalicAttr == NULL)
00728 return FALSE;
00729
00730 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), ItalicAttr, FALSE, TRUE);
00731
00732
00733
00734
00735
00736 AttrTxtUnderline* UnderlineAttr = new AttrTxtUnderline;
00737 if (UnderlineAttr == NULL)
00738 return FALSE;
00739
00740
00741 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), UnderlineAttr, FALSE, TRUE);
00742
00743
00744
00745
00746 AttrTxtFontSize* FontSizeAttr = new AttrTxtFontSize;
00747 if (FontSizeAttr == NULL)
00748 return FALSE;
00749
00750
00751 FontSizeAttr->Value.FontSize = 12000;
00752
00753 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), FontSizeAttr, FALSE, TRUE);
00754
00755
00756
00757
00758
00759 AttrTxtAspectRatio* AspectRatioAttr = new AttrTxtAspectRatio;
00760 if (AspectRatioAttr == NULL)
00761 return FALSE;
00762
00763 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), AspectRatioAttr, FALSE, TRUE);
00764
00765
00766
00767
00768
00769 AttrTxtJustification* JustificationAttr = new AttrTxtJustification;
00770 if (JustificationAttr == NULL)
00771 return FALSE;
00772
00773 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), JustificationAttr, FALSE, TRUE);
00774
00775
00776
00777
00778
00779 AttrTxtTracking* TxtTrackingAttr = new AttrTxtTracking;
00780 if (TxtTrackingAttr == NULL)
00781 return FALSE;
00782
00783 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), TxtTrackingAttr, FALSE, TRUE);
00784
00785
00786
00787 AttrTxtScript* TxtScriptAttr = new AttrTxtScript;
00788 if (TxtScriptAttr == NULL)
00789 return FALSE;
00790
00791 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), TxtScriptAttr, FALSE, TRUE);
00792
00793
00794
00795 AttrTxtBaseLine* TxtBaseLineAttr = new AttrTxtBaseLine;
00796 if (TxtBaseLineAttr == NULL)
00797 return FALSE;
00798
00799 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), TxtBaseLineAttr, FALSE, TRUE);
00800
00801
00802
00803
00804 AttrTxtLineSpace* TxtLineSpaceAttr = new AttrTxtLineSpace;
00805 if (TxtLineSpaceAttr == NULL)
00806 return FALSE;
00807
00808 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), TxtLineSpaceAttr, FALSE, TRUE);
00809
00810
00811
00812 AttrTxtLeftMargin* TxtLeftMarginAttr = new AttrTxtLeftMargin;
00813 if (TxtLeftMarginAttr == NULL)
00814 return FALSE;
00815
00816 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), TxtLeftMarginAttr, FALSE, TRUE);
00817
00818 AttrTxtRightMargin* TxtRightMarginAttr = new AttrTxtRightMargin;
00819 if (TxtRightMarginAttr == NULL)
00820 return FALSE;
00821
00822 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), TxtRightMarginAttr, FALSE, TRUE);
00823
00824 AttrTxtFirstIndent* TxtFirstIndentAttr = new AttrTxtFirstIndent;
00825 if (TxtFirstIndentAttr == NULL)
00826 return FALSE;
00827
00828 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), TxtFirstIndentAttr, FALSE, TRUE);
00829
00830 AttrTxtRuler* TxtRulerAttr = new AttrTxtRuler;
00831 if (TxtRulerAttr == NULL)
00832 return FALSE;
00833
00834 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), TxtRulerAttr, FALSE, TRUE);
00835
00836
00837
00838
00839 Attr1 = new AttrFlatColourFill;
00840 if (Attr1 == NULL)
00841 return FALSE;
00842
00843
00844 Attr1->SetStartColour(&DefBlack);
00845 Attr1->SetEndColour(&DefWhite);
00846
00847 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), Attr1, FALSE, TRUE);
00848
00849
00850
00851 Attr4 = new AttrFlatTranspFill;
00852 if (Attr4 == NULL)
00853 return FALSE;
00854
00855 Transp = 0;
00856 Attr4->SetStartTransp(&Transp);
00857 Attr4->SetEndTransp(&Transp);
00858 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), Attr4, FALSE, TRUE);
00859
00860
00861
00862
00863 FillMapp = new AttrFillMappingLinear;
00864 if (FillMapp == NULL)
00865 return FALSE;
00866 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), FillMapp, FALSE, TRUE);
00867
00868
00869
00870
00871
00872 TranspFillMapp = new AttrTranspFillMappingLinear;
00873 if (TranspFillMapp == NULL)
00874 return FALSE;
00875 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), TranspFillMapp, FALSE, TRUE);
00876
00877
00878
00879
00880
00881 Attr5 = new AttrFillEffectFade;
00882 if (Attr5 == NULL)
00883 return FALSE;
00884 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), Attr5, FALSE, TRUE);
00885
00886
00887
00888
00889 Attr2 = new AttrStrokeColour;
00890 if (Attr2 == NULL)
00891 return FALSE;
00892 Attr2->Value.Colour = DocColour(COLOUR_NONE);
00893
00894 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), Attr2, FALSE, TRUE);
00895
00896
00897
00898
00899 Attr6 = new AttrStrokeTransp;
00900 if (Attr6 == NULL)
00901 return FALSE;
00902 Attr6->Value.Transp = 0;
00903 Attr6->Value.TranspType = TT_Mix;
00904 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), Attr6, FALSE, TRUE);
00905
00906
00907
00908 Attr3 = new AttrLineWidth;
00909 if (Attr3 == NULL)
00910 return FALSE;
00911
00912 Attr3->Value.LineWidth = 250;
00913 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), Attr3, FALSE, TRUE);
00914
00915
00916
00917
00918
00919
00920 StartArrow = new AttrStartArrow;
00921 if (StartArrow == NULL)
00922 return FALSE;
00923
00924 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), StartArrow, FALSE, TRUE);
00925
00926
00927
00928
00929
00930
00931 EndArrow = new AttrEndArrow;
00932 if (EndArrow == NULL)
00933 return FALSE;
00934
00935 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), EndArrow, FALSE, TRUE);
00936
00937
00938
00939
00940
00941
00942 StCaps = new AttrStartCap;
00943 if (StCaps == NULL)
00944 return FALSE;
00945
00946 StCaps->Value.StartCap = LineCapButt;
00947
00948 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), StCaps, FALSE, TRUE);
00949
00950
00951
00952
00953 JoinType = new AttrJoinType;
00954 if (JoinType == NULL)
00955 return FALSE;
00956
00957 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), JoinType, FALSE, TRUE);
00958
00959
00960
00961
00962 MitreLimit = new AttrMitreLimit;
00963 if (MitreLimit == NULL)
00964 return FALSE;
00965
00966 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), MitreLimit, FALSE, TRUE);
00967
00968
00969
00970
00971 WindingRule = new AttrWindingRule;
00972 if (WindingRule == NULL)
00973 return FALSE;
00974
00975 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), WindingRule, FALSE, TRUE);
00976
00977
00978
00979
00980 DashPattern = new AttrDashPattern;
00981 if (DashPattern == NULL)
00982 return FALSE;
00983
00984 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), DashPattern, FALSE, TRUE);
00985
00986
00987
00988 {
00989 AttrOverprintLine *OPAttr = new AttrOverprintLine;
00990 if (OPAttr == NULL)
00991 return FALSE;
00992
00993 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), OPAttr, FALSE, TRUE);
00994 }
00995
00996
00997
00998 {
00999 AttrOverprintFill *OPAttr = new AttrOverprintFill;
01000 if (OPAttr == NULL)
01001 return FALSE;
01002
01003 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), OPAttr, FALSE, TRUE);
01004 }
01005
01006
01007
01008 {
01009 AttrPrintOnAllPlates *POAPAttr = new AttrPrintOnAllPlates;
01010 if (POAPAttr == NULL)
01011 return FALSE;
01012
01013 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), POAPAttr, FALSE, TRUE);
01014 }
01015
01016 #ifdef VECTOR_STROKING // Neville 6/8/97
01017
01018
01019
01020 {
01021 AttrStrokeType* pStroke = new AttrStrokeType;
01022 if (pStroke == NULL)
01023 return FALSE;
01024
01025 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), pStroke, FALSE, TRUE);
01026 }
01027
01028
01029
01030
01031
01032 {
01033 AttrVariableWidth* pVarWidth = new AttrVariableWidth;
01034 if (pVarWidth == NULL)
01035 return FALSE;
01036
01037 UpdateCurrentAttribute(CC_RUNTIME_CLASS(BaseTextClass), pVarWidth, FALSE, TRUE);
01038 }
01039
01040
01041 {
01042
01043 }
01044
01045 #endif // VECTOR_STROKING
01046
01047
01048 return TRUE;
01049 }
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069 AttributeManager::~AttributeManager()
01070 {
01071
01072 AttributeGroup* CurrentGroup = (AttributeGroup*)AttrGroupList.GetHead();
01073 NodeAttribute* CurrentAttr;
01074 NodeAttribute* NextAttr;
01075 while (CurrentGroup != NULL)
01076 {
01077
01078 CurrentAttr = CurrentGroup->AttrListHd;
01079
01080 while (CurrentAttr != NULL)
01081 {
01082 NextAttr = (NodeAttribute*)CurrentAttr->FindNext();
01083 delete CurrentAttr;
01084 CurrentAttr = NextAttr;
01085 }
01086
01087 delete (AttrGroupList.RemoveItem((ListItem*)CurrentGroup));
01088 CurrentGroup =(AttributeGroup*)AttrGroupList.GetHead();
01089 }
01090 }
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130 BOOL AttributeManager::InitDefaults()
01131 {
01132 BOOL ok = RegisterBasicAttributes();
01133 #if !defined(EXCLUDE_FROM_RALPH)
01134 ok = ok && Camelot.DeclareSection(TEXT("Attributes"), 10) &&
01135 Camelot.DeclarePref(TEXT("Attributes"), TEXT("LastAttrAppliedBecomesCurrent"),
01136 &AttributeManager::LastAttrAppliedBecomesCurrent, 0, 1) &&
01137 Camelot.DeclarePref(TEXT("Attributes"), TEXT("AskBeforeSettingCurrentAttr"),
01138 &AttributeManager::AskBeforeSettingCurrentAttr,0, 1) &&
01139 Camelot.DeclarePref(TEXT("Attributes"), TEXT("AskBeforeSettingContoneColours"),
01140 &AttributeManager::ShouldAskAboutContoneColours,0, 1);
01141 #endif
01142 return (ok);
01143 }
01144
01145 void AttributeManager::Deinit()
01146 {
01147
01148 for (UINT32 i = 0; i < NumAttributes; i++)
01149 delete DefaultAttrValues[i].pAttr;
01150
01151 CCFree(DefaultAttrValues);
01152 CCFree(DefaultNodeAttrs);
01153
01154 #if !defined(EXCLUDE_FROM_RALPH)
01155
01156 OpRepeatApplyAttribToSelected::FillBlobState.DeleteAll();
01157 #endif
01158 }
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177 BOOL AttributeManager::RegisterBasicAttributes()
01178 {
01179
01180
01181 ColourCMYK Def;
01182 Def.Cyan = Def.Magenta = Def.Yellow = 0;
01183
01184 Def.Key = 1.0;
01185 DefaultBlack = DocColour(COLOURMODEL_CMYK, (ColourGeneric *) &Def);
01186
01187 Def.Key = 0;
01188 DefaultWhite = DocColour(COLOURMODEL_CMYK, (ColourGeneric *) &Def);
01189
01190
01191
01192
01193 if (StrokeColourAttribute::Init() &&
01194 StrokeTranspAttribute::Init() &&
01195 ColourFillAttribute::Init() &&
01196 TranspFillAttribute::Init() &&
01197 FillMappingAttribute::Init() &&
01198 TranspFillMappingAttribute::Init() &&
01199 FillEffectAttribute::Init() &&
01200 LineWidthAttribute::Init() &&
01201
01202 WindingRuleAttribute::Init() &&
01203
01204 JoinTypeAttribute::Init() &&
01205 QualityAttribute::Init() &&
01206 DashPatternAttribute::Init() &&
01207 StartCapAttribute::Init() &&
01208 StartArrowAttribute::Init() &&
01209 EndArrowAttribute::Init() &&
01210 MitreLimitAttribute::Init() &&
01211 UserAttribute::Init() &&
01212 WebAddressAttribute::Init() &&
01213
01214
01215 TxtFontTypefaceAttribute::Init() &&
01216 TxtBoldAttribute::Init() &&
01217 TxtItalicAttribute::Init() &&
01218 TxtAspectRatioAttribute::Init() &&
01219 TxtJustificationAttribute::Init() &&
01220 TxtTrackingAttribute::Init() &&
01221 TxtUnderlineAttribute::Init() &&
01222 TxtFontSizeAttribute::Init() &&
01223 TxtScriptAttribute::Init() &&
01224 TxtBaseLineAttribute::Init() &&
01225 TxtLineSpaceAttribute::Init() &&
01226
01227 TxtLeftMarginAttribute::Init() &&
01228 TxtRightMarginAttribute::Init() &&
01229 TxtFirstIndentAttribute::Init() &&
01230 TxtRulerAttribute::Init() &&
01231
01232 OverprintLineAttrValue::Init() &&
01233 OverprintFillAttrValue::Init() &&
01234 PrintOnAllPlatesAttrValue::Init()
01235
01236 #ifdef VECTOR_STROKING
01237 &&
01238 StrokeTypeAttrValue::Init() &&
01239 VariableWidthAttrValue::Init() &&
01240
01241 BevelAttributeValueIndent::Init() &&
01242 BevelAttributeValueType::Init() &&
01243 BevelAttributeValueContrast::Init() &&
01244 BevelAttributeValueLightAngle::Init() &&
01245 BevelAttributeValueLightTilt::Init() &&
01246
01247 BrushAttrValue::Init() &&
01248 #endif
01249
01250 FeatherAttrValue::Init() &&
01251 ClipRegionAttribute::Init()
01252
01253 )
01254 {
01255
01256
01257
01258 DrawingModeAttribute *pDMAttr = new DrawingModeAttribute(DM_COPYPEN);
01259 if (pDMAttr==NULL)
01260 return FALSE;
01261
01262 DrawingModeAttribute::ID = RegisterDefaultAttribute(NULL, pDMAttr);
01263 if (DrawingModeAttribute::ID==ATTR_BAD_ID)
01264 return FALSE;
01265
01266
01267 return TRUE;
01268 }
01269
01270
01271 return FALSE;
01272 }
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326 BOOL AttributeManager::CreateCurrentAttributeGroup(CCRuntimeClass* AttrGroup,
01327 CCRuntimeClass* BaseGroup,
01328 String_256& GrpName)
01329 {
01330
01331 AttributeGroup* NewGrp = new AttributeGroup();
01332 ERRORIF(!NewGrp, _R(IDE_NOMORE_MEMORY), FALSE);
01333 NewGrp->AttrGroup = AttrGroup;
01334 NewGrp->AttrListHd = NULL;
01335 NewGrp->BaseGroup = BaseGroup;
01336 NewGrp->GroupName = GrpName;
01337
01338 AttrGroupList.AddHead((ListItem*)NewGrp);
01339 return TRUE;
01340 }
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392 NodeAttribute* AttributeManager::UpdateCurrentAttribute(CCRuntimeClass* AttrGroup,
01393 NodeAttribute* Attribute,
01394 BOOL fCheckTransparency,
01395 BOOL DefiningGroups,
01396 BOOL TellWorld,
01397 BOOL bForceNewValue )
01398 {
01399 ERROR3IF (AttrGroup == NULL, "Invalid attribute group specified");
01400
01401
01402
01403 SelRange* Sel = GetApplication()->FindSelection();
01404 if (Sel)
01405 Sel->AttrsHaveChanged();
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416 if (Attribute->IsKindOfTextAttribute())
01417 {
01418 AttrGroup = CC_RUNTIME_CLASS(BaseTextClass);
01419 }
01420
01421 AttributeGroup* CurrentGrp;
01422 CCRuntimeClass* IDAttrGroupToAddTo = AttrGroup;
01423
01424
01425
01426
01427 do
01428 {
01429
01430 CurrentGrp = (AttributeGroup*)AttrGroupList.GetHead();
01431 while (CurrentGrp != NULL)
01432 {
01433 if (CurrentGrp->AttrGroup == IDAttrGroupToAddTo)
01434 {
01435 if (DefiningGroups)
01436 {
01437 AddAttributeToGroup(CurrentGrp, Attribute, fCheckTransparency, FALSE, bForceNewValue);
01438 return Attribute;
01439 }
01440
01441 NodeAttribute* CurrentAttrib = CurrentGrp->AttrListHd;
01442 while (CurrentAttrib != NULL)
01443 {
01444 if (CurrentAttrib->GetAttributeType() == Attribute->GetAttributeType())
01445 {
01446
01447
01448 if (!bForceNewValue && (CurrentAttrib->GetRuntimeClass()) == (Attribute->GetRuntimeClass()))
01449 {
01450 if ((*CurrentAttrib) == (*Attribute))
01451 {
01452 delete Attribute;
01453 return NULL;
01454 }
01455 }
01456
01457 if (CurrentGrp->AttrListHd == CurrentAttrib)
01458 {
01459 CurrentGrp->AttrListHd = (NodeAttribute*)CurrentAttrib->FindNext();
01460 }
01461
01462
01463 CurrentAttrib->UnlinkNodeFromTree();
01464 delete CurrentAttrib;
01465
01466 AddAttributeToGroup(CurrentGrp, Attribute, fCheckTransparency, TellWorld, bForceNewValue);
01467 return Attribute;
01468 }
01469
01470 CurrentAttrib = (NodeAttribute*)CurrentAttrib->FindNext();
01471 }
01472
01473 }
01474
01475 CurrentGrp = (AttributeGroup *) AttrGroupList.GetNext(CurrentGrp);
01476 }
01477 } while (CurrentGrp != NULL);
01478
01479 return NULL;
01480 }
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495 AttributeGroup* AttributeManager::GetAttributeGroup(CCRuntimeClass* GroupID)
01496 {
01497 AttributeGroup* CurrentGrp;
01498 CurrentGrp = (AttributeGroup*)AttrGroupList.GetHead();
01499 do
01500 {
01501 if (CurrentGrp->AttrGroup == GroupID)
01502 {
01503 return CurrentGrp;
01504 }
01505 CurrentGrp = (AttributeGroup *) AttrGroupList.GetNext(CurrentGrp);
01506
01507 } while (CurrentGrp);
01508
01509 return NULL;
01510 }
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543 void AttributeManager::AddAttributeToGroup(AttributeGroup* pAttrGroup,
01544 NodeAttribute* Attribute,
01545 BOOL fCheckTransparency,
01546 BOOL TellWorld,
01547 BOOL bRetainValues )
01548 {
01549
01550 if (pAttrGroup->AttrListHd != NULL)
01551 Attribute->AttachNode(pAttrGroup->AttrListHd, NEXT, fCheckTransparency);
01552 else
01553 pAttrGroup->AttrListHd = Attribute;
01554
01555
01556
01557 if (Attribute->IsAFillAttr())
01558 {
01559 AttrFillGeometry* Fill = (AttrFillGeometry*)Attribute;
01560
01561
01562 Fill->DeselectAll();
01563
01564 if (!bRetainValues && Fill->GetBoundingRect().IsEmpty())
01565 {
01566
01567
01568
01569
01570
01571 DocCoord coord;
01572 Fill->SetStartPoint( &coord );
01573 Fill->SetEndPoint( &coord );
01574 Fill->SetEndPoint2( &coord );
01575 }
01576
01577 }
01578
01579
01580 if (TellWorld)
01581 {
01582 BROADCAST_TO_ALL(CurrentAttrChangedMsg());
01583 }
01584 }
01585
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632 static BOOL UpdateDeletedColour(ColourList *ColList, DocColour *TheColour,
01633 IndexedColour **NewDefault)
01634 {
01635 if (TheColour == NULL)
01636 return FALSE;
01637
01638 IndexedColour *RefColour = TheColour->FindParentIndexedColour();
01639 if( RefColour == NULL ||
01640 !RefColour->IsDeleted() )
01641 return FALSE;
01642
01643
01644
01645
01646 SelRange* Sel = GetApplication()->FindSelection();
01647 if (Sel)
01648 Sel->AttrsHaveChanged();
01649
01650
01651
01652
01653 if (*NewDefault != NULL)
01654 TheColour->MakeRefToIndexedColour(*NewDefault);
01655 else
01656 {
01657 AttributeManager::FindDefaultColour(ColList, _R(IDS_BLACKNAME), TheColour);
01658 *NewDefault = TheColour->FindParentIndexedColour();
01659 }
01660
01661 return TRUE;
01662 }
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681 void AttributeManager::UpdateForDeletedColours(ColourList *ParentList)
01682 {
01683 AttributeGroup* CurrentGrp = (AttributeGroup*)AttrGroupList.GetHead();
01684 NodeAttribute* CurrentAttrib;
01685 DocColour *pColour;
01686 UINT32 Context = 0;
01687 BOOL Changed = FALSE;
01688 IndexedColour *NewDefault = NULL;
01689
01690 while (CurrentGrp != NULL)
01691 {
01692 CurrentAttrib = CurrentGrp->AttrListHd;
01693 while (CurrentAttrib != NULL)
01694 {
01695 Context = 0;
01696 do
01697 {
01698
01699 pColour = CurrentAttrib->EnumerateColourFields(Context++);
01700
01701
01702 if (pColour != NULL)
01703 Changed |= UpdateDeletedColour(ParentList, pColour, &NewDefault);
01704 }
01705 while (pColour != NULL);
01706
01707 CurrentAttrib = (NodeAttribute*)CurrentAttrib->FindNext();
01708 }
01709
01710 CurrentGrp = (AttributeGroup *) AttrGroupList.GetNext(CurrentGrp);
01711 }
01712
01713 if (Changed)
01714 {
01715
01716 BROADCAST_TO_ALL(CurrentAttrChangedMsg());
01717 }
01718 }
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740 BOOL AttributeManager::ApplyCurrentAttribsToNode(NodeRenderableInk* Node)
01741 {
01742 ERROR3IF(Node == NULL, "NULL object passed to AttributeManager::ApplyCurrentAttribsToNode");
01743
01744
01745
01746 CCRuntimeClass* IDCurrentAttrGroup = Node->GetCurrentAttribGroup();
01747 ERROR3IF (IDCurrentAttrGroup == NULL, "Object has NULL attribute group associated with it");
01748
01749
01750
01751 CCAttrMap* pAppliedAttrsMap;
01752
01753 try
01754 {
01755 pAppliedAttrsMap = new CCAttrMap(30);
01756 }
01757 catch( ... )
01758 {
01759 return FALSE;
01760 }
01761
01762
01763 do
01764 {
01765
01766 AttributeGroup* CurrentGrp = (AttributeGroup*)AttrGroupList.GetHead();
01767 while (CurrentGrp != NULL)
01768 {
01769 if (CurrentGrp->AttrGroup == IDCurrentAttrGroup)
01770 {
01771
01772 NodeAttribute* CurrentAttrib = CurrentGrp->AttrListHd;
01773 while (CurrentAttrib != NULL)
01774 {
01775
01776
01777 CCRuntimeClass* CurrentAttrType = CurrentAttrib->GetAttributeType();
01778
01779 void* NotUsed;
01780 if( !pAppliedAttrsMap->Lookup( CurrentAttrType, NotUsed ) &&
01781 Node->RequiresAttrib( CurrentAttrib ) )
01782 {
01783
01784
01785 Node->InvalidateBoundingRect();
01786 DocRect NodeBounds = Node->GetBoundingRect(TRUE);
01787
01788
01789 NodeAttribute* AttribClone = (NodeAttribute*)CurrentAttrib->SimpleCopy();
01790 ERRORIF(!AttribClone, _R(IDE_NOMORE_MEMORY), FALSE);
01791
01792
01793
01794 AttribClone->TransformToNewBounds(NodeBounds);
01795
01796
01797 AttribClone->AttachNode(Node, FIRSTCHILD);
01798
01799 if (AttribClone->GetAttributeType() == CC_RUNTIME_CLASS(AttrFillGeometry) ||
01800 AttribClone->GetAttributeType() == CC_RUNTIME_CLASS(AttrTranspFillGeometry))
01801 {
01802
01803
01804
01805
01806
01807 ((AttrFillGeometry*)AttribClone)->AttributeChanged();
01808 }
01809
01810
01811
01812 pAppliedAttrsMap->SetAt(CurrentAttrType, NULL);
01813 }
01814 CurrentAttrib = (NodeAttribute*)CurrentAttrib->FindNext();
01815 }
01816
01817 IDCurrentAttrGroup = CurrentGrp->BaseGroup;
01818 break;
01819 }
01820 CurrentGrp = (AttributeGroup *) AttrGroupList.GetNext(CurrentGrp);
01821 ERROR3IF(CurrentGrp == NULL, "Unable to find attribute group");
01822 }
01823
01824 } while (IDCurrentAttrGroup != NULL);
01825
01826 delete pAppliedAttrsMap;
01827 return TRUE;
01828 }
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852 NodeAttribute* AttributeManager::GetCurrentAttribute(CCRuntimeClass* AttrGroup,
01853 CCRuntimeClass* AttrType)
01854 {
01855 CCRuntimeClass* GroupToFind = AttrGroup;
01856 do
01857 {
01858
01859 AttributeGroup* CurrentGrp = (AttributeGroup*)AttrGroupList.GetHead();
01860 while (CurrentGrp != NULL)
01861 {
01862 if (CurrentGrp->AttrGroup == GroupToFind)
01863 {
01864
01865 NodeAttribute* CurrentAttrib = CurrentGrp->AttrListHd;
01866 while (CurrentAttrib != NULL)
01867 {
01868 if (CurrentAttrib->GetAttributeType() == AttrType)
01869 {
01870 return CurrentAttrib;
01871 }
01872 CurrentAttrib = (NodeAttribute*)CurrentAttrib->FindNext();
01873 }
01874
01875 GroupToFind = CurrentGrp->BaseGroup;
01876 break;
01877 }
01878 CurrentGrp = (AttributeGroup *) AttrGroupList.GetNext(CurrentGrp);
01879 ERROR3IF(CurrentGrp == NULL, "Could not find attribute group");
01880 }
01881
01882 } while (GroupToFind != NULL);
01883
01884 ENSURE(FALSE,"Attribute manager unable to find current attribute");
01885 return NULL;
01886 }
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907
01908 NodeAttribute* AttributeManager::GetSelToolCurrentAttribute(CCRuntimeClass* pAttrType)
01909 {
01910 CCRuntimeClass* CurrentAttribGroup;
01911
01912
01913
01914
01915
01916 if (pAttrType->IsKindOf(CC_RUNTIME_CLASS(AttrTxtBase)))
01917 {
01918 CurrentAttribGroup = CC_RUNTIME_CLASS(BaseTextClass);
01919 }
01920 else
01921 {
01922
01923 Tool* CurrentTool = Tool::GetCurrent();
01924 if (CurrentTool == NULL)
01925 {
01926 return FALSE;
01927 }
01928
01929 CurrentAttribGroup =
01930 CurrentTool->Parent->m_ToolInfo.CurrentAttributeGroup;
01931
01932 ENSURE (CurrentAttribGroup != NULL, "Tool has no associated current attribute group");
01933 }
01934
01935 return GetCurrentAttribute( CurrentAttribGroup, pAttrType);
01936 }
01937
01938
01939
01940
01941
01942
01943
01944
01945
01946
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956 void AttributeManager::GetCurrentLineAndFillColour(CCRuntimeClass* AttrGroup,
01957 DocColour* LineCol, DocColour* FillCol)
01958 {
01959
01960 AttributeGroup* CurrentGrp = (AttributeGroup*)AttrGroupList.GetHead();
01961 while (CurrentGrp != NULL)
01962 {
01963 if (CurrentGrp->AttrGroup == AttrGroup)
01964 {
01965
01966 NodeAttribute* CurrentAttrib = CurrentGrp->AttrListHd;
01967 while (CurrentAttrib != NULL)
01968 {
01969 if (CurrentAttrib->GetAttributeType() == CC_RUNTIME_CLASS(AttrStrokeColour))
01970 *LineCol = ((AttrStrokeColour*)CurrentAttrib)->Value.Colour;
01971 if ((CurrentAttrib->GetAttributeType() == CC_RUNTIME_CLASS(AttrFillGeometry)) &&
01972 (((AttrFillGeometry*)CurrentAttrib)->GetStartColour()))
01973 *FillCol = *((AttrFillGeometry*)CurrentAttrib)->GetStartColour();
01974 CurrentAttrib = (NodeAttribute*)CurrentAttrib->FindNext();
01975 }
01976 return;
01977 }
01978 CurrentGrp = (AttributeGroup *) AttrGroupList.GetNext(CurrentGrp);
01979 }
01980 ENSURE(FALSE,"Attribute manager unable to find attribute group");
01981 }
01982
01983 #define TSIZE(C) (AttributeTableSize * sizeof(C))
01984
01985 BOOL AttributeManager::EnsureTableSpaceAvailable()
01986 {
01987 if (AttributeTableSize == 0)
01988 {
01989
01990 AttributeTableSize = AttributeTableGranularity;
01991
01992
01993 DefaultAttrValues = (AttributeEntry *) CCMalloc(TSIZE(AttributeEntry));
01994 if (DefaultAttrValues==NULL)
01995 return FALSE;
01996
01997
01998 DefaultNodeAttrs = (NodeTypeEntry *) CCMalloc(TSIZE(NodeTypeEntry));
01999 if (DefaultNodeAttrs==NULL)
02000 return FALSE;
02001 }
02002 else if (NumAttributes >= AttributeTableSize)
02003 {
02004
02005 AttributeTableSize += AttributeTableGranularity;
02006
02007 AttributeEntry *pTmpAttrs =
02008 (AttributeEntry *) CCRealloc(DefaultAttrValues, TSIZE(AttributeEntry));
02009
02010 if (pTmpAttrs==NULL)
02011 return FALSE;
02012
02013 DefaultAttrValues = pTmpAttrs;
02014
02015
02016 NodeTypeEntry *pTmpNodeAttrs =
02017 (NodeTypeEntry *) CCRealloc(DefaultNodeAttrs, TSIZE(NodeTypeEntry));
02018
02019 if (pTmpNodeAttrs == NULL)
02020 {
02021
02022
02023 AttributeTableSize -= AttributeTableGranularity;
02024 pTmpAttrs = (AttributeEntry *) CCRealloc(DefaultAttrValues, TSIZE(AttributeEntry));
02025
02026 if (pTmpAttrs != NULL)
02027
02028 DefaultAttrValues = pTmpAttrs;
02029
02030
02031 return FALSE;
02032 }
02033
02034
02035 DefaultNodeAttrs = pTmpNodeAttrs;
02036 }
02037
02038
02039 return TRUE;
02040 }
02041
02042
02043
02044
02045 UINT32 AttributeManager::RegisterDefaultAttribute(CCRuntimeClass *pNodeType,
02046 AttributeValue *pValue)
02047 {
02048
02049 if (!EnsureTableSpaceAvailable())
02050 return ATTR_BAD_ID;
02051
02052 ENSURE(pValue != NULL, "NULL AttributeValue passed to RegisterDefaultAttribute()");
02053
02054
02055
02056 DefaultAttrValues[NumAttributes].pAttr = pValue;
02057 DefaultAttrValues[NumAttributes].Temp = FALSE;
02058 DefaultAttrValues[NumAttributes].Ignore = FALSE;
02059
02060
02061 DefaultNodeAttrs[NumAttributes].pNodeType = pNodeType;
02062
02063
02064 NumAttributes++;
02065
02066
02067 return (NumAttributes - 1);
02068 }
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092 AttributeEntry *AttributeManager::GetDefaultAttributes()
02093 {
02094
02095 ENSURE(NumAttributes > 0, "No attributes have registered yet!");
02096
02097
02098
02099 INT32 Size = NumAttributes * sizeof(AttributeEntry);
02100 AttributeEntry *pAttrs = (AttributeEntry *) CCMalloc(Size);
02101 if (pAttrs == NULL)
02102 return NULL;
02103
02104
02105 memcpy(pAttrs, DefaultAttrValues, Size);
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120 return pAttrs;
02121 }
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139 NodeAttribute* AttributeManager::GetDefaultAttribute(AttrIndex AttrID)
02140 {
02141 AttributeValue * pAttrVal = NULL;
02142 NodeAttribute * pNewAttr = NULL;
02143 if(!DefaultAttrValues)
02144 {
02145 ENSURE(FALSE,"Default attr table not allocated yet.");
02146 return NULL;
02147 }
02148
02149 if (AttrID==ATTR_BAD_ID)
02150 {
02151 ENSURE(FALSE,"BAD ID passed to GetDefaultAttribute");
02152 return NULL;
02153 }
02154
02155 pAttrVal = DefaultAttrValues[AttrID].pAttr;
02156 if(!pAttrVal)
02157 {
02158 ENSURE(FALSE,"No default attr for ATTR_ID");
02159 return NULL;
02160 }
02161
02162
02163 pNewAttr = pAttrVal->MakeNode();
02164 if(!pNewAttr)
02165 {
02166 ENSURE(FALSE,"Not enough mem to create default attribute copy");
02167 return NULL;
02168 }
02169
02170 return pNewAttr;
02171 }
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184
02185
02186 AttributeValue* AttributeManager::GetDefaultAttributeVal(AttrIndex AttrID)
02187 {
02188 AttributeValue * pAttrVal = NULL;
02189
02190 if(!DefaultAttrValues)
02191 {
02192 ENSURE(FALSE,"Default attr table not allocated yet.");
02193 return NULL;
02194 }
02195
02196 pAttrVal = DefaultAttrValues[AttrID].pAttr;
02197 if(!pAttrVal)
02198 {
02199 ENSURE(FALSE,"No default attr for ATTR_ID");
02200 return NULL;
02201 }
02202
02203 return pAttrVal;
02204 }
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227 BOOL AttributeManager::GetDefaultAttribute(AttrIndex aiToGet, AttributeValue* pavReturn)
02228 {
02229
02230 ERROR3IF(NumAttributes <= 0, "AttributeManager::GetDefaultAttribute - No attributes have registered yet!");
02231 ERROR3IF(pavReturn==NULL, "AttributeManager::GetDefaultAttribute - passed NULL pointer");
02232
02233
02234 AttributeEntry* paeReturn=&DefaultAttrValues[aiToGet];
02235
02236
02237 if (paeReturn && paeReturn->pAttr)
02238 {
02239
02240
02241 *pavReturn=*(paeReturn->pAttr);
02242
02243
02244 return TRUE;
02245 }
02246 else
02247
02248 return FALSE;
02249 }
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266 UINT32 AttributeManager::GetNumAttributes()
02267 {
02268 return NumAttributes;
02269 }
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287 BOOL AttributeManager::ApplyBasedOnDefaults(Node *Target, AttributeEntry *AttrsToApply)
02288 {
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298
02299
02300
02301
02302
02303
02304
02305
02306
02307
02308
02309
02310 for (INT32 i = NumAttributes - 1; i >= 0; i--)
02311 {
02312
02313 if (!AttrsToApply[i].Ignore &&
02314 (DefaultAttrValues[i].pAttr != AttrsToApply[i].pAttr) &&
02315 (Target->IsKindOf(DefaultNodeAttrs[i].pNodeType)))
02316 {
02317
02318 if ((DefaultAttrValues[i].pAttr == NULL) ||
02319 (AttrsToApply[i].pAttr->GetRuntimeClass() !=
02320 DefaultAttrValues[i].pAttr->GetRuntimeClass()) ||
02321 AttrsToApply[i].pAttr->IsDifferent(DefaultAttrValues[i].pAttr))
02322 {
02323
02324
02325 Node *pNode = AttrsToApply[i].pAttr->MakeNode();
02326
02327
02328 if (pNode == NULL)
02329 return FALSE;
02330
02331
02332 pNode->AttachNode(Target, FIRSTCHILD);
02333 }
02334 }
02335
02336 }
02337
02338
02339 return TRUE;
02340 }
02341
02342
02343
02344
02345
02346
02347
02348
02349
02350
02351
02352
02353
02354
02355
02356
02357
02358
02359
02360
02361
02362
02363
02364
02365
02366
02367
02368
02369
02370
02371
02372
02373
02374
02375
02376
02377
02378
02379
02380
02381
02382
02383
02384
02385
02386
02387
02388
02389 void AttributeManager::AttributeSelected(NodeAttribute* Attrib, NodeAttribute* OldAttr)
02390 {
02391 #if !defined(EXCLUDE_FROM_RALPH)
02392 ENSURE( (Attrib != NULL || OldAttr != NULL), "NULL attributes passed to AttributeSelected");
02393
02394 BOOL Mutate = (Attrib == NULL);
02395 AttrFillGeometry* Mutator = NULL;
02396
02397 pLastNodeAppliedTo = NULL;
02398
02399
02400 if (Mutate)
02401 {
02402 ERROR3IF(!OldAttr->IsAFillAttr(), "A Mutator must be a fill attribute");
02403
02404 Mutator = (AttrFillGeometry*)OldAttr;
02405 }
02406
02407
02408
02409
02410
02411 SelRange* Sel = GetApplication()->FindSelection();
02412 ERROR3IF(Sel==NULL,"Can't find SelRange!");
02413 if (Sel==NULL) return;
02414
02415
02416
02417
02418 BOOL ApplyAttribute;
02419
02420 List AttrGroupList;
02421
02422 if (Attrib != NULL)
02423 {
02424 ApplyAttribute = CanBeAppliedToSelection(Attrib, &AttrGroupList);
02425 }
02426 else
02427 {
02428 ERROR3IF(OldAttr == NULL, "What are we applying then exactly ??");
02429 ApplyAttribute = CanBeAppliedToSelection(OldAttr, &AttrGroupList);
02430 }
02431
02432
02433 if (ApplyAttribute)
02434 {
02435
02436
02437
02438
02439
02440 AttrFillGeometry::SelectionCount = AttrFillGeometry::CountSelectionControlPoints();
02441
02442
02443 BOOL bApplying = TRUE;
02444 OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpApplyAttribToSelected));
02445
02446
02447 Operation* pLastOp = Document::GetSelected()->GetOpHistory().FindLastOp();
02448
02449 if (Mutate && pLastOp && pLastOp->GetRuntimeClass() == CC_RUNTIME_CLASS(OpApplyAttribToSelected))
02450 {
02451
02452 OpApplyAttribToSelected* pLastApplyOp = (OpApplyAttribToSelected*)pLastOp;
02453
02454 if (pLastApplyOp->GetValueChangeType() == Mutator->GetRuntimeClass() &&
02455 pLastApplyOp->IsMergeableApplyOp())
02456 {
02457
02458
02459
02460
02461
02462
02463 RestoreSelectionsAction* pRestoreSelAct = (RestoreSelectionsAction*)
02464 pLastApplyOp->GetUndoActionList()->FindActionOfClass(CC_RUNTIME_CLASS(RestoreSelectionsAction));
02465 SelectionState* LastOpsSelection = pRestoreSelAct->GetSelState();
02466
02467 SelectionState CurrentSelection;
02468 CurrentSelection.Record();
02469
02470 if (*LastOpsSelection == CurrentSelection)
02471 {
02472 FillBlobSelectionState CurrentFillBlobState;
02473 CurrentFillBlobState.Record();
02474
02475 if (OpRepeatApplyAttribToSelected::FillBlobState == CurrentFillBlobState)
02476 {
02477 OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpRepeatApplyAttribToSelected));
02478 bApplying = FALSE;
02479 }
02480 }
02481 }
02482 }
02483
02484
02485 OpParam tempParam((void *)Attrib,(void *)OldAttr);
02486 OpDesc->Invoke(&tempParam);
02487
02488
02489
02490 if (bApplying)
02491 OpRepeatApplyAttribToSelected::FillBlobState.Record();
02492
02493 UpdateAfterAttrApplied(Mutate ? Mutator : NULL);
02494
02495 }
02496
02497 BOOL bCurrentUpdated = UpdateCurrentAppliedAttr(Mutate ? Mutator: Attrib, &AttrGroupList, ApplyAttribute, Mutate);
02498 if (!bCurrentUpdated)
02499 {
02500
02501 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
02502 }
02503
02504
02505 if (Mutate)
02506 {
02507 if (Mutator != NULL)
02508 {
02509 delete Mutator;
02510 Mutator = NULL;
02511 }
02512 }
02513 if (Attrib != NULL)
02514 {
02515 delete Attrib;
02516 Attrib = NULL;
02517 }
02518
02519
02520 AttrGroupList.DeleteAll();
02521
02522
02523
02524
02525 Sel->BroadcastAnyPendingMessages();
02526 #endif
02527 }
02528
02529
02530 BOOL AttributeManager::UpdateAfterAttrApplied(NodeAttribute* pAttr)
02531 {
02532 if (SendMessages)
02533 {
02534
02535 SelRange* Sel = GetApplication()->FindSelection();
02536
02537 Sel->AttrsHaveChanged();
02538
02539 AttrFillGeometry::SelectionCount = AttrFillGeometry::CountSelectionControlPoints();
02540
02541 if (pAttr && pAttr->IsKindOf(CC_RUNTIME_CLASS(AttrColourChange)))
02542 {
02543
02544
02545 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::COLOURATTCHANGED));
02546 }
02547 else
02548 {
02549
02550 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::COLOURATTCHANGED));
02551
02552 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
02553
02554 Sel->UpdateBounds();
02555 }
02556 }
02557
02558 return TRUE;
02559 }
02560
02561 BOOL AttributeManager::UpdateCurrentAppliedAttr(NodeAttribute* pAttr, List* pAttrGroupList, BOOL bAttrApplied, BOOL bMutate)
02562 {
02563 Document* CurrentDoc = Document::GetSelected();
02564 if (CurrentDoc == NULL)
02565 return FALSE;
02566
02567 AttributeManager& AttrMgr = CurrentDoc->GetAttributeMgr();
02568 if (AttrMgr.WeShouldMakeAttrCurrent(bAttrApplied, pAttr, pAttrGroupList))
02569 {
02570 NodeAttribute* NewCurrent = pAttr;
02571
02572
02573 UpdateCurrentAttr(NewCurrent, bMutate, pAttrGroupList);
02574
02575
02576 BOOL IsMutate;
02577 NodeAttribute* pOther = AttributeManager::GetOtherAttrToApply(NewCurrent, &IsMutate);
02578
02579 if (pOther != NULL)
02580 {
02581 UpdateCurrentAttr(pOther, IsMutate, pAttrGroupList);
02582
02583 delete pOther;
02584 }
02585
02586 return TRUE;
02587 }
02588
02589 return FALSE;
02590 }
02591
02592
02593
02594
02595
02596
02597
02598
02599
02600
02601
02602
02603
02604
02605
02606
02607
02608
02609
02610
02611
02612
02613
02614
02615
02616
02617
02618
02619
02620
02621
02622
02623
02624
02625
02626
02627
02628
02629
02630
02631
02632
02633
02634 void AttributeManager::AttributesSelected(List& AttribsToApply, UINT32 OpName)
02635 {
02636 #if !defined(EXCLUDE_FROM_RALPH)
02637
02638 ERROR3IF(AttribsToApply.IsEmpty(), "No attributes to apply in AttributeManager::AttributesSelected");
02639 if (AttribsToApply.IsEmpty()) return;
02640
02641
02642 Document* CurrentDoc = Document::GetSelected();
02643 if (CurrentDoc == NULL)
02644 return;
02645
02646 SelRange* Sel = GetApplication()->FindSelection();
02647 ERROR3IF(Sel==NULL,"Can't find SelRange!");
02648 if (Sel==NULL) return;
02649
02650
02651
02652
02653
02654 OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpApplyAttribsToSelected));
02655
02656 List AttrGroupsList;
02657
02658
02659 BOOL Success;
02660 BOOL AnyAttrsApplied;
02661
02662
02663 ApplyAttribsToSelectedParam OpParam(&AttribsToApply,
02664 OpName,
02665 &AttrGroupsList,
02666 &Success,
02667 &AnyAttrsApplied);
02668
02669
02670
02671
02672 OpDesc->Invoke(&OpParam);
02673
02674 if (Success)
02675 {
02676
02677 if (AnyAttrsApplied)
02678 {
02679
02680 Sel->AttrsHaveChanged();
02681
02682
02683 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::COLOURATTCHANGED));
02684
02685 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
02686 Sel->UpdateBounds();
02687 }
02688
02689
02690
02691
02692 AttributeManager& AttrMgr = CurrentDoc->GetAttributeMgr();
02693 AttrsToMakeCurrent AttribsToMakeCurrent = AttrMgr.GetAttributesToMakeCurrent(AttribsToApply,
02694 AttrGroupsList,
02695 FALSE);
02696
02697 if (AttribsToMakeCurrent == NONE)
02698 {
02699
02700
02701 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
02702 }
02703 else
02704 {
02705 BOOL AttributeApplied;
02706 NodeAttributePtrItem* pAttr = (NodeAttributePtrItem*)(AttribsToApply.GetHead());
02707 ListListItem* pAttrsGroups = (ListListItem*) (AttrGroupsList.GetHead());
02708 while (pAttr)
02709 {
02710 AttributeApplied = (!(pAttrsGroups->list.IsEmpty()));
02711 if (!AttributeApplied || (AttribsToMakeCurrent == ALL))
02712 {
02713
02714
02715 UpdateCurrentAttr(pAttr->NodeAttribPtr,
02716 FALSE,
02717 &(pAttrsGroups->list),
02718 FALSE);
02719 }
02720 pAttr = (NodeAttributePtrItem*)(AttribsToApply.GetNext(pAttr));
02721 pAttrsGroups = (ListListItem*)(AttrGroupsList.GetNext(pAttrsGroups));
02722 }
02723
02724 BROADCAST_TO_ALL(CurrentAttrChangedMsg());
02725 }
02726 }
02727
02728 AttrGroupsList.DeleteAll();
02729
02730
02731
02732
02733 Sel->BroadcastAnyPendingMessages();
02734 #endif
02735 }
02736
02737
02738
02739
02740
02741
02742
02743
02744
02745
02746
02747
02748
02749
02750
02751
02752
02753
02754
02755
02756
02757
02758
02759
02760
02761
02762
02763
02764
02765
02766
02767
02768
02769
02770
02771
02772
02773
02774
02775
02776
02777
02778
02779 BOOL SelOperation::DoAttributesSelected(List& AttribsToApply, UINT32 OpName, BOOL bPasteAttrs)
02780 {
02781
02782 ERROR3IF(AttribsToApply.IsEmpty(), "No attributes to apply in AttributeManager::AttributesSelected");
02783 if (AttribsToApply.IsEmpty()) return FALSE;
02784
02785
02786 Document* CurrentDoc = Document::GetSelected();
02787 if (CurrentDoc == NULL)
02788 return TRUE;
02789
02790 SelRange* Sel = GetApplication()->FindSelection();
02791 ERROR3IF(Sel==NULL,"Can't find SelRange!");
02792 if (Sel==NULL) return TRUE;
02793
02794
02795
02796
02797 List AttrGroupsList;
02798
02799
02800 BOOL Success;
02801 BOOL AnyAttrsApplied;
02802
02803
02804 ApplyAttribsToSelectedParam OpParam(&AttribsToApply,
02805 OpName,
02806 &AttrGroupsList,
02807 &Success,
02808 &AnyAttrsApplied);
02809
02810
02811
02812
02813 DoApplyAttribsToSelection(&OpParam, !GetStarted());
02814
02815 if (Success)
02816 {
02817
02818 if (AnyAttrsApplied)
02819 {
02820
02821 Sel->AttrsHaveChanged();
02822
02823
02824 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::COLOURATTCHANGED));
02825
02826 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
02827 Sel->UpdateBounds();
02828 }
02829
02830
02831
02832
02833 AttributeManager& AttrMgr = CurrentDoc->GetAttributeMgr();
02834 AttributeManager::AttrsToMakeCurrent AttribsToMakeCurrent = AttrMgr.GetAttributesToMakeCurrent(AttribsToApply,
02835 AttrGroupsList,
02836 bPasteAttrs);
02837
02838 if( AttribsToMakeCurrent == AttributeManager::NONE )
02839 {
02840
02841
02842 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
02843 }
02844 else
02845 {
02846 BOOL AttributeApplied;
02847 NodeAttributePtrItem* pAttr = (NodeAttributePtrItem*)(AttribsToApply.GetHead());
02848 ListListItem* pAttrsGroups = (ListListItem*) (AttrGroupsList.GetHead());
02849 while (pAttr)
02850 {
02851 AttributeApplied = (!(pAttrsGroups->list.IsEmpty()));
02852 if (!AttributeApplied || (AttribsToMakeCurrent == AttributeManager::ALL))
02853 {
02854
02855
02856 AttributeManager::UpdateCurrentAttr(pAttr->NodeAttribPtr,
02857 FALSE,
02858 &(pAttrsGroups->list),
02859 FALSE);
02860 }
02861 pAttr = (NodeAttributePtrItem*)(AttribsToApply.GetNext(pAttr));
02862 pAttrsGroups = (ListListItem*)(AttrGroupsList.GetNext(pAttrsGroups));
02863 }
02864
02865 BROADCAST_TO_ALL(CurrentAttrChangedMsg());
02866 }
02867 }
02868
02869 AttrGroupsList.DeleteAll();
02870
02871
02872
02873
02874 Sel->BroadcastAnyPendingMessages();
02875
02876 return Success;
02877 }
02878
02879
02880
02881
02882
02883
02884
02885
02886
02887
02888
02889
02890
02891
02892
02893
02894
02895
02896
02897
02898
02899
02900
02901
02902
02903
02904
02905
02906
02907
02908
02909 AttributeManager::AttrsToMakeCurrent AttributeManager::GetAttributesToMakeCurrent(List& Attribs,
02910 List& AttrGroupSetList,
02911 BOOL bPasteAttrs)
02912 {
02913 #if !defined(EXCLUDE_FROM_RALPH)
02914 if (LastAttrAppliedBecomesCurrent)
02915 {
02916
02917 return ALL;
02918 }
02919
02920
02921
02922
02923 BOOL AllAttrsApplied = TRUE;
02924
02925 ListListItem* pCurrentAttrSet = (ListListItem*)(AttrGroupSetList.GetHead());
02926 while (pCurrentAttrSet)
02927 {
02928 if (pCurrentAttrSet->list.IsEmpty())
02929 {
02930
02931 AllAttrsApplied = FALSE;
02932 break;
02933 }
02934 pCurrentAttrSet = (ListListItem*)(AttrGroupSetList.GetNext(pCurrentAttrSet));
02935 }
02936
02937 if (AllAttrsApplied)
02938 return NONE;
02939
02940 if (!AttributeManager::AskBeforeSettingCurrentAttr)
02941 return NOT_APPLIED;
02942
02943
02944 SelRange* Sel = GetApplication()->FindSelection();
02945
02946 UINT32 nQueryStringID;
02947
02948 if (Sel->Count() > 0)
02949 {
02950 if (bPasteAttrs)
02951
02952
02953
02954 return NONE;
02955 else
02956
02957
02958 nQueryStringID = _R(IDS_ATTRS_NOT_REQD_BY_OBJS);
02959 }
02960 else
02961 {
02962 if (bPasteAttrs)
02963 nQueryStringID = _R(IDS_NO_OBJS_SEL_PASTE_ATTRS_CURRENT);
02964 else
02965
02966
02967 nQueryStringID = _R(IDS_NO_OBJS_SEL_MAKE_ATTRS_CURRENT);
02968 }
02969
02970 String_256 QueryString(nQueryStringID);
02971
02972
02973 Error::SetError(0, QueryString, 0);
02974 SetNextMsgHelpContext(nQueryStringID);
02975 INT32 DlgResult = InformMessage(0, _R(IDS_SET), _R(IDS_CANCEL), _R(IDS_QUIET));
02976 Error::ClearError();
02977
02978
02979 switch(DlgResult)
02980 {
02981 case 1:
02982 {
02983 return NOT_APPLIED;
02984 }
02985 case 2:
02986 {
02987 return NONE;
02988 }
02989 case 3:
02990 {
02991
02992 AttributeManager::AskBeforeSettingCurrentAttr = FALSE;
02993
02994
02995 BROADCAST_TO_ALL(OptionsChangingMsg(OptionsChangingMsg::ASKBEFORESETTINGATTR));
02996 return NOT_APPLIED;
02997 }
02998 default:
02999 {
03000 ERROR3("I don't know what to do");
03001 return NONE;
03002 }
03003 }
03004 #else
03005 return NONE;
03006 #endif
03007 }
03008
03009
03010
03011
03012
03013
03014
03015
03016
03017
03018
03019
03020
03021
03022
03023
03024
03025
03026
03027
03028
03029
03030
03031
03032
03033
03034
03035
03036
03037
03038
03039
03040
03041
03042
03043
03044
03045
03046
03047
03048 BOOL AttributeManager::WeShouldMakeAttrCurrent(BOOL AttributeApplied,
03049 NodeAttribute* pAttr,
03050 List* pAttrGroupList,
03051 BOOL DroppedAttr,
03052 BOOL AttrDroppedOntoPage)
03053 {
03054 #if !defined(EXCLUDE_FROM_RALPH)
03055 UseLastAttrApplied = FALSE;
03056
03057
03058
03059 if(!pAttr->ShouldBecomeCurrent()) return FALSE;
03060
03061
03062
03063
03064
03065 if ((!AttributeApplied) || LastAttrAppliedBecomesCurrent)
03066 {
03067
03068 if (LastAttrAppliedBecomesCurrent || (!AttributeManager::AskBeforeSettingCurrentAttr))
03069 {
03070 UseLastAttrApplied = LastAttrAppliedBecomesCurrent;
03071
03072 return TRUE;
03073 }
03074 else
03075 {
03076
03077
03078
03079
03080 String_256 AttrGroupsString;
03081
03082
03083
03084 if (pAttr->IsKindOfTextAttribute())
03085 {
03086 AttrGroupsString = String(_R(IDS_TEXT));
03087 }
03088 else
03089 {
03090
03091
03092 if (pAttrGroupList->IsEmpty())
03093 {
03094 ToolListItem* pItem = Tool::GetCurrent()->Parent;
03095 if (pItem)
03096 AttrGroupsString = GetAttributeGroup((pItem->m_ToolInfo.CurrentAttributeGroup))->GroupName;
03097 }
03098 else
03099 {
03100
03101 AttributeGroupItem* pAttributeGroupItem;
03102 pAttributeGroupItem = (AttributeGroupItem*) pAttrGroupList->GetHead();
03103 ERROR3IF(!pAttributeGroupItem, "Attribute group list should not be empty");
03104 AttrGroupsString = (GetAttributeGroup(pAttributeGroupItem->AttrGroup))->GroupName;
03105 pAttributeGroupItem = (AttributeGroupItem*) pAttrGroupList->GetNext(pAttributeGroupItem);
03106 if (pAttributeGroupItem)
03107 {
03108 AttrGroupsString += String(TEXT(" "));
03109 AttrGroupsString += String(_R(IDS_AND));
03110 AttrGroupsString += String(TEXT(" "));
03111 AttrGroupsString += (GetAttributeGroup(pAttributeGroupItem->AttrGroup))->GroupName;
03112 }
03113 }
03114 }
03115
03116 AttrGroupsString += String(TEXT(" "));
03117 AttrGroupsString += String(_R(IDS_ATTRIBUTEC));
03118 AttrGroupsString += String(_R(IDS_QM));
03119
03120
03121 String_256 AttrNameString;
03122 AttrNameString += String(_R(IDS_K_ATTRMGR_OPENQUOTE));
03123 AttrNameString += String_256(pAttr->GetAttrNameID());
03124 AttrNameString += String(_R(IDS_K_ATTRMGR_CLOSEQUOTE));
03125 AttrNameString += String(_R(IDS_A_CURRENT));
03126 AttrNameString += String(TEXT(" "));
03127 AttrNameString += AttrGroupsString;
03128
03129
03130 SelRange* Sel = GetApplication()->FindSelection();
03131 UINT32 nQueryStringID;
03132 if (DroppedAttr)
03133 {
03134
03135 if (AttrDroppedOntoPage)
03136 {
03137
03138 nQueryStringID = _R(IDS_DROPPED_ONTO_PAGE);
03139 }
03140 else
03141 {
03142
03143 nQueryStringID = _R(IDS_ATTRIB_NOT_REQUIRED_BY_OBJECT);
03144 }
03145 }
03146 else if (Sel->Count() > 0)
03147 {
03148
03149 nQueryStringID = _R(IDS_ATTRIB_NOT_REQUIRED);
03150 }
03151 else
03152 {
03153
03154
03155 nQueryStringID = _R(IDS_MAKE_COL_CURRENT_ATTRIB);
03156 }
03157
03158
03159 String_256 QueryString(nQueryStringID);
03160 QueryString += AttrNameString;
03161
03162
03163 Error::SetError(0, QueryString, 0);
03164 SetNextMsgHelpContext(nQueryStringID);
03165 INT32 DlgResult = InformMessage(0, _R(IDS_SET), _R(IDS_CANCEL), _R(IDS_QUIET));
03166 Error::ClearError();
03167
03168 switch(DlgResult)
03169 {
03170 case 1:
03171 {
03172 return TRUE;
03173 }
03174 case 2:
03175 {
03176 return FALSE;
03177 }
03178 case 3:
03179 {
03180
03181 AttributeManager::AskBeforeSettingCurrentAttr = FALSE;
03182
03183
03184 BROADCAST_TO_ALL(OptionsChangingMsg(OptionsChangingMsg::ASKBEFORESETTINGATTR));
03185 return TRUE;
03186 }
03187 default:
03188 {
03189 ERROR3("I don't know what to do");
03190 return FALSE;
03191 }
03192 }
03193
03194 }
03195 }
03196 else
03197 return FALSE;
03198 #else
03199 return FALSE;
03200 #endif
03201 }
03202
03203
03204
03205
03206
03207
03208
03209
03210
03211
03212
03213
03214
03215
03216
03217
03218
03219
03220
03221
03222
03223
03224
03225
03226
03227
03228
03229
03230
03231 BOOL AttributeManager::CanBeAppliedToSelection(NodeAttribute* Attrib, List* pAttrGroups)
03232 {
03233 #if !defined(EXCLUDE_FROM_RALPH)
03234 SelRange* Sel = GetApplication()->FindSelection();
03235
03236 BOOL RequiresAttrib = FALSE;
03237
03238
03239 NodeRenderableInk* Current = (NodeRenderableInk*)Sel->FindFirst();
03240 while (Current != NULL)
03241 {
03242
03243 if (CanBeAppliedToNode(Current, Attrib, pAttrGroups))
03244 {
03245 RequiresAttrib = TRUE;
03246 if ((INT32)(pAttrGroups->GetCount()) == NUM_ATTR_GROUPS)
03247 break;
03248 }
03249 Current = (NodeRenderableInk*)(Sel->FindNext(Current));
03250 }
03251 return RequiresAttrib;
03252 #else
03253 return FALSE;
03254 #endif
03255 }
03256
03257
03258
03259
03260
03261
03262
03263
03264
03265
03266
03267
03268
03269
03270
03271
03272
03273
03274
03275
03276
03277
03278
03279
03280
03281
03282
03283 BOOL AttributeManager::CanBeAppliedToNode(NodeRenderableInk* pObject,
03284 NodeAttribute* Attrib, List* pAttrGroups)
03285 {
03286 BOOL RequiresAttrib = FALSE;
03287
03288 CCRuntimeClass* NewAttrGroup;
03289 CCRuntimeClass* InSetAttrGroup;
03290 AttributeGroupItem* pAttrGrpItem;
03291
03292 BOOL InSet;
03293
03294 NodeRenderableInk* Current = pObject;
03295
03296 if (Current != NULL)
03297 {
03298 if (Current->RequiresAttrib(Attrib))
03299 {
03300 RequiresAttrib = TRUE;
03301
03302
03303 NewAttrGroup = Current->GetCurrentAttribGroup();
03304 ERROR3IF(NewAttrGroup == NULL, "Object has a NULL attribute group");
03305
03306 InSet = FALSE;
03307
03308
03309 pAttrGrpItem = (AttributeGroupItem*)pAttrGroups->GetHead();
03310 while(pAttrGrpItem != NULL)
03311 {
03312 InSetAttrGroup = pAttrGrpItem->AttrGroup;
03313 ERROR3IF(InSetAttrGroup == NULL, "NULL attribute group found");
03314 if (NewAttrGroup == InSetAttrGroup)
03315 {
03316 InSet = TRUE;
03317 break;
03318 }
03319 pAttrGrpItem = (AttributeGroupItem*)pAttrGroups->GetNext(pAttrGrpItem);
03320 }
03321
03322 if (!InSet)
03323 {
03324
03325 pAttrGrpItem = new AttributeGroupItem();
03326 if (pAttrGrpItem == NULL)
03327 return FALSE;
03328
03329 pAttrGrpItem->AttrGroup = NewAttrGroup;
03330
03331
03332 pAttrGroups->AddHead(pAttrGrpItem);
03333 }
03334 }
03335 }
03336
03337 return RequiresAttrib;
03338 }
03339
03340
03341
03342
03343
03344
03345
03346
03347
03348
03349
03350
03351
03352
03353
03354
03355
03356 void AttributeManager::ReplaceAttributes(NodeAttribute* Attrib, List* OldAttrs)
03357 {
03358 #if !defined(EXCLUDE_FROM_RALPH)
03359
03360 OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpReplaceAttributes));
03361
03362
03363
03364 AttrFillGeometry::SelectionCount = AttrFillGeometry::CountSelectionControlPoints();
03365
03366 UseLastAttrApplied = FALSE;
03367
03368
03369 ReplaceAttributesParam param(Attrib, OldAttrs);
03370 OpDesc->Invoke(¶m);
03371
03372 if (SendMessages)
03373 {
03374
03375 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::COLOURATTCHANGED));
03376
03377 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
03378 }
03379 #endif
03380 }
03381
03382
03383
03384
03385
03386
03387
03388
03389
03390
03391
03392
03393
03394
03395
03396
03397
03398 void AttributeManager::ApplyAttribToNode(NodeRenderableInk* InkNode, NodeAttribute* NewAttr)
03399 {
03400
03401
03402 ApplyAttribToNodeHelper(InkNode, NewAttr);
03403
03404
03405 if (InkNode != NULL && (InkNode->IsSelected() || InkNode->IsChildOfSelected()) && SendMessages)
03406 {
03407
03408 SelRange* Sel = GetApplication()->FindSelection();
03409 if (Sel)
03410 Sel->AttrsHaveChanged();
03411
03412 if (NewAttr->IsKindOf(CC_RUNTIME_CLASS(AttrColourChange)) )
03413 {
03414
03415
03416 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::COLOURATTCHANGED));
03417 }
03418 else
03419 {
03420
03421 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::COLOURATTCHANGED));
03422
03423 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
03424
03425 if (Sel) Sel->UpdateBounds();
03426 }
03427
03428
03429
03430
03431 if (Sel)
03432 Sel->BroadcastAnyPendingMessages();
03433 }
03434
03435
03436 delete NewAttr;
03437 }
03438
03439
03440
03441
03442
03443
03444
03445
03446
03447
03448
03449
03450
03451
03452
03453
03454
03455
03456
03457
03458 void AttributeManager::ApplyAttribToNodeHelper(NodeRenderableInk* InkNode, NodeAttribute* NewAttr)
03459 {
03460 #if !defined(EXCLUDE_FROM_RALPH)
03461 BOOL ApplyAttribute = FALSE;
03462 List AttrGroupList;
03463
03464 pLastNodeAppliedTo = NULL;
03465
03466 if (InkNode != NULL && NewAttr != NULL)
03467 {
03468 ApplyAttribute = CanBeAppliedToNode(InkNode, NewAttr, &AttrGroupList);
03469 }
03470
03471 if (ApplyAttribute)
03472 {
03473
03474 OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpApplyAttribToNode));
03475
03476
03477
03478
03479 #ifdef BUILDSHADOWS
03480
03481 if(InkNode->IS_KIND_OF(NodeShadow))
03482 {
03483 AttrFillGeometry::SelectionCount = 1;
03484 }
03485 else
03486 #endif
03487 {
03488 AttrFillGeometry::SelectionCount = AttrFillGeometry::CountSelectionControlPoints();
03489 }
03490
03491
03492
03493
03494
03495
03496
03497
03498
03499
03500
03501
03502
03503
03504
03505
03506
03507
03508
03509
03510
03511
03512
03513
03514
03515
03516
03517
03518
03519
03520
03521
03522
03523
03524
03525
03526
03527
03528
03529
03530 OpParam tempParam((void *)InkNode,(void *)NewAttr);
03531 OpDesc->Invoke(&tempParam);
03532 }
03533
03534 Document* CurrentDoc = Document::GetSelected();
03535 if (CurrentDoc == NULL)
03536 return;
03537
03538 AttributeManager& AttrMgr = CurrentDoc->GetAttributeMgr();
03539
03540 if (AttrMgr.WeShouldMakeAttrCurrent(ApplyAttribute, NewAttr, &AttrGroupList,
03541 TRUE,
03542 InkNode == NULL))
03543 {
03544 UpdateCurrentAttr(NewAttr, NewAttr->IsAFillAttr(), &AttrGroupList);
03545
03546
03547 BOOL IsMutate;
03548 NodeAttribute* pOther = AttributeManager::GetOtherAttrToApply(NewAttr, &IsMutate);
03549
03550 if (pOther != NULL)
03551 {
03552 UpdateCurrentAttr(pOther, IsMutate, &AttrGroupList);
03553
03554 }
03555
03556 if (pOther)
03557 {
03558 delete pOther;
03559 }
03560 }
03561
03562
03563 AttrGroupList.DeleteAll();
03564 #endif
03565 }
03566
03567
03568
03569
03570
03571
03572
03573
03574
03575
03576
03577
03578
03579
03580
03581
03582
03583
03584
03585
03586
03587
03588
03589
03590
03591
03592
03593
03594
03595
03596
03597
03598
03599
03600
03601 void AttributeManager::UpdateCurrentAttr(NodeAttribute* Attr,
03602 BOOL Mutate,
03603 List* pAttrGroupList,
03604 BOOL TellWorld )
03605 {
03606
03607
03608
03609 if (UseLastAttrApplied)
03610 {
03611
03612 if (pLastNodeAppliedTo != NULL)
03613 {
03614 NodeAttribute* pLastAttrApplied;
03615
03616
03617 if (!pLastNodeAppliedTo->FindAppliedAttribute(Attr->GetAttributeType(), &pLastAttrApplied))
03618 {
03619 return;
03620 }
03621
03622
03623 Attr = (NodeAttribute*)pLastAttrApplied->SimpleCopy();
03624 if (Attr == NULL)
03625 return;
03626
03627
03628 if (Attr->IsAFillAttr())
03629 {
03630 DocRect Bounds = pLastNodeAppliedTo->GetBoundingRect();
03631 ((AttrFillGeometry*)Attr)->SetBoundingRect(Bounds);
03632 }
03633
03634 if (Attr->IsAFractalFill())
03635 {
03636
03637 ((AttrFillGeometry*)Attr)->SetFractalDPI(AttrFillGeometry::FractalDPI);
03638 }
03639
03640 Mutate = FALSE;
03641 }
03642 }
03643
03644 Document* CurrentDoc = Document::GetSelected();
03645
03646 if (CurrentDoc == NULL)
03647 return;
03648
03649 NodeAttribute* CurrentAttrib = Attr;
03650
03651
03652 AttributeManager& AttrMgr = CurrentDoc->GetAttributeMgr();
03653
03654 AttributeGroupItem* pAttributeGroupItem = NULL;
03655
03656 if (pAttrGroupList != NULL)
03657 {
03658 pAttributeGroupItem = (AttributeGroupItem*) pAttrGroupList->GetHead();
03659 }
03660
03661
03662
03663
03664 CCRuntimeClass* CurrentAttribGroup;
03665
03666 if (pAttributeGroupItem == NULL)
03667 {
03668
03669
03670
03671
03672
03673 CurrentAttribGroup =
03674 Tool::GetCurrent()->Parent->m_ToolInfo.CurrentAttributeGroup;
03675 }
03676 else
03677 {
03678
03679 CurrentAttribGroup = pAttributeGroupItem->AttrGroup;
03680 ERROR3IF(CurrentAttribGroup == NULL, "Illegal NULL attribute group specified");
03681 }
03682
03683
03684
03685 do
03686 {
03687 if (Mutate)
03688 {
03689
03690 ERROR3IF(!(Attr->IS_KIND_OF(AttrFillGeometry)), "Mutator is not a AttrFillGeometry");
03691
03692
03693 AttrFillGeometry* CurrentAttr = (AttrFillGeometry*)AttrMgr
03694 .GetCurrentAttribute(CurrentAttribGroup,
03695 Attr->GetAttributeType());
03696
03697
03698 CurrentAttrib = (AttrFillGeometry*)CurrentAttr->Mutate((AttrFillGeometry*)Attr);
03699
03700 if (CurrentAttrib)
03701 {
03702
03703
03704 DocRect Bounds = ((AttrFillGeometry*)Attr)->GetBoundingRect();
03705 ((AttrFillGeometry*)CurrentAttrib)->SetBoundingRect(Bounds);
03706 }
03707
03708 if (CurrentAttrib && (*CurrentAttrib == *CurrentAttr))
03709 {
03710 delete CurrentAttrib;
03711 CurrentAttrib = NULL;
03712 }
03713 }
03714
03715 if (CurrentAttrib)
03716 {
03717
03718 NodeAttribute* pAttrToApply = (NodeAttribute*)(CurrentAttrib->SimpleCopy());
03719 if (pAttrToApply == NULL)
03720 {
03721 return;
03722 }
03723
03724
03725 AttrMgr.UpdateCurrentAttribute(CurrentAttribGroup, pAttrToApply);
03726
03727 if (Mutate)
03728 delete CurrentAttrib;
03729 }
03730
03731
03732 CurrentAttribGroup = NULL;
03733 if (pAttributeGroupItem)
03734 {
03735 pAttributeGroupItem = (AttributeGroupItem*)pAttrGroupList->GetNext(pAttributeGroupItem);
03736 if (pAttributeGroupItem)
03737 {
03738 CurrentAttribGroup = pAttributeGroupItem->AttrGroup;
03739 ERROR3IF(CurrentAttribGroup == NULL, "Illegal NULL attribute group specified");
03740 }
03741 }
03742
03743 } while (CurrentAttribGroup != NULL);
03744
03745 if (UseLastAttrApplied && pLastNodeAppliedTo != NULL)
03746 {
03747
03748 delete Attr;
03749 }
03750 }
03751
03752
03753
03754
03755
03756
03757
03758
03759
03760
03761
03762
03763
03764
03765
03766
03767
03768
03769
03770 NodeAttribute* AttributeManager::GetOtherAttrToApply(NodeAttribute* AttrApplied,
03771 BOOL* IsMutate)
03772 {
03773
03774 return AttrApplied->GetOtherAttrToApply(IsMutate);
03775
03776
03777
03778
03779
03780
03781
03782
03783
03784
03785
03786
03787
03788
03789
03790
03791
03792
03793
03794
03795
03796
03797
03798
03799
03800
03801
03802
03803
03804
03805
03806
03807
03808
03809
03810
03811
03812
03813
03814
03815
03816
03817
03818
03819
03820
03821
03822
03823
03824
03825
03826
03827
03828
03829
03830
03831
03832
03833
03834
03835
03836
03837
03838
03839
03840
03841
03842
03843
03844
03845
03846
03847
03848
03849
03850
03851
03852
03853
03854
03855
03856
03857
03858
03859
03860
03861
03862
03863
03864
03865
03866
03867
03868
03869
03870
03871
03872
03873
03874
03875
03876
03877
03878
03879
03880
03881
03882
03883
03884
03885
03886
03887
03888
03889
03890
03891
03892
03893
03894
03895
03896
03897
03898
03899
03900
03901
03902
03903
03904
03905
03906
03907
03908
03909
03910
03911
03912
03913
03914
03915
03916
03917
03918
03919
03920
03921
03922
03923
03924
03925
03926
03927
03928
03929
03930
03931
03932
03933
03934
03935
03936
03937
03938
03939
03940 }
03941
03942
03943
03944
03945
03946
03947
03948
03949
03950
03951
03952
03953
03954
03955
03956 BOOL AttributeManager::WriteCurrentAttributes(BaseCamelotFilter* pFilter)
03957 {
03958 BOOL ok = TRUE;
03959 AttributeGroup* CurrentGrp;
03960
03961
03962 CurrentGrp = (AttributeGroup*)AttrGroupList.GetHead();
03963
03964 while (ok && CurrentGrp != NULL)
03965 {
03966 if (ok) ok = WriteCurrentAttributeGroupRecord(pFilter, CurrentGrp);
03967 if (ok) ok = pFilter->WriteZeroSizedRecord(TAG_DOWN);
03968
03969
03970 NodeAttribute* CurrentAttrib = CurrentGrp->AttrListHd;
03971 while (ok && CurrentAttrib != NULL)
03972 {
03973
03974 BOOL bWriteAttr = TRUE;
03975 NodeAttribute* pDefaultAttr = NULL;
03976 AttrIndex attrid = CurrentAttrib->GetAttributeIndex();
03977
03978 if (attrid!=ATTR_BAD_ID && attrid<ATTR_FIRST_FREE_ID)
03979 pDefaultAttr = GetDefaultAttribute(attrid);
03980
03981 if (pDefaultAttr!=NULL && *CurrentAttrib == *pDefaultAttr)
03982
03983
03984 bWriteAttr = FALSE;
03985
03986 if (bWriteAttr)
03987 {
03988
03989 CurrentAttrib->WritePreChildrenNative(pFilter);
03990 CurrentAttrib->WritePostChildrenNative(pFilter);
03991 if (CurrentAttrib->IsKindOf(CC_RUNTIME_CLASS(AttrFillGeometry)))
03992 ((AttrFillGeometry*)CurrentAttrib)->WriteBoundingRect(pFilter);
03993 }
03994
03995 if (pDefaultAttr)
03996 delete pDefaultAttr;
03997
03998
03999 CurrentAttrib = (NodeAttribute*)CurrentAttrib->FindNext();
04000 }
04001
04002 if (ok) ok = pFilter->WriteZeroSizedRecord(TAG_UP);
04003
04004
04005 CurrentGrp = (AttributeGroup *) AttrGroupList.GetNext(CurrentGrp);
04006 }
04007
04008 return ok;
04009 }
04010
04011
04012
04013
04014
04015
04016
04017
04018
04019
04020
04021
04022
04023
04024
04025 BOOL AttributeManager::WriteCurrentAttributeGroupRecord(BaseCamelotFilter* pFilter, AttributeGroup* pGroup)
04026 {
04027 BOOL ok = TRUE;
04028
04029 CXaraFileRecord Rec(TAG_CURRENTATTRIBUTES, TAG_CURRENTATTRIBUTES_SIZE);
04030
04031 ok = Rec.Init();
04032
04033 if (pGroup->AttrGroup == CC_RUNTIME_CLASS(NodeRenderableInk))
04034 {
04035 if (ok) ok = Rec.WriteBYTE(ATTRIBUTEGROUP_INK);
04036 }
04037 else if (pGroup->AttrGroup == CC_RUNTIME_CLASS(BaseTextClass))
04038 {
04039 if (ok) ok = Rec.WriteBYTE(ATTRIBUTEGROUP_TEXT);
04040 }
04041 else
04042 {
04043 ERROR3("Unknown Attribute Group");
04044 ok = FALSE;
04045 }
04046
04047
04048
04049 INT32 RecordNumber = 0L;
04050 if (ok) RecordNumber = pFilter->Write(&Rec);
04051
04052
04053 return (ok && RecordNumber > 0);
04054 }
04055
04056
04057
04058
04059
04060
04061
04062
04063
04064
04065
04066
04067
04068
04069
04070
04071
04072
04073
04074
04075
04076
04077
04078
04079
04080
04081
04082
04083
04084
04085 BOOL CommonAttributeItem::InitSafeAttrItem(CCRuntimeClass* AtrType, NodeAttribute* pAttrib,
04086 Range::CommonAttribResult status)
04087 {
04088 if (pAttrib)
04089 {
04090
04091 NodeAttribute* pAttrCopy = (NodeAttribute*) (pAttrib->SimpleCopy());
04092 if (!pAttrCopy)
04093 return FALSE;
04094 pAttr = pAttrCopy;
04095 }
04096 else
04097 pAttr = NULL;
04098
04099 AttrType = AtrType;
04100 Status = status;
04101 pAttrIsCopy = TRUE;
04102 return TRUE;
04103 }
04104
04105
04106
04107
04108
04109
04110
04111
04112
04113
04114
04115 CommonAttributeItem::~CommonAttributeItem()
04116 {
04117 if (pAttrIsCopy && pAttr)
04118 delete pAttr;
04119 };
04120