Commit c454dd3d authored by konovalovsergey's avatar konovalovsergey

Bug #22107 - [Copy&Paste] Слайд с темой копируется в другую презентацию с...

Bug #22107 - [Copy&Paste] Слайд с темой копируется в другую презентацию с красным крестом вместо темы
parent a4e0ff6a
......@@ -33,6 +33,7 @@ window.location = {};
window.location.protocol = "";
window.location.host = "";
window.location.href = "";
window.location.pathname = "";
window.NATIVE_EDITOR_ENJINE = true;
window.NATIVE_EDITOR_ENJINE_SYNC_RECALC = true;
......
......@@ -32,6 +32,7 @@ window.location = {};
window.location.protocol = "";
window.location.host = "";
window.location.href = "";
window.location.pathname = "";
window.NATIVE_EDITOR_ENJINE = true;
window.NATIVE_EDITOR_ENJINE_SYNC_RECALC = true;
......
......@@ -113,7 +113,7 @@ function CBinaryFileWriter()
this.Start_UseDocumentOrigin = function(origin)
{
this.PresentationThemesOrigin = origin + "/presentationthemes/";
this.PresentationThemesOrigin = origin;
};
this.End_UseFullUrl = function()
......
......@@ -66,7 +66,9 @@ function baseEditorsApi(name) {
// Тип скачивания файлы(download или event).нужен для txt, csv. запоминаем на asc_DownloadAs используем asc_setAdvancedOptions
this.downloadType = DownloadType.None;
this.OpenDocumentProgress = new COpenProgress();
this.documentOrigin = ''; // ToDo скорее всего лишняя переменная и можно обойтись и без нее
var sProtocol = window.location.protocol;
this.documentOrigin = ((sProtocol && '' !== sProtocol) ? sProtocol + '//' : '') + window.location.host; // for presentation theme url
this.documentPathname = window.location.pathname; // for presentation theme url
// Переменная отвечает, получили ли мы ответ с сервера совместного редактирования
this.ServerIdWaitComplete = false;
......@@ -185,8 +187,6 @@ baseEditorsApi.prototype.asc_setDocInfo = function(oDocInfo) {
this.documentFormat = this.DocInfo.get_Format();
this.documentCallbackUrl = this.DocInfo.get_CallbackUrl();
this.documentVKey = this.DocInfo.get_VKey();
var sProtocol = window.location.protocol;
this.documentOrigin = ((sProtocol && '' !== sProtocol) ? sProtocol + '//' : '') + window.location.host;
this.documentOpenOptions = this.DocInfo.asc_getOptions();
......
......@@ -155,8 +155,8 @@ DocumentUrls.prototype = {
getLocal : function(url){
if(this.urlsReverse){
var res = this.urlsReverse[url];
if (!res && typeof editor !== 'undefined' && editor.ThemeLoader && 0 == url.indexOf(editor.ThemeLoader.ThemesUrl)) {
res = url.substring(editor.ThemeLoader.ThemesUrl.length);
if (!res && typeof editor !== 'undefined' && editor.ThemeLoader && 0 == url.indexOf(editor.ThemeLoader.ThemesUrlAbs)) {
res = url.substring(editor.ThemeLoader.ThemesUrlAbs.length);
}
return res;
}
......@@ -351,14 +351,29 @@ function g_fMapAscServerErrorToAscError (nServerError) {
return nRes;
}
function joinUrls(base, relative) {
//http://stackoverflow.com/questions/14780350/convert-relative-path-to-absolute-using-javascript
var stack = base.split("/"),
parts = relative.split("/");
stack.pop(); // remove current file name (or empty string)
// (omit if "base" is the current folder without trailing slash)
for (var i=0; i<parts.length; i++) {
if (parts[i] == ".")
continue;
if (parts[i] == "..")
stack.pop();
else
stack.push(parts[i]);
}
return stack.join("/");
}
function getFullImageSrc2 (src) {
if (window["NATIVE_EDITOR_ENJINE"])
return src;
var start = src.slice(0, 6);
if (0 === start.indexOf('theme')){
var themesUrl = editor.ThemeLoader ? editor.ThemeLoader.ThemesUrl : undefined;
return themesUrl + src;
if (0 === start.indexOf('theme') && editor.ThemeLoader){
return editor.ThemeLoader.ThemesUrlAbs + src;
}
if (0 !== start.indexOf('http:') && 0 !== start.indexOf('data:') && 0 !== start.indexOf('https:') &&
......
......@@ -606,7 +606,9 @@ function CopyProcessor(api, onlyBinaryCopy)
this.oBinaryFileWriter = new BinaryFileWriter(this.oDocument);
this.oPresentationWriter = new CBinaryFileWriter();
this.oPresentationWriter.Start_UseFullUrl();
this.oPresentationWriter.Start_UseDocumentOrigin(this.api.documentOrigin);
if (this.api.ThemeLoader) {
this.oPresentationWriter.Start_UseDocumentOrigin(this.api.ThemeLoader.ThemesUrlAbs);
}
this.oRoot = new CopyElement("root");
}
......
......@@ -48,7 +48,8 @@ function CThemeLoader()
this.Api = null;
this.CurrentLoadThemeIndex = -1;
this.ThemesUrl = "";
this.ThemesUrl = "";
this.ThemesUrlAbs = "";
this.IsReloadBinaryThemeEditorNow = false;
......
......@@ -552,6 +552,11 @@ asc_docs_api.prototype.asc_setLocale = function(val) {
asc_docs_api.prototype.SetThemesPath = function(path)
{
this.ThemeLoader.ThemesUrl = path;
if (this.documentOrigin) {
this.ThemeLoader.ThemesUrlAbs = joinUrls(this.documentOrigin + this.documentPathname, path);
} else {
this.ThemeLoader.ThemesUrlAbs = path;
}
};
asc_docs_api.prototype.CreateCSS = function()
......
......@@ -1234,13 +1234,7 @@ CMetafile.prototype =
var srcLocal = g_oDocumentUrls.getLocal(_src);
if (srcLocal){
_src = srcLocal;
} else {
if (window.editor.ThemeLoader !== undefined && window.editor.ThemeLoader != null)
{
if (0 == _src.indexOf(window.editor.ThemeLoader.ThemesUrl))
_src = _src.substring(window.editor.ThemeLoader.ThemesUrl.length);
}
}
}
this.Memory.WriteByte(CommandType.ctDrawImageFromFile);
this.Memory.WriteString2(_src);
......
......@@ -1017,7 +1017,10 @@ function BinaryFileWriter(doc, bMailMergeDocx, bMailMergeHtml)
{
var api = this.Document.DrawingDocument.m_oWordControl.m_oApi;
window.global_pptx_content_writer.Start_UseFullUrl();
window.global_pptx_content_writer.Start_UseDocumentOrigin(api.documentOrigin);
if (api.ThemeLoader) {
window.global_pptx_content_writer.Start_UseDocumentOrigin(api.ThemeLoader.ThemesUrlAbs);
}
window.global_pptx_content_writer._Start();
this.copyParams.bLockCopyElems = 0;
this.copyParams.itemCount = 0;
......
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