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
00104 #include "camtypes.h"
00105 #include "viewcomp.h"
00106
00107 #include "webparam.h"
00108
00109
00110 #include "bitfilt.h"
00111
00112
00113
00114 #include "page.h"
00115
00116 #include "cxftags.h"
00117
00118
00119
00120
00121 #include "rechview.h"
00122
00123 #include "zoomops.h"
00124
00125
00126 CC_IMPLEMENT_DYNAMIC(ViewComponentClass,DocComponentClass)
00127 CC_IMPLEMENT_DYNAMIC(ViewComponent, DocComponent)
00128 CC_IMPLEMENT_DYNAMIC(ViewRecordHandler,CamelotRecordHandler)
00129
00130
00131 #define new CAM_DEBUG_NEW
00132
00133
00134
00135 DECLARE_SOURCE("$Revision: 1688 $");
00136
00137
00138 #define DEFAULT_VIEW_QUALITY 110
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 BOOL ViewComponentClass::Init()
00157 {
00158
00159 ViewComponentClass *pClass = new ViewComponentClass;
00160 if (pClass == NULL)
00161 return FALSE;
00162
00163
00164 GetApplication()->RegisterDocComponent(pClass);
00165
00166
00167 return TRUE;
00168 }
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186 BOOL ViewComponentClass::AddComponent(BaseDocument *pDocument)
00187 {
00188
00189 if (pDocument->GetDocComponent(CC_RUNTIME_CLASS(ViewComponent)) != NULL)
00190 return TRUE;
00191
00192
00193
00194
00195 ViewComponent *pComponent = new ViewComponent;
00196
00197
00198 pDocument->AddDocComponent(pComponent);
00199
00200 return TRUE;
00201 }
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 ViewComponent::ViewComponent()
00223 {
00224 }
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238 ViewComponent::~ViewComponent()
00239 {
00240 }
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259 BOOL ViewComponent::StartImport(BaseCamelotFilter *pFilter)
00260 {
00261 return TRUE;
00262 }
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281 BOOL ViewComponent::EndImport(BaseCamelotFilter *pFilter, BOOL Success)
00282 {
00283 return TRUE;
00284 }
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301 BOOL ViewComponent::StartExport(BaseCamelotFilter *pFilter)
00302 {
00303 #ifdef DO_EXPORT
00304
00305 ERROR2IF(pFilter == NULL,FALSE,"Null filter ptr");
00306
00307 if (pFilter->IsWebFilter())
00308 return StartWebExport(pFilter);
00309 else
00310 return StartNativeExport(pFilter);
00311
00312 #else
00313 return TRUE;
00314 #endif //DO_EXPORT
00315 }
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332 BOOL ViewComponent::EndExport(BaseCamelotFilter *pFilter, BOOL Success)
00333 {
00334 #ifdef DO_EXPORT
00335
00336 ERROR2IF(pFilter == NULL,FALSE,"Null filter ptr");
00337
00338 if (!Success)
00339 return TRUE;
00340
00341 if (pFilter->IsWebFilter())
00342 return EndWebExport(pFilter);
00343 else
00344 return EndNativeExport(pFilter);
00345
00346 #else
00347 return TRUE;
00348 #endif //DO_EXPORT
00349 }
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 BOOL ViewComponent::StartWebExport(BaseCamelotFilter* pFilter)
00366 {
00367
00368 ViewComponent::ExportViewPortRecord(pFilter);
00369
00370 return TRUE;
00371 }
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387 BOOL ViewComponent::StartNativeExport(BaseCamelotFilter *pFilter)
00388 {
00389
00390 ViewComponent::ExportViewPortRecord(pFilter);
00391
00392 return TRUE;
00393 }
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409 BOOL ViewComponent::EndWebExport(BaseCamelotFilter *pFilter)
00410 {
00411 return TRUE;
00412 }
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428 BOOL ViewComponent::EndNativeExport(BaseCamelotFilter *pFilter)
00429 {
00430 #ifdef DO_EXPORT
00431
00432 BOOL ok = ExportAllViews(pFilter);
00433
00434 return ok;
00435 #else
00436 return TRUE;
00437 #endif //DO_EXPORT
00438 }
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454 BOOL ViewComponent::ExportViewPortRecord(BaseCamelotFilter* pFilter)
00455 {
00456 #ifdef DO_EXPORT
00457 ERROR2IF(pFilter == NULL,FALSE,"Null filter ptr");
00458
00459 DocRect Rect;
00460
00461
00462 Document* pDocument = pFilter->GetDocument();
00463 Spread* pSpread = pFilter->GetSpread();
00464
00465 ERROR2IF(pDocument == NULL,FALSE,"No document dude!");
00466 ERROR2IF(pSpread == NULL,FALSE,"Can't find a spread");
00467
00468
00469
00470 SelectionType SelType = DRAWING;
00471 WebPrefsDlgParam* pPrefs = pFilter->GetCachedExportOptions();
00472 if (pPrefs != NULL)
00473 SelType = pPrefs->GetViewportSel();
00474
00475
00476
00477 #ifdef WEBSTER
00478 SelType = pFilter->GetSelType();
00479 #endif // WEBSTER
00480
00481 switch (SelType)
00482 {
00483 case SELECTION:
00484 {
00485
00486 SelRange* pSelection = GetApplication()->FindSelection();
00487 if (pSelection)
00488 Rect = pSelection->GetBoundingRect();
00489
00490
00491 if (Rect.IsEmpty())
00492 Rect = BaseBitmapFilter::GetSizeOfDrawing(pSpread);
00493 }
00494 break;
00495
00496 case DRAWING:
00497 Rect = BaseBitmapFilter::GetSizeOfDrawing(pSpread);
00498 break;
00499
00500
00501
00502
00503
00504
00505 default :
00506 ERROR3("Unknown selection type in web export options");
00507 Rect = BaseBitmapFilter::GetSizeOfDrawing(pSpread);
00508 break;
00509 }
00510
00511
00512 CamelotFileRecord Rec(pFilter,TAG_VIEWPORT,TAG_VIEWPORT_SIZE);
00513 BOOL ok = Rec.Init();
00514 if (ok) ok = Rec.WriteCoord(Rect.lo);
00515 if (ok) ok = Rec.WriteCoord(Rect.hi);
00516 if (ok) ok = pFilter->Write(&Rec);
00517
00518
00519
00520 Quality ViewQuality(Quality::QualityMax);
00521 DocView* pDocView = DocView::GetSelected();
00522 if (pDocView != NULL)
00523 ViewQuality.SetQuality(pDocView->RenderQuality.GetQuality());
00524
00525
00526 if (!ExportViewQualityRecord(pFilter,&ViewQuality))
00527 return FALSE;
00528
00529 return ok;
00530 #else
00531 return TRUE;
00532 #endif //DO_EXPORT
00533 }
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556 BOOL ViewComponent::ExportViewQualityRecord(BaseCamelotFilter* pFilter, Quality* pQuality)
00557 {
00558 #ifdef DO_EXPORT
00559 ERROR2IF(pFilter == NULL,FALSE,"Null filter ptr");
00560 ERROR2IF(pQuality == NULL,FALSE,"Null quality ptr");
00561
00562 ERROR3IF(UINT32(pQuality->GetQuality()) > 255,"Can't store the view quality in a byte");
00563
00564
00565 if (pQuality->GetQuality() == DEFAULT_VIEW_QUALITY)
00566 return TRUE;
00567
00568
00569 CamelotFileRecord Rec(pFilter,TAG_VIEWQUALITY,TAG_VIEWQUALITY_SIZE);
00570 BOOL ok = Rec.Init();
00571 if (ok) ok = Rec.WriteBYTE(pQuality->GetQuality());
00572 if (ok) ok = pFilter->Write(&Rec);
00573
00574 return ok;
00575 #else
00576 return TRUE;
00577 #endif //DO_EXPORT
00578 }
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594 BOOL ViewComponent::ExportAllViews(BaseCamelotFilter* pFilter)
00595 {
00596 #ifdef DO_EXPORT
00597 ERROR2IF(pFilter == NULL,FALSE,"Null filter ptr");
00598
00599 Document* pDocument = pFilter->GetDocument();
00600 ERROR2IF(pDocument == NULL,FALSE,"ExportViewDefinition no document pointer!");
00601
00602
00603 if (pDocument->IsAClipboard() || pDocument->IsAHiddenDoc())
00604 {
00605 TRACEUSER( "JustinF", _T("Skipping document 0x%p in ViewComponent::ExportAllViews\n"),
00606 (LPVOID) pDocument);
00607 return TRUE;
00608 }
00609
00610 BOOL ok = TRUE;
00611
00612
00613 DocView* pView = pDocument->GetFirstDocView();
00614
00615 while (pView != NULL && ok)
00616 {
00617 ok = ExportViewDefinition(pFilter, pView);
00618 pView = pDocument->GetNextDocView(pView);
00619 }
00620
00621 return ok;
00622 #else
00623 return TRUE;
00624 #endif //DO_EXPORT
00625 }
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642 BOOL ViewComponent::ExportViewDefinition(BaseCamelotFilter* pFilter, DocView * pView)
00643 {
00644 #ifdef DO_EXPORT
00645 ERROR2IF(pFilter == NULL,FALSE,"ExportViewDefinition Null filter ptr");
00646 ERROR2IF(pView == NULL,FALSE,"ExportViewDefinition Null View ptr");
00647
00648
00649 Spread* pSpread = pFilter->GetSpread();
00650 ERROR2IF(pSpread == NULL,FALSE,"ExportViewDefinition no spread pointer");
00651
00652 WorkCoord ScrollOffsets = pView->GetScrollOffsets();
00653
00654
00655
00656
00657
00658 DocRect ViewRect = pView->GetDocViewRect(pSpread);
00659
00660 DocRect SpreadViewRect(ViewRect.ToSpread(pSpread, pView));
00661
00662 FIXED16 ScaleFactor = pView->GetViewScale();
00663
00664
00665 BOOL ForeBackMode = pView->GetForeBackMode();
00666 BOOL ShowGrid = pView->GetShowGridState();
00667 BOOL SnapToGrid = pView->GetSnapToGridState();
00668 BOOL SnapToObjects = pView->GetSnapToObjectsState();
00669 BOOL SnapToMagObjects = pView->GetSnapToMagObjectsState();
00670 BOOL ShowPrintBorders = pView->GetShowPrintBorders();
00671 BOOL SnapToGuides = pView->GetSnapToGuidesState();
00672 BOOL ShowGuides = pView->GetShowGuidesState();
00673 BOOL ShowScrollBars = pView->AreScrollersVisible();
00674 BOOL ShowRulers = pView->AreRulersVisible();
00675
00676 UINT32 ViewFlags = (SnapToObjects ? 8 : 0) | (SnapToGrid ? 4 : 0) | (ShowGrid ? 2 : 0) | (ForeBackMode ? 1 : 0);
00677 ViewFlags |= (( (ShowGuides ? 8 : 0) | (SnapToGuides ? 4 : 0) | (ShowPrintBorders ? 2 : 0) | (SnapToMagObjects ? 1 : 0) ) << 8);
00678 ViewFlags |= (( (ShowRulers ? 2 : 0) | (ShowScrollBars ? 1 : 0) ) << 16);
00679
00680
00681
00682
00683
00684 CamelotFileRecord Rec(pFilter,TAG_DOCUMENTVIEW, TAG_DOCUMENTVIEW_SIZE);
00685 BOOL ok = Rec.Init();
00686 if (ok) ok = Rec.WriteFIXED16(ScaleFactor);
00687 if (ok) ok = Rec.WriteCoord(SpreadViewRect.lo);
00688 if (ok) ok = Rec.WriteCoord(SpreadViewRect.hi);
00689 if (ok) ok = Rec.WriteUINT32(ViewFlags);
00690 if (ok) ok = pFilter->Write(&Rec);
00691
00692
00693
00694 Quality ViewQuality(Quality::QualityMax);
00695 if (pView != NULL)
00696 ViewQuality.SetQuality(pView->RenderQuality.GetQuality());
00697
00698
00699 if (!ExportViewQualityRecord(pFilter,&ViewQuality))
00700 return FALSE;
00701
00702 return ok;
00703 #else
00704 return TRUE;
00705 #endif //DO_EXPORT
00706 }
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725 ViewRecordHandler::ViewRecordHandler()
00726 {
00727 pLastDocView = NULL;
00728 }
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743 BOOL ViewRecordHandler::BeginImport()
00744 {
00745 pLastDocView = NULL;
00746 ViewCount = 0;
00747 return TRUE;
00748 }
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764 UINT32* ViewRecordHandler::GetTagList()
00765 {
00766 static UINT32 TagList[] = { TAG_VIEWPORT,
00767 TAG_VIEWQUALITY,
00768 TAG_DOCUMENTVIEW,
00769 CXFRH_TAG_LIST_END};
00770
00771 return (UINT32*)&TagList;
00772 }
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788 BOOL ViewRecordHandler::HandleRecord(CXaraFileRecord* pCXaraFileRecord)
00789 {
00790 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00791
00792 BOOL ok = TRUE;
00793
00794 switch (pCXaraFileRecord->GetTag())
00795 {
00796 case TAG_VIEWPORT:
00797 ok = HandleViewPortRecord(pCXaraFileRecord);
00798 break;
00799
00800 case TAG_VIEWQUALITY:
00801 ok = HandleViewQualityRecord(pCXaraFileRecord);
00802 break;
00803
00804 case TAG_DOCUMENTVIEW:
00805 ok = HandleDocumentViewRecord(pCXaraFileRecord);
00806 break;
00807
00808 default:
00809 ok = FALSE;
00810 ERROR3_PF(("I don't handle records with the tag (%d)\n",pCXaraFileRecord->GetTag()));
00811 break;
00812 }
00813
00814 return ok;
00815 }
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840 BOOL ViewRecordHandler::HandleViewPortRecord(CXaraFileRecord* pCXaraFileRecord)
00841 {
00842 TRACEUSER( "Simon", _T("D1 Picked up ViewRecord"));
00843 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00844 ERROR2IF(pCXaraFileRecord->GetTag() != TAG_VIEWPORT,FALSE,"I don't handle this tag type");
00845
00846 BOOL ok = TRUE;
00847
00848
00849 DocRect ViewPortRect;
00850 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&ViewPortRect.lo,0,0);
00851 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&ViewPortRect.hi,0,0);
00852
00853 if (ok && IsOpeningMinimalWebFormat())
00854 {
00855 Spread* pSpread = GetSpread();
00856
00857 if (pSpread != NULL)
00858 {
00859 MILLIPOINT Width = 0;
00860 MILLIPOINT Height = 0;
00861 MILLIPOINT Margin = 0;
00862 MILLIPOINT Bleed = 0;
00863 BOOL Dps = TRUE;
00864 BOOL ShowDropShadow = TRUE;
00865
00866 #ifdef RALPH
00867 MILLIPOINT Inflate = 0;
00868 #else
00869 MILLIPOINT Inflate = (max(ViewPortRect.Width(),ViewPortRect.Height())*5)/100;
00870 #endif
00871 DocRect NewPageRect = ViewPortRect;
00872 NewPageRect.Inflate(Inflate);
00873
00874 if (ok) ok = pSpread->GetPageSize(&Width, &Height, &Margin, &Bleed, &Dps, &ShowDropShadow);
00875 if (ok) ok = pSpread->SetPageSize(NewPageRect.Width(), NewPageRect.Height(), Margin, Bleed, Dps, ShowDropShadow);
00876
00877 Page *pPage = pSpread->FindFirstPageInSpread();
00878 ERROR2IF(pPage == NULL,FALSE,"Spread has no pages");
00879 DocRect PageRect = pPage->GetPageRect();
00880
00881
00882
00883 DocCoord Origin = PageRect.lo;
00884 Origin.x += (Inflate - ViewPortRect.lo.x);
00885 Origin.y += (Inflate - ViewPortRect.lo.y);
00886 SetCoordOrigin(Origin);
00887
00888 ViewPortRect.Translate(-ViewPortRect.lo.x,-ViewPortRect.lo.y);
00889 }
00890 }
00891
00892 if (ok && IsImportingAtPosition())
00893 {
00894 pCXaraFileRecord->ResetReadPos();
00895
00896 DocRect ViewPortRect;
00897 if (ok) ok = pCXaraFileRecord->ReadCoord(&ViewPortRect.lo);
00898 if (ok) ok = pCXaraFileRecord->ReadCoord(&ViewPortRect.hi);
00899
00900 DocCoord Centre = ViewPortRect.lo;
00901 Centre.x += ViewPortRect.Width()/2;
00902 Centre.y += ViewPortRect.Height()/2;
00903
00904 DocCoord Origin = GetCoordOrigin();
00905
00906 Origin.x -= Centre.x - Origin.x;
00907 Origin.y -= Centre.y - Origin.y;
00908
00909 SetCoordOrigin(Origin);
00910 }
00911
00912
00913 #ifdef RALPH
00914
00915
00916
00917
00918 if (ok)
00919 {
00920 TRACEUSER( "Simon", _T("D1 Before FakeZoomToRect"));
00921
00922 DocRect RalphViewPortRect = ViewPortRect;
00923
00924 Document * pDoc = Document::GetCurrent();
00925 RalphDocument * pRalphDoc = NULL;
00926 RalphView * pRalphView = NULL;
00927 if(pDoc)
00928 {
00929 if(pDoc->IsARalphDoc())
00930 {
00931 pRalphDoc=pDoc->GetRalphDoc();
00932 if(pRalphDoc)
00933 {
00934
00935
00936 pRalphDoc->SetViewportRect(RalphViewPortRect);
00937 }
00938 }
00939 }
00940
00941
00942
00943 }
00944
00945 #endif
00946 TRACEUSER( "Simon", _T("D1 End Handle View Record"));
00947
00948 return ok;
00949 }
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968 BOOL ViewRecordHandler::HandleViewQualityRecord(CXaraFileRecord* pCXaraFileRecord)
00969 {
00970 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00971 ERROR2IF(pCXaraFileRecord->GetTag() != TAG_VIEWQUALITY,FALSE,"I don't handle this tag type");
00972
00973 BYTE QualVal;
00974 BOOL ok = pCXaraFileRecord->ReadBYTE(&QualVal);
00975
00976 if (pLastDocView != NULL)
00977 pLastDocView->RenderQuality.SetQuality(QualVal);
00978
00979 return ok;
00980 }
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997 BOOL ViewRecordHandler::HandleDocumentViewRecord(CXaraFileRecord* pCXaraFileRecord)
00998 {
00999 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"HandleDocumentViewRecord pCXaraFileRecord is NULL");
01000 ERROR2IF(pCXaraFileRecord->GetTag() != TAG_DOCUMENTVIEW,FALSE,"HandleDocumentViewRecord I don't handle this tag type");
01001
01002
01003
01004 if (IsImporting())
01005 return TRUE;
01006
01007
01008 FIXED16 ScaleFactor;
01009 DocCoord BottomLeft;
01010 DocCoord TopRight;
01011 UINT32 ViewFlags = 0L;
01012
01013 BOOL ok = pCXaraFileRecord->ReadFIXED16(&ScaleFactor);
01014 if (ok) ok = pCXaraFileRecord->ReadCoord(&BottomLeft);
01015 if (ok) ok = pCXaraFileRecord->ReadCoord(&TopRight);
01016 if (ok) ok = pCXaraFileRecord->ReadUINT32(&ViewFlags);
01017
01018 Document* pDocument = GetDocument();
01019 ERROR2IF(pDocument == NULL,FALSE,"HandleDocumentViewRecord no document pointer!");
01020
01021 Spread* pSpread = GetSpread();
01022 ERROR2IF(pSpread == NULL,FALSE,"HandleDocumentViewRecord no spread pointer");
01023
01024
01025 DocView* pView = pDocument->GetFirstDocView();
01026
01027 ViewCount ++;
01028
01029 BOOL Restore = pDocument->GetRestoreViewOnImport();
01030
01031
01032
01033 if (ok && pView && ViewCount == 1 && Restore)
01034 {
01035
01036
01037 ERROR3IF(pView != DocView::GetCurrent(),"ViewRecordHandler::HandleDocumentViewRecord DocView::Current is screwed");
01038 pView->SetCurrent();
01039
01040
01041
01042 pView->SetViewScale(ScaleFactor);
01043
01044
01045
01046 DocCoord SpreadScrollOffsets(BottomLeft.x, TopRight.y);
01047
01048 DocCoord DocScrollOffsets(SpreadScrollOffsets.ToDoc(pSpread, pView));
01049
01050 WorkCoord ScrollOffsets(DocScrollOffsets.ToWork(pSpread, pView));
01051
01052
01053 if (ScrollOffsets.x < 0) ScrollOffsets.x = 0;
01054 if (ScrollOffsets.y > 0) ScrollOffsets.y = 0;
01055
01056 pView->SetScrollOffsets(ScrollOffsets, TRUE);
01057
01058
01059 BOOL ForeBackMode = FALSE;
01060 BOOL ShowGrid = FALSE;
01061 BOOL SnapToGrid = FALSE;
01062 BOOL SnapToObjects = FALSE;
01063 BOOL SnapToMagObjects = FALSE;
01064 BOOL ShowPrintBorders = FALSE;
01065 BOOL SnapToGuides = FALSE;
01066 BOOL ShowGuides = FALSE;
01067 BOOL ShowScrollBars = FALSE;
01068 BOOL ShowRulers = FALSE;
01069
01070
01071
01072
01073 #ifndef WEBSTER
01074 if (ViewFlags & 8)
01075 SnapToObjects = TRUE;
01076 #endif // WEBSTER
01077
01078 if (ViewFlags & 4)
01079 SnapToGrid = TRUE;
01080 if (ViewFlags & 2)
01081 ShowGrid = TRUE;
01082 if (ViewFlags & 1)
01083 ForeBackMode = TRUE;
01084
01085 #ifndef WEBSTER
01086 if (ViewFlags & (8 << 8))
01087 ShowGuides = TRUE;
01088 if (ViewFlags & (4 << 8))
01089 SnapToGuides = TRUE;
01090 if (ViewFlags & (2 << 8))
01091 ShowPrintBorders = TRUE;
01092 if (ViewFlags & (1 << 8))
01093 SnapToMagObjects = TRUE;
01094
01095 if (ViewFlags & (2 << 16))
01096 ShowRulers = TRUE;
01097 #endif // WEBSTER
01098
01099 #ifndef WEBSTER
01100
01101 if (ViewFlags & (1 << 16))
01102 ShowScrollBars = TRUE;
01103 #else
01104
01105 ShowScrollBars = TRUE;
01106 #endif
01107 pView->SetForeBackMode(ForeBackMode);
01108 pView->SetShowGridState(ShowGrid);
01109 pView->SetSnapToGridState(SnapToGrid);
01110 pView->SetSnapToObjectsState(SnapToObjects);
01111 pView->SetSnapToMagObjectsState(SnapToMagObjects);
01112 pView->SetShowPrintBorders(ShowPrintBorders);
01113 pView->SetSnapToGuidesState(SnapToGuides);
01114 pView->SetShowGuidesState(ShowGuides);
01115 pView->ShowViewScrollers(ShowScrollBars);
01116 pView->ShowViewRulers(ShowRulers);
01117
01118
01119 pView->RenderQuality.SetQuality(DEFAULT_VIEW_QUALITY);
01120
01121
01122 #ifndef RALPH
01123 OpZoomComboDescriptor::Update();
01124 #endif
01125
01126 pLastDocView = pView;
01127 }
01128
01129 return ok;
01130 }
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147 #ifdef XAR_TREE_DIALOG
01148 void ViewRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord,StringBase* pStr)
01149 {
01150 if (pStr == NULL || pRecord == NULL)
01151 return;
01152
01153 TCHAR s[256];
01154
01155
01156 CamelotRecordHandler::GetRecordDescriptionText(pRecord,pStr);
01157
01158 switch (pRecord->GetTag())
01159 {
01160 case TAG_VIEWPORT:
01161 {
01162 DocCoord lo,hi;
01163
01164 pRecord->ReadCoord(&lo);
01165 pRecord->ReadCoord(&hi);
01166
01167 camSprintf(s,_T("lo.x = %d\r\n"),lo.x); (*pStr) += s;
01168 camSprintf(s,_T("lo.y = %d\r\n"),lo.y); (*pStr) += s;
01169 camSprintf(s,_T("hi.x = %d\r\n"),hi.x); (*pStr) += s;
01170 camSprintf(s,_T("hi.y = %d\r\n"),hi.y); (*pStr) += s;
01171 }
01172 break;
01173
01174 case TAG_VIEWQUALITY:
01175 {
01176 BYTE Quality = 0;
01177 pRecord->ReadBYTE(&Quality);
01178
01179 camSprintf(s,_T("Quality = %d\r\n"),Quality);
01180 (*pStr) += s;
01181 }
01182 break;
01183
01184 case TAG_DOCUMENTVIEW:
01185 {
01186 FIXED16 ScaleFactor;
01187 DocCoord BottomLeft;
01188 DocCoord TopRight;
01189 UINT32 ViewFlags = 0L;
01190 pRecord->ReadFIXED16(&ScaleFactor);
01191 pRecord->ReadCoord(&BottomLeft);
01192 pRecord->ReadCoord(&TopRight);
01193 pRecord->ReadUINT32(&ViewFlags);
01194
01195 (*pStr) += _T("Document view\r\n\r\n");
01196 camSprintf(s,_T("Scale factor \t= %f\r\n"),ScaleFactor.MakeDouble());
01197 (*pStr) += s;
01198 camSprintf(s,_T("Bottom left \t= %d,%d\r\n"),BottomLeft.x,BottomLeft.y);
01199 (*pStr) += s;
01200 camSprintf(s,_T("Top right \t\t= %d,%d\r\n"),TopRight.x,TopRight.y);
01201 (*pStr) += s;
01202
01203 if (ViewFlags & 8)
01204 (*pStr) += _T("SnapToObjects");
01205 if (ViewFlags & 4)
01206 (*pStr) += _T("SnapToGrid ");
01207 if (ViewFlags & 2)
01208 (*pStr) += _T("ShowGrid ");
01209 if (ViewFlags & 1)
01210 (*pStr) += _T("ForeBackMode ");
01211 (*pStr) += _T("\r\n");
01212
01213 if (ViewFlags & (8 << 8))
01214 (*pStr) += _T("ShowGuides ");
01215 if (ViewFlags & (4 << 8))
01216 (*pStr) += _T("SnapToGuides ");
01217 if (ViewFlags & (2 << 8))
01218 (*pStr) += _T("ShowPrintBorders ");
01219 if (ViewFlags & (1 << 8))
01220 (*pStr) += _T("SnapToMagObjects ");
01221 (*pStr) += _T("\r\n");
01222
01223 if (ViewFlags & (2 << 16))
01224 (*pStr) += _T("ShowRulers ");
01225 if (ViewFlags & (1 << 16))
01226 (*pStr) += _T("ShowScrollBars ");
01227 (*pStr) += _T("\r\n");
01228
01229
01230
01231 }
01232 break;
01233 }
01234 }
01235 #endif