ViewComponent Class Reference

Provide a component that handles the saving of view information to the v2 file format. More...

#include <viewcomp.h>

Inheritance diagram for ViewComponent:

DocComponent ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 ViewComponent ()
 Construct a view component. Does nothing at the mo.
 ~ViewComponent ()
 The destructor - does nowt at the mo.
virtual BOOL StartImport (BaseCamelotFilter *pFilter)
 Gives the component a chance to prepare for import. Does nothing at the mo.
virtual BOOL EndImport (BaseCamelotFilter *pFilter, BOOL Success)
 Gives the component a chance to clean up after import. Does nothing at the mo.
virtual BOOL StartExport (BaseCamelotFilter *pFilter)
 Gives the component a chance to export info before the main document tree Does nothing at the mo.
virtual BOOL EndExport (BaseCamelotFilter *pFilter, BOOL Success)
 Gives the component a chance to export info after the main document tree.
BOOL ImportViewDefinition (BaseCamelotFilter *pFilter)

Static Public Member Functions

static BOOL ExportViewPortRecord (BaseCamelotFilter *pFilter)
 Exports the view port record to the filter.

Private Member Functions

BOOL StartWebExport (BaseCamelotFilter *pFilter)
 Exports web stuff before the doc tree has been exported.
BOOL StartNativeExport (BaseCamelotFilter *pFilter)
 Exports native stuff before the doc tree has been exported.
BOOL EndWebExport (BaseCamelotFilter *pFilter)
 Exports web stuff after the doc tree has been exported.
BOOL EndNativeExport (BaseCamelotFilter *pFilter)
 Exports native stuff after the doc tree has been exported.
BOOL ExportAllViews (BaseCamelotFilter *pFilter)
 Exports all the current views as individual definition records to the filter.
BOOL ExportViewDefinition (BaseCamelotFilter *pFilter, DocView *pView)
 Exports a single view definition record to the filter.

Static Private Member Functions

static BOOL ExportViewQualityRecord (BaseCamelotFilter *pFilter, Quality *pQuality)
 Exports the view quality record to the filter.

Detailed Description

Provide a component that handles the saving of view information to the v2 file format.

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

Definition at line 142 of file viewcomp.h.


Constructor & Destructor Documentation

ViewComponent::ViewComponent  ) 
 

Construct a view component. Does nothing at the mo.

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

Definition at line 222 of file viewcomp.cpp.

00223 {
00224 }

ViewComponent::~ViewComponent  ) 
 

The destructor - does nowt at the mo.

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

Definition at line 238 of file viewcomp.cpp.

00239 {
00240 }


Member Function Documentation

BOOL ViewComponent::EndExport BaseCamelotFilter pFilter,
BOOL  Success
[virtual]
 

Gives the component a chance to export info after the main document tree.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/7/96 Input: pFilter = ptr to the filter to export to Success = TRUE if the import was successful, FALSE otherwise
Parameters:
- [OUTPUTS]
Returns:
TRUE if ok, FALSE otherwise
See also:
ViewComponent

Reimplemented from DocComponent.

Definition at line 332 of file viewcomp.cpp.

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 }

BOOL ViewComponent::EndImport BaseCamelotFilter pFilter,
BOOL  Success
[virtual]
 

Gives the component a chance to clean up after import. Does nothing at the mo.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/7/96 Input: pFilter = ptr to the filter to import from Success = TRUE if the import was successful, FALSE otherwise
Parameters:
- [OUTPUTS]
Returns:
TRUE if ok, FALSE otherwise
See also:
ViewComponent

Reimplemented from DocComponent.

Definition at line 281 of file viewcomp.cpp.

00282 {
00283     return TRUE;
00284 }

BOOL ViewComponent::EndNativeExport BaseCamelotFilter pFilter  )  [private]
 

Exports native stuff after the doc tree has been exported.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/7/96 Input: pFilter = ptr to the filter to export to
Parameters:
- [OUTPUTS]
Returns:
TRUE if ok, FALSE otherwise
See also:
ViewComponent

Definition at line 428 of file viewcomp.cpp.

00429 {
00430 #ifdef DO_EXPORT
00431     // save out DocView records for all available views
00432     BOOL ok = ExportAllViews(pFilter);
00433 
00434     return ok;
00435 #else
00436     return TRUE;
00437 #endif //DO_EXPORT
00438 }

BOOL ViewComponent::EndWebExport BaseCamelotFilter pFilter  )  [private]
 

