Commit 36a4e369 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

memory: CCellValue убрано поле cell

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@60364 954022d7-b5bf-4e40-9824-e11837661b57
parent de2d1990
......@@ -4031,7 +4031,7 @@ Woorksheet.prototype.expandRangeByMerged = function(range){
*/
function Cell(worksheet){
this.ws = worksheet;
this.oValue = new CCellValue(this);
this.oValue = new CCellValue();
this.xfs = null;
this.tableXfs = null;
this.conditionalFormattingXfs = null;
......@@ -4083,7 +4083,7 @@ Cell.prototype.clone=function(oNewWs){
oNewCell.nCol = this.nCol;;
if(null != this.xfs)
oNewCell.xfs = this.xfs.clone();
oNewCell.oValue = this.oValue.clone(oNewCell);
oNewCell.oValue = this.oValue.clone();
if(null != this.sFormula)
oNewCell.sFormula = this.sFormula;
return oNewCell;
......@@ -4206,7 +4206,7 @@ Cell.prototype.setValue=function(val,callback, isCopyPaste){
this.setFormula( val.substring(1) );
}
else {
this.oValue.setValue(val);
this.oValue.setValue(this, val);
this.formulaParsed = null;
}
}
......@@ -4237,7 +4237,7 @@ Cell.prototype.setValue2=function(array){
//[{text:"",format:TextFormat},{}...]
this.setValueCleanFormula();
this.oValue.clean();
this.oValue.setValue2(array);
this.oValue.setValue2(this, array);
sortDependency(this.ws.workbook);
var DataNew = null;
if(History.Is_On())
......@@ -4384,7 +4384,7 @@ Cell.prototype.setFont=function(val, bModifyValue){
};
Cell.prototype.setFontname=function(val){
var oRes = this.ws.workbook.oStyleManager.setFontname(this, val);
this.oValue.setFontname(val);
this.oValue.setFontname(this, val);
if(History.Is_On() && oRes.oldVal != oRes.newVal)
History.Add(g_oUndoRedoCell, historyitem_Cell_Fontname, this.ws.getId(), new Asc.Range(this.nCol, this.nRow, this.nCol, this.nRow), new UndoRedoData_CellSimpleData(this.nRow, this.nCol, oRes.oldVal, oRes.newVal));
this.bNeedCompileXfs = true;
......@@ -4392,7 +4392,7 @@ Cell.prototype.setFontname=function(val){
};
Cell.prototype.setFontsize=function(val){
var oRes = this.ws.workbook.oStyleManager.setFontsize(this, val);
this.oValue.setFontsize(val);
this.oValue.setFontsize(this, val);
if(History.Is_On() && oRes.oldVal != oRes.newVal)
History.Add(g_oUndoRedoCell, historyitem_Cell_Fontsize, this.ws.getId(), new Asc.Range(this.nCol, this.nRow, this.nCol, this.nRow), new UndoRedoData_CellSimpleData(this.nRow, this.nCol, oRes.oldVal, oRes.newVal));
this.bNeedCompileXfs = true;
......@@ -4400,7 +4400,7 @@ Cell.prototype.setFontsize=function(val){
};
Cell.prototype.setFontcolor=function(val){
var oRes = this.ws.workbook.oStyleManager.setFontcolor(this, val);
this.oValue.setFontcolor(val);
this.oValue.setFontcolor(this, val);
if(History.Is_On() && oRes.oldVal != oRes.newVal)
History.Add(g_oUndoRedoCell, historyitem_Cell_Fontcolor, this.ws.getId(), new Asc.Range(this.nCol, this.nRow, this.nCol, this.nRow), new UndoRedoData_CellSimpleData(this.nRow, this.nCol, oRes.oldVal, oRes.newVal));
this.bNeedCompileXfs = true;
......@@ -4408,7 +4408,7 @@ Cell.prototype.setFontcolor=function(val){
};
Cell.prototype.setBold=function(val){
var oRes = this.ws.workbook.oStyleManager.setBold(this, val);
this.oValue.setBold(val);
this.oValue.setBold(this, val);
if(History.Is_On() && oRes.oldVal != oRes.newVal)
History.Add(g_oUndoRedoCell, historyitem_Cell_Bold, this.ws.getId(), new Asc.Range(this.nCol, this.nRow, this.nCol, this.nRow), new UndoRedoData_CellSimpleData(this.nRow, this.nCol, oRes.oldVal, oRes.newVal));
this.bNeedCompileXfs = true;
......@@ -4416,7 +4416,7 @@ Cell.prototype.setBold=function(val){
};
Cell.prototype.setItalic=function(val){
var oRes = this.ws.workbook.oStyleManager.setItalic(this, val);
this.oValue.setItalic(val);
this.oValue.setItalic(this, val);
if(History.Is_On() && oRes.oldVal != oRes.newVal)
History.Add(g_oUndoRedoCell, historyitem_Cell_Italic, this.ws.getId(), new Asc.Range(this.nCol, this.nRow, this.nCol, this.nRow), new UndoRedoData_CellSimpleData(this.nRow, this.nCol, oRes.oldVal, oRes.newVal));
this.bNeedCompileXfs = true;
......@@ -4424,7 +4424,7 @@ Cell.prototype.setItalic=function(val){
};
Cell.prototype.setUnderline=function(val){
var oRes = this.ws.workbook.oStyleManager.setUnderline(this, val);
this.oValue.setUnderline(val);
this.oValue.setUnderline(this, val);
if(History.Is_On() && oRes.oldVal != oRes.newVal)
History.Add(g_oUndoRedoCell, historyitem_Cell_Underline, this.ws.getId(), new Asc.Range(this.nCol, this.nRow, this.nCol, this.nRow), new UndoRedoData_CellSimpleData(this.nRow, this.nCol, oRes.oldVal, oRes.newVal));
this.bNeedCompileXfs = true;
......@@ -4432,7 +4432,7 @@ Cell.prototype.setUnderline=function(val){
};
Cell.prototype.setStrikeout=function(val){
var oRes = this.ws.workbook.oStyleManager.setStrikeout(this, val);
this.oValue.setStrikeout(val);
this.oValue.setStrikeout(this, val);
if(History.Is_On() && oRes.oldVal != oRes.newVal)
History.Add(g_oUndoRedoCell, historyitem_Cell_Strikeout, this.ws.getId(), new Asc.Range(this.nCol, this.nRow, this.nCol, this.nRow), new UndoRedoData_CellSimpleData(this.nRow, this.nCol, oRes.oldVal, oRes.newVal));
this.bNeedCompileXfs = true;
......@@ -4440,7 +4440,7 @@ Cell.prototype.setStrikeout=function(val){
};
Cell.prototype.setFontAlign=function(val){
var oRes = this.ws.workbook.oStyleManager.setFontAlign(this, val);
this.oValue.setFontAlign(val);
this.oValue.setFontAlign(this, val);
if(History.Is_On() && oRes.oldVal != oRes.newVal)
History.Add(g_oUndoRedoCell, historyitem_Cell_FontAlign, this.ws.getId(), new Asc.Range(this.nCol, this.nRow, this.nCol, this.nRow), new UndoRedoData_CellSimpleData(this.nRow, this.nCol, oRes.oldVal, oRes.newVal));
this.bNeedCompileXfs = true;
......@@ -4552,23 +4552,23 @@ Cell.prototype.getFormula=function(){
return "";
};
Cell.prototype.getValueForEdit=function(numFormat){
return this.oValue.getValueForEdit();
return this.oValue.getValueForEdit(this);
};
Cell.prototype.getValueForEdit2=function(numFormat){
return this.oValue.getValueForEdit2();
return this.oValue.getValueForEdit2(this);
};
Cell.prototype.getValueWithoutFormat=function(){
return this.oValue.getValueWithoutFormat();
};
Cell.prototype.getValue=function(numFormat, dDigitsCount){
return this.oValue.getValue();
return this.oValue.getValue(this);
};
Cell.prototype.getValue2=function(dDigitsCount, fIsFitMeasurer){
if(null == fIsFitMeasurer)
fIsFitMeasurer = function(aText){return true;};
if(null == dDigitsCount)
dDigitsCount = gc_nMaxDigCountView;
return this.oValue.getValue2(dDigitsCount, fIsFitMeasurer);
return this.oValue.getValue2(this, dDigitsCount, fIsFitMeasurer);
};
Cell.prototype.getNumFormatStr=function(){
if(null != this.xfs && null != this.xfs.num)
......@@ -4599,7 +4599,7 @@ Cell.prototype.getOffset3=function(cellAddr){
return {offsetCol:(this.nCol - cAddr2.col + 1), offsetRow:(this.nRow - cAddr2.row + 1)};
};
Cell.prototype.getValueData = function(){
return new UndoRedoData_CellValueData(this.sFormula, this.oValue.clone(null));
return new UndoRedoData_CellValueData(this.sFormula, this.oValue.clone());
};
Cell.prototype.setValueData = function(Val){
//значения устанавляваются через setValue, чтобы пересчитались формулы
......@@ -7705,7 +7705,7 @@ Range.prototype._promoteFromTo=function(from, to, bIsPromote, oCanPromote, bCtrl
//копируем полностью
if(!oFromCell.formulaParsed){
var DataOld = oCopyCell.getValueData();
oCopyCell.oValue = oFromCell.oValue.clone(oCopyCell);
oCopyCell.oValue = oFromCell.oValue.clone();
var DataNew = oCopyCell.getValueData();
if(false == DataOld.isEqual(DataNew))
History.Add(g_oUndoRedoCell, historyitem_Cell_ChangeValue, this.worksheet.getId(), new Asc.Range(oCopyCell.nCol, oCopyCell.nRow, oCopyCell.nCol, oCopyCell.nRow), new UndoRedoData_CellSimpleData(oCopyCell.nRow, oCopyCell.nCol, DataOld, DataNew));
......
......@@ -2732,10 +2732,9 @@ var g_oCCellValueProperties = {
number: 2,
type: 3
};
function CCellValue(cell)
function CCellValue()
{
this.Properties = g_oCCellValueProperties;
this.cell = cell;
this.text = null;
this.multiText = null;
......@@ -2793,9 +2792,9 @@ CCellValue.prototype =
this.type = CellValueType.Number;
this.cleanCache();
},
clone : function(cell)
clone : function()
{
var oRes = new CCellValue(cell);
var oRes = new CCellValue();
if(null != this.text)
oRes.text = this.text;
if(null != this.multiText)
......@@ -2852,11 +2851,11 @@ CCellValue.prototype =
sResult = this.getStringFromMultiText();
return sResult;
},
getValue : function()
getValue : function(cell)
{
if(null == this.textValue)
{
this.getValue2(gc_nMaxDigCountView, function(){return true;});
this.getValue2(cell, gc_nMaxDigCountView, function(){return true;});
this.textValue = "";
var aText = this.aTextValue2[gc_nMaxDigCountView];
for(var i = 0, length = aText.length; i < length; ++i)
......@@ -2867,18 +2866,18 @@ CCellValue.prototype =
}
return this.textValue;
},
getValueForEdit : function()
getValueForEdit : function(cell)
{
if(null == this.textValueForEdit)
{
this.getValueForEdit2();
this.getValueForEdit2(cell);
this.textValueForEdit = "";
for(var i = 0, length = this.textValueForEdit2.length; i < length; ++i)
this.textValueForEdit += this.textValueForEdit2[i].text;
}
return this.textValueForEdit;
},
getValue2 : function(dDigitsCount, fIsFitMeasurer)
getValue2 : function(cell, dDigitsCount, fIsFitMeasurer)
{
var aRes = null;
if(null != this.aTextValue2[dDigitsCount])
......@@ -2898,7 +2897,7 @@ CCellValue.prototype =
if(CellValueType.String == this.type)
bNeedMeasure = false;
var oNumFormat;
var xfs = this.cell.getCompiledStyle();
var xfs = cell.getCompiledStyle();
if(null != xfs && null != xfs.num)
oNumFormat = oNumFormatCache.get(xfs.num.f);
else
......@@ -2949,7 +2948,7 @@ CCellValue.prototype =
break;
else
{
aRes = this._getValue2Result(sText, aText);
aRes = this._getValue2Result(cell, sText, aText);
//Проверяем влезает ли текст
if(true == fIsFitMeasurer(aRes))
{
......@@ -2987,7 +2986,7 @@ CCellValue.prototype =
}
if(bNeedMeasure)
{
aRes = this._getValue2Result(sText, aText);
aRes = this._getValue2Result(cell, sText, aText);
//Проверяем влезает ли текст
if(false == fIsFitMeasurer(aRes))
{
......@@ -2999,17 +2998,17 @@ CCellValue.prototype =
}
}
if(null == aRes)
aRes = this._getValue2Result(sText, aText);
if( this.cell.sFormula ){
aRes[0].sFormula = this.cell.sFormula;
aRes[0].sId = this.cell.getName();
aRes = this._getValue2Result(cell, sText, aText);
if( cell.sFormula ){
aRes[0].sFormula = cell.sFormula;
aRes[0].sId = cell.getName();
}
this.aTextValue2[dDigitsCount] = aRes;
}
return aRes;
},
getValueForEdit2: function (cultureInfo)
getValueForEdit2: function (cell, cultureInfo)
{
if (null == cultureInfo)
cultureInfo = g_oDefaultCultureInfo;
......@@ -3019,9 +3018,9 @@ CCellValue.prototype =
//применяем форматирование
var oValueText = null;
var oValueArray = null;
var xfs = this.cell.getCompiledStyle();
if(this.cell.sFormula)
oValueText = "="+this.cell.sFormula;
var xfs = cell.getCompiledStyle();
if(cell.sFormula)
oValueText = "="+cell.sFormula;
else
{
if(null != this.text || null != this.number)
......@@ -3100,25 +3099,25 @@ CCellValue.prototype =
else if(this.multiText)
oValueArray = this.multiText;
}
if(null != xfs && true == xfs.QuotePrefix && CellValueType.String == this.type && false == this.cell.isFormula())
if(null != xfs && true == xfs.QuotePrefix && CellValueType.String == this.type && false == cell.isFormula())
{
if(null != oValueText)
oValueText = "'" + oValueText;
else if(null != oValueArray)
oValueArray = [{text:"'"}].concat(oValueArray);
}
this.textValueForEdit2 = this._getValue2Result(oValueText, oValueArray);
this.textValueForEdit2 = this._getValue2Result(cell, oValueText, oValueArray);
}
return this.textValueForEdit2;
},
_getValue2Result : function(sText, aText)
_getValue2Result : function(cell, sText, aText)
{
var aResult = [];
if(null == sText && null == aText)
sText = "";
var color;
var cellfont;
var xfs = this.cell.getCompiledStyle();
var xfs = cell.getCompiledStyle();
if(null != xfs && null != xfs.font)
cellfont = xfs.font;
else
......@@ -3133,7 +3132,7 @@ CCellValue.prototype =
//для посещенных гиперссылок
if(g_nColorHyperlink == color.theme && null == color.tint)
{
var hyperlink = this.cell.ws.hyperlinkManager.getByCell(this.cell.nRow, this.cell.nCol);
var hyperlink = cell.ws.hyperlinkManager.getByCell(cell.nRow, cell.nCol);
if(null != hyperlink && hyperlink.data.getVisited())
{
oNewItem.format.c = g_oColorManager.getThemeColor(g_nColorHyperlinkVisited, null);
......@@ -3161,7 +3160,7 @@ CCellValue.prototype =
//для посещенных гиперссылок
if(g_nColorHyperlink == color.theme && null == color.tint)
{
var hyperlink = this.cell.ws.hyperlinkManager.getByCell(this.cell.nRow, this.cell.nCol);
var hyperlink = cell.ws.hyperlinkManager.getByCell(cell.nRow, cell.nCol);
if(null != hyperlink && hyperlink.data.getVisited())
{
oNewItem.format.c = g_oColorManager.getThemeColor(g_nColorHyperlinkVisited, null);
......@@ -3174,13 +3173,13 @@ CCellValue.prototype =
}
return aResult;
},
setValue : function(val)
setValue : function(cell, val)
{
this.clean();
if("" == val)
return;
var oNumFormat;
var xfs = this.cell.getCompiledStyle();
var xfs = cell.getCompiledStyle();
if(null != xfs && null != xfs.num)
oNumFormat = oNumFormatCache.get(xfs.num.f);
else
......@@ -3223,7 +3222,7 @@ CCellValue.prototype =
(c_oAscNumFormatType.Currency == nFormatType && res.bCurrency) ||
(c_oAscNumFormatType.Date == nFormatType && res.bDate) ||
(c_oAscNumFormatType.Time == nFormatType && res.bTime)) && res.format != oNumFormat.sFormat)
this.cell.setNumFormat(res.format);
cell.setNumFormat(res.format);
this.number = res.value;
this.type = CellValueType.Number;
}
......@@ -3233,7 +3232,7 @@ CCellValue.prototype =
//проверяем QuotePrefix
if(val.length > 0 && "'" == val[0])
{
this.cell.setQuotePrefix(true);
cell.setQuotePrefix(true);
val = val.substring(1);
}
this.text = val;
......@@ -3247,20 +3246,20 @@ CCellValue.prototype =
if(0 != val.indexOf("http://") && 0 != val.indexOf("https://"))
sRealUrl = "http://" + sRealUrl;
var oNewHyperlink = new Hyperlink();
oNewHyperlink.Ref = this.cell.ws.getCell3(this.cell.nRow, this.cell.nCol);
oNewHyperlink.Ref = cell.ws.getCell3(cell.nRow, cell.nCol);
oNewHyperlink.Hyperlink = sRealUrl;
oNewHyperlink.Ref.setHyperlink(oNewHyperlink);
}
},
setValue2 : function(aVal)
setValue2 : function(cell, aVal)
{
var sSimpleText = "";
for(var i = 0, length = aVal.length; i < length; ++i)
sSimpleText += aVal[i].text;
this.setValue(sSimpleText);
var nRow = this.cell.nRow;
var nCol = this.cell.nCol;
if(CellValueType.String == this.type && null == this.cell.ws.hyperlinkManager.getByCell(nRow, nCol))
this.setValue(cell, sSimpleText);
var nRow = cell.nRow;
var nCol = cell.nCol;
if(CellValueType.String == this.type && null == cell.ws.hyperlinkManager.getByCell(nRow, nCol))
{
this.clean();
this.type = CellValueType.String;
......@@ -3277,14 +3276,14 @@ CCellValue.prototype =
oNewElem.format.set(item.format);
this.multiText.push(oNewElem);
}
this.miminizeMultiText(true);
this.miminizeMultiText(cell, true);
}
//обрабатываем QuotePrefix
if(null != this.text)
{
if(this.text.length > 0 && "'" == this.text[0])
{
this.cell.setQuotePrefix(true);
cell.setQuotePrefix(true);
this.text = this.text.substring(1);
}
}
......@@ -3295,7 +3294,7 @@ CCellValue.prototype =
var oFirstItem = this.multiText[0];
if(null != oFirstItem.text && oFirstItem.text.length > 0 && "'" == oFirstItem.text[0])
{
this.cell.setQuotePrefix(true);
cell.setQuotePrefix(true);
if(1 != oFirstItem.text.length)
oFirstItem.text = oFirstItem.text.substring(1);
else
......@@ -3319,14 +3318,14 @@ CCellValue.prototype =
oRes.push(this.multiText[i].clone());
return oRes;
},
miminizeMultiText : function(bSetCellFont)
miminizeMultiText : function(cell, bSetCellFont)
{
var bRes = false;
if(null == bSetCellFont)
bSetCellFont = true;
if(null != this.multiText && this.multiText.length > 0)
{
var range = this.cell.ws.getCell3(this.cell.nRow, this.cell.nCol);
var range = cell.ws.getCell3(cell.nRow, cell.nCol);
var cellFont = range.getFont();
var oIntersectFont;
for (var i = 0, length = this.multiText.length; i < length; i++) {
......@@ -3345,9 +3344,9 @@ CCellValue.prototype =
if(bSetCellFont)
{
if (oIntersectFont.isEqual(g_oDefaultFont))
this.cell.setFont(null, false);
cell.setFont(null, false);
else
this.cell.setFont(oIntersectFont, false);
cell.setFont(oIntersectFont, false);
}
//если у всех элементов один формат, то сохраняем только текст
var bIsEqual = true;
......@@ -3368,7 +3367,7 @@ CCellValue.prototype =
}
return bRes;
},
_setFontProp : function(fCheck, fAction)
_setFontProp : function(cell, fCheck, fAction)
{
var bRes = false;
if(null != this.multiText)
......@@ -3386,15 +3385,14 @@ CCellValue.prototype =
}
if(bChange)
{
var backupObj = this.cell.getValueData();
var backupObj = cell.getValueData();
for (var i = 0, length = this.multiText.length; i < length; ++i) {
var elem = this.multiText[i];
if (null != elem.format)
fAction(elem.format)
}
//пробуем преобразовать в простую строку
var cell = this.cell;
if(this.miminizeMultiText(false))
if(this.miminizeMultiText(cell, false))
{
var DataNew = cell.getValueData();
History.Add(g_oUndoRedoCell, historyitem_Cell_ChangeValue, cell.ws.getId(), new Asc.Range(cell.nCol, cell.nRow, cell.nCol, cell.nRow), new UndoRedoData_CellSimpleData(cell.nRow,cell.nCol, backupObj, DataNew));
......@@ -3409,37 +3407,37 @@ CCellValue.prototype =
}
return bRes;
},
setFontname : function(val)
setFontname : function(cell, val)
{
return this._setFontProp(function(format){return val != format.fn;}, function(format){format.fn = val;});
return this._setFontProp(cell, function(format){return val != format.fn;}, function(format){format.fn = val;});
},
setFontsize : function(val)
setFontsize : function(cell, val)
{
return this._setFontProp(function(format){return val != format.fs;}, function(format){format.fs = val;});
return this._setFontProp(cell, function(format){return val != format.fs;}, function(format){format.fs = val;});
},
setFontcolor : function(val)
setFontcolor : function(cell, val)
{
return this._setFontProp(function(format){return val != format.c;}, function(format){format.c = val;});
return this._setFontProp(cell, function(format){return val != format.c;}, function(format){format.c = val;});
},
setBold : function(val)
setBold : function(cell, val)
{
return this._setFontProp(function(format){return val != format.b;}, function(format){format.b = val;});
return this._setFontProp(cell, function(format){return val != format.b;}, function(format){format.b = val;});
},
setItalic : function(val)
setItalic : function(cell, val)
{
return this._setFontProp(function(format){return val != format.i;}, function(format){format.i = val;});
return this._setFontProp(cell, function(format){return val != format.i;}, function(format){format.i = val;});
},
setUnderline : function(val)
setUnderline : function(cell, val)
{
return this._setFontProp(function(format){return val != format.u;}, function(format){format.u = val;});
return this._setFontProp(cell, function(format){return val != format.u;}, function(format){format.u = val;});
},
setStrikeout : function(val)
setStrikeout : function(cell, val)
{
return this._setFontProp(function(format){return val != format.s;}, function(format){format.s = val;});
return this._setFontProp(cell, function(format){return val != format.s;}, function(format){format.s = val;});
},
setFontAlign : function(val)
setFontAlign : function(cell, val)
{
return this._setFontProp(function(format){return val != format.va;}, function(format){format.va = val;});
return this._setFontProp(cell, function(format){return val != format.va;}, function(format){format.va = val;});
},
setValueType : function(type)
{
......
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