Commit 86255078 authored by Dmitry.Vikulov's avatar Dmitry.Vikulov Committed by Alexander.Trofimov

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48871 954022d7-b5bf-4e40-9824-e11837661b57
parent 51600023
...@@ -2178,6 +2178,16 @@ function DrawingObjects() { ...@@ -2178,6 +2178,16 @@ function DrawingObjects() {
return _t.graphicObject != null; return _t.graphicObject != null;
} }
_t.isLocked = function(callback) {
_this.objectLocker.reset();
if ( _t.graphicObject ) {
_this.objectLocker.addObjectId(_t.graphicObject.Id);
_this.objectLocker.checkObjects(callback);
}
else
callback(true);
}
_t.getWorkbook = function() { _t.getWorkbook = function() {
return (_t.worksheet ? _t.worksheet.model.workbook : null); return (_t.worksheet ? _t.worksheet.model.workbook : null);
} }
...@@ -2499,14 +2509,7 @@ function DrawingObjects() { ...@@ -2499,14 +2509,7 @@ function DrawingObjects() {
drawingObject.graphicObject.drawingBase = drawingObject; drawingObject.graphicObject.drawingBase = drawingObject;
drawingObject.graphicObject.drawingObjects = _this; drawingObject.graphicObject.drawingObjects = _this;
drawingObject.graphicObject.recalculate();
History.TurnOff();
var metrics = drawingObject.getGraphicObjectMetrics();
drawingObject.graphicObject.setPosition( metrics.x, metrics.y );
drawingObject.graphicObject.setExtents( metrics.extX, metrics.extY );
drawingObject.graphicObject.recalculateTransform();
drawingObject.graphicObject.calculateTransformTextMatrix();
History.TurnOn();
aObjects.push( drawingObject ); aObjects.push( drawingObject );
} }
...@@ -3169,318 +3172,325 @@ function DrawingObjects() { ...@@ -3169,318 +3172,325 @@ function DrawingObjects() {
var metrics = null; var metrics = null;
for (var i = 0; i < aObjects.length; i++) { for (var i = 0; i < aObjects.length; i++) {
var obj = aObjects[i]; var obj = aObjects[i];
var bbox = obj.isChart() ? obj.graphicObject.chart.range.intervalObject.getBBox0() : null; obj.isLocked(callbackFunc);
if ( obj.isChart() || obj.isImage() || obj.isShape() ) { function callbackFunc(result) {
if ( result ) {
var bbox = obj.isChart() ? obj.graphicObject.chart.range.intervalObject.getBBox0() : null;
metrics = { from: {}, to: {} }; if ( obj.isChart() || obj.isImage() || obj.isShape() ) {
metrics.from.col = obj.from.col; metrics.to.col = obj.to.col;
metrics.from.colOff = obj.from.colOff; metrics.to.colOff = obj.to.colOff;
metrics.from.row = obj.from.row; metrics.to.row = obj.to.row;
metrics.from.rowOff = obj.from.rowOff; metrics.to.rowOff = obj.to.rowOff;
if (bInsert) { // Insert
switch (operType) {
case c_oAscInsertOptions.InsertColumns:
{
var count = updateRange.c2 - updateRange.c1 + 1;
// Position
if (updateRange.c1 <= obj.from.col) {
metrics.from.col += count;
metrics.to.col += count;
}
else if ((updateRange.c1 > obj.from.col) && (updateRange.c1 <= obj.to.col)) {
metrics.to.col += count;
}
else
metrics = null;
// Range
if (obj.isChart()) {
if (updateRange.c1 <= bbox.c1)
changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 + count , bbox.r2 , bbox.c2 + count );
else if (updateRange.c1 <= bbox.c2)
changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 , bbox.r2 , bbox.c2 + count );
}
}
break;
case c_oAscInsertOptions.InsertRows:
{
// Position
var count = updateRange.r2 - updateRange.r1 + 1;
if (updateRange.r1 <= obj.from.row) {
metrics.from.row += count;
metrics.to.row += count;
}
else if ((updateRange.r1 > obj.from.row) && (updateRange.r1 <= obj.to.row)) {
metrics.to.row += count;
}
else
metrics = null;
// Range
if (obj.isChart()) {
if (updateRange.r1 <= bbox.r1)
changedRange = new Range(worksheet.model, bbox.r1 + count , bbox.c1 , bbox.r2 + count , bbox.c2 );
else if (updateRange.r1 <= bbox.r2)
changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 , bbox.r2 + count , bbox.c2 );
}
}
break;
}
}
else { // Delete
switch (operType) {
case c_oAscDeleteOptions.DeleteColumns:
{
// Position metrics = { from: {}, to: {} };
var count = updateRange.c2 - updateRange.c1 + 1; metrics.from.col = obj.from.col; metrics.to.col = obj.to.col;
metrics.from.colOff = obj.from.colOff; metrics.to.colOff = obj.to.colOff;
metrics.from.row = obj.from.row; metrics.to.row = obj.to.row;
metrics.from.rowOff = obj.from.rowOff; metrics.to.rowOff = obj.to.rowOff;
if (bInsert) { // Insert
switch (operType) {
case c_oAscInsertOptions.InsertColumns:
{
var count = updateRange.c2 - updateRange.c1 + 1;
// Position
if (updateRange.c1 <= obj.from.col) {
metrics.from.col += count;
metrics.to.col += count;
}
else if ((updateRange.c1 > obj.from.col) && (updateRange.c1 <= obj.to.col)) {
metrics.to.col += count;
}
else
metrics = null;
if (updateRange.c1 <= obj.from.col) { // Range
if (obj.isChart()) {
if (updateRange.c1 <= bbox.c1)
changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 + count , bbox.r2 , bbox.c2 + count );
// outside else if (updateRange.c1 <= bbox.c2)
if (updateRange.c2 < obj.from.col) { changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 , bbox.r2 , bbox.c2 + count );
metrics.from.col -= count;
metrics.to.col -= count;
}
// inside
else {
metrics.from.col = updateRange.c1;
metrics.from.colOff = 0;
var offset = 0;
if (obj.to.col - updateRange.c2 - 1 > 0)
offset = obj.to.col - updateRange.c2 - 1;
else {
offset = 1;
metrics.to.colOff = 0;
} }
metrics.to.col = metrics.from.col + offset;
} }
} break;
case c_oAscInsertOptions.InsertRows:
{
else if ((updateRange.c1 > obj.from.col) && (updateRange.c1 <= obj.to.col)) { // Position
var count = updateRange.r2 - updateRange.r1 + 1;
// outside if (updateRange.r1 <= obj.from.row) {
if (updateRange.c2 >= obj.to.col) { metrics.from.row += count;
metrics.to.col = updateRange.c1; metrics.to.row += count;
metrics.to.colOff = 0; }
} else if ((updateRange.r1 > obj.from.row) && (updateRange.r1 <= obj.to.row)) {
else metrics.to.row += count;
metrics.to.col -= count; }
} else
else metrics = null;
metrics = null;
// Range // Range
if (obj.isChart()) { if (obj.isChart()) {
var count = updateRange.c2 - updateRange.c1 + 1; if (updateRange.r1 <= bbox.r1)
changedRange = new Range(worksheet.model, bbox.r1 + count , bbox.c1 , bbox.r2 + count , bbox.c2 );
if (updateRange.c1 < bbox.c1) { else if (updateRange.r1 <= bbox.r2)
changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 , bbox.r2 + count , bbox.c2 );
}
}
break;
}
}
else { // Delete
switch (operType) {
case c_oAscDeleteOptions.DeleteColumns:
{
if (updateRange.c2 < bbox.c1) // Position
changedRange = new Range(worksheet.model, bbox.r1, bbox.c1 - count , bbox.r2 , bbox.c2 - count ); var count = updateRange.c2 - updateRange.c1 + 1;
else {
// outside if (updateRange.c1 <= obj.from.col) {
if (updateRange.c2 > bbox.c2)
changedRange = new Range(worksheet.model, bbox.r1 , updateRange.c1 , bbox.r2 , updateRange.c1);
// outside
if (updateRange.c2 < obj.from.col) {
metrics.from.col -= count;
metrics.to.col -= count;
}
// inside // inside
else { else {
var offset = bbox.c2 - updateRange.c2; metrics.from.col = updateRange.c1;
changedRange = new Range(worksheet.model, bbox.r1 , updateRange.c1 , bbox.r2 , updateRange.c1 + offset - 1); metrics.from.colOff = 0;
var offset = 0;
if (obj.to.col - updateRange.c2 - 1 > 0)
offset = obj.to.col - updateRange.c2 - 1;
else {
offset = 1;
metrics.to.colOff = 0;
}
metrics.to.col = metrics.from.col + offset;
} }
} }
}
else if ((updateRange.c1 >= bbox.c1) && (updateRange.c1 <= bbox.c2)) { else if ((updateRange.c1 > obj.from.col) && (updateRange.c1 <= obj.to.col)) {
// outside // outside
if (updateRange.c2 > bbox.c2) { if (updateRange.c2 >= obj.to.col) {
var offset = (bbox.c1 + 1 > updateRange.c1) ? 1 : 0; metrics.to.col = updateRange.c1;
changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 , bbox.r2 , updateRange.c1 + offset - 1); metrics.to.colOff = 0;
}
else
metrics.to.col -= count;
} }
else
metrics = null;
// inside // Range
else { if (obj.isChart()) {
var offset = bbox.c2 + 1 - bbox.c1 - count; var count = updateRange.c2 - updateRange.c1 + 1;
if (offset <= 0)
offset = 1;
changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 , bbox.r2 , bbox.c1 + offset - 1);
}
}
}
}
break;
case c_oAscDeleteOptions.DeleteRows: if (updateRange.c1 < bbox.c1) {
{
// Position if (updateRange.c2 < bbox.c1)
var count = updateRange.r2 - updateRange.r1 + 1; changedRange = new Range(worksheet.model, bbox.r1, bbox.c1 - count , bbox.r2 , bbox.c2 - count );
else {
if (updateRange.r1 <= obj.from.row) { // outside
if (updateRange.c2 > bbox.c2)
changedRange = new Range(worksheet.model, bbox.r1 , updateRange.c1 , bbox.r2 , updateRange.c1);
// outside // inside
if (updateRange.r2 < obj.from.row) { else {
metrics.from.row -= count; var offset = bbox.c2 - updateRange.c2;
metrics.to.row -= count; changedRange = new Range(worksheet.model, bbox.r1 , updateRange.c1 , bbox.r2 , updateRange.c1 + offset - 1);
} }
// inside }
else { }
metrics.from.row = updateRange.r1;
metrics.from.colOff = 0;
var offset = 0;
if (obj.to.row - updateRange.r2 - 1 > 0)
offset = obj.to.row - updateRange.r2 - 1;
else {
offset = 1;
metrics.to.colOff = 0;
}
metrics.to.row = metrics.from.row + offset;
}
}
else if ((updateRange.r1 > obj.from.row) && (updateRange.r1 <= obj.to.row)) {
// outside else if ((updateRange.c1 >= bbox.c1) && (updateRange.c1 <= bbox.c2)) {
if (updateRange.r2 >= obj.to.row) {
metrics.to.row = updateRange.r1; // outside
metrics.to.colOff = 0; if (updateRange.c2 > bbox.c2) {
var offset = (bbox.c1 + 1 > updateRange.c1) ? 1 : 0;
changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 , bbox.r2 , updateRange.c1 + offset - 1);
}
// inside
else {
var offset = bbox.c2 + 1 - bbox.c1 - count;
if (offset <= 0)
offset = 1;
changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 , bbox.r2 , bbox.c1 + offset - 1);
}
}
}
} }
else break;
metrics.to.row -= count;
}
else
metrics = null;
// range case c_oAscDeleteOptions.DeleteRows:
if (obj.isChart()) { {
var count = updateRange.r2 - updateRange.r1 + 1;
if (updateRange.r1 < bbox.r1) { // Position
var count = updateRange.r2 - updateRange.r1 + 1;
if (updateRange.r2 < bbox.r1) if (updateRange.r1 <= obj.from.row) {
changedRange = new Range(worksheet.model, bbox.r1 - count, bbox.c1 , bbox.r2 - count , bbox.c2 );
else {
// outside // outside
if (updateRange.r2 >= bbox.r2) if (updateRange.r2 < obj.from.row) {
changedRange = new Range(worksheet.model, updateRange.r1 , bbox.c1 , updateRange.r1 , bbox.c2); metrics.from.row -= count;
metrics.to.row -= count;
}
// inside // inside
else { else {
var offset = bbox.r1 + 1 - updateRange.r2; metrics.from.row = updateRange.r1;
changedRange = new Range(worksheet.model, updateRange.r1 , bbox.c1 , updateRange.r1 + offset, bbox.c2); metrics.from.colOff = 0;
var offset = 0;
if (obj.to.row - updateRange.r2 - 1 > 0)
offset = obj.to.row - updateRange.r2 - 1;
else {
offset = 1;
metrics.to.colOff = 0;
}
metrics.to.row = metrics.from.row + offset;
} }
} }
}
else if ((updateRange.r1 >= bbox.r1) && (updateRange.r1 <= bbox.r2)) { else if ((updateRange.r1 > obj.from.row) && (updateRange.r1 <= obj.to.row)) {
// outside // outside
if (updateRange.r2 > bbox.r2) { if (updateRange.r2 >= obj.to.row) {
var offset = (bbox.r1 + 1 > updateRange.r1) ? 1 : 0; metrics.to.row = updateRange.r1;
changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 , updateRange.r1 + offset - 1, bbox.c2 ); metrics.to.colOff = 0;
}
else
metrics.to.row -= count;
} }
else
metrics = null;
// range
if (obj.isChart()) {
var count = updateRange.r2 - updateRange.r1 + 1;
if (updateRange.r1 < bbox.r1) {
if (updateRange.r2 < bbox.r1)
changedRange = new Range(worksheet.model, bbox.r1 - count, bbox.c1 , bbox.r2 - count , bbox.c2 );
else {
// outside
if (updateRange.r2 >= bbox.r2)
changedRange = new Range(worksheet.model, updateRange.r1 , bbox.c1 , updateRange.r1 , bbox.c2);
// inside // inside
else { else {
var offset = bbox.r2 + 1 - bbox.r1 - count; var offset = bbox.r1 + 1 - updateRange.r2;
if (offset <= 0) offset = 1; changedRange = new Range(worksheet.model, updateRange.r1 , bbox.c1 , updateRange.r1 + offset, bbox.c2);
changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 , bbox.r1 + offset - 1, bbox.c2 ); }
}
}
else if ((updateRange.r1 >= bbox.r1) && (updateRange.r1 <= bbox.r2)) {
// outside
if (updateRange.r2 > bbox.r2) {
var offset = (bbox.r1 + 1 > updateRange.r1) ? 1 : 0;
changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 , updateRange.r1 + offset - 1, bbox.c2 );
}
// inside
else {
var offset = bbox.r2 + 1 - bbox.r1 - count;
if (offset <= 0) offset = 1;
changedRange = new Range(worksheet.model, bbox.r1 , bbox.c1 , bbox.r1 + offset - 1, bbox.c2 );
}
}
} }
} }
} break;
} }
break; }
}
}
// Normalize position // Normalize position
if (metrics) { if (metrics) {
if (metrics.from.col < 0) { if (metrics.from.col < 0) {
metrics.from.col = 0; metrics.from.col = 0;
metrics.from.colOff = 0; metrics.from.colOff = 0;
} }
if (metrics.to.col <= 0) { if (metrics.to.col <= 0) {
metrics.to.col = 1; metrics.to.col = 1;
metrics.to.colOff = 0; metrics.to.colOff = 0;
} }
if (metrics.from.row < 0) { if (metrics.from.row < 0) {
metrics.from.row = 0; metrics.from.row = 0;
metrics.from.rowOff = 0; metrics.from.rowOff = 0;
} }
if (metrics.to.row <= 0) { if (metrics.to.row <= 0) {
metrics.to.row = 1; metrics.to.row = 1;
metrics.to.rowOff = 0; metrics.to.rowOff = 0;
} }
if (metrics.from.col == metrics.to.col) { if (metrics.from.col == metrics.to.col) {
metrics.to.col++; metrics.to.col++;
metrics.to.colOff = 0; metrics.to.colOff = 0;
} }
if (metrics.from.row == metrics.to.row) { if (metrics.from.row == metrics.to.row) {
metrics.to.row++; metrics.to.row++;
metrics.to.rowOff = 0; metrics.to.rowOff = 0;
} }
} }
// Normalize range // Normalize range
if (changedRange) { if (changedRange) {
var bbox = changedRange.getBBox0(); var bbox = changedRange.getBBox0();
var tmp; var tmp;
if (bbox.c1 > bbox.c2) { if (bbox.c1 > bbox.c2) {
tmp = bbox.c1; tmp = bbox.c1;
bbox.c1 = bbox.c2; bbox.c1 = bbox.c2;
bbox.c2 = tmp; bbox.c2 = tmp;
} }
if (bbox.r1 > bbox.r2) { if (bbox.r1 > bbox.r2) {
tmp = bbox.r1; tmp = bbox.r1;
bbox.r1 = bbox.r2; bbox.r1 = bbox.r2;
bbox.r2 = tmp; bbox.r2 = tmp;
} }
changedRange = new Range(worksheet.model, bbox.r1, bbox.c1, bbox.r2, bbox.c2); changedRange = new Range(worksheet.model, bbox.r1, bbox.c1, bbox.r2, bbox.c2);
} }
if ( changedRange || metrics ) { if ( changedRange || metrics ) {
if ( obj.isChart() && changedRange ) { if ( obj.isChart() && changedRange ) {
obj.graphicObject.chart.range.intervalObject = changedRange; obj.graphicObject.chart.range.intervalObject = changedRange;
_this.calcChartInterval(obj.graphicObject.chart); _this.calcChartInterval(obj.graphicObject.chart);
obj.graphicObject.chart.rebuildSeries(); obj.graphicObject.chart.rebuildSeries();
obj.graphicObject.recalculate(); obj.graphicObject.recalculate();
} }
if (metrics) { if (metrics) {
obj.from.col = metrics.from.col; obj.from.col = metrics.from.col;
obj.from.colOff = metrics.from.colOff; obj.from.colOff = metrics.from.colOff;
obj.from.row = metrics.from.row; obj.from.row = metrics.from.row;
obj.from.rowOff = metrics.from.rowOff; obj.from.rowOff = metrics.from.rowOff;
obj.to.col = metrics.to.col; obj.to.col = metrics.to.col;
obj.to.colOff = metrics.to.colOff; obj.to.colOff = metrics.to.colOff;
obj.to.row = metrics.to.row; obj.to.row = metrics.to.row;
obj.to.rowOff = metrics.to.rowOff; obj.to.rowOff = metrics.to.rowOff;
}
// Update graphic object
obj.graphicObject.setPosition( pxToMm(obj.getRealLeftOffset(true)), pxToMm(obj.getRealTopOffset(true)) );
obj.graphicObject.recalculateTransform();
obj.graphicObject.calculateTransformTextMatrix();
_this.showDrawingObjects(true);
}
} }
// Update graphic object
obj.graphicObject.setPosition( pxToMm(obj.getRealLeftOffset(true)), pxToMm(obj.getRealTopOffset(true)) );
obj.graphicObject.recalculateTransform();
obj.graphicObject.calculateTransformTextMatrix();
_this.showDrawingObjects(true);
} }
} }
} }
......
...@@ -880,11 +880,27 @@ CShape.prototype = ...@@ -880,11 +880,27 @@ CShape.prototype =
recalculate: function() recalculate: function()
{ {
if(this.recalcInfo.recalculateTransform) if(this.recalcInfo.recalculateTransform)
{
this.recalculateTransform(); this.recalculateTransform();
this.recalcInfo.recalculateTransform = false;
}
if(this.recalcInfo.recalculateBrush) if(this.recalcInfo.recalculateBrush)
{
this.recalculateBrush(); this.recalculateBrush();
if(this.recalcInfo.recalculatePen) this.recalcInfo.recalculateBrush = false;
}
if(this.recalcInfo.recalculatePen)
{
this.recalculatePen(); this.recalculatePen();
this.recalcInfo.recalculatePen = false;
}
if(this.recalInfo.recalculateGeometry)
{
if(this.spPr.geometry)
{
this.spPr.geometry.Recalculate(this.extX, this.extY);
}
}
}, },
calculateFill: function() calculateFill: function()
......
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