Commit 71b3e205 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@53348 954022d7-b5bf-4e40-9824-e11837661b57
parent e30deaf8
<Settings>
<file>X:\AVS\Sources\TeamlabOffice\trunk\ServerComponents\DoctRenderer\COMMON\native.js</file>
<file>X:\AVS\Sources\TeamlabOffice\trunk\ServerComponents\DoctRenderer\COMMON\jquery_native.js</file>
<file>X:\AVS\Sources\TeamlabOffice\trunk\OfficeWeb\Common\3rdparty\XRegExp\xregexp-all-min.js</file>
</Settings>
\ No newline at end of file
......@@ -147,6 +147,9 @@ private:
CExecuteParams m_oParams;
IASCRenderer* m_pRenderer;
CString m_strConfigPath;
CAtlArray<CString> m_arrFiles;
public:
CDoctRenderer()
{
......@@ -157,6 +160,35 @@ public:
HRESULT FinalConstruct()
{
m_strConfigPath = _T("");
HINSTANCE hModule = _AtlBaseModule.GetModuleInstance();
TCHAR szPathDLL[MAX_PATH] = {0}; ::GetModuleFileName(hModule, szPathDLL, MAX_PATH);
m_strConfigPath = CString(szPathDLL);
int nFind = m_strConfigPath.ReverseFind(TCHAR('\\'));
if (-1 != nFind)
m_strConfigPath.Delete(nFind, m_strConfigPath.GetLength() - nFind);
m_strConfigPath += _T("\\DoctRenderer.config");
XmlUtils::CXmlNode oNode;
if (oNode.FromXmlFile(m_strConfigPath))
{
XmlUtils::CXmlNodes oNodes;
if (oNode.GetNodes(_T("file"), oNodes))
{
int nCount = oNodes.GetCount();
XmlUtils::CXmlNode _node;
for (int i = 0; i < nCount; ++i)
{
oNodes.GetAt(i, _node);
m_arrFiles.Add(_node.GetText());
}
}
}
return S_OK;
}
......@@ -186,6 +218,15 @@ public:
{
m_oParams.FromXml(bsXml);
CString strMainPart = _T("");
for (size_t i = 0; i < m_arrFiles.GetCount(); ++i)
{
strMainPart += ReadFileCStringA(m_arrFiles[i]);
strMainPart += _T("\n\n");
}
CString strCorrector = _T("");
LPCTSTR sResource = NULL;
switch (m_oParams.m_eSrcFormat)
{
......@@ -227,6 +268,7 @@ public:
case DoctRendererFormat::PDF:
{
sResource = MAKEINTRESOURCE(IDB_SCRIPT_XSLX);
strCorrector = _T("var NATIVE_DOCUMENT_TYPE = \"spreadsheet\";$.ready();");
break;
}
default:
......@@ -278,8 +320,11 @@ public:
strScript += _T("\";\n\n");
strScript += strAllFonts;
strScript += strMainPart;
strScript += strResource;
strScript += strCorrector;
BOOL bResult = ExecuteScript(strScript);
return bResult ? S_OK : S_FALSE;
......@@ -350,6 +395,18 @@ private:
return pUnicodeString;
}
CString ReadFileCStringA(const CString& strFile)
{
CFile oFile;
HRESULT hr = oFile.OpenFile(strFile);
int nSize = (int)oFile.GetFileSize();
BYTE* pData = new BYTE[nSize];
oFile.ReadFile(pData, (DWORD)nSize);
CString sRes((char*)pData, nSize);
delete [] pData;
return sRes;
}
BOOL ExecuteScript(CString& strScript)
{
CString strException = _T("");
......@@ -372,6 +429,7 @@ private:
if (try_catch.HasCaught())
{
CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get());
return FALSE;
}
......@@ -380,7 +438,7 @@ private:
if (try_catch.HasCaught())
{
int nLineError = try_catch.Message()->GetLineNumber();
CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get());
return FALSE;
}
......@@ -436,7 +494,7 @@ private:
if (try_catch.HasCaught())
{
int nLineError = try_catch.Message()->GetLineNumber();
CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get()); // ?
return FALSE;
}
......
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