libwps_tools_win.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
00002 /* libwps
00003  * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
00004  * Copyright (C) 2006, 2007 Andrew Ziem
00005  * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00006  * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
00007  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Library General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Library General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Library General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00022  *
00023  * For further information visit http://libwps.sourceforge.net
00024  */
00025 
00026 /* "This product is not manufactured, approved, or supported by
00027  * Corel Corporation or Corel Corporation Limited."
00028  */
00029 
00030 /* This header contains code specific to windows file :
00031  *     - a class used to convert DOS/Win3 font characters in unicode
00032  *     - a class used to defined the text Language
00033  */
00034 
00035 #ifndef WPS_WIN
00036 #  define WPS_WIN
00037 
00038 #  include <assert.h>
00039 #  include <string>
00040 
00041 #  include "libwps_internal.h"
00042 
00044 namespace libwps_tools_win
00045 {
00047 class Font
00048 {
00049 public:
00051         enum Type { DOS_850,
00052                     WIN3_ARABIC, WIN3_BALTIC, WIN3_CEUROPE, WIN3_CYRILLIC,
00053                     WIN3_GREEK, WIN3_HEBREW, WIN3_TURKISH,
00054                     WIN3_VIETNAMESE, WIN3_WEUROPE
00055                   };
00056 
00058         static unsigned long unicode(unsigned char c, Type type)
00059         {
00060                 switch(type)
00061                 {
00062                 case DOS_850:
00063                         return unicodeFromCP850(c);
00064                 case WIN3_ARABIC:
00065                         return unicodeFromCP1256(c);
00066                 case WIN3_BALTIC:
00067                         return unicodeFromCP1257(c);
00068                 case WIN3_CEUROPE:
00069                         return unicodeFromCP1250(c);
00070                 case WIN3_CYRILLIC:
00071                         return unicodeFromCP1251(c);
00072                 case WIN3_GREEK:
00073                         return unicodeFromCP1253(c);
00074                 case WIN3_HEBREW:
00075                         return unicodeFromCP1255(c);
00076                 case WIN3_TURKISH:
00077                         return unicodeFromCP1254(c);
00078                 case WIN3_VIETNAMESE:
00079                         return unicodeFromCP1258(c);
00080                 case WIN3_WEUROPE:
00081                         return unicodeFromCP1252(c);
00082                 default:
00083                         assert(0);
00084                         return c;
00085                 }
00086         }
00087 
00093         static Type getWin3Type(std::string &name);
00094 
00095 protected:
00096         //
00097         // DOS FONTS
00098         //
00099 
00101         static unsigned long unicodeFromCP850(unsigned char c);
00102 
00104         static unsigned long unicodeFromCP1250(unsigned char c);
00106         static unsigned long unicodeFromCP1251(unsigned char c);
00108         static unsigned long unicodeFromCP1252(unsigned char c);
00110         static unsigned long unicodeFromCP1253(unsigned char c);
00112         static unsigned long unicodeFromCP1254(unsigned char c);
00114         static unsigned long unicodeFromCP1255(unsigned char c);
00116         static unsigned long unicodeFromCP1256(unsigned char c);
00118         static unsigned long unicodeFromCP1257(unsigned char c);
00120         static unsigned long unicodeFromCP1258(unsigned char c);
00121 };
00122 
00123 // see http://msdn.microsoft.com/en-us/library/bb213877.aspx (Community Content)
00125 namespace Language
00126 {
00128 std::string name(long id);
00130 std::string localeName(long id);
00132 long getDefault();
00133 }
00134 
00135 }
00136 
00137 
00138 #endif
00139 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: