Commit 1058b8a6 authored by konovalovsergey's avatar konovalovsergey

open/save xlsx SheetView selection

parent 54ae5cb8
...@@ -268,8 +268,9 @@ var c_oAscCanChangeColWidth = { ...@@ -268,8 +268,9 @@ var c_oAscCanChangeColWidth = {
}; };
var c_oAscPaneState = { var c_oAscPaneState = {
Frozen: "frozen", Frozen: 0,
FrozenSplit: "frozenSplit" FrozenSplit: 1,
Split: 2
}; };
var c_oAscFindLookIn = { var c_oAscFindLookIn = {
......
...@@ -610,7 +610,8 @@ ...@@ -610,7 +610,8 @@
ZoomScalePageLayoutView : 17, ZoomScalePageLayoutView : 17,
ZoomScaleSheetLayoutView : 18, ZoomScaleSheetLayoutView : 18,
Pane : 19 Pane : 19,
Selection : 20
}; };
var c_oSer_DrawingType = var c_oSer_DrawingType =
{ {
...@@ -629,11 +630,19 @@ ...@@ -629,11 +630,19 @@
/** @enum */ /** @enum */
var c_oSer_Pane = { var c_oSer_Pane = {
ActivePane : 0, ActivePane : 0,
State : 1, //State : 1,
TopLeftCell : 2, TopLeftCell : 2,
XSplit : 3, XSplit : 3,
YSplit : 4 YSplit : 4,
State : 5
}; };
/** @enum */
var c_oSer_Selection = {
ActiveCell: 0,
ActiveCellId: 1,
Sqref: 2,
Pane: 3
};
/** @enum */ /** @enum */
var c_oSer_CellStyle = { var c_oSer_CellStyle = {
BuiltinId : 0, BuiltinId : 0,
...@@ -2626,10 +2635,10 @@ ...@@ -2626,10 +2635,10 @@
this.WriteSheetViews = function (ws) { this.WriteSheetViews = function (ws) {
var oThis = this; var oThis = this;
for (var i = 0, length = ws.sheetViews.length; i < length; ++i) { for (var i = 0, length = ws.sheetViews.length; i < length; ++i) {
this.bs.WriteItem(c_oSerWorksheetsTypes.SheetView, function(){oThis.WriteSheetView(ws.sheetViews[i]);}); this.bs.WriteItem(c_oSerWorksheetsTypes.SheetView, function(){oThis.WriteSheetView(ws, ws.sheetViews[i]);});
} }
}; };
this.WriteSheetView = function (oSheetView) { this.WriteSheetView = function (ws, oSheetView) {
var oThis = this; var oThis = this;
if (null !== oSheetView.showGridLines) if (null !== oSheetView.showGridLines)
this.bs.WriteItem(c_oSer_SheetView.ShowGridLines, function(){oThis.memory.WriteBool(oSheetView.showGridLines);}); this.bs.WriteItem(c_oSer_SheetView.ShowGridLines, function(){oThis.memory.WriteBool(oSheetView.showGridLines);});
...@@ -2637,11 +2646,14 @@ ...@@ -2637,11 +2646,14 @@
this.bs.WriteItem(c_oSer_SheetView.ShowRowColHeaders, function(){oThis.memory.WriteBool(oSheetView.showRowColHeaders);}); this.bs.WriteItem(c_oSer_SheetView.ShowRowColHeaders, function(){oThis.memory.WriteBool(oSheetView.showRowColHeaders);});
if (null !== oSheetView.pane && oSheetView.pane.isInit()) if (null !== oSheetView.pane && oSheetView.pane.isInit())
this.bs.WriteItem(c_oSer_SheetView.Pane, function(){oThis.WriteSheetViewPane(oSheetView.pane);}); this.bs.WriteItem(c_oSer_SheetView.Pane, function(){oThis.WriteSheetViewPane(oSheetView.pane);});
if (null !== ws.selectionRange)
this.bs.WriteItem(c_oSer_SheetView.Selection, function(){oThis.WriteSheetViewSelection(ws.selectionRange);});
}; };
this.WriteSheetViewPane = function (oPane) { this.WriteSheetViewPane = function (oPane) {
var oThis = this; var oThis = this;
//this.bs.WriteItem(c_oSer_Pane.ActivePane, function(){oThis.memory.WriteByte();});
// Всегда пишем Frozen // Всегда пишем Frozen
this.bs.WriteItem(c_oSer_Pane.State, function(){oThis.memory.WriteString3(AscCommonExcel.c_oAscPaneState.Frozen);}); this.bs.WriteItem(c_oSer_Pane.State, function(){oThis.memory.WriteByte(AscCommonExcel.c_oAscPaneState.Frozen);});
this.bs.WriteItem(c_oSer_Pane.TopLeftCell, function(){oThis.memory.WriteString3(oPane.topLeftFrozenCell.getID());}); this.bs.WriteItem(c_oSer_Pane.TopLeftCell, function(){oThis.memory.WriteString3(oPane.topLeftFrozenCell.getID());});
var col = oPane.topLeftFrozenCell.getCol0(); var col = oPane.topLeftFrozenCell.getCol0();
...@@ -2651,6 +2663,24 @@ ...@@ -2651,6 +2663,24 @@
if (0 < row) if (0 < row)
this.bs.WriteItem(c_oSer_Pane.YSplit, function(){oThis.memory.WriteDouble2(row);}); this.bs.WriteItem(c_oSer_Pane.YSplit, function(){oThis.memory.WriteDouble2(row);});
}; };
this.WriteSheetViewSelection = function (selectionRange) {
var oThis = this;
if (null != selectionRange.activeCell) {
this.bs.WriteItem(c_oSer_Selection.ActiveCell, function(){oThis.memory.WriteString3(selectionRange.activeCell.getName());});
}
if (null != selectionRange.activeCellId) {
this.bs.WriteItem(c_oSer_Selection.ActiveCellId, function(){oThis.memory.WriteLong(selectionRange.activeCellId);});
}
//this.bs.WriteItem(c_oSer_Selection.Pane, function(){oThis.memory.WriteByte();});
if (null != selectionRange.ranges) {
var refs = [];
for (var i = 0; i < selectionRange.ranges.length; ++i) {
refs.push(selectionRange.ranges[i].getName());
}
var sqref = refs.join(' ');
this.bs.WriteItem(c_oSer_Selection.Sqref, function(){oThis.memory.WriteString3(sqref);});
}
};
this.WriteSheetPr = function (sheetPr) { this.WriteSheetPr = function (sheetPr) {
var oThis = this; var oThis = this;
if (null !== sheetPr.CodeName) if (null !== sheetPr.CodeName)
...@@ -6500,24 +6530,65 @@ ...@@ -6500,24 +6530,65 @@
this.ReadSheetView = function (type, length, oSheetView) { this.ReadSheetView = function (type, length, oSheetView) {
var oThis = this; var oThis = this;
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
if (c_oSer_SheetView.ShowGridLines === type) { if (c_oSer_SheetView.ColorId === type) {
oSheetView.showGridLines = this.stream.GetBool(); this.stream.GetLong();
} else if (c_oSer_SheetView.ShowRowColHeaders === type) { } else if (c_oSer_SheetView.DefaultGridColor === type) {
oSheetView.showRowColHeaders = this.stream.GetBool(); this.stream.GetBool();
} else if (c_oSer_SheetView.RightToLeft === type) {
this.stream.GetBool();
} else if (c_oSer_SheetView.ShowFormulas === type) {
this.stream.GetBool();
} else if (c_oSer_SheetView.ShowGridLines === type) {
oSheetView.showGridLines = this.stream.GetBool();
} else if (c_oSer_SheetView.ShowOutlineSymbols === type) {
this.stream.GetBool();
} else if (c_oSer_SheetView.ShowRowColHeaders === type) {
oSheetView.showRowColHeaders = this.stream.GetBool();
} else if (c_oSer_SheetView.ShowRuler === type) {
this.stream.GetBool();
} else if (c_oSer_SheetView.ShowWhiteSpace === type) {
this.stream.GetBool();
} else if (c_oSer_SheetView.ShowZeros === type) {
this.stream.GetBool();
} else if (c_oSer_SheetView.TabSelected === type) {
this.stream.GetBool();
} else if (c_oSer_SheetView.TopLeftCell === type) {
this.stream.GetString2LE(length);
} else if (c_oSer_SheetView.View === type) {
this.stream.GetUChar();
} else if (c_oSer_SheetView.WindowProtection === type) {
this.stream.GetBool();
} else if (c_oSer_SheetView.WorkbookViewId === type) {
this.stream.GetLong();
} else if (c_oSer_SheetView.ZoomScale === type) {
this.stream.GetLong();
} else if (c_oSer_SheetView.ZoomScaleNormal === type) {
this.stream.GetLong();
} else if (c_oSer_SheetView.ZoomScalePageLayoutView === type) {
this.stream.GetLong();
} else if (c_oSer_SheetView.ZoomScaleSheetLayoutView === type) {
this.stream.GetLong();
} else if (c_oSer_SheetView.Pane === type) { } else if (c_oSer_SheetView.Pane === type) {
oSheetView.pane = new AscCommonExcel.asc_CPane(); oSheetView.pane = new AscCommonExcel.asc_CPane();
res = this.bcr.Read1(length, function (t, l) { res = this.bcr.Read1(length, function (t, l) {
return oThis.ReadPane(t, l, oSheetView.pane); return oThis.ReadPane(t, l, oSheetView.pane);
}); });
oSheetView.pane.init(); oSheetView.pane.init();
} else if (c_oSer_SheetView.Selection === type) {
this.curWorksheet.selectionRange.clean();
res = this.bcr.Read1(length, function (t, l) {
return oThis.ReadSelection(t, l, oThis.curWorksheet.selectionRange);
});
} else } else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}; };
this.ReadPane = function (type, length, oPane) { this.ReadPane = function (type, length, oPane) {
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
if (c_oSer_Pane.State === type) if (c_oSer_Pane.ActivePane === type)
oPane.state = this.stream.GetString2LE(length); this.stream.GetUChar();
else if (c_oSer_Pane.State === type)
oPane.state = this.stream.GetUChar();
else if (c_oSer_Pane.TopLeftCell === type) else if (c_oSer_Pane.TopLeftCell === type)
oPane.topLeftCell = this.stream.GetString2LE(length); oPane.topLeftCell = this.stream.GetString2LE(length);
else if (c_oSer_Pane.XSplit === type) else if (c_oSer_Pane.XSplit === type)
...@@ -6528,6 +6599,31 @@ ...@@ -6528,6 +6599,31 @@
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}; };
this.ReadSelection = function (type, length, selectionRange) {
var res = c_oSerConstants.ReadOk;
if (c_oSer_Selection.ActiveCell === type) {
var activeCell = AscCommonExcel.g_oRangeCache.getAscRange(this.stream.GetString2LE(length));
if (activeCell) {
selectionRange.activeCell = new AscCommon.CellBase(activeCell.r1, activeCell.c1);
}
} else if (c_oSer_Selection.ActiveCellId === type) {
selectionRange.activeCellId = this.stream.GetLong();
} else if (c_oSer_Selection.Sqref === type) {
var sqref = this.stream.GetString2LE(length);
var refs = sqref.split(' ');
selectionRange.ranges = [];
for (var i = 0; i < refs.length; ++i) {
var ref = AscCommonExcel.g_oRangeCache.getAscRange(refs[i]);
if (ref) {
selectionRange.ranges.push(ref.clone());
}
}
} else if (c_oSer_Selection.Pane === type) {
this.stream.GetUChar();
} else
res = c_oSerConstants.ReadUnknown;
return res;
};
this.ReadSheetPr = function (type, length, oSheetPr) { this.ReadSheetPr = function (type, length, oSheetPr) {
var oThis = this; var oThis = this;
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
......
...@@ -784,6 +784,9 @@ var g_oCellAddressUtils = new CellAddressUtils(); ...@@ -784,6 +784,9 @@ var g_oCellAddressUtils = new CellAddressUtils();
CellBase.prototype.isEqual = function(cell) { CellBase.prototype.isEqual = function(cell) {
return this.row === cell.row && this.col === cell.col; return this.row === cell.row && this.col === cell.col;
}; };
CellBase.prototype.getName = function() {
return g_oCellAddressUtils.colnumToColstr(this.col + 1) + (this.row + 1);
};
/** /**
* @constructor * @constructor
*/ */
......
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