ViewRecordHandler Class Reference

Handles the reading of all view records in the v2 file format. More...

#include <rechview.h>

Inheritance diagram for ViewRecordHandler:

CamelotRecordHandler CXaraFileRecordHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 ViewRecordHandler ()
 Default constructor Inits the view record handler.
 ~ViewRecordHandler ()
virtual UINT32GetTagList ()
 Provides the record handler system with a list of records handled by this handler.
virtual BOOL HandleRecord (CXaraFileRecord *pCXaraFileRecord)
 Handles the given record.
virtual BOOL BeginImport ()
 Informs the handler that importing is about to begin.

Private Member Functions

 CC_DECLARE_DYNAMIC (ViewRecordHandler)
BOOL HandleViewPortRecord (CXaraFileRecord *pCXaraFileRecord)
 Handles the view port record.
BOOL HandleViewQualityRecord (CXaraFileRecord *pCXaraFileRecord)
 Handles the view quality record. It reads a view quality value to apply to the last view port & doc view read in.
BOOL HandleDocumentViewRecord (CXaraFileRecord *pCXaraFileRecord)
 Handles the document view definition record. All this does is set the current view quality (applied to subsequent view port & doc view records).

Private Attributes

DocViewpLastDocView
INT32 ViewCount

Detailed Description

Handles the reading of all view records in the v2 file format.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/7/96
See also:
-

Definition at line 119 of file rechview.h.


Constructor & Destructor Documentation

ViewRecordHandler::ViewRecordHandler  ) 
 

Default constructor Inits the view record handler.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/7/96
See also:
-

Definition at line 725 of file viewcomp.cpp.

00726 {
00727     pLastDocView = NULL;
00728 }

ViewRecordHandler::~ViewRecordHandler  )  [inline]
 

Definition at line 126 of file rechview.h.

00126 {}


Member Function Documentation

BOOL ViewRecordHandler::BeginImport  )  [virtual]
 

Informs the handler that importing is about to begin.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/7/96
Parameters:
- [INPUTS]
Returns:
TRUE if ok, FALSE otherwise
See also:
-

Reimplemented from CXaraFileRecordHandler.

Definition at line 743 of file viewcomp.cpp.

00744 {
00745     pLastDocView = NULL;
00746     ViewCount = 0;
00747     return TRUE;
00748 }

ViewRecordHandler::CC_DECLARE_DYNAMIC ViewRecordHandler   )  [private]
 

UINT32 * ViewRecordHandler::GetTagList  )  [virtual]
 

Provides the record handler system with a list of records handled by this handler.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/7/96
Parameters:
- [INPUTS]
Returns:
Ptr to a list of tag values, terminated by CXFRH_TAG_LIST_END
See also:
-

Implements CXaraFileRecordHandler.

Definition at line 764 of file viewcomp.cpp.

00765 {
00766     static UINT32 TagList[] = { TAG_VIEWPORT,
00767                                 TAG_VIEWQUALITY,
00768                                 TAG_DOCUMENTVIEW,
00769                                 CXFRH_TAG_LIST_END};
00770 
00771     return (UINT32*)&TagList;
00772 }

BOOL ViewRecordHandler::HandleDocumentViewRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles the document view definition record. All this does is set the current view quality (applied to subsequent view port & doc view records).

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/8/96
Parameters:
pCXaraFileRecord = ptr to record to handle [INPUTS]
Returns:
TRUE if handled successfuly FALSE otherwise
See also:
-