Exports web stuff after the doc tree has been exported.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/7/96 Input: pFilter = ptr to the filter to export to
Parameters:
- [OUTPUTS]
Returns:
TRUE if ok, FALSE otherwise
See also:
ViewComponent

Definition at line 409 of file viewcomp.cpp.

00410 {
00411     return TRUE;
00412 }

BOOL ViewComponent::ExportAllViews BaseCamelotFilter pFilter  )  [private]
 

Exports all the current views as individual definition records to the filter.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/8/96 Input: pFilter = ptr to the filter to export to
Parameters:
- [OUTPUTS]
Returns:
TRUE if ok, FALSE otherwise
See also:
ViewComponent

Definition at line 594 of file viewcomp.cpp.

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     // Don't try saving views if it's the clipboard document or hidden (no views).
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     // Find the first DocView (if there is one)
00613     DocView* pView = pDocument->GetFirstDocView();
00614     //if (pView != NULL && ok)
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 }

BOOL ViewComponent::ExportViewDefinition BaseCamelotFilter pFilter,
DocView pView
[private]
 

Exports a single view definition record to the filter.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/8/96 Input: pFilter = ptr to the filter to export to pView = view to be exported
Parameters:
- [OUTPUTS]
Returns:
TRUE if ok, FALSE otherwise
See also:
ViewComponent

Definition at line 642 of file viewcomp.cpp.

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     // Find the spread ptrs
00649     Spread* pSpread = pFilter->GetSpread();
00650     ERROR2IF(pSpread == NULL,FALSE,"ExportViewDefinition no spread pointer");
00651 
00652     WorkCoord ScrollOffsets = pView->GetScrollOffsets();
00653     //INT32 XOffset         = ScrollOffsets.x.MakeLong();
00654     //INT32 YOffset         = ScrollOffsets.y.MakeLong();
00655     //WorkRect WorkViewRect = pView->GetViewRect();
00656     
00657     // Get the current viewing rectangle in document coordinates
00658     DocRect ViewRect        = pView->GetDocViewRect(pSpread);
00659     // Convert this to spread coords. I know, I know it says DocCoords but image it is SpreadCoords
00660     DocRect  SpreadViewRect(ViewRect.ToSpread(pSpread, pView)); // ie from    DocCoords to SpreadCoords
00661 
00662     FIXED16 ScaleFactor     = pView->GetViewScale();
00663 
00664     // Find all the State flags
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     //BOOL Multilayer           = IsMultilayer();
00681     //BOOL AllLayersVisible = IsAllVisible();
00682 
00683     // Write out the rectangle in the guise of a View Port record.
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); // bottom left of work area
00688     if (ok) ok = Rec.WriteCoord(SpreadViewRect.hi); // top right of work area
00689     if (ok) ok = Rec.WriteUINT32(ViewFlags);
00690     if (ok) ok = pFilter->Write(&Rec);
00691 
00692     // Find out the quality value of the DocView
00693     // Default to the maximum quality, if there isn't a doc view
00694     Quality ViewQuality(Quality::QualityMax);
00695     if (pView != NULL)
00696         ViewQuality.SetQuality(pView->RenderQuality.GetQuality());
00697 
00698     // The Doc View record must always have a View Quality record after it
00699     if (!ExportViewQualityRecord(pFilter,&ViewQuality))
00700         return FALSE;
00701 
00702     return ok;
00703 #else
00704     return TRUE;
00705 #endif //DO_EXPORT
00706 }

BOOL ViewComponent::ExportViewPortRecord BaseCamelotFilter pFilter  )  [static]
 

Exports the view port record to the filter.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/7/96 Input: pFilter = ptr to the filter to export to
Parameters:
- [OUTPUTS]
Returns:
TRUE if ok, FALSE otherwise
See also:
ViewComponent

Definition at line 454 of file viewcomp.cpp.

