Logo Search packages:      
Sourcecode: jexcelapi version File versions  Download package

void jxl::biff::XFRecord::initializeFormatInformation (  )  [inline, private]

Initializes the internal format information from the data read in

Definition at line 1345 of file XFRecord.java.

References align, backgroundColour, biffType, bottomBorder, bottomBorderColour, jxl::format::Colour::DEFAULT_BACKGROUND, jxl::format::Colour::DEFAULT_BACKGROUND1, excelFormat, font, fontIndex, formatIndex, formatInfoInitialized, formattingRecords, jxl::format::VerticalAlignment::getAlignment(), jxl::format::Alignment::getAlignment(), jxl::read::biff::Record::getData(), jxl::biff::Fonts::getFont(), jxl::biff::FormattingRecords::getFonts(), jxl::biff::FormattingRecords::getFormatRecord(), jxl::format::Colour::getInternalColour(), jxl::format::Orientation::getOrientation(), jxl::format::Pattern::getPattern(), jxl::biff::RecordData::getRecord(), jxl::format::BorderLineStyle::getStyle(), hidden, indentation, leftBorder, leftBorderColour, locked, logger, jxl::format::Pattern::NONE, orientation, parentFormat, pattern, rightBorder, rightBorderColour, shrinkToFit, topBorder, topBorderColour, jxl::format::Colour::UNKNOWN, usedAttributes, valign, jxl::common::Logger::warn(), wrap, and xfFormatType.

Referenced by equals(), getAlignment(), getBackgroundColour(), getBorderColour(), getBorderLine(), getData(), getFont(), getFormat(), getIndentation(), getOrientation(), getPattern(), getVerticalAlignment(), getWrap(), hasBorders(), hashCode(), isLocked(), isShrinkToFit(), and XFRecord().

  {
    // Initialize the cell format string
    if (formatIndex < BuiltInFormat.builtIns.length &&
        BuiltInFormat.builtIns[formatIndex] != null)
    {
      excelFormat = BuiltInFormat.builtIns[formatIndex];
    }
    else
    {
      excelFormat = formattingRecords.getFormatRecord(formatIndex);
    }

    // Initialize the font
    font = formattingRecords.getFonts().getFont(fontIndex);

    // Initialize the cell format data from the binary record
    byte[] data = getRecord().getData();

    // Get the parent record
    int cellAttributes = IntegerHelper.getInt(data[4], data[5]);
    parentFormat = (cellAttributes & 0xfff0) >> 4;
    int formatType = cellAttributes & 0x4;
    xfFormatType = formatType == 0 ? cell : style;
    locked = ((cellAttributes & 0x1) != 0);
    hidden = ((cellAttributes & 0x2) != 0);

    if (xfFormatType == cell &&
        (parentFormat & 0xfff) == 0xfff)
    {
      // Something is screwy with the parent format - set to zero
      parentFormat = 0;
      logger.warn("Invalid parent format found - ignoring");
    }


    int alignMask = IntegerHelper.getInt(data[6], data[7]);

    // Get the wrap
    if ((alignMask & 0x08) != 0)
    {
      wrap = true;
    }

    // Get the horizontal alignment
    align = Alignment.getAlignment(alignMask & 0x7);

    // Get the vertical alignment
    valign = VerticalAlignment.getAlignment((alignMask >> 4) & 0x7);

    // Get the orientation
    orientation = Orientation.getOrientation((alignMask >> 8) & 0xff);

    int attr = IntegerHelper.getInt(data[8], data[9]);

    // Get the indentation
    indentation = attr & 0x0F;

    // Get the shrink to fit flag
    shrinkToFit = (attr & 0x10) != 0;

    // Get the used attribute
    if (biffType == biff8)
    {
      usedAttributes = data[9];
    }

    // Get the borders
    int borderMask = IntegerHelper.getInt(data[10], data[11]);

    leftBorder   = BorderLineStyle.getStyle(borderMask & 0x7);
    rightBorder  = BorderLineStyle.getStyle((borderMask >> 4) & 0x7);
    topBorder    = BorderLineStyle.getStyle((borderMask >> 8) & 0x7);
    bottomBorder = BorderLineStyle.getStyle((borderMask >> 12) & 0x7);

    int borderColourMask = IntegerHelper.getInt(data[12], data[13]);

    leftBorderColour = Colour.getInternalColour(borderColourMask & 0x7f);
    rightBorderColour = Colour.getInternalColour
      ((borderColourMask & 0x3f80) >> 7);

    borderColourMask = IntegerHelper.getInt(data[14], data[15]);
    topBorderColour = Colour.getInternalColour(borderColourMask & 0x7f);
    bottomBorderColour = Colour.getInternalColour
      ((borderColourMask & 0x3f80) >> 7);
    
    if (biffType == biff8)
    {
      // Get the background pattern.  This is the six most significant bits
      int patternVal = IntegerHelper.getInt(data[16], data[17]);
      patternVal = patternVal & 0xfc00;
      patternVal = patternVal >> 10;
      pattern = Pattern.getPattern(patternVal);

      // Get the background colour
      int colourPaletteMask = IntegerHelper.getInt(data[18], data[19]);
      backgroundColour = Colour.getInternalColour(colourPaletteMask & 0x3f);

      if (backgroundColour == Colour.UNKNOWN ||
          backgroundColour == Colour.DEFAULT_BACKGROUND1)
      {
        backgroundColour = Colour.DEFAULT_BACKGROUND;
      }
    }
    else
    {
      pattern = Pattern.NONE;
      backgroundColour = Colour.DEFAULT_BACKGROUND;
    }

    // Set the lazy initialization flag
    formatInfoInitialized = true;
  }


Generated by  Doxygen 1.6.0   Back to index