infocomp.cpp

Go to the documentation of this file.
00001 // $Id: infocomp.cpp 1282 2006-06-09 09:46:49Z alex $
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 // The document component for the document's information.
00100 
00101 // This is to allow details such as the comment for this document to be output
00102 // to the new file format and loaded back in.
00103 
00104 /*
00105 */
00106 
00107 #include "camtypes.h"
00108 
00109 #include "infocomp.h"
00110 
00111 //#include "basedoc.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 
00114 //#include "camfiltr.h" // BaseCamelotFilter - version 2 native filter - in camtypes.h [AUTOMATICALLY REMOVED]
00115 #include "cxftags.h"    // TAG_DOCUMENTCOMMENT
00116 //#include "cxfdefs.h"  //  - in camtypes.h [AUTOMATICALLY REMOVED]
00117 #include "cxfile.h"     // CXF_UNKNOWN_SIZE
00118 //#include "expcol.h"       // ExportedColours handling class
00119 //#include "cxfrec.h"       // CXaraFileRecord handler - in camtypes.h [AUTOMATICALLY REMOVED]
00120 
00121 #include "exphint.h"    // ExportHint class
00122 #include "ophist.h"
00123 
00124 DECLARE_SOURCE("$Revision: 1282 $");
00125 
00126 // Declare smart memory handling in Debug builds
00127 #define new CAM_DEBUG_NEW
00128 
00129 CC_IMPLEMENT_DYNAMIC(DocInfoComponentClass,     DocComponentClass)
00130 CC_IMPLEMENT_DYNAMIC(DocInfoComponent,      DocComponent)
00131 
00132 /********************************************************************************************
00133 ********************************************************************************************/
00134 
00135 /********************************************************************************************
00136 
00137 >   BOOL DocInfoComponentClass::Init()
00138 
00139     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00140     Created:    24/7/96
00141     Returns:    TRUE if all went well;
00142                 FALSE if not.
00143     Purpose:    Register the unit list document component with the main application.
00144     Errors:     Out of memory.
00145     SeeAlso:    DocComponent
00146 
00147 ********************************************************************************************/
00148 
00149 BOOL DocInfoComponentClass::Init()
00150 {
00151     // Instantiate a component class to register with the application.
00152     DocInfoComponentClass *pClass = new DocInfoComponentClass;
00153     if (pClass == NULL)
00154         return FALSE;
00155 
00156     // Register it
00157     GetApplication()->RegisterDocComponent(pClass);
00158 
00159     // All ok
00160     return TRUE;
00161 }
00162 
00163 
00164 /********************************************************************************************
00165 
00166 >   BOOL DocInfoComponentClass::AddComponent(BaseDocument *pDocument)
00167 
00168     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00169     Created:    24/7/96
00170     Inputs:     pDocument - the document to add the unit list to.
00171     Returns:    TRUE if the unit list was added ok;
00172                 FALSE if not.
00173     Purpose:    Add a unit list component to the specified document.
00174     Errors:     Out of memory
00175     SeeAlso:    DocInfoComponentClass
00176 
00177 ********************************************************************************************/
00178 
00179 BOOL DocInfoComponentClass::AddComponent(BaseDocument *pDocument)
00180 {
00181     // Check to see if this document already has a colour list; if so, leave it alone.
00182     if (pDocument->GetDocComponent(CC_RUNTIME_CLASS(DocInfoComponent)) != NULL)
00183         return TRUE;
00184 
00185     // Ok - create the colour list component using this list.
00186     DocInfoComponent *pComponent = new DocInfoComponent();
00187     if (pComponent == NULL)
00188     {
00189         // Out of memory...
00190         return FALSE;
00191     }
00192 
00193     // All ok - add the component to the document.
00194     pDocument->AddDocComponent(pComponent);
00195     return TRUE;
00196 }
00197 
00198 
00199 
00200 /********************************************************************************************
00201 
00202 >   DocInfoComponent::DocInfoComponent()
00203 
00204     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00205     Created:    23/07/96
00206     Purpose:    Construct a unit list component.
00207 
00208 ********************************************************************************************/
00209 
00210 DocInfoComponent::DocInfoComponent()
00211 {
00212 }
00213 
00214 /********************************************************************************************
00215 
00216 >   DocInfoComponent::~DocInfoComponent()
00217 
00218     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00219     Created:    24/7/96
00220     Purpose:    Clean up a unit list component's data structures.
00221     SeeAlso:    DocInfoComponent
00222 
00223 ********************************************************************************************/
00224 
00225 DocInfoComponent::~DocInfoComponent()
00226 {
00227 }
00228 
00229 /********************************************************************************************
00230 ********************************************************************************************/
00231 
00232 // Remove the following code on all builds but those who want it
00233 
00234 /********************************************************************************************
00235 ********************************************************************************************/
00236 
00237 /********************************************************************************************
00238 
00239 >   BOOL DocInfoComponent::StartImport(BaseCamelotFilter *pFilter)
00240 
00241     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00242     Created:    24/7/96
00243     Inputs:     pFilter - the BaseCamelotFilter filter that is being used to import a file.
00244     Returns:    TRUE if the component was able to prepare for importing;
00245                 FALSE if not (e.g. out of memory)
00246     Purpose:    Inform the unit list document component that a Native or Web import is
00247                 about to start.
00248     SeeAlso:    DocComponent
00249 
00250 ********************************************************************************************/
00251 
00252 BOOL DocInfoComponent::StartImport(BaseCamelotFilter *pFilter)
00253 {
00254 TRACEUSER( "Neville", _T("DocInfoComponent::StartImport\n"));
00255     if (pFilter == NULL)
00256     {
00257         ERROR3("DocInfoComponent::EndExport filter is null!");
00258         return TRUE;
00259     }
00260     
00261     return TRUE;
00262 }
00263 
00264 /********************************************************************************************
00265 
00266 >   BOOL DocInfoComponent::EndImport(BaseCamelotFilter *pFilter, BOOL Success)
00267 
00268     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00269     Created:    24/7/96
00270     Inputs:     pFilter - the BaseCamelotFilter filter that is being used to import a file.
00271                 Success - TRUE => The import was successful;
00272                          FALSE => The import failed - abandon any changes.
00273     Returns:    TRUE if the component was able to end the importing;
00274                 FALSE if not (e.g. out of memory)
00275     Purpose:    Inform the unit list document component that a Native or Web import has
00276                 just finished.
00277     SeeAlso:    DocComponent
00278 
00279 ********************************************************************************************/
00280 
00281 BOOL DocInfoComponent::EndImport(BaseCamelotFilter *pFilter, BOOL Success)
00282 {
00283 TRACEUSER( "Neville", _T("DocInfoComponent::EndImport\n"));
00284     if (pFilter == NULL)
00285     {
00286         ERROR3("DocInfoComponent::EndImport filter is null!");
00287         return TRUE;
00288     }
00289 
00290     return TRUE;
00291 }
00292 
00293 
00294 /********************************************************************************************
00295 
00296 >   BOOL DocInfoComponent::ImportDocumentComment(CXaraFileRecord* pCXaraFileRecord, Document * pDoc)
00297 
00298     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00299     Created:    24/7/96
00300     Inputs:     pCXaraFileRecord = ptr to record to handle
00301                 pDoc             = document to apply the information to     
00302     Returns:    TRUE if the component was able to import the data correctly;
00303                 FALSE if not (e.g. out of memory)
00304     Purpose:    Import the document comment from the current record.
00305     SeeAlso:    DocComponent
00306 
00307 ********************************************************************************************/
00308 
00309 BOOL DocInfoComponent::ImportDocumentComment(CXaraFileRecord* pCXaraFileRecord, Document * pDoc)
00310 {
00311     ERROR2IF(pCXaraFileRecord == NULL,FALSE," DocInfoComponent::ImportDocumentComment pCXaraFileRecord is NULL");
00312 
00313     String_256 Comment; 
00314     pCXaraFileRecord->ReadUnicode(&Comment);//Comment, Comment.MaxLength());
00315     if (pDoc)
00316     {
00317         pDoc->SetComment(&Comment);
00318     }
00319 
00320     return TRUE;
00321 }
00322 
00323 /********************************************************************************************
00324 
00325 >   BOOL DocInfoComponent::ImportDocumentDates(CXaraFileRecord* pCXaraFileRecord, Document * pDoc)
00326 
00327     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00328     Created:    30/7/96
00329     Inputs:     pCXaraFileRecord = ptr to record to handle
00330                 pDoc             = document to apply the information to     
00331     Returns:    TRUE if the component was able to import the data correctly;
00332                 FALSE if not (e.g. out of memory)
00333     Purpose:    Import the document information from the current record.
00334     SeeAlso:    DocComponent
00335 
00336 ********************************************************************************************/
00337 
00338 BOOL DocInfoComponent::ImportDocumentDates(CXaraFileRecord* pCXaraFileRecord, Document * pDoc)
00339 {
00340     ERROR2IF(pCXaraFileRecord == NULL,FALSE," DocInfoComponent::ImportDocumentDates pCXaraFileRecord is NULL");
00341 
00342     // Read in the times/dates from the record
00343     INT32 Creation;
00344     INT32 LastSaved;
00345 
00346     pCXaraFileRecord->ReadINT32(&Creation);
00347     pCXaraFileRecord->ReadINT32(&LastSaved);
00348     if (pDoc)
00349     {
00350         pDoc->SetCreationTime((time_t)Creation);
00351         pDoc->SetLastSaveTime((time_t)LastSaved);
00352     }
00353 
00354     return TRUE;
00355 }
00356 
00357 /********************************************************************************************
00358 
00359 >   BOOL DocInfoComponent::ImportUndoBufferSize(CXaraFileRecord* pCXaraFileRecord, Document * pDoc)
00360 
00361     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00362     Created:    30/7/96
00363     Inputs:     pCXaraFileRecord = ptr to record to handle
00364                 pDoc             = document to apply the information to     
00365     Returns:    TRUE if the component was able to import the data correctly;
00366                 FALSE if not (e.g. out of memory)
00367     Purpose:    Import the document undo buffer size from the current record.
00368     SeeAlso:    DocComponent
00369 
00370 ********************************************************************************************/
00371 
00372 BOOL DocInfoComponent::ImportUndoBufferSize(CXaraFileRecord* pCXaraFileRecord, Document * pDoc)
00373 {
00374     PORTNOTETRACE("other","DocInfoComponent::ImportUndoBufferSize - do nothing");
00375 #ifndef EXCLUDE_FROM_XARALX
00376     ERROR2IF(pCXaraFileRecord == NULL,FALSE," DocInfoComponent::ImportUndoBufferSize pCXaraFileRecord is NULL");
00377 
00378     // Read the size of the operation history from the record
00379     UINT32 UndoBufSize = 0; 
00380     pCXaraFileRecord->ReadUINT32(&UndoBufSize);
00381 
00382     if (pDoc)
00383     {
00384         // Minimum size = 1K
00385         if (UndoBufSize < 1024)
00386             UndoBufSize = 1024;
00387 
00388         // Set the size of the Operation History in
00389         // the document.
00390         pDoc->GetOpHistory().SetNewMaxSize(UndoBufSize);
00391     }
00392 #endif
00393     return TRUE;
00394 }
00395 
00396 /********************************************************************************************
00397 
00398 >   BOOL DocInfoComponent::ImportDocumentFlags(CXaraFileRecord* pCXaraFileRecord, Document * pDoc)
00399 
00400     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00401     Created:    6/8/96
00402     Inputs:     pCXaraFileRecord = ptr to record to handle
00403                 pDoc             = document to apply the information to     
00404     Returns:    TRUE if the component was able to import the data correctly;
00405                 FALSE if not (e.g. out of memory)
00406     Purpose:    Import the document flags from the current record.
00407     SeeAlso:    DocComponent
00408 
00409 ********************************************************************************************/
00410 
00411 BOOL DocInfoComponent::ImportDocumentFlags(CXaraFileRecord* pCXaraFileRecord, Document * pDoc)
00412 {
00413     ERROR2IF(pCXaraFileRecord == NULL,FALSE," DocInfoComponent::ImportDocumentFlags pCXaraFileRecord is NULL");
00414 
00415     // Find the flags we are interested in
00416     BOOL Multilayer         = FALSE;
00417     BOOL AllLayersVisible   = FALSE;
00418 
00419     // Read the flags from the record
00420     UINT32 DocFlags = 0; 
00421     pCXaraFileRecord->ReadUINT32(&DocFlags);
00422 
00423     if (DocFlags & 2)
00424         Multilayer = TRUE;
00425     if (DocFlags & 1)
00426         AllLayersVisible = TRUE;
00427 
00428     if (pDoc)
00429     {
00430         pDoc->SetMultilayer(Multilayer);
00431         pDoc->SetAllVisible(AllLayersVisible);
00432     }
00433 
00434     return TRUE;
00435 }
00436 
00437 /********************************************************************************************
00438 
00439 >   BOOL DocInfoComponent::StartExportBeforeComp(BaseCamelotFilter *pFilter)
00440 
00441     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00442     Created:    7/8/96
00443     Returns:    TRUE if the component was able to prepare for exporting;
00444                 FALSE if not (e.g. out of memory)
00445     Inputs:     pFilter - the BaseCamelotFilter filter that is being used to export a file.
00446     Purpose:    Inform the information document component that a Web or Native export is
00447                 about to start.
00448                 This version of StartExport is called before compression is started up.
00449                 This means we can save the comment record in the uncompressed section of the
00450                 file so that it is easy for the indexer to find.
00451     SeeAlso:    DocInfoComponent::StartExport;
00452 
00453 ********************************************************************************************/
00454 
00455 BOOL DocInfoComponent::StartExportBeforeComp(BaseCamelotFilter *pFilter)
00456 {
00457 #ifdef DO_EXPORT
00458     if (pFilter == NULL)
00459     {
00460         ERROR3("DocInfoComponent::StartExportBeforeComp filter is null!");
00461         return TRUE;
00462     }
00463 
00464     // The document comment should be amongst the first bits of data to be exported
00465     // and must be in the uncompressed section as the gallery searches for it. 
00466     Document * pDoc = pFilter->GetDocument();
00467     if (pDoc)
00468     {
00469         /*BOOL ok =*/ ExportDocumentComment(pFilter, pDoc);
00470     }
00471 
00472 #endif
00473     return TRUE;
00474 }
00475 
00476 
00477 /********************************************************************************************
00478 
00479 >   BOOL DocInfoComponent::StartExport(BaseCamelotFilter *pFilter)
00480 
00481     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00482     Created:    24/7/96
00483     Returns:    TRUE if the component was able to prepare for exporting;
00484                 FALSE if not (e.g. out of memory)
00485     Inputs:     pFilter - the BaseCamelotFilter filter that is being used to export a file.
00486     Purpose:    Inform the information document component that a Web or Native export is
00487                 about to start.
00488     SeeAlso:    DocComponent
00489 
00490 ********************************************************************************************/
00491 
00492 BOOL DocInfoComponent::StartExport(BaseCamelotFilter *pFilter)
00493 {
00494 #ifdef DO_EXPORT
00495     ERROR2IF(pFilter == NULL, TRUE, "DocInfoComponent::StartExport filter is null!");
00496 
00497     BOOL ok = TRUE;
00498 
00499     // The export hint gets written out here (if the document has one)
00500     Document * pDoc = pFilter->GetDocument();
00501     if (pDoc)
00502     {
00503         ExportHint* pHint = pDoc->GetExportHint();
00504         
00505         // If there is a hint then write it out...
00506         if (pHint)
00507             ok = pHint->WriteExportHintRecord(pFilter);
00508     }
00509 
00510     return(ok);
00511 #else
00512     return(TRUE);
00513 #endif
00514 }
00515 
00516 
00517 /********************************************************************************************
00518 
00519 >   BOOL DocInfoComponent::EndExport(BaseCamelotFilter *pFilter, BOOL Success)
00520 
00521     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00522     Created:    24/7/96
00523     Inputs:     pFilter - the BaseCamelotFilter filter that is being used to import a file.
00524                 Success - True if everything went swimmingly, False if just a clean up is required.
00525     Purpose:    Inform the information document component that a Web or Native export has
00526                 just finished.
00527     Returns:    TRUE if the component was able to end the importing;
00528                 FALSE if not (e.g. out of memory)
00529     SeeAlso:    DocComponent
00530 
00531 ********************************************************************************************/
00532 
00533 BOOL DocInfoComponent::EndExport(BaseCamelotFilter *pFilter, BOOL Success)
00534 {
00535 #ifdef DO_EXPORT
00536 
00537     // Export any remaining document related items.
00538     BOOL ok = TRUE;
00539     Document * pDoc = pFilter->GetDocument();
00540     if (pDoc && Success)
00541     {
00542         if (ok) ok = ExportDocumentDates(pFilter, pDoc);
00543         if (ok) ok = ExportUndoBufferSize(pFilter, pDoc);
00544         if (ok) ok = ExportDocumentFlags(pFilter, pDoc);
00545     }
00546 
00547     return ok;
00548 #else
00549     return TRUE;
00550 #endif
00551 }
00552 
00553 /********************************************************************************************
00554 
00555 >   BOOL DocInfoComponent::ExportDocumentComment(BaseCamelotFilter *pFilter, Document * pDoc)
00556 
00557     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00558     Created:    24/7/96
00559     Inputs:     pFilter - the BaseCamelotFilter filter that is being used to import a file.
00560                 pDoc    - The document we are currently exporting
00561     Purpose:    Save out a document comment record to the file.
00562     Returns:    TRUE if the comment was saved correctly
00563                 FALSE if not (e.g. out of memory)
00564     SeeAlso:    DocComponent
00565 
00566 ********************************************************************************************/
00567 
00568 BOOL DocInfoComponent::ExportDocumentComment(BaseCamelotFilter *pFilter, Document * pDoc)
00569 {
00570 #ifdef DO_EXPORT
00571     ERROR2IF(pFilter == NULL || pDoc == NULL,FALSE,"DocInfoComponent::ExportDocumentComment Null pFilter or pDoc");
00572 
00573     // Only export information in native files
00574     if (pFilter->IsWebFilter())
00575         return TRUE;
00576 
00577     // Write the data out to the file
00578     BOOL ok = TRUE;
00579     String_256 Comment = pDoc->GetComment();
00580     // Only save the record if there is any data to save
00581     if (Comment.Length() == 0)
00582         return TRUE;
00583     
00584     // Write the data out to the file
00585     UINT32 Size = 0;
00586     // If there is a string name, then add it to this size
00587     // REMEMBER: We save out unicode strings and so we need to double the length of the returned string length
00588     Size += (Comment.Length() + 1) * SIZEOF_XAR_UTF16;
00589     CXaraFileRecord Rec(TAG_DOCUMENTCOMMENT, Size);
00590     ok = Rec.Init();
00591 
00592     if (ok) ok = Rec.WriteUnicode(Comment);
00593 
00594     // Finally, write the record out to file
00595     // In the process get the record number that this was written out as
00596     INT32 RecordNumber = 0L;
00597     if (ok) RecordNumber = pFilter->Write(&Rec);    // Get the document comment
00598     
00599     // If we have had a problem at any of the stages then return that to the caller
00600     if (!ok || RecordNumber <= 0)
00601         return 0L;
00602     
00603     return ok;
00604 
00605 #endif
00606     return TRUE;
00607 }
00608 
00609 /********************************************************************************************
00610 
00611 >   BOOL DocInfoComponent::ExportDocumentDates(BaseCamelotFilter *pFilter, Document * pDoc)
00612 
00613     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00614     Created:    30/7/96
00615     Inputs:     pFilter - the BaseCamelotFilter filter that is being used to import a file.
00616                 pDoc    - The document we are currently exporting
00617     Purpose:    Save out a document information record to the file.
00618     Returns:    TRUE if the information record was saved correctly
00619                 FALSE if not (e.g. out of memory)
00620     SeeAlso:    DocComponent
00621 
00622 ********************************************************************************************/
00623 
00624 BOOL DocInfoComponent::ExportDocumentDates(BaseCamelotFilter *pFilter, Document * pDoc)
00625 {
00626 #ifdef DO_EXPORT
00627     ERROR2IF(pFilter == NULL || pDoc == NULL,FALSE,"DocInfoComponent::ExportDocumentDates Null pFilter or pDoc");
00628 
00629     // Only export information in native files
00630     if (pFilter->IsWebFilter())
00631         return TRUE;
00632 
00633     // Write the data out to the file
00634     BOOL ok = TRUE;
00635 
00636     // Set the last saved date to now
00637     if (pDoc)
00638         pDoc->SetLastSaveTime();
00639 
00640     // Find out what they are
00641     time_t Creation =  pDoc->GetCreationTime();
00642     time_t LastSaved = pDoc->GetLastSaveTime();
00643 
00644     // Write the data out to the file
00645     CXaraFileRecord Rec(TAG_DOCUMENTDATES, TAG_DOCUMENTDATES_SIZE);
00646     ok = Rec.Init();
00647 
00648     if (ok) ok = Rec.WriteINT32(Creation);
00649     if (ok) ok = Rec.WriteINT32(LastSaved);
00650 
00651     // Finally, write the record out to file
00652     // In the process get the record number that this was written out as
00653     INT32 RecordNumber = 0L;
00654     if (ok) RecordNumber = pFilter->Write(&Rec);    // Get the document comment
00655     
00656     // If we have had a problem at any of the stages then return that to the caller
00657     if (!ok || RecordNumber <= 0)
00658         return 0L;
00659     
00660     return ok;
00661 
00662 #endif
00663     return TRUE;
00664 }
00665 
00666 /********************************************************************************************
00667 
00668 >   BOOL DocInfoComponent::ExportUndoBufferSize(BaseCamelotFilter *pFilter, Document * pDoc)
00669 
00670     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00671     Created:    30/7/96
00672     Inputs:     pFilter - the BaseCamelotFilter filter that is being used to import a file.
00673                 pDoc    - The document we are currently exporting
00674     Purpose:    Save out a document undo buffer size record to the file.
00675     Returns:    TRUE if the undo buffer size record was saved correctly
00676                 FALSE if not (e.g. out of memory)
00677     SeeAlso:    DocComponent
00678 
00679 ********************************************************************************************/
00680 
00681 BOOL DocInfoComponent::ExportUndoBufferSize(BaseCamelotFilter *pFilter, Document * pDoc)
00682 {
00683 #ifdef DO_EXPORT
00684     ERROR2IF(pFilter == NULL || pDoc == NULL,FALSE,"DocInfoComponent::ExportUndoBufferSize Null pFilter or pDoc");
00685 
00686     // Only export information in native files
00687     if (pFilter->IsWebFilter())
00688         return TRUE;
00689 
00690     // Write the data out to the file
00691     BOOL ok = TRUE;
00692     
00693     // Find the size of the operation history
00694     UINT32 UndoBufSize = pDoc->GetOpHistory().GetMaxSize();
00695 
00696     CXaraFileRecord Rec(TAG_DOCUMENTUNDOSIZE, TAG_DOCUMENTUNDOSIZE_SIZE);
00697     ok = Rec.Init();
00698 
00699     if (ok) ok = Rec.WriteUINT32(UndoBufSize);
00700 
00701     // Finally, write the record out to file
00702     // In the process get the record number that this was written out as
00703     INT32 RecordNumber = 0L;
00704     if (ok) RecordNumber = pFilter->Write(&Rec);    // Get the document comment
00705     
00706     // If we have had a problem at any of the stages then return that to the caller
00707     if (!ok || RecordNumber <= 0)
00708         return 0L;
00709     
00710     return ok;
00711 
00712 #endif
00713     return TRUE;
00714 }
00715 
00716 /********************************************************************************************
00717 
00718 >   BOOL DocInfoComponent::ExportDocumentFlags(BaseCamelotFilter *pFilter, Document * pDoc)
00719 
00720     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00721     Created:    6/8/96
00722     Inputs:     pFilter - the BaseCamelotFilter filter that is being used to import a file.
00723                 pDoc    - The document we are currently exporting
00724     Purpose:    Save out a document flags record to the file.
00725     Returns:    TRUE if the document flags record was saved correctly
00726                 FALSE if not (e.g. out of memory)
00727     SeeAlso:    DocComponent
00728 
00729 ********************************************************************************************/
00730 
00731 BOOL DocInfoComponent::ExportDocumentFlags(BaseCamelotFilter *pFilter, Document * pDoc)
00732 {
00733 #ifdef DO_EXPORT
00734     ERROR2IF(pFilter == NULL || pDoc == NULL,FALSE,"DocInfoComponent::ExportDocumentFlags Null pFilter or pDoc");
00735 
00736     // Only export information in native files
00737     if (pFilter->IsWebFilter())
00738         return TRUE;
00739 
00740     // Write the data out to the file
00741     BOOL ok = TRUE;
00742     
00743     // Find the flags we are interested in
00744     BOOL Multilayer         = pDoc->IsMultilayer();
00745     BOOL AllLayersVisible   = pDoc->IsAllVisible();
00746 
00747     UINT32 DocFlags = (Multilayer ? 2 : 0) | (AllLayersVisible ? 1 : 0);
00748 
00749     CXaraFileRecord Rec(TAG_DOCUMENTFLAGS, TAG_DOCUMENTFLAGS_SIZE);
00750     ok = Rec.Init();
00751 
00752     if (ok) ok = Rec.WriteUINT32(DocFlags);
00753 
00754     // Finally, write the record out to file
00755     // In the process get the record number that this was written out as
00756     INT32 RecordNumber = 0L;
00757     if (ok) RecordNumber = pFilter->Write(&Rec);    // Get the document comment
00758     
00759     // If we have had a problem at any of the stages then return that to the caller
00760     if (!ok || RecordNumber <= 0)
00761         return 0L;
00762     
00763     return ok;
00764 
00765 #endif
00766     return TRUE;
00767 }

Generated on Sat Nov 10 03:45:33 2007 for Camelot by  doxygen 1.4.4