Commit 2d55616c authored by konovalovsergey's avatar konovalovsergey

if promote cell to the table header that will create more than one history point

parent 4c227e54
...@@ -9209,7 +9209,7 @@ function _isSameSizeMerged(bbox, aMerged) { ...@@ -9209,7 +9209,7 @@ function _isSameSizeMerged(bbox, aMerged) {
return oRes; return oRes;
} }
function _canPromote(from, wsFrom, to, wsTo, bIsPromote, nWidth, nHeight, bVertical, nIndex) { function _canPromote(from, wsFrom, to, wsTo, bIsPromote, nWidth, nHeight, bVertical, nIndex) {
var oRes = {oMergedFrom: null, oMergedTo: null}; var oRes = {oMergedFrom: null, oMergedTo: null, to: to};
//если надо только удалить внутреннее содержимое не смотрим на замерженость //если надо только удалить внутреннее содержимое не смотрим на замерженость
if(!bIsPromote || !((true == bVertical && nIndex >= 0 && nIndex < nHeight) || (false == bVertical && nIndex >= 0 && nIndex < nWidth))) if(!bIsPromote || !((true == bVertical && nIndex >= 0 && nIndex < nHeight) || (false == bVertical && nIndex >= 0 && nIndex < nWidth)))
{ {
...@@ -9285,52 +9285,55 @@ function promoteFromTo(from, wsFrom, to, wsTo) { ...@@ -9285,52 +9285,55 @@ function promoteFromTo(from, wsFrom, to, wsTo) {
_promoteFromTo(from, wsFrom, to, wsTo, false, oCanPromote, false, bVertical, nIndex); _promoteFromTo(from, wsFrom, to, wsTo, false, oCanPromote, false, bVertical, nIndex);
} }
} }
Range.prototype.promote=function(bCtrl, bVertical, nIndex){ Range.prototype.canPromote=function(bCtrl, bVertical, nIndex){
//todo отдельный метод для promote в таблицах и merge в таблицах var oBBox = this.bbox;
var oBBox = this.bbox; var nWidth = oBBox.c2 - oBBox.c1 + 1;
var nWidth = oBBox.c2 - oBBox.c1 + 1; var nHeight = oBBox.r2 - oBBox.r1 + 1;
var nHeight = oBBox.r2 - oBBox.r1 + 1; var bWholeCol = false; var bWholeRow = false;
var bWholeCol = false; var bWholeRow = false; if(0 == oBBox.r1 && gc_nMaxRow0 == oBBox.r2)
if(0 == oBBox.r1 && gc_nMaxRow0 == oBBox.r2) bWholeCol = true;
bWholeCol = true; if(0 == oBBox.c1 && gc_nMaxCol0 == oBBox.c2)
if(0 == oBBox.c1 && gc_nMaxCol0 == oBBox.c2) bWholeRow = true;
bWholeRow = true; if((bWholeCol && bWholeRow) || (true == bVertical && bWholeCol) || (false == bVertical && bWholeRow))
if((bWholeCol && bWholeRow) || (true == bVertical && bWholeCol) || (false == bVertical && bWholeRow)) return null;
return false; var oPromoteAscRange = null;
var oPromoteAscRange = null; if(0 == nIndex)
if(0 == nIndex) oPromoteAscRange = Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2);
oPromoteAscRange = Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2); else
else
{
if(bVertical)
{ {
if(nIndex > 0) if(bVertical)
{ {
if(nIndex >= nHeight) if(nIndex > 0)
oPromoteAscRange = Asc.Range(oBBox.c1, oBBox.r2 + 1, oBBox.c2, oBBox.r1 + nIndex); {
if(nIndex >= nHeight)
oPromoteAscRange = Asc.Range(oBBox.c1, oBBox.r2 + 1, oBBox.c2, oBBox.r1 + nIndex);
else
oPromoteAscRange = Asc.Range(oBBox.c1, oBBox.r1 + nIndex, oBBox.c2, oBBox.r2);
}
else else
oPromoteAscRange = Asc.Range(oBBox.c1, oBBox.r1 + nIndex, oBBox.c2, oBBox.r2); oPromoteAscRange = Asc.Range(oBBox.c1, oBBox.r1 + nIndex, oBBox.c2, oBBox.r1 - 1);
} }
else else
oPromoteAscRange = Asc.Range(oBBox.c1, oBBox.r1 + nIndex, oBBox.c2, oBBox.r1 - 1);
}
else
{
if(nIndex > 0)
{ {
if(nIndex >= nWidth) if(nIndex > 0)
oPromoteAscRange = Asc.Range(oBBox.c2 + 1, oBBox.r1, oBBox.c1 + nIndex, oBBox.r2); {
if(nIndex >= nWidth)
oPromoteAscRange = Asc.Range(oBBox.c2 + 1, oBBox.r1, oBBox.c1 + nIndex, oBBox.r2);
else
oPromoteAscRange = Asc.Range(oBBox.c1 + nIndex, oBBox.r1, oBBox.c2, oBBox.r2);
}
else else
oPromoteAscRange = Asc.Range(oBBox.c1 + nIndex, oBBox.r1, oBBox.c2, oBBox.r2); oPromoteAscRange = Asc.Range(oBBox.c1 + nIndex, oBBox.r1, oBBox.c1 - 1, oBBox.r2);
} }
else
oPromoteAscRange = Asc.Range(oBBox.c1 + nIndex, oBBox.r1, oBBox.c1 - 1, oBBox.r2);
} }
} //проверяем можно ли осуществить promote
//проверяем можно ли осуществить promote return _canPromote(oBBox, this.worksheet, oPromoteAscRange, this.worksheet, true, nWidth, nHeight, bVertical, nIndex);
var oCanPromote = _canPromote(oBBox, this.worksheet, oPromoteAscRange, this.worksheet, true, nWidth, nHeight, bVertical, nIndex); };
if(null == oCanPromote) Range.prototype.promote=function(bCtrl, bVertical, nIndex, oCanPromote){
return false; //todo отдельный метод для promote в таблицах и merge в таблицах
var oBBox = this.bbox;
var nWidth = oBBox.c2 - oBBox.c1 + 1;
var nHeight = oBBox.r2 - oBBox.r1 + 1;
History.Create_NewPoint(); History.Create_NewPoint();
var oSelection = History.GetSelection(); var oSelection = History.GetSelection();
...@@ -9377,10 +9380,9 @@ Range.prototype.promote=function(bCtrl, bVertical, nIndex){ ...@@ -9377,10 +9380,9 @@ Range.prototype.promote=function(bCtrl, bVertical, nIndex){
} }
oFormulaLocaleInfo.Parse = false; oFormulaLocaleInfo.Parse = false;
oFormulaLocaleInfo.DigitSep = false; oFormulaLocaleInfo.DigitSep = false;
_promoteFromTo(oBBox, this.worksheet, oPromoteAscRange, this.worksheet, true, oCanPromote, bCtrl, bVertical, nIndex); _promoteFromTo(oBBox, this.worksheet, oCanPromote.to, this.worksheet, true, oCanPromote, bCtrl, bVertical, nIndex);
oFormulaLocaleInfo.Parse = true; oFormulaLocaleInfo.Parse = true;
oFormulaLocaleInfo.DigitSep = true; oFormulaLocaleInfo.DigitSep = true;
return true;
}; };
function _promoteFromTo(from, wsFrom, to, wsTo, bIsPromote, oCanPromote, bCtrl, bVertical, nIndex) { function _promoteFromTo(from, wsFrom, to, wsTo, bIsPromote, oCanPromote, bCtrl, bVertical, nIndex) {
var wb = wsFrom.workbook; var wb = wsFrom.workbook;
......
...@@ -8144,11 +8144,15 @@ ...@@ -8144,11 +8144,15 @@
var applyFillHandleCallback = function ( res ) { var applyFillHandleCallback = function ( res ) {
if ( res ) { if ( res ) {
// Автозаполняем ячейки // Автозаполняем ячейки
if ( range.promote( /*bCtrl*/ctrlPress, /*bVertical*/(1 === t.fillHandleDirection), nIndex ) ) { var oCanPromote = range.canPromote(/*bCtrl*/ctrlPress, /*bVertical*/(1 === t.fillHandleDirection), nIndex);
if (null != oCanPromote) {
History.Create_NewPoint();
History.StartTransaction();
range.promote(/*bCtrl*/ctrlPress, /*bVertical*/(1 === t.fillHandleDirection), nIndex, oCanPromote);
// Вызываем функцию пересчета для заголовков форматированной таблицы // Вызываем функцию пересчета для заголовков форматированной таблицы
t.model.autoFilters.renameTableColumn( arn ); t.model.autoFilters.renameTableColumn( arn );
} History.EndTransaction();
else { } else {
t.handlers.trigger( "onErrorEvent", c_oAscError.ID.CannotFillRange, c_oAscError.Level.NoCritical ); t.handlers.trigger( "onErrorEvent", c_oAscError.ID.CannotFillRange, c_oAscError.Level.NoCritical );
t.activeRange.assign2( range.bbox ); t.activeRange.assign2( range.bbox );
} }
......
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