OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 80 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 80 Rev 93
Line 27... Line 27...
27
import org.openconcerto.utils.Tuple2;
27
import org.openconcerto.utils.Tuple2;
28
import org.openconcerto.xml.JDOMUtils;
28
import org.openconcerto.xml.JDOMUtils;
29
import org.openconcerto.xml.SimpleXMLPath;
29
import org.openconcerto.xml.SimpleXMLPath;
30
 
30
 
31
import java.awt.Point;
31
import java.awt.Point;
32
import java.math.BigDecimal;
-
 
33
import java.util.ArrayList;
32
import java.util.ArrayList;
34
import java.util.HashMap;
33
import java.util.HashMap;
35
import java.util.HashSet;
34
import java.util.HashSet;
36
import java.util.List;
35
import java.util.List;
37
import java.util.Map;
36
import java.util.Map;
Line 362... Line 361...
362
                        newEndY = endCellPoint.y + nth * count;
361
                        newEndY = endCellPoint.y + nth * count;
363
                    } else {
362
                    } else {
364
                        // we must use height to compute new values for end-cell-address and end-y
363
                        // we must use height to compute new values for end-cell-address and end-y
365
 
364
 
366
                        // find the height of the shape
365
                        // find the height of the shape
367
                        final LengthUnit unit = LengthUnit.MM;
-
 
368
                        final BigDecimal[] coordinates = getODDocument().getFormatVersion().getXML().getCoordinates(endCellParentElem, unit, false, true);
366
                        final Length[] coordinates = getODDocument().getFormatVersion().getXML().getCoordinates(endCellParentElem, false, true);
369
                        if (coordinates == null)
367
                        if (coordinates == null)
370
                            throw new IllegalStateException("Couldn't find the height of the shape : " + JDOMUtils.output(endCellParentElem));
368
                            throw new IllegalStateException("Couldn't find the height of the shape : " + JDOMUtils.output(endCellParentElem));
371
                        final BigDecimal endYFromAnchor = coordinates[3];
369
                        final Length endYFromAnchor = coordinates[3];
372
                        assert endYFromAnchor != null : "getCoordinates() should never return null BigDecimal (unless requested by horizontal/vertical)";
370
                        assert endYFromAnchor != null : "getCoordinates() should never return null BigDecimal (unless requested by horizontal/vertical)";
373
                        // find the end row
371
                        // find the end row
374
                        int rowIndex = startRowIndex;
372
                        int rowIndex = startRowIndex;
375
                        BigDecimal cellEndYFromAnchor = getRow(rowIndex).getStyle().getTableRowProperties().getHeight(unit);
373
                        Length cellEndYFromAnchor = getRow(rowIndex).getStyle().getTableRowProperties().getHeight();
376
                        while (endYFromAnchor.compareTo(cellEndYFromAnchor) > 0) {
374
                        while (endYFromAnchor.compareTo(cellEndYFromAnchor) > 0) {
377
                            rowIndex++;
375
                            rowIndex++;
378
                            cellEndYFromAnchor = cellEndYFromAnchor.add(getRow(rowIndex).getStyle().getTableRowProperties().getHeight(unit));
376
                            cellEndYFromAnchor = cellEndYFromAnchor.add(getRow(rowIndex).getStyle().getTableRowProperties().getHeight());
379
                        }
377
                        }
380
                        // find the end-y
378
                        // find the end-y
381
                        final BigDecimal cellStartYFromAnchor = cellEndYFromAnchor.subtract(getRow(rowIndex).getStyle().getTableRowProperties().getHeight(unit));
379
                        final Length cellStartYFromAnchor = cellEndYFromAnchor.subtract(getRow(rowIndex).getStyle().getTableRowProperties().getHeight());
382
                        final BigDecimal endY = endYFromAnchor.subtract(cellStartYFromAnchor);
380
                        final Length endY = endYFromAnchor.subtract(cellStartYFromAnchor);
383
                        assert endY.signum() >= 0;
381
                        assert endY.signum() >= 0;
384
 
382
 
385
                        newEndY = rowIndex;
383
                        newEndY = rowIndex;
386
                        endCellParentElem.setAttribute("end-y", unit.format(endY), getTABLE());
384
                        endCellParentElem.setAttribute("end-y", endY.format(), getTABLE());
387
                    }
385
                    }
388
                    endCellAttr.setValue(SpreadSheet.formatSheetName(endCellSheet.getName()) + "." + Table.getAddress(new Point(endCellPoint.x, newEndY)));
386
                    endCellAttr.setValue(SpreadSheet.formatSheetName(endCellSheet.getName()) + "." + Table.getAddress(new Point(endCellPoint.x, newEndY)));
389
                }
387
                }
390
            }
388
            }
391
        }
389
        }
Line 631... Line 629...
631
        return this.getImmutableCellAt(ref).getValue();
629
        return this.getImmutableCellAt(ref).getValue();
632
    }
630
    }
633
 
631
 
634
    // *** get count
632
    // *** get count
635
 
633
 
-
 
634
    // not public since Row represent the physical (XML) row, i.e. it can represent many logical
-
 
635
    // rows. Ideally two classes should be created (as Cell/MutableCell), but this would only be
-
 
636
    // useful for changing style (e.g. setHeight()).
-
 
637
 
636
    final Row<D> getRow(int index) {
638
    final Row<D> getRow(int index) {
637
        return this.rows.get(index);
639
        return this.rows.get(index);
638
    }
640
    }
639
 
641
 
640
    final Row<D> getMutableRow(int y) {
642
    final Row<D> getMutableRow(int y) {
Line 645... Line 647...
645
        } else {
647
        } else {
646
            return c;
648
            return c;
647
        }
649
        }
648
    }
650
    }
649
 
651
 
-
 
652
    // OK to use immutable row since for now RowStyle has no setter (except for raw methods in super
-
 
653
    // classes)
-
 
654
    public final RowStyle getRowStyle(int index) {
-
 
655
        return this.getRow(index).getStyle();
-
 
656
    }
-
 
657
 
650
    public final Column<D> getColumn(int i) {
658
    public final Column<D> getColumn(int i) {
651
        return this.cols.get(i);
659
        return this.cols.get(i);
652
    }
660
    }
653
 
661
 
-
 
662
    public final ColumnStyle getColumnStyle(int index) {
-
 
663
        return this.getColumn(index).getStyle();
-
 
664
    }
-
 
665
 
654
    public final int getRowCount() {
666
    public final int getRowCount() {
655
        return this.rows.size();
667
        return this.rows.size();
656
    }
668
    }
657
 
669
 
658
    public final TableGroup getRowGroup() {
670
    public final TableGroup getRowGroup() {