rechbmpp.cpp

Go to the documentation of this file.
00001 // $Id: rechbmpp.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 // Handles the reading of bitmap properties records
00100 
00101 #include "camtypes.h"
00102 
00103 #include "rechbmpp.h"   // BitmapPropertiesRecordHandler for importing bitmaps from v2 native/web files
00104 #include "bmpcomp.h"    // Document bitmap component, handles import of bitmaps
00105 //#include "camfiltr.h" // BaseCamelotFilter - version 2 native filter - in camtypes.h [AUTOMATICALLY REMOVED]
00106 #include "cxfile.h"     // CXaraFile file handling class for version 2 native filter 
00107 #include "cxftags.h"    // TAG_DEFINEBITMAP_**** 
00108 //#include "sgliboil.h" // Wav stuff
00109 //#include "cxfrec.h"       // The main record handling class - in camtypes.h [AUTOMATICALLY REMOVED]
00110 
00111 //#include "bitmap.h"       // KernelBitmap - in camtypes.h [AUTOMATICALLY REMOVED]
00112 //#include "xmlutils.h" // CXMLUtils (and msxml2.h)
00113 //#include "xpehost.h"  // XPEHost
00114 
00115 DECLARE_SOURCE("$Revision: 1688 $");
00116 
00117 // Declare smart memory handling in Debug builds
00118 #define new CAM_DEBUG_NEW
00119 
00120 // An implement to match the Declare in the .h file.
00121 CC_IMPLEMENT_DYNAMIC(BitmapPropertiesRecordHandler,CamelotRecordHandler);
00122 
00123 
00124 /********************************************************************************************
00125 
00126 >   virtual UINT32* BitmapPropertiesRecordHandler::GetTagList()
00127 
00128     Author:     Andy_Hills (Xara Group Ltd) <camelotdev@xara.com>
00129     Created:    30/10/00
00130     Inputs:     -
00131     Returns:    Ptr to a list of tag values, terminated by CXFRH_TAG_LIST_END
00132     Purpose:    Provides the record handler system with a list of records handled by this
00133                 handler
00134     SeeAlso:    -
00135 
00136 ********************************************************************************************/
00137 
00138 UINT32* BitmapPropertiesRecordHandler::GetTagList()
00139 {
00140     static UINT32 TagList[] = {TAG_BITMAP_PROPERTIES, TAG_XPE_BITMAP_PROPERTIES, CXFRH_TAG_LIST_END};
00141 
00142     return (UINT32*)&TagList;
00143 }
00144 
00145 
00146 /********************************************************************************************
00147 
00148 >   virtual BOOL BitmapPropertiesRecordHandler::IsStreamed(UINT32 Tag)
00149 
00150     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00151     Created:    29/01/2004
00152     Inputs:     The tag of the record
00153     Returns:    TRUE if this is a streamed record
00154                 FALSE otherwise
00155     Purpose:    Function to find out if the record is streamed or not.
00156     Errors:     -
00157     SeeAlso:    -
00158 
00159 ********************************************************************************************/
00160 
00161 BOOL BitmapPropertiesRecordHandler::IsStreamed(UINT32 Tag)
00162 {
00163     // We handle both types so check what we need to do by the tag we have been given
00164     BOOL Streamed = FALSE;
00165     switch (Tag)
00166     {
00167         case TAG_BITMAP_PROPERTIES:
00168             Streamed = FALSE;
00169             break;
00170         case TAG_XPE_BITMAP_PROPERTIES:
00171             Streamed = FALSE;
00172             break;
00173         default:
00174             Streamed = FALSE;
00175             ERROR3_PF(("BitmapPropertiesRecordHandler::IsStreamed I don't handle records with the tag (%d)\n", Tag));
00176             break;
00177     }
00178 
00179     return Streamed;
00180 }
00181 
00182 /********************************************************************************************
00183 
00184 >   virtual BOOL BitmapPropertiesRecordHandler::HandleRecord(CXaraFileRecord* pCXaraFileRecord)
00185 
00186     Author:     Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
00187     Created:    30/10/00
00188     Inputs:     pCXaraFileRecord = ptr to record to handle
00189     Returns:    TRUE if handled successfuly
00190                 FALSE otherwise
00191     Purpose:    Handles the given record.
00192     SeeAlso:    -
00193 
00194 ********************************************************************************************/
00195 
00196 BOOL BitmapPropertiesRecordHandler::HandleRecord( CXaraFileRecord* pCXaraFileRecord )
00197 {
00198     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"BitmapPropertiesRecordHandler::HandleRecord pCXaraFileRecord is NULL");
00199 
00200     BOOL ok = TRUE;
00201     UINT32 tag = pCXaraFileRecord->GetTag();
00202 
00203     // read in the record ---------------------------------------------------------
00204 
00205     // read bitmap reference
00206     INT32 BmpRef = 0;
00207     INT32 MasterRef = 0;
00208     String_256 BitmapName;
00209     ok = pCXaraFileRecord->ReadINT32(&BmpRef);
00210 
00211     // read flags
00212     BYTE Flags;
00213     if (ok) ok = pCXaraFileRecord->ReadBYTE(&Flags);
00214 
00215     // read other stuff
00216     BYTE Temp;
00217     for( INT32 i=0; i<7; i++ )
00218     {
00219         if (ok) ok = pCXaraFileRecord->ReadBYTE(&Temp);
00220     }
00221 
00222     // Read XPE master ref and XML edits list
00223 //  _bstr_t bstrXML;
00224     StringVar strXML;
00225     if (ok && tag==TAG_XPE_BITMAP_PROPERTIES)
00226     {
00227         ok = pCXaraFileRecord->ReadINT32(&MasterRef);
00228 
00229         if (ok) ok = pCXaraFileRecord->ReadUnicode(&BitmapName);
00230 
00231 //      if (ok) ok = pCXaraFileRecord->ReadBSTR(&bstrXML, pCXaraFileRecord->GetSize());
00232         if (ok) ok = pCXaraFileRecord->ReadUTF16STR(&strXML, pCXaraFileRecord->GetSize());
00233     }
00234 
00235     // process the record ---------------------------------------------------------
00236 
00237     // look up the bitmap from BmpRef
00238 
00239     if (BmpRef == 0)
00240     {
00241         // no such bitmap
00242         ok = FALSE;
00243     }
00244     else
00245     {
00246         KernelBitmap *pBitmap = NULL;
00247         pBitmap = GetReadBitmapReference(BmpRef);
00248 
00249         if (pBitmap == NULL)
00250         {
00251             // no such bitmap
00252             ok = FALSE;
00253         }
00254         else
00255         {
00256             // process the flags
00257             BOOL bSmoothWhenScaledUp = Flags & 0x01;
00258             pBitmap->SetInterpolation(bSmoothWhenScaledUp);
00259 
00260             // Setup XPE info
00261             // (If we don't have it, it's not important - this bitmap will just lose
00262             //  it's XPE edit info and will become its own master)
00263 PORTNOTETRACE("other","BitmapPropertiesRecordHandler::HandleRecord - remove XML code");
00264 #ifndef EXCLUDE_FROM_XARALX
00265             if (tag==TAG_XPE_BITMAP_PROPERTIES && MasterRef!=0)
00266             {
00267                 KernelBitmap* pMasterBitmap = NULL;
00268                 pMasterBitmap = GetReadBitmapReference(MasterRef);
00269 
00270                 VARIANT_BOOL varResult;
00271                 IXMLDOMDocumentPtr pxmlDoc = CXMLUtils::NewDocument();
00272                 HRESULT hr = pxmlDoc->loadXML(bstrXML, &varResult);
00273                 if (pMasterBitmap && SUCCEEDED(hr) && VARIANT_TRUE == varResult)
00274                 {
00275                     // We now know that this master bitmap will be used
00276                     // so add it to the document's bitmap list...
00277                     // Get the bitmap list from the current document
00278                     Document* pDoc = Document::GetCurrent();
00279                     BitmapList* pBmpList = pDoc->GetBitmapList();
00280                     if (!pBmpList->FindDuplicateBitmap(pMasterBitmap->ActualBitmap))
00281                         // and then attach the bitmap
00282                         pMasterBitmap->Attach(pBmpList);
00283 
00284                     // See whether we need to regenerate this bitmap from the
00285                     // Master and the Edits...
00286                     if (pBitmap->IsDefaultBitmap())
00287                     {
00288                         XPEEditOp::DoProcessBitmap(pBitmap, pMasterBitmap, pxmlDoc);
00289                     }
00290 
00291                     pBitmap->SetXPEInfo(pMasterBitmap, pxmlDoc);    // Can only do this after DoProcessBitmap...
00292                 }
00293 
00294                 pBitmap->SetName(BitmapName);                       // ...and this, because process may create new OILBitmap
00295             }
00296 #endif
00297         }
00298     }
00299 
00300     return ok;
00301 }
00302 
00303 
00304 
00305 
00306 /********************************************************************************************
00307 
00308 >   virtual BOOL BitmapPropertiesRecordHandler::HandleStreamedRecord(CXaraFile * pCXFile, UINT32 Tag,UINT32 Size,UINT32 RecordNumber)
00309 
00310     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00311     Created:    29/01/2004
00312     Inputs:     pCXFile = access to the CXaraFile class
00313                 Tag  = the tag value
00314                 Size = size of record
00315                 RecordNumber = the record number in the file
00316     Returns:    TRUE if handled ok
00317                 FALSE otherwise
00318     Purpose:    This is the bitmap streamed record handler. It handles the loading of bitmap
00319                 definitions.
00320     Errors:     -
00321     SeeAlso:    -
00322 
00323 ********************************************************************************************/
00324 
00325 BOOL BitmapPropertiesRecordHandler::HandleStreamedRecord(CXaraFile * pCXFile, UINT32 Tag,UINT32 Size,UINT32 RecordNumber)
00326 {
00327     ERROR2IF(pCXFile == NULL,FALSE,"BitmapRecordHandler::HandleStreamedRecord pCXFile is NULL");
00328 
00329     if (Tag!=TAG_XPE_BITMAP_PROPERTIES)
00330     {
00331         ERROR3_PF(("BitmapPropertiesRecordHandler::HandleStreamedRecord I don't handle records with the tag (%d)\n", Tag));
00332         return FALSE;
00333     }
00334     ERROR3_PF(("Unimplemented!", Tag));
00335 
00336     return TRUE;
00337 }
00338 
00339 
00340 
00341 
00342 /********************************************************************************************
00343 
00344 >   virtual void BitmapPropertiesRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord,StringBase* pStr)
00345 
00346     Author:     Andy_Hills (Xara Group Ltd) <camelotdev@xara.com>
00347     Created:    30/10/00
00348     Inputs:     pRecord = ptr to a record
00349                 pStr = ptr to string to update
00350     Returns:    -
00351     Purpose:    This provides descriptions for the define bitmap properties records.
00352     Errors:     -
00353     SeeAlso:    -
00354 
00355 ********************************************************************************************/
00356 
00357 #ifdef XAR_TREE_DIALOG
00358 void BitmapPropertiesRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord, StringBase* pStr)
00359 {
00360     if (pStr == NULL || pRecord == NULL)
00361         return;
00362 
00363     // Call base class first
00364     // This outputs the tag and size
00365     CamelotRecordHandler::GetRecordDescriptionText(pRecord,pStr);
00366     return;
00367 }
00368 #endif // XAR_TREE_DIALOG
00369 
00370 //#endif // NEW_NATIVE_FILTER
00371 

Generated on Sat Nov 10 03:46:41 2007 for Camelot by  doxygen 1.4.4