Skip to content

Commit

Permalink
For bug 71998
Browse files Browse the repository at this point in the history
  • Loading branch information
Coolcooo committed Feb 18, 2025
1 parent a04cdc6 commit f0657b6
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 18 deletions.
6 changes: 6 additions & 0 deletions cell/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5550,6 +5550,11 @@ var editor;
return ws.objectRender.getOriginalImageSize();
};

spreadsheet_api.prototype.asc_getCropOriginalImageSize = function() {
var ws = this.wb.getWorksheet();
return ws.objectRender.getCropOriginalImageSize();
};

spreadsheet_api.prototype.asc_setInterfaceDrawImagePlaceTextArt = function(elementId) {
this.textArtElementId = elementId;
};
Expand Down Expand Up @@ -10306,6 +10311,7 @@ var editor;
prot["asc_GetSelectedText"] = prot.asc_GetSelectedText;
prot["asc_setGraphicObjectProps"] = prot.asc_setGraphicObjectProps;
prot["asc_getOriginalImageSize"] = prot.asc_getOriginalImageSize;
prot["asc_getCropOriginalImageSize"] = prot.asc_getCropOriginalImageSize;
prot["asc_changeShapeType"] = prot.asc_changeShapeType;
prot["asc_setInterfaceDrawImagePlaceShape"] = prot.asc_setInterfaceDrawImagePlaceShape;
prot["asc_setInterfaceDrawImagePlaceTextArt"] = prot.asc_setInterfaceDrawImagePlaceTextArt;
Expand Down
39 changes: 22 additions & 17 deletions common/Charts/DrawingObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -4030,26 +4030,31 @@ CSparklineView.prototype.setMinMaxValAx = function(minVal, maxVal, oSparklineGro
}
};

