Changeset 3a849c8 in tol


Ignore:
Timestamp:
Mar 20, 2011, 3:21:00 PM (16 years ago)
Author:
Jorge Pérez <josp.jorge@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
fe52ab1
Parents:
51de3f7
Message:

refs #854, writing Date objects

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@3341 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/contrib/excel/tolExcel.cpp

    r51de3f7 r3a849c8  
    346346  BasicExcel *m_ptrXLS;
    347347  XLSFormatManager *m_ptrFmtMgr;
     348  CellFormat *m_ptrCellFmt;
    348349  BasicExcelWorksheet *m_ptrActiveWS;
    349350};
    … …  
    445446  m_ptrXLS(NULL),
    446447  m_ptrFmtMgr(NULL),
     448  m_ptrCellFmt(NULL),
    447449  m_ptrActiveWS(NULL)
    448450{
    449   m_ptrXLS = new BasicExcel;
    450   m_ptrActiveWS = m_ptrXLS->AddWorksheet( );
    451   m_isOpen = false;
     451  this->m_ptrXLS = new BasicExcel;
     452  this->m_ptrActiveWS = this->m_ptrXLS->AddWorksheet( );
     453  this->m_ptrFmtMgr = new XLSFormatManager( *(this->m_ptrXLS) );
     454  this->m_ptrCellFmt = new CellFormat( *(this->m_ptrFmtMgr) );
     455  this->m_isOpen = false;
    452456}
    453457
    … …  
    458462  m_ptrActiveWS(NULL)
    459463{
    460   m_ptrXLS = new BasicExcel;
    461   if ( !( m_isOpen = m_ptrXLS->Load( path ) ) ) {
     464  this->m_ptrXLS = new BasicExcel;
     465  if ( !( this->m_isOpen = this->m_ptrXLS->Load( path ) ) ) {
    462466    delete m_ptrXLS;
    463     m_ptrXLS = NULL;
    464   } else {
    465     m_ptrActiveWS = m_ptrXLS->GetWorksheet( 0 );
     467    this->m_ptrXLS = NULL;
     468  } else {
     469    this->m_ptrActiveWS = this->m_ptrXLS->GetWorksheet( 0 );
    466470  }
    467471  if ( m_ptrXLS ) {
    468     m_ptrFmtMgr = new XLSFormatManager( *m_ptrXLS );
     472    this->m_ptrFmtMgr = new XLSFormatManager( *(this->m_ptrXLS) );
     473    this->m_ptrCellFmt = new CellFormat( *(this->m_ptrFmtMgr) );
    469474  }
    470475  m_ptrActiveWS = NULL;
    … …  
    473478TolExcel::~TolExcel()
    474479{
    475   if ( m_ptrFmtMgr ) {
    476     delete m_ptrFmtMgr;
    477     m_ptrFmtMgr = NULL;
    478   }
    479   if ( m_ptrXLS ) {
    480     delete m_ptrXLS;
    481     m_ptrXLS = NULL;
    482   }
    483   m_isOpen = false;
    484   m_ptrXLS = NULL;
     480  if ( this->m_ptrCellFmt ) {
     481    delete this->m_ptrCellFmt;
     482    this->m_ptrCellFmt = NULL;
     483  }
     484  if ( this->m_ptrFmtMgr ) {
     485    delete this->m_ptrFmtMgr;
     486    this->m_ptrFmtMgr = NULL;
     487  }
     488  if ( this->m_ptrXLS ) {
     489    delete this->m_ptrXLS;
     490    this->m_ptrXLS = NULL;
     491  }
     492  this->m_isOpen = false;
    485493}
    486494
    … …  
    498506  } else if ( value->Grammar() == GraDate() ) {
    499507    BDate &date = Date( value );
     508    //XLSFormatManager fmt_mgr(*m_ptrXLS);
     509    //CellFormat fmt(fmt_mgr);
    500510    int serialDate = TolExcel::DMYToExcelSerialDate( date.Day(),
    501511                                                     date.Month(),
    502512                                                     date.Year() );
    503     cell->SetDouble( double( serialDate ) );
     513    this->m_ptrCellFmt->set_format_string( "DD/MM/YYYY" );
     514    //fmt.set_format_string( "DD/MM/YY" );
     515    BDateFormat dateFormat( "%d/%m/%y" );
     516    BText txt( dateFormat.DateToText( date ) );
     517    cell->Set( txt.String() );
     518    //cell->SetFormat( fmt );
     519    cell->SetFormat( *(this->m_ptrCellFmt) );
     520    //cell->SetDouble( double( serialDate ) );
     521    //cell->SetDouble( 25780 );
     522    //cell->Set( "31/07/70" );
    504523  } else if ( value->Grammar() == GraText() ) {
    505524    BText &txt = Text( value );
Note: See TracChangeset for help on using the changeset viewer.