Switch to FileDownloader from core

This commit is contained in:
Oleg Korshul
2018-04-19 18:12:34 +03:00
parent 593313cedb
commit 63be78f331
5 changed files with 38 additions and 14 deletions

View File

@ -85,7 +85,8 @@ SOURCES += \
./../../../core/Common/OfficeFileFormatChecker2.cpp \
./../../../core/Common/3dParty/pole/pole.cpp \
./../../../core/Common/DocxFormat/Source/Base/unicode_util.cpp \
./../../../core/HtmlRenderer/src/ASCSVGWriter.cpp
./../../../core/HtmlRenderer/src/ASCSVGWriter.cpp \
./../../../core/Common/FileDownloader/FileDownloader_curl.cpp
SOURCES += \
./src/additional/create.cpp

View File

@ -74,7 +74,8 @@ SOURCES += \
./../../../core/Common/OfficeFileFormatChecker2.cpp \
./../../../core/Common/3dParty/pole/pole.cpp \
./../../../core/Common/DocxFormat/Source/Base/unicode_util.cpp \
./../../../core/HtmlRenderer/src/ASCSVGWriter.cpp
./../../../core/HtmlRenderer/src/ASCSVGWriter.cpp \
./../../../core/Common/FileDownloader/FileDownloader_win.cpp
SOURCES += \
./src/additional/create.cpp

View File

@ -45,9 +45,9 @@
#include <iostream>
#include <set>
#include "./filedownloader.h"
#include "../../../../core/DesktopEditor/xml/include/xmlutils.h"
#include "../../../../core/Common/OfficeFileFormatChecker.h"
#include "../../../../core/Common/FileDownloader/FileDownloader.h"
#include "../../../../core/DesktopEditor/fontengine/application_generate_fonts.h"
@ -65,6 +65,28 @@
#define ONLYOFFICE_FONTS_VERSION_ 1
namespace NSFileDownloader
{
static bool IsNeedDownload(const std::wstring& FilePath)
{
std::wstring::size_type n1 = FilePath.find(L"www.");
std::wstring::size_type n2 = FilePath.find(L"http://");
std::wstring::size_type n3 = FilePath.find(L"ftp://");
std::wstring::size_type n4 = FilePath.find(L"https://");
if (n1 != std::wstring::npos && n1 < 10)
return true;
if (n2 != std::wstring::npos && n2 < 10)
return true;
if (n3 != std::wstring::npos && n3 < 10)
return true;
if (n4 != std::wstring::npos && n4 < 10)
return true;
return false;
}
}
class CAscReporterData
{
public:
@ -983,7 +1005,7 @@ public:
std::wstring sPath = sPathSrc;
#ifdef WIN32
if (!CFileDownloader::IsNeedDownload(sPath))
if (!NSFileDownloader::IsNeedDownload(sPath))
NSCommon::string_replace(sPath, L"/", L"\\");
#endif

View File

@ -115,7 +115,7 @@ std::wstring CPrintData::DownloadImage(const std::wstring& strFile)
void CPrintData::CalculateImagePaths()
{
m_sDocumentImagesPath = L"";
if (CFileDownloader::IsNeedDownload(m_sFrameUrl) && !CFileDownloader::IsNeedDownload(m_sDocumentUrl))
if (NSFileDownloader::IsNeedDownload(m_sFrameUrl) && !NSFileDownloader::IsNeedDownload(m_sDocumentUrl))
{
if (0 == m_sDocumentUrl.find(wchar_t('/')))
{
@ -157,8 +157,8 @@ void CPrintData::CalculateImagePaths()
}
m_sPresentationThemesPath = L"";
if ((CFileDownloader::IsNeedDownload(m_sFrameUrl) || (m_sFrameUrl.find(L"file://") == 0))
&& !CFileDownloader::IsNeedDownload(m_sThemesUrl))
if ((NSFileDownloader::IsNeedDownload(m_sFrameUrl) || (m_sFrameUrl.find(L"file://") == 0))
&& !NSFileDownloader::IsNeedDownload(m_sThemesUrl))
{
if (0 == m_sThemesUrl.find(wchar_t('/')))
{
@ -265,7 +265,7 @@ std::wstring CPrintData::GetImagePath(const std::wstring& sPath)
}
// 3) смотрим, может это прямая ссылка
if (CFileDownloader::IsNeedDownload(sPath))
if (NSFileDownloader::IsNeedDownload(sPath))
{
std::wstring sFileDownload = this->DownloadImage(sPath);
m_mapImages.insert(std::pair<std::wstring, std::wstring>(sPath, sFileDownload));
@ -295,7 +295,7 @@ std::wstring CPrintData::GetImagePath(const std::wstring& sPath)
sUrl2 = m_sDocumentImagesPath + sPath2.substr(0, nPos) + L".wmf";
}
if (CFileDownloader::IsNeedDownload(m_sDocumentImagesPath))
if (NSFileDownloader::IsNeedDownload(m_sDocumentImagesPath))
{
std::wstring s1 = this->DownloadImage(sUrl);
if (!s1.empty())
@ -388,7 +388,7 @@ std::wstring CPrintData::GetImagePath(const std::wstring& sPath)
sUrl2 = sPresentationThemesPath + sPath.substr(0, nPos) + L".wmf";
}
if (CFileDownloader::IsNeedDownload(m_sPresentationThemesPath))
if (NSFileDownloader::IsNeedDownload(m_sPresentationThemesPath))
{
std::wstring s1 = this->DownloadImage(sUrl);
if (!s1.empty())

View File

@ -55,10 +55,10 @@ namespace NSFileDownloader
{
static bool IsNeedDownload(const std::wstring& FilePath)
{
int n1 = FilePath.find(L"www.");
int n2 = FilePath.find(L"http://");
int n3 = FilePath.find(L"ftp://");
int n4 = FilePath.find(L"https://");
std::wstring::size_type n1 = FilePath.find(L"www.");
std::wstring::size_type n2 = FilePath.find(L"http://");
std::wstring::size_type n3 = FilePath.find(L"ftp://");
std::wstring::size_type n4 = FilePath.find(L"https://");
if (n1 != std::wstring::npos && n1 < 10)
return true;