/**
  * Sets the background colour for this cell format
  *
  * @param c the bacground colour
  * @exception jxl.write.WriteException
  */
 public void setBackground(Colour c)
 {
     this.setBackground(c, Pattern.SOLID);
 }
 /**
  * Sets the background colour and pattern for this cell format
  *
  * @param c the colour
  * @param p the pattern
  * @exception jxl.write.WriteException
  */
 public override void setBackground(Colour c, Pattern p)
 {
     base.setBackground(c, p);
 }
 /**
  * Sets the RGB value for the specified colour for this workbook
  *
  * @param c the colour whose RGB value is to be overwritten
  * @param r the red portion to set (0-255)
  * @param g the green portion to set (0-255)
  * @param b the blue portion to set (0-255)
  */
 public override void setColourRGB(Colour c, int r, int g, int b)
 {
     formatRecords.setColourRGB(c, r, g, b);
 }
 /**
  * Accessor for the RGB value for the specified colour
  *
  * @return the RGB for the specified colour
  */
 public RGB getColourRGB(Colour c)
 {
     return formatRecords.getColourRGB(c);
 }
Пример #5
0
        /**
         * Sets the border for this cell
         * This method should only be called from its writable subclass
         * CellXFRecord
         *
         * @param b the border
         * @param ls the border line style
         */
        protected void setXFBorder(Border b,BorderLineStyle ls,Colour c)
        {
            Assert.verify(!initialized);

            if (c == Colour.BLACK || c == Colour.UNKNOWN)
                {
                c = Colour.PALETTE_BLACK;
                }

            if (b == Border.LEFT)
                {
                leftBorder = ls;
                leftBorderColour = c;
                }
            else if (b == Border.RIGHT)
                {
                rightBorder = ls;
                rightBorderColour = c;
                }
            else if (b == Border.TOP)
                {
                topBorder = ls;
                topBorderColour = c;
                }
            else if (b == Border.BOTTOM)
                {
                bottomBorder = ls;
                bottomBorderColour = c;
                }

            usedAttributes |= USE_BORDER;

            return;
        }
Пример #6
0
 /**
  * Sets the background for the cell
  *
  * @exception WriteException
  * @param c the background colour
  * @param p the background patter
  */
 public virtual void setBackground(Colour c, Pattern p)
 {
     if (isInitialized())
         {
         throw new JxlWriteException(JxlWriteException.formatInitialized);
         }
     base.setXFBackground(c, p);
     base.setXFCellOptions(0x4000);
 }
Пример #7
0
 /**
  * Creates a font of the specified face, point size, bold style,
  * italicisation, underline style and colour
  *
  * @param ps the point size
  * @param bs the bold style
  * @param us the underline style
  * @param fn the font name
  * @param it italic flag
  * @param c the colour
  * @deprecated use jxl.write.WritableFont
  */
 public Font(FontName fn,
     int ps,
     BoldStyle bs,
     bool it,
     UnderlineStyle us,
     Colour c)
     : base(fn,ps,bs,it,us,c)
 {
 }
Пример #8
0
 /**
  * Creates a font of the specified face, point size, bold style,
  * italicisation, underline style, colour, and script
  * style (superscript/subscript)
  *
  * @param ps the point size
  * @param bs the bold style
  * @param us the underline style
  * @param fn the font name
  * @param it the italic flag
  * @param c the colour
  * @param ss the script style
  */
 public WritableFont(FontName fn,
     int ps,
     BoldStyle bs,
     bool it,
     UnderlineStyle us,
     Colour c,
     ScriptStyle ss)
     : base(fn.name, ps, bs.value, it, us.getValue(), c.getValue(), ss.getValue())
 {
 }
