Commit 271c8c0a authored by Sergey Luzyanin's avatar Sergey Luzyanin Committed by Alexander.Trofimov

Объект класса CBlipFillTile для настроек тайловой заливки вместо флага;

Не набивался мап картинок при чтении темы;
Поправлен баг с расчетом заливки автофигур по индексу стиля.
parent bef83b36
......@@ -1851,6 +1851,76 @@ CSrcRect.prototype =
}
};
var TILE_FLIP_MODE_NONE = 0;
var TILE_FLIP_MODE_X = 1;
var TILE_FLIP_MODE_Y = 2;
var TILE_FLIP_MODE_XY = 3;
var TILE_RECT_ALIGN_B = 0;
var TILE_RECT_ALIGN_BL = 1;
var TILE_RECT_ALIGN_BR = 2;
var TILE_RECT_ALIGN_CTR = 3;
var TILE_RECT_ALIGN_L = 4;
var TILE_RECT_ALIGN_R = 5;
var TILE_RECT_ALIGN_T = 6;
var TILE_RECT_ALIGN_TL = 7;
var TILE_RECT_ALIGN_TR = 8;
function CBlipFillTile()
{
this.tx = null;
this.ty = null;
this.sx = null;
this.sy = null;
this.flip = null;
this.algn = null;
}
CBlipFillTile.prototype.Write_ToBinary = function(w)
{
writeLong(w, this.tx);
writeLong(w, this.ty);
writeLong(w, this.sx);
writeLong(w, this.sy);
writeLong(w, this.flip);
writeLong(w, this.algn);
};
CBlipFillTile.prototype.Read_FromBinary = function(r)
{
this.tx = readLong(r);
this.ty = readLong(r);
this.sx = readLong(r);
this.sy = readLong(r);
this.flip = readLong(r);
this.algn = readLong(r);
};
CBlipFillTile.prototype.createDuplicate = function()
{
var ret = new CBlipFillTile();
ret.tx = this.tx;
ret.ty = this.ty;
ret.sx = this.sx;
ret.sy = this.sy;
ret.flip = this.flip;
ret.algn = this.algn;
return ret;
};
CBlipFillTile.prototype.IsIdentical = function(o)
{
if(!o)
{
return false;
}
return ( o.tx == this.tx &&
o.ty == this.ty &&
o.sx == this.sx &&
o.sy == this.sy &&
o.flip == this.flip &&
o.algn == this.algn)
};
function CBlipFill()
{
this.type = FILL_TYPE_BLIP;
......@@ -1893,7 +1963,15 @@ CBlipFill.prototype =
writeBool(w, false);
}
writeBool(w, this.stretch);
writeBool(w, this.tile);
if(isRealObject(this.tile))
{
w.WriteBool(true);
this.tile.Write_ToBinary(w);
}
else
{
w.WriteBool(false);
}
writeBool(w, this.rotWithShape);
},
......@@ -1925,7 +2003,15 @@ CBlipFill.prototype =
this.srcRect = null;
}
this.stretch = readBool(r);
this.tile = readBool(r);
if(r.GetBool())
{
this.tile = new CBlipFillTile();
this.tile.Read_FromBinary(r);
}
else
{
this.tile = null;
}
this.rotWithShape = readBool(r);
},
......@@ -1999,7 +2085,10 @@ CBlipFill.prototype =
duplicate.VectorImageBin = this.VectorImageBin;
duplicate.stretch = this.stretch;
duplicate.tile = this.tile;
if(isRealObject(this.tile))
{
duplicate.tile = this.tile.createDuplicate();
}
if (null != this.srcRect)
duplicate.srcRect = this.srcRect.createDublicate();
......@@ -2034,11 +2123,20 @@ CBlipFill.prototype =
return false;
}
if(fill.tile != this.tile)
if(isRealObject(this.tile))
{
if(!this.tile.IsIdentical(fill.tile))
{
return false;
}
}
else
{
if(fill.tile)
{
return false;
}
}
/*
if(fill.rotWithShape != this.rotWithShape)
{
......@@ -2064,9 +2162,16 @@ CBlipFill.prototype =
{
_ret.stretch = this.stretch;
}
if(fill.tile == this.tile)
if(isRealObject(fill.tile))
{
_ret.tile = this.tile;
if(fill.tile.IsIdentical(this.tile))
{
_ret.tile = this.tile.createDuplicate();
}
else
{
_ret.tile = new CBlipFillTile();
}
}
if(fill.rotWithShape === this.rotWithShape)
{
......@@ -3309,6 +3414,15 @@ function CompareUniFill(unifill_1, unifill_2)
}
function CompareBlipTiles(tile1, tile2)
{
if(isRealObject(tile1))
{
return tile1.IsIdentical(tile2);
}
return tile1 === tile2;
}
function CompareUnifillBool(u1, u2)
{
if(!u1 && !u2)
......@@ -3354,7 +3468,7 @@ function CompareUnifillBool(u1, u2)
return false;
}
if(u1.fill.stretch !== u2.fill.stretch || u1.fill.tile !== u2.fill.tile || u1.fill.rotWithShape !== u2.fill.rotWithShape)
if(u1.fill.stretch !== u2.fill.stretch || !CompareBlipTiles(u1.fill.tile, u2.fill.tile) || u1.fill.rotWithShape !== u2.fill.rotWithShape)
return false;
break;
}
......@@ -8262,9 +8376,9 @@ CTheme.prototype =
}
else if (idx >= 1001)
{
if (this.themeElements.fmtScheme.bgFillStyleLst[idx-1])
if (this.themeElements.fmtScheme.bgFillStyleLst[idx-1001])
{
ret = this.themeElements.fmtScheme.bgFillStyleLst[idx-1].createDuplicate();
ret = this.themeElements.fmtScheme.bgFillStyleLst[idx-1001].createDuplicate();
if(ret)
{
ret.checkPhColor(unicolor);
......
......@@ -4488,8 +4488,20 @@ CShape.prototype =
getAllRasterImages: function(images)
{
if(this.spPr && this.spPr.Fill && this.spPr.Fill.fill && typeof this.spPr.Fill.fill.RasterImageId === "string" && this.spPr.Fill.fill.RasterImageId.length > 0)
if(this.spPr && this.spPr.Fill && this.spPr.Fill.fill && typeof (this.spPr.Fill.fill.RasterImageId) === "string" && this.spPr.Fill.fill.RasterImageId.length > 0)
images.push(this.spPr.Fill.fill.RasterImageId);
var compiled_style = this.getCompiledStyle();
var parents = this.getParentObjects();
if (isRealObject(parents.theme) && isRealObject(compiled_style) && isRealObject(compiled_style.fillRef))
{
var brush = parents.theme.getFillStyle(compiled_style.fillRef.idx, compiled_style.fillRef.Color);
if(brush && brush.fill && typeof (brush.fill.RasterImageId) === "string" && brush.fill.RasterImageId.length > 0)
{
images.push(brush.fill.RasterImageId);
}
}
var oContent = this.getDocContent();
if(oContent)
{
......
......@@ -2196,8 +2196,62 @@ function BinaryPPTYLoader()
}
case 2:
{
uni_fill.fill.setTile(true);
s.SkipRecord();
var oBlipTile = new CBlipFillTile();
var s = this.stream;
var _rec_start = s.cur;
var _end_rec = _rec_start + s.GetLong() + 4;
s.Skip2(1); // start attributes
while (true)
{
var _at = s.GetUChar();
if (_at == g_nodeAttributeEnd)
break;
switch (_at)
{
case 0:
{
oBlipTile.sx = s.GetLong();
break;
}
case 1:
{
oBlipTile.sy = s.GetLong();
break;
}
case 2:
{
oBlipTile.tx = s.GetLong();
break;
}
case 3:
{
oBlipTile.ty = s.GetLong();
break;
}
case 4:
{
oBlipTile.algn = s.GetUChar();
break;
}
case 5:
{
oBlipTile.flip = s.GetUChar();
break;
}
default:
{
break;
}
}
}
s.Seek2(_end_rec);
uni_fill.fill.setTile(oBlipTile);
break;
}
case 3:
......
......@@ -2340,10 +2340,16 @@ function CBinaryFileWriter()
oThis.EndRecord();
}
if (true === fill.tile)
if (null != fill.tile)
{
oThis.StartRecord(2);
oThis.WriteUChar(g_nodeAttributeStart);
oThis._WriteInt2(0, fill.tile.sx);
oThis._WriteInt2(1, fill.tile.sy);
oThis._WriteInt2(2, fill.tile.tx);
oThis._WriteInt2(3, fill.tile.ty);
oThis._WriteInt2(4, fill.tile.algn);
oThis._WriteInt2(5, fill.tile.flip);
oThis.WriteUChar(g_nodeAttributeEnd);
oThis.EndRecord();
}
......
......@@ -3078,8 +3078,7 @@ function CorrectUniFill(asc_fill, unifill, editorId)
if (tile == c_oAscFillBlipType.STRETCH)
ret.fill.tile = null;
else if (tile == c_oAscFillBlipType.TILE)
ret.fill.tile = true;
ret.fill.tile = new CBlipFillTile();
break;
}
case c_oAscFill.FILL_TYPE_PATT:
......
......@@ -725,6 +725,7 @@ function CPPTXContentLoader()
this.stream.cur = stream.cur;
this.Reader.stream = this.stream;
this.Reader.ImageMapChecker = this.ImageMapChecker;
return this.Reader.ReadTheme();
}
......
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