Commit 800e065e authored by Alexander.Trofimov's avatar Alexander.Trofimov

fix bug 33607 🐛

parent b90efd53
...@@ -498,7 +498,8 @@ ...@@ -498,7 +498,8 @@
t._moveCursor(kEndOfText); t._moveCursor(kEndOfText);
}; };
CellEditor.prototype.move = function ( l, t, r, b ) { CellEditor.prototype.move = function (l, t, r, b) {
this.textFlags.wrapOnlyCE = false;
this.sides = this.options.getSides(); this.sides = this.options.getSides();
this.left = this.sides.cellX; this.left = this.sides.cellX;
this.top = this.sides.cellY; this.top = this.sides.cellY;
...@@ -506,36 +507,34 @@ ...@@ -506,36 +507,34 @@
this.bottom = this.sides.b[0]; this.bottom = this.sides.b[0];
// ToDo вынести в отдельную функцию // ToDo вынести в отдельную функцию
var canExpW = true, canExpH = true, tm, expW, expH, fragments = this._getRenderFragments(); var canExpW = true, canExpH = true, tm, expW, expH, fragments = this._getRenderFragments();
if ( 0 < fragments.length ) { if (0 < fragments.length) {
tm = this.textRender.measureString( fragments, this.textFlags, this._getContentWidth() ); tm = this.textRender.measureString(fragments, this.textFlags, this._getContentWidth());
expW = tm.width > this._getContentWidth(); expW = tm.width > this._getContentWidth();
expH = tm.height > this._getContentHeight(); expH = tm.height > this._getContentHeight();
while ( expW && canExpW || expH && canExpH ) { while (expW && canExpW || expH && canExpH) {
if ( expW ) { if (expW) {
canExpW = this._expandWidth(); canExpW = this._expandWidth();
} }
if ( expH ) { if (expH) {
canExpH = this._expandHeight(); canExpH = this._expandHeight();
} }
if ( !canExpW ) { if (!canExpW) {
this.textFlags.wrapText = true; this.textFlags.wrapOnlyCE = true;
tm = this.textRender.measureString( fragments, this.textFlags, this._getContentWidth() ); tm = this.textRender.measureString(fragments, this.textFlags, this._getContentWidth());
} } else {
else { tm = this.textRender.measure(this._getContentWidth());
tm = this.textRender.measure( this._getContentWidth() );
} }
expW = tm.width > this._getContentWidth(); expW = tm.width > this._getContentWidth();
expH = tm.height > this._getContentHeight(); expH = tm.height > this._getContentHeight();
} }
} }
if ( this.left < l || this.top < t || this.left > r || this.top > b ) { if (this.left < l || this.top < t || this.left > r || this.top > b) {
// hide // hide
this._hideCanvas(); this._hideCanvas();
} } else {
else {
this._adjustCanvas(); this._adjustCanvas();
this._showCanvas(); this._showCanvas();
this._renderText(); this._renderText();
...@@ -1109,25 +1108,24 @@ ...@@ -1109,25 +1108,24 @@
CellEditor.prototype._draw = function () { CellEditor.prototype._draw = function () {
var canExpW = true, canExpH = true, tm, expW, expH, fragments = this._getRenderFragments(); var canExpW = true, canExpH = true, tm, expW, expH, fragments = this._getRenderFragments();
if ( 0 < fragments.length ) { if (0 < fragments.length) {
tm = this.textRender.measureString( fragments, this.textFlags, this._getContentWidth() ); tm = this.textRender.measureString(fragments, this.textFlags, this._getContentWidth());
expW = tm.width > this._getContentWidth(); expW = tm.width > this._getContentWidth();
expH = tm.height > this._getContentHeight(); expH = tm.height > this._getContentHeight();
while ( expW && canExpW || expH && canExpH ) { while (expW && canExpW || expH && canExpH) {
if ( expW ) { if (expW) {
canExpW = this._expandWidth(); canExpW = this._expandWidth();
} }
if ( expH ) { if (expH) {
canExpH = this._expandHeight(); canExpH = this._expandHeight();
} }
if ( !canExpW ) { if (!canExpW) {
this.textFlags.wrapText = true; this.textFlags.wrapOnlyCE = true;
tm = this.textRender.measureString( fragments, this.textFlags, this._getContentWidth() ); tm = this.textRender.measureString(fragments, this.textFlags, this._getContentWidth());
} } else {
else { tm = this.textRender.measure(this._getContentWidth());
tm = this.textRender.measure( this._getContentWidth() );
} }
expW = tm.width > this._getContentWidth(); expW = tm.width > this._getContentWidth();
expH = tm.height > this._getContentHeight(); expH = tm.height > this._getContentHeight();
...@@ -1139,59 +1137,59 @@ ...@@ -1139,59 +1137,59 @@
this._adjustCanvas(); this._adjustCanvas();
this._showCanvas(); this._showCanvas();
this._renderText(); this._renderText();
this.input.value = this._getFragmentsText( fragments ); this.input.value = this._getFragmentsText(fragments);
this._updateCursorPosition(); this._updateCursorPosition();
this._showCursor(); this._showCursor();
}; };
CellEditor.prototype._update = function () { CellEditor.prototype._update = function () {
this._updateFormulaEditMod( /*bIsOpen*/false ); this._updateFormulaEditMod(/*bIsOpen*/false);
var tm, canExpW, canExpH, oldLC, doAjust = false, fragments = this._getRenderFragments(); var tm, canExpW, canExpH, oldLC, doAjust = false, fragments = this._getRenderFragments();
if ( 0 < fragments.length ) { if (0 < fragments.length) {
oldLC = this.textRender.getLinesCount(); oldLC = this.textRender.getLinesCount();
tm = this.textRender.measureString( fragments, this.textFlags, this._getContentWidth() ); tm = this.textRender.measureString(fragments, this.textFlags, this._getContentWidth());
if ( this.textRender.getLinesCount() < oldLC ) { if (this.textRender.getLinesCount() < oldLC) {
this.topLineIndex -= oldLC - this.textRender.getLinesCount(); this.topLineIndex -= oldLC - this.textRender.getLinesCount();
} }
canExpW = !this.textFlags.wrapText; canExpW = !(this.textFlags.wrapText || this.textFlags.wrapOnlyCE);
while ( tm.width > this._getContentWidth() && canExpW ) { while (tm.width > this._getContentWidth() && canExpW) {
canExpW = this._expandWidth(); canExpW = this._expandWidth();
if ( !canExpW ) { if (!canExpW) {
this.textFlags.wrapText = true; this.textFlags.wrapOnlyCE = true;
tm = this.textRender.measureString( fragments, this.textFlags, this._getContentWidth() ); tm = this.textRender.measureString(fragments, this.textFlags, this._getContentWidth());
} }
doAjust = true; doAjust = true;
} }
canExpH = true; canExpH = true;
while ( tm.height > this._getContentHeight() && canExpH ) { while (tm.height > this._getContentHeight() && canExpH) {
canExpH = this._expandHeight(); canExpH = this._expandHeight();
doAjust = true; doAjust = true;
} }
if ( this.textRender.isLastCharNL() && !doAjust && canExpH ) { if (this.textRender.isLastCharNL() && !doAjust && canExpH) {
var lm = this.textRender.calcCharHeight( this.textRender.getCharsCount() - 1 ); var lm = this.textRender.calcCharHeight(this.textRender.getCharsCount() - 1);
if ( tm.height + lm.th > this._getContentHeight() ) { if (tm.height + lm.th > this._getContentHeight()) {
this._expandHeight(); this._expandHeight();
doAjust = true; doAjust = true;
} }
} }
} }
if ( doAjust ) { if (doAjust) {
this._adjustCanvas(); this._adjustCanvas();
} }
this._renderText(); // вызов нужен для пересчета поля line.startX, которое используется в _updateCursorPosition this._renderText(); // вызов нужен для пересчета поля line.startX, которое используется в _updateCursorPosition
this._fireUpdated(); // вызов нужен для обновление текста верхней строки, перед обновлением позиции курсора this._fireUpdated(); // вызов нужен для обновление текста верхней строки, перед обновлением позиции курсора
this._updateCursorPosition( true ); this._updateCursorPosition(true);
this._showCursor(); this._showCursor();
this._updateUndoRedoChanged(); this._updateUndoRedoChanged();
if ( window['IS_NATIVE_EDITOR'] && !this.dontUpdateText ) { if (window['IS_NATIVE_EDITOR'] && !this.dontUpdateText) {
window['native']['onCellEditorChangeText']( this._getFragmentsText( this.options.fragments ) ); window['native']['onCellEditorChangeText'](this._getFragmentsText(this.options.fragments));
} }
}; };
......
...@@ -556,7 +556,7 @@ ...@@ -556,7 +556,7 @@
* @return {Number} * @return {Number}
*/ */
StringRender.prototype._calcLineWidth = function (startPos, endPos) { StringRender.prototype._calcLineWidth = function (startPos, endPos) {
var wrap = this.flags && (this.flags.wrapText || this.flags.wrapOnlyNL); var wrap = this.flags && (this.flags.wrapText || this.flags.wrapOnlyNL || this.flags.wrapOnlyCE);
var isAtEnd, j, chProp, tw; var isAtEnd, j, chProp, tw;
if (endPos === undefined || endPos < 0) { if (endPos === undefined || endPos < 0) {
...@@ -813,7 +813,7 @@ ...@@ -813,7 +813,7 @@
StringRender.prototype._measureChars = function (maxWidth) { StringRender.prototype._measureChars = function (maxWidth) {
var self = this; var self = this;
var ctx = this.drawingCtx; var ctx = this.drawingCtx;
var wrap = this.flags && this.flags.wrapText && !this.flags.isNumberFormat; var wrap = this.flags && (this.flags.wrapText || this.flags.wrapOnlyCE) && !this.flags.isNumberFormat;
var wrapNL = this.flags && this.flags.wrapOnlyNL; var wrapNL = this.flags && this.flags.wrapOnlyNL;
var hasRepeats = false; var hasRepeats = false;
var i, j, fr, fmt, text, p, p_ = {}, pIndex, f, f_, eq, startCh; var i, j, fr, fmt, text, p, p_ = {}, pIndex, f, f_, eq, startCh;
......
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