📄 cell.cpp
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) Yeico S. A. de C. V. * xlsLib -- A multiplatform, C++ library for dynamic generation of Excel (TM) * files. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Source: /cvsroot/xlslib/xlslib/src/xlslib/cell.cpp,v $ * $Revision: 1.1.1.1 $ * $Author: darioglz $ * $Date: 2004/08/27 16:31:54 $ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * File description: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */#include "cell.h"using namespace std;using namespace xlslib_core;cell_t::cell_t() :m_pGlobalRecs(NULL){}cell_t::~cell_t(){}unsigned16_t cell_t::GetXFIndex(){ unsigned16_t xfindex; pxf != NULL? xfindex = pxf->GetIndex() :xfindex = 0x000f; return xfindex;}bool cell_t::operator==(const cell_t& right) const{ return (row == right.row);}bool cell_t::operator!=(const cell_t& right) const{ return (row != right.row);}/* bool cell_t::operator<(const cell_t& right) const { return (row < right.row); } bool cell_t::operator>(const cell_t& right) const { return (row > right.row); } bool cell_t::operator%(const cell_t& right) const { return (row == right.row && col == right.col); }*//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Implementation of the XF record interface (xf_i pure virtual interface) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */#define SET_XF_CELL_FUNCTION(function,value) \ { \ xf_t* currentxf = pxf; \ if(pxf == NULL) \ currentxf = m_pGlobalRecs->GetDefaultXF(); \ \ xf_t* xfbackup = new xf_t; \ (*xfbackup) = (*currentxf); \ \ if(currentxf->Usage() > 1) \ { \ xf_t* newxf = new xf_t(); \ (*newxf) = (*currentxf); \ newxf->function(value); \ newxf = m_pGlobalRecs->AddXFormat(newxf); \ pxf = newxf; \ pxf->MarkUsed(); \ \ } \ else \ { \ xf_t* xfnew = new xf_t; \ (*xfnew) = (*currentxf); \ xfnew->function(value); \ xfnew->MarkUsed(); \ xfnew = m_pGlobalRecs->ReplaceXFormat(xfbackup, xfnew); \ pxf = xfnew; \ pxf->MarkUsed(); \ \ } \ delete xfbackup; \ }void cell_t::borderstyle(border_side_t side, border_style_t style, color_name_t color){ xf_t* currentxf = pxf; if(pxf == NULL) currentxf = m_pGlobalRecs->GetDefaultXF(); xf_t* xfbackup = new xf_t; (*xfbackup) = (*currentxf); if(currentxf->Usage() > 1) { xf_t* newxf = new xf_t(); (*newxf) = (*currentxf); newxf->SetBorderStyle(side, style, color); newxf = m_pGlobalRecs->AddXFormat(newxf); pxf = newxf; pxf->MarkUsed(); } else { xf_t* xfnew = new xf_t; (*xfnew) = (*currentxf); xfnew->SetBorderStyle(side, style, color); xfnew->MarkUsed(); xfnew = m_pGlobalRecs->ReplaceXFormat(xfbackup, xfnew); pxf = xfnew; pxf->MarkUsed(); } delete xfbackup;}void cell_t::font(font_t* fontidx){ SET_XF_CELL_FUNCTION(SetFont, fontidx);/* xf_t* currentxf = pxf; if(pxf == NULL) currentxf = m_pGlobalRecs->GetDefaultXF(); xf_t* xfbackup = new xf_t; (*xfbackup) = (*currentxf); if(currentxf->Usage() > 1) { xf_t* newxf = new xf_t(); (*newxf) = (*currentxf); newxf->SetFont(fontidx); newxf = m_pGlobalRecs->AddXFormat(newxf); pxf = newxf; pxf->MarkUsed(); } else { xf_t* xfnew = new xf_t; (*xfnew) = (*currentxf); xfnew->SetFont(fontidx); xfnew->MarkUsed(); xfnew = m_pGlobalRecs->ReplaceXFormat(xfbackup, xfnew); pxf = xfnew; } delete xfbackup;*/}void cell_t::format(format_number_t formatidx){ SET_XF_CELL_FUNCTION(SetFormat,formatidx);}void cell_t::halign(halign_option_t ha_option){ SET_XF_CELL_FUNCTION(SetHAlign,ha_option);}void cell_t::valign(valign_option_t va_option){ SET_XF_CELL_FUNCTION(SetVAlign,va_option);}void cell_t::orientation(txtori_option_t ori_option){ SET_XF_CELL_FUNCTION(SetTxtOrientation,ori_option);}void cell_t::fillfgcolor(color_name_t color){ SET_XF_CELL_FUNCTION(SetFillFGColor,color);/* xf_t* currentxf = pxf; if(pxf == NULL) currentxf = m_pGlobalRecs->GetDefaultXF(); xf_t* xfbackup = new xf_t; (*xfbackup) = (*currentxf); if(currentxf->Usage() > 1) { xf_t* newxf = new xf_t(); (*newxf) = (*currentxf); newxf->SetFillFGColor(color); newxf = m_pGlobalRecs->AddXFormat(newxf); pxf = newxf; pxf->MarkUsed(); } else { xf_t* xfnew = new xf_t; (*xfnew) = (*currentxf); xfnew->SetFillFGColor(color); xfnew->MarkUsed(); xfnew = m_pGlobalRecs->ReplaceXFormat(xfbackup, xfnew); pxf = xfnew; pxf->MarkUsed(); } delete xfbackup;*/}void cell_t::fillbgcolor(color_name_t color){ SET_XF_CELL_FUNCTION(SetFillBGColor,color);}void cell_t::fillstyle(fill_option_t fill){ SET_XF_CELL_FUNCTION(SetFillStyle,fill);/* xf_t* currentxf = pxf; if(pxf == NULL) currentxf = m_pGlobalRecs->GetDefaultXF(); xf_t* xfbackup = new xf_t; (*xfbackup) = (*currentxf); if(currentxf->Usage() > 1) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -