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";
};
spreadsheet_api.prototype.asc_setGraphicObjectProps = function(props) {
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() {
......
......@@ -2038,45 +2038,94 @@ asc_docs_api.prototype.ShapeApply = function(prop)
bShapeTexture = false;
}
}
if (image_url != "")
{
var _image = this.ImageLoader.LoadImage(image_url, 1);
var srcLocal = g_oDocumentUrls.getImageLocal(image_url);
if (srcLocal) {
image_url = srcLocal;
if (!isNullOrEmptyString(image_url)){
var sImageUrl = null;
if(!g_oDocumentUrls.getImageLocal(image_url)){
sImageUrl = image_url;
}
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
}
else
{
}
else
{
oFill.fill.asc_putUrl(image_url);
}
if (null != _image)
{
this.WordControl.m_oLogicDocument.ShapeApply(prop);
}
if (null != _image)
{
oApi.WordControl.m_oLogicDocument.ShapeApply(prop);
if(bShapeTexture)
{
this.WordControl.m_oDrawingDocument.DrawImageTextureFillShape(image_url);
oApi.WordControl.m_oDrawingDocument.DrawImageTextureFillShape(image_url);
}
else
{
this.WordControl.m_oDrawingDocument.DrawImageTextureFillTextArt(image_url);
oApi.WordControl.m_oDrawingDocument.DrawImageTextureFillTextArt(image_url);
}
}
else
{
this.sync_StartAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadImage);
}
else
{
oApi.sync_StartAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadImage);
var oProp = prop;
this.asyncImageEndLoaded2 = function(_image)
oApi.asyncImageEndLoaded2 = function(_image)
{
this.WordControl.m_oLogicDocument.ShapeApply(oProp);
this.WordControl.m_oDrawingDocument.DrawImageTextureFillShape(image_url);
this.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadImage);
this.asyncImageEndLoaded2 = null;
oApi.WordControl.m_oLogicDocument.ShapeApply(oProp);
oApi.WordControl.m_oDrawingDocument.DrawImageTextureFillShape(image_url);
oApi.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadImage);
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
......@@ -3096,29 +3145,75 @@ asc_docs_api.prototype.ImgApply = function(obj){
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 (srcLocal){
ImagePr.ImageUrl = srcLocal;
}
if(!isNullOrEmptyString(ImagePr.ImageUrl)){
var sImageUrl = null;
if(!g_oDocumentUrls.getImageLocal(ImagePr.ImageUrl)){
sImageUrl = ImagePr.ImageUrl;
}
if (null != _img)
{
//ImagePr.ImageUrl = _img.src;
this.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr );
}
else
{
this.asyncImageEndLoaded2 = function(_image)
{
//ImagePr.ImageUrl = _image.src;
this.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr );
this.asyncImageEndLoaded2 = null;
}
}
var oApi = this;
var fApplyCallback = function(){
var _img = oApi.ImageLoader.LoadImage(ImagePr.ImageUrl, 1);
var srcLocal = g_oDocumentUrls.getImageLocal(ImagePr.ImageUrl);
if (srcLocal){
ImagePr.ImageUrl = srcLocal;
}
if (null != _img){
oApi.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr );
}
else{
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
{
......
......@@ -4767,43 +4767,95 @@ asc_docs_api.prototype.ImgApply = function(obj)
if (ImagePr.ShapeProperties)
ImagePr.ImageUrl = "";
if(ImagePr.ImageUrl != undefined && ImagePr.ImageUrl != null && ImagePr.ImageUrl != "")
{
var _img = this.ImageLoader.LoadImage(ImagePr.ImageUrl, 1);
if (null != _img)
{
ImagePr.ImageUrl = _img.src;
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(historydescription_Document_ApplyImagePrWithUrl);
this.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr );
}
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 );
var sImageUrl = null, fReplaceCallback = null, bImageUrl = false, sImageToDownLoad = "";
if(!isNullOrEmptyString(ImagePr.ImageUrl)){
if(!g_oDocumentUrls.getImageLocal(ImagePr.ImageUrl)){
sImageUrl = ImagePr.ImageUrl;
fReplaceCallback = function(sUrl){
ImagePr.ImageUrl = sUrl;
sImageToDownLoad = sUrl;
}
}
sImageToDownLoad = ImagePr.ImageUrl;
}
else if (ImagePr.ShapeProperties && ImagePr.ShapeProperties.fill && ImagePr.ShapeProperties.fill.fill &&
ImagePr.ShapeProperties.fill.fill.url !== undefined && ImagePr.ShapeProperties.fill.fill.url != null && ImagePr.ShapeProperties.fill.fill.url != "")
{
var _img = this.ImageLoader.LoadImage(ImagePr.ShapeProperties.fill.fill.url, 1);
if (null != _img)
{
ImagePr.ImageUrl = _img.src;
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(historydescription_Document_ApplyImagePrWithFillUrl);
this.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr );
else if(ImagePr.ShapeProperties && ImagePr.ShapeProperties.fill &&
ImagePr.ShapeProperties.fill.fill && !isNullOrEmptyString(ImagePr.ShapeProperties.fill.fill.url)){
if(!g_oDocumentUrls.getImageLocal(ImagePr.ShapeProperties.fill.fill.url)){
sImageUrl = ImagePr.ShapeProperties.fill.fill.url;
fReplaceCallback = function(sUrl){
ImagePr.ShapeProperties.fill.fill.url = sUrl;
sImageToDownLoad = sUrl;
}
}
else
{
this.asyncImageEndLoaded2 = function(_image)
sImageToDownLoad = ImagePr.ShapeProperties.fill.fill.url;
}
var oApi = this;
if(!isNullOrEmptyString(sImageToDownLoad)){
var fApplyCallback = function(){
var _img = oApi.ImageLoader.LoadImage(sImageToDownLoad, 1);
if (null != _img)
{
ImagePr.ImageUrl = _image.src;
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint(historydescription_Document_ApplyImagePrWithFillUrlLong);
this.WordControl.m_oLogicDocument.Set_ImageProps( ImagePr );
oApi.WordControl.m_oLogicDocument.Create_NewHistoryPoint(historydescription_Document_ApplyImagePrWithUrl);
oApi.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
......
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