Пример #9
0
        /**
         * A public copy constructor which can be used for copy formats between
         * different sheets.  Unlike the the other copy constructor, this
         * version does a deep copy
         *
         * @param cellFormat the format to copy
         */
        protected XFRecord(CellFormat cellFormat)
            : base(Type.XF)
        {
            Assert.verify(cellFormat != null);
            Assert.verify(cellFormat is XFRecord);
            XFRecord fmt = (XFRecord)cellFormat;

            if (!fmt.formatInfoInitialized)
                {
                fmt.initializeFormatInformation();
                }

            locked = fmt.locked;
            hidden = fmt.hidden;
            align = fmt.align;
            valign = fmt.valign;
            orientation = fmt.orientation;
            wrap = fmt.wrap;
            leftBorder = fmt.leftBorder;
            rightBorder = fmt.rightBorder;
            topBorder = fmt.topBorder;
            bottomBorder = fmt.bottomBorder;
            leftBorderColour = fmt.leftBorderColour;
            rightBorderColour = fmt.rightBorderColour;
            topBorderColour = fmt.topBorderColour;
            bottomBorderColour = fmt.bottomBorderColour;
            pattern = fmt.pattern;
            xfFormatType = fmt.xfFormatType;
            parentFormat = fmt.parentFormat;
            indentation = fmt.indentation;
            shrinkToFit = fmt.shrinkToFit;
            backgroundColour = fmt.backgroundColour;

            // Deep copy of the font
            font = new FontRecord(fmt.getFont());

            // Copy the format
            if (fmt.getFormat() == null)
                {
                // format is writable
                if (fmt.format.isBuiltIn())
                    {
                    format = fmt.format;
                    }
                else
                    {
                    // Format is not built in, so do a deep copy
                    format = new FormatRecord((FormatRecord)fmt.format);
                    }
                }
            else if (fmt.getFormat() is BuiltInFormat)
                {
                // read excel format is built in
                excelFormat = (BuiltInFormat)fmt.excelFormat;
                format = (BuiltInFormat)fmt.excelFormat;
                }
            else
                {
                // read excel format is user defined
                Assert.verify(fmt.formatInfoInitialized);

                // in this case FormattingRecords should initialize the excelFormat
                // field with an instance of FormatRecord
                Assert.verify(fmt.excelFormat is FormatRecord);

                // Format is not built in, so do a deep copy
                FormatRecord fr = new FormatRecord((FormatRecord)fmt.excelFormat);

                // Set both format fields to be the same object, since
                // FormatRecord implements all the necessary interfaces
                excelFormat = fr;
                format = fr;
                }

            biffType = biff8;

            // The format info should be all OK by virtue of the deep copy
            formatInfoInitialized = true;

            // This format was not read in
            read = false;

            // Treat this as a new cell record, so set the copied flag to false
            copied = false;

            // The font or format indexes need to be set, so set initialized to false
            initialized = false;
        }
 /**
  * Sets the RGB value for the specified colour for this workbook
  *
  * @param c the colour whose RGB value is to be overwritten
  * @param r the red portion to set (0-255)
  * @param g the green portion to set (0-255)
  * @param b the blue portion to set (0-255)
  */
 public abstract void setColourRGB(Colour c, int r, int g, int b);
Пример #11
0
        /**
         * Copy constructor.  Used for copying writable formats, typically
         * when duplicating formats to handle merged cells
         *
         * @param fmt XFRecord
         */
        protected XFRecord(XFRecord fmt)
            : base(Type.XF)
        {
            initialized = false;
            locked = fmt.locked;
            hidden = fmt.hidden;
            align = fmt.align;
            valign = fmt.valign;
            orientation = fmt.orientation;
            wrap = fmt.wrap;
            leftBorder = fmt.leftBorder;
            rightBorder = fmt.rightBorder;
            topBorder = fmt.topBorder;
            bottomBorder = fmt.bottomBorder;
            leftBorderColour = fmt.leftBorderColour;
            rightBorderColour = fmt.rightBorderColour;
            topBorderColour = fmt.topBorderColour;
            bottomBorderColour = fmt.bottomBorderColour;
            pattern = fmt.pattern;
            xfFormatType = fmt.xfFormatType;
            indentation = fmt.indentation;
            shrinkToFit = fmt.shrinkToFit;
            parentFormat = fmt.parentFormat;
            backgroundColour = fmt.backgroundColour;

            // Shallow copy is sufficient for these purposes
            font = fmt.font;
            format = fmt.format;

            fontIndex = fmt.fontIndex;
            formatIndex = fmt.formatIndex;

            formatInfoInitialized = fmt.formatInfoInitialized;

            biffType = biff8;
            read = false;
            copied = true;
        }
