From b484c7769930de3014540108917ee855f7eea51b Mon Sep 17 00:00:00 2001 From: "Alexander.Trofimov" Date: Fri, 5 Jul 2013 07:52:17 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B=20asc=5FgetSheetViewSettin?= =?UTF-8?q?gs=20=D0=B8=20asc=5FsetSheetViewSettings=20asc=5FCSheetViewSett?= =?UTF-8?q?ings:=20=09asc=5FgetShowGridLines=20=09asc=5FgetShowRowColHeade?= =?UTF-8?q?rs=20=09asc=5FsetShowGridLines=20=09asc=5FsetShowRowColHeaders?= =?UTF-8?q?=20=D0=A1=D0=B5=D1=82=D0=BA=D0=B0=20=D0=BE=D1=82=D1=80=D0=B8?= =?UTF-8?q?=D1=81=D0=BE=D0=B2=D1=8B=D0=B2=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20?= =?UTF-8?q?=D0=B2=20=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8=D0=BC=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B8=20=D0=BE=D1=82=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D1=80=D0=B0=20ToDo=20=D1=81=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=BD=D0=B5=20=D0=BE=D1=82=D1=80?= =?UTF-8?q?=D0=B8=D1=81=D0=BE=D0=B2=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D0=BE=D0=BB=D0=BE=D0=B2=D0=BA=D0=B8=20=D0=94=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=B2=20=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D1=8E=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B8=20=D0=BC=D0=B5=D0=BD=D1=8F=D1=82=D1=8C=20view?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47746 954022d7-b5bf-4e40-9824-e11837661b57 --- Excel/SpreadsheetTestMenu.html | 17 +++++++++++++++++ Excel/api.js | 10 ++++++++++ Excel/menu/menu.js | 29 +++++++++++++++++++++++++++++ Excel/model/Serialize.js | 16 ++++++++-------- Excel/utils/utils.js | 28 ++++++++++++++++++++++++++++ Excel/view/WorksheetView.js | 25 +++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 8 deletions(-) diff --git a/Excel/SpreadsheetTestMenu.html b/Excel/SpreadsheetTestMenu.html index 618412d7c5..ac2912be1f 100644 --- a/Excel/SpreadsheetTestMenu.html +++ b/Excel/SpreadsheetTestMenu.html @@ -1667,6 +1667,8 @@ + + + +
+ + + + +
diff --git a/Excel/api.js b/Excel/api.js index d8c0ac4651..f5950ce15e 100644 --- a/Excel/api.js +++ b/Excel/api.js @@ -1915,6 +1915,14 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; return this.wb.getWorksheet().getSelectionMergeInfo(options); }, + asc_getSheetViewSettings: function () { + return this.wb.getWorksheet().getSheetViewSettings(); + }, + + asc_setSheetViewSettings: function (options) { + this.wb.getWorksheet().changeWorksheet("sheetViewSettings", options); + }, + // Images & Charts asc_drawingObjectsExist: function(chart) { @@ -2804,6 +2812,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; prot["asc_sortCells"] = prot.asc_sortCells; prot["asc_emptyCells"] = prot.asc_emptyCells; prot["asc_mergeCellsDataLost"] = prot.asc_mergeCellsDataLost; + prot["asc_getSheetViewSettings"] = prot.asc_getSheetViewSettings; + prot["asc_setSheetViewSettings"] = prot.asc_setSheetViewSettings; // Auto filters interface prot["asc_addAutoFilter"] = prot.asc_addAutoFilter; diff --git a/Excel/menu/menu.js b/Excel/menu/menu.js index 6409131a36..5bc952fc0f 100644 --- a/Excel/menu/menu.js +++ b/Excel/menu/menu.js @@ -1,6 +1,7 @@ $(function () { var IsVisibleMenu = false, elem, contextGrad, gradient, gradSelectPosTop = 1, imgd, pix, colorSelecterClick, newColorSelected={r:255,g:0,b:0},lastColorSelected={r:255,g:0,b:0}; var autoFilterObj; + var g_sheetViewSettings = null; var docTitle = window.location.toString().match(/&title=([^&]+)&/); if (docTitle) { @@ -53,6 +54,10 @@ onTabClicked( api.asc_getActiveWorksheetIndex() ); } + function onActiveSheetChanged () { + updateSheetViewSettings(); + } + function showZoomValue() { $("#ws-navigation .ws-zoom-input") .val(Math.round(api.asc_getZoom() * 100) + "%"); @@ -176,6 +181,12 @@ consolelog("onEndAction " + arguments[0] + " " + arguments[1]); } + function updateSheetViewSettings () { + g_sheetViewSettings = api.asc_getSheetViewSettings(); + $("#showGridLines").attr("checked", g_sheetViewSettings.asc_getShowGridLines()); + $("#showHeaders").attr("checked", g_sheetViewSettings.asc_getShowRowColHeaders()); + } + function onTabNavigationBtnClicked(event) { var btn = $(event.currentTarget), tablist = $("#ws-navigation .tabs"), @@ -229,6 +240,7 @@ .removeClass("active") .eq(index).addClass("active"); api.asc_showWorksheet(index); + updateSheetViewSettings(); return true; } @@ -445,6 +457,8 @@ }); api.asc_registerCallback("asc_onSetAFDialog", onSetAFDialog); + + api.asc_registerCallback("asc_onActiveSheetChanged", onActiveSheetChanged); api.asc_registerCallback("asc_onConfirmAction", function(){ var arg = arguments; @@ -1616,6 +1630,14 @@ }); $("#drawingObjectsLayerMenu").dialog("open"); } + + function onChangeView () { + var showGridLines = document.getElementById("showGridLines"); + var showHeaders = document.getElementById("showHeaders"); + g_sheetViewSettings.asc_setShowGridLines(showGridLines.checked); + g_sheetViewSettings.asc_setShowRowColHeaders(showHeaders.checked); + api.asc_setSheetViewSettings(g_sheetViewSettings); + } // Comments @@ -2579,4 +2601,11 @@ api.asc_unGroupGraphicsObjects(); } ); + + $("#showGridLines").change(function () { + onChangeView(); + }); + $("#showHeaders").change(function () { + onChangeView(); + }); }); \ No newline at end of file diff --git a/Excel/model/Serialize.js b/Excel/model/Serialize.js index d066e3e4b3..529898ac50 100644 --- a/Excel/model/Serialize.js +++ b/Excel/model/Serialize.js @@ -2146,7 +2146,7 @@ function BinaryWorksheetsTableWriter(memory, wb, oSharedStrings, oDrawings, aDxf if(ws.aCols.length > 0 || null != ws.oAllCol) this.bs.WriteItem(c_oSerWorksheetsTypes.Cols, function(){oThis.WriteWorksheetCols(ws);}); - if (null != ws.sheetViews) + if (null !== ws.sheetViews) this.bs.WriteItem(c_oSerWorksheetsTypes.SheetViews, function(){oThis.WriteSheetViews(ws);}); this.bs.WriteItem(c_oSerWorksheetsTypes.SheetFormatPr, function(){oThis.WriteSheetFormatPr(ws);}); @@ -2342,15 +2342,15 @@ function BinaryWorksheetsTableWriter(memory, wb, oSharedStrings, oDrawings, aDxf } }; this.WriteSheetView = function (oSheetView) { - if (undefined !== oSheetView.ShowGridLines) { + if (null !== oSheetView.showGridLines) { this.memory.WriteByte(c_oSer_SheetView.ShowGridLines); this.memory.WriteByte(c_oSerPropLenType.Byte); - this.memory.WriteBool(oSheetView.ShowGridLines); + this.memory.WriteBool(oSheetView.showGridLines); } - if (undefined !== oSheetView.ShowRowColHeaders) { + if (null !== oSheetView.showRowColHeaders) { this.memory.WriteByte(c_oSer_SheetView.ShowRowColHeaders); this.memory.WriteByte(c_oSerPropLenType.Byte); - this.memory.WriteBool(oSheetView.ShowRowColHeaders); + this.memory.WriteBool(oSheetView.showRowColHeaders); } }; this.WriteSheetFormatPr = function(ws) @@ -5706,7 +5706,7 @@ function Binary_WorksheetTableReader(stream, wb, aSharedStrings, aCellXfs, Dxfs, var oSheetView = null; if (c_oSerWorksheetsTypes.SheetView === type) { - oSheetView = {}; + oSheetView = new Asc.asc_CSheetViewSettings(); res = this.bcr.Read1(length, function (t, l) { return oThis.ReadSheetView(t, l, oSheetView); }); @@ -5717,9 +5717,9 @@ function Binary_WorksheetTableReader(stream, wb, aSharedStrings, aCellXfs, Dxfs, this.ReadSheetView = function (type, length, oSheetView) { var res = c_oSerConstants.ReadOk; if (c_oSer_SheetView.ShowGridLines === type) { - oSheetView.ShowGridLines = this.stream.GetBool(); + oSheetView.showGridLines = this.stream.GetBool(); } else if (c_oSer_SheetView.ShowRowColHeaders === type) { - oSheetView.ShowRowColHeaders = this.stream.GetBool(); + oSheetView.showRowColHeaders = this.stream.GetBool(); } else res = c_oSerConstants.ReadUnknown; return res; diff --git a/Excel/utils/utils.js b/Excel/utils/utils.js index ba071214b1..8eec487fca 100644 --- a/Excel/utils/utils.js +++ b/Excel/utils/utils.js @@ -628,6 +628,27 @@ this["r2"] = r2; } + function asc_CSheetViewSettings () { + if (!(this instanceof asc_CSheetViewSettings)) { + return new asc_CSheetViewSettings(); + } + + // Показывать ли сетку + this.showGridLines = null; + // Показывать обозначения строк и столбцов + this.showRowColHeaders = null; + + return this; + } + + asc_CSheetViewSettings.prototype = { + constructor: asc_CSheetViewSettings, + asc_getShowGridLines: function () { return false !== this.showGridLines; }, + asc_getShowRowColHeaders: function () { return false !== this.showRowColHeaders; }, + asc_setShowGridLines: function (val) { this.showGridLines = val; }, + asc_setShowRowColHeaders: function (val) { this.showRowColHeaders = val; } + } + /* * Export @@ -742,5 +763,12 @@ window["Asc"].asc_CCollaborativeRange = asc_CCollaborativeRange; + window["Asc"]["asc_CSheetViewSettings"] = window["Asc"].asc_CSheetViewSettings = asc_CSheetViewSettings; + prot = asc_CSheetViewSettings.prototype; + prot["asc_getShowGridLines"] = prot.asc_getShowGridLines; + prot["asc_getShowRowColHeaders"] = prot.asc_getShowRowColHeaders; + prot["asc_setShowGridLines"] = prot.asc_setShowGridLines; + prot["asc_setShowRowColHeaders"] = prot.asc_setShowRowColHeaders; + } )(jQuery, window); diff --git a/Excel/view/WorksheetView.js b/Excel/view/WorksheetView.js index 458621387e..c83d210969 100644 --- a/Excel/view/WorksheetView.js +++ b/Excel/view/WorksheetView.js @@ -644,6 +644,13 @@ return ct ? $.extend({}, ct.metrics) : undefined; }, + getSheetViewSettings: function () { + if (null === this.model.sheetViews || 0 === this.model.sheetViews.length) + return new asc.asc_CSheetViewSettings(); + + return this.model.sheetViews[0]; + }, + // mouseX - это разница стартовых координат от мыши при нажатии и границы changeColumnWidth: function (col, x2, mouseX) { @@ -2176,6 +2183,11 @@ /** Рисует сетку таблицы */ _drawGrid: function (drawingCtx, range, leftFieldInPt, topFieldInPt, width, height) { + // Возможно сетку не нужно рисовать (при печати свои проверки) + if (undefined === drawingCtx && null !== this.model.sheetViews && + 0 < this.model.sheetViews.length && false === this.model.sheetViews[0].asc_getShowGridLines()) + return; + if (range === undefined) { range = this.visibleRange; } @@ -8270,6 +8282,19 @@ } break; + case "sheetViewSettings": + functionModelAction = function () { + if (null === t.model.sheetViews) + t.model.sheetViews = []; + t.model.sheetViews[0] = val; + + isUpdateCols = true; + isUpdateRows = true; + fullRecalc = false; + }; + + return this._isLockedAll (onChangeWorksheetCallback); + case "update": if (val !== undefined) { fullRecalc = !!val.fullRecalc;