OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 83 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
17 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.openoffice.spreadsheet;
15
 
20 ilm 16
import org.openconcerto.openoffice.Log;
17 ilm 17
import org.openconcerto.openoffice.ODDocument;
18
import org.openconcerto.openoffice.ODFrame;
19
import org.openconcerto.openoffice.ODValueType;
25 ilm 20
import org.openconcerto.openoffice.StyleDesc;
73 ilm 21
import org.openconcerto.openoffice.XMLVersion;
17 ilm 22
import org.openconcerto.openoffice.spreadsheet.BytesProducer.ByteArrayProducer;
23
import org.openconcerto.openoffice.spreadsheet.BytesProducer.ImageProducer;
73 ilm 24
import org.openconcerto.openoffice.spreadsheet.CellStyle.StyleTableCellProperties;
61 ilm 25
import org.openconcerto.openoffice.style.data.BooleanStyle;
20 ilm 26
import org.openconcerto.openoffice.style.data.DataStyle;
61 ilm 27
import org.openconcerto.openoffice.style.data.DateStyle;
17 ilm 28
import org.openconcerto.utils.FileUtils;
73 ilm 29
import org.openconcerto.utils.TimeUtils;
80 ilm 30
import org.openconcerto.utils.TimeUtils.DurationNullsChanger;
73 ilm 31
import org.openconcerto.utils.Tuple2;
25 ilm 32
import org.openconcerto.utils.Tuple3;
17 ilm 33
 
34
import java.awt.Color;
35
import java.awt.Image;
21 ilm 36
import java.awt.Point;
17 ilm 37
import java.io.File;
38
import java.io.IOException;
39
import java.text.DateFormat;
40
import java.text.DecimalFormat;
41
import java.text.NumberFormat;
20 ilm 42
import java.util.Calendar;
17 ilm 43
import java.util.Date;
44
import java.util.List;
61 ilm 45
import java.util.Locale;
65 ilm 46
import java.util.logging.Level;
17 ilm 47
 
25 ilm 48
import javax.xml.datatype.Duration;
49
 
17 ilm 50
import org.jdom.Attribute;
51
import org.jdom.Element;
52
import org.jdom.Namespace;
53
import org.jdom.Text;
54
 
55
/**
56
 * A cell whose value can be changed.
57
 *
58
 * @author Sylvain
59
 * @param <D> type of document
60
 */
