Commit 65797e11 authored by Alexey.Musinov's avatar Alexey.Musinov Committed by Alexander.Trofimov

[ios] cell editor

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64255 954022d7-b5bf-4e40-9824-e11837661b57
parent a95aec06
...@@ -1050,16 +1050,20 @@ ...@@ -1050,16 +1050,20 @@
var ctx = this.overlayCtx, ppix = ctx.getPPIX(), ppiy = ctx.getPPIY(); var ctx = this.overlayCtx, ppix = ctx.getPPIX(), ppiy = ctx.getPPIY();
var begPos, endPos, top, top1, top2, begInfo, endInfo, line1, line2, i; var begPos, endPos, top, top1, top2, begInfo, endInfo, line1, line2, i;
var selection = [];
function drawRect(x, y, w, h) { function drawRect(x, y, w, h) {
ctx.fillRect( selection.push([asc_calcnpt(x, ppix), asc_calcnpt(y, ppiy), asc_calcnpt(w, ppix), asc_calcnpt(h, ppiy)]);
asc_calcnpt(x, ppix), asc_calcnpt(y, ppiy),
asc_calcnpt(w, ppix), asc_calcnpt(h, ppiy)); //ctx.fillRect(
// asc_calcnpt(x, ppix), asc_calcnpt(y, ppiy),
// asc_calcnpt(w, ppix), asc_calcnpt(h, ppiy));
} }
begPos = this.selectionBegin; begPos = this.selectionBegin;
endPos = this.selectionEnd; endPos = this.selectionEnd;
ctx.setFillStyle(this.defaults.selectColor).clear(); //ctx.setFillStyle(this.defaults.selectColor).clear();
if (begPos !== endPos && !this.isTopLineActive) { if (begPos !== endPos && !this.isTopLineActive) {
top = this.textRender.calcLineOffset(this.topLineIndex); top = this.textRender.calcLineOffset(this.topLineIndex);
...@@ -1081,6 +1085,8 @@ ...@@ -1081,6 +1085,8 @@
} }
} }
} }
return selection;
}; };
// Cursor // Cursor
...@@ -1407,28 +1413,28 @@ ...@@ -1407,28 +1413,28 @@
t.selectionBegin = begPos; t.selectionBegin = begPos;
t.selectionEnd = endPos; t.selectionEnd = endPos;
t._drawSelection(); //t._drawSelection();
if (t.isTopLineActive && !t.skipTLUpdate) {t._updateTopLineCurPos();} if (t.isTopLineActive && !t.skipTLUpdate) {t._updateTopLineCurPos();}
}; };
CellEditor.prototype._changeSelection = function (coord) { CellEditor.prototype._changeSelection = function (coord) {
var t = this; var t = this;
function doChangeSelection(coord) { function doChangeSelection(coord) {
var pos = t._findCursorPosition(coord); var pos = t._findCursorPosition(coord);
if (pos !== undefined) {pos >= 0 ? t._selectChars(kPosition, pos) : t._selectChars(pos);} if (pos !== undefined) {pos >= 0 ? t._selectChars(kPosition, pos) : t._selectChars(pos);}
if (t.isSelectMode) { // if (t.isSelectMode) {
t.selectionTimer = window.setTimeout( // t.selectionTimer = window.setTimeout(
function () {doChangeSelection(coord);}, // function () {doChangeSelection(coord);},
t.defaults.selectionTimeout); // t.defaults.selectionTimeout);
} // }
} }
doChangeSelection(coord); doChangeSelection(coord);
//window.clearTimeout(t.selectionTimer); //window.clearTimeout(t.selectionTimer);
//t.selectionTimer = window.setTimeout(function () {doChangeSelection(coord);}, 0); //t.selectionTimer = window.setTimeout(function () {doChangeSelection(coord);}, 0);
}; };
CellEditor.prototype._findFragment = function (pos, fragments) { CellEditor.prototype._findFragment = function (pos, fragments) {
var i, begin, end; var i, begin, end;
......
...@@ -1372,6 +1372,7 @@ function asc_menu_WriteFontFamily(_type, _family, _stream) { ...@@ -1372,6 +1372,7 @@ function asc_menu_WriteFontFamily(_type, _family, _stream) {
_stream["WriteByte"](255); _stream["WriteByte"](255);
} }
function asc_ReadCBorder(s, p) { function asc_ReadCBorder(s, p) {
var color = null; var color = null;
var style = null; var style = null;
...@@ -1406,6 +1407,159 @@ function asc_ReadCBorder(s, p) { ...@@ -1406,6 +1407,159 @@ function asc_ReadCBorder(s, p) {
return null; return null;
} }
function asc_ReadAdjustPrint(s, p) {
var adjustPrint = new asc_CAdjustPrint();
var next = true;
while (next)
{
var _attr = s[p.pos++];
switch (_attr)
{
case 0:
{
adjustPrint.asc_setPrintType(s[p.pos++]);
break;
}
case 1:
{
adjustPrint.asc_setLayoutPageType(s[p.pos++]);
break;
}
case 255:
default:
{
next = false;
break;
}
}
}
return adjustPrint;
}
function asc_ReadCPageMargins(s, p) {
var pageMargins = new asc_CPageMargins();
var next = true;
while (next)
{
var _attr = s[p.pos++];
switch (_attr)
{
case 0:
{
pageMargins.asc_setLeft(s[p.pos++]);
break;
}
case 1:
{
pageMargins.asc_setRight(s[p.pos++]);
break;
}
case 2:
{
pageMargins.asc_setTop(s[p.pos++]);
break;
}
case 3:
{
pageMargins.asc_setBottom(s[p.pos++]);
break;
}
case 255:
default:
{
next = false;
break;
}
}
}
return pageMargins;
}
function asc_ReadCPageSetup(s, p) {
var pageSetup = new asc_CPageSetup();
var next = true;
while (next)
{
var _attr = s[p.pos++];
switch (_attr)
{
case 0:
{
pageSetup.asc_setOrientation(s[p.pos++]);
break;
}
case 1:
{
pageSetup.asc_setWidth(s[p.pos++]);
break;
}
case 2:
{
pageSetup.asc_setHeight(s[p.pos++]);
break;
}
case 255:
default:
{
next = false;
break;
}
}
}
return pageSetup;
}
function asc_ReadPageOptions(s, p) {
var pageOptions = new asc_CPageOptions();
var next = true;
while (next)
{
var _attr = s[p.pos++];
switch (_attr)
{
case 0:
{
pageOptions.pageIndex = s[p.pos++];
break;
}
case 1:
{
pageOptions.asc_setPageMargins(asc_ReadCPageMargins(s,p));
break;
}
case 2:
{
pageOptions.asc_setPageSetup(asc_ReadCPageSetup(s,p));
break;
}
case 3:
{
pageOptions.asc_setGridLines(s[p.pos++]);
break;
}
case 4:
{
pageOptions.asc_setHeadings(s[p.pos++]);
break;
}
case 255:
default:
{
next = false;
break;
}
}
}
return pageOptions;
}
function asc_WriteCBorder(i, c, s) { function asc_WriteCBorder(i, c, s) {
if (!c) return; if (!c) return;
...@@ -1605,6 +1759,7 @@ var deviceScale = 1; ...@@ -1605,6 +1759,7 @@ var deviceScale = 1;
function OfflineEditor () { function OfflineEditor () {
this.zoom = 1.0; this.zoom = 1.0;
this.textSelection = 0;
// main // main
...@@ -1968,12 +2123,13 @@ function OfflineEditor () { ...@@ -1968,12 +2123,13 @@ function OfflineEditor () {
else else
showWorksheetCallback(true); showWorksheetCallback(true);
}; };
this.offline_print = function() { this.offline_print = function(s, p) {
var _adjustPrint = new asc_CAdjustPrint(); var adjustPrint = asc_ReadAdjustPrint(s, p);
var _printPagesData = _api.wb.calcPagesPrint(_adjustPrint); var pagesData = _api.wb.calcPagesPrint(adjustPrint);
var pdf_writer = new CPdfPrinter(_api.wbModel.sUrlPath); var pdfWriter = new CPdfPrinter(_api.wbModel.sUrlPath);
var isEndPrint = _api.wb.printSheet(pdf_writer, _printPagesData); var isEndPrint = _api.wb.printSheet(pdfWriter, pagesData);
return pdf_writer.DocumentRenderer.Memory.GetBase64Memory();
return pdfWriter.DocumentRenderer.Memory.GetBase64Memory();
}; };
} }
var _s = new OfflineEditor(); var _s = new OfflineEditor();
...@@ -1998,17 +2154,17 @@ function offline_get_selection(x, y, width, height) { ...@@ -1998,17 +2154,17 @@ function offline_get_selection(x, y, width, height) {
function offline_get_worksheet_bounds() { function offline_get_worksheet_bounds() {
return _s.getMaxBounds(); return _s.getMaxBounds();
} }
function offline_complete_cell(x, y){ function offline_complete_cell(x, y) {
return _s.getNearCellCoord(x, y); return _s.getNearCellCoord(x, y);
} }
function offline_cell_editor_open(x, y, width, height, ratio) { function offline_cell_editor_open(x, y, width, height, ratio) {
_null_object.width = width * ratio; _null_object.width = width * ratio;
_null_object.height = height * ratio; _null_object.height = height * ratio;
var wb = _api.wb; var wb = _api.wb;
wb._onEditCell (x, y, /*isCoord*/true, /*isFocus*/undefined, /*isClearCell*/undefined, wb._onEditCell (x, y, true,undefined, undefined, true, false);
/*isHideCursor*/true, /*isQuickInput*/false);
return [wb.cellEditor.left, wb.cellEditor.top, wb.cellEditor.right, wb.cellEditor.bottom, return [wb.cellEditor.left, wb.cellEditor.top, wb.cellEditor.right, wb.cellEditor.bottom,
wb.cellEditor.curLeft, wb.cellEditor.curTop, wb.cellEditor.curHeight]; wb.cellEditor.curLeft, wb.cellEditor.curTop, wb.cellEditor.curHeight];
...@@ -2046,50 +2202,76 @@ function offline_cell_editor_mouse_event(events, width, height, ratio) { ...@@ -2046,50 +2202,76 @@ function offline_cell_editor_mouse_event(events, width, height, ratio) {
_null_object.height = height * ratio; _null_object.height = height * ratio;
} }
var wb = _api.wb; var left, right;
var cellEditor = _api.wb.cellEditor;
for (var i = 0; i < events.length; ++i) { for (var i = 0; i < events.length; ++i) {
var event = { var event = {
pageX:events[i][1], pageX:events[i][1],
pageY:events[i][2], pageY:events[i][2],
which: 1, which: 1,
shiftKey: false shiftKey:events[i][3]
}; };
if (events[i][3]) {
if (-1 == events[i][4]) {
left = Math.min(cellEditor.selectionBegin, cellEditor.selectionEnd);
right = Math.max(cellEditor.selectionBegin, cellEditor.selectionEnd);
cellEditor.cursorPos = left;
cellEditor.selectionBegin = right;
cellEditor.selectionEnd = left;
_s.textSelection = -1;
}
if (1 == events[i][4]) {
left = Math.min(cellEditor.selectionBegin, cellEditor.selectionEnd);
right = Math.max(cellEditor.selectionBegin, cellEditor.selectionEnd);
cellEditor.cursorPos = right;
cellEditor.selectionBegin = left;
cellEditor.selectionEnd = right;
_s.textSelection = 1;
}
}
if (0 === events[i][0]) { if (0 === events[i][0]) {
wb.cellEditor._onMouseDown(event); var pos = cellEditor.cursorPos;
left = cellEditor.selectionBegin;
right = cellEditor.selectionEnd;
cellEditor._onMouseDown(event);
if (-1 === _s.textSelection) {
cellEditor.cursorPos = Math.min(left - 1, cellEditor.cursorPos);
cellEditor.selectionBegin = left;
cellEditor.selectionEnd = Math.min(left - 1, cellEditor.selectionEnd);
}
else if (1 === _s.textSelection) {
cellEditor.cursorPos = Math.max(left + 1, cellEditor.cursorPos);
cellEditor.selectionBegin = left;
cellEditor.selectionEnd = Math.max(left + 1, cellEditor.selectionEnd);
}
} else if (1 === events[i][0]) { } else if (1 === events[i][0]) {
wb.cellEditor._onMouseUp(event); cellEditor._onMouseUp(event);
_s.textSelection = 0;
} else if (2 == events[i][0]) { } else if (2 == events[i][0]) {
wb.cellEditor._onMouseMove(event); cellEditor._onMouseMove(event);
} else if (3 == events[i][0]) {
cellEditor._onMouseDblClick(event);
_s.textSelection = 0;
} }
} }
return [wb.cellEditor.left, wb.cellEditor.top, wb.cellEditor.right, wb.cellEditor.bottom, return [cellEditor.left, cellEditor.top, cellEditor.right, cellEditor.bottom,
wb.cellEditor.curLeft, wb.cellEditor.curTop, wb.cellEditor.curHeight]; cellEditor.curLeft, cellEditor.curTop, cellEditor.curHeight];
} }
function offline_cell_editor_close(x, y, width, height, ratio) { function offline_cell_editor_close(x, y, width, height, ratio) {
var worksheet = _api.wb.getWorksheet();
var region = _s._updateRegion(worksheet, 0, 0, 5000, 5000);
//
// console.log('========================');
// for (var i = 0; i < 10; ++i) {
// console.log('top['+ i+']: ' + worksheet.rows[i].top)
// }
// console.log('-------------');
_api.wb.cellEditor._tryCloseEditor(); _api.wb.cellEditor._tryCloseEditor();
}
// for (var i = 0; i < 10; ++i) { function offline_cell_editor_selection() {
// console.log('top['+ i+']: ' + worksheet.rows[i].top) return _api.wb.cellEditor._drawSelection();
// }
// console.log('-------------');
// worksheet._updateCache(region.columnBeg, region.rowBeg, region.columnEnd, region.rowEnd);
// for (var i = 0; i < 10; ++i) {
// console.log('top['+ i+']: ' + worksheet.rows[i].top)
// }
// console.log('========================');
} }
function offline_add_shape(x, y) { function offline_add_shape(x, y) {
...@@ -2220,7 +2402,7 @@ function offline_apply_event(type,params) { ...@@ -2220,7 +2402,7 @@ function offline_apply_event(type,params) {
{ {
_stream = global_memory_stream_menu; _stream = global_memory_stream_menu;
_stream["ClearNoAttack"](); _stream["ClearNoAttack"]();
_stream["WriteStringA"](_s.offline_print()); _stream["WriteStringA"](_s.offline_print(params,_current));
_return = _stream; _return = _stream;
break; break;
} }
...@@ -2606,6 +2788,12 @@ function offline_apply_event(type,params) { ...@@ -2606,6 +2788,12 @@ function offline_apply_event(type,params) {
_api.asc_setSheetViewSettings(colRowHeaders); _api.asc_setSheetViewSettings(colRowHeaders);
break; break;
} }
case 2215: // ASC_SPREADSHEETS_EVENT_TYPE_SET_PAGE_OPTIONS
{
var pageOptions = asc_ReadPageOptions(params, _current);
_api.asc_setPageOptions(pageOptions, pageOptions.pageIndex);
break;
}
case 2400: // ASC_SPREADSHEETS_EVENT_TYPE_COMPLETE_SEARCH case 2400: // ASC_SPREADSHEETS_EVENT_TYPE_COMPLETE_SEARCH
{ {
......
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