Definition at line 997 of file viewcomp.cpp.

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     // If we are just importing data from this document into an existing one,
01003     // then don't import this data.
01004     if (IsImporting())
01005         return TRUE;
01006     
01007     // Read in all the information
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     // Find the first DocView (if there is one)
01025     DocView* pView = pDocument->GetFirstDocView();
01026     // Increment our view count
01027     ViewCount ++;
01028     // Check that we should restore the view on import
01029     BOOL Restore = pDocument->GetRestoreViewOnImport();
01030             
01031     // If everything was read in ok and we have a view and this is the first view record
01032     // then apply the data
01033     if (ok && pView && ViewCount == 1 && Restore)
01034     {
01035         // Set the view for the following code.  The zoom ops work on the current
01036         // view, as do the coordinate conversion functions.
01037         ERROR3IF(pView != DocView::GetCurrent(),"ViewRecordHandler::HandleDocumentViewRecord DocView::Current is screwed");
01038         pView->SetCurrent();
01039 
01040         // Set the view scale and positioning
01041         // First set the correct view scale factor as otherwise some of the conversions may go wrong
01042         pView->SetViewScale(ScaleFactor);
01043         // The top left corner of this rectangle is the same as the value returned by GetScrollOffsets().
01044         // First take our saved version which is in SpreadCoords.
01045         // I know, I know just imagine DocCoord = SpreadCoord at this point.
01046         DocCoord SpreadScrollOffsets(BottomLeft.x, TopRight.y);
01047         // Convert this to DocCoords
01048         DocCoord DocScrollOffsets(SpreadScrollOffsets.ToDoc(pSpread, pView));
01049         // And now to WorkCoords, which the scroll offsets require
01050         WorkCoord ScrollOffsets(DocScrollOffsets.ToWork(pSpread, pView));
01051 
01052         // Check the scroll offsets bounds as we can't have scroll offsets anywhere.
01053         if (ScrollOffsets.x < 0) ScrollOffsets.x = 0;
01054         if (ScrollOffsets.y > 0) ScrollOffsets.y = 0;
01055 
01056         pView->SetScrollOffsets(ScrollOffsets, TRUE);
01057 
01058         // Find all the State flags
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 // WEBSTER - markn 14/1/97
01071 // Various view flags should be off in Webster, so I've commented out
01072 // the 'if' statements that can set them to TRUE
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         // In Camelot use the saved value
01101         if (ViewFlags & (1 << 16))
01102             ShowScrollBars = TRUE;
01103 #else
01104         // In Webster the user has no control over the scroll bars and so it must be on
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         // The set the default view quality for the view
01119         pView->RenderQuality.SetQuality(DEFAULT_VIEW_QUALITY);
01120         
01121         // Update the button bar
01122 #ifndef RALPH
01123         OpZoomComboDescriptor::Update();
01124 #endif
01125         
01126         pLastDocView = pView;
01127     }
01128 
01129     return ok;
01130 }

BOOL ViewRecordHandler::HandleRecord CXaraFileRecord pCXaraFileRecord  )  [virtual]
 

Handles the given record.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/7/96
Parameters:
pCXaraFileRecord = ptr to record to handle [INPUTS]
Returns:
TRUE if handled successfuly FALSE otherwise
See also:
-

Implements CXaraFileRecordHandler.

Definition at line 788 of file viewcomp.cpp.

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 }

BOOL ViewRecordHandler::HandleViewPortRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles the view port record.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/8/96
Parameters:
pCXaraFileRecord = ptr to record to handle [INPUTS]
Returns:
TRUE if handled successfuly FALSE otherwise
Current, all this does is set the coord origin to be the centre of the view port rect, but only if we are importing.

I'm 28 today. Late twenties are depressing because you realise that you're not going to change any more in any great way. You have grown up. When you're younger, there's that unspoken hope that things will get better, but now you know you are what you are, so you'd better make the most of it. I kind of expected things to get more fun, but you can't expect it.

See also:
-

Definition at line 840 of file viewcomp.cpp.

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 //#ifndef RALPH
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             // align the bottom-left of the viewport with the bottom-left of the page, but
00882             // add 'Inflate' to give it a comfortable distance away from the page's edge
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 //#else
00913 #ifdef RALPH
00914 /*  DocRect Rect;
00915     ok = pCXaraFileRecord->ReadCoord(&Rect.lo);
00916     if (ok) ok = pCXaraFileRecord->ReadCoord(&Rect.hi);
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                     // Store the viewport away until its safe to zoom.
00936                     pRalphDoc->SetViewportRect(RalphViewPortRect); 
00937                 }
00938             }
00939         }
00940         // We used to do this !!, which was bad cos we had multiple threads piddling with RenderRegion lists.
00941         //  OpZoomDescriptor::FakeZoomToRect(&Rect);
00942 //      DocView::GetCurrent()->SetScrollOffsets(WorkCoord(0,0), FALSE);
00943     }
00944 
00945 #endif
00946     TRACEUSER( "Simon", _T("D1 End Handle View Record")); 
00947 
00948     return ok;
00949 }

BOOL ViewRecordHandler::HandleViewQualityRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles the view quality record. It reads a view quality value to apply to the last view port & doc view read in.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/7/96
Parameters:
pCXaraFileRecord = ptr to record to handle [INPUTS]
Returns:
TRUE if handled successfuly FALSE otherwise
implementation not complete ****
See also:
-

Definition at line 968 of file viewcomp.cpp.

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 }


Member Data Documentation

DocView* ViewRecordHandler::pLastDocView [private]
 

Definition at line 143 of file rechview.h.

INT32 ViewRecordHandler::ViewCount [private]
 

Definition at line 144 of file rechview.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:03:00 2007 for Camelot by  doxygen 1.4.4