Package org.formulacompiler.spreadsheet.internal

Examples of org.formulacompiler.spreadsheet.internal.CellIndex


        else {
          elts.add( buildExpressionModelForLocalRange( next ) );
        }
      }

      final CellIndex from = range.getFrom();
      final ExpressionNode result = (shaped) ? new ExpressionNodeForArrayReference( new ArrayDescriptor(
          from.getSheetIndex(), from.getRowIndex(), from.getColumnIndex(), sheets, rows, cols ) )
          : new ExpressionNodeForSubstitution();
      result.arguments().addAll( elts );
      return result;
    }
View Full Code Here


      }
    }

    private ExpressionNode buildExpressionModelForLocalRange( CellRange _range ) throws CompilerException
    {
      final CellIndex from = _range.getFrom();
      final CellIndex to = _range.getTo();
      final int sheets = to.getSheetIndex() - from.getSheetIndex() + 1;
      final int rows = to.getRowIndex() - from.getRowIndex() + 1;
      final int cols = to.getColumnIndex() - from.getColumnIndex() + 1;
      final ExpressionNode result = new ExpressionNodeForArrayReference( new ArrayDescriptor( from.getSheetIndex(),
          from.getRowIndex(), from.getColumnIndex(), sheets, rows, cols ) );
      buildExpressionModelsForLocalRangeCells( _range, result.arguments() );
      return result;
    }
View Full Code Here

  }


  public RangeRef range( CellRef _oneCorner, CellRef _otherCorner )
  {
    final CellIndex a = cellOf( _oneCorner );
    final CellIndex b = cellOf( _otherCorner );

    int sheetMin = Math.min( a.getSheetIndex(), b.getSheetIndex() );
    int sheetMax = Math.max( a.getSheetIndex(), b.getSheetIndex() );
    int rowMin = Math.min( a.getRowIndex(), b.getRowIndex() );
    int rowMax = Math.max( a.getRowIndex(), b.getRowIndex() );
    int colMin = Math.min( a.getColumnIndex(), b.getColumnIndex() );
    int colMax = Math.max( a.getColumnIndex(), b.getColumnIndex() );

    final CellIndex min = new CellIndex( this.spreadsheet, sheetMin, colMin, rowMin );
    final CellIndex max = new CellIndex( this.spreadsheet, sheetMax, colMax, rowMax );

    return new RangeRefImpl( CellRange.getCellRange( min, max ) );
  }
View Full Code Here

  {
    validateImplementable( _call );
    if (this.outputs.containsKey( _call )) {
      throw new CompilerException.DuplicateDefinition( "Output method '" + _call.toString() + "' is already defined" );
    }
    final CellIndex cellIndex = (CellIndex) _cell;
    final OutputCellBinding def = new OutputCellBinding( this, _call, cellIndex );
    this.outputs.put( _call, def );
    this.workbook.add( def );
  }
View Full Code Here

  }


  public CellRange getPrototypeRange( CellRange _range ) throws CompilerException
  {
    CellIndex from = _range.getFrom();
    CellIndex to = _range.getTo();

    int wantFrom = this.range.getFrom().getIndex( this.orientation );
    int wantTo = this.range.getTo().getIndex( this.orientation );
    int isFrom = from.getIndex( this.orientation );
    int isTo = to.getIndex( this.orientation );

    if ((isFrom != wantFrom) || (isTo != wantTo)) {
      throw new SpreadsheetException.SectionExtentNotCovered( _range.getShortName(), this.toString(), this.orientation );
    }
    if (!contains( _range.getFrom() ) || !contains( _range.getTo() )) {
      throw new SpreadsheetException.NotInSection( null, _range.getShortName(), this.toString(), this.getRange()
          .getShortName() );
    }

    if (isTo > isFrom) {
      return CellRange.getCellRange( from, to.setIndex( this.orientation, isFrom ) );
    }
    else {
      return _range;
    }
View Full Code Here

      if (1 == xlsRange.length) {
        final int xlsStartSheet = xlsRange[ 0 ].getFirstSheetIndex();
        final int xlsEndSheet = xlsRange[ 0 ].getLastSheetIndex();
        final jxl.Cell xlsStart = xlsRange[ 0 ].getTopLeft();
        final jxl.Cell xlsEnd = xlsRange[ 0 ].getBottomRight();
        final CellIndex start = new CellIndex( _workbook, xlsStartSheet, xlsStart.getColumn(), true, xlsStart.getRow(), true );
        final CellIndex end = new CellIndex( _workbook, xlsEndSheet, xlsEnd.getColumn(), true, xlsEnd.getRow(), true );
        final CellRange range = CellRange.getCellRange( start, end );
        _workbook.defineModelRangeName( name, range );
      }
    }
  }
