Commit 1ae20da7 authored by Oleg Korshul's avatar Oleg Korshul Committed by Alexander Trofimov

новая схема (несколько скриптов)

parent 65d37bb2
......@@ -203,9 +203,9 @@ namespace NSDoctRenderer
std::wstring m_strConfigPath;
CArray<std::wstring> m_arrFiles;
std::wstring m_strDoctSDK;
std::wstring m_strPpttSDK;
std::wstring m_strXlstSDK;
std::vector<std::wstring> m_arDoctSDK;
std::vector<std::wstring> m_arPpttSDK;
std::vector<std::wstring> m_arXlstSDK;
std::wstring m_strEditorType;
std::wstring m_strFilePath;
......@@ -250,30 +250,17 @@ namespace NSDoctRenderer
}
}
m_strDoctSDK = L"";
m_strPpttSDK = L"";
m_strXlstSDK = L"";
XmlUtils::CXmlNode oNodeSdk = oNode.ReadNode(L"DoctSdk");
if (oNodeSdk.IsValid())
m_strDoctSDK = oNodeSdk.GetText();
LoadSDK_scripts(oNodeSdk, m_arDoctSDK);
oNodeSdk = oNode.ReadNode(L"PpttSdk");
if (oNodeSdk.IsValid())
m_strPpttSDK = oNodeSdk.GetText();
LoadSDK_scripts(oNodeSdk, m_arPpttSDK);
oNodeSdk = oNode.ReadNode(L"XlstSdk");
if (oNodeSdk.IsValid())
m_strXlstSDK = oNodeSdk.GetText();
if (!NSFile::CFileBinary::Exists(m_strDoctSDK))
m_strDoctSDK = m_strConfigDir + m_strDoctSDK;
if (!NSFile::CFileBinary::Exists(m_strPpttSDK))
m_strPpttSDK = m_strConfigDir + m_strPpttSDK;
if (!NSFile::CFileBinary::Exists(m_strXlstSDK))
m_strXlstSDK = m_strConfigDir + m_strXlstSDK;
LoadSDK_scripts(oNodeSdk, m_arXlstSDK);
m_sConsoleLogFile = L"";
m_sErrorsLogFile = L"";
......@@ -299,6 +286,37 @@ namespace NSDoctRenderer
}
void LoadSDK_scripts(XmlUtils::CXmlNode& oNode, std::vector<std::wstring>& _files)
{
XmlUtils::CXmlNodes oNodes;
if (oNode.GetNodes(L"file", oNodes))
{
int nCount = oNodes.GetCount();
XmlUtils::CXmlNode _node;
for (int i = 0; i < nCount; ++i)
{
oNodes.GetAt(i, _node);
std::wstring strFilePath = _node.GetText();
if (NSFile::CFileBinary::Exists(strFilePath) &&
!NSFile::CFileBinary::Exists(m_strConfigDir + strFilePath))
_files.push_back(strFilePath);
else
_files.push_back(m_strConfigDir + strFilePath);
}
}
else
{
std::wstring strFilePath = oNode.GetText();
if (NSFile::CFileBinary::Exists(strFilePath) &&
!NSFile::CFileBinary::Exists(m_strConfigDir + strFilePath))
_files.push_back(strFilePath);
else
_files.push_back(m_strConfigDir + strFilePath);
}
}
public:
static void _LOGGING_ERROR_(const std::wstring& strType, const std::wstring& strError)
......@@ -960,7 +978,7 @@ namespace NSDoctRenderer
m_pInternal->m_oParams.FromXml(strXml);
m_pInternal->m_arImagesInChanges.clear();
std::wstring sResourceFile;
std::vector<std::wstring>* arSdkFiles = NULL;
switch (m_pInternal->m_oParams.m_eSrcFormat)
{
case DoctRendererFormat::DOCT:
......@@ -971,7 +989,7 @@ namespace NSDoctRenderer
case DoctRendererFormat::PDF:
case DoctRendererFormat::HTML:
{
sResourceFile = m_pInternal->m_strDoctSDK;
arSdkFiles = &m_pInternal->m_arDoctSDK;
m_pInternal->m_strEditorType = L"document";
break;
}
......@@ -987,7 +1005,7 @@ namespace NSDoctRenderer
case DoctRendererFormat::PPTT:
case DoctRendererFormat::PDF:
{
sResourceFile = m_pInternal->m_strPpttSDK;
arSdkFiles = &m_pInternal->m_arPpttSDK;
m_pInternal->m_strEditorType = L"presentation";
break;
}
......@@ -1003,7 +1021,7 @@ namespace NSDoctRenderer
case DoctRendererFormat::XLST:
case DoctRendererFormat::PDF:
{
sResourceFile = m_pInternal->m_strXlstSDK;
arSdkFiles = &m_pInternal->m_arXlstSDK;
m_pInternal->m_strEditorType = L"spreadsheet";
break;
}
......@@ -1037,9 +1055,15 @@ namespace NSDoctRenderer
strScript += "\n\n";
}
// теперь оборачиваем сами
//strScript += ("(function(){" + m_pInternal->ReadScriptFile(sResourceFile) + "})();");
strScript += m_pInternal->ReadScriptFile(sResourceFile);
if (NULL != arSdkFiles)
{
for (std::vector<std::wstring>::iterator i = arSdkFiles->begin(); i != arSdkFiles->end(); i++)
{
strScript += m_pInternal->ReadScriptFile(*i);
strScript += "\n\n";
}
}
if (m_pInternal->m_strEditorType == L"spreadsheet")
strScript += "\n$.ready();";
......
......@@ -117,13 +117,36 @@ static void GetScriptsPath(NSStringUtils::CStringBuilder& oBuilder)
}
}
std::wstring sPath = oNode.ReadValueString(L"DoctSdk");
if (!NSFile::CFileBinary::Exists(sPath) || NSFile::CFileBinary::Exists(sProcess + sPath))
sPath = sProcess + sPath;
XmlUtils::CXmlNode oNodeSdk = oNode.ReadNode(L"DoctSdk");
XmlUtils::CXmlNodes oNodes;
if (oNodeSdk.GetNodes(L"file", oNodes))
{
int nCount = oNodes.GetCount();
XmlUtils::CXmlNode _node;
for (int i = 0; i < nCount; ++i)
{
oNodes.GetAt(i, _node);
std::wstring sPath = _node.GetText();
if (!NSFile::CFileBinary::Exists(sPath) || NSFile::CFileBinary::Exists(sProcess + sPath))
sPath = sProcess + sPath;
oBuilder.WriteString(L"<sdk>");
oBuilder.WriteEncodeXmlString(CorrectHtmlPath(sPath));
oBuilder.WriteString(L"</sdk>");
}
}
else
{
std::wstring sPath = oNodeSdk.GetText();
if (!NSFile::CFileBinary::Exists(sPath) || NSFile::CFileBinary::Exists(sProcess + sPath))
sPath = sProcess + sPath;
oBuilder.WriteString(L"<sdk>");
oBuilder.WriteEncodeXmlString(CorrectHtmlPath(sPath));
oBuilder.WriteString(L"</sdk>");
oBuilder.WriteString(L"<sdk>");
oBuilder.WriteEncodeXmlString(CorrectHtmlPath(sPath));
oBuilder.WriteString(L"</sdk>");
}
}
int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstring& sDstfolder, const std::wstring& sPathInternal)
......@@ -214,11 +237,31 @@ int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstr
NULL, NULL, TRUE, CREATE_UNICODE_ENVIRONMENT, (LPVOID)pCommandLineEnv, NULL, &sturtupinfo, &processinfo);
#else
HANDLE ghJob = CreateJobObject(NULL, NULL);
if (ghJob)
{
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 };
// Configure all child processes associated with the job to terminate when the
jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
if ( 0 == SetInformationJobObject( ghJob, JobObjectExtendedLimitInformation, &jeli, sizeof(jeli)))
{
CloseHandle(ghJob);
ghJob = NULL;
}
}
PROCESS_INFORMATION processinfo;
ZeroMemory(&processinfo,sizeof(PROCESS_INFORMATION));
BOOL bResult = CreateProcessW(sInternal.c_str(), pCommandLine,
NULL, NULL, TRUE, NULL, NULL, NULL, &sturtupinfo, &processinfo);
if (bResult && ghJob)
{
AssignProcessToJobObject(ghJob, processinfo.hProcess);
}
#endif
::WaitForSingleObject(processinfo.hProcess, INFINITE);
......
......@@ -24,7 +24,7 @@ CONFIG += c++11
TEMPLATE = app
############### destination path ###############
DESTINATION_SDK_PATH = $$PWD/../../SDK/lib
DESTINATION_SDK_PATH = $$PWD/../../build/lib
# WINDOWS
win32:contains(QMAKE_TARGET.arch, x86_64):{
......@@ -56,8 +56,8 @@ LIBS += -L$$DESTINATION_SDK_PATH -lgraphics
linux-g++ | linux-g++-64 | linux-g++-32 {
QMAKE_LFLAGS += -Wl,--rpath=./
LIBS += $$PWD/../../UnicodeConverter/icubuilds/linux64/usr/local/lib/libicuuc.so.55
LIBS += $$PWD/../../UnicodeConverter/icubuilds/linux64/usr/local/lib/libicudata.so.55
LIBS += $$PWD/../../build/bin/icu/linux_64/libicuuc.so.55
LIBS += $$PWD/../../build/bin/icu/linux_64/libicudata.so.55
message(linux)
}
......
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