/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This file is part of xlslib -- A multiplatform, C/C++ library * for dynamic generation of Excel(TM) files. * * xlslib is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * xlslib is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with xlslib. If not, see . * * Copyright 2004 Yeico S. A. de C. V. * Copyright 2008 David Hoerl * * $Source: /cvsroot/xlslib/xlslib/src/xlslib/font.cpp,v $ * $Revision: 1.2 $ * $Author: dhoerl $ * $Date: 2008/10/25 18:39:54 $ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * File description: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include using namespace std; using namespace xlslib_core; /* ********************************** CFont class implementation ********************************** */ CFont::CFont(string name, unsigned16_t height, unsigned16_t boldstyle, unsigned8_t underline, unsigned16_t script, unsigned16_t color, unsigned16_t attributes, unsigned8_t family, unsigned8_t charset) { SetRecordType(RECTYPE_FONT); AddValue16(height); AddValue16(attributes); AddValue16(color); AddValue16(boldstyle); AddValue16(script); AddValue8(underline); AddValue8(family); AddValue8(charset); AddValue8(FONT_RESERVED); #if VERSION_BIFF == VERSION_BIFF5 AddValue8((unsigned8_t)name.size()); AddDataArray((const unsigned8_t*)name.c_str(), name.size()); #else AddUnicodeStrlen((unsigned8_t)name.size()); AddUnicodeString((const unsigned8_t*)name.c_str(), name.size()); #endif SetRecordLength(GetDataSize()-4); } CFont::CFont(font_t* fontdef) { SetRecordType(RECTYPE_FONT); AddValue16(fontdef->GetHeight()); AddValue16(fontdef->GetAttributes()); AddValue16(fontdef->GetColor()); AddValue16(fontdef->GetBoldStyle()); AddValue16(fontdef->GetScriptStyle()); AddValue8(fontdef->GetUnderlineStyle()); AddValue8(fontdef->GetFamily()); AddValue8(fontdef->GetCharset()); AddValue8(FONT_RESERVED); #if VERSION_BIFF == VERSION_BIFF5 AddValue8((unsigned8_t)((fontdef->GetName()).size())); AddDataArray((const unsigned8_t*)((fontdef->GetName()).c_str()), (fontdef->GetName()).size()); #else AddUnicodeStrlen((unsigned8_t)((fontdef->GetName()).size())); AddUnicodeString((const unsigned8_t*)((fontdef->GetName()).c_str()), (fontdef->GetName()).size()); #endif SetRecordLength(GetDataSize()-4); } CFont::~CFont() { } /* ********************************** ********************************** */ int CFont::SetName(string& name) { int errcode = NO_ERRORS; name = name; /* NOTE: Unimplemented. Temporarilly this function won't set the name */ return errcode; } /* ********************************** ********************************** */ int CFont::GetName(string& name) { int errcode = NO_ERRORS; signed16_t namesize; GetValue16From(&namesize, FONT_OFFSET_NAMELENGTH); name = ""; for(int i=0; i