Commit 544ff7de authored by Alexander.Trofimov's avatar Alexander.Trofimov

fix position column data headers

parent f5f0660f
...@@ -2759,8 +2759,11 @@ CT_pivotTableDefinition.prototype.contains = function (col, row) { ...@@ -2759,8 +2759,11 @@ CT_pivotTableDefinition.prototype.contains = function (col, row) {
CT_pivotTableDefinition.prototype.getRange = function () { CT_pivotTableDefinition.prototype.getRange = function () {
return this.location && this.location.ref; return this.location && this.location.ref;
}; };
CT_pivotTableDefinition.prototype.getFirstHeaderRow = function () { CT_pivotTableDefinition.prototype.getFirstHeaderRow0 = function () {
return this.location && this.location.firstHeaderRow; return this.location && (this.location.firstHeaderRow + this.getColumnFieldsCount() - 1);
};
CT_pivotTableDefinition.prototype.getFirstDataCol = function () {
return this.location && this.location.firstDataCol;
}; };
CT_pivotTableDefinition.prototype.getColumnFieldsCount = function (withoutValues) { CT_pivotTableDefinition.prototype.getColumnFieldsCount = function (withoutValues) {
var res = 0; var res = 0;
......
...@@ -5211,8 +5211,8 @@ ...@@ -5211,8 +5211,8 @@
} }
}; };
Worksheet.prototype.updatePivotTablesStyle = function (range) { Worksheet.prototype.updatePivotTablesStyle = function (range) {
var pivotTable, pivotRange, styleInfo, style, wholeStyle, cells, j, r, pos, firstHeaderRow0, countC, var pivotTable, pivotRange, styleInfo, style, wholeStyle, cells, j, r, pos, firstHeaderRow0, firstDataCol0,
countCWValues, countR, countD, stripe1, stripe2, items, item, start, countC, countCWValues, countR, countD, stripe1, stripe2, items, item, start,
emptyStripe = new Asc.CTableStyleElement(); emptyStripe = new Asc.CTableStyleElement();
var dxf, dxfLabels, dxfValues, grandColumn; var dxf, dxfLabels, dxfValues, grandColumn;
for (var i = 0; i < this.pivotTables.length; ++i) { for (var i = 0; i < this.pivotTables.length; ++i) {
...@@ -5255,7 +5255,8 @@ ...@@ -5255,7 +5255,8 @@
continue; continue;
} }
firstHeaderRow0 = pivotTable.getFirstHeaderRow() + countC - 1; firstHeaderRow0 = pivotTable.getFirstHeaderRow0();
firstDataCol0 = pivotTable.getFirstDataCol();
countD = pivotTable.getDataFieldsCount(); countD = pivotTable.getDataFieldsCount();
countCWValues = pivotTable.getColumnFieldsCount(true); countCWValues = pivotTable.getColumnFieldsCount(true);
...@@ -5266,7 +5267,7 @@ ...@@ -5266,7 +5267,7 @@
if (styleInfo.showColStripes) { if (styleInfo.showColStripes) {
stripe1 = style.firstColumnStripe || emptyStripe; stripe1 = style.firstColumnStripe || emptyStripe;
stripe2 = style.secondColumnStripe || emptyStripe; stripe2 = style.secondColumnStripe || emptyStripe;
start = pivotRange.c1 + countR; start = pivotRange.c1 + firstDataCol0;
if (stripe1.dxf) { if (stripe1.dxf) {
cells = this.getRange3(pivotRange.r1, start, pivotRange.r2, pivotRange.c2); cells = this.getRange3(pivotRange.r1, start, pivotRange.r2, pivotRange.c2);
cells.setTableStyle(stripe1.dxf, new Asc.CTableStyleStripe(stripe1.size, stripe2.size)); cells.setTableStyle(stripe1.dxf, new Asc.CTableStyleStripe(stripe1.size, stripe2.size));
...@@ -5294,8 +5295,8 @@ ...@@ -5294,8 +5295,8 @@
// First Column // First Column
dxf = style.firstColumn && style.firstColumn.dxf; dxf = style.firstColumn && style.firstColumn.dxf;
if (styleInfo.showRowHeaders && countR && dxf) { if (styleInfo.showRowHeaders && countR && dxf) {
cells = this.getRange3(pivotRange.r1, pivotRange.c1, pivotRange.r2, cells = this.getRange3(pivotRange.r1, pivotRange.c1, pivotRange.r2, pivotRange.c1 +
pivotRange.c1 + Math.max(0, countR - 1)); Math.max(0, firstDataCol0 - 1));
cells.setTableStyle(dxf); cells.setTableStyle(dxf);
} }
...@@ -5310,14 +5311,14 @@ ...@@ -5310,14 +5311,14 @@
dxf = style.firstHeaderCell && style.firstHeaderCell.dxf; dxf = style.firstHeaderCell && style.firstHeaderCell.dxf;
if (styleInfo.showColHeaders && styleInfo.showRowHeaders && countCWValues && (countR + countD) && dxf) { if (styleInfo.showColHeaders && styleInfo.showRowHeaders && countCWValues && (countR + countD) && dxf) {
cells = this.getRange3(pivotRange.r1, pivotRange.c1, pivotRange.r1 + firstHeaderRow0 - (countR ? 1 : 0), cells = this.getRange3(pivotRange.r1, pivotRange.c1, pivotRange.r1 + firstHeaderRow0 - (countR ? 1 : 0),
pivotRange.c1 + Math.max(0, countR - 1)); pivotRange.c1 + Math.max(0, firstDataCol0 - 1));
cells.setTableStyle(dxf); cells.setTableStyle(dxf);
} }
// Subtotal Column // Subtotal Column
items = pivotTable.getColItems(); items = pivotTable.getColItems();
if (items) { if (items) {
start = pivotRange.c1 + countR; start = pivotRange.c1 + firstDataCol0;
for (j = 0; j < items.length; ++j) { for (j = 0; j < items.length; ++j) {
dxf = null; dxf = null;
item = items[j]; item = items[j];
...@@ -5380,7 +5381,7 @@ ...@@ -5380,7 +5381,7 @@
// Column Subheading // Column Subheading
items = pivotTable.getColItems(); items = pivotTable.getColItems();
if (items) { if (items) {
start = pivotRange.c1 + countR; start = pivotRange.c1 + firstDataCol0;
for (j = 0; j < countCWValues; ++j) { for (j = 0; j < countCWValues; ++j) {
if (0 === j) { if (0 === j) {
dxf = style.firstColumnSubheading; dxf = style.firstColumnSubheading;
...@@ -5456,7 +5457,7 @@ ...@@ -5456,7 +5457,7 @@
}; };
Worksheet.prototype.getPivotTableButtons = function (range) { Worksheet.prototype.getPivotTableButtons = function (range) {
var res = []; var res = [];
var pivotTable, pivotRange, j, pos, countC, countCWValues, countR, firstHeaderRow0, cell; var pivotTable, pivotRange, j, pos, countC, countCWValues, countR, cell;
for (var i = 0; i < this.pivotTables.length; ++i) { for (var i = 0; i < this.pivotTables.length; ++i) {
pivotTable = this.pivotTables[i]; pivotTable = this.pivotTables[i];
if (!pivotTable.intersection(range)) { if (!pivotTable.intersection(range)) {
...@@ -5476,16 +5477,15 @@ ...@@ -5476,16 +5477,15 @@
countCWValues = pivotTable.getColumnFieldsCount(true); countCWValues = pivotTable.getColumnFieldsCount(true);
countR = pivotTable.getRowFieldsCount(true); countR = pivotTable.getRowFieldsCount(true);
pivotRange = pivotTable.getRange(); pivotRange = pivotTable.getRange();
firstHeaderRow0 = pivotTable.getFirstHeaderRow() + countC - 1;
if (countR) { if (countR) {
cell = new AscCommon.CellBase(pivotRange.r1 + firstHeaderRow0, pivotRange.c1); cell = new AscCommon.CellBase(pivotRange.r1 + pivotTable.getFirstHeaderRow0(), pivotRange.c1);
if (range.contains2(cell)) { if (range.contains2(cell)) {
res.push(cell); res.push(cell);
} }
} }
if (countCWValues) { if (countCWValues) {
cell = new AscCommon.CellBase(pivotRange.r1, pivotRange.c1 + countR); cell = new AscCommon.CellBase(pivotRange.r1, pivotRange.c1 + pivotTable.getFirstDataCol());
if (range.contains2(cell)) { if (range.contains2(cell)) {
res.push(cell); res.push(cell);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment