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) {
return oRes;
}
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)))
{
......@@ -9285,52 +9285,55 @@ function promoteFromTo(from, wsFrom, to, wsTo) {
_promoteFromTo(from, wsFrom, to, wsTo, false, oCanPromote, false, bVertical, nIndex);
}
}
Range.prototype.promote=function(bCtrl, bVertical, nIndex){
//todo отдельный метод для promote в таблицах и merge в таблицах
var oBBox = this.bbox;
var nWidth = oBBox.c2 - oBBox.c1 + 1;
var nHeight = oBBox.r2 - oBBox.r1 + 1;
var bWholeCol = false; var bWholeRow = false;
if(0 == oBBox.r1 && gc_nMaxRow0 == oBBox.r2)
bWholeCol = true;
if(0 == oBBox.c1 && gc_nMaxCol0 == oBBox.c2)
bWholeRow = true;
if((bWholeCol && bWholeRow) || (true == bVertical && bWholeCol) || (false == bVertical && bWholeRow))
return false;
var oPromoteAscRange = null;
if(0 == nIndex)
oPromoteAscRange = Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2);
else
{
if(bVertical)
Range.prototype.canPromote=function(bCtrl, bVertical, nIndex){
var oBBox = this.bbox;
var nWidth = oBBox.c2 - oBBox.c1 + 1;
var nHeight = oBBox.r2 - oBBox.r1 + 1;
var bWholeCol = false; var bWholeRow = false;
if(0 == oBBox.r1 && gc_nMaxRow0 == oBBox.r2)
bWholeCol = true;
if(0 == oBBox.c1 && gc_nMaxCol0 == oBBox.c2)
bWholeRow = true;
if((bWholeCol && bWholeRow) || (true == bVertical && bWholeCol) || (false == bVertical && bWholeRow))
return null;
var oPromoteAscRange = null;
if(0 == nIndex)
oPromoteAscRange = Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2);
else
{
if(nIndex > 0)
if(bVertical)
{
if(nIndex >= nHeight)
oPromoteAscRange = Asc.Range(oBBox.c1, oBBox.r2 + 1, oBBox.c2, oBBox.r1 + nIndex);
if(nIndex > 0)
{
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
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
oPromoteAscRange = Asc.Range(oBBox.c1, oBBox.r1 + nIndex, oBBox.c2, oBBox.r1 - 1);
}
else
{
if(nIndex > 0)
{
if(nIndex >= nWidth)
oPromoteAscRange = Asc.Range(oBBox.c2 + 1, oBBox.r1, oBBox.c1 + nIndex, oBBox.r2);
if(nIndex > 0)
{
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
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
var oCanPromote = _canPromote(oBBox, this.worksheet, oPromoteAscRange, this.worksheet, true, nWidth, nHeight, bVertical, nIndex);
if(null == oCanPromote)
return false;
//проверяем можно ли осуществить promote
return _canPromote(oBBox, this.worksheet, oPromoteAscRange, this.worksheet, true, nWidth, nHeight, bVertical, nIndex);
};
Range.prototype.promote=function(bCtrl, bVertical, nIndex, oCanPromote){
//todo отдельный метод для promote в таблицах и merge в таблицах
var oBBox = this.bbox;
var nWidth = oBBox.c2 - oBBox.c1 + 1;
var nHeight = oBBox.r2 - oBBox.r1 + 1;
History.Create_NewPoint();
var oSelection = History.GetSelection();
......@@ -9377,10 +9380,9 @@ Range.prototype.promote=function(bCtrl, bVertical, nIndex){
}
oFormulaLocaleInfo.Parse = 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.DigitSep = true;
return true;
};
function _promoteFromTo(from, wsFrom, to, wsTo, bIsPromote, oCanPromote, bCtrl, bVertical, nIndex) {
var wb = wsFrom.workbook;
......
......@@ -8144,11 +8144,15 @@
var applyFillHandleCallback = function ( 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 );
}
else {
History.EndTransaction();
} else {
t.handlers.trigger( "onErrorEvent", c_oAscError.ID.CannotFillRange, c_oAscError.Level.NoCritical );
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