embedded_font.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 
00019 #if !defined EMBEDDED_FONT_HEADER
00020 #define EMBEDDED_FONT_HEADER
00021 
00025 
00026 #include "whiptk/whipcore.h"
00027 #include "whiptk/file.h"
00028 #include "whiptk/object.h"
00029 
00035 
00036 
00047 class WHIPTK_API WT_Embedded_Font : public WT_Object
00048 {
00049     friend class WT_W2D_Class_Factory;
00050     friend class WT_Opcode;
00051 
00052 public:
00054     enum WT_Request_Format
00055     {
00057         Raw                           = 0x00000001,
00059         Subset                        = 0x00000002,
00061         Compressed                    = 0x00000004,
00063         Fail_If_Variations_Simulated  = 0x00000008,
00065         Eudc                          = 0x00000010,
00067         Validation_Tests              = 0x00000020,
00069         Web_Object                    = 0x00000040,
00071         Encrypt_Data                  = 0x00000080
00072     };
00073 
00075     enum WT_Character_Set
00076     {
00078         Unicode                       = 0x00000001,
00080         Symbol                        = 0x00000002,
00082         Glyphidx                      = 0x00000003
00083     };
00084 
00086     enum WT_Privilege
00087     {
00089         PreviewPrint                  = 0x00000001,
00091         Editable                      = 0x00000002,
00093         Installable                   = 0x00000003,
00095         Non_Embedding                 = 0x00000004
00096     };
00097 
00098 private:
00099 
00100     WT_Unsigned_Integer32   m_request;
00101     WT_Byte                 m_privilege;
00102     WT_Byte                 m_character_set_type;
00103     WT_Integer32            m_font_type_face_name_length;
00104     WT_Byte *               m_font_type_face_name_string;
00105     WT_Integer32            m_font_logfont_name_length;
00106     WT_Byte *               m_font_logfont_name_string;
00107     WT_Integer32            m_data_size;
00108     WT_Byte *               m_data;
00109 
00110 protected:
00111     WT_Boolean              m_local_data_copy;
00112 private:
00113 
00114     enum
00115     {
00116         Starting,
00117         Getting_Request_Type,
00118         Getting_Privilege_Type,
00119         Getting_Character_Set_Type,
00120         Getting_Font_Type_Face_Name_Length,
00121         Getting_Font_Type_Face_Name_String,
00122         Getting_Font_LogFont_Name_Length,
00123         Getting_Font_LogFont_Name_String,
00124         Getting_Pre_Data_Size_Whitespace,
00125         Getting_Pre_Data_Size_Open_Paren,
00126         Getting_Data_Size,
00127         Getting_Data,
00128         Getting_Close
00129     }   m_stage;
00130 
00131     WT_Embedded_Font (WT_Embedded_Font const &)
00132     : WT_Object()
00133     , m_request(Raw)
00134     , m_privilege(0)
00135     , m_character_set_type(0)
00136     , m_font_type_face_name_length(0)
00137     , m_font_type_face_name_string(WD_Null)
00138     , m_font_logfont_name_length(0)
00139     , m_font_logfont_name_string(WD_Null)
00140     , m_data_size(0)
00141     , m_data(WD_Null)
00142     , m_local_data_copy(WD_False)
00143     , m_stage(Starting)
00144     {
00145         WD_Complain ("cannot copy WT_Embedded_Font");
00146     } // prohibited
00147 
00148     WT_Embedded_Font operator= (WT_Embedded_Font const &)
00149     {
00150         WD_Complain ("cannot assign WT_Embedded_Font");
00151         return *this;
00152     } // prohibited
00153 
00154 public:
00155 
00157 
00158     WT_Embedded_Font ()
00159     : m_request(Raw)
00160     , m_privilege(0)
00161     , m_character_set_type(0)
00162     , m_font_type_face_name_length(0)
00163     , m_font_type_face_name_string(WD_Null)
00164     , m_font_logfont_name_length(0)
00165     , m_font_logfont_name_string(WD_Null)
00166     , m_data_size(0)
00167     , m_data(WD_Null)
00168     , m_local_data_copy(WD_False)
00169     , m_stage(Starting)
00170     { }
00171 
00173     WT_Embedded_Font (
00174         int request_type,
00175         int privilege_type,
00176         int character_set_type)
00177     : m_request(request_type)
00178     , m_privilege(static_cast<WT_Byte>(privilege_type))
00179     , m_character_set_type(static_cast<WT_Byte>(character_set_type))
00180     , m_font_type_face_name_length(0)
00181     , m_font_type_face_name_string(WD_Null)
00182     , m_font_logfont_name_length(0)
00183     , m_font_logfont_name_string(WD_Null)
00184     , m_data_size(0)
00185     , m_data(WD_Null)
00186     , m_local_data_copy(WD_False)
00187     , m_stage(Starting)
00188     { }
00189 
00191     WT_Embedded_Font(
00193         int                            request_type,
00195         int                            privilege_type,
00197         int                            character_set_type,
00199         WT_Integer32                   data_size,
00201         WT_Byte *                      data,
00203         WT_Boolean                     copy
00204         ) throw(WT_Result)
00205     : m_request(request_type)
00206     , m_privilege(static_cast<WT_Byte>(privilege_type))
00207     , m_character_set_type(static_cast<WT_Byte>(character_set_type))
00208     , m_font_type_face_name_length(0)
00209     , m_font_type_face_name_string(WD_Null)
00210     , m_font_logfont_name_length(0)
00211     , m_font_logfont_name_string(WD_Null)
00212     , m_data_size(data_size)
00213     , m_data(WD_Null)
00214     , m_local_data_copy(copy)
00215     , m_stage(Starting)
00216     {
00217         if (copy)
00218         {
00219             if (m_local_data_copy)
00220             {
00221                 m_data = new WT_Byte[data_size];
00222 
00223                 if (m_data)
00224                     memcpy(m_data, data, data_size);
00225                 else
00226                     throw WT_Result::Out_Of_Memory_Error;
00227 
00228             }
00229         }  else {
00230             m_data = data;
00231         }
00232     }
00233 
00235     WT_Embedded_Font(
00237         int                            request_type,
00239         int                            privilege_type,
00241         int                            character_set_type,
00243         WT_Integer32                   data_size,
00245         WT_Byte *                      data,
00247         WT_Integer32                   font_type_face_name_length,
00249         WT_Byte *                      font_type_face_name_string,
00251         WT_Integer32                   font_logfont_name_length,
00253         WT_Byte *                      font_logfont_name_string,
00255         WT_Boolean                     copy
00256         ) throw(WT_Result)
00257     : m_request(request_type)
00258     , m_privilege(static_cast<WT_Byte>(privilege_type))
00259     , m_character_set_type(static_cast<WT_Byte>(character_set_type))
00260     , m_font_type_face_name_length(font_type_face_name_length)
00261     , m_font_type_face_name_string(WD_Null)
00262     , m_font_logfont_name_length(font_logfont_name_length)
00263     , m_font_logfont_name_string(WD_Null)
00264     , m_data_size(data_size)
00265     , m_data(WD_Null)
00266     , m_local_data_copy(copy)
00267     , m_stage(Starting)
00268     {
00269         if (copy)
00270         {
00271             if (m_local_data_copy)
00272             {
00273                 m_data = new WT_Byte[data_size];
00274 
00275                 if (m_data)
00276                     memcpy(m_data, data, data_size);
00277                 else
00278                     throw WT_Result::Out_Of_Memory_Error;
00279 
00280                 m_font_type_face_name_string =
00281                     new WT_Byte[font_type_face_name_length];
00282 
00283                 m_font_logfont_name_string =
00284                     new WT_Byte[font_logfont_name_length];
00285 
00286                 if(m_font_type_face_name_string)
00287                     strncpy((char *)m_font_type_face_name_string
00288                     , (const char *)font_type_face_name_string
00289                     , font_type_face_name_length);
00290                 else
00291                     throw WT_Result::Out_Of_Memory_Error;
00292 
00293                 if(m_font_logfont_name_string)
00294                     strncpy((char *)m_font_logfont_name_string
00295                     , (const char *)font_logfont_name_string
00296                     , font_logfont_name_length);
00297                 else
00298                     throw WT_Result::Out_Of_Memory_Error;
00299 
00300             }
00301         }  else {
00302             m_data = data;
00303             m_font_type_face_name_string = font_type_face_name_string;
00304             m_font_logfont_name_string = font_logfont_name_string;
00305         }
00306     }
00307 
00309     virtual ~WT_Embedded_Font()
00310     {
00311         if (m_local_data_copy) {
00312             delete [] m_data;
00313             delete [] m_font_type_face_name_string;
00314             delete [] m_font_logfont_name_string;
00315         }
00316     }
00318 
00319 public:
00320 
00322 
00323     const WT_Byte& character_set_type() const { return m_character_set_type;  }
00324           WT_Byte& character_set_type()       { return m_character_set_type;  }
00325 
00327     WT_Byte * const & data() const { return m_data;  }
00328     WT_Byte *       & data()       { return m_data;  }
00329 
00331     const WT_Integer32& data_size() const { return m_data_size; }
00332           WT_Integer32& data_size()       { return m_data_size; }
00333 
00335     const WT_Integer32& font_type_face_name_length() const { return m_font_type_face_name_length; }
00336           WT_Integer32& font_type_face_name_length()       { return m_font_type_face_name_length; }
00337 
00339     WT_Byte * const & font_type_face_name_string() const { return m_font_type_face_name_string;  }
00340     WT_Byte *       & font_type_face_name_string()       { return m_font_type_face_name_string;  }
00341 
00343     const WT_Integer32& font_logfont_name_length() const { return m_font_logfont_name_length; }
00344           WT_Integer32& font_logfont_name_length()       { return m_font_logfont_name_length; }
00345 
00347     WT_Byte * const & font_logfont_name_string() const { return m_font_logfont_name_string;  }
00348     WT_Byte *       & font_logfont_name_string()       { return m_font_logfont_name_string;  }
00349 
00351     const WT_Byte& privilege() const { return m_privilege;  }
00352           WT_Byte& privilege()       { return m_privilege;  }
00353 
00355     const WT_Unsigned_Integer32& request_type() const { return m_request;  }
00356           WT_Unsigned_Integer32& request_type()       { return m_request;  }
00358 
00360     WT_ID            object_id() const;
00361     WT_Type          object_type() const;
00362     WT_Result        materialize(WT_Opcode const & opcode, WT_File & file);
00363     WT_Result        process(WT_File & file);
00364     WT_Result        skip_operand(WT_Opcode const & opcode, WT_File & file);
00365     WT_Result        serialize (WT_File & file) const;
00366     WT_Result        sync (WT_File & file) const;
00368 
00370 
00372     static WT_Result default_process(
00373         WT_Embedded_Font & item, 
00374         WT_File & file 
00375         );
00376 };
00377 
00379 
00380 #endif // EMBEDDED_FONT_HEADER

Generated on Tue Jan 6 22:41:12 2009 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.5