61
public class MutableCell<D extends ODDocument> extends Cell<D> {
62
 
20 ilm 63
    static private final DateFormat TextPDateFormat = DateFormat.getDateInstance();
64
    static private final DateFormat TextPTimeFormat = DateFormat.getTimeInstance();
25 ilm 65
    static private final NumberFormat TextPMinuteSecondFormat = new DecimalFormat("00.###");
20 ilm 66
    static private final NumberFormat TextPFloatFormat = DecimalFormat.getNumberInstance();
67
    static private final NumberFormat TextPPercentFormat = DecimalFormat.getPercentInstance();
68
    static private final NumberFormat TextPCurrencyFormat = DecimalFormat.getCurrencyInstance();
17 ilm 69
 
20 ilm 70
    static public String formatNumber(Number n, final CellStyle defaultStyle) {
73 ilm 71
        return formatNumber(TextPFloatFormat, n, defaultStyle);
20 ilm 72
    }
73
 
74
    static public String formatPercent(Number n, final CellStyle defaultStyle) {
73 ilm 75
        return formatNumber(TextPPercentFormat, n, defaultStyle);
20 ilm 76
    }
77
 
78
    static public String formatCurrency(Number n, final CellStyle defaultStyle) {
73 ilm 79
        return formatNumber(TextPCurrencyFormat, n, defaultStyle);
20 ilm 80
    }
81
 
73 ilm 82
    static private String formatNumber(NumberFormat format, Number n, final CellStyle defaultStyle) {
20 ilm 83
        synchronized (format) {
84
            final int decPlaces = DataStyle.getDecimalPlaces(defaultStyle);
73 ilm 85
            format.setMinimumFractionDigits(0);
20 ilm 86
            format.setMaximumFractionDigits(decPlaces);
87
            return format.format(n);
88
        }
89
    }
90
 
80 ilm 91
    static private boolean LO_MODE = true;
92
    // no date part, all time part to zero
93
    static private final DurationNullsChanger TIME_NULLS = new TimeUtils.DurationNullsBuilder(TimeUtils.EmptyFieldPolicy.SET_TO_ZERO).setToNull(TimeUtils.getDateFields()).build();
94
 
95
    public static void setTimeValueMode(boolean loMode) {
96
        LO_MODE = loMode;
97
    }
98
 
99
    /**
100
     * Whether {@link #setValue(Object)} formats {@link Duration} using the standard way or using
101
     * the LibreOffice way. LibreOffice does not support years, months and days in cells ; even set
102
     * to 0 (it does in user meta fields). The initial value is <code>true</code>.
103
     *
104
     * @return <code>true</code> if durations should be formatted the LibO way.
105
     */
106
    public static boolean getTimeValueMode() {
107
        return LO_MODE;
108
    }
109
 
25 ilm 110
    MutableCell(Row<D> parent, Element elem, StyleDesc<CellStyle> styleDesc) {
111
        super(parent, elem, styleDesc);
17 ilm 112
    }
113
 
114
    // ask our column to our row so we don't have to update anything when columns are removed/added
115
    public final int getX() {
116
        return this.getRow().getX(this);
117
    }
118
 
119
    public final int getY() {
120
        return this.getRow().getY();
121
    }
122
 
21 ilm 123
    public final Point getPoint() {
124
        return new Point(getX(), getY());
125
    }
126
 
127
    final void setRowsSpanned(final int rowsSpanned) {
128
        if (rowsSpanned <= 1)
129
            this.getElement().removeAttribute("number-rows-spanned", getNS().getTABLE());
130
        else
131
            this.getElement().setAttribute("number-rows-spanned", String.valueOf(rowsSpanned), getNS().getTABLE());
132
    }
133
 
17 ilm 134
    // *** setValue
135
 
136
    private void setValueAttributes(ODValueType type, Object val) {
73 ilm 137
        final Namespace valueNS = getValueNS();
138
        final Attribute valueTypeAttr = this.getElement().getAttribute("value-type", valueNS);
67 ilm 139
        // e.g. DATE
140
        final ODValueType currentType = valueTypeAttr == null ? null : ODValueType.get(valueTypeAttr.getValue());
141
 
17 ilm 142
        if (type == null) {
143
            if (valueTypeAttr != null) {
144
                valueTypeAttr.detach();
145
            }
146
        } else {
73 ilm 147
            if (!type.equals(currentType)) {
148
                if (valueTypeAttr != null) {
149
                    valueTypeAttr.setValue(type.getName());
150
                } else {
151
                    // create an instance of Attribute to avoid a getAttribute() in the simpler
152
                    // setAttribute()
153
                    this.getElement().setAttribute(new Attribute("value-type", type.getName(), valueNS));
154
                }
155
            }
17 ilm 156
        }
73 ilm 157
 
158
        // remove old value attribute (assume Element is valid, otherwise we would need to remove
159
        // all possible value attributes)
160
        if (currentType != null && (!currentType.equals(type) || type == ODValueType.STRING)) {
161
            // e.g. @date-value
162
            this.getElement().removeAttribute(currentType.getValueAttribute(), valueNS);
163
        }
164
        // Like LO, do not generate string-value
165
        if (type != null && type != ODValueType.STRING) {
80 ilm 166
            // LO cells don't support the full syntax of a duration (user meta fields do)
167
            // instead it support only values without nYnMnD
168
            if (type == ODValueType.TIME && getTimeValueMode()) {
169
                final Duration d = val instanceof Duration ? (Duration) val : TimeUtils.timePartToDuration((Calendar) val);
170
                val = TIME_NULLS.apply(getODDocument().getEpoch().normalizeToHours(d));
171
            }
73 ilm 172
            this.getElement().setAttribute(type.getValueAttribute(), type.format(val), valueNS);
173
        }
17 ilm 174
    }
175
 
176
    private void setTextP(String value) {
83 ilm 177
        if (value == null) {
17 ilm 178
            this.getElement().removeContent();
83 ilm 179
        } else {
180
            new Lines(this.getODDocument(), value).setText(getElement(), getTextValueMode());
17 ilm 181
        }
182
    }
183
 
184
    private void setValue(ODValueType type, Object value, String textP) {
132 ilm 185
        // as in LO, setting a cell value clears the formula
186
        this.setFormula(null);
17 ilm 187
        this.setValueAttributes(type, value);
188
        this.setTextP(textP);
189
    }
190
 
191
    public void clearValue() {
192
        this.setValue(null, null, null);
193
    }
194
 
195
    public void setValue(Object obj) {
25 ilm 196
        this.setValue(obj, true);
197
    }
198
 
199
    public void setValue(Object obj, final boolean allowTypeChange) throws UnsupportedOperationException {
20 ilm 200
        final ODValueType type;
201
        final ODValueType currentType = getValueType();
202
        // try to keep current type, since for example a Number can work with FLOAT, PERCENTAGE
203
        // and CURRENCY
204
        if (currentType != null && currentType.canFormat(obj.getClass())) {
205
            type = currentType;
206
        } else {
57 ilm 207
            final ODValueType tmp = ODValueType.forObject(obj);
208
            // allow any Object
209
            if (allowTypeChange && tmp == null) {
210
                type = ODValueType.STRING;
211
                obj = String.valueOf(obj);
212
            } else {
213
                type = tmp;
214
            }
25 ilm 215
        }
216
        if (type == null) {
20 ilm 217
            throw new IllegalArgumentException("Couldn't infer type of " + obj);
218
        }
25 ilm 219
        this.setValue(obj, type, allowTypeChange, true);
20 ilm 220
    }
221
 
222
    /**
223
     * Change the value of this cell.
224
     *
225
     * @param obj the new cell value.
226
     * @param vt the value type.
25 ilm 227
     * @param allowTypeChange if <code>true</code> <code>obj</code> and <code>vt</code> might be
228
     *        changed to allow the data style to format, e.g. from Boolean.FALSE to 0.
20 ilm 229
     * @param lenient <code>false</code> to throw an exception if we can't format according to the
230
     *        ODF, <code>true</code> to try best-effort.
231
     * @throws UnsupportedOperationException if <code>obj</code> couldn't be formatted.
232
     */
25 ilm 233
    public void setValue(Object obj, ODValueType vt, final boolean allowTypeChange, final boolean lenient) throws UnsupportedOperationException {
20 ilm 234
        final String text;
25 ilm 235
        final Tuple3<String, ODValueType, Object> formatted = format(obj, vt, !allowTypeChange, lenient);
236
        vt = formatted.get1();
237
        obj = formatted.get2();
20 ilm 238
 
25 ilm 239
        if (formatted.get0() != null) {
240
            text = formatted.get0();
20 ilm 241
        } else {
242
            // either there were no format or formatting failed
243
            if (vt == ODValueType.FLOAT) {
244
                text = formatNumber((Number) obj, getDefaultStyle());
245
            } else if (vt == ODValueType.PERCENTAGE) {
246
                text = formatPercent((Number) obj, getDefaultStyle());
247
            } else if (vt == ODValueType.CURRENCY) {
248
                text = formatCurrency((Number) obj, getDefaultStyle());
249
            } else if (vt == ODValueType.DATE) {
25 ilm 250
                final Date d;
251
                if (obj instanceof Calendar) {
252
                    d = ((Calendar) obj).getTime();
253
                } else {
254
                    d = (Date) obj;
255
                }
256
                text = TextPDateFormat.format(d);
20 ilm 257
            } else if (vt == ODValueType.TIME) {
25 ilm 258
                if (obj instanceof Duration) {
259
                    final Duration normalized = getODDocument().getEpoch().normalizeToHours((Duration) obj);
73 ilm 260
                    text = "" + normalized.getHours() + ':' + TextPMinuteSecondFormat.format(normalized.getMinutes()) + ':' + TextPMinuteSecondFormat.format(TimeUtils.getSeconds(normalized));
25 ilm 261
                } else {
262
                    text = TextPTimeFormat.format(((Calendar) obj).getTime());
263
                }
20 ilm 264
            } else if (vt == ODValueType.BOOLEAN) {
61 ilm 265
                // LO do not use the the document language but the system language
266
                // http://help.libreoffice.org/Common/Selecting_the_Document_Language
267
                Locale l = Locale.getDefault();
268
                // except of course if there's a data style
269
                final CellStyle s = getStyle();
270
                if (s != null) {
271
                    final DataStyle ds = s.getDataStyle();
272
                    if (ds != null)
273
                        l = DateStyle.getLocale(ds.getElement());
274
                }
275
                text = BooleanStyle.toString((Boolean) obj, l, lenient);
20 ilm 276
            } else if (vt == ODValueType.STRING) {
277
                text = obj.toString();
19 ilm 278
            } else {
20 ilm 279
                throw new IllegalStateException(vt + " unknown");
19 ilm 280
            }
20 ilm 281
        }
282
        this.setValue(vt, obj, text);
17 ilm 283
    }
284
 
25 ilm 285
    // return null String if no data style exists, or if one exists but we couldn't use it
286
    private Tuple3<String, ODValueType, Object> format(Object obj, ODValueType valueType, boolean onlyCast, boolean lenient) {
287
        String res = null;
20 ilm 288
        try {
25 ilm 289
            final Tuple3<DataStyle, ODValueType, Object> ds = getDataStyleAndValue(obj, valueType, onlyCast);
290
            if (ds != null) {
291
                obj = ds.get2();
292
                valueType = ds.get1();
293
                // act like OO, that is if we set a String to a Date cell, change the value and
294
                // value-type but leave the data-style untouched
295
                if (ds.get0().canFormat(obj.getClass()))
296
                    res = ds.get0().format(obj, getDefaultStyle(), lenient);
297
            }
20 ilm 298
        } catch (UnsupportedOperationException e) {
299
            if (lenient)
65 ilm 300
                Log.get().log(Level.WARNING, "Couldn't format", e);
20 ilm 301
            else
302
                throw e;
303
        }
25 ilm 304
        return Tuple3.create(res, valueType, obj);
20 ilm 305
    }
306
 
307
    public final DataStyle getDataStyle() {
25 ilm 308
        final Tuple3<DataStyle, ODValueType, Object> s = this.getDataStyleAndValue(this.getValue(), this.getValueType(), true);
309
        return s != null ? s.get0() : null;
310
    }
311
 
312
    private final Tuple3<DataStyle, ODValueType, Object> getDataStyleAndValue(Object obj, ODValueType valueType, boolean onlyCast) {
20 ilm 313
        final CellStyle s = this.getStyle();
73 ilm 314
        return s != null ? s.getDataStyle(obj, valueType, onlyCast) : null;
20 ilm 315
    }
316
 
317
    protected final CellStyle getDefaultStyle() {
318
        return this.getRow().getSheet().getDefaultCellStyle();
319
    }
320
 
17 ilm 321
    public void replaceBy(String oldValue, String newValue) {
322
        replaceContentBy(this.getElement(), oldValue, newValue);
323
    }
324
 
325
    private void replaceContentBy(Element l, String oldValue, String newValue) {
20 ilm 326
        final List<?> content = l.getContent();
17 ilm 327
        for (int i = 0; i < content.size(); i++) {
328
            final Object obj = content.get(i);
329
            if (obj instanceof Text) {
330
                // System.err.println(" Text --> " + obj.toString());
331
                final Text t = (Text) obj;
332
                t.setText(t.getText().replaceAll(oldValue, newValue));
333
            } else if (obj instanceof Element) {
334
                replaceContentBy((Element) obj, oldValue, newValue);
335
            }
336
        }
337
    }
338
 
73 ilm 339
    /**
340
     * Set the raw value of the formula attribute.
341
     *
342
     * @param formula the raw value, e.g. "of:sum(A1:A2)".
343
     */
344
    public final void setRawFormula(final String formula) {
345
        // from 19.642 table:formula of OpenDocument-v1.2 : Whenever the initial text of a formula
346
        // has the appearance of an NCName followed by ":", an OpenDocument producer shall provide a
347
        // valid namespace prefix in order to eliminate any ambiguity.
132 ilm 348
        final String nsPrefix = formula == null ? null : getFormulaNSPrefix(formula).get0();
73 ilm 349
        if (nsPrefix != null && this.getElement().getNamespace(nsPrefix) == null) {
350
            throw new IllegalArgumentException("Unknown namespace prefix : " + nsPrefix);
351
        }
352
        this.setFormulaNoCheck(formula);
353
    }
354
 
355
    private final void setFormulaNoCheck(final String formula) {
132 ilm 356
        if (formula == null)
357
            this.getElement().removeAttribute("formula", getTABLE());
358
        else
359
            this.getElement().setAttribute("formula", formula, getTABLE());
73 ilm 360
    }
361
 
362
    public final void setFormulaAndNamespace(final Tuple2<Namespace, String> formula) {
363
        this.setFormulaAndNamespace(formula.get0(), formula.get1());
364
    }
365
 
366
    public final void setFormula(final String formula) {
367
        this.setFormulaAndNamespace(null, formula);
368
    }
369
 
370
    public final void setFormulaAndNamespace(final Namespace ns, final String formula) {
132 ilm 371
        if (formula == null) {
372
            this.setFormulaNoCheck(formula);
373
        } else if (getODDocument().getVersion() == XMLVersion.OOo) {
73 ilm 374
            if (ns != null)
375
                throw new IllegalArgumentException("Namespaces not supported by this version : " + ns);
376
            this.setFormulaNoCheck(formula);
377
        } else if (ns == null) {
378
            final String nsPrefix = getFormulaNSPrefix(formula).get0();
379
            if (nsPrefix != null) {
380
                // eliminate ambiguity
381
                final Namespace defaultNS = getDefaultFormulaNS();
382
                // prevent infinite recursion
383
                if (defaultNS == null)
384
                    throw new IllegalStateException("Cannot resolve ambiguity, formula appears to begin with " + nsPrefix + " and no default namespace found");
385
                this.setFormulaAndNamespace(defaultNS, formula);
386
            } else {
387
                this.setFormulaNoCheck(formula);
388
            }
389
        } else {
390
            final Namespace existingNS = this.getElement().getNamespace(ns.getPrefix());
391
            if (existingNS == null)
392
                this.getElement().getDocument().getRootElement().addNamespaceDeclaration(ns);
393
            else if (!existingNS.equals(ns))
394
                throw new IllegalStateException("Namespace conflict : " + existingNS + " != " + ns);
395
            this.setFormulaNoCheck(ns.getPrefix() + ':' + formula);
396
        }
397
    }
398
 
17 ilm 399
    public final void unmerge() {
400
        // from 8.1.3 Table Cell : table-cell are like covered-table-cell with some extra
401
        // optional attributes so it's safe to rename covered cells into normal ones
402
        final int x = this.getX();
403
        final int y = this.getY();
404
        final int columnsSpanned = getColumnsSpanned();
405
        final int rowsSpanned = getRowsSpanned();
406
        for (int i = 0; i < columnsSpanned; i++) {
407
            for (int j = 0; j < rowsSpanned; j++) {
408
                // don't mind if we change us at 0,0 we're already a table-cell
409
                this.getRow().getSheet().getImmutableCellAt(x + i, y + j).getElement().setName("table-cell");
410
            }
411
        }
412
        this.getElement().removeAttribute("number-columns-spanned", getNS().getTABLE());
413
        this.getElement().removeAttribute("number-rows-spanned", getNS().getTABLE());
414
    }
415
 
416
    /**
417
     * Merge this cell and the following ones. If this cell already spanned multiple columns/rows
418
     * this method un-merge any additional cells.
419
     *
420
     * @param columnsSpanned number of columns to merge.
421
     * @param rowsSpanned number of rows to merge.
422
     */
423
    public final void merge(final int columnsSpanned, final int rowsSpanned) {
424
        final int currentCols = this.getColumnsSpanned();
425
        final int currentRows = this.getRowsSpanned();
426
 
427
        // nothing to do
428
        if (columnsSpanned == currentCols && rowsSpanned == currentRows)
429
            return;
430
 
431
        final int x = this.getX();
432
        final int y = this.getY();
433
 
434
        // check for problems before any modifications
435
        for (int i = 0; i < columnsSpanned; i++) {
436
            for (int j = 0; j < rowsSpanned; j++) {
437
                final boolean coveredByThis = i < currentCols && j < currentRows;
438
                if (!coveredByThis) {
439
                    final int x2 = x + i;
440
                    final int y2 = y + j;
441
                    final Cell<D> immutableCell = this.getRow().getSheet().getImmutableCellAt(x2, y2);
442
                    // check for overlapping range from inside
443
                    if (immutableCell.coversOtherCells())
444
                        throw new IllegalArgumentException("Cell at " + x2 + "," + y2 + " is a merged cell.");
445
                    // and outside
446
                    if (immutableCell.getElement().getName().equals("covered-table-cell"))
447
                        throw new IllegalArgumentException("Cell at " + x2 + "," + y2 + " is already covered.");
448
                }
449
            }
450
        }
451
 
452
        final boolean shrinks = columnsSpanned < currentCols || rowsSpanned < currentRows;
453
        if (shrinks)
454
            this.unmerge();
455
 
456
        // from 8.1.3 Table Cell : table-cell are like covered-table-cell with some extra
457
        // optional attributes so it's safe to rename
458
        for (int i = 0; i < columnsSpanned; i++) {
459
            for (int j = 0; j < rowsSpanned; j++) {
460
                final boolean coveredByThis = i < currentCols && j < currentRows;
461
                // don't cover this,
462
                // if we grow the current covered cells are invalid so don't try to access them
463
                if ((i != 0 || j != 0) && (shrinks || !coveredByThis))
464
                    // MutableCell is needed to break repeated
465
                    this.getRow().getSheet().getCellAt(x + i, y + j).getElement().setName("covered-table-cell");
466
            }
467
        }
468
        this.getElement().setAttribute("number-columns-spanned", columnsSpanned + "", getNS().getTABLE());
469
        this.getElement().setAttribute("number-rows-spanned", rowsSpanned + "", getNS().getTABLE());
470
    }
471
 
472
    @Override
473
    public final String getStyleName() {
474
        return this.getRow().getSheet().getStyleNameAt(this.getX(), this.getY());
475
    }
476
 
73 ilm 477
    public final StyleTableCellProperties getTableCellProperties() {
478
        return this.getRow().getSheet().getTableCellPropertiesAt(this.getX(), this.getY());
479
    }
480
 
17 ilm 481
    public void setImage(final File pic) throws IOException {
482
        this.setImage(pic, false);
483
    }
484
 
485
    public void setImage(final File pic, boolean keepRatio) throws IOException {
486
        this.setImage(pic.getName(), new ByteArrayProducer(FileUtils.readBytes(pic), keepRatio));
487
    }
488
 
489
    public void setImage(final String name, final Image img) throws IOException {
490
        this.setImage(name, img == null ? null : new ImageProducer(img, true));
491
    }
492
 
493
    private void setImage(final String name, final BytesProducer data) {
494
        final Namespace draw = this.getNS().getNS("draw");
495
        final Element frame = this.getElement().getChild("frame", draw);
496
        final Element imageElem = frame == null ? null : frame.getChild("image", draw);
497
 
498
        if (imageElem != null) {
499
            final Attribute refAttr = imageElem.getAttribute("href", this.getNS().getNS("xlink"));
500
            this.getODDocument().getPackage().putFile(refAttr.getValue(), null);
501
 
502
            if (data == null)
503
                frame.detach();
504
            else {
505
                refAttr.setValue("Pictures/" + name + (data.getFormat() != null ? "." + data.getFormat() : ""));
506
                this.getODDocument().getPackage().putFile(refAttr.getValue(), data.getBytes(new ODFrame<D>(getODDocument(), frame)));
507
            }
508
        } else if (data != null)
509
            throw new IllegalStateException("this cell doesn't contain an image: " + this);
510
    }
511
 
512
    public final void setBackgroundColor(final Color color) {
73 ilm 513
        this.getPrivateStyle().getTableCellProperties(this).setBackgroundColor(color);
17 ilm 514
    }
515
}