View Full Code Here

  private void saveNames( BaseSpreadsheet _wb, WritableWorkbook _xwb )
  {
    for (final Entry<String, CellRange> nd : _wb.getModelRangeNames().entrySet()) {
      final String name = nd.getKey();
      final CellRange ref = nd.getValue();
      final CellIndex from = ref.getFrom();
      final CellIndex to = ref.getTo();
      if (from.getSheetIndex() == to.getSheetIndex()) {
        _xwb.addNameArea( name, _xwb.getSheet( from.getSheetIndex() ), from.getColumnIndex(), from.getRowIndex(),
            to.getColumnIndex(), to.getRowIndex() );
      }
    }
  }
View Full Code Here


  public void defineInputCell( Spreadsheet.Cell _cell, CallFrame _callChainToCall ) throws CompilerException
  {
    validateAccessible( _callChainToCall );
    final CellIndex cellIndex = (CellIndex) _cell;
    if (this.inputs.containsKey( cellIndex )) {
      throw new CompilerException.DuplicateDefinition( "Input cell '"
          + cellIndex.getShortName() + "' is already defined" );
    }
    final InputCellBinding def = new InputCellBinding( this, _callChainToCall, cellIndex );
    this.inputs.put( def.getIndex(), def );
    this.workbook.add( def );
  }
View Full Code Here

    final Attribute reference = _cell.getAttributeByName( XMLConstants.Main.CELL_REFERENCE );
    final Attribute dataType = _cell.getAttributeByName( XMLConstants.Main.CELL_TYPE );
    final Attribute styleIndex = _cell.getAttributeByName( XMLConstants.Main.CELL_STYLE );

    final BaseSheet sheet = _row.getSheet();
    final CellIndex upperLeftCellIndex = new CellIndex( sheet.getSpreadsheet(), sheet.getSheetIndex(), 0, 0 );
    final CellIndex cellIndex = CellRefParser.A1.parseCellA1( reference.getValue(), upperLeftCellIndex );

    String formula = null;
    String formulaIndex = null;

    String value = null;

    final int cellContext = getContext();
    StartElement se;
    while ((se = findAny( cellContext )) != null) {
      final QName name = se.getName();
      if (name.equals( XMLConstants.Main.CELL_FORMULA )) {
        final Attribute formulaType = se.getAttributeByName( XMLConstants.Main.CELL_FORMULA_TYPE );
        if (formulaType != null && "shared".equals( formulaType.getValue() ))
          formulaIndex = se.getAttributeByName( XMLConstants.Main.CELL_FORMULA_SHARED_INDEX ).getValue();
        formula = getText();
      }
      else if (name.equals( XMLConstants.Main.CELL_VALUE )) {
        value = getText();
      }
    }

    if (formula == null && formulaIndex == null && value == null)
      return;

    final int columnIndex = cellIndex.getColumnIndex();
    while (columnIndex != _row.getCellList().size())
      _row.getCellList().add( null );

    if (formula != null) {
      final CellWithLazilyParsedExpression exprCell = new CellWithLazilyParsedExpression(
View Full Code Here

    final Object[] args = _frame.getArgs();
    boolean changed = false;
    if (null != args) {
      for (int i = 0; i < args.length; i++) {
        if (args[ i ] instanceof CellIndex) {
          CellIndex cell = (CellIndex) args[ i ];
          CellModel model = getOrCreateCellModel( cell );
          args[ i ] = model;
          changed = true;
        }
      }
View Full Code Here

TOP

Related Classes of org.formulacompiler.spreadsheet.internal.CellIndex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.