_this.getOriginalImageSize = function() {

var selectedObjects = _this.controller.selectedObjects;
if ( (selectedObjects.length == 1) ) {

_this._getOriginalImageSize = function(isCrop) {
const selectedObjects = _this.controller.selectedObjects;
if ( (selectedObjects.length === 1) ) {
const oShape = selectedObjects[0];
if(oShape.isImage()){
const imageUrl = oShape.getImageUrl();

const oImagePr = new Asc.asc_CImgProperty();
oImagePr.asc_putImageUrl(imageUrl);
oImagePr.cropWidthCoefficient = oShape.getCropWidthCoefficient();
oImagePr.cropHeightCoefficient = oShape.getCropHeightCoefficient();
return isCrop ? oImagePr.asc_getCropOriginSize(api) : oImagePr.asc_getOriginSize(api);

if(selectedObjects[0].isImage()){
var imageUrl = selectedObjects[0].getImageUrl();

var oImagePr = new Asc.asc_CImgProperty();
oImagePr.asc_putImageUrl(imageUrl);
var oSize = oImagePr.asc_getOriginSize(api);
if(oSize.IsCorrect) {
return oSize;
}
}
}
return new AscCommon.asc_CImageSize( 50, 50, false );
}
}
return new AscCommon.asc_CImageSize( 50, 50, false );
};
_this.getOriginalImageSize = function() {
return this._getOriginalImageSize();
};

_this.getCropOriginalImageSize = function() {
return this._getOriginalImageSize(true);
};

_this.getSelectionImg = function() {
return _this.controller.getSelectionImage().asc_getImageUrl();
};
Expand Down
6 changes: 6 additions & 0 deletions common/Drawings/CommonController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7374,6 +7374,8 @@
ImageUrl: drawing.getImageUrl(),
transparent: drawing.getTransparent(),
isCrop: drawing.hasCrop(),
cropHeightCoefficient: drawing.getCropHeightCoefficient(),
cropWidthCoefficient: drawing.getCropWidthCoefficient(),
w: drawing.extX,
h: drawing.extY,
rot: drawing.rot,
Expand Down Expand Up @@ -7483,6 +7485,8 @@
{
ImageUrl: drawing.getImageUrl(),
isCrop: drawing.hasCrop(),
cropHeightCoefficient: drawing.getCropHeightCoefficient(),
cropWidthCoefficient: drawing.getCropWidthCoefficient(),
transparent: null,
w: drawing.extX,
h: drawing.extY,
Expand Down Expand Up @@ -8226,6 +8230,8 @@
image_props.flipV = props.imageProps.flipV;
image_props.ImageUrl = props.imageProps.ImageUrl;
image_props.isCrop = props.imageProps.isCrop;
image_props.cropHeightCoefficient = props.imageProps.cropHeightCoefficient;
image_props.cropWidthCoefficient = props.imageProps.cropWidthCoefficient;
image_props.transparent = props.imageProps.transparent;
image_props.Locked = props.imageProps.locked === true;
image_props.lockAspect = props.imageProps.lockAspect;
Expand Down
14 changes: 14 additions & 0 deletions common/Drawings/Format/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,20 @@
CImageShape.prototype.canFill = function () {
return true;
};
CImageShape.prototype.getCropHeightCoefficient = function() {
const oSrcRect = this.blipFill && this.blipFill.srcRect;
if (oSrcRect) {
return (oSrcRect.b - oSrcRect.t) / 100;
}
return 1;
};
CImageShape.prototype.getCropWidthCoefficient = function() {
const oSrcRect = this.blipFill && this.blipFill.srcRect;
if (oSrcRect) {
return (oSrcRect.r - oSrcRect.l) / 100;
}
return 1;
};

function CreateBrushFromBlipFill(oBlipFill) {
if (!oBlipFill) {
Expand Down
30 changes: 29 additions & 1 deletion common/apiCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -3694,7 +3694,8 @@ function (window, undefined) {
this.bSetOriginalSize = obj.bSetOriginalSize;
this.transparent = obj.transparent;
this.isCrop = obj.isCrop;

this.cropHeightCoefficient = obj.cropHeightCoefficient;
this.cropWidthCoefficient = obj.cropWidthCoefficient;
}
else {
this.CanBeFlow = true;
Expand Down Expand Up @@ -3755,6 +3756,8 @@ function (window, undefined) {

this.transparent = undefined;
this.isCrop = undefined;
this.cropHeightCoefficient = 1;
this.cropWidthCoefficient = 1;
}
}

Expand Down Expand Up @@ -3980,6 +3983,13 @@ function (window, undefined) {
return new asc_CImageSize(50, 50, false);
};

asc_CImgProperty.prototype.asc_getCropOriginSize = function(api) {
const oSizes = this.asc_getOriginSize(api);
oSizes.Width *= this.cropWidthCoefficient;
oSizes.Height *= this.cropHeightCoefficient;
return oSizes;
};

//oleObjects
asc_CImgProperty.prototype.asc_getPluginGuid = function () {
return this.pluginGuid;
Expand Down Expand Up @@ -4144,6 +4154,19 @@ function (window, undefined) {
asc_CImgProperty.prototype.asc_getIsCrop = function () {
return this.isCrop;
};
asc_CImgProperty.prototype.asc_getCropHeightCoefficient = function () {
return this.cropHeightCoefficient;
};
asc_CImgProperty.prototype.asc_putCropHeightCoefficient = function (v) {
this.cropHeightCoefficient = v;
};
asc_CImgProperty.prototype.asc_getCropWidthCoefficient = function () {
return this.cropWidthCoefficient;
};
asc_CImgProperty.prototype.asc_putCropWidthCoefficient = function (v) {
this.cropWidthCoefficient = v;
};

/** @constructor */
function asc_CSelectedObject(type, val) {
this.Type = (undefined != type) ? type : null;
Expand Down Expand Up @@ -6854,6 +6877,7 @@ function (window, undefined) {
prot["put_SlicerProperties"] = prot["asc_putSlicerProperties"] = prot.asc_putSlicerProperties;
prot["get_SlicerProperties"] = prot["asc_getSlicerProperties"] = prot.asc_getSlicerProperties;
prot["get_OriginSize"] = prot["asc_getOriginSize"] = prot.asc_getOriginSize;
prot["get_CropOriginSize"] = prot["asc_getCropOriginSize"] = prot.asc_getCropOriginSize;
prot["get_PluginGuid"] = prot["asc_getPluginGuid"] = prot.asc_getPluginGuid;
prot["put_PluginGuid"] = prot["asc_putPluginGuid"] = prot.asc_putPluginGuid;
prot["get_PluginData"] = prot["asc_getPluginData"] = prot.asc_getPluginData;
Expand Down Expand Up @@ -6901,6 +6925,10 @@ function (window, undefined) {
prot["put_ProtectionPrint"] = prot["asc_putProtectionPrint"] = prot.asc_putProtectionPrint;
prot["get_Transparent"] = prot["asc_getTransparent"] = prot.asc_getTransparent;
prot["put_Transparent"] = prot["asc_putTransparent"] = prot.asc_putTransparent;
prot["get_CropHeightCoefficient"] = prot["asc_getCropHeightCoefficient"] = prot.asc_getCropHeightCoefficient;
prot["put_CropHeightCoefficient"] = prot["asc_putCropHeightCoefficient"] = prot.asc_putCropHeightCoefficient;
prot["get_CropWidthCoefficient"] = prot["asc_getCropWidthCoefficient"] = prot.asc_getCropWidthCoefficient;
prot["put_CropWidthCoefficient"] = prot["asc_putCropWidthCoefficient"] = prot.asc_putCropWidthCoefficient;
prot["get_IsCrop"] = prot["asc_getIsCrop"] = prot.asc_getIsCrop;

window["AscCommon"].asc_CSelectedObject = asc_CSelectedObject;
Expand Down
10 changes: 10 additions & 0 deletions slide/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5287,6 +5287,15 @@ background-repeat: no-repeat;\
}
return null;
};
asc_docs_api.prototype.asc_getCropOriginalImageSize = function()
{
for(var i = 0; i < this.SelectedObjectsStack.length; ++i){
if(this.SelectedObjectsStack[i].Type == c_oAscTypeSelectElement.Image && this.SelectedObjectsStack[i].Value && this.SelectedObjectsStack[i].Value.ImageUrl){
return this.SelectedObjectsStack[i].Value.asc_getCropOriginSize(this);
}
}
return null;
};

asc_docs_api.prototype.asc_FitImagesToSlide = function()
{
Expand Down Expand Up @@ -9883,6 +9892,7 @@ background-repeat: no-repeat;\
asc_docs_api.prototype['set_ImgDistanceFromText'] = asc_docs_api.prototype.set_ImgDistanceFromText;
asc_docs_api.prototype['set_PositionOnPage'] = asc_docs_api.prototype.set_PositionOnPage;
asc_docs_api.prototype['get_OriginalSizeImage'] = asc_docs_api.prototype.get_OriginalSizeImage;
asc_docs_api.prototype['asc_getCropOriginalImageSize'] = asc_docs_api.prototype.asc_getCropOriginalImageSize;
asc_docs_api.prototype['asc_FitImagesToSlide'] = asc_docs_api.prototype.asc_FitImagesToSlide;
asc_docs_api.prototype['asc_onCloseChartFrame'] = asc_docs_api.prototype.asc_onCloseChartFrame;
asc_docs_api.prototype['sync_AddImageCallback'] = asc_docs_api.prototype.sync_AddImageCallback;
Expand Down
2 changes: 2 additions & 0 deletions word/Editor/GraphicObjects/GraphicObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,8 @@ CGraphicObjects.prototype =
image_props = new asc_CImgProperty(para_drawing_props);
image_props.ImageUrl = props_by_types.imageProps.ImageUrl;
image_props.isCrop = props_by_types.imageProps.isCrop;
image_props.cropHeightCoefficient = props_by_types.imageProps.cropHeightCoefficient;
image_props.cropWidthCoefficient = props_by_types.imageProps.cropWidthCoefficient;
image_props.Width = props_by_types.imageProps.w;
image_props.Height = props_by_types.imageProps.h;
image_props.rot = props_by_types.imageProps.rot;
Expand Down
10 changes: 10 additions & 0 deletions word/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6478,6 +6478,15 @@ background-repeat: no-repeat;\
}
return null;
};
asc_docs_api.prototype.asc_getCropOriginalImageSize = function()
{
for(var i = 0; i < this.SelectedObjectsStack.length; ++i){
if(this.SelectedObjectsStack[i].Type == c_oAscTypeSelectElement.Image && this.SelectedObjectsStack[i].Value && this.SelectedObjectsStack[i].Value.ImageUrl){
return this.SelectedObjectsStack[i].Value.asc_getCropOriginSize(this);
}
}
return null;
};

asc_docs_api.prototype.ShapeApply = function(shapeProps)
{
Expand Down Expand Up @@ -14548,6 +14557,7 @@ background-repeat: no-repeat;\
asc_docs_api.prototype['set_ImgDistanceFromText'] = asc_docs_api.prototype.set_ImgDistanceFromText;
asc_docs_api.prototype['set_PositionOnPage'] = asc_docs_api.prototype.set_PositionOnPage;
asc_docs_api.prototype['get_OriginalSizeImage'] = asc_docs_api.prototype.get_OriginalSizeImage;
asc_docs_api.prototype['asc_getCropOriginalImageSize'] = asc_docs_api.prototype.asc_getCropOriginalImageSize;
asc_docs_api.prototype['ShapeApply'] = asc_docs_api.prototype.ShapeApply;
asc_docs_api.prototype['sync_AddImageCallback'] = asc_docs_api.prototype.sync_AddImageCallback;
asc_docs_api.prototype['sync_ImgPropCallback'] = asc_docs_api.prototype.sync_ImgPropCallback;
Expand Down

0 comments on commit f0657b6

Please sign in to comment.