Commit e58d6308 authored by Alexander.Trofimov's avatar Alexander.Trofimov

.prototype = {} -> .prototype.method

parent 5f8b00fa
...@@ -492,29 +492,28 @@ var g_oFontProperties = { ...@@ -492,29 +492,28 @@ var g_oFontProperties = {
c: 7, c: 7,
va: 8 va: 8
}; };
/** @constructor */
function Font(val) /** @constructor */
{ function Font(val) {
if(null == val) if (null == val) {
val = g_oDefaultFormat.FontAbs; val = g_oDefaultFormat.FontAbs;
this.Properties = g_oFontProperties; }
this.fn = val.fn; this.Properties = g_oFontProperties;
this.scheme = val.scheme; this.fn = val.fn;
this.fs = val.fs; this.scheme = val.scheme;
this.b = val.b; this.fs = val.fs;
this.i = val.i; this.b = val.b;
this.u = val.u; this.i = val.i;
this.s = val.s; this.u = val.u;
this.c = val.c; this.s = val.s;
this.va = val.va; this.c = val.c;
//skip и repeat не сохраняются в файл нужны здесь только чтобы класс Font можно было использовать в комплексных строках this.va = val.va;
this.skip = val.skip; //skip и repeat не сохраняются в файл нужны здесь только чтобы класс Font можно было использовать в комплексных строках
this.repeat = val.repeat; this.skip = val.skip;
} this.repeat = val.repeat;
Font.prototype = }
{
clean : function() Font.prototype.clean = function () {
{
this.fn = null; this.fn = null;
this.scheme = null; this.scheme = null;
this.fs = null; this.fs = null;
...@@ -526,16 +525,15 @@ Font.prototype = ...@@ -526,16 +525,15 @@ Font.prototype =
this.va = null; this.va = null;
this.skip = null; this.skip = null;
this.repeat = null; this.repeat = null;
}, };
_mergeProperty : function(first, second, def) Font.prototype._mergeProperty = function (first, second, def) {
{ if (def != first) {
if(def != first)
return first; return first;
else } else {
return second; return second;
}, }
merge : function(font) };
{ Font.prototype.merge = function (font) {
var defaultFontAbs = g_oDefaultFormat.FontAbs; var defaultFontAbs = g_oDefaultFormat.FontAbs;
var oRes = new Font(); var oRes = new Font();
oRes.fn = this._mergeProperty(this.fn, font.fn, defaultFontAbs.fn); oRes.fn = this._mergeProperty(this.fn, font.fn, defaultFontAbs.fn);
...@@ -546,184 +544,244 @@ Font.prototype = ...@@ -546,184 +544,244 @@ Font.prototype =
oRes.u = this._mergeProperty(this.u, font.u, defaultFontAbs.u); oRes.u = this._mergeProperty(this.u, font.u, defaultFontAbs.u);
oRes.s = this._mergeProperty(this.s, font.s, defaultFontAbs.s); oRes.s = this._mergeProperty(this.s, font.s, defaultFontAbs.s);
//заглушка excel при merge стилей игнорирует default цвет //заглушка excel при merge стилей игнорирует default цвет
if(this.c instanceof ThemeColor && g_nColorTextDefault == this.c.theme && null == this.c.tint) if (this.c instanceof ThemeColor && g_nColorTextDefault == this.c.theme && null == this.c.tint) {
oRes.c = this._mergeProperty(font.c, this.c, defaultFontAbs.c); oRes.c = this._mergeProperty(font.c, this.c, defaultFontAbs.c);
else } else {
oRes.c = this._mergeProperty(this.c, font.c, defaultFontAbs.c); oRes.c = this._mergeProperty(this.c, font.c, defaultFontAbs.c);
}
oRes.va = this._mergeProperty(this.va, font.va, defaultFontAbs.va); oRes.va = this._mergeProperty(this.va, font.va, defaultFontAbs.va);
oRes.skip = this._mergeProperty(this.skip, font.skip, defaultFontAbs.skip); oRes.skip = this._mergeProperty(this.skip, font.skip, defaultFontAbs.skip);
oRes.repeat = this._mergeProperty(this.repeat, font.repeat, defaultFontAbs.repeat); oRes.repeat = this._mergeProperty(this.repeat, font.repeat, defaultFontAbs.repeat);
return oRes; return oRes;
}, };
getRgbOrNull : function() Font.prototype.getRgbOrNull = function () {
{
var nRes = null; var nRes = null;
if(null != this.c) if (null != this.c) {
nRes = this.c.getRgb(); nRes = this.c.getRgb();
}
return nRes; return nRes;
}, };
getDif : function(val) Font.prototype.getDif = function (val) {
{
var oRes = new Font(this); var oRes = new Font(this);
var bEmpty = true; var bEmpty = true;
if(this.fn == val.fn) if (this.fn == val.fn) {
oRes.fn = null; oRes.fn = null;
else } else {
bEmpty = false; bEmpty = false;
if(this.scheme == val.scheme) }
oRes.scheme = null; if (this.scheme == val.scheme) {
else oRes.scheme = null;
} else {
bEmpty = false; bEmpty = false;
if(this.fs == val.fs) }
oRes.fs = null; if (this.fs == val.fs) {
else oRes.fs = null;
} else {
bEmpty = false; bEmpty = false;
if(this.b == val.b) }
oRes.b = null; if (this.b == val.b) {
else oRes.b = null;
} else {
bEmpty = false; bEmpty = false;
if(this.i == val.i) }
oRes.i = null; if (this.i == val.i) {
else oRes.i = null;
} else {
bEmpty = false; bEmpty = false;
if(this.u == val.u) }
oRes.u = null; if (this.u == val.u) {
else oRes.u = null;
} else {
bEmpty = false; bEmpty = false;
if(this.s == val.s) }
oRes.s = null; if (this.s == val.s) {
else oRes.s = null;
} else {
bEmpty = false; bEmpty = false;
if(g_oColorManager.isEqual(this.c, val.c)) }
oRes.c = null; if (g_oColorManager.isEqual(this.c, val.c)) {
else oRes.c = null;
} else {
bEmpty = false; bEmpty = false;
if(this.va == val.va) }
oRes.va = null; if (this.va == val.va) {
else oRes.va = null;
} else {
bEmpty = false; bEmpty = false;
if(this.skip == val.skip) }
oRes.skip = null; if (this.skip == val.skip) {
else oRes.skip = null;
} else {
bEmpty = false; bEmpty = false;
if(this.repeat == val.repeat) }
oRes.repeat = null; if (this.repeat == val.repeat) {
else oRes.repeat = null;
} else {
bEmpty = false; bEmpty = false;
if(bEmpty) }
if (bEmpty) {
oRes = null; oRes = null;
}
return oRes; return oRes;
}, };
isEqual : function(font) Font.prototype.isEqual = function (font) {
{
var bRes = this.fs == font.fs && this.b == font.b && this.i == font.i && this.u == font.u && this.s == font.s && var bRes = this.fs == font.fs && this.b == font.b && this.i == font.i && this.u == font.u && this.s == font.s &&
g_oColorManager.isEqual(this.c, font.c) && this.va == font.va && this.skip == font.skip && this.repeat == font.repeat; g_oColorManager.isEqual(this.c, font.c) && this.va == font.va && this.skip == font.skip &&
if(bRes) this.repeat == font.repeat;
{ if (bRes) {
if (Asc.EFontScheme.fontschemeNone == this.scheme && Asc.EFontScheme.fontschemeNone == font.scheme) if (Asc.EFontScheme.fontschemeNone == this.scheme && Asc.EFontScheme.fontschemeNone == font.scheme) {
bRes = this.fn == font.fn; bRes = this.fn == font.fn;
else if (Asc.EFontScheme.fontschemeNone != this.scheme && Asc.EFontScheme.fontschemeNone != font.scheme) } else if (Asc.EFontScheme.fontschemeNone != this.scheme &&
Asc.EFontScheme.fontschemeNone != font.scheme) {
bRes = this.scheme == font.scheme; bRes = this.scheme == font.scheme;
else } else {
bRes = false; bRes = false;
}
} }
return bRes; return bRes;
}, };
clone : function() Font.prototype.clone = function () {
{
return new Font(this); return new Font(this);
}, };
set : function(oVal) Font.prototype.set = function (oVal) {
{ if (null != oVal.fn) {
if (null != oVal.fn) { this.fn = oVal.fn;
this.fn = oVal.fn; this.scheme = Asc.EFontScheme.fontschemeNone;
this.scheme = Asc.EFontScheme.fontschemeNone; }
} if (null != oVal.scheme) {
if(null != oVal.scheme) this.scheme = oVal.scheme;
this.scheme = oVal.scheme; }
if(null != oVal.fs) if (null != oVal.fs) {
this.fs = oVal.fs; this.fs = oVal.fs;
if(null != oVal.b) }
this.b = oVal.b; if (null != oVal.b) {
if(null != oVal.i) this.b = oVal.b;
this.i = oVal.i; }
if(null != oVal.u) if (null != oVal.i) {
this.u = oVal.u; this.i = oVal.i;
if(null != oVal.s) }
this.s = oVal.s; if (null != oVal.u) {
if(null != oVal.c) this.u = oVal.u;
this.c = oVal.c; }
if(null != oVal.va) if (null != oVal.s) {
this.va = oVal.va; this.s = oVal.s;
if(null != oVal.skip) }
this.skip = oVal.skip; if (null != oVal.c) {
if(null != oVal.repeat) this.c = oVal.c;
this.repeat = oVal.repeat; }
}, if (null != oVal.va) {
intersect : function(oFont, oDefVal) this.va = oVal.va;
{ }
if(this.fn != oFont.fn) if (null != oVal.skip) {
this.fn = oDefVal.fn; this.skip = oVal.skip;
if(this.scheme != oFont.scheme) }
this.scheme = oDefVal.scheme; if (null != oVal.repeat) {
if(this.fs != oFont.fs) this.repeat = oVal.repeat;
this.fs = oDefVal.fs; }
if(this.b != oFont.b) };
this.b = oDefVal.b; Font.prototype.intersect = function (oFont, oDefVal) {
if(this.i != oFont.i) if (this.fn != oFont.fn) {
this.i = oDefVal.i; this.fn = oDefVal.fn;
if(this.u != oFont.u) }
this.u = oDefVal.u; if (this.scheme != oFont.scheme) {
if(this.s != oFont.s) this.scheme = oDefVal.scheme;
this.s = oDefVal.s; }
if(false == g_oColorManager.isEqual(this.c, oFont.c)) if (this.fs != oFont.fs) {
this.c = oDefVal.c; this.fs = oDefVal.fs;
if(this.va != oFont.va) }
this.va = oDefVal.va; if (this.b != oFont.b) {
if(this.skip != oFont.skip) this.b = oDefVal.b;
this.skip = oDefVal.skip; }
if(this.repeat != oFont.repeat) if (this.i != oFont.i) {
this.repeat = oDefVal.repeat; this.i = oDefVal.i;
}, }
getType : function() if (this.u != oFont.u) {
{ this.u = oDefVal.u;
}
if (this.s != oFont.s) {
this.s = oDefVal.s;
}
if (false == g_oColorManager.isEqual(this.c, oFont.c)) {
this.c = oDefVal.c;
}
if (this.va != oFont.va) {
this.va = oDefVal.va;
}
if (this.skip != oFont.skip) {
this.skip = oDefVal.skip;
}
if (this.repeat != oFont.repeat) {
this.repeat = oDefVal.repeat;
}
};
Font.prototype.getType = function () {
return UndoRedoDataTypes.StyleFont; return UndoRedoDataTypes.StyleFont;
}, };
getProperties : function() Font.prototype.getProperties = function () {
{
return this.Properties; return this.Properties;
}, };
getProperty : function(nType) Font.prototype.getProperty = function (nType) {
{ switch (nType) {
switch(nType) case this.Properties.fn:
{ return this.fn;
case this.Properties.fn: return this.fn;break; break;
case this.Properties.scheme: return this.scheme;break; case this.Properties.scheme:
case this.Properties.fs: return this.fs;break; return this.scheme;
case this.Properties.b: return this.b;break; break;
case this.Properties.i: return this.i;break; case this.Properties.fs:
case this.Properties.u: return this.u;break; return this.fs;
case this.Properties.s: return this.s;break; break;
case this.Properties.c: return this.c;break; case this.Properties.b:
case this.Properties.va: return this.va;break; return this.b;
break;
case this.Properties.i:
return this.i;
break;
case this.Properties.u:
return this.u;
break;
case this.Properties.s:
return this.s;
break;
case this.Properties.c:
return this.c;
break;
case this.Properties.va:
return this.va;
break;
} }
}, };
setProperty : function(nType, value) Font.prototype.setProperty = function (nType, value) {
{ switch (nType) {
switch(nType) case this.Properties.fn:
{ this.fn = value;
case this.Properties.fn: this.fn = value;break; break;
case this.Properties.scheme: this.scheme = value;break; case this.Properties.scheme:
case this.Properties.fs: this.fs = value;break; this.scheme = value;
case this.Properties.b: this.b = value;break; break;
case this.Properties.i: this.i = value;break; case this.Properties.fs:
case this.Properties.u: this.u = value;break; this.fs = value;
case this.Properties.s: this.s = value;break; break;
case this.Properties.c: this.c = value;break; case this.Properties.b:
case this.Properties.va: this.va = value;break; this.b = value;
break;
case this.Properties.i:
this.i = value;
break;
case this.Properties.u:
this.u = value;
break;
case this.Properties.s:
this.s = value;
break;
case this.Properties.c:
this.c = value;
break;
case this.Properties.va:
this.va = value;
break;
} }
} };
};
var g_oFillProperties = { var g_oFillProperties = {
bg: 0 bg: 0
}; };
......
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