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

Поддержка цветов темы.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47235 954022d7-b5bf-4e40-9824-e11837661b57
parent 37c54347
...@@ -149,10 +149,28 @@ function BinaryCommonWriter(memory) ...@@ -149,10 +149,28 @@ function BinaryCommonWriter(memory)
} }
}; };
this.WriteColorSpreadsheet = function(color) this.WriteColorSpreadsheet = function(color)
{
if(color instanceof ThemeColor)
{
if(null != color.theme)
{
this.memory.WriteByte(c_oSer_ColorObjectType.Theme);
this.memory.WriteByte(c_oSerPropLenType.Byte);
this.memory.WriteByte(color.theme);
}
if(null != color.tint)
{
this.memory.WriteByte(c_oSer_ColorObjectType.Tint);
this.memory.WriteByte(c_oSerPropLenType.Double);
this.memory.WriteDouble(color.tint);
}
}
else
{ {
this.memory.WriteByte(c_oSer_ColorObjectType.Rgb); this.memory.WriteByte(c_oSer_ColorObjectType.Rgb);
this.memory.WriteByte(c_oSerPropLenType.Long); this.memory.WriteByte(c_oSerPropLenType.Long);
this.memory.WriteLong(color); this.memory.WriteLong(color.getRgb());
}
}; };
}; };
function Binary_CommonReader(stream) function Binary_CommonReader(stream)
......
...@@ -131,23 +131,13 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -131,23 +131,13 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
{ {
// потом реализовать проверку на то, что нужно ли посылать // потом реализовать проверку на то, что нужно ли посылать
var _theme = this.wbModel.theme; var _theme = this.wbModel.theme;
var _clrMap = this.wbModel.clrSchemeMap.color_map;
var arr_colors = new Array(10); var arr_colors = new Array(10);
var rgba = {R:0, G:0, B:0, A:255}; var _count = arr_colors.length;
// bg1,tx1,bg2,tx2,accent1 - accent6
var array_colors_types = [6, 15, 7, 16, 0, 1, 2, 3, 4, 5];
var _count = array_colors_types.length;
var color = new CUniColor();
color.color = new CSchemeColor();
for (var i = 0; i < _count; ++i) for (var i = 0; i < _count; ++i)
{ {
color.color.id = array_colors_types[i]; var color = g_oColorManager.getThemeColor(i);
color.Calculate(_theme, _clrMap, rgba); arr_colors[i] = new CColor(color.getR(), color.getG(), color.getB());
var _rgba = color.RGBA;
arr_colors[i] = new CColor(_rgba.R, _rgba.G, _rgba.B);
} }
// теперь проверим // теперь проверим
...@@ -205,30 +195,11 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -205,30 +195,11 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
for (var i = 0; i < _count; ++i) for (var i = 0; i < _count; ++i)
{ {
var _color_src = this.GuiControlColorsMap[i]; for(var j = 0, length = g_oThemeColorTint.length; j < length; ++j)
_ret_array[_cur_index] = new CColor(_color_src.r, _color_src.g, _color_src.b);
_cur_index++;
// теперь с модификаторами
var _count_mods = g_oThemeColorsDefaultMods.length;
for (var j = 0; j < _count_mods; ++j)
{
var _mods = g_oThemeColorsDefaultMods[j];
var dst_mods = new CColorModifiers();
var _ind = 0;
for (var k in _mods)
{ {
dst_mods.Mods[_ind] = new CColorMod(); var tint = g_oThemeColorTint[j];
dst_mods.Mods[_ind].name = k; var color = g_oColorManager.getThemeColor(i, tint);
dst_mods.Mods[_ind].val = _mods[k]; _ret_array[_cur_index] = new CColor(color.getR(), color.getG(), color.getB());
_ind++;
}
var _rgba = {R:_color_src.r, G: _color_src.g, B:_color_src.b, A: 255};
dst_mods.Apply(_rgba);
_ret_array[_cur_index] = new CColor(_rgba.R, _rgba.G, _rgba.B);
_cur_index++; _cur_index++;
} }
} }
...@@ -2150,21 +2121,19 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -2150,21 +2121,19 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
asc_setCellTextColor: function (color) { asc_setCellTextColor: function (color) {
if(color instanceof CAscColor) if(color instanceof CAscColor)
{ {
//преобразуем в css color = CorrectAscColor(color);
color = asc.numberToCSSColor((color.get_r() << 16) | (color.get_g() << 8) | color.get_b());
}
this.wb.setFontAttributes("c", color); this.wb.setFontAttributes("c", color);
this.wb.restoreFocus(); this.wb.restoreFocus();
}
}, },
asc_setCellBackgroundColor: function (color) { asc_setCellBackgroundColor: function (color) {
if(color instanceof CAscColor) if(color instanceof CAscColor)
{ {
//преобразуем в css color = CorrectAscColor(color);
color = asc.numberToCSSColor((color.get_r() << 16) | (color.get_g() << 8) | color.get_b());
}
this.wb.getWorksheet().setSelectionInfo("bc", color); this.wb.getWorksheet().setSelectionInfo("bc", color);
this.wb.restoreFocus(); this.wb.restoreFocus();
}
}, },
asc_setCellBorders: function (borders) { asc_setCellBorders: function (borders) {
......
...@@ -105,6 +105,47 @@ function numberToAscColor(n) { ...@@ -105,6 +105,47 @@ function numberToAscColor(n) {
return CreateAscColorCustom(r, g, b); return CreateAscColorCustom(r, g, b);
} }
function colorObjToAscColor(color) {
var oRes = null;
var n = color.getRgb();
var r = (n >> 16) & 0xff;
var g = (n >> 8) & 0xff;
var b = n & 0xff;
var bTheme = false;
if(color instanceof ThemeColor && null != color.theme)
{
var array_colors_types = [6, 15, 7, 16, 0, 1, 2, 3, 4, 5];
var themePresentation = array_colors_types[color.theme];
var tintExcel = 0;
if(null != color.tint)
tintExcel = color.tint;
var tintPresentation = 0;
for(var i = 0 , length = g_oThemeColorTint.length; i < length; ++i)
{
var cur = g_oThemeColorTint[i];
//0.005 установлено экспериментально
if(Math.abs(cur - tintExcel) < 0.005)
{
bTheme = true;
tintPresentation = i;
break;
}
}
if(bTheme)
{
oRes = new CAscColor();
oRes.r = r;
oRes.g = g;
oRes.b = b;
oRes.a = 255;
oRes.type = c_oAscColor.COLOR_TYPE_SCHEME;
oRes.value = themePresentation;
}
}
if(false == bTheme)
oRes = CreateAscColorCustom(r, g, b);
return oRes;
}
var oldPpi = undefined, var oldPpi = undefined,
cvt = undefined; cvt = undefined;
...@@ -1211,6 +1252,7 @@ window["Asc"].getCvtRatio = getCvtRatio; ...@@ -1211,6 +1252,7 @@ window["Asc"].getCvtRatio = getCvtRatio;
window["Asc"].calcNearestPt = calcNearestPt; window["Asc"].calcNearestPt = calcNearestPt;
window["Asc"].numberToCSSColor = numberToCSSColor; window["Asc"].numberToCSSColor = numberToCSSColor;
window["Asc"].numberToAscColor = numberToAscColor; window["Asc"].numberToAscColor = numberToAscColor;
window["Asc"].colorObjToAscColor = colorObjToAscColor;
window["Asc"].parseColor = parseColor; window["Asc"].parseColor = parseColor;
window["Asc"].FontProperties = FontProperties; window["Asc"].FontProperties = FontProperties;
......
...@@ -934,7 +934,7 @@ ...@@ -934,7 +934,7 @@
var otd_color_fon = $("#td_color_fon"); var otd_color_fon = $("#td_color_fon");
otd_color_fon.blur(); otd_color_fon.blur();
$("#td_BackgroundColor").removeClass("iconPressed"); $("#td_BackgroundColor").removeClass("iconPressed");
api.asc_setCellBackgroundColor(a2) api.asc_setCellBackgroundColor(Asc.numberToAscColor(Asc.parseColor(a2).binary));
return false; return false;
}); });
$(".clrPicker2, .clrPicker3").mousedown(function(event){ $(".clrPicker2, .clrPicker3").mousedown(function(event){
...@@ -980,7 +980,7 @@ ...@@ -980,7 +980,7 @@
otd_color.blur(); otd_color.blur();
$("#td_TextColor").removeClass("iconPressed"); $("#td_TextColor").removeClass("iconPressed");
// changeFontColor(a2,"text"); // changeFontColor(a2,"text");
api.asc_setCellTextColor(a2) api.asc_setCellTextColor(Asc.numberToAscColor(Asc.parseColor(a2).binary))
return false; return false;
}); });
$("#td_func_choose").mousedown(function(event) { $("#td_func_choose").mousedown(function(event) {
...@@ -1035,34 +1035,34 @@ ...@@ -1035,34 +1035,34 @@
} }
case "1":{ case "1":{
val = []; val = [];
val[c_oAscBorderOptions.Left] = new window.Asc.asc_CBorder(0, "thin", "#000"); val[c_oAscBorderOptions.Left] = new window.Asc.asc_CBorder(0, "thin", Asc.numberToAscColor(Asc.parseColor("#000").binary));
api.asc_setCellBorders(val); api.asc_setCellBorders(val);
break; break;
} }
case "4":{ case "4":{
val = []; val = [];
val[c_oAscBorderOptions.Top] = new window.Asc.asc_CBorder(0, "thin", "#000"); val[c_oAscBorderOptions.Top] = new window.Asc.asc_CBorder(0, "thin", Asc.numberToAscColor(Asc.parseColor("#000").binary));
api.asc_setCellBorders(val); api.asc_setCellBorders(val);
break; break;
} }
case "16":{ case "16":{
val = []; val = [];
val[c_oAscBorderOptions.Right] = new window.Asc.asc_CBorder(0, "thin", "#000"); val[c_oAscBorderOptions.Right] = new window.Asc.asc_CBorder(0, "thin", Asc.numberToAscColor(Asc.parseColor("#000").binary));
api.asc_setCellBorders(val); api.asc_setCellBorders(val);
break; break;
} }
case "64":{ case "64":{
val = []; val = [];
val[c_oAscBorderOptions.Bottom] = new window.Asc.asc_CBorder(0, "thin", "#000"); val[c_oAscBorderOptions.Bottom] = new window.Asc.asc_CBorder(0, "thin", Asc.numberToAscColor(Asc.parseColor("#000").binary));
api.asc_setCellBorders(val); api.asc_setCellBorders(val);
break; break;
} }
case "85":{ case "85":{
val = []; val = [];
val[c_oAscBorderOptions.Left] = new window.Asc.asc_CBorder(0, "thin", "#000"); val[c_oAscBorderOptions.Left] = new window.Asc.asc_CBorder(0, "thin", Asc.numberToAscColor(Asc.parseColor("#000").binary));
val[c_oAscBorderOptions.Top] = new window.Asc.asc_CBorder(0, "thin", "#000"); val[c_oAscBorderOptions.Top] = new window.Asc.asc_CBorder(0, "thin", Asc.numberToAscColor(Asc.parseColor("#000").binary));
val[c_oAscBorderOptions.Right] = new window.Asc.asc_CBorder(0, "thin", "#000"); val[c_oAscBorderOptions.Right] = new window.Asc.asc_CBorder(0, "thin", Asc.numberToAscColor(Asc.parseColor("#000").binary));
val[c_oAscBorderOptions.Bottom] = new window.Asc.asc_CBorder(0, "thin", "#000"); val[c_oAscBorderOptions.Bottom] = new window.Asc.asc_CBorder(0, "thin", Asc.numberToAscColor(Asc.parseColor("#000").binary));
api.asc_setCellBorders(val); api.asc_setCellBorders(val);
break; break;
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -221,6 +221,8 @@ UndoRedoItemSerializable.prototype = { ...@@ -221,6 +221,8 @@ UndoRedoItemSerializable.prototype = {
{ {
if(null != oDataObject.Read_FromBinary2) if(null != oDataObject.Read_FromBinary2)
oDataObject.Read_FromBinary2(oBinaryReader); oDataObject.Read_FromBinary2(oBinaryReader);
else if(null != oDataObject.Read_FromBinary2AndReplace)
oDataObject = oDataObject.Read_FromBinary2AndReplace(oBinaryReader);
else else
this.DeserializeDataInner(oBinaryReader, oDataObject, nLength, false); this.DeserializeDataInner(oBinaryReader, oDataObject, nLength, false);
} }
...@@ -320,6 +322,8 @@ var UndoRedoDataTypes = new function() { ...@@ -320,6 +322,8 @@ var UndoRedoDataTypes = new function() {
this.DrawingObjectLayer = 31; this.DrawingObjectLayer = 31;
this.AutoFiltersOptionsElements = 32; this.AutoFiltersOptionsElements = 32;
this.SingleProperty = 33; this.SingleProperty = 33;
this.RgbColor = 34;
this.ThemeColor = 35;
this.Create = function(nType) this.Create = function(nType)
{ {
switch(nType) switch(nType)
...@@ -358,6 +362,8 @@ var UndoRedoDataTypes = new function() { ...@@ -358,6 +362,8 @@ var UndoRedoDataTypes = new function() {
case this.AutoFiltersOptions: return new Asc.AutoFiltersOptions(); break; case this.AutoFiltersOptions: return new Asc.AutoFiltersOptions(); break;
case this.AutoFiltersOptionsElements: return new Asc.AutoFiltersOptionsElements(); break; case this.AutoFiltersOptionsElements: return new Asc.AutoFiltersOptionsElements(); break;
case this.SingleProperty: return new UndoRedoData_SingleProperty(); break; case this.SingleProperty: return new UndoRedoData_SingleProperty(); break;
case this.RgbColor: return new RgbColor(); break;
case this.ThemeColor: return new ThemeColor(); break;
} }
return null; return null;
}; };
......
...@@ -1362,7 +1362,6 @@ function Workbook(sUrlPath, eventsHandlers, oApi){ ...@@ -1362,7 +1362,6 @@ function Workbook(sUrlPath, eventsHandlers, oApi){
this.nActive = 0; this.nActive = 0;
this.theme = GenerateDefaultTheme(this); this.theme = GenerateDefaultTheme(this);
this.clrSchemeMap = GenerateDefaultColorMap();
this.DefinedNames = new Object(); this.DefinedNames = new Object();
this.oRealDefinedNames = new Object(); this.oRealDefinedNames = new Object();
...@@ -1496,7 +1495,9 @@ Workbook.prototype.init=function(){ ...@@ -1496,7 +1495,9 @@ Workbook.prototype.init=function(){
} }
}; };
Workbook.prototype.rebuildColors=function(){ Workbook.prototype.rebuildColors=function(){
this.TableStyles.rebuildColors(this.theme); g_oColorManager.rebuildColors();
for(var i = 0 , length = this.aWorksheets.length; i < length; ++i)
this.aWorksheets[i].rebuildColors();;
} }
Workbook.prototype.getDefaultFont=function(){ Workbook.prototype.getDefaultFont=function(){
return g_oDefaultFont.fn; return g_oDefaultFont.fn;
...@@ -2107,6 +2108,11 @@ function Woorksheet(wb, _index, bAddUserId, sId){ ...@@ -2107,6 +2108,11 @@ function Woorksheet(wb, _index, bAddUserId, sId){
this.nMaxRowId = 1; this.nMaxRowId = 1;
this.nMaxColId = 1; this.nMaxColId = 1;
}; };
Woorksheet.prototype.rebuildColors=function(){
this._forEachCell(function(cell){
cell.cleanCache();
});
}
Woorksheet.prototype.generateFontMap=function(oFontMap){ Woorksheet.prototype.generateFontMap=function(oFontMap){
//пробегаемся по колонкам //пробегаемся по колонкам
for(var i in this.aCols) for(var i in this.aCols)
...@@ -3888,6 +3894,9 @@ Cell.prototype.Remove=function(){ ...@@ -3888,6 +3894,9 @@ Cell.prototype.Remove=function(){
Cell.prototype.getName=function(){ Cell.prototype.getName=function(){
return this.oId.getID(); return this.oId.getID();
}; };
Cell.prototype.cleanCache=function(){
this.oValue.cleanCache();
}
Cell.prototype.setFormula=function(val){ Cell.prototype.setFormula=function(val){
this.sFormula = val; this.sFormula = val;
this.oValue.cleanCache(); this.oValue.cleanCache();
...@@ -5168,7 +5177,7 @@ Range.prototype.setBorder=function(border){ ...@@ -5168,7 +5177,7 @@ Range.prototype.setBorder=function(border){
oNewBorderProp = oNewBorder.b; oNewBorderProp = oNewBorder.b;
break; break;
} }
if(null != oNewBorderProp && null != oCurBorderProp && null != oCurBorderProp.s && (oNewBorderProp.s != oCurBorderProp.s || oNewBorderProp.c != oCurBorderProp.c)){ if(null != oNewBorderProp && null != oCurBorderProp && null != oCurBorderProp.s && (oNewBorderProp.s != oCurBorderProp.s || oNewBorderProp.getRgbOrNull() != oCurBorderProp.getRgbOrNull())){
switch(type) switch(type)
{ {
case nEdgeTypeLeft: oCurBorder.r = new BorderProp(); break; case nEdgeTypeLeft: oCurBorder.r = new BorderProp(); break;
...@@ -5212,7 +5221,7 @@ Range.prototype.setBorder=function(border){ ...@@ -5212,7 +5221,7 @@ Range.prototype.setBorder=function(border){
oNewBorderProp = oNewBorder.b; oNewBorderProp = oNewBorder.b;
break; break;
} }
if(null != oNewBorderProp && null != oCurBorderProp && (oNewBorderProp.s != oCurBorderProp.s || oNewBorderProp.c != oCurBorderProp.c)){ if(null != oNewBorderProp && null != oCurBorderProp && (oNewBorderProp.s != oCurBorderProp.s || oNewBorderProp.getRgbOrNull() != oCurBorderProp.getRgbOrNull())){
switch(type) switch(type)
{ {
case nEdgeTypeLeft: oCurBorder.r = new BorderProp(); break; case nEdgeTypeLeft: oCurBorder.r = new BorderProp(); break;
...@@ -6917,7 +6926,7 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){ ...@@ -6917,7 +6926,7 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){
oHyperlinkFont.fn = this.worksheet.workbook.getDefaultFont(); oHyperlinkFont.fn = this.worksheet.workbook.getDefaultFont();
oHyperlinkFont.fs = this.worksheet.workbook.getDefaultSize(); oHyperlinkFont.fs = this.worksheet.workbook.getDefaultSize();
oHyperlinkFont.u = "single"; oHyperlinkFont.u = "single";
oHyperlinkFont.c = g_nColorHyperlink; oHyperlinkFont.c = g_oColorManager.getThemeColor(g_nColorHyperlink);
var bNeedCheckHyperlink = true; var bNeedCheckHyperlink = true;
var fCheckHyperlink = function(aHyperlinks) var fCheckHyperlink = function(aHyperlinks)
{ {
......
This diff is collapsed.
This diff is collapsed.
...@@ -1189,7 +1189,7 @@ ...@@ -1189,7 +1189,7 @@
borderTopColor = $(node).css('border-top-color');*/ borderTopColor = $(node).css('border-top-color');*/
var borderTopColor = 0; var borderTopColor = 0;
oNewItem.borders.t.c = borderTopColor; oNewItem.borders.t.c = new RgbColor(borderTopColor);
var style = borderTopStyle + parseInt(borderTopWidth).toString(); var style = borderTopStyle + parseInt(borderTopWidth).toString();
if(undefined != kBorderRevVal[$.inArray(style, kBorderRev)]) if(undefined != kBorderRevVal[$.inArray(style, kBorderRev)])
oNewItem.borders.t.s = kBorderRevVal[$.inArray(style, kBorderRev)]; oNewItem.borders.t.s = kBorderRevVal[$.inArray(style, kBorderRev)];
...@@ -1210,7 +1210,7 @@ ...@@ -1210,7 +1210,7 @@
borderBottomColor = $(node).css('border-bottom-color');*/ borderBottomColor = $(node).css('border-bottom-color');*/
var borderBottomColor = 0; var borderBottomColor = 0;
oNewItem.borders.b.c = borderBottomColor; oNewItem.borders.b.c = new RgbColor(borderBottomColor);
var style = borderBottomStyle + parseInt(borderBottomWidth).toString(); var style = borderBottomStyle + parseInt(borderBottomWidth).toString();
if(undefined != kBorderRevVal[$.inArray(style, kBorderRev)]) if(undefined != kBorderRevVal[$.inArray(style, kBorderRev)])
oNewItem.borders.b.s = kBorderRevVal[$.inArray(style, kBorderRev)]; oNewItem.borders.b.s = kBorderRevVal[$.inArray(style, kBorderRev)];
...@@ -1233,7 +1233,7 @@ ...@@ -1233,7 +1233,7 @@
borderLeftColor = $(node).css('border-left-color');*/ borderLeftColor = $(node).css('border-left-color');*/
var borderLeftColor = 0; var borderLeftColor = 0;
oNewItem.borders.l.c = borderLeftColor; oNewItem.borders.l.c = new RgbColor(borderLeftColor);
var style = borderLeftStyle + parseInt(borderLeftWidth).toString(); var style = borderLeftStyle + parseInt(borderLeftWidth).toString();
if(undefined != kBorderRevVal[$.inArray(style, kBorderRev)]) if(undefined != kBorderRevVal[$.inArray(style, kBorderRev)])
oNewItem.borders.l.s = kBorderRevVal[$.inArray(style, kBorderRev)]; oNewItem.borders.l.s = kBorderRevVal[$.inArray(style, kBorderRev)];
...@@ -1254,7 +1254,7 @@ ...@@ -1254,7 +1254,7 @@
borderRightColor = $(node).css('border-right-color'); */ borderRightColor = $(node).css('border-right-color'); */
var borderRightColor = 0; var borderRightColor = 0;
oNewItem.borders.r.c = borderRightColor; oNewItem.borders.r.c = new RgbColor(borderRightColor);
var style = borderRightStyle + parseInt(borderRightWidth).toString(); var style = borderRightStyle + parseInt(borderRightWidth).toString();
if(undefined != kBorderRevVal[$.inArray(style, kBorderRev)]) if(undefined != kBorderRevVal[$.inArray(style, kBorderRev)])
oNewItem.borders.r.s = kBorderRevVal[$.inArray(style, kBorderRev)]; oNewItem.borders.r.s = kBorderRevVal[$.inArray(style, kBorderRev)];
...@@ -2014,7 +2014,7 @@ ...@@ -2014,7 +2014,7 @@
function makeBorder(border) { function makeBorder(border) {
return !border || !border.s || border.s === "none" ? return !border || !border.s || border.s === "none" ?
"" : "" :
kBorder[border.s][1] + "px " + kBorder[border.s][0] + " " + number2color(border.c); kBorder[border.s][1] + "px " + kBorder[border.s][0] + " " + number2color(border.getRgbOrNull());
} }
table = doc.createElement("TABLE"); table = doc.createElement("TABLE");
...@@ -2162,7 +2162,7 @@ ...@@ -2162,7 +2162,7 @@
b = cell.getFill(); b = cell.getFill();
// если b==0 мы не зайдем в if, хотя b==0 это ни что иное, как черный цвет заливки. // если b==0 мы не зайдем в if, хотя b==0 это ни что иное, как черный цвет заливки.
if (b!=null) {td.style.backgroundColor = number2color(b);} if (b!=null) {td.style.backgroundColor = number2color(b.getRgb());}
var isQPrefix = cell.getQuotePrefix() var isQPrefix = cell.getQuotePrefix()
this._makeNodesFromCellValue(cell.getValue2(), fn ,fs,isQPrefix,isFormat,cell).forEach( this._makeNodesFromCellValue(cell.getValue2(), fn ,fs,isQPrefix,isFormat,cell).forEach(
......
...@@ -113,6 +113,7 @@ ...@@ -113,6 +113,7 @@
this.hasCursor = false; this.hasCursor = false;
this.hasFocus = false; this.hasFocus = false;
this.newTextFormat = undefined; this.newTextFormat = undefined;
this.newTextFormatAdditional = undefined;
this.selectionTimer = undefined; this.selectionTimer = undefined;
this.enableKeyEvents = true; this.enableKeyEvents = true;
this.isTopLineActive = false; this.isTopLineActive = false;
...@@ -314,7 +315,8 @@ ...@@ -314,7 +315,8 @@
if (first && last) { if (first && last) {
for (i = first.index; i <= last.index; ++i) { for (i = first.index; i <= last.index; ++i) {
var valTmp = t._setFormatProperty(opt.fragments[i].format, prop, val); var elem = opt.fragments[i];
var valTmp = t._setFormatProperty(elem.format, prop, val, elem);
// Только для горячих клавиш // Только для горячих клавиш
if (null === val) if (null === val)
val = valTmp; val = valTmp;
...@@ -337,9 +339,11 @@ ...@@ -337,9 +339,11 @@
first = t._findFragmentToInsertInto(t.cursorPos); first = t._findFragmentToInsertInto(t.cursorPos);
if (first) { if (first) {
if (!t.newTextFormat) { if (!t.newTextFormat) {
t.newTextFormat = t._cloneFormat(opt.fragments[first.index].format); var elem = opt.fragments[first.index];
t.newTextFormat = t._cloneFormat(elem.format);
t.newTextFormatAdditional = {theme: elem.theme, tint: elem.tint};
} }
t._setFormatProperty(t.newTextFormat, prop, val); t._setFormatProperty(t.newTextFormat, prop, val, t.newTextFormatAdditional);
} }
} }
...@@ -631,6 +635,7 @@ ...@@ -631,6 +635,7 @@
t._cleanFragments(opt.fragments); t._cleanFragments(opt.fragments);
t.textRender.setString(opt.fragments, t.textFlags); t.textRender.setString(opt.fragments, t.textFlags);
delete t.newTextFormat; delete t.newTextFormat;
delete t.newTextFormatAdditional;
if (opt.zoom > 0) { if (opt.zoom > 0) {
t.overlayCtx.setFont(t.drawingCtx.getFont()); t.overlayCtx.setFont(t.drawingCtx.getFont());
...@@ -1254,8 +1259,15 @@ ...@@ -1254,8 +1259,15 @@
} }
if (t.newTextFormat) { if (t.newTextFormat) {
t._addFragments([{format: t.newTextFormat, text: str}], pos); var oNewObj = {format: t.newTextFormat, text: str, theme: null, tint: null};
if(null != t.newTextFormatAdditional)
{
oNewObj.theme = t.newTextFormatAdditional.theme;
oNewObj.tint = t.newTextFormatAdditional.tint;
}
t._addFragments([oNewObj], pos);
delete t.newTextFormat; delete t.newTextFormat;
delete t.newTextFormatAdditional;
} else { } else {
f = t._findFragmentToInsertInto(pos); f = t._findFragmentToInsertInto(pos);
if (f) { if (f) {
...@@ -1412,8 +1424,8 @@ ...@@ -1412,8 +1424,8 @@
Array.prototype.splice.apply( Array.prototype.splice.apply(
opt.fragments, opt.fragments,
[f.index, 1].concat([ [f.index, 1].concat([
{format: t._cloneFormat(fr.format), text: fr.text.slice(0, pos - f.begin)}, {format: t._cloneFormat(fr.format), text: fr.text.slice(0, pos - f.begin), theme: fr.theme, tint: fr.tint},
{format: t._cloneFormat(fr.format), text: fr.text.slice(pos - f.begin)}])); {format: t._cloneFormat(fr.format), text: fr.text.slice(pos - f.begin), theme: fr.theme, tint: fr.tint}]));
} }
}, },
...@@ -1487,8 +1499,9 @@ ...@@ -1487,8 +1499,9 @@
} }
if (i < opt.fragments.length - 1 && if (i < opt.fragments.length - 1 &&
t._isEqualFormats(opt.fragments[i].format, opt.fragments[i + 1].format)) { t._isEqualFormats(opt.fragments[i].format, opt.fragments[i + 1].format)) {
var fr = opt.fragments[i];
opt.fragments.splice(i, 2, opt.fragments.splice(i, 2,
{format: opt.fragments[i].format, text: opt.fragments[i].text + opt.fragments[i + 1].text}); {format: fr.format, text: fr.text + fr.text, theme: fr.theme, tint: fr.tint});
continue; continue;
} }
++i; ++i;
...@@ -1524,7 +1537,7 @@ ...@@ -1524,7 +1537,7 @@
f1.c === f2.c && f1.va === f2.va; f1.c === f2.c && f1.va === f2.va;
}, },
_setFormatProperty: function (format, prop, val) { _setFormatProperty: function (format, prop, val, formatAdditional) {
switch (prop) { switch (prop) {
case "fn": format.fn = val; break; case "fn": format.fn = val; break;
case "fs": format.fs = val; break; case "fs": format.fs = val; break;
...@@ -1542,7 +1555,14 @@ ...@@ -1542,7 +1555,14 @@
break; break;
case "s": format.s = val; break; case "s": format.s = val; break;
case "fa": format.va = val; break; case "fa": format.va = val; break;
case "c": format.c = asc_parsecolor(val).binary; break; case "c":
format.c = asc.numberToCSSColor(val.getRgb());
if(val instanceof ThemeColor)
{
formatAdditional.theme = val.theme;
formatAdditional.tint = val.tint;
}
break;
} }
return val; return val;
}, },
......
...@@ -977,8 +977,12 @@ ...@@ -977,8 +977,12 @@
f_ = f; f_ = f;
this.fontNeedUpdate = false; this.fontNeedUpdate = false;
} }
var fillStyle;
ctx.setFillStyle(p.c || textColor); if(null != p.c && null != p.c.getRgb)
fillStyle = p.c.getRgb();
else
fillStyle = p.c || textColor;
ctx.setFillStyle(fillStyle);
p_ = p; p_ = p;
} }
if (p.skip > 0) { if (p.skip > 0) {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
var asc_round = asc.round; var asc_round = asc.round;
var asc_n2css = asc.numberToCSSColor; var asc_n2css = asc.numberToCSSColor;
var asc_n2Color = asc.numberToAscColor; var asc_n2Color = asc.numberToAscColor;
var asc_obj2Color = asc.colorObjToAscColor;
var asc_typeof = asc.typeOf; var asc_typeof = asc.typeOf;
var asc_debug = asc.outputDebugStr; var asc_debug = asc.outputDebugStr;
var asc_DC = asc.DrawingContext; var asc_DC = asc.DrawingContext;
...@@ -165,7 +166,7 @@ ...@@ -165,7 +166,7 @@
/** @type {String} */ /** @type {String} */
this.s = style !== undefined ? style : kcbNone; this.s = style !== undefined ? style : kcbNone;
/** @type {Number} */ /** @type {Number} */
this.c = color !== undefined ? color : 0; this.c = color !== undefined ? color.getRgb() : 0;
/** @type {Number} */ /** @type {Number} */
this.w = width !== undefined ? width : 0; this.w = width !== undefined ? width : 0;
/** @type {Boolean} */ /** @type {Boolean} */
...@@ -2200,6 +2201,8 @@ ...@@ -2200,6 +2201,8 @@
var ctx = (undefined === drawingCtx) ? this.drawingCtx : drawingCtx; var ctx = (undefined === drawingCtx) ? this.drawingCtx : drawingCtx;
var bg = c.getFill(); var bg = c.getFill();
if(null != bg)
bg = bg.getRgb();
var fl = this._getCellFlags(c); var fl = this._getCellFlags(c);
var range = fl.isMerged ? this._getMergedCellsRange(col, row) : undefined; var range = fl.isMerged ? this._getMergedCellsRange(col, row) : undefined;
var mwidth = 0, mheight = 0; var mwidth = 0, mheight = 0;
...@@ -2227,7 +2230,7 @@ ...@@ -2227,7 +2230,7 @@
if (c2) { if (c2) {
var bg2 = c2.getFill(); var bg2 = c2.getFill();
if (bg2 !== null) { if (bg2 !== null) {
ctx.setFillStyle(asc_n2css(bg2)) ctx.setFillStyle(asc_n2css(bg2.getRgb()))
.fillRect( .fillRect(
this.cols[col + 1].left - offsetX - this.width_1px, this.cols[col + 1].left - offsetX - this.width_1px,
this.rows[row].top - offsetY - this.height_1px, this.rows[row].top - offsetY - this.height_1px,
...@@ -2239,7 +2242,7 @@ ...@@ -2239,7 +2242,7 @@
if (c3) { if (c3) {
var bg3 = c3.getFill(); var bg3 = c3.getFill();
if (bg3 !== null) { if (bg3 !== null) {
ctx.setFillStyle(asc_n2css(bg3)) ctx.setFillStyle(asc_n2css(bg3.getRgb()))
.fillRect( .fillRect(
this.cols[col].left - offsetX - this.width_1px, this.cols[col].left - offsetX - this.width_1px,
this.rows[row + 1].top - offsetY - this.height_1px, this.rows[row + 1].top - offsetY - this.height_1px,
...@@ -3763,11 +3766,13 @@ ...@@ -3763,11 +3766,13 @@
cto = this._calcCellTextOffset(col, row, ha, tm.width); cto = this._calcCellTextOffset(col, row, ha, tm.width);
} }
} }
var oFontColor = c.getFontcolor();
if(null != oFontColor)
oFontColor = oFontColor.getRgb();
this._fetchCellCache(col, row).text = { this._fetchCellCache(col, row).text = {
state : this.stringRender.getInternalState(), state : this.stringRender.getInternalState(),
flags : fl, flags : fl,
color : (c.getFontcolor() || this.settings.cells.defaultState.color), color : (oFontColor || this.settings.cells.defaultState.color),
metrics : tm, metrics : tm,
cellW : cto.maxWidth, cellW : cto.maxWidth,
cellHA : ha, cellHA : ha,
...@@ -5703,17 +5708,17 @@ ...@@ -5703,17 +5708,17 @@
cell_info.font.strikeout = c.getStrikeout(); cell_info.font.strikeout = c.getStrikeout();
cell_info.font.subscript = fa === "subscript"; cell_info.font.subscript = fa === "subscript";
cell_info.font.superscript = fa === "superscript"; cell_info.font.superscript = fa === "superscript";
cell_info.font.color = (fc ? asc_n2Color(fc) : asc_n2Color(c_opt.defaultState.colorNumber)); cell_info.font.color = (fc ? asc_obj2Color(fc) : asc_n2Color(c_opt.defaultState.colorNumber));
cell_info.fill = new asc_CFill((null !== bg && undefined !== bg) ? asc_n2Color(bg) : bg); cell_info.fill = new asc_CFill((null !== bg && undefined !== bg) ? asc_obj2Color(bg) : bg);
cell_info.border = new asc_CBorders(); cell_info.border = new asc_CBorders();
cell_info.border.left = new asc_CBorder(b.l.w, b.l.s, asc_n2Color(b.l.c)); cell_info.border.left = new asc_CBorder(b.l.w, b.l.s, b.l.c);
cell_info.border.top = new asc_CBorder(b.t.w, b.t.s, asc_n2Color(b.t.c)); cell_info.border.top = new asc_CBorder(b.t.w, b.t.s, b.t.c);
cell_info.border.right = new asc_CBorder(b.r.w, b.r.s, asc_n2Color(b.r.c)); cell_info.border.right = new asc_CBorder(b.r.w, b.r.s, b.r.c);
cell_info.border.bottom = new asc_CBorder(b.b.w, b.b.s, asc_n2Color(b.b.c)); cell_info.border.bottom = new asc_CBorder(b.b.w, b.b.s, b.b.c);
cell_info.border.diagDown = new asc_CBorder(b.dd.w, b.dd.s, asc_n2Color(b.dd.c)); cell_info.border.diagDown = new asc_CBorder(b.dd.w, b.dd.s, b.dd.c);
cell_info.border.diagUp = new asc_CBorder(b.du.w, b.du.s, asc_n2Color(b.du.c)); cell_info.border.diagUp = new asc_CBorder(b.du.w, b.du.s, b.du.c);
// Получаем гиперссылку // Получаем гиперссылку
var ar = this.activeRange.clone(); var ar = this.activeRange.clone();
...@@ -6904,9 +6909,7 @@ ...@@ -6904,9 +6909,7 @@
if (b.style !== null && b.style !== undefined) {border.s = b.style;} if (b.style !== null && b.style !== undefined) {border.s = b.style;}
if (b.color !== null && b.color !== undefined) { if (b.color !== null && b.color !== undefined) {
if(b.color instanceof CAscColor) if(b.color instanceof CAscColor)
border.c = ((b.color.get_r() << 16) | (b.color.get_g() << 8) | b.color.get_b()); border.c = CorrectAscColor(b.color);
else
border.c = asc_parsecolor(b.color).binary;
} }
flag = flag || (b.width === null || b.style === null || b.color === null); flag = flag || (b.width === null || b.style === null || b.color === null);
} }
...@@ -6928,8 +6931,8 @@ ...@@ -6928,8 +6931,8 @@
case "fa": range.setFontAlign(val); break; case "fa": range.setFontAlign(val); break;
case "a": range.setAlignHorizontal(val); break; case "a": range.setAlignHorizontal(val); break;
case "va": range.setAlignVertical(val); break; case "va": range.setAlignVertical(val); break;
case "c": range.setFontcolor(asc_parsecolor(val).binary); break; case "c": range.setFontcolor(val); break;
case "bc": range.setFill((val) ? (asc_parsecolor(val).binary) : null); break; case "bc": range.setFill((val) ? (val) : null); break;
case "wrap": range.setWrap(val); break; case "wrap": range.setWrap(val); break;
case "shrink": range.setShrinkToFit(val); break; case "shrink": range.setShrinkToFit(val); break;
case "value": range.setValue(val); break; case "value": range.setValue(val); break;
...@@ -7361,7 +7364,7 @@ ...@@ -7361,7 +7364,7 @@
range.setItalic(currentObj[0].format.i); range.setItalic(currentObj[0].format.i);
range.setStrikeout(currentObj[0].format.s); range.setStrikeout(currentObj[0].format.s);
if(!isOneMerge && currentObj[0].format && currentObj[0].format.c != null && currentObj[0].format.c != undefined && asc_parsecolor(currentObj[0].format.c) != null) if(!isOneMerge && currentObj[0].format && currentObj[0].format.c != null && currentObj[0].format.c != undefined && asc_parsecolor(currentObj[0].format.c) != null)
range.setFontcolor(asc_parsecolor(currentObj[0].format.c).binary); range.setFontcolor(new RgbColor(asc_parsecolor(currentObj[0].format.c).binary));
range.setUnderline(currentObj[0].format.u); range.setUnderline(currentObj[0].format.u);
range.setAlignVertical(currentObj.va); range.setAlignVertical(currentObj.va);
range.setFontname(currentObj[0].format.fn); range.setFontname(currentObj[0].format.fn);
...@@ -7403,7 +7406,7 @@ ...@@ -7403,7 +7406,7 @@
range.setBorderSrc(currentObj.borders, false); range.setBorderSrc(currentObj.borders, false);
range.setWrap(currentObj.wrap); range.setWrap(currentObj.wrap);
if(currentObj.bc && currentObj.bc != 'rgba(0, 0, 0, 0)' && currentObj.bc != 'transparent' && '' != currentObj.bc && !isOneMerge) if(currentObj.bc && currentObj.bc != 'rgba(0, 0, 0, 0)' && currentObj.bc != 'transparent' && '' != currentObj.bc && !isOneMerge)
range.setFill(asc_parsecolor(currentObj.bc).binary); range.setFill(new RgbColor(asc_parsecolor(currentObj.bc).binary));
var link = values[r][c][0].hyperLink; var link = values[r][c][0].hyperLink;
if(link) if(link)
{ {
...@@ -7690,7 +7693,7 @@ ...@@ -7690,7 +7693,7 @@
range.setItalic(newVal.value2[numStyle].format.i); range.setItalic(newVal.value2[numStyle].format.i);
range.setStrikeout(newVal.value2[numStyle].format.s); range.setStrikeout(newVal.value2[numStyle].format.s);
if(!isOneMerge && newVal.value2[numStyle].format && newVal.value2[numStyle].format.c != null && newVal.value2[numStyle].format.c != undefined) if(!isOneMerge && newVal.value2[numStyle].format && newVal.value2[numStyle].format.c != null && newVal.value2[numStyle].format.c != undefined)
range.setFontcolor(asc_parsecolor(newVal.value2[numStyle].format.c).binary); range.setFontcolor(new RgbColor(asc_parsecolor(newVal.value2[numStyle].format.c).binary));
range.setUnderline(newVal.value2[numStyle].format.u); range.setUnderline(newVal.value2[numStyle].format.u);
//range.setAlignVertical(currentObj.va); //range.setAlignVertical(currentObj.va);
range.setFontname(newVal.value2[numStyle].format.fn); range.setFontname(newVal.value2[numStyle].format.fn);
...@@ -7717,7 +7720,6 @@ ...@@ -7717,7 +7720,6 @@
nameFormat = newVal.format.sFormat; nameFormat = newVal.format.sFormat;
if(nameFormat) if(nameFormat)
range.setNumFormat(nameFormat); range.setNumFormat(nameFormat);
range.setFill(newVal.fill); range.setFill(newVal.fill);
range.setWrap(newVal.wrap); range.setWrap(newVal.wrap);
...@@ -8788,11 +8790,16 @@ ...@@ -8788,11 +8790,16 @@
} }
bg = c.getFill(); bg = c.getFill();
if(null != bg)
bg = bg.getRgb();
t.isFormulaEditMode = false; t.isFormulaEditMode = false;
// Очищаем массив ячеек для текущей формулы // Очищаем массив ячеек для текущей формулы
t.arrActiveFormulaRanges = []; t.arrActiveFormulaRanges = [];
var oFontColor = c.getFontcolor();
if(null != oFontColor)
oFontColor = oFontColor.getRgb();
editor.open({ editor.open({
cellX: t.cellsLeft + tc[!fl.isMerged ? col : mc.c1].left - tc[vr.c1].left, cellX: t.cellsLeft + tc[!fl.isMerged ? col : mc.c1].left - tc[vr.c1].left,
cellY: t.cellsTop + tr[!fl.isMerged ? row : mc.r1].top - tr[vr.r1].top, cellY: t.cellsTop + tr[!fl.isMerged ? row : mc.r1].top - tr[vr.r1].top,
...@@ -8804,7 +8811,7 @@ ...@@ -8804,7 +8811,7 @@
font: new asc_FP(c.getFontname(), c.getFontsize()), font: new asc_FP(c.getFontname(), c.getFontsize()),
background: bg !== null ? asc_n2css(bg) : t.settings.cells.defaultState.background, background: bg !== null ? asc_n2css(bg) : t.settings.cells.defaultState.background,
hasBackground: bg !== null, hasBackground: bg !== null,
textColor: c.getFontcolor() || t.settings.cells.defaultState.color, textColor: oFontColor || t.settings.cells.defaultState.color,
cursorPos: cursorPos, cursorPos: cursorPos,
zoom: t.getZoom(), zoom: t.getZoom(),
focus: isFocus, focus: isFocus,
......
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