Пример #12
0
        /**
         * A constructor used when creating a writable record
         *
         * @param fnt the font
         * @param form the format
         */
        public XFRecord(FontRecord fnt,DisplayFormat form)
            : base(Type.XF)
        {
            initialized = false;
            locked = true;
            hidden = false;
            align = Alignment.GENERAL;
            valign = VerticalAlignment.BOTTOM;
            orientation = Orientation.HORIZONTAL;
            wrap = false;
            leftBorder = BorderLineStyle.NONE;
            rightBorder = BorderLineStyle.NONE;
            topBorder = BorderLineStyle.NONE;
            bottomBorder = BorderLineStyle.NONE;
            leftBorderColour = Colour.AUTOMATIC;
            rightBorderColour = Colour.AUTOMATIC;
            topBorderColour = Colour.AUTOMATIC;
            bottomBorderColour = Colour.AUTOMATIC;
            pattern = Pattern.NONE;
            backgroundColour = Colour.DEFAULT_BACKGROUND;
            indentation = 0;
            shrinkToFit = false;
            usedAttributes = (byte)(USE_FONT | USE_FORMAT |
                                 USE_BACKGROUND | USE_ALIGNMENT | USE_BORDER);

            // This will be set by the initialize method and the subclass respectively
            parentFormat = 0;
            xfFormatType = null;

            font = fnt;
            format = form;
            biffType = biff8;
            read = false;
            copied = false;
            formatInfoInitialized = true;

            Assert.verify(font != null);
            Assert.verify(format != null);
        }
Пример #13
0
        /**
         * Initializes the internal format information from the data read in
         */
        private void initializeFormatInformation()
        {
            // 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;
        }
 /**
  * Sets the specified border for this format
  *
  * @param b the border
  * @param ls the border line style
  * @param c the colour of the specified border
  * @exception jxl.write.WriteException
  */
 public override void setBorder(Border b, BorderLineStyle ls, Colour c)
 {
     base.setBorder(b, ls, c);
 }
Пример #15
0
 /**
  * Creates a font of the specified face, point size, bold style,
  * italicisation, underline style, colour, and script
  * style (superscript/subscript)
  *
  * @param ps the point size
  * @param bs the bold style
  * @param us the underline style
  * @param fn the font name
  * @param it the italic flag
  * @param c the colour
  * @param ss the script style
  * @deprecated use jxl.write.WritableFont
  */
 public Font(FontName fn,
     int ps,
     BoldStyle bs,
     bool it,
     UnderlineStyle us,
     Colour c,
     ScriptStyle ss)
     : base(fn,ps,bs,it,us,c,ss)
 {
 }
Пример #16
0
 /**
  * Creates a font of the specified face, point size, bold style,
  * italicisation, underline style and colour
  *
  * @param ps the point size
  * @param bs the bold style
  * @param us the underline style
  * @param fn the font name
  * @param it italic flag
  * @param c the colour
  */
 public WritableFont(FontName fn,
     int ps,
     BoldStyle bs,
     bool it,
     UnderlineStyle us,
     Colour c)
     : this(fn, ps, bs, it, us, c, ScriptStyle.NORMAL_SCRIPT)
 {
 }
Пример #17
0
        /**
         * Sets the border style for cells with this format
         *
         * @exception WriteException
         * @param b the border
         * @param ls the line for the specified border
         */
        public virtual void setBorder(Border b, BorderLineStyle ls, Colour c)
        {
            if (isInitialized())
                {
                throw new JxlWriteException(JxlWriteException.formatInitialized);
                }

            if (b == Border.ALL)
                {
                // Apply to all
                base.setXFBorder(Border.LEFT, ls, c);
                base.setXFBorder(Border.RIGHT, ls, c);
                base.setXFBorder(Border.TOP, ls, c);
                base.setXFBorder(Border.BOTTOM, ls, c);
                return;
                }

            if (b == Border.NONE)
                {
                // Apply to all
                base.setXFBorder(Border.LEFT, BorderLineStyle.NONE, Colour.BLACK);
                base.setXFBorder(Border.RIGHT, BorderLineStyle.NONE, Colour.BLACK);
                base.setXFBorder(Border.TOP, BorderLineStyle.NONE, Colour.BLACK);
                base.setXFBorder(Border.BOTTOM, BorderLineStyle.NONE, Colour.BLACK);
                return;
                }

            base.setXFBorder(b, ls, c);
        }
Пример #18
0
 /**
  * Sets the colour for this font, if the font hasn't been
  * initialized
  *
  * @param colour the colour
  * @exception WriteException, if this font is already in use elsewhere
  */
 public void setColour(Colour colour)
 {
     base.setColour(colour.getValue());
 }
Пример #19
0
 /**
  * Sets the horizontal alignment for the data in this cell.
  * This method should only be called from its writable subclass
  * CellXFRecord
  *
  * @param c the background colour
  * @param p the background pattern
  */
 protected void setXFBackground(Colour c,Pattern p)
 {
     Assert.verify(!initialized);
     backgroundColour = c;
     pattern = p;
     usedAttributes |= USE_BACKGROUND;
 }