Commit 9e7980ad authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил fitToWidth и fitToHeight. Методы и реализацию.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@67845 954022d7-b5bf-4e40-9824-e11837661b57
parent d004ae41
......@@ -1170,6 +1170,11 @@
// Вид печати
this.layoutPageType = c_oAscLayoutPageType.ActualSize;
// По ширине
this.fitToWidth = false;
// По высоте
this.fitToHeight = false;
return this;
}
asc_CAdjustPrint.prototype.asc_getPrintType = function () { return this.printType; };
......@@ -1177,6 +1182,11 @@
asc_CAdjustPrint.prototype.asc_setPrintType = function (val) { this.printType = val; };
asc_CAdjustPrint.prototype.asc_setLayoutPageType = function (val) { this.layoutPageType = val; };
asc_CAdjustPrint.prototype.getFitToWidth = function () { return this.fitToWidth; };
asc_CAdjustPrint.prototype.getFitToHeight = function () { this.fitToHeight; };
asc_CAdjustPrint.prototype.asc_setFitToWidth = function (val) { this.fitToWidth = val; };
asc_CAdjustPrint.prototype.asc_setFitToHeight = function (val) { this.fitToHeight = val; };
/** @constructor */
function asc_CLockInfo () {
this["sheetId"] = null;
......@@ -1667,6 +1677,8 @@
prot["asc_getLayoutPageType"] = prot.asc_getLayoutPageType;
prot["asc_setPrintType"] = prot.asc_setPrintType;
prot["asc_setLayoutPageType"] = prot.asc_setLayoutPageType;
prot["asc_setFitToWidth"] = prot.asc_setFitToWidth;
prot["asc_setFitToHeight"] = prot.asc_setFitToHeight;
window["Asc"].asc_CLockInfo = asc_CLockInfo;
......
......@@ -2153,17 +2153,19 @@
var activeWs;
var printPagesData = new asc_CPrintPagesData();
var printType = adjustPrint.asc_getPrintType();
var layoutPageType = adjustPrint.asc_getLayoutPageType();
// var layoutPageType = adjustPrint.asc_getLayoutPageType();
var bFitToWidth = adjustPrint.getFitToWidth();
var bFitToHeight = adjustPrint.getFitToHeight();
if (printType == c_oAscPrintType.ActiveSheets) {
activeWs = wb.getActive();
ws = this.getWorksheet();
printPagesData.arrPages = ws.calcPagesPrint (wb.getWorksheet(activeWs).PagePrintOptions, /*printOnlySelection*/false, /*indexWorksheet*/activeWs, layoutPageType);
printPagesData.arrPages = ws.calcPagesPrint(wb.getWorksheet(activeWs).PagePrintOptions, /*printOnlySelection*/false, /*indexWorksheet*/activeWs, bFitToWidth, bFitToHeight);
} else if (printType == c_oAscPrintType.EntireWorkbook) {
// Колличество листов
var countWorksheets = this.model.getWorksheetCount();
for (var i = 0; i < countWorksheets; ++i) {
ws = this.getWorksheet(i);
var arrPages = ws.calcPagesPrint (wb.getWorksheet(i).PagePrintOptions, /*printOnlySelection*/false, /*indexWorksheet*/i, layoutPageType);
var arrPages = ws.calcPagesPrint(wb.getWorksheet(i).PagePrintOptions, /*printOnlySelection*/false, /*indexWorksheet*/i, bFitToWidth, bFitToHeight);
if (null !== arrPages) {
if (null === printPagesData.arrPages)
printPagesData.arrPages = [];
......@@ -2173,7 +2175,7 @@
} else if (printType == c_oAscPrintType.Selection) {
activeWs = wb.getActive();
ws = this.getWorksheet();
printPagesData.arrPages = ws.calcPagesPrint (wb.getWorksheet(activeWs).PagePrintOptions, /*printOnlySelection*/true, /*indexWorksheet*/activeWs, layoutPageType);
printPagesData.arrPages = ws.calcPagesPrint(wb.getWorksheet(activeWs).PagePrintOptions, /*printOnlySelection*/true, /*indexWorksheet*/activeWs, bFitToWidth, bFitToHeight);
}
return printPagesData;
......
......@@ -1640,7 +1640,7 @@
};
// ----- Drawing for print -----
WorksheetView.prototype.calcPagesPrint = function(pageOptions, printOnlySelection, indexWorksheet, layoutPageType) {
WorksheetView.prototype.calcPagesPrint = function(pageOptions, printOnlySelection, indexWorksheet, bFitToWidth, bFitToHeight) {
var range;
var maxCols = this.model.getColsCount();
var maxRows = this.model.getRowsCount();
......@@ -1796,7 +1796,7 @@
for (rowIndex = currentRowIndex; rowIndex < maxRows; ++rowIndex) {
var currentRowHeight = this.rows[rowIndex].height;
if (currentHeight + currentRowHeight > pageHeightWithFieldsHeadings) {
if (!bFitToHeight && currentHeight + currentRowHeight > pageHeightWithFieldsHeadings) {
// Закончили рисовать страницу
break;
}
......@@ -1809,13 +1809,13 @@
currentColWidth -= newPagePrint.startOffsetPt;
}
if (c_oAscLayoutPageType.FitToWidth !== layoutPageType && currentWidth + currentColWidth > pageWidthWithFieldsHeadings && colIndex !== currentColIndex) {
if (!bFitToWidth && currentWidth + currentColWidth > pageWidthWithFieldsHeadings && colIndex !== currentColIndex) {
break;
}
currentWidth += currentColWidth;
if (c_oAscLayoutPageType.FitToWidth !== layoutPageType && currentWidth > pageWidthWithFieldsHeadings && colIndex === currentColIndex) {
if (!bFitToWidth && currentWidth > pageWidthWithFieldsHeadings && colIndex === currentColIndex) {
// Смещаем в селедующий раз ячейку
bIsAddOffset = true;
++colIndex;
......@@ -1829,7 +1829,7 @@
currentWidth += this.cellsLeft;
}
if (c_oAscLayoutPageType.FitToWidth === layoutPageType) {
if (bFitToWidth) {
newPagePrint.pageClipRectWidth = Math.max(currentWidth, newPagePrint.pageClipRectWidth);
newPagePrint.pageWidth = newPagePrint.pageClipRectWidth * vector_koef + (pageLeftField + pageRightField);
} else {
......@@ -1841,6 +1841,11 @@
currentWidth = 0;
}
if (bFitToHeight) {
newPagePrint.pageClipRectHeight = Math.max(currentHeight, newPagePrint.pageClipRectHeight);
newPagePrint.pageHeight = newPagePrint.pageClipRectHeight * vector_koef + (pageTopField + pageBottomField);
}
// Нужно будет пересчитывать колонки
isCalcColumnsWidth = true;
......
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