Commit c44bb887 authored by SergeyLuzyanin's avatar SergeyLuzyanin

fix Bug 35081

parent 2a02978c
...@@ -288,6 +288,43 @@ ...@@ -288,6 +288,43 @@
this.w = this.r - this.l; this.w = this.r - this.l;
this.h = this.b - this.t; this.h = this.b - this.t;
}; };
CGraphicBounds.prototype.checkByOther = function(oBounds){
if(oBounds){
if(oBounds.l < this.l){
this.l = oBounds.l;
}
if(oBounds.t < this.t){
this.t = oBounds.t;
}
if(oBounds.r > this.r){
this.r = oBounds.r;
}
if(oBounds.b > this.b){
this.b = oBounds.b;
}
}
};
CGraphicBounds.prototype.checkWH = function(){
this.x = this.l;
this.y = this.t;
this.w = this.r - this.l;
this.h = this.b - this.t;
};
CGraphicBounds.prototype.reset = function(l, t, r, b){
this.l = l;
this.t = t;
this.r = r;
this.b = b;
this.x = l;
this.y = t;
this.w = r - l;
this.h = b - t;
};
/** /**
* Base class for all graphic objects * Base class for all graphic objects
* @constructor * @constructor
......
...@@ -108,10 +108,13 @@ function SlideLayout() ...@@ -108,10 +108,13 @@ function SlideLayout()
this.Master = null; this.Master = null;
this.maxId = 1000; this.maxId = 1000;
this.bounds = new AscFormat.CGraphicBounds(0.0, 0.0, 0.0, 0.0);
this.recalcInfo = this.recalcInfo =
{ {
recalculateBackground: true, recalculateBackground: true,
recalculateSpTree: true recalculateSpTree: true,
recalculateBounds: true
}; };
...@@ -294,11 +297,32 @@ SlideLayout.prototype = ...@@ -294,11 +297,32 @@ SlideLayout.prototype =
var _shapes = this.cSld.spTree; var _shapes = this.cSld.spTree;
var _shape_index; var _shape_index;
var _shape_count = _shapes.length; var _shape_count = _shapes.length;
var bRecalculateBounds = this.recalcInfo.recalculateBounds;
if(bRecalculateBounds){
this.bounds.reset(this.Width + 100.0, this.Height + 100.0, -100.0, -100.0);
}
var bChecked = false;
for(_shape_index = 0; _shape_index < _shape_count; ++_shape_index) for(_shape_index = 0; _shape_index < _shape_count; ++_shape_index)
{ {
if(!_shapes[_shape_index].isPlaceholder()) if(!_shapes[_shape_index].isPlaceholder()){
_shapes[_shape_index].recalculate(); _shapes[_shape_index].recalculate();
if(bRecalculateBounds){
this.bounds.checkByOther(_shapes[_shape_index].bounds);
}
bChecked = true;
}
} }
if(bRecalculateBounds){
if(bChecked){
this.bounds.checkWH();
}
else{
this.bounds.reset(0.0, 0.0, 0.0, 0.0);
}
this.recalcInfo.recalculateBounds = false;
}
}, },
recalculate2: function() recalculate2: function()
......
...@@ -1033,15 +1033,24 @@ Slide.prototype = ...@@ -1033,15 +1033,24 @@ Slide.prototype =
draw: function(graphics) draw: function(graphics)
{ {
var _bounds;
DrawBackground(graphics, this.backgroundFill, this.Width, this.Height); DrawBackground(graphics, this.backgroundFill, this.Width, this.Height);
if(this.showMasterSp === true || (!(this.showMasterSp === false) && (this.Layout.showMasterSp == undefined || this.Layout.showMasterSp))) if(this.showMasterSp === true || (!(this.showMasterSp === false) && (this.Layout.showMasterSp == undefined || this.Layout.showMasterSp)))
{ {
if (graphics.IsSlideBoundsCheckerType === undefined) if (graphics.IsSlideBoundsCheckerType === undefined)
this.Layout.Master.draw(graphics); this.Layout.Master.draw(graphics);
else if(graphics.IsSlideBoundsCheckerType){
_bounds = this.Layout.Master.bounds;
graphics.rect(_bounds.l, _bounds.t, _bounds.w, _bounds.h);
}
} }
if (graphics && graphics.IsSlideBoundsCheckerType === undefined) if (graphics && graphics.IsSlideBoundsCheckerType === undefined)
this.Layout.draw(graphics); this.Layout.draw(graphics);
else{
_bounds = this.Layout.bounds;
graphics.rect(_bounds.l, _bounds.t, _bounds.w, _bounds.h);
}
for(var i=0; i < this.cSld.spTree.length; ++i) for(var i=0; i < this.cSld.spTree.length; ++i)
{ {
this.cSld.spTree[i].draw(graphics); this.cSld.spTree[i].draw(graphics);
......
...@@ -110,6 +110,7 @@ function MasterSlide(presentation, theme) ...@@ -110,6 +110,7 @@ function MasterSlide(presentation, theme)
this.DrawingDocument = editor.WordControl.m_oDrawingDocument; this.DrawingDocument = editor.WordControl.m_oDrawingDocument;
this.maxId = 1000; this.maxId = 1000;
this.bounds = new AscFormat.CGraphicBounds(0, 0, this.Width, this.Height);
//---------------------------------------------- //----------------------------------------------
this.presentation = editor.WordControl.m_oLogicDocument; this.presentation = editor.WordControl.m_oLogicDocument;
...@@ -119,7 +120,9 @@ function MasterSlide(presentation, theme) ...@@ -119,7 +120,9 @@ function MasterSlide(presentation, theme)
this.recalcInfo = this.recalcInfo =
{ {
recalculateBackground: true, recalculateBackground: true,
recalculateSpTree: true recalculateSpTree: true,
recalculateBounds: true
}; };
...@@ -157,6 +160,7 @@ MasterSlide.prototype = ...@@ -157,6 +160,7 @@ MasterSlide.prototype =
this.Id = r.GetString2(); this.Id = r.GetString2();
this.theme = AscFormat.readObject(r); this.theme = AscFormat.readObject(r);
}, },
draw: function(graphics) draw: function(graphics)
{ {
for(var i=0; i < this.cSld.spTree.length; ++i) for(var i=0; i < this.cSld.spTree.length; ++i)
...@@ -166,8 +170,6 @@ MasterSlide.prototype = ...@@ -166,8 +170,6 @@ MasterSlide.prototype =
} }
}, },
getMatchingLayout: function(type, matchingName, cSldName, themeFlag) getMatchingLayout: function(type, matchingName, cSldName, themeFlag)
{ {
var layoutType = type; var layoutType = type;
...@@ -253,7 +255,6 @@ MasterSlide.prototype = ...@@ -253,7 +255,6 @@ MasterSlide.prototype =
return this.sldLayoutLst[0]; return this.sldLayoutLst[0];
}, },
getMatchingShape: Slide.prototype.getMatchingShape,/*function(type, idx, bSingleBody) getMatchingShape: Slide.prototype.getMatchingShape,/*function(type, idx, bSingleBody)
{ {
var _input_reduced_type; var _input_reduced_type;
...@@ -393,12 +394,32 @@ MasterSlide.prototype = ...@@ -393,12 +394,32 @@ MasterSlide.prototype =
var _shapes = this.cSld.spTree; var _shapes = this.cSld.spTree;
var _shape_index; var _shape_index;
var _shape_count = _shapes.length; var _shape_count = _shapes.length;
var bRecalculateBounds = this.recalcInfo.recalculateBounds;
if(bRecalculateBounds){
this.bounds.reset(this.Width + 100.0, this.Height + 100.0, -100.0, -100.0);
}
var bChecked = false;
for(_shape_index = 0; _shape_index < _shape_count; ++_shape_index) for(_shape_index = 0; _shape_index < _shape_count; ++_shape_index)
{ {
if(!_shapes[_shape_index].isPlaceholder()) if(!_shapes[_shape_index].isPlaceholder()){
_shapes[_shape_index].recalculate(); _shapes[_shape_index].recalculate();
if(bRecalculateBounds){
this.bounds.checkByOther(_shapes[_shape_index].bounds);
}
bChecked = true;
}
}
if(bRecalculateBounds){
if(bChecked){
this.bounds.checkWH();
}
else{
this.bounds.reset(0.0, 0.0, 0.0, 0.0);
}
this.recalcInfo.recalculateBounds = false;
} }
}, },
checkSlideSize: Slide.prototype.checkSlideSize, checkSlideSize: Slide.prototype.checkSlideSize,
......
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