00455 {
00456 #ifdef DO_EXPORT
00457     ERROR2IF(pFilter == NULL,FALSE,"Null filter ptr");
00458 
00459     DocRect Rect;
00460 
00461     // Find the document & spread ptrs
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     // Find the selection type selected by the user.
00469     // Default to DRAWING if there is no cached export options object
00470     SelectionType SelType = DRAWING;
00471     WebPrefsDlgParam* pPrefs = pFilter->GetCachedExportOptions();
00472     if (pPrefs != NULL)
00473         SelType = pPrefs->GetViewportSel();
00474 
00475     // WEBSTER - markn 15/2/97
00476     // Bug fix for selection type save option
00477 #ifdef WEBSTER
00478     SelType = pFilter->GetSelType();
00479 #endif // WEBSTER
00480 
00481     switch (SelType)
00482     {
00483         case SELECTION:
00484         {
00485             // Get the bounding rectangle for the selection
00486             SelRange* pSelection = GetApplication()->FindSelection();
00487             if (pSelection)
00488                 Rect = pSelection->GetBoundingRect();
00489 
00490             // If the sel rect is empty, default to the drawing bounds
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             //Graham 26/7/97: Took out spread option
00501         /*case SPREAD:
00502             Rect = BaseBitmapFilter::GetSizeOfSpread(pSpread);
00503             break;*/
00504 
00505         default :
00506             ERROR3("Unknown selection type in web export options");
00507             Rect = BaseBitmapFilter::GetSizeOfDrawing(pSpread);
00508             break;
00509     }
00510 
00511     // Write out the rectangle in the guise of a View Port record.
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     // Find out the quality value of the selected DocView
00519     // Default to the maximum quality, if there isn't a selected doc view
00520     Quality ViewQuality(Quality::QualityMax);
00521     DocView* pDocView = DocView::GetSelected();
00522     if (pDocView != NULL)
00523         ViewQuality.SetQuality(pDocView->RenderQuality.GetQuality());
00524 
00525     // The View Port record must always have a View Quality record after it
00526     if (!ExportViewQualityRecord(pFilter,&ViewQuality))
00527         return FALSE;
00528 
00529     return ok;
00530 #else
00531     return TRUE;
00532 #endif //DO_EXPORT
00533 }

BOOL ViewComponent::ExportViewQualityRecord BaseCamelotFilter pFilter,
Quality pQuality
[static, private]
 

Exports the view quality record to the filter.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/7/96 Input: pFilter = ptr to the filter to export to pQuality = ptr to Quality object that contains the quality value to write out
Parameters:
- [OUTPUTS]
Returns:
TRUE if ok, FALSE otherwise
NOTE!!!!! If the view quality is equal to DEFAULT_VIEW_QUALITY, then no record is saved out. The file format specifies that if no view qual record is encountered, assume the default setting, so we don't need to save a record out in the case, saving space.

See also:
ViewComponent

Definition at line 556 of file viewcomp.cpp.

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     // Don't save out a record if it defines the default value (saves space)
00565     if (pQuality->GetQuality() == DEFAULT_VIEW_QUALITY)
00566         return TRUE;
00567 
00568     // Write out the rectangle in the guise of a View Port record.
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 }

BOOL ViewComponent::ImportViewDefinition BaseCamelotFilter pFilter  ) 
 

BOOL ViewComponent::StartExport BaseCamelotFilter pFilter  )  [virtual]
 

Gives the component a chance to export info before the main document tree Does nothing at the mo.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/7/96 Input: pFilter = ptr to the filter to export to
Parameters:
- [OUTPUTS]
Returns:
TRUE if ok, FALSE otherwise
See also:
ViewComponent

Reimplemented from DocComponent.

Definition at line 301 of file viewcomp.cpp.

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 }

BOOL ViewComponent::StartImport BaseCamelotFilter pFilter  )  [virtual]
 

Gives the component a chance to prepare for import. Does nothing at the mo.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/7/96
Parameters:
pFilter = ptr to the filter to import from [INPUTS]
- [OUTPUTS]
Returns:
TRUE if ok, FALSE otherwise
See also:
ViewComponent

Reimplemented from DocComponent.

Definition at line 259 of file viewcomp.cpp.

00260 {
00261     return TRUE;
00262 }

BOOL ViewComponent::StartNativeExport BaseCamelotFilter pFilter  )  [private]
 

Exports native stuff before the doc tree has been exported.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/7/96 Input: pFilter = ptr to the filter to export to
Parameters:
- [OUTPUTS]
Returns:
TRUE if ok, FALSE otherwise
See also:
ViewComponent

Definition at line 387 of file viewcomp.cpp.

00388 {
00389     // In native format we need a view port record
00390     ViewComponent::ExportViewPortRecord(pFilter);
00391 
00392     return TRUE;
00393 }

BOOL ViewComponent::StartWebExport BaseCamelotFilter pFilter  )  [private]
 

Exports web stuff before the doc tree has been exported.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/7/96 Input: pFilter = ptr to the filter to export to
Parameters:
- [OUTPUTS]
Returns:
TRUE if ok, FALSE otherwise
See also:
ViewComponent

Definition at line 365 of file viewcomp.cpp.

00366 {
00367     // In web format we need a view port record
00368     ViewComponent::ExportViewPortRecord(pFilter);
00369 
00370     return TRUE;
00371 }


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