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

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

Не набивался мап картинок при чтении темы;
Поправлен баг с расчетом заливки автофигур по индексу стиля.
parent bef83b36
...@@ -1851,6 +1851,76 @@ CSrcRect.prototype = ...@@ -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() function CBlipFill()
{ {
this.type = FILL_TYPE_BLIP; this.type = FILL_TYPE_BLIP;
...@@ -1893,7 +1963,15 @@ CBlipFill.prototype = ...@@ -1893,7 +1963,15 @@ CBlipFill.prototype =
writeBool(w, false); writeBool(w, false);
} }
writeBool(w, this.stretch); 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); writeBool(w, this.rotWithShape);
}, },
...@@ -1925,7 +2003,15 @@ CBlipFill.prototype = ...@@ -1925,7 +2003,15 @@ CBlipFill.prototype =
this.srcRect = null; this.srcRect = null;
} }
this.stretch = readBool(r); 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); this.rotWithShape = readBool(r);
}, },
...@@ -1999,7 +2085,10 @@ CBlipFill.prototype = ...@@ -1999,7 +2085,10 @@ CBlipFill.prototype =
duplicate.VectorImageBin = this.VectorImageBin; duplicate.VectorImageBin = this.VectorImageBin;
duplicate.stretch = this.stretch; duplicate.stretch = this.stretch;
duplicate.tile = this.tile; if(isRealObject(this.tile))
{
duplicate.tile = this.tile.createDuplicate();
}
if (null != this.srcRect) if (null != this.srcRect)
duplicate.srcRect = this.srcRect.createDublicate(); duplicate.srcRect = this.srcRect.createDublicate();
...@@ -2034,11 +2123,20 @@ CBlipFill.prototype = ...@@ -2034,11 +2123,20 @@ CBlipFill.prototype =
return false; return false;
} }
if(fill.tile != this.tile) if(isRealObject(this.tile))
{ {
if(!this.tile.IsIdentical(fill.tile))
{
return false; return false;
} }
}
else
{
if(fill.tile)
{
return false;
}
}
/* /*
if(fill.rotWithShape != this.rotWithShape) if(fill.rotWithShape != this.rotWithShape)
{ {
...@@ -2064,9 +2162,16 @@ CBlipFill.prototype = ...@@ -2064,9 +2162,16 @@ CBlipFill.prototype =
{ {
_ret.stretch = this.stretch; _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) if(fill.rotWithShape === this.rotWithShape)
{ {
...@@ -3309,6 +3414,15 @@ function CompareUniFill(unifill_1, unifill_2) ...@@ -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) function CompareUnifillBool(u1, u2)
{ {
if(!u1 && !u2) if(!u1 && !u2)
...@@ -3354,7 +3468,7 @@ function CompareUnifillBool(u1, u2) ...@@ -3354,7 +3468,7 @@ function CompareUnifillBool(u1, u2)
return false; 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; return false;
break; break;
} }
...@@ -8262,9 +8376,9 @@ CTheme.prototype = ...@@ -8262,9 +8376,9 @@ CTheme.prototype =
} }
else if (idx >= 1001) 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) if(ret)
{ {
ret.checkPhColor(unicolor); ret.checkPhColor(unicolor);
......
...@@ -4488,8 +4488,20 @@ CShape.prototype = ...@@ -4488,8 +4488,20 @@ CShape.prototype =
getAllRasterImages: function(images) 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); 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(); var oContent = this.getDocContent();
if(oContent) if(oContent)
{ {
......
...@@ -2196,8 +2196,62 @@ function BinaryPPTYLoader() ...@@ -2196,8 +2196,62 @@ function BinaryPPTYLoader()
} }
case 2: case 2:
{ {
uni_fill.fill.setTile(true); var oBlipTile = new CBlipFillTile();
s.SkipRecord();
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; break;
} }
case 3: case 3:
......
...@@ -2340,10 +2340,16 @@ function CBinaryFileWriter() ...@@ -2340,10 +2340,16 @@ function CBinaryFileWriter()
oThis.EndRecord(); oThis.EndRecord();
} }
if (true === fill.tile) if (null != fill.tile)
{ {
oThis.StartRecord(2); oThis.StartRecord(2);
oThis.WriteUChar(g_nodeAttributeStart); 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.WriteUChar(g_nodeAttributeEnd);
oThis.EndRecord(); oThis.EndRecord();
} }
......
...@@ -3078,8 +3078,7 @@ function CorrectUniFill(asc_fill, unifill, editorId) ...@@ -3078,8 +3078,7 @@ function CorrectUniFill(asc_fill, unifill, editorId)
if (tile == c_oAscFillBlipType.STRETCH) if (tile == c_oAscFillBlipType.STRETCH)
ret.fill.tile = null; ret.fill.tile = null;
else if (tile == c_oAscFillBlipType.TILE) else if (tile == c_oAscFillBlipType.TILE)
ret.fill.tile = true; ret.fill.tile = new CBlipFillTile();
break; break;
} }
case c_oAscFill.FILL_TYPE_PATT: case c_oAscFill.FILL_TYPE_PATT:
......
...@@ -725,6 +725,7 @@ function CPPTXContentLoader() ...@@ -725,6 +725,7 @@ function CPPTXContentLoader()
this.stream.cur = stream.cur; this.stream.cur = stream.cur;
this.Reader.stream = this.stream; this.Reader.stream = this.stream;
this.Reader.ImageMapChecker = this.ImageMapChecker;
return this.Reader.ReadTheme(); 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