Commit 2c8773fd authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

Баг с картинками по url'у

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@66208 954022d7-b5bf-4e40-9824-e11837661b57
parent 5f8e28cb
...@@ -2723,8 +2723,72 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -2723,8 +2723,72 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}; };
spreadsheet_api.prototype.asc_setGraphicObjectProps = function(props) { spreadsheet_api.prototype.asc_setGraphicObjectProps = function(props) {
var ws = this.wb.getWorksheet(); var ws = this.wb.getWorksheet();
return ws.objectRender.setGraphicObjectProps(props); var fReplaceCallback = null, sImageUrl = null;
if(!isNullOrEmptyString(props.ImageUrl)){
if(!g_oDocumentUrls.getImageLocal(props.ImageUrl)){
sImageUrl = props.ImageUrl;
fReplaceCallback = function(sLocalUrl){
props.ImageUrl = sLocalUrl;
}
}
}
else if(props.ShapeProperties && props.ShapeProperties.fill && props.ShapeProperties.fill.fill &&
!isNullOrEmptyString(props.ShapeProperties.fill.fill.url)){
if(!g_oDocumentUrls.getImageLocal(props.ShapeProperties.fill.fill.url)){
sImageUrl = props.ShapeProperties.fill.fill.url;
fReplaceCallback = function(sLocalUrl){
props.ShapeProperties.fill.fill.url = sLocalUrl;
}
}
}
if(fReplaceCallback){
var rData = {
"id": this.documentId,
"userid": this.documentUserId,
"vkey": this.documentVKey,
"c": "imgurl",
"saveindex": g_oDocumentUrls.getMaxIndex(),
"data": sImageUrl};
var t = this;
this.handlers.trigger("asc_onStartAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
this.fCurCallback = function(input) {
if (null != input && "imgurl" == input["type"]) {
if ("ok" == input["status"]) {
var data = input["data"];
var urls = {};
var firstUrl;
for (var i = 0; i < data.length; ++i) {
var elem = data[i];
if (elem.url) {
if (!firstUrl) {
firstUrl = elem.url;
}
urls[elem.path] = elem.url;
}
}
g_oDocumentUrls.addUrls(urls);
if (firstUrl) {
fReplaceCallback(firstUrl);
ws.objectRender.setGraphicObjectProps(props);
} else {
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
} else {
t.handlers.trigger("asc_onError", g_fMapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
} else {
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
t.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
};
sendCommand2(this, null, rData);
}
else{
ws.objectRender.setGraphicObjectProps(props);
}
}; };
spreadsheet_api.prototype.asc_getOriginalImageSize = function() { spreadsheet_api.prototype.asc_getOriginalImageSize = function() {
......
...@@ -2038,45 +2038,94 @@ asc_docs_api.prototype.ShapeApply = function(prop) ...@@ -2038,45 +2038,94 @@ asc_docs_api.prototype.ShapeApply = function(prop)
bShapeTexture = false; bShapeTexture = false;
} }
} }
if (image_url != "") if (!isNullOrEmptyString(image_url)){
{ var sImageUrl = null;
var _image = this.ImageLoader.LoadImage(image_url, 1); if(!g_oDocumentUrls.getImageLocal(image_url)){
sImageUrl = image_url;
var srcLocal = g_oDocumentUrls.getImageLocal(image_url);
if (srcLocal) {
image_url = srcLocal;
} }
if(bShapeTexture) var oApi = this;
{ var fApplyCallback = function(){
var _image = oApi.ImageLoader.LoadImage(image_url, 1);
var srcLocal = g_oDocumentUrls.getImageLocal(image_url);
if (srcLocal) {
image_url = srcLocal;
}
if(bShapeTexture)
{
prop.fill.fill.asc_putUrl(image_url); // erase documentUrl prop.fill.fill.asc_putUrl(image_url); // erase documentUrl
} }
else else
{ {
oFill.fill.asc_putUrl(image_url); oFill.fill.asc_putUrl(image_url);
} }
if (null != _image) if (null != _image)
{ {
this.WordControl.m_oLogicDocument.ShapeApply(prop); oApi.WordControl.m_oLogicDocument.ShapeApply(prop);
if(bShapeTexture) if(bShapeTexture)
{ {
this.WordControl.m_oDrawingDocument.DrawImageTextureFillShape(image_url); oApi.WordControl.m_oDrawingDocument.DrawImageTextureFillShape(image_url);
} }
else else
{ {
this.WordControl.m_oDrawingDocument.DrawImageTextureFillTextArt(image_url); oApi.WordControl.m_oDrawingDocument.DrawImageTextureFillTextArt(image_url);
} }
} }
else else
{ {
this.sync_StartAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadImage); oApi.sync_StartAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadImage);
var oProp = prop; var oProp = prop;
this.asyncImageEndLoaded2 = function(_image) oApi.asyncImageEndLoaded2 = function(_image)
{ {
this.WordControl.m_oLogicDocument.ShapeApply(oProp); oApi.WordControl.m_oLogicDocument.ShapeApply(oProp);
this.WordControl.m_oDrawingDocument.DrawImageTextureFillShape(image_url); oApi.WordControl.m_oDrawingDocument.DrawImageTextureFillShape(image_url);
this.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadImage); oApi.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadImage);
this.asyncImageEndLoaded2 = null; oApi.asyncImageEndLoaded2 = null;
} }
}
};
if(!sImageUrl){
fApplyCallback();
}
else{
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
this.fCurCallback = function(input) {
if(null != input && "imgurl" == input["type"]){
if("ok" ==input["status"]) {
var data = input["data"];
var urls = {};
var firstUrl;
for(var i = 0; i < data.length; ++i){
var elem = data[i];
if(elem.url){
if(!firstUrl){
firstUrl = elem.url;
}
urls[elem.path] = elem.url;
}
}
g_oDocumentUrls.addUrls(urls);
if(firstUrl) {
image_url = firstUrl;
fApplyCallback();
} else {
oApi.asc_fireCallback("asc_onError",c_oAscError.ID.Unknown,c_oAscError.Level.NoCritical);
}
} else {
oApi.asc_fireCallback("asc_onError", g_fMapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
} else {
oApi.asc_fireCallback("asc_onError",c_oAscError.ID.Unknown,c_oAscError.Level.NoCritical);
}
oApi.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
};
var rData = {
"id":documentId,
"userid": documentUserId,
"vkey": documentVKey,
"c":"imgurl",
"saveindex": g_oDocumentUrls.getMaxIndex(),
"data": sImageUrl};
sendCommand2(this, null, rData );
} }
} }
else else
...@@ -3096,29 +3145,75 @@ asc_docs_api.prototype.ImgApply = function(obj){ ...@@ -3096,29 +3145,75 @@ asc_docs_api.prototype.ImgApply = function(obj){
ImagePr.ImageUrl = obj.ImageUrl; ImagePr.ImageUrl = obj.ImageUrl;
if(ImagePr.ImageUrl != undefined && ImagePr.ImageUrl != null && ImagePr.ImageUrl != "")
{
var _img = this.ImageLoader.LoadImage(ImagePr.ImageUrl, 1);
var srcLocal = g_oDocumentUrls.getImageLocal(ImagePr.ImageUrl); if(!isNullOrEmptyString(ImagePr.ImageUrl)){
if (srcLocal){ var sImageUrl = null;
ImagePr.ImageUrl = srcLocal; if(!g_oDocumentUrls.getImageLocal(ImagePr.ImageUrl)){
} sImageUrl = ImagePr.ImageUrl;
}
if (null != _img) var oApi = this;
{ var fApplyCallback = function(){
//ImagePr.ImageUrl = _img.src; var _img = oApi.ImageLoader.LoadImage(ImagePr.ImageUrl, 1);
this.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr ); var srcLocal = g_oDocumentUrls.getImageLocal(ImagePr.ImageUrl);
} if (srcLocal){
else ImagePr.ImageUrl = srcLocal;
{ }
this.asyncImageEndLoaded2 = function(_image) if (null != _img){
{ oApi.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr );
//ImagePr.ImageUrl = _image.src; }
this.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr ); else{
this.asyncImageEndLoaded2 = null; oApi.asyncImageEndLoaded2 = function(_image){
} oApi.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr );
} oApi.asyncImageEndLoaded2 = null;
}
}
};
if(!sImageUrl){
fApplyCallback();
}
else{
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
this.fCurCallback = function(input) {
if(null != input && "imgurl" == input["type"]){
if("ok" ==input["status"]) {
var data = input["data"];
var urls = {};
var firstUrl;
for(var i = 0; i < data.length; ++i){
var elem = data[i];
if(elem.url){
if(!firstUrl){
firstUrl = elem.url;
}
urls[elem.path] = elem.url;
}
}
g_oDocumentUrls.addUrls(urls);
if(firstUrl) {
ImagePr.ImageUrl = firstUrl;
fApplyCallback();
} else {
oApi.asc_fireCallback("asc_onError",c_oAscError.ID.Unknown,c_oAscError.Level.NoCritical);
}
} else {
oApi.asc_fireCallback("asc_onError", g_fMapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
} else {
oApi.asc_fireCallback("asc_onError",c_oAscError.ID.Unknown,c_oAscError.Level.NoCritical);
}
oApi.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
};
var rData = {
"id":documentId,
"userid": documentUserId,
"vkey": documentVKey,
"c":"imgurl",
"saveindex": g_oDocumentUrls.getMaxIndex(),
"data": sImageUrl};
sendCommand2(this, null, rData );
}
} }
else else
{ {
......
...@@ -4767,43 +4767,95 @@ asc_docs_api.prototype.ImgApply = function(obj) ...@@ -4767,43 +4767,95 @@ asc_docs_api.prototype.ImgApply = function(obj)
if (ImagePr.ShapeProperties) if (ImagePr.ShapeProperties)
ImagePr.ImageUrl = ""; ImagePr.ImageUrl = "";
if(ImagePr.ImageUrl != undefined && ImagePr.ImageUrl != null && ImagePr.ImageUrl != "")
{ var sImageUrl = null, fReplaceCallback = null, bImageUrl = false, sImageToDownLoad = "";
var _img = this.ImageLoader.LoadImage(ImagePr.ImageUrl, 1); if(!isNullOrEmptyString(ImagePr.ImageUrl)){
if (null != _img) if(!g_oDocumentUrls.getImageLocal(ImagePr.ImageUrl)){
{ sImageUrl = ImagePr.ImageUrl;
ImagePr.ImageUrl = _img.src; fReplaceCallback = function(sUrl){
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(historydescription_Document_ApplyImagePrWithUrl); ImagePr.ImageUrl = sUrl;
this.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr ); sImageToDownLoad = sUrl;
}
else
{
this.asyncImageEndLoaded2 = function(_image)
{
ImagePr.ImageUrl = _image.src;
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(historydescription_Document_ApplyImagePrWithUrlLong);
this.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr );
} }
} }
sImageToDownLoad = ImagePr.ImageUrl;
} }
else if (ImagePr.ShapeProperties && ImagePr.ShapeProperties.fill && ImagePr.ShapeProperties.fill.fill && else if(ImagePr.ShapeProperties && ImagePr.ShapeProperties.fill &&
ImagePr.ShapeProperties.fill.fill.url !== undefined && ImagePr.ShapeProperties.fill.fill.url != null && ImagePr.ShapeProperties.fill.fill.url != "") ImagePr.ShapeProperties.fill.fill && !isNullOrEmptyString(ImagePr.ShapeProperties.fill.fill.url)){
{ if(!g_oDocumentUrls.getImageLocal(ImagePr.ShapeProperties.fill.fill.url)){
var _img = this.ImageLoader.LoadImage(ImagePr.ShapeProperties.fill.fill.url, 1); sImageUrl = ImagePr.ShapeProperties.fill.fill.url;
if (null != _img) fReplaceCallback = function(sUrl){
{ ImagePr.ShapeProperties.fill.fill.url = sUrl;
ImagePr.ImageUrl = _img.src; sImageToDownLoad = sUrl;
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(historydescription_Document_ApplyImagePrWithFillUrl); }
this.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr );
} }
else sImageToDownLoad = ImagePr.ShapeProperties.fill.fill.url;
{ }
this.asyncImageEndLoaded2 = function(_image)
var oApi = this;
if(!isNullOrEmptyString(sImageToDownLoad)){
var fApplyCallback = function(){
var _img = oApi.ImageLoader.LoadImage(sImageToDownLoad, 1);
if (null != _img)
{ {
ImagePr.ImageUrl = _image.src; oApi.WordControl.m_oLogicDocument.Create_NewHistoryPoint(historydescription_Document_ApplyImagePrWithUrl);
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(historydescription_Document_ApplyImagePrWithFillUrlLong); oApi.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr );
this.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr );
} }
else
{
oApi.asyncImageEndLoaded2 = function(_image)
{
oApi.WordControl.m_oLogicDocument.Create_NewHistoryPoint(historydescription_Document_ApplyImagePrWithUrlLong);
oApi.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr );
}
}
};
if(sImageUrl){
var rData = {
"id": documentId,
"userid": documentUserId,
"vkey": documentVKey,
"c": "imgurl",
"saveindex": g_oDocumentUrls.getMaxIndex(),
"data": sImageToDownLoad};
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
this.fCurCallback = function(input) {
if(null != input && "imgurl" == input["type"]){
if("ok" ==input["status"]) {
var data = input["data"];
var urls = {};
var firstUrl;
for(var i = 0; i < data.length; ++i){
var elem = data[i];
if(elem.url){
if(!firstUrl){
firstUrl = elem.url;
}
urls[elem.path] = elem.url;
}
}
g_oDocumentUrls.addUrls(urls);
if(firstUrl) {
fReplaceCallback(firstUrl);
fApplyCallback();
} else {
oApi.asc_fireCallback("asc_onError",c_oAscError.ID.Unknown,c_oAscError.Level.NoCritical);
}
} else {
oApi.asc_fireCallback("asc_onError", g_fMapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
} else {
oApi.asc_fireCallback("asc_onError",c_oAscError.ID.Unknown,c_oAscError.Level.NoCritical);
}
oApi.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
};
sendCommand2(this, null, rData );
}
else{
fApplyCallback();
} }
} }
else else
......
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