viewcomp.cpp

Go to the documentation of this file.
00001 // $Id: viewcomp.cpp 1688 2006-08-10 12:05:20Z gerry $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 //
00099 // Implementation of the view document component classes
00100 
00101 /*
00102 */
00103 
00104 #include "camtypes.h"
00105 #include "viewcomp.h"
00106 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 #include "webparam.h"
00108 //#include "xarprefs.h"
00109 //#include "webprefs.h"
00110 #include "bitfilt.h"        // For standard bounds calc routines.
00111 //#include "quality.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 #include "page.h"
00115 
00116 #include "cxftags.h"
00117 //#include "cxfdefs.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00118 //#include "cxfrec.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00119 
00120 //#include "camfiltr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00121 #include "rechview.h"
00122 
00123 #include "zoomops.h"
00124 //#include "ralphvw.h"
00125 
00126 CC_IMPLEMENT_DYNAMIC(ViewComponentClass,DocComponentClass)
00127 CC_IMPLEMENT_DYNAMIC(ViewComponent,     DocComponent)
00128 CC_IMPLEMENT_DYNAMIC(ViewRecordHandler,CamelotRecordHandler)
00129 
00130 // Declare smart memory handling in Debug builds
00131 #define new CAM_DEBUG_NEW
00132 
00133 // This is not compulsory, but you may as well put it in so that the correct version
00134 // of your file can be registered in the .exe
00135 DECLARE_SOURCE("$Revision: 1688 $");
00136 
00137 // This is the default view quality for the view records in a v2 file
00138 #define DEFAULT_VIEW_QUALITY 110
00139 
00140 //---------------------------------------------------------------------------------------
00141 
00142 /********************************************************************************************
00143 
00144 >   BOOL ViewComponentClass::Init()
00145 
00146     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00147     Created:    24/7/96
00148     Returns:    TRUE if all went well;
00149                 FALSE if not.
00150     Purpose:    Register the view document component with the main application.
00151     Errors:     Out of memory.
00152     SeeAlso:    DocComponent
00153 
00154 ********************************************************************************************/
00155 
00156 BOOL ViewComponentClass::Init()
00157 {
00158     // Instantiate a component class to register with the application.
00159     ViewComponentClass *pClass = new ViewComponentClass;
00160     if (pClass == NULL)
00161         return FALSE;
00162 
00163     // Register it
00164     GetApplication()->RegisterDocComponent(pClass);
00165 
00166     // All ok
00167     return TRUE;
00168 }
00169 
00170 
00171 /********************************************************************************************
00172 
00173 >   BOOL ViewComponentClass::AddComponent(BaseDocument *pDocument)
00174 
00175     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00176     Created:    24/7/96
00177     Inputs:     pDocument - the document to add the component to.
00178     Returns:    TRUE if the print was added ok;
00179                 FALSE if not.
00180     Purpose:    Add a view component to the specified document.
00181     Errors:     Out of memory
00182     SeeAlso:    ViewComponentClass
00183 
00184 ********************************************************************************************/
00185 
00186 BOOL ViewComponentClass::AddComponent(BaseDocument *pDocument)
00187 {
00188     // Check to see if this document already has a view component; if so, leave it alone.
00189     if (pDocument->GetDocComponent(CC_RUNTIME_CLASS(ViewComponent)) != NULL)
00190         return TRUE;
00191 
00192     // No view component - try to create a new one for this document.
00193 
00194     // create the view component
00195     ViewComponent *pComponent = new ViewComponent;
00196 
00197     // All ok - add the component to the document.
00198     pDocument->AddDocComponent(pComponent);
00199 
00200     return TRUE;
00201 }
00202 
00203 
00204 //---------------------------------------------------------------------------------------
00205 //---------------------------------------------------------------------------------------
00206 //---------------------------------------------------------------------------------------
00207 
00208 //----------------------------
00209 
00210 /********************************************************************************************
00211 
00212 >   ViewComponent::ViewComponent()
00213 
00214     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00215     Created:    24/7/96
00216     Purpose:    Construct a view component.
00217                 Does nothing at the mo
00218     SeeAlso:    ViewComponent
00219 
00220 ********************************************************************************************/
00221 
00222 ViewComponent::ViewComponent()
00223 {
00224 }
00225 
00226 /********************************************************************************************
00227 
00228 >   ViewComponent::~ViewComponent()
00229 
00230     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00231     Created:    24/7/96
00232     Purpose:    The destructor - does nowt at the mo
00233     Errors:     -
00234     SeeAlso:    ViewComponent
00235 
00236 ********************************************************************************************/
00237 
00238 ViewComponent::~ViewComponent()
00239 {
00240 }
00241 
00242 
00243 
00244 /********************************************************************************************
00245 
00246 >   virtual ViewComponent::StartImport(BaseCamelotFilter *pFilter)
00247 
00248     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00249     Created:    24/7/96
00250     Inputs:     pFilter = ptr to the filter to import from
00251     Outputs:    -
00252     Returns:    TRUE if ok, FALSE otherwise
00253     Purpose:    Gives the component a chance to prepare for import.
00254                 Does nothing at the mo
00255     SeeAlso:    ViewComponent
00256 
00257 ********************************************************************************************/
00258 
00259 BOOL ViewComponent::StartImport(BaseCamelotFilter *pFilter)
00260 {
00261     return TRUE;
00262 }
00263 
00264 
00265 /********************************************************************************************
00266 
00267 >   virtual BOOL ViewComponent::EndImport(BaseCamelotFilter *pFilter, BOOL Success)
00268 
00269     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00270     Created:    24/7/96
00271     Input:      pFilter = ptr to the filter to import from
00272                 Success = TRUE if the import was successful, FALSE otherwise
00273     Outputs:    -
00274     Returns:    TRUE if ok, FALSE otherwise
00275     Purpose:    Gives the component a chance to clean up after import.
00276                 Does nothing at the mo
00277     SeeAlso:    ViewComponent
00278 
00279 ********************************************************************************************/
00280 
00281 BOOL ViewComponent::EndImport(BaseCamelotFilter *pFilter, BOOL Success)
00282 {
00283     return TRUE;
00284 }
00285 
00286 /********************************************************************************************
00287 
00288 >   virtual BOOL ViewComponent::StartExport(BaseCamelotFilter *pFilter)
00289 
00290     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00291     Created:    24/7/96
00292     Input:      pFilter = ptr to the filter to export to
00293     Outputs:    -
00294     Returns:    TRUE if ok, FALSE otherwise
00295     Purpose:    Gives the component a chance to export info before the main document tree
00296                 Does nothing at the mo
00297     SeeAlso:    ViewComponent
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 >   virtual BOOL ViewComponent::EndExport(BaseCamelotFilter *pFilter, BOOL Success)
00320 
00321     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00322     Created:    24/7/96
00323     Input:      pFilter = ptr to the filter to export to
00324                 Success = TRUE if the import was successful, FALSE otherwise
00325     Outputs:    -
00326     Returns:    TRUE if ok, FALSE otherwise
00327     Purpose:    Gives the component a chance to export info after the main document tree
00328     SeeAlso:    ViewComponent
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 >   BOOL ViewComponent::StartWebExport(BaseCamelotFilter *pFilter)
00354 
00355     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00356     Created:    24/7/96
00357     Input:      pFilter = ptr to the filter to export to
00358     Outputs:    -
00359     Returns:    TRUE if ok, FALSE otherwise
00360     Purpose:    Exports web stuff before the doc tree has been exported
00361     SeeAlso:    ViewComponent
00362 
00363 ********************************************************************************************/
00364 
00365 BOOL ViewComponent::StartWebExport(BaseCamelotFilter* pFilter)
00366 {
00367     // In web format we need a view port record
00368     ViewComponent::ExportViewPortRecord(pFilter);
00369 
00370     return TRUE;
00371 }
00372 
00373 /********************************************************************************************
00374 
00375 >   BOOL ViewComponent::StartNativeExport(BaseCamelotFilter *pFilter)
00376 
00377     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00378     Created:    24/7/96
00379     Input:      pFilter = ptr to the filter to export to
00380     Outputs:    -
00381     Returns:    TRUE if ok, FALSE otherwise
00382     Purpose:    Exports native stuff before the doc tree has been exported
00383     SeeAlso:    ViewComponent
00384 
00385 ********************************************************************************************/
00386 
00387 BOOL ViewComponent::StartNativeExport(BaseCamelotFilter *pFilter)
00388 {
00389     // In native format we need a view port record
00390     ViewComponent::ExportViewPortRecord(pFilter);
00391 
00392     return TRUE;
00393 }
00394 
00395 /********************************************************************************************
00396 
00397 >   BOOL ViewComponent::EndWebExport(BaseCamelotFilter *pFilter)
00398 
00399     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00400     Created:    24/7/96
00401     Input:      pFilter = ptr to the filter to export to
00402     Outputs:    -
00403     Returns:    TRUE if ok, FALSE otherwise
00404     Purpose:    Exports web stuff after the doc tree has been exported
00405     SeeAlso:    ViewComponent
00406 
00407 ********************************************************************************************/
00408 
00409 BOOL ViewComponent::EndWebExport(BaseCamelotFilter *pFilter)
00410 {
00411     return TRUE;
00412 }
00413 
00414 /********************************************************************************************
00415 
00416 >   BOOL ViewComponent::EndNativeExport(BaseCamelotFilter *pFilter)
00417 
00418     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00419     Created:    24/7/96
00420     Input:      pFilter = ptr to the filter to export to
00421     Outputs:    -
00422     Returns:    TRUE if ok, FALSE otherwise
00423     Purpose:    Exports native stuff after the doc tree has been exported
00424     SeeAlso:    ViewComponent
00425 
00426 ********************************************************************************************/
00427 
00428 BOOL ViewComponent::EndNativeExport(BaseCamelotFilter *pFilter)
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 }
00439 
00440 /********************************************************************************************
00441 
00442 >   static BOOL ViewComponent::ExportViewPortRecord(BaseCamelotFilter *pFilter)
00443 
00444     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00445     Created:    24/7/96
00446     Input:      pFilter = ptr to the filter to export to
00447     Outputs:    -
00448     Returns:    TRUE if ok, FALSE otherwise
00449     Purpose:    Exports the view port record to the filter
00450     SeeAlso:    ViewComponent
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     // 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 }
00534 
00535 /********************************************************************************************
00536 
00537 >   static BOOL ViewComponent::ExportViewQualityRecord(BaseCamelotFilter *pFilter,Quality* pQuality)
00538 
00539     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00540     Created:    26/7/96
00541     Input:      pFilter  = ptr to the filter to export to
00542                 pQuality = ptr to Quality object that contains the quality value to write out
00543     Outputs:    -
00544     Returns:    TRUE if ok, FALSE otherwise
00545     Purpose:    Exports the view quality record to the filter
00546 
00547                 NOTE!!!!!
00548                 If the view quality is equal to DEFAULT_VIEW_QUALITY, then no record is saved out.
00549                 The file format specifies that if no view qual record is encountered, assume the default setting,
00550                 so we don't need to save a record out in the case, saving space.
00551 
00552     SeeAlso:    ViewComponent
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     // 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 }
00579 
00580 /********************************************************************************************
00581 
00582 >   BOOL ViewComponent::ExportAllViews(BaseCamelotFilter* pFilter)
00583 
00584     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00585     Created:    6/8/96
00586     Input:      pFilter = ptr to the filter to export to
00587     Outputs:    -
00588     Returns:    TRUE if ok, FALSE otherwise
00589     Purpose:    Exports all the current views as individual definition records to the filter
00590     SeeAlso:    ViewComponent
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     // 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 }
00626 
00627 /********************************************************************************************
00628 
00629 >   BOOL ViewComponent::ExportViewDefinition(BaseCamelotFilter* pFilter, DocView * pView)
00630 
00631     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00632     Created:    6/8/96
00633     Input:      pFilter = ptr to the filter to export to
00634                 pView   = view to be exported
00635     Outputs:    -
00636     Returns:    TRUE if ok, FALSE otherwise
00637     Purpose:    Exports a single view definition record to the filter
00638     SeeAlso:    ViewComponent
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     // 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 }
00707 
00708 //---------------------------------------------------------------------------------------
00709 //---------------------------------------------------------------------------------------
00710 //---------------------------------------------------------------------------------------
00711 
00712 
00713 /********************************************************************************************
00714 
00715 >   ViewRecordHandler::ViewRecordHandler()
00716 
00717     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00718     Created:    26/7/96
00719     Purpose:    Default constructor
00720                 Inits the view record handler
00721     SeeAlso:    -
00722 
00723 ********************************************************************************************/
00724 
00725 ViewRecordHandler::ViewRecordHandler()
00726 {
00727     pLastDocView = NULL;
00728 }
00729 
00730 /********************************************************************************************
00731 
00732 >   BOOL ViewRecordHandler::BeginImport()
00733 
00734     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00735     Created:    26/7/96
00736     Inputs:     -
00737     Returns:    TRUE if ok, FALSE otherwise
00738     Purpose:    Informs the handler that importing is about to begin
00739     SeeAlso:    -
00740 
00741 ********************************************************************************************/
00742 
00743 BOOL ViewRecordHandler::BeginImport()
00744 {
00745     pLastDocView = NULL;
00746     ViewCount = 0;
00747     return TRUE;
00748 }
00749 
00750 /********************************************************************************************
00751 
00752 >   virtual UINT32* ViewRecordHandler::GetTagList()
00753 
00754     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00755     Created:    24/7/96
00756     Inputs:     -
00757     Returns:    Ptr to a list of tag values, terminated by CXFRH_TAG_LIST_END
00758     Purpose:    Provides the record handler system with a list of records handled by this
00759                 handler
00760     SeeAlso:    -
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 >   virtual BOOL ViewRecordHandler::HandleRecord(CXaraFileRecord* pCXaraFileRecord)
00777 
00778     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00779     Created:    24/7/96
00780     Inputs:     pCXaraFileRecord = ptr to record to handle
00781     Returns:    TRUE if handled successfuly
00782                 FALSE otherwise
00783     Purpose:    Handles the given record.
00784     SeeAlso:    -
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 >   BOOL ViewRecordHandler::HandleViewPortRecord(CXaraFileRecord* pCXaraFileRecord)
00820 
00821     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00822     Created:    6/8/96
00823     Inputs:     pCXaraFileRecord = ptr to record to handle
00824     Returns:    TRUE if handled successfuly
00825                 FALSE otherwise
00826     Purpose:    Handles the view port record.
00827 
00828                 Current, all this does is set the coord origin to be the centre of the view port rect,
00829                 but only if we are importing.
00830 
00831                 I'm 28 today.  Late twenties are depressing because you realise that you're not going
00832                 to change any more in any great way.  You have grown up.  When you're younger, there's that
00833                 unspoken hope that things will get better, but now you know you are what you are, so you'd
00834                 better make the most of it.  I kind of expected things to get more fun, but you can't expect it.
00835 
00836     SeeAlso:    -
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 //#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 }
00950 
00951 /********************************************************************************************
00952 
00953 >   BOOL ViewRecordHandler::HandleViewQualityRecord(CXaraFileRecord* pCXaraFileRecord)
00954 
00955     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00956     Created:    26/7/96
00957     Inputs:     pCXaraFileRecord = ptr to record to handle
00958     Returns:    TRUE if handled successfuly
00959                 FALSE otherwise
00960     Purpose:    Handles the view quality record.
00961                 It reads a view quality value to apply to the last view port & doc view read in
00962 
00963                 **** implementation not complete ****
00964     SeeAlso:    -
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 >   BOOL ViewRecordHandler::HandleDocumentViewRecord(CXaraFileRecord* pCXaraFileRecord)
00985 
00986     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00987     Created:    6/8/96
00988     Inputs:     pCXaraFileRecord = ptr to record to handle
00989     Returns:    TRUE if handled successfuly
00990                 FALSE otherwise
00991     Purpose:    Handles the document view definition record.
00992                 All this does is set the current view quality (applied to subsequent view port & doc view records)
00993     SeeAlso:    -
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     // 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 }
01131 
01132 /********************************************************************************************
01133 
01134 >   virtual void ViewRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord,StringBase* pStr)
01135 
01136     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01137     Created:    24/7/96
01138     Inputs:     pRecord = ptr to a record
01139                 pStr = ptr to string to update
01140     Returns:    -
01141     Purpose:    This provides descriptions for the viewrecords.
01142     Errors:     -
01143     SeeAlso:    -
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     //   Call base class first
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             // Show all the State flags
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             //camSprintf(s,_T("Flags \t= %d\r\n"),ViewFlags);
01230             //(*pStr) += s;
01231         }
01232         break;
01233     }
01234 }
01235 #endif

Generated on Sat Nov 10 03:47:21 2007 for Camelot by  doxygen 1.4.4