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 #include "camtypes.h"
00101 #include "rechdoc.h"
00102
00103
00104
00105
00106
00107 #include "page.h"
00108 #include "layer.h"
00109 #include "grid.h"
00110 #include "chapter.h"
00111
00112 #include "cxftags.h"
00113
00114 #include "unitcomp.h"
00115 #include "guides.h"
00116
00117 #include "ngsentry.h"
00118
00119
00120 #include "userattr.h"
00121 #include "tmpltatr.h"
00122 #include "nodetxts.h"
00123
00124
00125
00126
00127
00128
00129
00130
00131 INT32 g_NoOfBarsBeforeImport;
00132
00133 DECLARE_SOURCE("$Revision: 1688 $");
00134
00135 CC_IMPLEMENT_DYNAMIC(DocumentRecordHandler,CamelotRecordHandler)
00136
00137
00138
00139 #define new CAM_DEBUG_NEW
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 DocumentRecordHandler::DocumentRecordHandler()
00156 {
00157 InitVars();
00158 }
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 void DocumentRecordHandler::InitVars()
00174 {
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 BOOL DocumentRecordHandler::BeginImport()
00191 {
00192
00193 InitVars();
00194
00195 return TRUE;
00196 }
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 UINT32* DocumentRecordHandler::GetTagList()
00211 {
00212 static UINT32 TagList[] = { TAG_SPREAD,
00213 TAG_SPREADINFORMATION,
00214 TAG_DOCUMENT,
00215 TAG_CHAPTER,
00216 TAG_LAYER,
00217 TAG_LAYERDETAILS,
00218 TAG_GUIDELAYERDETAILS,
00219 TAG_GUIDELINE,
00220 TAG_GRIDRULERSETTINGS,
00221 TAG_GRIDRULERORIGIN,
00222 TAG_SPREADSCALING_ACTIVE,
00223 TAG_SPREADSCALING_INACTIVE,
00224 TAG_SPREAD_ANIMPROPS,
00225 TAG_LAYER_FRAMEPROPS,
00226 TAG_SETSENTINEL,
00227 TAG_SETPROPERTY,
00228 TAG_BARPROPERTY,
00229 TAG_CURRENTATTRIBUTES,
00230 TAG_CURRENTATTRIBUTEBOUNDS,
00231 TAG_DUPLICATIONOFFSET,
00232 CXFRH_TAG_LIST_END
00233 };
00234 return TagList;
00235 }
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253 BOOL DocumentRecordHandler::HandleRecord(CXaraFileRecord* pCXaraFileRecord)
00254 {
00255 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00256
00257 BOOL ok = TRUE;
00258
00259 INT32 Tag = pCXaraFileRecord->GetTag();
00260 switch (Tag)
00261 {
00262 case TAG_DOCUMENT:
00263 ok = HandleDocumentRecord(pCXaraFileRecord);
00264 break;
00265
00266 case TAG_CHAPTER:
00267 ok = HandleChapterRecord(pCXaraFileRecord);
00268 break;
00269
00270 case TAG_SPREAD:
00271 ok = HandleSpreadRecord(pCXaraFileRecord);
00272 break;
00273
00274 case TAG_SPREADINFORMATION:
00275 ok = HandleSpreadInformationRecord(pCXaraFileRecord);
00276 break;
00277
00278 case TAG_GRIDRULERSETTINGS:
00279 ok = HandleGridAndRulerSettingsRecord(pCXaraFileRecord);
00280 break;
00281 case TAG_GRIDRULERORIGIN:
00282 ok = HandleGridAndRulerOriginRecord(pCXaraFileRecord);
00283 break;
00284
00285 case TAG_SPREADSCALING_ACTIVE:
00286 case TAG_SPREADSCALING_INACTIVE:
00287 ok = HandleSpreadScalingRecord(pCXaraFileRecord, Tag);
00288 break;
00289
00290 case TAG_LAYER:
00291 ok = HandleLayerRecord(pCXaraFileRecord);
00292 break;
00293
00294 case TAG_LAYERDETAILS:
00295 case TAG_GUIDELAYERDETAILS:
00296 ok = HandleLayerDetailsRecord(pCXaraFileRecord);
00297 break;
00298
00299 case TAG_GUIDELINE:
00300 ok = HandleGuidelineRecord(pCXaraFileRecord);
00301 break;
00302
00303 case TAG_SPREAD_ANIMPROPS:
00304 ok = HandleSpreadAnimPropertiesRecord(pCXaraFileRecord);
00305 break;
00306
00307 case TAG_LAYER_FRAMEPROPS:
00308 ok = HandleFramePropertiesRecord(pCXaraFileRecord);
00309 break;
00310
00311 case TAG_SETSENTINEL:
00312 ok = HandleSetSentinelRecord(pCXaraFileRecord);
00313 break;
00314
00315 case TAG_SETPROPERTY:
00316 ok = HandleSetPropertyRecord(pCXaraFileRecord);
00317 break;
00318
00319 case TAG_BARPROPERTY:
00320 ok = HandleBarPropertyRecord(pCXaraFileRecord);
00321 break;
00322
00323 case TAG_CURRENTATTRIBUTES:
00324 ok = HandleCurrentAttrsRecord(pCXaraFileRecord);
00325 break;
00326
00327 case TAG_CURRENTATTRIBUTEBOUNDS:
00328 ok = HandleCurrentAttrsRecord(pCXaraFileRecord);
00329 break;
00330
00331 case TAG_DUPLICATIONOFFSET:
00332 ok = HandleDuplicationOffsetRecord(pCXaraFileRecord);
00333 break;
00334
00335 default:
00336 ok = FALSE;
00337 ERROR3_PF(("I don't handle records with the tag (%d)\n",pCXaraFileRecord->GetTag()));
00338 break;
00339 }
00340
00341 return ok;
00342 }
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360 BOOL DocumentRecordHandler::HandleDocumentRecord(CXaraFileRecord* pCXaraFileRecord)
00361 {
00362 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00363 ERROR2IF(pCXaraFileRecord->GetTag() != TAG_DOCUMENT,FALSE,"I don't handle this tag type");
00364
00365 IncDocumentInsertedCount();
00366
00367
00368 if (GetDocumentInsertedCount() > 1)
00369 EndOfFile();
00370
00371 return TRUE;
00372 }
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389 BOOL DocumentRecordHandler::HandleChapterRecord(CXaraFileRecord* pCXaraFileRecord)
00390 {
00391 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00392 ERROR2IF(pCXaraFileRecord->GetTag() != TAG_CHAPTER,FALSE,"I don't handle this tag type");
00393
00394 IncChapterInsertedCount();
00395
00396
00397 if (GetChapterInsertedCount() > 1)
00398 {
00399 EndOfFile();
00400 return TRUE;
00401 }
00402
00403
00404 if (IsImporting()) return TRUE;
00405
00406 Node* pContextNode = GetInsertContextNode();
00407 ERROR2IF(pContextNode == NULL,FALSE, "What? No context node?");
00408 Node* pChapter = pContextNode->FindParent(CC_RUNTIME_CLASS(Chapter));
00409 ERROR2IF(pChapter == NULL,FALSE, "Couldn't find the chapter node");
00410
00411 return TRUE;
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442 }
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459 BOOL DocumentRecordHandler::HandleSpreadRecord(CXaraFileRecord* pCXaraFileRecord)
00460 {
00461 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00462 ERROR2IF(pCXaraFileRecord->GetTag() != TAG_SPREAD,FALSE,"I don't handle this tag type");
00463
00464 IncSpreadInsertedCount();
00465
00466
00467 if (GetSpreadInsertedCount() <= 1)
00468 {
00469
00470
00471
00472 if (IsImporting())
00473 return TRUE;
00474
00475 Node* pContextNode = GetInsertContextNode();
00476 ERROR2IF(pContextNode == NULL, FALSE, "What? No context node?");
00477
00478
00479 if (IS_A(pContextNode, NodeSetSentinel))
00480 {
00481 SetInsertContextNode(0);
00482 pContextNode = GetInsertContextNode();
00483 }
00484
00485 Spread* pSpread = (Spread*) pContextNode->FindParent(CC_RUNTIME_CLASS(Spread));
00486 ERROR2IF(pSpread == NULL, FALSE, "Can't find the spread");
00487
00488 SetLastSpreadInserted(pSpread);
00489 SetInsertContextNode(pSpread);
00490 InsertNextNodeAsChild();
00491
00492 Layer* pLayer = pSpread->FindFirstLayer();
00493 if (pLayer != NULL)
00494 {
00495 SetInsertContextNode(pLayer);
00496 InsertNextNodeAsChild();
00497 }
00498
00499 return TRUE;
00500 }
00501 else
00502 {
00503
00504
00505
00506
00507
00508
00509
00510 Node* pContextNode = GetInsertContextNode();
00511 ERROR2IF(pContextNode == NULL,FALSE,"What? No context node?");
00512
00513
00514 if (IS_A(pContextNode, NodeSetSentinel))
00515 {
00516 SetInsertContextNode(0);
00517 pContextNode = GetInsertContextNode();
00518 }
00519
00520 Node* pSpread = pContextNode->FindParent(CC_RUNTIME_CLASS(Spread));
00521 if (pSpread != NULL)
00522 {
00523 SetInsertContextNode(pSpread);
00524 InsertNextNodeAsSibling();
00525 }
00526
00527 BOOL ok = FALSE;
00528
00529 {
00530 Spread* pNewSpread = new Spread;
00531 if (pNewSpread != NULL)
00532 ok = InsertNode(pNewSpread);
00533
00534 if (ok)
00535 {
00536 SetLastSpreadInserted(pNewSpread);
00537 InsertNextNodeAsChild();
00538
00539 NodeGrid::MakeDefaultGrid(pNewSpread);
00540
00541 Page* pPage = new Page;
00542 ok = (pPage != NULL);
00543
00544 if (ok)
00545 pPage->AttachNode(pNewSpread,LASTCHILD);
00546
00547 SetInsertContextNode(pNewSpread);
00548 InsertNextNodeAsChild();
00549 }
00550 }
00551
00552 if (!ok && pSpread != NULL)
00553 {
00554 pSpread->CascadeDelete();
00555 delete pSpread;
00556 pSpread = NULL;
00557 }
00558 return ok;
00559 }
00560 }
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578 BOOL DocumentRecordHandler::HandleSpreadInformationRecord(CXaraFileRecord* pCXaraFileRecord)
00579 {
00580
00581 if (IsImporting())
00582 return TRUE;
00583
00584 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00585
00586 Spread* pLastSpread = GetLastSpreadInserted();
00587
00588
00589 if (pLastSpread == NULL)
00590 {
00591 ERROR3("I don't have a 'last spread' ptr");
00592 return TRUE;
00593 }
00594
00595 BOOL ok = TRUE;
00596
00597
00598 MILLIPOINT Width = 0;
00599 MILLIPOINT Height = 0;
00600 if (ok) ok = pCXaraFileRecord->ReadINT32(&Width);
00601 if (ok) ok = pCXaraFileRecord->ReadINT32(&Height);
00602
00603
00604
00605 MILLIPOINT Margin = 0;
00606 MILLIPOINT Bleed = 0;
00607 if (ok) ok = pCXaraFileRecord->ReadINT32(&Margin);
00608 if (ok) ok = pCXaraFileRecord->ReadINT32(&Bleed);
00609
00610
00611
00612
00613
00614 BOOL Dps = TRUE;
00615 BOOL ShowDropShadow = TRUE;
00616 BYTE FlagsWord = 0;
00617 if (ok) ok = pCXaraFileRecord->ReadBYTE(&FlagsWord);
00618 if (FlagsWord & 1)
00619 Dps = TRUE;
00620 else
00621 Dps = FALSE;
00622 if (FlagsWord & 2)
00623 ShowDropShadow = TRUE;
00624 else
00625 ShowDropShadow = FALSE;
00626
00627
00628
00629
00630 if (ok && pLastSpread && Width > 0 && Height > 0)
00631 {
00632
00633 pLastSpread->SetPageSize(Width, Height, Margin, Bleed, Dps, ShowDropShadow);
00634
00635 if (!IsImporting())
00636 {
00637
00638
00639
00640
00641
00642 DocRect PagesRect;
00643 if (pLastSpread->GetPagesRect(&PagesRect))
00644 SetCoordOrigin(PagesRect.lo);
00645 }
00646 }
00647
00648 return ok;
00649 }
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668 Layer* DocumentRecordHandler::FindThisLayer(UINT32 n)
00669 {
00670 if (n < 1) n = 1;
00671
00672 Node* pNode = GetInsertContextNode();
00673 if (pNode != NULL)
00674 pNode = pNode->FindParent();
00675 if (pNode != NULL)
00676 pNode = pNode->FindFirstChild();
00677
00678 while (pNode != NULL)
00679 {
00680 if (pNode->IsLayer())
00681 {
00682 n--;
00683 if (n == 0)
00684 return (Layer*)pNode;
00685 }
00686
00687 pNode = pNode->FindNext();
00688 }
00689
00690 return NULL;
00691 }
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709 BOOL DocumentRecordHandler::HandleLayerRecord(CXaraFileRecord* pCXaraFileRecord)
00710 {
00711 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00712 ERROR2IF(pCXaraFileRecord->GetTag() != TAG_LAYER,FALSE,"I don't handle this tag type");
00713
00714 IncLayerInsertedCount();
00715
00716 BOOL ok = TRUE;
00717
00718 Layer* pLayer = NULL;
00719
00720 if (!IsImporting())
00721 pLayer = FindThisLayer(GetLayerInsertedCount());
00722
00723 if (pLayer == NULL)
00724 {
00725 pLayer = new Layer;
00726
00727 ok = FALSE;
00728 if (pLayer != NULL)
00729 {
00730 ok = InsertNode(pLayer);
00731
00732 if (ok)
00733 {
00734
00735 String_256 LayerName( _("Imported ") );
00736 String_256 Suffix( _("layer") );
00737 LayerName += Suffix;
00738 pLayer->SetLayerID(LayerName);
00739 pLayer->EnsureUniqueLayerID();
00740 }
00741 }
00742 }
00743
00744 SetLastLayerInserted(pLayer);
00745
00746
00747 Layer * pFirstImportedLayer = GetFirstImportedLayer();
00748 if (pFirstImportedLayer == NULL)
00749 SetFirstImportedLayer(pLayer);
00750
00751 return ok;
00752 }
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769 BOOL DocumentRecordHandler::HandleLayerDetailsRecord(CXaraFileRecord* pCXaraFileRecord)
00770 {
00771 UINT32 Tag = pCXaraFileRecord->GetTag();
00772
00773 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00774 ERROR2IF(Tag != TAG_LAYERDETAILS && Tag != TAG_GUIDELAYERDETAILS,FALSE,"I don't handle this tag type");
00775
00776 Layer* pLastLayer = GetLastLayerInserted();
00777
00778
00779 if (pLastLayer == NULL)
00780 {
00781 ERROR3("I don't have a 'last layer' ptr");
00782 return TRUE;
00783 }
00784
00785 BYTE Flags = 0;
00786 String_256 Name;
00787 INT32 ColRef = 0;
00788 DocColour Col;
00789
00790 BOOL ok = TRUE;
00791
00792 if (ok) ok = pCXaraFileRecord->ReadBYTE(&Flags);
00793 if (ok) ok = pCXaraFileRecord->ReadUnicode(&Name);
00794
00795 if (ok && Tag == TAG_GUIDELAYERDETAILS)
00796 ok = pCXaraFileRecord->ReadINT32(&ColRef);
00797
00798 #ifdef WEBSTER
00799 if (ok)
00800 {
00801
00802
00803
00804
00805 if (Tag == TAG_GUIDELAYERDETAILS)
00806 Flags &= ~TAG_LAYER_FLAG_VISIBLE;
00807 else
00808 {
00809 if (Flags & TAG_LAYER_FLAG_VISIBLE)
00810 Flags &= ~TAG_LAYER_FLAG_LOCKED;
00811
00812
00813
00814
00815 if (Flags & TAG_LAYER_FLAG_PAGEBACKGROUND)
00816 Flags |= TAG_LAYER_FLAG_LOCKED;
00817 }
00818 }
00819 #endif // WEBSTER
00820
00821 pLastLayer->SetVisible( (Flags & TAG_LAYER_FLAG_VISIBLE) != 0);
00822 pLastLayer->SetLocked( (Flags & TAG_LAYER_FLAG_LOCKED) != 0);
00823 pLastLayer->SetPrintable((Flags & TAG_LAYER_FLAG_PRINTABLE) != 0);
00824 pLastLayer->SetActive( (Flags & TAG_LAYER_FLAG_ACTIVE) != 0);
00825
00826 pLastLayer->SetPageBackground((Flags & TAG_LAYER_FLAG_PAGEBACKGROUND) != 0);
00827
00828 pLastLayer->SetBackground((Flags & TAG_LAYER_FLAG_BACKGROUND) != 0);
00829
00830
00831 if(Tag == TAG_GUIDELAYERDETAILS)
00832 {
00833 pLastLayer->SetGuide(TRUE);
00834 }
00835 else
00836 {
00837 pLastLayer->SetGuide(FALSE);
00838 }
00839
00840 pLastLayer->SetLayerID(Name);
00841
00842 #if !defined(EXCLUDE_FROM_RALPH)
00843 if (ok && ColRef != 0)
00844 {
00845 ok = GetDocColour(ColRef,&Col);
00846 if (ok)
00847 {
00848 IndexedColour* pIndexedColour = Col.FindParentIndexedColour();
00849 pLastLayer->SetGuideColour(pIndexedColour);
00850 pLastLayer->SetGuide(TRUE);
00851 }
00852 }
00853 #endif
00854
00855 if (ok)
00856 {
00857
00858
00859
00860
00861
00862
00863
00864 if (IsImporting())
00865 {
00866
00867
00868 if (!pLastLayer->IsGuide())
00869 {
00870
00871
00872
00873 pLastLayer->SetLocked(FALSE);
00874 pLastLayer->SetPrintable(TRUE);
00875 }
00876
00877
00878
00879
00880
00881 pLastLayer->SetActive(FALSE);
00882
00883
00884 if (pLastLayer->IsPageBackground())
00885 {
00886
00887
00888 pLastLayer->SetPageBackground(FALSE);
00889
00890 pLastLayer->SetFrame(TRUE);
00891
00892 pLastLayer->SetHiddenFrame(TRUE);
00893 pLastLayer->SetSolid(TRUE);
00894 }
00895
00896
00897
00898
00899 INT32 ImportWithLayers = 1;
00900 Camelot.GetPrefValue(TEXT("Filters"), TEXT("ImportWithLayers"), &ImportWithLayers);
00901
00902 if (ImportWithLayers == 0)
00903 pLastLayer->EnsureUniqueLayerID();
00904 else if (ImportWithLayers == 1)
00905 {
00906 Spread* pSpread = GetSpread();
00907
00908 if (pSpread)
00909 {
00910
00911
00912 Layer * pActiveLayer = pSpread->FindActiveLayer();
00913 pLastLayer->SetLayerID(pActiveLayer->GetLayerID());
00914 }
00915 }
00916
00917 String_256 CurName = pLastLayer->GetLayerID();
00918
00919
00920 if (ImportWithLayers == 0 && CurName != Name)
00921 {
00922
00923 String_256 Prefix( _("Imported ") );
00924
00925
00926
00927 if (Name.Sub(Prefix) == 0)
00928 {
00929
00930 Prefix += Name;
00931 pLastLayer->SetLayerID(Prefix);
00932 pLastLayer->EnsureUniqueLayerID();
00933 }
00934 }
00935 }
00936 else
00937 pLastLayer->EnsureUniqueLayerID();
00938 }
00939
00940 return ok;
00941 }
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958 BOOL DocumentRecordHandler::HandleGuidelineRecord(CXaraFileRecord* pCXaraFileRecord)
00959 {
00960 #if !defined(EXCLUDE_FROM_RALPH)
00961 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00962 ERROR3IF(pCXaraFileRecord->GetTag() != TAG_GUIDELINE,"I don't handle this tag type");
00963
00964 BYTE Type;
00965 MILLIPOINT Ordinate;
00966
00967 BOOL ok = pCXaraFileRecord->ReadBYTE(&Type);
00968
00969 if (ok && Type == GUIDELINE_HORZ)
00970 ok = pCXaraFileRecord->ReadYOrd(&Ordinate);
00971 else
00972 ok = pCXaraFileRecord->ReadXOrd(&Ordinate);
00973
00974 if (ok)
00975 {
00976 NodeGuideline* pGuide = new NodeGuideline;
00977
00978 if (pGuide != NULL)
00979 {
00980 pGuide->SetType(GuidelineType(Type));
00981 pGuide->SetOrdinate(Ordinate);
00982 ok = InsertNode(pGuide);
00983 }
00984 }
00985
00986 return ok;
00987 #else
00988 return TRUE;
00989 #endif
00990 }
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007 BOOL DocumentRecordHandler::HandleGridAndRulerSettingsRecord(CXaraFileRecord* pCXaraFileRecord)
01008 {
01009 #if !defined(EXCLUDE_FROM_RALPH)
01010 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
01011
01012
01013
01014 if (IsImporting())
01015 return TRUE;
01016
01017 BOOL ok = TRUE;
01018
01019 double Divisions = 0.0;
01020 UnitType Type = NOTYPE;
01021 UINT32 SubDivisions = 0;
01022 GridType TypeOfGrid = RECTANGULAR;
01023 INT32 UnitsRef = 0L;
01024 BYTE TypeOfGridB = (BYTE)RECTANGULAR;
01025
01026 if (ok) ok = pCXaraFileRecord->ReadINT32(&UnitsRef);
01027 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&Divisions);
01028 if (ok) ok = pCXaraFileRecord->ReadUINT32(&SubDivisions);
01029 if (ok) ok = pCXaraFileRecord->ReadBYTE(&TypeOfGridB);
01030 TypeOfGrid = (GridType)TypeOfGridB;
01031
01032
01033 UnitListComponent * pUnitsComponent = GetUnitDocComponent();
01034 ERROR2IF(pUnitsComponent == NULL,FALSE,"HandleGridAndRulerSettingsRecord No units doc component present");
01035
01036 Unit* pUnit = pUnitsComponent->GetReadUnitReference(UnitsRef);
01037 if (pUnit)
01038 Type = pUnit->GetUnitType();
01039 else
01040 return FALSE;
01041
01042 Spread* pSpread = GetSpread();
01043 ERROR2IF(pSpread == NULL,FALSE,"HandleGridAndRulerSettingsRecord No spread");
01044
01045 NodeGrid* pDefaultGrid = pSpread->FindFirstDefaultGridInSpread();
01046 ERROR2IF(pDefaultGrid == NULL,FALSE,"HandleGridAndRulerSettingsRecord No default grid");
01047
01048
01049 pDefaultGrid->CascadeDelete();
01050 delete pDefaultGrid;
01051
01052
01053 NodeGrid::SetDefaultDivisions(Divisions);
01054 NodeGrid::SetDefaultSubdivisions(SubDivisions);
01055 NodeGrid::SetDefaultUnits(Type);
01056 NodeGrid::SetDefaultGridType(TypeOfGrid);
01057
01058
01059
01060
01061
01062
01063 BOOL Scale=FALSE;
01064 NodeGrid::MakeDefaultGrid(pSpread, Scale);
01065
01066
01067
01068
01069
01070
01071
01072
01073 return ok;
01074 #else
01075 return TRUE;
01076 #endif
01077 }
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094 BOOL DocumentRecordHandler::HandleGridAndRulerOriginRecord(CXaraFileRecord* pCXaraFileRecord)
01095 {
01096 #if !defined(EXCLUDE_FROM_RALPH)
01097 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
01098
01099
01100
01101 if (IsImporting())
01102 return TRUE;
01103
01104 BOOL ok = TRUE;
01105
01106 DocCoord Origin(0,0);
01107 if (ok) ok = pCXaraFileRecord->ReadCoord(&Origin);
01108
01109 Spread* pSpread = GetSpread();
01110 ERROR2IF(pSpread == NULL,FALSE,"HandleGridAndRulerOriginRecord No spread");
01111
01112 NodeGrid* pDefaultGrid = pSpread->FindFirstDefaultGridInSpread();
01113 ERROR2IF(pDefaultGrid == NULL,FALSE,"HandleGridAndRulerOriginRecord No default grid");
01114
01115 pDefaultGrid->SetOrigin(Origin.x, Origin.y);
01116
01117 return ok;
01118 #else
01119 return TRUE;
01120 #endif
01121 }
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140 BOOL DocumentRecordHandler::HandleSpreadScalingRecord(CXaraFileRecord* pCXaraFileRecord, INT32 Tag)
01141 {
01142 #if !defined(EXCLUDE_FROM_RALPH)
01143 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
01144
01145
01146
01147 if (IsImporting())
01148 return TRUE;
01149
01150 BOOL ok = TRUE;
01151
01152 BOOL Active = FALSE;
01153 if (Tag == TAG_SPREADSCALING_ACTIVE)
01154 Active= TRUE;
01155
01156 double DrawingScaleValue = 1.0;
01157 INT32 DrawingUnits = 0L;
01158 double RealScaleValue = 1.0;
01159 INT32 RealUnits = 0L;
01160
01161
01162 BOOL DrawingPrefix = FALSE;
01163 BOOL RealPrefix = FALSE;
01164 String_32 DrawingAbbr;
01165 String_32 RealAbbr;
01166
01167 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&DrawingScaleValue);
01168 if (ok) ok = pCXaraFileRecord->ReadINT32(&DrawingUnits);
01169 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&RealScaleValue);
01170 if (ok) ok = pCXaraFileRecord->ReadINT32(&RealUnits);
01171
01172
01173 if (!ok)
01174 return FALSE;
01175
01176
01177 UnitListComponent * pUnitsComponent = GetUnitDocComponent();
01178 ERROR2IF(pUnitsComponent == NULL,FALSE,"HandleSpreadScalingRecord No units doc component present");
01179
01180 Unit* pDrawingUnit = pUnitsComponent->GetReadUnitReference(DrawingUnits);
01181 if (pDrawingUnit)
01182 {
01183 DrawingAbbr = pDrawingUnit->GetSpecifier();
01184 DrawingPrefix = pDrawingUnit->IsPrefix();
01185 }
01186 else
01187 return FALSE;
01188
01189 Unit* pRealUnit = pUnitsComponent->GetReadUnitReference(RealUnits);
01190 if (pRealUnit)
01191 {
01192 RealAbbr = pRealUnit->GetSpecifier();
01193 RealPrefix = pRealUnit->IsPrefix();
01194 }
01195 else
01196 return FALSE;
01197
01198
01199
01200
01201 Spread* pSpread = GetSpread();
01202 ERROR2IF(pSpread == NULL,FALSE,"HandleSpreadScalingRecord No spread");
01203
01204 DimScale* pDimScale = pSpread->GetPtrDimScale();
01205 ERROR2IF(pDimScale == NULL,FALSE,"HandleSpreadScalingRecord No pDimScale");
01206
01207
01208
01209
01210 String_32 DrawingScale;
01211 String_32 RealScale;
01212 INT32 DecimalPlaces = 6;
01213 if (DrawingPrefix)
01214 {
01215 DrawingScale += DrawingAbbr;
01216 }
01217 if (ok) ok = Convert::DoubleToString( DrawingScaleValue, &DrawingScale, DecimalPlaces);
01218 if (!DrawingPrefix)
01219 {
01220 DrawingScale += DrawingAbbr;
01221 }
01222
01223 if (RealPrefix)
01224 RealScale += RealAbbr;
01225 if (ok) ok = Convert::DoubleToString( RealScaleValue, &RealScale, DecimalPlaces);
01226 if (!RealPrefix)
01227 RealScale += RealAbbr;
01228
01229 if (ok)
01230 {
01231
01232 pDimScale->SetActiveState(Active);
01233
01234 ok = pDimScale->SetDrawingScaleStr(DrawingScale);
01235 if (ok) ok = pDimScale->SetRealScaleStr(RealScale);
01236 if (ok) ok = pDimScale->SetScaleFactor();
01237 }
01238
01239 #ifdef __WXMAC__
01240 PORTNOTE("MacPort", "Horrendous bodge - One of the above functions returns ok = FALSE. Another ReadDOUBLE problem?")
01241 return TRUE;
01242 #endif
01243
01244 return ok;
01245 #else
01246 return TRUE;
01247 #endif
01248 }
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267 #ifdef XAR_TREE_DIALOG
01268 void DocumentRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord, StringBase* pStr)
01269 {
01270 if (pStr == NULL || pRecord == NULL)
01271 return;
01272
01273
01274
01275 CamelotRecordHandler::GetRecordDescriptionText(pRecord,pStr);
01276
01277 TCHAR s[256];
01278 BOOL ok = TRUE;
01279
01280 UINT32 Tag = pRecord->GetTag();
01281 switch (Tag)
01282 {
01283 case TAG_DOCUMENT:
01284 break;
01285
01286 case TAG_SPREAD:
01287 break;
01288
01289 case TAG_CHAPTER:
01290 break;
01291
01292 case TAG_SETSENTINEL:
01293 break;
01294
01295 case TAG_SETPROPERTY:
01296 break;
01297
01298 case TAG_SPREADINFORMATION:
01299 {
01300 (*pStr) += _T("Spread Information record\r\n\r\n");
01301
01302
01303 MILLIPOINT Width = 0;
01304 MILLIPOINT Height = 0;
01305 if (ok) ok = pRecord->ReadINT32(&Width);
01306 if (ok) ok = pRecord->ReadINT32(&Height);
01307 camSprintf(s,_T("Page width \t: %d\r\n"),Width);
01308 (*pStr) += s;
01309 camSprintf(s,_T("Page height \t: %d\r\n"),Height);
01310 (*pStr) += s;
01311
01312
01313
01314 MILLIPOINT Margin = 0;
01315 MILLIPOINT Bleed = 0;
01316 if (ok) ok = pRecord->ReadINT32(&Margin);
01317 if (ok) ok = pRecord->ReadINT32(&Bleed);
01318 camSprintf(s,_T("Margin around spread : %d\r\n"),Margin);
01319 (*pStr) += s;
01320 camSprintf(s,_T("Bleed around spread : %d\r\n"),Bleed);
01321 (*pStr) += s;
01322
01323
01324
01325
01326
01327
01328 BOOL Dps = TRUE;
01329 BOOL ShowDropShadow = TRUE;
01330 BYTE FlagsWord = 0;
01331 if (ok) ok = pRecord->ReadBYTE(&FlagsWord);
01332 if (FlagsWord & 4)
01333 Dps = TRUE;
01334 else
01335 Dps = FALSE;
01336 if (FlagsWord & 2)
01337 ShowDropShadow = TRUE;
01338 else
01339 camSprintf(s,_T("Double page spread : %d\r\n"),Dps);
01340 (*pStr) += s;
01341 camSprintf(s,_T("Show drop shadow : %d\r\n"),ShowDropShadow);
01342 (*pStr) += s;
01343
01344 break;
01345 }
01346 case TAG_PAGE:
01347 break;
01348
01349 case TAG_LAYERDETAILS:
01350 case TAG_GUIDELAYERDETAILS:
01351 {
01352 BYTE Flags;
01353 String_256 Name;
01354 INT32 ColRef = 0;
01355
01356 pRecord->ReadBYTE(&Flags);
01357 pRecord->ReadUnicode(&Name);
01358 if (Tag == TAG_GUIDELAYERDETAILS)
01359 {
01360 (*pStr) += _T("Guide layer details\r\n\r\n");
01361 pRecord->ReadINT32(&ColRef);
01362 }
01363 else
01364 {
01365 (*pStr) += _T("Standard layer details\r\n\r\n");
01366 }
01367
01368 (*pStr) += _T("Flags\r\n");
01369 camSprintf(s,_T("Visible:\t%d\r\n"), (Flags & TAG_LAYER_FLAG_VISIBLE) != 0); (*pStr) += s;
01370 camSprintf(s,_T("Locked:\t%d\r\n"), (Flags & TAG_LAYER_FLAG_LOCKED) != 0); (*pStr) += s;
01371 camSprintf(s,_T("Printable:\t%d\r\n"), (Flags & TAG_LAYER_FLAG_PRINTABLE) != 0); (*pStr) += s;
01372 camSprintf(s,_T("Active:\t%d\r\n"), (Flags & TAG_LAYER_FLAG_ACTIVE) != 0); (*pStr) += s;
01373 camSprintf(s,_T("PageBackground:\t%d\r\n"),(Flags & TAG_LAYER_FLAG_PAGEBACKGROUND) != 0); (*pStr) += s;
01374 (*pStr) += _T("\r\n");
01375
01376 camSprintf(s,_T("Name: %s\r\n\r\n"),(TCHAR*)Name); (*pStr) += s;
01377 camSprintf(s,_T("Colour reference : %d\r\n"),ColRef); (*pStr) += s;
01378 }
01379 break;
01380
01381 case TAG_GRIDRULERSETTINGS:
01382 {
01383 double Divisions = 0.0;
01384
01385 UINT32 SubDivisions = 0;
01386 GridType TypeOfGrid = RECTANGULAR;
01387 BYTE TypeOfGridB = 0;
01388 INT32 UnitsRef = 0L;
01389
01390 if (ok) ok = pRecord->ReadINT32(&UnitsRef);
01391 camSprintf(s,_T("Grid units : %d\r\n"),UnitsRef);
01392 (*pStr) += s;
01393 if (ok) ok = pRecord->ReadDOUBLE(&Divisions);
01394 camSprintf(s,_T("Grid divisions : %f\r\n"),Divisions);
01395 if (ok) ok = pRecord->ReadUINT32(&SubDivisions);
01396 camSprintf(s,_T("Grid sub divisions : %d\r\n"),SubDivisions);
01397 if (ok) ok = pRecord->ReadBYTE(&TypeOfGridB);
01398 TypeOfGrid = (GridType)TypeOfGridB;
01399 if (TypeOfGrid == RECTANGULAR)
01400 (*pStr) += _T("Rectangular");
01401 else if (TypeOfGrid == ISOMETRIC)
01402 (*pStr) += _T("Isometric");
01403 else
01404 (*pStr) += _T("Unknown");
01405 break;
01406 }
01407
01408 case TAG_GRIDRULERORIGIN:
01409 {
01410 DocCoord Origin(0,0);
01411 if (ok) ok = pRecord->ReadCoord(&Origin);
01412 camSprintf(s,_T("Grid and Ruler origin : %d, %d\r\n"),Origin.x,Origin.y);
01413 (*pStr) += s;
01414 break;
01415 }
01416
01417 case TAG_SPREADSCALING_ACTIVE:
01418 case TAG_SPREADSCALING_INACTIVE:
01419 {
01420 if (Tag == TAG_SPREADSCALING_ACTIVE)
01421 (*pStr) += _T("Spread scaling active \r\n\r\n");
01422 else
01423 (*pStr) += _T("Spread scaling inactive \r\n\r\n");
01424
01425 double DrawingScaleValue = 1.0;
01426 INT32 DrawingUnits = 0L;
01427 double RealScaleValue = 1.0;
01428 INT32 RealUnits = 0L;
01429 if (ok) ok = pRecord->ReadDOUBLE(&DrawingScaleValue);
01430 if (ok) ok = pRecord->ReadINT32(&DrawingUnits);
01431 if (ok) ok = pRecord->ReadDOUBLE(&RealScaleValue);
01432 if (ok) ok = pRecord->ReadINT32(&RealUnits);
01433 camSprintf(s,_T("Drawing scale factor \t: %f\r\n"),DrawingScaleValue);
01434 (*pStr) += s;
01435 camSprintf(s,_T("Drawing units ref \t: %d\r\n"),DrawingUnits);
01436 (*pStr) += s;
01437 camSprintf(s,_T("Real scale factor \t\t: %f\r\n"),RealScaleValue);
01438 (*pStr) += s;
01439 camSprintf(s,_T("Real units ref \t: %d\r\n"),RealUnits);
01440 (*pStr) += s;
01441 break;
01442 }
01443
01444 case TAG_GUIDELINE:
01445 {
01446 BYTE Type;
01447 MILLIPOINT Ordinate;
01448
01449 pRecord->ReadBYTE(&Type);
01450 pRecord->ReadINT32(&Ordinate);
01451
01452 camSprintf(s,_T("Type\t: %d\r\n"),INT32(Type)); (*pStr) += s;
01453 camSprintf(s,_T("Type\t: %d\r\n"),Ordinate); (*pStr) += s;
01454 }
01455 break;
01456
01457 case TAG_SPREAD_ANIMPROPS:
01458 {
01459 DWORD Loop =0;
01460 DWORD GlobalDelay =0;
01461 DWORD Dither =0;
01462 DWORD WebPalette =0;
01463 DWORD ColoursPalette =0;
01464 DWORD NumColsInPalette =0;
01465 DWORD FlagsWord =0;
01466
01467 if (ok)
01468 ok = pRecord->ReadUINT32(&Loop);
01469 if (ok)
01470 ok = pRecord->ReadUINT32(&GlobalDelay);
01471 if (ok)
01472 ok = pRecord->ReadUINT32(&Dither);
01473 if (ok)
01474 ok = pRecord->ReadUINT32(&WebPalette);
01475 if (ok)
01476 ok = pRecord->ReadUINT32(&ColoursPalette);
01477 if (ok)
01478 ok = pRecord->ReadUINT32(&NumColsInPalette);
01479 if (ok)
01480 ok = pRecord->ReadUINT32(&FlagsWord);
01481
01482
01483 BOOL UseSystemColours = FALSE;
01484
01485
01486
01487 UseSystemColours = ((FlagsWord & 1) ? TRUE : FALSE);
01488
01489
01490
01491 camSprintf(s,_T("Animation Loop \t: %d\r\n"),Loop);
01492 (*pStr) += s;
01493 camSprintf(s,_T("GlobalDelay \t: %d\r\n"),GlobalDelay);
01494 (*pStr) += s;
01495 camSprintf(s,_T("Animation Dither \t: %d\r\n"),Dither);
01496 (*pStr) += s;
01497 camSprintf(s,_T("Palette \t: %d\r\n"),WebPalette);
01498 (*pStr) += s;
01499 camSprintf(s,_T("Palette Colours \t: %d\r\n"),ColoursPalette);
01500 (*pStr) += s;
01501 camSprintf(s,_T("Number of Colours In Palette \t: %d\r\n"),NumColsInPalette);
01502 (*pStr) += s;
01503 camSprintf(s,_T("Add System Colours \t: %d\r\n"),UseSystemColours);
01504 (*pStr) += s;
01505
01506 };
01507 break;
01508
01509 case TAG_LAYER_FRAMEPROPS:
01510 {
01511 DWORD Delay=0;
01512 BYTE Flags = 0;
01513
01514 if (ok) ok = pRecord->ReadUINT32(&Delay);
01515 if (ok) ok = pRecord->ReadBYTE(&Flags);
01516 camSprintf(s,_T("Frame Layer Delay \t: %d\r\n"),Delay); (*pStr) += s;
01517 camSprintf(s,_T("Solid:\t%d\r\n"), (Flags & TAG_LAYER_FLAG_SOLID) != 0); (*pStr) += s;
01518 camSprintf(s,_T("Overlay:\t%d\r\n"),(Flags & TAG_LAYER_FLAG_OVERLAY) != 0); (*pStr) += s;
01519 camSprintf(s,_T("Hidden:\t%d\r\n"), (Flags & TAG_LAYER_FLAG_HIDDEN) != 0); (*pStr) += s;
01520 }
01521 break;
01522
01523 case TAG_CURRENTATTRIBUTES:
01524 {
01525 BYTE GroupID;
01526 pRecord->ReadBYTE(&GroupID);
01527 switch(GroupID)
01528 {
01529 case ATTRIBUTEGROUP_INK:
01530 (*pStr) += _T("Attribute Group ID = INK\r\n");
01531 break;
01532 case ATTRIBUTEGROUP_TEXT:
01533 (*pStr) += _T("Attribute Group ID = TEXT\r\n");
01534 break;
01535 default:
01536 (*pStr) += _T("Attribute Group ID = UNKNOWN!\r\n");
01537 break;
01538 }
01539 }
01540 break;
01541
01542 case TAG_CURRENTATTRIBUTEBOUNDS:
01543 {
01544 DocRect attrBounds;
01545 pRecord->ReadCoord(&attrBounds.lo);
01546 pRecord->ReadCoord(&attrBounds.hi);
01547
01548 camSprintf(s,_T("lo.x \t: %d\r\n"), attrBounds.lo.x);
01549 (*pStr) += s;
01550 camSprintf(s,_T("lo.y \t: %d\r\n"), attrBounds.lo.y);
01551 (*pStr) += s;
01552 camSprintf(s,_T("hi.x \t: %d\r\n"), attrBounds.hi.x);
01553 (*pStr) += s;
01554 camSprintf(s,_T("hi.y \t: %d\r\n"), attrBounds.hi.y);
01555 (*pStr) += s;
01556
01557 }
01558 break;
01559
01560 }
01561 }
01562 #endif // _DEBUG
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578 BOOL DocumentRecordHandler::HandleSpreadAnimPropertiesRecord(CXaraFileRecord* pRec)
01579 {
01580
01581 if (IsImporting())
01582 return TRUE;
01583
01584 UINT32 Tag = pRec->GetTag();
01585 ERROR2IF(pRec == NULL,FALSE,"pCXaraFileRecord is NULL");
01586 ERROR2IF(Tag != TAG_SPREAD_ANIMPROPS,FALSE,"I do not handle this tag type!");
01587
01588
01589 Spread* pLastSpread = GetLastSpreadInserted();
01590 if (pLastSpread == NULL)
01591 {
01592 ERROR3("I don't have a 'last spread' ptr");
01593 return TRUE;
01594 }
01595
01596 BOOL ok = TRUE;
01597
01598
01599 UINT32 Loop =0;
01600 UINT32 GlobalDelay =0;
01601 UINT32 Dither =0;
01602 UINT32 WebPalette =0;
01603 UINT32 ColoursPalette =0;
01604 UINT32 NumColsInPalette =0;
01605 UINT32 FlagsWord =0;
01606
01607 if (ok)
01608 ok = pRec->ReadUINT32(&Loop);
01609 if (ok)
01610 ok = pRec->ReadUINT32(&GlobalDelay);
01611 if (ok)
01612 ok = pRec->ReadUINT32(&Dither);
01613 if (ok)
01614 ok = pRec->ReadUINT32(&WebPalette);
01615 if (ok)
01616 ok = pRec->ReadUINT32(&ColoursPalette);
01617 if (ok)
01618 ok = pRec->ReadUINT32(&NumColsInPalette);
01619 if (ok)
01620 ok = pRec->ReadUINT32(&FlagsWord);
01621
01622
01623 BOOL UseSystemColours = FALSE;
01624 BOOL BgTransparent = FALSE;
01625
01626
01627
01628
01629 UseSystemColours = ((FlagsWord & 1) ? TRUE : FALSE);
01630
01631
01632
01633
01634 BgTransparent = ((FlagsWord & 2) ? FALSE : TRUE);
01635
01636
01637 if (ok && pLastSpread)
01638 {
01639
01640 pLastSpread->SetSpreadAnimPropertiesParam(Loop, GlobalDelay,(DITHER)Dither,(WEB_PALETTE)WebPalette,
01641 (PALETTE_COLOURS)ColoursPalette, NumColsInPalette,
01642 UseSystemColours, BgTransparent);
01643 }
01644 return ok;
01645 };
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663 BOOL DocumentRecordHandler::HandleFramePropertiesRecord(CXaraFileRecord* pRec)
01664 {
01665 ERROR2IF(pRec == NULL,FALSE,"pCXaraFileRecord is NULL");
01666 UINT32 Tag = pRec->GetTag();
01667 ERROR2IF(Tag != TAG_LAYER_FRAMEPROPS,FALSE,"I do not handle this tag type");
01668
01669
01670 Layer* pLastLayer = GetLastLayerInserted();
01671 if (pLastLayer == NULL)
01672 {
01673 ERROR3("I don't have a 'last layer' ptr!");
01674 return TRUE;
01675 }
01676
01677 UINT32 Delay=0;
01678 BYTE Flags = 0;
01679 BOOL ok =TRUE;
01680
01681
01682 if (ok) ok = pRec->ReadUINT32(&Delay);
01683 if (ok) ok = pRec->ReadBYTE(&Flags);
01684
01685 if (ok) pLastLayer->SetFrameDelay(Delay);
01686
01687 pLastLayer->SetSolid((Flags & TAG_LAYER_FLAG_SOLID) != 0);
01688 pLastLayer->SetOverlay((Flags & TAG_LAYER_FLAG_OVERLAY) != 0);
01689 pLastLayer->SetHiddenFrame((Flags & TAG_LAYER_FLAG_HIDDEN) != 0);
01690
01691 pLastLayer->SetFrame(TRUE);
01692
01693 pLastLayer->SetBackground(FALSE);
01694
01695 return ok;
01696 };
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712 BOOL DocumentRecordHandler::HandleSetSentinelRecord(CXaraFileRecord* pRec)
01713 {
01714 ERROR2IF(pRec == 0, FALSE,
01715 "DocumentRecordHandler::HandleSetSentinelRecord: no record");
01716 ERROR2IF_PF(pRec->GetTag() != TAG_SETSENTINEL, FALSE,
01717 ("SetSentinel: I don't handle records with the tag (%d)", pRec->GetTag()));
01718
01719
01720 IncSetSentinelInsertedCount();
01721 if (GetSetSentinelInsertedCount() > 1) EndOfFile();
01722
01723
01724 SetInsertContextNode(GetDocument()->GetSetSentinel());
01725 InsertNextNodeAsChild();
01726
01727
01728 return TRUE;
01729 }
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745 BOOL DocumentRecordHandler::HandleSetPropertyRecord(CXaraFileRecord* pRec)
01746 {
01747 ERROR2IF(pRec == 0, FALSE,
01748 "DocumentRecordHandler::HandleSetPropertyRecord: no record");
01749 ERROR2IF_PF(pRec->GetTag() != TAG_SETPROPERTY, FALSE,
01750 ("SetProperty: I don't handle records with the tag (%d)", pRec->GetTag()));
01751
01752
01753 String_256 strName;
01754 short n;
01755 if (!pRec->ReadUnicode(&strName) ||
01756 !pRec->ReadINT16(&n))
01757 return FALSE;
01758
01759
01760
01761
01762
01763
01764
01765
01766 NodeSetProperty* pProp = new NodeSetProperty(strName);
01767 ERRORIF( pProp == 0 || !pProp->CreateDefaults(), _R(IDE_NOMORE_MEMORY), FALSE );
01768
01769 BOOL ok = TRUE;
01770
01771
01772
01773 while (n--)
01774 {
01775 short nType;
01776 if (!pRec->ReadINT16(&nType))
01777 {
01778 ok = FALSE;
01779 break;
01780 }
01781 if (nType >= SGNameProp::nPropertyCount)
01782 break;
01783 if (!pProp->GetProperty(nType)->Read(pRec))
01784 {
01785 ok = FALSE;
01786 break;
01787 }
01788 }
01789
01790
01791
01792
01793 if (!ok)
01794 {
01795 delete pProp;
01796 pProp = NULL;
01797
01798 pProp = new NodeSetProperty(strName);
01799 ERRORIF(pProp == 0 || !pProp->CreateDefaults(), _R(IDE_NOMORE_MEMORY), FALSE );
01800 }
01801
01802 pProp->m_Imported = TRUE;
01803
01804
01805 if (!InsertNode(pProp))
01806 return FALSE;
01807
01808
01809
01810
01811 if (IsImporting())
01812 {
01813 SelOperation* pSelOp = GetBaseCamelotFilter()->GetImportSelOp();
01814 if (pSelOp != 0)
01815 {
01816 HideNodeAction* pHideAct;
01817 if (AC_FAIL == HideNodeAction::Init(pSelOp, pSelOp->GetUndoActions(),
01818 pProp, TRUE, (Action**) &pHideAct) )
01819 return FALSE;
01820
01821 TemplateAttribute* pAttr = GetDocument()->GetSetSentinel()->GetNameAttr(strName);
01822
01823
01824 if (pAttr && AC_FAIL == HideNodeAction::Init(pSelOp, pSelOp->GetUndoActions(),
01825 pAttr, TRUE, (Action**) &pHideAct) )
01826 return FALSE;
01827
01828 }
01829 }
01830
01831
01832 return TRUE;
01833 }
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849 BOOL DocumentRecordHandler::HandleBarPropertyRecord(CXaraFileRecord* pRec)
01850 {
01851 PORTNOTE("dialog","DocumentRecordHandler::HandleBarPropertyRecord - do nothing")
01852 #ifndef EXCLUDE_FROM_XARALX
01853 ERROR2IF(pRec == 0, FALSE,
01854 "DocumentRecordHandler::HandleBarPropertyRecord: no record");
01855 ERROR2IF_PF(pRec->GetTag() != TAG_BARPROPERTY, FALSE,
01856 ("BarProperty: I don't handle records with the tag (%d)", pRec->GetTag()));
01857
01858
01859 NodeSetSentinel* pSentry = Document::GetCurrent()->GetSetSentinel();
01860 ERROR3IF(pSentry == 0, "DocumentRecordHandler::HandleBarPropertyRecord: no sentry");
01861 NodeBarProperty* pBarProp = pSentry->FindBarProperty();
01862 ERROR3IF(pBarProp == 0, "DocumentRecordHandler::HandleBarPropertyRecord: no properties");
01863
01864 g_NoOfBarsBeforeImport = pBarProp->HowMany();
01865
01866
01867 INT32 nBars;
01868 if (!pRec->ReadINT32(&nBars)) return FALSE;
01869 if (nBars == 0) return TRUE;
01870
01871
01872
01873 if (IsImporting())
01874 {
01875 SelOperation* pSelOp = GetBaseCamelotFilter()->GetImportSelOp();
01876 if (pSelOp != 0)
01877 {
01878
01879 NodeBarProperty* pCopy;
01880 ALLOC_WITH_FAIL(pCopy, ((NodeBarProperty*) pBarProp->SimpleCopy()), pSelOp);
01881 if (pCopy == 0) return FALSE;
01882
01883
01884 pCopy->AttachNode(pSentry, LASTCHILD);
01885 HideNodeAction* pHideAct;
01886 if (AC_FAIL == HideNodeAction::Init(pSelOp, pSelOp->GetUndoActions(),
01887 pCopy, TRUE, (Action**) &pHideAct))
01888 return FALSE;
01889
01890
01891 if (!pSelOp->DoHideNode(pBarProp, TRUE, 0, TRUE)) return FALSE;
01892 pBarProp = pCopy;
01893 }
01894 }
01895 else
01896 pBarProp->Clear();
01897
01898
01899 for (INT32 i = 0; i < nBars; i++)
01900 {
01901 BarDataType bdt;
01902 BYTE nCode;
01903 if (!pRec->ReadINT32(&bdt.Spacing) || !pRec->ReadBYTE(&nCode) || !pRec->ReadBYTE(&bdt.SameSize))
01904 return FALSE;
01905
01906 bdt.IsLive = nCode & 1;
01907 bdt.IsHorizontal = (nCode >> 1) & 1;
01908 bdt.RequiresShuffle = (nCode >> 2) & 1;
01909 bdt.ButtonsExtend = (nCode >> 3) & 1;
01910 bdt.ButtonsScale = (nCode >> 4) & 1;
01911 bdt.GroupsStretch = (nCode >> 5) & 1;
01912
01913 if (pBarProp->HowMany() < MAX_BAR_PROPERTIES) pBarProp->Add(bdt);
01914 }
01915 #endif
01916
01917 return TRUE;
01918 }
01919
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935 BOOL DocumentRecordHandler::HandleCurrentAttrsRecord(CXaraFileRecord* pCXaraFileRecord)
01936 {
01937 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
01938 ERROR2IF(!(pCXaraFileRecord->GetTag() == TAG_CURRENTATTRIBUTES || pCXaraFileRecord->GetTag() == TAG_CURRENTATTRIBUTEBOUNDS), FALSE, "I don't handle this tag type");
01939
01940 BOOL bOK = TRUE;
01941
01942 if (pCXaraFileRecord->GetTag() == TAG_CURRENTATTRIBUTES)
01943 {
01944
01945
01946
01947
01948
01949
01950
01951
01952 CCRuntimeClass* pGroupType = NULL;
01953
01954 BYTE groupid = 0;
01955 bOK = pCXaraFileRecord->ReadBYTE(&groupid);
01956
01957 if (groupid == ATTRIBUTEGROUP_INK)
01958 pGroupType = CC_RUNTIME_CLASS(NodeRenderableInk);
01959
01960 else if (groupid == ATTRIBUTEGROUP_TEXT)
01961 pGroupType = CC_RUNTIME_CLASS(BaseTextClass);
01962
01963 else
01964 {
01965 ERROR3("Unknown Attribute Group ID");
01966
01967 pGroupType = NULL;
01968 }
01969
01970 if (bOK && pGroupType!=NULL)
01971 {
01972 pBaseCamelotFilter->SetInsertMode(INSERTMODE_SETCURRENTATTRIBUTE, pGroupType);
01973 bOK = pBaseCamelotFilter->ReadFileUntil(TAG_UP);
01974 pBaseCamelotFilter->SetInsertMode(INSERTMODE_ATTACHTOTREE);
01975 }
01976 }
01977 else if (pCXaraFileRecord->GetTag() == TAG_CURRENTATTRIBUTEBOUNDS)
01978 {
01979 NodeAttribute* pLastCurrentAttr = pBaseCamelotFilter->GetLastCurrentAttrInserted();
01980 if (pLastCurrentAttr && pLastCurrentAttr->IsKindOf(CC_RUNTIME_CLASS(AttrFillGeometry)))
01981 {
01982 DocRect newBounds;
01983 if (bOK) bOK = pCXaraFileRecord->ReadCoord(&newBounds.lo);
01984 if (bOK) bOK = pCXaraFileRecord->ReadCoord(&newBounds.hi);
01985 ((AttrFillGeometry*)pLastCurrentAttr)->SetBoundingRect(newBounds);
01986 }
01987 }
01988
01989 return bOK;
01990 }
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010 BOOL DocumentRecordHandler::HandleDuplicationOffsetRecord(CXaraFileRecord* pCXaraFileRecord)
02011 {
02012 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
02013 ERROR2IF(pCXaraFileRecord->GetTag() != TAG_DUPLICATIONOFFSET,FALSE,"I don't handle this tag type");
02014
02015 BOOL bOK = TRUE;
02016 Document* pDoc = Document::GetCurrent();
02017 if (pDoc)
02018 {
02019 DocCoord newOffset;
02020 if (bOK) bOK = pCXaraFileRecord->ReadINT32(&(newOffset.x));
02021 if (bOK) bOK = pCXaraFileRecord->ReadINT32(&(newOffset.y));
02022 if (bOK) pDoc->SetDuplicationOffset(newOffset);
02023 }
02024
02025 return bOK;
02026 }
02027
02028
02029
02030