Changeset eb2b9dd in tol


Ignore:
Timestamp:
Feb 16, 2011, 7:33:52 PM (16 years ago)
Author:
Jorge Pérez <josp.jorge@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
03befc6
Parents:
26e0c37
Message:

closes #1099, now Excel.ReadRange accept an extra argument with de default values for every column

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

File:
1 edited

Legend:

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

    r26e0c37 reb2b9dd  
    398398  }
    399399#endif
    400   assert( cell );
    401400  if ( cell ) {
    402401    CellFormat fmt( *m_ptrFmtMgr, cell );
    … …  
    422421        snprintf( cell_coord, 64, "(%d,%d)", row, col );       
    423422        Warning( err_name + ": " +
    424                  I2("don't know how to interpret the result in cell ",
     423                 I2("don't know how to interpret the result in cell formula ",
    425424                    "no se como interpretar el resultado en la celda " ) + cell_coord );
    426         result = new BContensText( "" );
     425        // OJO: aqui hay que retornar NULL y dejar que el que llama tome la decision.
     426        result = NULL;
     427        //result = new BContensText( "" );
    427428      }
    428429      break;
    … …  
    434435                  "no se que hacer con la celda " ) + cell_coord );
    435436#endif
    436       result = new BContensText( "" );
     437      result = NULL;
     438      // result = new BContensText( "" );
    437439    }
    438440  }
    … …  
    784786//---------------------------------------------------------------------------
    785787DeclareContensClass(BSet, BSetTemporary, BSetExcelReadRange);
    786 DefExtOpr(1, BSetExcelReadRange, "Excel.ReadRange", 3, 3, "Real Anything Anything",
    787           "(Real ExcelHandler, Anything CornerLT, Anything CornerRB)",
     788DefExtOpr(1, BSetExcelReadRange, "Excel.ReadRange", 3, 4,
     789          "Real Anything Anything Set",
     790          "(Real ExcelHandler, Anything CornerLT, Anything CornerRB [,Set ColumnTypes])",
    788791          I2("Return the contents of the cells contained given cell's range. "
    789792             "The cell corners delimiting the range can be given as Text or "
    … …  
    807810    // bool status1 = ;
    808811    // bool status2 = ;
     812    BSet *ptrArgs = NULL;
     813
    809814    if ( TolExcel::getCellCoordinates( _name_, cornerLT, r0, c0 ) &&
    810815         TolExcel::getCellCoordinates( _name_, cornerBR, r1, c1 ) ) {
    … …  
    812817      BList*    aux    = NIL;
    813818      size_t    r,c;
     819      size_t    numColumns = c1 - c0 + 1;
     820      if ( NumArgs() > 3 ) {
     821        ptrArgs = &Set( Arg( 4 ) );
     822        if ( numColumns == ptrArgs->Card() ) {
     823          for ( c = 1; c <= ptrArgs->Card(); c++ ) {
     824            BGrammar *grammar = (*ptrArgs)[c]->Grammar();
     825            if ( grammar != GraText() &&
     826                 grammar != GraReal() &&
     827                 grammar != GraDate() ) {
     828              Warning( _name_ + ": " +
     829                       "Invalid type in column type specification, only Real, Date or Text is returned from excel" );
     830              ptrArgs = NULL;
     831              break;
     832            }
     833          }
     834        } else {
     835          char buffer[256];
     836          snprintf( buffer, 256, "Expecting %d columns (%d,%d)", numColumns, c0, c1 );
     837          Warning( _name_ + ": " +
     838                   "The number of column's types does not match the number of columns. " + buffer);
     839          ptrArgs = NULL;
     840        }
     841      }
    814842      for( r = r0; r <= r1; r++ ) {
    815843        BList* lsta       = NIL;
    … …  
    817845        for( c = c0; c <= c1; c++ ) {
    818846          BSyntaxObject *cellValue = xls->GetCellAnything( _name_, r, c );
     847          // OJO: aqui hay que rellenar con el omitido segun el tipo de columna
    819848          if ( !cellValue ) {
    820             cellValue = new BContensText( "" );
     849            cellValue = ptrArgs ? ((*ptrArgs)[c-c0+1])->CopyContens() :
     850              new BContensText( "" );
    821851          }
    822852          LstFastAppend( lsta, auxa, cellValue );
    … …  
    861891                    "direccion de objecto excel invalido") );
    862892          return NULL;
    863         }   
     893        }
     894        // OJO, puede venir NULL
    864895        result = xls->GetCellAnything( _name_, i_row, i_col );
     896        if ( !result ) {
     897          result = new BContensText( "" );
     898        }
    865899      }
    866900    }
Note: See TracChangeset for help on using the changeset viewer.