Commit 7ac1656a authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

удалил ненужное

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@64218 954022d7-b5bf-4e40-9824-e11837661b57
parent 4f33c2f0
......@@ -7648,12 +7648,6 @@ DesktopEditor/xml/libxml2/xstc svnc_tsvn_003alogminsize=5
DesktopEditor/xml/src svnc_tsvn_003alogminsize=5
DjVuFile/DjVuFileTest svnc_tsvn_003alogminsize=5
DjVuFile/libdjvu svnc_tsvn_003alogminsize=5
DoctRenderer/COMMON/Dlls/AVSGraphics.dll svn_mime_002dtype=application%2Foctet-stream
DoctRenderer/COMMON/Dlls/AVSOfficeFOFile.dll svn_mime_002dtype=application%2Foctet-stream
DoctRenderer/COMMON/Joiner/bin/Debug/Joiner.exe svn_mime_002dtype=application%2Foctet-stream
DoctRenderer/COMMON/JoinerPPT/bin/Debug/Joiner.exe svn_mime_002dtype=application%2Foctet-stream
DoctRenderer/COMMON/JoinerXLS/bin/Debug/Joiner.exe svn_mime_002dtype=application%2Foctet-stream
DoctRenderer/COMMON/TestConsole/Ionic.Zip.Reduced.dll svn_mime_002dtype=application%2Foctet-stream
/HtmlFile svnc_tsvn_003alogminsize=5
HtmlFile/Internal svnc_tsvn_003alogminsize=5
HtmlFile/Internal/src svnc_tsvn_003alogminsize=5
#pragma once
#include "stdafx.h"
#include "resource.h" // main symbols
#include "Registration.h"
#include "..\Interfaces\XmlUtils.h"
#include "..\..\AVSVideoStudio3\Common\AvsUtils.h"
#include "ImageSerializeObjects2.h"
#include "AVSDocumentRenderer.h"
#include "GdiPlusEx.h"
#include "Common.h"
// XML
#include "..\..\..\AVSOfficeStudio\Common\RSA\XMLDecoder.h"
// -
#include "..\Interfaces\BaseThread.h"
using namespace ImageStudio::Serialize::Paint::Common;
// IAVSOfficeViewer
[object, uuid("0DA1E32E-D5D6-48f7-A28C-B477554AFE65"), dual, pointer_default(unique)]
__interface IAVSDocumentPainter : IDispatch
{
[id(0)] HRESULT SetXml([in] BSTR bstrXml);
[id(1)] HRESULT AddRenderer([in] IUnknown* punkRenderer);
[id(2)] HRESULT RemoveRenderer([in] IUnknown* punkRenderer);
[id(10)] HRESULT Start();
[id(11)] HRESULT Stop();
[id(12)] HRESULT Suspend();
[id(13)] HRESULT Resume();
[id(50), propget] HRESULT Status([out, retval] LONG* pStatus);
[id(60), propget] HRESULT Priority([out, retval] LONG* pPriority);
[id(60), propput] HRESULT Priority([in] LONG Priotity);
[id(2000)] HRESULT SetAdditionalParam([in] BSTR ParamName, [in] VARIANT ParamValue);
[id(2001)] HRESULT GetAdditionalParam([in] BSTR ParamName, [out, retval] VARIANT* ParamValue);
};
[dispinterface, uuid("ECE824D3-96AC-4cac-BBE0-A156FDF1F9DC")]
__interface _IAVSDocumentPainterEvents
{
[id(0)] HRESULT OnError(LONG lError);
[id(1)] HRESULT OnStop();
[id(5)] HRESULT OnProgress(LONG lProgressPage);
[id(6)] HRESULT OnProgressParce(LONG lType, LONG lProgress);
// , , gdiplus-
[id(10)] HRESULT OnNewPage(double dWidthMm, double dHeightMm);
[id(11)] HRESULT OnCompletePage();
};
// CAVSDocumentPainter
[coclass, uuid("F06CB25F-4960-4083-9858-C775158BA9A5"), event_source(com), threading(apartment), vi_progid("AVSDocumentPainter"), progid("AVSDocumentPainter.1"), version(1.0)]
class ATL_NO_VTABLE CAVSDocumentPainter :
public IAVSDocumentPainter,
public CBaseThread,
public CEventReceiver,
public CTextMeasurer
{
protected:
class CPageInfo
{
public:
CString m_strPageInfo;
double m_dWidthMetric;
double m_dHeightMetric;
CBaseThread* m_pThread;
CEventReceiver* m_pReceiver;
public:
CPageInfo() :
m_pThread(NULL),
m_pReceiver(NULL),
m_strPageInfo(_T("")),
m_dWidthMetric(0.0),
m_dHeightMetric(0.0)
{
}
CPageInfo(const CPageInfo& oSrc)
{
*this = oSrc;
}
CPageInfo& operator=(const CPageInfo& oSrc)
{
m_strPageInfo = oSrc.m_strPageInfo;
m_pThread = oSrc.m_pThread;
m_pReceiver = oSrc.m_pReceiver;
m_dWidthMetric = oSrc.m_dWidthMetric;
m_dHeightMetric = oSrc.m_dHeightMetric;
return *this;
}
public:
void Render(IAVSRenderer* pRenderer, CTextMeasurer* pMeasurer, double dDPIX, double dDPIY)
{
if ((NULL == pRenderer) || (NULL == pMeasurer) || (NULL == m_pThread))
return;
LONG lRendType = 0;
pRenderer->get_Type(&lRendType);
if (c_nPDFWriter == lRendType)
{
VARIANT var;
var.vt = VT_BOOL;
var.boolVal = VARIANT_TRUE;
pRenderer->SetAdditionalParam(L"WhiteBackImage", var);
}
XmlUtils::CXmlNode oNodeSource;
oNodeSource.FromXmlString(m_strPageInfo);
if (g_cpszXMLImageSource == oNodeSource.GetName())
{
CString strFileName = oNodeSource.GetAttributeOrValue(_T("FilePath"));
float fX = 0;
float fY = 0;
float fWidth = m_dWidthMetric;
float fHeight = m_dHeightMetric;
IAVSDocumentRenderer* pRend2 = NULL;
pRenderer->QueryInterface(__uuidof(IAVSDocumentRenderer), (void**)&pRend2);
if (NULL != pRend2)
{
pRenderer->put_Width(fWidth);
pRenderer->put_Height(fHeight);
BSTR bstrFile = strFileName.AllocSysString();
pRend2->DrawImageFromFile(bstrFile, fX, fY, fWidth, fHeight);
SysFreeString(bstrFile);
RELEASEINTERFACE(pRend2);
}
else
{
ImageStudio::Serialize::Paint::Common::CDrawImageFromFile oImagePainter;
oImagePainter.FilePath = strFileName;
oImagePainter.Left = fX;
oImagePainter.Top = fY;
oImagePainter.Right = fX + fWidth;
oImagePainter.Bottom = fY + fHeight;
oImagePainter.m_dWidthMM = m_dWidthMetric;
oImagePainter.m_dHeightMM = m_dHeightMetric;
oImagePainter.Draw(pRenderer, dDPIX, dDPIY);
}
return;
}
XmlUtils::CXmlNode oNodeVideoTransforms;
if ( oNodeSource.GetNode(g_cpszXMLVideoTransforms, oNodeVideoTransforms) )
{
XmlUtils::CXmlReader oReader;
if (oReader.SetXmlString(oNodeVideoTransforms.GetXml()) && oReader.ReadNodeList(_T("*")))
{
int nEffectCount = oReader.GetLengthList();
if (0 < nEffectCount)
{
for (int i = 0; (i < nEffectCount) && (m_pThread->IsRunned()); ++i)
{
if (NULL != m_pReceiver)
{
m_pReceiver->OnSendEvent(OFFICEEDITOR_PROGRESS_TYPE_ELEMENT, 100 * (i + 1) / nEffectCount, 0);
}
XmlUtils::CXmlNode oNodeEffect;
oNodeEffect.FromXmlString(oReader.ReadNodeXml(i));
CString sNodeName = oNodeEffect.GetName();
if (g_cpszXMLEffectText == sNodeName)
{
if (NULL != pMeasurer)
{
pMeasurer->InternalFromXmlNode(oNodeEffect);
if (!pMeasurer->IsFormated())
{
pMeasurer->InitDrawText(pRenderer, 720, 576);
}
pMeasurer->DrawText(pRenderer, 1.0);
}
}
else if (g_cpszXMLPath == sNodeName)
{
ImageStudio::Serialize::Paint::Common::CDrawGraphicPath oPath;
oPath.InternalFromXmlNode(oNodeEffect);
oPath.Draw(pRenderer);
pRenderer->PathCommandEnd();
}
else if (g_cpszXMLImage == sNodeName)
{
ImageStudio::Serialize::Paint::Common::CDrawImageFromFile oImagePainter;
oImagePainter.InternalFromXmlNode(oNodeEffect);
BOOL bNeedDraw = TRUE;
if (-1 == dDPIX && -1 == dDPIY)
{
IAVSDocumentRenderer* pCommandRenderer = NULL;
pRenderer->QueryInterface(__uuidof(IAVSDocumentRenderer), (void**)&pCommandRenderer);
if (NULL != pCommandRenderer)
{
oImagePainter.DrawFromFile(pRenderer);
RELEASEINTERFACE(pCommandRenderer);
bNeedDraw = FALSE;
}
}
if (bNeedDraw)
{
oImagePainter.Draw(pRenderer, dDPIX, dDPIY);
}
}
m_pThread->CheckSuspend();
}
}
}
}
}
};
protected:
CGdiPlusInit m_oInit;
CXMLDecoder m_oDecoder;
// xml-, .
// .
// 1) xml videosource
// 2) XmlRenderer',
// , xml-fo
CAtlArray<CPageInfo> m_arPages;
// xsl-fo
CString m_strFoXml;
// ...
CAtlArray<IAVSRenderer*> m_arRenderers;
public:
__event __interface _IAVSDocumentPainterEvents;
CAVSDocumentPainter() : m_arRenderers(), m_arPages(), CBaseThread(0)
{
m_oInit.Init();
m_strFoXml = _T("");
}
~CAVSDocumentPainter()
{
Stop();
size_t nCount = m_arRenderers.GetCount();
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
{
RELEASEINTERFACE((m_arRenderers[nIndex]));
}
m_arRenderers.RemoveAll();
}
public:
STDMETHOD(SetXml)(BSTR bstrXml)
{
m_arPages.RemoveAll();
//CString strXml = CString(bstrXml);
//strXml = m_oDecoder.DecryptXML(strXml);
CString strXml = _T("");
CString strInput = (CString)bstrXml;
if (strInput.Find(_T("TEAMLAB_DOCS")) == 0)
strXml = strInput.Mid(12);
else
strXml = m_oDecoder.DecryptXML(bstrXml);
m_strFoXml = _T("");
//
XmlUtils::CXmlNode oRootNode;
XmlUtils::CXmlNode XmlSingleSourceNode;
BOOL bIsVideoSource = FALSE;
if (oRootNode.FromXmlString(strXml))
{
if (_T("Tracks") == oRootNode.GetName())
{
XmlUtils::CXmlNodes oUsers;
if (oRootNode.GetNodes(g_cpszXMLMultiSource, oUsers))
{
if (0 < oUsers.GetCount())
{
XmlUtils::CXmlNode oMulti;
if (oUsers.GetAt(0, oMulti))
{
if (oMulti.GetNode(g_cpszXMLSingleSource, XmlSingleSourceNode))
{
bIsVideoSource = TRUE;
}
}
}
}
}
else if (oRootNode.GetNode(g_cpszXMLSingleSource, XmlSingleSourceNode))
{
bIsVideoSource = TRUE;
}
}
if ( bIsVideoSource )
{
XmlUtils::CXmlNode XmlNodeVideo;
if ( XmlSingleSourceNode.GetNode ( g_cpszXMLVideoSources, XmlNodeVideo ) )
{
XmlUtils::CXmlNodes oReader;
if (XmlNodeVideo.GetNodes(_T("*"), oReader))
{
int nSourceCount = oReader.GetCount();
if (0 < nSourceCount)
{
for (int i = 0; i < nSourceCount; ++i)
{
XmlUtils::CXmlNode oPageNode;
oReader.GetAt(i, oPageNode);
CString sNodeName = oPageNode.GetName();
if (g_cpszXMLColorSource == sNodeName)
{
// ( ??)
if (0 == i)
{
int nColor = XmlUtils::GetInteger(oPageNode.GetAttributeOrValue(_T("Color"), _T("-1")));
if (0 == nColor)
{
XmlUtils::CXmlNode oNodeTransforms;
if (!oPageNode.GetNode(g_cpszXMLVideoTransforms, oNodeTransforms))
{
// ))
continue;
}
}
}
m_arPages.Add();
m_arPages[m_arPages.GetCount() - 1].m_strPageInfo = oPageNode.GetXml();
m_arPages[m_arPages.GetCount() - 1].m_pThread = this;
m_arPages[m_arPages.GetCount() - 1].m_pReceiver = this;
m_arPages[m_arPages.GetCount() - 1].m_dWidthMetric = Strings::ToDouble(oPageNode.GetAttributeOrValue(_T("widthmetric"), _T("210")));
m_arPages[m_arPages.GetCount() - 1].m_dHeightMetric = Strings::ToDouble(oPageNode.GetAttributeOrValue(_T("heightmetric"), _T("190")));
}
else if (g_cpszXMLImageSource == sNodeName)
{
m_arPages.Add();
m_arPages[m_arPages.GetCount() - 1].m_strPageInfo = oPageNode.GetXml();
m_arPages[m_arPages.GetCount() - 1].m_pThread = this;
m_arPages[m_arPages.GetCount() - 1].m_pReceiver = this;
m_arPages[m_arPages.GetCount() - 1].m_dWidthMetric = Strings::ToDouble(oPageNode.GetAttributeOrValue(_T("widthmetric"), _T("210")));
m_arPages[m_arPages.GetCount() - 1].m_dHeightMetric = Strings::ToDouble(oPageNode.GetAttributeOrValue(_T("heightmetric"), _T("190")));
}
}
}
}
}
}
else
{
// fo - .
// XmlRenderer.
//
//m_strFoXml = GetCStringFromUTF8((CStringA)strXml);
m_strFoXml = DeleteRootNode(strXml);
}
return S_OK;
}
STDMETHOD(AddRenderer)(IUnknown* punkRenderer)
{
// ...
size_t nCount = m_arRenderers.GetCount();
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
{
if (punkRenderer == m_arRenderers[nIndex])
{
//
return S_OK;
}
}
IAVSRenderer* pRenderer = NULL;
if (NULL != punkRenderer)
punkRenderer->QueryInterface(__uuidof(IAVSRenderer), (void**)&pRenderer);
if (NULL != pRenderer)
{
m_arRenderers.Add(pRenderer);
}
return S_OK;
}
STDMETHOD(RemoveRenderer)(IUnknown* punkRenderer)
{
// ...
size_t nCount = m_arRenderers.GetCount();
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
{
if (punkRenderer == m_arRenderers[nIndex])
{
RELEASEINTERFACE((m_arRenderers[nIndex]));
m_arRenderers.RemoveAt(nIndex);
break;
}
}
return S_OK;
}
STDMETHOD(Start)()
{
if (IsRunned())
return S_FALSE;
StartWork(m_lThreadPriority);
return S_OK;
}
STDMETHOD(Stop)()
{
StopWork();
return S_OK;
}
STDMETHOD(Suspend)()
{
SuspendWork();
return S_OK;
}
STDMETHOD(Resume)()
{
ResumeWork();
return S_OK;
}
STDMETHOD(get_Status)(LONG* pStatus)
{
*pStatus = AVS_OFFICEEDITOR_STATUS_NONE;
if (m_bRunThread)
*pStatus = AVS_OFFICEEDITOR_STATUS_STARTED;
return S_OK;
}
STDMETHOD(get_Priority)(LONG* pPriority)
{
*pPriority = GetPriority();
return S_OK;
}
STDMETHOD(put_Priority)(LONG Priority)
{
m_lThreadPriority = Priority;
if (IsRunned())
{
::SetThreadPriority(m_hThread, m_lThreadPriority);
}
return S_OK;
}
STDMETHOD(SetAdditionalParam)(BSTR ParamName, VARIANT ParamValue)
{
CString sParamName; sParamName = ParamName;
if (g_csBlowfishKeyParamName == sParamName)
{
if (!m_oDecoder.SetBlowfishKey(ParamValue.punkVal))
return S_FALSE;
}
if (_T("OnCompletePage") == sParamName)
{
OnCompletePage();
}
return S_OK;
}
STDMETHOD(GetAdditionalParam)(BSTR ParamName, VARIANT* ParamValue)
{
return S_OK;
}
protected:
virtual DWORD ThreadProc()
{
if (!CRegistratorClient::IsRegistered())
return S_OK;
CoInitialize(NULL);
if (_T("") == m_strFoXml)
{
// .
size_t nCountPages = m_arPages.GetCount();
for (size_t nIndex = 0; nIndex < nCountPages; ++nIndex)
{
size_t nRendCount = m_arRenderers.GetCount();
//
//Suspend();
OnNewPage(m_arPages[nIndex].m_dWidthMetric, m_arPages[nIndex].m_dHeightMetric);
//
CheckSuspend();
for (size_t nRendIndex = 0; nRendIndex < nRendCount; ++nRendIndex)
{
if (NULL == m_arRenderers[nRendIndex])
continue;
m_arRenderers[nRendIndex]->NewPage();
m_arRenderers[nRendIndex]->put_Width(m_arPages[nIndex].m_dWidthMetric);
m_arRenderers[nRendIndex]->put_Height(m_arPages[nIndex].m_dHeightMetric);
}
for (size_t nRendIndex = 0; nRendIndex < nRendCount; ++nRendIndex)
{
if (NULL == m_arRenderers[nRendIndex])
continue;
double dDPIX = -1;
double dDPIY = -1;
if (NULL != m_arRenderers[nRendIndex])
{
VARIANT var;
var.vt = VT_R8;
var.dblVal = -1;
m_arRenderers[nRendIndex]->GetAdditionalParam(L"DPIX", &var);
dDPIX = var.dblVal;
var.dblVal = -1;
m_arRenderers[nRendIndex]->GetAdditionalParam(L"DPIY", &var);
dDPIY = var.dblVal;
}
m_arPages[nIndex].Render(m_arRenderers[nRendIndex], this, dDPIX, dDPIY);
}
//
//Suspend();
IWorker_OnCompletePage();
OnProgress(100 * (nIndex + 1) / nCountPages);
CheckSuspend();
}
}
else
{
// 1) convert to doct
Docx2::IAVSOfficeDocxFile2Ptr pDocx2;
pDocx2.CreateInstance(Docx2::CLSID_CAVSOfficeDocxFile2);
BSTR bsInput = m_strFoXml.AllocSysString();
CString strOutput = m_strFoXml + _T("\\Editor.bin");
BSTR bsOutput = strOutput.AllocSysString();
VARIANT varNoBase64;
varNoBase64.vt = VT_BOOL;
varNoBase64.boolVal = VARIANT_TRUE;
pDocx2->SetAdditionalParam(L"NoBase64Save", varNoBase64);
pDocx2->OpenFile(bsInput, bsOutput);
SysFreeString(bsInput);
SysFreeString(bsOutput);
// 2) open doct to documentrenderer
if (m_arRenderers.GetCount() > 0)
{
DoctRenderer::IDoctRendererPtr pDoct;
pDoct.CreateInstance(DoctRenderer::CLSID_CDoctRenderer);
IUnknown* pThis = NULL;
this->QueryInterface(IID_IUnknown, (void**)&pThis);
VARIANT var;
var.punkVal = pThis;
pDoct->SetAdditionalParam(L"Parent", var);
RELEASEINTERFACE(pThis);
IUnknown* punkRenderer = NULL;
m_arRenderers[0]->QueryInterface(IID_IUnknown, (void**)&punkRenderer);
BSTR bsFile = m_strFoXml.AllocSysString();
pDoct->OpenFile(bsFile, punkRenderer);
SysFreeString(bsFile);
RELEASEINTERFACE(punkRenderer);
}
/*
XmlUtils::CXmlNode oNodeFo;
if (oNodeFo.FromXmlString(m_strFoXml, _T("xmlns:fo='http://www.w3.org/1999/XSL/Format'")))
{
InternalFromXmlNode(oNodeFo);
for (size_t nIndex = 0; nIndex < m_arRenderers.GetCount(); ++nIndex)
{
BOOL bIsLastPage = FALSE;
do
{
if (!m_bRunThread)
break;
CheckSuspend();
bIsLastPage = DrawText(m_arRenderers[nIndex], 1.0);
}
while (!bIsLastPage);
}
}
*/
}
OnStop();
CoUninitialize();
m_bRunThread = FALSE;
return 0;
}
virtual void OnSendEvent(LONG lType, LONG lParam1, LONG lParam2)
{
switch (lType)
{
case OFFICEEDITOR_PROGRESS_TYPE_ERROR:
{
OnError(lParam1);
break;
}
case OFFICEEDITOR_PROGRESS_TYPE_STOP:
{
OnStop();
break;
}
case OFFICEEDITOR_PROGRESS_TYPE_PAGE:
{
OnProgress(lParam1);
break;
}
case OFFICEEDITOR_PROGRESS_TYPE_ELEMENT:
{
OnProgressParce(OFFICEEDITOR_PROGRESS_TYPE_ELEMENT, lParam1);
break;
}
default:
break;
};
}
// IWorker events
virtual void IWorker_OnNewPage(double dWidthMm, double dHeightMm)
{
//
//Suspend();
OnNewPage(dWidthMm, dHeightMm);
//
CheckSuspend();
if (0 < m_arRenderers[0])
{
SetRenderer(m_arRenderers[0]);
m_arRenderers[0]->NewPage();
m_arRenderers[0]->put_Width(dWidthMm);
m_arRenderers[0]->put_Height(dHeightMm);
}
else
{
SetRenderer(NULL);
}
}
virtual void IWorker_OnCompletePage()
{
//
//Suspend();
// -
if (0 < m_arRenderers.GetCount())
{
if (NULL != m_arRenderers[0])
{
m_arRenderers[0]->EndCommand(c_nPageType);
}
}
OnCompletePage();
//
CheckSuspend();
}
virtual void IWorker_OnProgress(double dCompleteness)
{
LONG lPercents = (LONG)(100 * dCompleteness);
OnProgress(lPercents);
}
private:
CString GetCStringFromUTF8( CStringA str )
{
BYTE* pBuffer = (BYTE*)str.GetBuffer();
LONG lLen = str.GetLength();
return GetCStringFromUTF8(pBuffer, lLen);
}
CString DeleteRootNode(CString& str)
{
int nStart = str.Find(_T("<?xml"));
int nEnd = str.Find(_T("?>"));
if (-1 == nStart)
return str;
return str.Mid(nEnd + 2);
}
CString GetCStringFromUTF8( BYTE* pBuffer, LONG lCount, BOOL bIsRemoveCode = TRUE )
{
if (bIsRemoveCode)
{
// ...
while (('>' != *pBuffer) && (lCount > 0))
{
++pBuffer;
--lCount;
}
++pBuffer;
--lCount;
}
LONG lLenght = 0;
TCHAR* pUnicodeString = new TCHAR[lCount + 1];
LONG lIndexUnicode = 0;
for (LONG lIndex = 0; lIndex < lCount; ++lIndex)
{
if (0x00 == (0x80 & pBuffer[lIndex]))
{
//strRes += (TCHAR)pBuffer[lIndex];
pUnicodeString[lIndexUnicode++] = (WCHAR)pBuffer[lIndex];
continue;
}
else if (0x00 == (0x20 & pBuffer[lIndex]))
{
TCHAR mem = (TCHAR)(((pBuffer[lIndex] & 0x1F) << 6) + (pBuffer[lIndex + 1] & 0x3F));
//strRes += mem;
pUnicodeString[lIndexUnicode++] = mem;
lIndex += 1;
}
else if (0x00 == (0x10 & pBuffer[lIndex]))
{
TCHAR mem = (TCHAR)(((pBuffer[lIndex] & 0x0F) << 12) + ((pBuffer[lIndex + 1] & 0x3F) << 6) + (pBuffer[lIndex + 2] & 0x3F));
//strRes += mem;
pUnicodeString[lIndexUnicode++] = mem;
lIndex += 2;
}
else
{
BYTE mem = pBuffer[lIndex];
//pUnicodeString[lIndexUnicode++] = mem;
}
}
pUnicodeString[lIndexUnicode] = 0;
CString strRes = (CString)pUnicodeString;
RELEASEARRAYOBJECTS(pUnicodeString);
return strRes;
}
};
\ No newline at end of file
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_NONSTDC_NO_DEPRECATE 1
#ifndef STRICT
#define STRICT
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0500 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 2000 or later.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#define _ATL_APARTMENT_THREADED
//#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off ATL's hiding of some common and often safely ignored warning messages
#define _ATL_ALL_WARNINGS
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
#include <atlcoll.h>
#include <atldefine.h>
#include "Gdiplus.h"
#pragma comment(lib, "gdiplus.lib")
// FreeType
#include <ft2build.h>
#include FT_FREETYPE_H
//#ifdef _VS_2005
#pragma comment (lib, "Objects\\Font\\FreeType\\freetype242_vs2005.lib")
//#pragma comment (lib, "Objects\\Font\\FreeType\\freetype242_vs2005.lib")
//#endif
//
//#ifdef _VS_2008
//#pragma comment (lib, "FreeType\\freetype2312.lib")
//#endif
//#define AVS_CXIMAGE_USE
#define CXIMAGE_SUPPORT_ALPHA
#ifdef AVS_CXIMAGE_USE
#pragma comment (lib, "Expat\\lib\\libexpat.lib")
#pragma comment (lib, "cximage\\zlib\\Release\\zlib.lib")
#pragma comment (lib, "cximage\\tiff\\Release\\Tiff.lib")
#pragma comment (lib, "cximage\\png\\Release\\png.lib")
#pragma comment (lib, "cximage\\mng\\Release\\mng.lib")
#pragma comment (lib, "cximage\\jpeg\\Release\\Jpeg.lib")
#pragma comment (lib, "cximage\\jbig\\Release\\jbig.lib")
#pragma comment (lib, "cximage\\jasper\\Release\\jasper.lib")
#pragma comment (lib, "cximage\\raw\\Release\\libdcr.lib")
#pragma comment (lib, "cximage\\CxImage\\Release\\cximage.lib")
#endif
#pragma comment (lib, "cximage\\zlib\\Release\\zlib.lib")
#ifdef _DEBUG
#pragma comment (lib, "Debug\\agg2d.lib")
#else
#pragma comment (lib, "Release\\agg2d.lib")
#endif
#define _AVS_GRAPHICS_
using namespace ATL;
#include "..\..\AVSVideoStudio3\Common\AVSUtils.h"
#import "..\..\..\Redist\AVSMediaCore3.dll" named_guids raw_interfaces_only rename_namespace("MediaCore"), exclude("tagRECT")
#import "..\..\..\Redist\AVSMediaFormatSettings3.dll" named_guids raw_interfaces_only rename_namespace("MediaFormat"), exclude("tagRECT")
#import "..\..\..\Redist\AVSImageStudio3.dll" named_guids raw_interfaces_only rename_namespace("ImageStudio")
#import "..\..\..\Redist\AVSOfficeStudio\AVSOfficeUniversalConverter.dll" named_guids raw_interfaces_only rename_namespace("DocConverter")
#import "..\..\TeamlabOffice\trunk\ServerComponents\Redist\ASCOfficeDocxFile2.dll" named_guids raw_interfaces_only rename_namespace("Docx2")
#import "..\..\TeamlabOffice\trunk\ServerComponents\Redist\DoctRenderer.dll" named_guids raw_interfaces_only rename_namespace("DoctRenderer")
/*! \file OfficeFOFile.cpp
* \brief Implementation of COfficeFOFile
*/
#include "precompiled_avsofficefofile.h"
#include <shlwapi.h>
#include "OfficeFOFile.h"
#include "utils/helpers.h"
#define MAX_PATH_LEN 256
#define XML_HEADER_STRING "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>"
#define PACKAGE_HEADER_STRING "<oox:package xmlns:oox=\"urn:oox\">"
#define PACKAGE_FOOTER_STRING "</oox:package>"
#define PART_HEADER_STRING "<oox:part oox:name=\"%s\">"
#define PART_HEADER_STRING_L "<oox:part oox:name=\""
#define PART_HEADER_STRING_R "\">"
#define PART_FOOTER_STRING "</oox:part>"
#define array_size( arr ) ( ( sizeof( arr ) ) / ( sizeof( arr[ 0 ] ) ) )
typedef enum
{
READER_MODE_INIT = 0,
READER_MODE_QUESTION_MARK,
READER_MODE_CONTENT
}
reader_mode;
static const char input_files[][MAX_PATH_LEN] = {
"_rels/.rels",
"word/_rels/document.xml.rels",
"word/settings.xml",
"word/fontTable.xml",
"word/styles.xml",
"word/numbering.xml",
"word/document.xml",
"docProps/app.xml",
"docProps/core.xml",
};
static const char additional_relationships [ ] [ MAX_PATH_LEN ] =
{
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" ,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"
};
static const char nodeAvsProperties[] = "AvsProperties";
static const char nodeAvsPropertiesOutputFOFileName[] = "OutputFOFileName";
static const char nodeAvsPropertiesTemploraryDir[] = "TemploraryDirectory";
// COfficeFOFile
COfficeFOFile::COfficeFOFile()
{
HRESULT hr;
if FAILED(hr = LoadXSLT()){
ATLTRACE2("Cannot load XSL-transform");
}
}
HRESULT COfficeFOFile::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXMLOptions)
{
return E_NOTIMPL;
}
HRESULT COfficeFOFile::MergeAndEncode(BSTR SrcPath, BSTR DestPath, std::wstring& Result)
{
HRESULT hr;
// XSL-
if (!CheckXSLTReady())
return E_FAIL;
// Docx
CHECK_HR(LoadDocx(SrcPath, AVS::Utils::ExtractFileName(std::wstring(DestPath))));
#ifdef _DEBUG
m_MergedDocx->save(CComVariant(_T("c:\\temp\\debug_merged_doc.xml")));
#endif
CHECK_HR(DoXSLTransformImpl(m_XSLDoc, m_MergedDocx, Result));
// -
//CHECK_HR(CopyMediaFilesFromDocx(sSrcPath, sDstFileName));
/*
DEPRECATE
xml,
*/
/* HECK_HR(ReplaceImagesPath(std::wstring(sDstFileName), outputXML)); */
return S_OK;
}
HRESULT COfficeFOFile::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR sXMLOptions)
{
std::wstring outputXML;
HRESULT hr = MergeAndEncode(sSrcPath, sDstFileName, outputXML);
if(hr != S_OK)
return hr;
std::string strOutputXml = AVS::Utils::WideStringToUTF8(outputXML);
CString strTempXml(strOutputXml.c_str());
CStringA strA = m_oEncoder.EncryptXML(strTempXml);
BSTR bstrA = strA.AllocSysString();
outputXML = std::wstring(bstrA);
SysFreeString(bstrA);
std::ofstream outputFile(std::wstring(sDstFileName).c_str());
outputFile << AVS::Utils::WideStringToUTF8(outputXML);
outputFile.close();
return S_OK;
}
HRESULT COfficeFOFile::GetFOXml(BSTR SrcFile, BSTR* FOXML)
{
CString strTempXml = (CString)SrcFile;
strTempXml = _T("TEAMLAB_DOCS") + strTempXml;
*FOXML = strTempXml.AllocSysString();
//CStringA strA = m_oEncoder.EncryptXML(strTempXml);
//*FOXML = strA.AllocSysString();
/*
BSTR l_bstrEmpty(L"");
std::wstring outputXML;
HRESULT hr = MergeAndEncode(SrcFile, l_bstrEmpty, outputXML);
if(hr != S_OK)
return hr;
//std::string strOutputXml = AVS::Utils::WideStringToUTF8(outputXML);
CString strTempXml(outputXML.c_str());
CStringA strA = m_oEncoder.EncryptXML(strTempXml);
*FOXML = strA.AllocSysString();
//outputXML = std::wstring(bstrA);
//SysFreeString(bstrA);
*/
return S_OK;
}
HRESULT COfficeFOFile::LoadXMLFromResource(BSTR * xmlStr, WORD resourceID, LPTSTR resourceType)
{
if (resourceID == IDR_HTML2)
{
#ifdef _DEBUG
std::string strXml;
LoadXMLFromResource(&strXml, resourceID, resourceType);
std::string xslStringWithoutBOM;
if ((unsigned char)strXml[0] == 0xEF
&& (unsigned char)strXml[1] == 0xBB
&& (unsigned char)strXml[2] == 0xBF)
xslStringWithoutBOM = &strXml[3];
else
xslStringWithoutBOM = strXml;
*xmlStr = ::SysAllocString(AVS::Utils::UTF8ToWideString(xslStringWithoutBOM).c_str());
#else
CString strXml = readFileFromRresource(IDR_REGISTRY1);
*xmlStr = strXml.AllocSysString();
#endif
}
return S_OK;
}
HRESULT COfficeFOFile::LoadXMLFromResource(std::string * xmlStr, WORD resourceID, LPTSTR resourceType)
{
if (!xmlStr)
return E_POINTER;
HINSTANCE hResInstance = ATL::_pModule->GetResourceInstance();
if (!hResInstance)
return E_FAIL;
HRSRC hRes = FindResource((HMODULE)hResInstance, MAKEINTRESOURCE(resourceID), resourceType);
if (!hRes)
return E_FAIL;
DWORD sizeofXML = SizeofResource((HMODULE) hResInstance, hRes);
HGLOBAL hData = LoadResource((HMODULE) hResInstance, hRes);
if (!hData)
return false;
LPVOID lpData = LockResource(hData);
if (!lpData)
return E_FAIL;
char * resourceXML = new char[sizeofXML + 1];
memset(reinterpret_cast<void*>(resourceXML), 0, sizeofXML+1);
memcpy_s(reinterpret_cast<void*>(resourceXML), sizeofXML + 1, lpData, sizeofXML);
*xmlStr = (char*)resourceXML;
free(resourceXML);
return S_OK;
}
HRESULT COfficeFOFile::LoadXSLT()
{
HRESULT hr;
m_xsltString = "";
m_XSLDoc.Release();
BSTR xslTempString;
CHECK_HR(LoadXMLFromResource(&xslTempString, IDR_HTML2, RT_HTML));
CComPtr<IXMLDOMDOCUMENT> pXSLDoc;
CHECK_HR(hr = CreateMSXMLDocument(&pXSLDoc, MS_XML_VERSION));
VARIANT_BOOL bSuccessful = VARIANT_FALSE;
hr = pXSLDoc->loadXML(xslTempString, &bSuccessful);
SysFreeString(xslTempString);
if (FAILED(hr) || bSuccessful == VARIANT_FALSE)
return hr;
m_XSLDoc.Attach(pXSLDoc.Detach());
return S_OK;
}
HRESULT COfficeFOFile::LoadDocx(BSTR bstrPath)
{
return LoadDocx(bstrPath, std::wstring(L""));
}
HRESULT COfficeFOFile::LoadDocx(BSTR bstrPath, std::wstring & foFileName)
{
HRESULT hr;
// ,
std::vector<std::wstring> relationshipsFiles;
CalcRels(bstrPath, relationshipsFiles);
std::string mergedDocx;
CHECK_HR(MergeDocxIntoSingleXML(bstrPath, mergedDocx, relationshipsFiles, foFileName));
CComPtr<IXMLDOMDOCUMENT> pMergedDocx;
CHECK_HR(CreateMSXMLDocument(&pMergedDocx, MS_XML_VERSION));
VARIANT_BOOL bSuccessful = VARIANT_FALSE;
pMergedDocx->put_validateOnParse(VARIANT_FALSE);
hr = pMergedDocx->loadXML(CComBSTR(AVS::Utils::UTF8ToWideString(mergedDocx).c_str()), &bSuccessful);
if (S_FALSE == hr)
return E_FAIL;
if (FAILED(hr) || bSuccessful == VARIANT_FALSE)
return hr;
m_MergedDocx.Attach(pMergedDocx.Detach());
return S_OK;
}
HRESULT COfficeFOFile::DoXSLTransformImpl(IXMLDOMDOCUMENT * xslt, IXMLDOMDOCUMENT * xml, std::wstring & resultXML)
{
HRESULT hr;
IXMLDOMElement * xslRootElm = NULL;
hr = xslt->get_documentElement(&xslRootElm);
BSTR bsResultXML = NULL;
if (S_OK != (hr = xml->transformNode(xslRootElm, &bsResultXML)))
return hr;
resultXML = std::wstring(bsResultXML);
SysFreeString(bsResultXML);
return S_OK;
}
HRESULT COfficeFOFile::MergeDocxIntoSingleXMLImpl1(BSTR bstrPath, std::string & mergedDocx, const std::vector<std::wstring> & additionalFiles)
{
return MergeDocxIntoSingleXMLImpl1(bstrPath, mergedDocx, additionalFiles, std::wstring(L""));
}
// DEPRECATE
// from AVSOfficeHtmpFile
HRESULT COfficeFOFile::MergeDocxIntoSingleXMLImpl1(BSTR bstrPath, std::string & mergedDocx, const std::vector<std::wstring> & additionalFiles, std::wstring & outputFOFileName)
{
/*
, XML-
*/
if (!bstrPath)
return E_INVALIDARG;
std::wstring input_dir = bstrPath;
std::stringstream outputString;
char buff [ 512 ] = { 0 };
wchar_t wbuff [ MAX_PATH_LEN ] = { 0 };
size_t len = 0;
outputString << XML_HEADER_STRING;
outputString << PACKAGE_HEADER_STRING;
std::vector<std::string> inputFilesArray;
for (UINT i = 0; i < array_size( input_files ); ++i)
inputFilesArray.push_back(input_files[i]);
for (UINT i = 0; i < additionalFiles.size(); ++i)
inputFilesArray.push_back(AVS::Utils::WideStringToANSI(additionalFiles[i]));
for (UINT i = 0; i < inputFilesArray.size(); ++i)
{
FILE * tmp = NULL;
wchar_t tmp_path [ MAX_PATH_LEN * 2 ] = { 0 };
reader_mode mode = READER_MODE_INIT;
swprintf_s(tmp_path, MAX_PATH_LEN * 2, L"%s/%s", input_dir.c_str(), AVS::Utils::ANSIToWideString(inputFilesArray[ i ]).c_str() );
_wfopen_s(&tmp, tmp_path, L"r+" );
if ( tmp )
{
outputString << PART_HEADER_STRING_L << inputFilesArray[ i ] << PART_HEADER_STRING_R;
while ( !feof( tmp ) )
{
char c = fgetc( tmp );
switch ( mode )
{
case READER_MODE_INIT:
if ( c == '?' )
{
mode = READER_MODE_QUESTION_MARK;
}
break;
case READER_MODE_QUESTION_MARK:
mode = ( c == '>' ) ? READER_MODE_CONTENT : READER_MODE_INIT;
break;
case READER_MODE_CONTENT:
outputString << c;
break;
default:
break;
}
}
outputString << PART_FOOTER_STRING;
fclose( tmp );
}
else
continue;
}
if (outputFOFileName != L"")
{
outputString << PART_HEADER_STRING_L << nodeAvsProperties << PART_HEADER_STRING_R;
outputString << "<" << "oox:" << nodeAvsProperties << ">";
outputString << "<" << "oox:" << nodeAvsPropertiesOutputFOFileName << " value=\"" << AVS::Utils::WideStringToUTF8(outputFOFileName) << "\"/>";
outputString << "</" << "oox:" << nodeAvsProperties << ">";
outputString << PART_FOOTER_STRING;
outputString << PACKAGE_FOOTER_STRING ;
}
mergedDocx = outputString.str();
std::ofstream outputFile(L"e:/01.xml");
outputFile << mergedDocx;
outputFile.close();
return S_OK;
}
/*! Merge XML xmllite-
*/
HRESULT COfficeFOFile::MergeDocxIntoSingleXMLImpl2(BSTR bstrPath, std::string & mergedDocx, const std::vector<std::wstring> & additionalFiles)
{
return MergeDocxIntoSingleXMLImpl2(bstrPath, mergedDocx, additionalFiles, std::wstring(L""));
}
/*! Merge XML xmllite-
*/
HRESULT COfficeFOFile::MergeDocxIntoSingleXMLImpl2(BSTR bstrPath, std::string & mergedDocx, const std::vector<std::wstring> & additionalFiles, std::wstring & outputFOFileName)
{
HRESULT hr;
CComPtr<IXmlWriter> pWriter;
CComPtr<IStream> pOutFileStream;
CHECK_HR(AVS::StringStreamImpl::CreateStream(&pOutFileStream));
CHECK_HR(CreateXmlWriter(__uuidof(IXmlWriter), (void**)&pWriter, NULL));
if (!pOutFileStream)
return E_FAIL;
CHECK_HR(pWriter->SetOutput(pOutFileStream));
CHECK_HR(pWriter->WriteStartDocument(XmlStandalone_Yes));
wchar_t * oox_ns = L"oox";
wchar_t * oox_uri = L"urn:oox";
CHECK_HR(pWriter->WriteStartElement(oox_ns, L"package", oox_uri));
std::vector<std::string> inputFilesArray;
for (UINT i = 0; i < array_size( input_files ); ++i)
inputFilesArray.push_back(input_files[i]);
for (UINT i = 0; i < additionalFiles.size(); ++i)
inputFilesArray.push_back(AVS::Utils::WideStringToANSI(additionalFiles[i]));
std::wstring input_dir = bstrPath;
for (UINT i = 0; i < inputFilesArray.size(); ++i)
{
std::wstring tmp_path;
tmp_path = input_dir + L"/" + AVS::Utils::ANSIToWideString(inputFilesArray[i]);
CComPtr<IStream> pFileStream;
CComPtr<IXmlReader> pReader;
if (FAILED(hr = SHCreateStreamOnFileW(tmp_path.c_str(), STGM_READ, &pFileStream)) || !pFileStream)
continue;
CHECK_HR(CreateXmlReader(__uuidof(IXmlReader), (void**) &pReader, NULL));
CHECK_HR(pReader->SetInput(pFileStream));
CHECK_HR(pWriter->WriteStartElement(oox_ns, L"part", oox_uri));
CHECK_HR(pWriter->WriteAttributeString(oox_ns, L"name", oox_uri, AVS::Utils::ANSIToWideString(inputFilesArray[i]).c_str()));
CHECK_HR(pWriter->WriteNode(pReader, true));
CHECK_HR(pWriter->WriteFullEndElement());
}
CHECK_HR(pWriter->WriteStartElement(oox_ns, L"part", oox_uri));
CHECK_HR(pWriter->WriteAttributeString(oox_ns, L"name", oox_uri, AVS::Utils::ANSIToWideString(nodeAvsProperties).c_str() ));
CHECK_HR(pWriter->WriteStartElement(oox_ns, AVS::Utils::ANSIToWideString(nodeAvsProperties).c_str(), oox_uri));
if (outputFOFileName != L"")
{
CHECK_HR(pWriter->WriteStartElement(oox_ns, AVS::Utils::ANSIToWideString(nodeAvsPropertiesOutputFOFileName).c_str(), oox_uri));
CHECK_HR(pWriter->WriteAttributeString(NULL, L"value", NULL, outputFOFileName.c_str() ));
CHECK_HR(pWriter->WriteEndElement());
}
CHECK_HR(pWriter->WriteStartElement(oox_ns, AVS::Utils::ANSIToWideString(nodeAvsPropertiesTemploraryDir).c_str(), oox_uri));
CHECK_HR(pWriter->WriteAttributeString(NULL, L"value", NULL, input_dir.c_str() ));
CHECK_HR(pWriter->WriteEndElement());
CHECK_HR(pWriter->WriteEndElement());
CHECK_HR(pWriter->WriteEndElement());
CHECK_HR(pWriter->WriteEndElement());
CHECK_HR(pWriter->WriteEndDocument());
CHECK_HR(pWriter->Flush());
CComPtr<AVS::IStringStream> pStringStream;
CHECK_HR(pOutFileStream.QueryInterface(&pStringStream));
CHECK_HR(pStringStream->GetString(&mergedDocx));
return S_OK;
}
HRESULT COfficeFOFile::MergeDocxIntoSingleXML(BSTR bstrPath, std::string & mergedDocx, const std::vector<std::wstring> & additionalFiles)
{
return COfficeFOFile::MergeDocxIntoSingleXML(bstrPath, mergedDocx, additionalFiles, std::wstring(L""));
}
HRESULT COfficeFOFile::MergeDocxIntoSingleXML(BSTR bstrPath, std::string & mergedDocx, const std::vector<std::wstring> & additionalFiles, std::wstring & outputFOFileName)
{
HRESULT hr;
if SUCCEEDED(hr = MergeDocxIntoSingleXMLImpl2(bstrPath, mergedDocx, additionalFiles, outputFOFileName))
return hr;
// xmllite ( ?)
return MergeDocxIntoSingleXMLImpl1(bstrPath, mergedDocx, additionalFiles, outputFOFileName);
}
bool COfficeFOFile::CheckXSLTReady() const
{
return (!!m_XSLDoc);
}
HRESULT COfficeFOFile::FinalConstruct()
{
return S_OK;
}
void COfficeFOFile::FinalRelease()
{
}
HRESULT COfficeFOFile::CreateMSXMLDocument(IXMLDOMDOCUMENT ** ixmlDomDocument, long version)
{
HRESULT hr;
CComPtr<IXMLDOMDOCUMENT> xmlDomDocument;
switch(version)
{
case 6:
if FAILED(hr = xmlDomDocument.CoCreateInstance(__uuidof(DOMDocument60)))
{
// MSXML
return CreateMSXMLDocument(ixmlDomDocument, 4);
}
else
{
*ixmlDomDocument = xmlDomDocument.Detach();
return hr;
}
case 4:
CHECK_HR(xmlDomDocument.CoCreateInstance(__uuidof(DOMDocument40)));
*ixmlDomDocument = xmlDomDocument.Detach();
return hr;
default:
return E_INVALIDARG;
}
}
HRESULT COfficeFOFile::CopyMediaFilesFromDocx(BSTR bstrOOXPath, BSTR bstrFOPath)
{
std::wstring outputDirName = std::wstring(bstrFOPath) + L".files";
std::wstring inputDirMask = std::wstring(bstrOOXPath) + L"/word/media/*.*";
WIN32_FIND_DATAW FindFileData = { 0 };
HANDLE hCopy = FindFirstFileW(inputDirMask.c_str(), &FindFileData );
BOOL findReslut = (INVALID_HANDLE_VALUE != hCopy);
if (findReslut)
{
if (!CreateDirectoryW(outputDirName.c_str(), NULL))
{
DWORD lastError = GetLastError();
if (ERROR_ALREADY_EXISTS != lastError)
return E_FAIL;
}
}
while (findReslut)
{
std::wstring file_from = std::wstring(bstrOOXPath) + L"/word/media/" + std::wstring(FindFileData.cFileName);
std::wstring file_to = outputDirName + L"/" + std::wstring(FindFileData.cFileName);
CopyFileW(file_from.c_str(), file_to.c_str(), FALSE );
findReslut = FindNextFileW( hCopy, &FindFileData );
}
return S_OK;
}
/*
\deprecate xslt-
*/
HRESULT COfficeFOFile::ReplaceImagesPath(const std::wstring & stringFOPath, std::wstring &foXML)
{
//std::wstring imagePath = std::wstring(L".\\") + AVS::Utils::ExtractFileName(stringFOPath) + L".files";
//boost::algorithm::replace_all(foXML, L"avsooximagesource:media", imagePath);
return S_OK;
}
HRESULT COfficeFOFile::CalcRels(BSTR bstrPath, std::vector<std::wstring> & relationshipsFiles, const std::string & relsName)
{
HRESULT hr;
std::wstring input_dir = bstrPath;
CComPtr<IXMLDOMDOCUMENT> pXMLDoc;
CHECK_HR(CreateMSXMLDocument(&pXMLDoc, MS_XML_VERSION));
input_dir += std::wstring(L"\\word\\_rels\\") + AVS::Utils::ANSIToWideString(relsName) + std::wstring(L".xml.rels");
VARIANT_BOOL isSuccessful = VARIANT_FALSE;
CHECK_HR(pXMLDoc->load(CComVariant(input_dir.c_str()), &isSuccessful));
if (isSuccessful != VARIANT_TRUE)
return S_OK;
std::vector<std::wstring> reslutVector;
for (int i = 0; i < array_size(additional_relationships); ++i)
GetRelationshipValues(pXMLDoc, additional_relationships[i], reslutVector);
relationshipsFiles = reslutVector;
return S_OK;
}
HRESULT COfficeFOFile::GetRelationshipValues(CComPtr<IXMLDOMDOCUMENT> & xmlDoc, const std::string & relType, std::vector<std::wstring> & relTarget)
{
HRESULT hr;
std::vector<std::wstring> resultVector;
std::string queryString = std::string("//*[@Type='") + relType + std::string("']/@Target");
CComPtr<IXMLDOMNodeList> pNodeList;
CHECK_HR(xmlDoc->selectNodes(CComBSTR(queryString.c_str()), &pNodeList));
if (!pNodeList)
return E_UNEXPECTED;
long nodeListLength = 0;
CHECK_HR(pNodeList->get_length(&nodeListLength));
if (0 == nodeListLength)
{
ATLTRACE2("Warning: rels for type %s not found\n", relType.c_str());
return S_OK;
}
for (int nodeIndex = 0; nodeIndex < nodeListLength; ++nodeIndex)
{
CComPtr<IXMLDOMNode> pCurrentNode;
if FAILED(pNodeList->get_item(nodeIndex, &pCurrentNode))
{
ATLTRACE2("Warning: cannot get item from node list\n");
continue;
}
CComVariant pNodeValue;
if FAILED(pCurrentNode->get_nodeValue(&pNodeValue))
{
ATLTRACE2("Warning: cannot get node value\n");
continue;
}
if (VT_BSTR == pNodeValue.vt)
{
relTarget.push_back(std::wstring(L"word/") + std::wstring(pNodeValue.bstrVal));
relTarget.push_back(std::wstring(L"word/_rels/") + std::wstring(pNodeValue.bstrVal) + std::wstring(L".rels"));
}else
{
ATLTRACE2("Warning: unknown attribute type");
}
}
return S_OK;
}
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef STRICT
#define STRICT
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0500 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0500 // Change this to the appropriate value to target Windows 2000 or later.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0510 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0501 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off ATL's hiding of some common and often safely ignored warning messages
#define _ATL_ALL_WARNINGS
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include "utils\stringutils.h"
//#include <boost/algorithm/string.hpp>
#include "config.h"
#include "xmllite.h"
#pragma comment(lib,"xmllite.lib")
#if (MS_XML_VERSION == 6)
#include "msxml6.h"
#define DOMDOCUMENT DOMDocument60
#define IXMLDOMDOCUMENT IXMLDOMDocument3
#elif (MS_XML_VERSION == 4)
#include "msxml2.h"
#define DOMDOCUMENT DOMDocument40
#define IXMLDOMDOCUMENT IXMLDOMDocument2
#else
#error Invalid MS_XML_VERSION
#endif
#define CHECK_HR(HR) if FAILED(hr = (HR)) return hr;
#import "..\..\..\Redist\AVSMediaCore3.dll" named_guids raw_interfaces_only rename_namespace("MediaCore"), exclude("tagRECT")
using namespace ATL;
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Joiner</RootNamespace>
<AssemblyName>Joiner</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Joiner", "Joiner.csproj", "{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Joiner
{
class Program
{
static void Main(string[] args)
{
string strApplication = Directory.GetCurrentDirectory();
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
string strRoot = strApplication + "\\OfficeWeb\\";
List<string> files = new List<string>();
string[] arrFilesConfig = {
"Common/3rdparty/jquery/jquery.min.js",
"Common/3rdparty/Underscore/underscore-min.js",
"Common/3rdparty/Sockjs/sockjs-0.3.min.js",
"Common/3rdparty/XRegExp/xregexp-all-min.js",
"Common/3rdparty/jszip/jszip.min.js",
"Common/3rdparty/jszip-utils/jszip-utils.min.js",
"Common/AllFonts.js",
"Common/Build/License.js",
"Common/browser.js",
"Common/docscoapicommon.js",
"Common/docscoapi.js",
"Common/apiCommon.js",
"Common/spellcheckapi.js",
"Common/wordcopypaste.js",
"Common/spellCheckLanguage.js",
"Common/spellCheckLanguagesAll.js",
"Common/downloaderfiles.js",
"Common/commonDefines.js",
"Common/editorscommon.js",
"Common/Shapes/Serialize.js",
"Common/Shapes/SerializeWriter.js",
"Common/SerializeCommonWordExcel.js",
"Common/SerializeChart.js",
"Common/Drawings/Format/Constants.js",
"Common/Drawings/Format/Format.js",
"Common/trackFile.js",
"Common/FontsFreeType/font_engine.js",
"Common/FontsFreeType/FontFile.js",
"Common/FontsFreeType/FontManager.js",
"Common/FontsFreeType/font_map.js",
"Word/Drawing/Externals.js",
"Word/Drawing/GlobalLoaders.js",
"Word/Drawing/translations.js",
"Common/Charts/charts.js",
"Common/Charts/ChartsDrawer.js",
"Common/Charts/DrawingArea.js",
"Common/Charts/DrawingObjects.js",
"Common/NumFormat.js",
"Common/Drawings/TrackObjects/AdjustmentTracks.js",
"Common/Drawings/TrackObjects/MoveTracks.js",
"Common/Drawings/TrackObjects/NewShapeTracks.js",
"Common/Drawings/TrackObjects/PolyLine.js",
"Common/Drawings/TrackObjects/ResizeTracks.js",
"Common/Drawings/TrackObjects/RotateTracks.js",
"Common/Drawings/TrackObjects/Spline.js",
"Common/Drawings/ArcTo.js",
"Common/Drawings/ColorArray.js",
"Common/Drawings/CommonController.js",
"Common/Drawings/DrawingObjectsHandlers.js",
"Common/Drawings/Hit.js",
"Common/Drawings/Joined.js",
"Common/Drawings/Math.js",
"Common/Drawings/Format/Shape.js",
"Common/Drawings/Format/Image.js",
"Common/Drawings/Format/GroupShape.js",
"Common/Drawings/Format/ChartSpace.js",
"Common/Drawings/Format/ChartFormat.js",
"Common/Drawings/Format/CreateGeometry.js",
"Common/Drawings/Format/Geometry.js",
"Common/Drawings/Format/Path.js",
"Common/Drawings/Format/TextBody.js",
"Common/Drawings/TextDrawer.js",
"Word/Editor/GraphicObjects/Format/ShapePrototype.js",
"Word/Editor/GraphicObjects/Format/ImagePrototype.js",
"Word/Editor/GraphicObjects/Format/GroupPrototype.js",
"Word/Editor/GraphicObjects/Format/ChartSpacePrototype.js",
"PowerPoint/Editor/Format/GraphicFrame.js",
"Word/Editor/GraphicObjects/DrawingStates.js",
"Word/Editor/GraphicObjects/GraphicObjects.js",
"Word/Editor/GraphicObjects/GraphicPage.js",
"Word/Editor/GraphicObjects/WrapManager.js",
"Word/Editor/CollaborativeEditing.js",
"Word/Editor/Comments.js",
"Word/Editor/History.js",
"Word/Editor/Styles.js",
"Word/Editor/FlowObjects.js",
"Word/Editor/ParagraphContent.js",
"Word/Editor/ParagraphContentBase.js",
"Word/Editor/Hyperlink.js",
"Word/Editor/Field.js",
"Word/Editor/Run.js",
"Word/Editor/Math.js",
"Word/Editor/Paragraph.js",
"Word/Editor/Paragraph_Recalculate.js",
"Word/Editor/Sections.js",
"Word/Editor/Numbering.js",
"Word/Editor/HeaderFooter.js",
"Word/Editor/Document.js",
"Word/Editor/Common.js",
"Word/Editor/DocumentContent.js",
"Word/Editor/Table.js",
"Word/Editor/Serialize2.js",
"Word/Editor/Search.js",
"Word/Editor/FontClassification.js",
"Word/Editor/Spelling.js",
"Word/Drawing/Graphics.js",
"Word/Drawing/Overlay.js",
"Word/Drawing/HatchPattern.js",
"Word/Drawing/ShapeDrawer.js",
"Word/Drawing/Metafile.js",
"Word/Drawing/DrawingDocument.js",
"Word/Drawing/GraphicsEvents.js",
"Common/Scrolls/iscroll.js",
"Word/Drawing/WorkEvents.js",
"Common/Controls.js",
"Word/Drawing/Rulers.js",
"Word/Drawing/HtmlPage.js",
"Word/Drawing/documentrenderer.js",
"Common/scroll.js",
"Word/Editor/SerializeCommon.js",
"Word/apiDefines.js",
"Word/document/empty.js",
"Word/Math/mathTypes.js",
"Word/Math/mathText.js",
"Word/Math/mathContent.js",
"Word/Math/base.js",
"Word/Math/fraction.js",
"Word/Math/degree.js",
"Word/Math/matrix.js",
"Word/Math/limit.js",
"Word/Math/nary.js",
"Word/Math/radical.js",
"Word/Math/operators.js",
"Word/Math/accent.js",
"Word/Math/borderBox.js",
"Excel/utils/utils.js",
"Excel/model/CellComment.js",
"Excel/model/Serialize.js",
"Excel/model/WorkbookElems.js",
"Excel/model/Workbook.js",
"Excel/model/CellInfo.js",
"Excel/model/AdvancedOptions.js",
"Common/Locks.js",
"Common/Shapes/EditorSettings.js",
"Word/apiCommon.js",
"Word/api.js"
};
if (true)
{
files.Clear();
for (int i = 0; i < arrFilesConfig.Length; ++i)
{
files.Add(arrFilesConfig[i]);
}
}
StringBuilder oBuilder = new StringBuilder();
for (int i = 0; i < files.Count; i++)
{
StreamReader oReader = new StreamReader(strRoot + files[i]);
oBuilder.Append(oReader.ReadToEnd());
oBuilder.Append("\n\n");
}
string strDestPath = strApplication + "\\OfficeWeb\\Word\\sdk-all.js";
StreamWriter oWriter = new StreamWriter(strDestPath, false, Encoding.UTF8);
oWriter.Write(oBuilder.ToString());
oWriter.Close();
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Joiner")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Ascensio System SIA")]
[assembly: AssemblyProduct("Joiner")]
[assembly: AssemblyCopyright("Ascensio System SIA Copyright (c) 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0e989b01-1ac4-4bc9-8346-c19b89b47389")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Joiner</RootNamespace>
<AssemblyName>Joiner</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Joiner", "Joiner.csproj", "{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Joiner
{
class Program
{
static void Main(string[] args)
{
string strApplication = Directory.GetCurrentDirectory();
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
string strRoot = strApplication + "\\OfficeWeb\\";
List<string> files = new List<string>();
string[] arrFilesConfig = {
"Common/Build/License.js",
"Common/browser.js",
"Common/FontsFreeType/font_engine.js",
"Common/FontsFreeType/FontFile.js",
"Common/FontsFreeType/FontManager.js",
"Common/FontsFreeType/font_map.js",
"Word/Drawing/Externals.js",
"Word/Drawing/GlobalLoaders.js",
"Common/commonDefines.js",
"Common/apiCommon.js",
"Common/downloaderfiles.js",
"Common/docscoapicommon.js",
"Common/docscoapi.js",
"Common/docscoapisettings.js",
"Common/wordcopypaste.js",
"Common/editorscommon.js",
"PowerPoint/Drawing/ThemeLoader.js",
"Common/Charts/DrawingObjects.js",
"Common/SerializeCommonWordExcel.js",
"Common/SerializeChart.js",
"Common/Charts/charts.js",
"Common/Charts/ChartsDrawer.js",
"Common/Charts/DrawingArea.js",
"Common/NumFormat.js",
"Word/Editor/Serialize2.js",
"Common/trackFile.js",
"Word/Editor/Styles.js",
"Word/Editor/Numbering.js",
"Word/Drawing/Metafile.js",
"PowerPoint/Editor/CollaborativeEditing.js",
"Word/Drawing/GraphicsEvents.js",
"Word/Drawing/WorkEvents.js",
"Word/Drawing/Controls.js",
"Word/Drawing/Rulers.js",
"Word/Editor/Table.js",
"Word/Editor/Common.js",
"Word/Editor/Sections.js",
"Common/scroll.js",
"Word/Editor/History.js",
"Common/Drawings/Hit.js",
"Common/Drawings/States.js",
"Common/Drawings/DrawingObjectsHandlers.js",
"Common/Drawings/TrackObjects/AdjustmentTracks.js",
"Common/Drawings/TrackObjects/ResizeTracks.js",
"Common/Drawings/TrackObjects/RotateTracks.js",
"Common/Drawings/TrackObjects/NewShapeTracks.js",
"Common/Drawings/TrackObjects/PolyLine.js",
"Common/Drawings/TrackObjects/Spline.js",
"Common/Drawings/TrackObjects/MoveTracks.js",
"Word/Drawing/HatchPattern.js",
"Word/Drawing/Graphics.js",
"Word/Drawing/Private/Graphics.js",
"Word/Drawing/Overlay.js",
"Word/Drawing/ShapeDrawer.js",
"PowerPoint/Drawing/Transitions.js",
"PowerPoint/Drawing/DrawingDocument.js",
"PowerPoint/Drawing/HtmlPage.js",
"PowerPoint/apiDefines.js",
"Common/Drawings/Format/Constants.js",
"Common/Shapes/Serialize.js",
"Common/Shapes/SerializeWriter.js",
"Word/Editor/SerializeCommon.js",
"Common/Drawings/Math.js",
"Common/Drawings/ArcTo.js",
"Word/Drawing/ColorArray.js",
"PowerPoint/Editor/Format/Presentation.js",
"Common/Drawings/CommonController.js",
"Excel/view/DrawingObjectsController.js",
"PowerPoint/Editor/DrawingObjectsController.js",
"Common/Drawings/Format/Format.js",
"Common/Drawings/Format/CreateGeometry.js",
"Common/Drawings/Format/Geometry.js",
"Common/Drawings/Format/Path.js",
"Common/Drawings/Format/Shape.js",
"Common/Drawings/Format/Image.js",
"Common/Drawings/Format/GroupShape.js",
"Common/Drawings/Format/ChartSpace.js",
"Common/Drawings/Format/ChartFormat.js",
"Common/Drawings/Format/TextBody.js",
"PowerPoint/Editor/Format/Slide.js",
"PowerPoint/Editor/Format/SlideMaster.js",
"PowerPoint/Editor/Format/Layout.js",
"PowerPoint/Editor/Format/Comments.js",
"Word/Editor/Styles.js",
"Word/Editor/Numbering.js",
"Word/Editor/ParagraphContent.js",
"Word/Editor/ParagraphContentBase.js",
"Word/Editor/Hyperlink.js",
"Word/Editor/Field.js",
"Word/Editor/Run.js",
"Word/Math/mathTypes.js",
"Word/Math/mathText.js",
"Word/Math/mathContent.js",
"Word/Math/base.js",
"Word/Math/fraction.js",
"Word/Math/degree.js",
"Word/Math/matrix.js",
"Word/Math/limit.js",
"Word/Math/nary.js",
"Word/Math/radical.js",
"Word/Math/operators.js",
"Word/Math/accent.js",
"Word/Math/borderBox.js",
"Word/Editor/FlowObjects.js",
"Word/Editor/Paragraph.js",
"Word/Editor/Paragraph_Recalculate.js",
"Word/Editor/Document.js",
"Word/Editor/DocumentContent.js",
"Word/Editor/HeaderFooter.js",
"Word/Editor/Table.js",
"Word/Editor/Math.js",
"Word/Editor/Spelling.js",
"Word/Editor/Search.js",
"Word/Editor/FontClassification.js",
"PowerPoint/Editor/Format/ShapePrototype.js",
"PowerPoint/Editor/Format/ImagePrototype.js",
"PowerPoint/Editor/Format/GroupPrototype.js",
"PowerPoint/Editor/Format/ChartSpacePrototype.js",
"PowerPoint/Editor/Format/GraphicFrame.js",
"Excel/utils/utils.js",
"Excel/model/Serialize.js",
"Excel/model/WorkbookElems.js",
"Excel/model/Workbook.js",
"Excel/model/CellInfo.js",
"Excel/model/AdvancedOptions.js",
"Common/Private/Locks.js",
"Common/Shapes/EditorSettings.js",
"PowerPoint/themes/Themes.js",
"PowerPoint/apiDefines.js",
"Common/commonDefines.js",
"PowerPoint/api.js",
"PowerPoint/apiCommon.js"
};
if (true)
{
files.Clear();
for (int i = 0; i < arrFilesConfig.Length; ++i)
{
files.Add(arrFilesConfig[i]);
}
}
StringBuilder oBuilder = new StringBuilder();
for (int i = 0; i < files.Count; i++)
{
StreamReader oReader = new StreamReader(strRoot + files[i]);
oBuilder.Append(oReader.ReadToEnd());
oBuilder.Append("\n\n");
}
string strDestPath = strApplication + "\\OfficeWeb\\PowerPoint\\sdk-all.js";
StreamWriter oWriter = new StreamWriter(strDestPath, false, Encoding.UTF8);
oWriter.Write(oBuilder.ToString());
oWriter.Close();
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Joiner")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Ascensio System SIA")]
[assembly: AssemblyProduct("Joiner")]
[assembly: AssemblyCopyright("Ascensio System SIA Copyright (c) 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0e989b01-1ac4-4bc9-8346-c19b89b47389")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Joiner</RootNamespace>
<AssemblyName>Joiner</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Joiner", "Joiner.csproj", "{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44F7AE26-3218-4A27-BEF7-0FC1B2AE9CB7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Joiner
{
class Program
{
static void Main(string[] args)
{
string strApplication = Directory.GetCurrentDirectory();
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
strApplication = Path.GetDirectoryName(strApplication);
string strRoot = strApplication + "\\OfficeWeb\\";
List<string> files = new List<string>();
/*
string[] arrFilesConfig = {
"Common/Build/License.js",
"Common/browser.js",
"Common/docscoapisettings.js",
"Common/docscoapicommon.js",
"Common/docscoapi.js",
"Common/downloaderfiles.js",
"Common/apiCommon.js",
"Common/commonDefines.js",
"Common/editorscommon.js",
"Common/NumFormat.js",
"Common/Charts/charts.js",
"Common/Charts/DrawingArea.js",
"Common/Charts/DrawingObjects.js",
"Common/Charts/ChartsDrawer.js",
"Common/FontsFreeType/font_engine.js",
"Common/FontsFreeType/FontFile.js",
"Common/FontsFreeType/FontManager.js",
"Word/Drawing/HatchPattern.js",
"Word/Drawing/Externals.js",
"Word/Drawing/Metafile.js",
"Excel/model/DrawingObjects/GlobalLoaders.js",
"Common/trackFile.js",
"Excel/apiDefines.js",
"Excel/document/empty-workbook.js",
"Excel/utils/utils.js",
"Excel/model/clipboard.js",
"Excel/model/autofilters.js",
"Excel/graphics/DrawingContext.js",
"Excel/graphics/pdfprinter.js",
"Excel/model/CollaborativeEditing.js",
"Excel/model/ConditionalFormatting.js",
"Excel/model/FormulaObjects/parserFormula.js",
"Excel/model/FormulaObjects/dateandtimeFunctions.js",
"Excel/model/FormulaObjects/engineeringFunctions.js",
"Excel/model/FormulaObjects/cubeFunctions.js",
"Excel/model/FormulaObjects/databaseFunctions.js",
"Excel/model/FormulaObjects/textanddataFunctions.js",
"Excel/model/FormulaObjects/statisticalFunctions.js",
"Excel/model/FormulaObjects/financialFunctions.js",
"Excel/model/FormulaObjects/mathematicFunctions.js",
"Excel/model/FormulaObjects/lookupandreferenceFunctions.js",
"Excel/model/FormulaObjects/informationFunctions.js",
"Excel/model/FormulaObjects/logicalFunctions.js",
"Excel/model/Serialize.js",
"Excel/model/WorkbookElems.js",
"Excel/model/Workbook.js",
"Excel/model/CellInfo.js",
"Excel/model/AdvancedOptions.js",
"Excel/model/History.js",
"Excel/model/UndoRedo.js",
"Excel/model/CellComment.js",
"Excel/view/mobileTouch.js",
"Excel/view/iscroll.js",
"Excel/view/PopUpSelector.js",
"Excel/view/StringRender.js",
"Excel/view/CellTextRender.js",
"Excel/view/CellEditorView.js",
"Excel/view/WorksheetView.js",
"Excel/view/HandlerList.js",
"Excel/view/EventsController.js",
"Excel/view/WorkbookView.js",
"Common/scroll.js",
"Word/Editor/SerializeCommon.js",
"Common/Drawings/Math.js",
"Common/Drawings/ArcTo.js",
"Word/Drawing/ColorArray.js",
"Common/Shapes/Serialize.js",
"Common/Shapes/SerializeWriter.js",
"Common/SerializeCommonWordExcel.js",
"Common/SerializeChart.js",
"Common/Charts/libraries/OfficeExcel.common.core.js",
"Common/Charts/libraries/OfficeExcel.common.key.js",
"Common/Charts/libraries/OfficeExcel.bar.js",
"Common/Charts/libraries/OfficeExcel.hbar.js",
"Common/Charts/libraries/OfficeExcel.line.js",
"Common/Charts/libraries/OfficeExcel.pie.js",
"Common/Charts/libraries/OfficeExcel.scatter.js",
"Common/Charts/libraries/OfficeExcel.chartProperties.js",
"Common/Drawings/Hit.js",
"Common/Drawings/States.js",
"Common/Drawings/TrackObjects/AdjustmentTracks.js",
"Common/Drawings/TrackObjects/ResizeTracks.js",
"Common/Drawings/TrackObjects/RotateTracks.js",
"Common/Drawings/TrackObjects/NewShapeTracks.js",
"Common/Drawings/TrackObjects/PolyLine.js",
"Common/Drawings/TrackObjects/Spline.js",
"Common/Drawings/TrackObjects/MoveTracks.js",
"Common/Drawings/Format/Constants.js",
"Common/Drawings/Format/Format.js",
"Common/Drawings/Format/CreateGeometry.js",
"Common/Drawings/Format/Geometry.js",
"Common/Drawings/Format/Path.js",
"Common/Drawings/Format/Shape.js",
"Common/Drawings/Format/GroupShape.js",
"Common/Drawings/Format/Image.js",
"Common/Drawings/Format/ChartSpace.js",
"Common/Drawings/Format/ChartFormat.js",
"Common/Drawings/Format/TextBody.js",
"Common/Drawings/CommonController.js",
"Excel/view/DrawingObjectsController.js",
"Excel/model/DrawingObjects/Graphics.js",
"Excel/model/DrawingObjects/Overlay.js",
"Excel/model/DrawingObjects/Controls.js",
"Excel/model/DrawingObjects/ShapeDrawer.js",
"Word/Editor/CollaborativeEditing.js",
"Excel/model/DrawingObjects/DrawingDocument.js",
"Excel/model/DrawingObjects/Format/ShapePrototype.js",
"Excel/model/DrawingObjects/Format/ImagePrototype.js",
"Excel/model/DrawingObjects/Format/GroupPrototype.js",
"Excel/model/DrawingObjects/Format/ChartSpacePrototype.js",
"Word/Math/mathTypes.js",
"Word/Math/mathText.js",
"Word/Math/mathContent.js",
"Word/Math/base.js",
"Word/Math/fraction.js",
"Word/Math/degree.js",
"Word/Math/matrix.js",
"Word/Math/limit.js",
"Word/Math/nary.js",
"Word/Math/radical.js",
"Word/Math/operators.js",
"Word/Math/accent.js",
"Word/Math/borderBox.js",
"Word/Editor/Comments.js",
"Word/Editor/Styles.js",
"Word/Editor/FlowObjects.js",
"Word/Editor/ParagraphContent.js",
"Word/Editor/Hyperlink.js",
"Word/Editor/Run.js",
"Word/Editor/Math.js",
"Word/Editor/Paragraph.js",
"Word/Editor/Sections.js",
"Word/Editor/Numbering.js",
"Word/Editor/HeaderFooter.js",
"Word/Editor/Document.js",
"Word/Editor/DocumentContent.js",
"Word/Editor/Table.js",
"Word/Editor/Serialize2.js",
"Word/Editor/FontClassification.js",
"Word/Editor/Spelling.js",
"Word/Math/mathTypes.js",
"Word/Math/print.js",
"Word/Math/mathText.js",
"Word/Math/mathContent.js",
"Word/Math/actions.js",
"Word/Math/base.js",
"Word/Math/subBase.js",
"Word/Math/fraction.js",
"Word/Math/degree.js",
"Word/Math/matrix.js",
"Word/Math/limit.js",
"Word/Math/nary.js",
"Word/Math/radical.js",
"Word/Math/operators.js",
"Word/Math/accent.js",
"Word/Math/drawingUnion.js",
"Word/Math/borderBox.js",
"Word/Math/test_composition.js",
"Excel/model/DrawingObjects/GlobalCounters.js",
"Word/apiCommon.js",
"Excel/api.js"
};
*/
string[] arrFilesConfig = {
"Common/Build/License.js",
"Common/browser.js",
"Common/docscoapisettings.js",
"Common/docscoapicommon.js",
"Common/docscoapi.js",
"Common/downloaderfiles.js",
"Common/apiCommon.js",
"Common/commonDefines.js",
"Common/editorscommon.js",
"Common/NumFormat.js",
"Common/Charts/charts.js",
"Common/Charts/DrawingArea.js",
"Common/Charts/DrawingObjects.js",
"Common/Charts/ChartsDrawer.js",
"Common/FontsFreeType/font_engine.js",
"Common/FontsFreeType/FontFile.js",
"Common/FontsFreeType/FontManager.js",
"Common/FontsFreeType/font_map.js",
"Word/Drawing/HatchPattern.js",
"Word/Drawing/WorkEvents.js",
"Word/Drawing/Externals.js",
"Word/Drawing/Metafile.js",
"Excel/model/DrawingObjects/GlobalLoaders.js",
"Common/trackFile.js",
"Excel/apiDefines.js",
"Excel/document/empty-workbook.js",
"Excel/utils/utils.js",
"Excel/model/clipboard.js",
"Excel/model/autofilters.js",
"Excel/graphics/DrawingContext.js",
"Excel/graphics/pdfprinter.js",
"Excel/model/CollaborativeEditing.js",
"Excel/model/ConditionalFormatting.js",
"Excel/model/FormulaObjects/parserFormula.js",
"Excel/model/FormulaObjects/dateandtimeFunctions.js",
"Excel/model/FormulaObjects/engineeringFunctions.js",
"Excel/model/FormulaObjects/cubeFunctions.js",
"Excel/model/FormulaObjects/databaseFunctions.js",
"Excel/model/FormulaObjects/textanddataFunctions.js",
"Excel/model/FormulaObjects/statisticalFunctions.js",
"Excel/model/FormulaObjects/financialFunctions.js",
"Excel/model/FormulaObjects/mathematicFunctions.js",
"Excel/model/FormulaObjects/lookupandreferenceFunctions.js",
"Excel/model/FormulaObjects/informationFunctions.js",
"Excel/model/FormulaObjects/logicalFunctions.js",
"Excel/model/Serialize.js",
"Excel/model/WorkbookElems.js",
"Excel/model/Workbook.js",
"Excel/model/CellInfo.js",
"Excel/model/AdvancedOptions.js",
"Excel/model/History.js",
"Excel/model/UndoRedo.js",
"Excel/model/CellComment.js",
"Excel/model/Private/CellComment.js",
"Excel/view/mobileTouch.js",
"Excel/view/iscroll.js",
"Excel/view/PopUpSelector.js",
"Excel/view/StringRender.js",
"Excel/view/CellTextRender.js",
"Excel/view/CellEditorView.js",
"Excel/view/WorksheetView.js",
"Excel/view/Private/WorksheetView.js",
"Excel/view/HandlerList.js",
"Excel/view/EventsController.js",
"Excel/view/WorkbookView.js",
"Common/scroll.js",
"Word/Editor/SerializeCommon.js",
"Common/Drawings/Math.js",
"Common/Drawings/ArcTo.js",
"Word/Drawing/ColorArray.js",
"Common/Shapes/Serialize.js",
"Common/Shapes/SerializeWriter.js",
"Common/SerializeCommonWordExcel.js",
"Common/SerializeChart.js",
"Common/Drawings/Hit.js",
"Common/Drawings/States.js",
"Common/Drawings/DrawingObjectsHandlers.js",
"Common/Drawings/TrackObjects/AdjustmentTracks.js",
"Common/Drawings/TrackObjects/ResizeTracks.js",
"Common/Drawings/TrackObjects/RotateTracks.js",
"Common/Drawings/TrackObjects/NewShapeTracks.js",
"Common/Drawings/TrackObjects/PolyLine.js",
"Common/Drawings/TrackObjects/Spline.js",
"Common/Drawings/TrackObjects/MoveTracks.js",
"Common/Drawings/CommonController.js",
"Common/Drawings/Format/Constants.js",
"Common/Drawings/Format/Format.js",
"Common/Drawings/Format/CreateGeometry.js",
"Common/Drawings/Format/Geometry.js",
"Common/Drawings/Format/Path.js",
"Common/Drawings/Format/Shape.js",
"Common/Drawings/Format/GroupShape.js",
"Common/Drawings/Format/Image.js",
"Common/Drawings/Format/ChartSpace.js",
"Common/Drawings/Format/ChartFormat.js",
"Common/Drawings/Format/TextBody.js",
"Common/wordcopypaste.js",
"Excel/view/DrawingObjectsController.js",
"Excel/model/DrawingObjects/Graphics.js",
"Excel/model/DrawingObjects/Private/Graphics.js",
"Excel/model/DrawingObjects/Overlay.js",
"Excel/model/DrawingObjects/Controls.js",
"Excel/model/DrawingObjects/ShapeDrawer.js",
"Excel/model/DrawingObjects/DrawingDocument.js",
"Excel/model/DrawingObjects/Format/ShapePrototype.js",
"Excel/model/DrawingObjects/Format/ImagePrototype.js",
"Excel/model/DrawingObjects/Format/GroupPrototype.js",
"Excel/model/DrawingObjects/Format/ChartSpacePrototype.js",
"PowerPoint/Editor/Format/GraphicFrame.js",
"Word/Editor/Comments.js",
"Word/Editor/Styles.js",
"Word/Editor/FlowObjects.js",
"Word/Editor/ParagraphContent.js",
"Word/Editor/ParagraphContentBase.js",
"Word/Editor/Hyperlink.js",
"Word/Editor/Field.js",
"Word/Editor/Run.js",
"Word/Editor/Math.js",
"Word/Editor/Paragraph.js",
"Word/Editor/Paragraph_Recalculate.js",
"Word/Editor/Sections.js",
"Word/Editor/Numbering.js",
"Word/Editor/HeaderFooter.js",
"Word/Editor/Document.js",
"Word/Editor/DocumentContent.js",
"Word/Editor/Table.js",
"Word/Editor/Serialize2.js",
"Word/Editor/FontClassification.js",
"Word/Editor/Spelling.js",
"Word/Editor/GraphicObjects/WrapManager.js",
"Word/Math/mathTypes.js",
"Word/Math/mathText.js",
"Word/Math/mathContent.js",
"Word/Math/base.js",
"Word/Math/fraction.js",
"Word/Math/degree.js",
"Word/Math/matrix.js",
"Word/Math/limit.js",
"Word/Math/nary.js",
"Word/Math/radical.js",
"Word/Math/operators.js",
"Word/Math/accent.js",
"Word/Math/borderBox.js",
"Excel/model/DrawingObjects/GlobalCounters.js",
"Word/apiCommon.js",
"Excel/api.js",
"Common/Shapes/EditorSettings.js"
};
if (true)
{
files.Clear();
for (int i = 0; i < arrFilesConfig.Length; ++i)
{
files.Add(arrFilesConfig[i]);
}
}
StringBuilder oBuilder = new StringBuilder();
for (int i = 0; i < files.Count; i++)
{
StreamReader oReader = new StreamReader(strRoot + files[i]);
oBuilder.Append(oReader.ReadToEnd());
oBuilder.Append("\n\n");
}
string strDestPath = strApplication + "\\OfficeWeb\\Excel\\sdk-all.js";
StreamWriter oWriter = new StreamWriter(strDestPath, false, Encoding.UTF8);
oWriter.Write(oBuilder.ToString());
oWriter.Close();
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Joiner")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Ascensio System SIA")]
[assembly: AssemblyProduct("Joiner")]
[assembly: AssemblyCopyright("Ascensio System SIA Copyright (c) 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0e989b01-1ac4-4bc9-8346-c19b89b47389")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
This source diff could not be displayed because it is too large. You can view the blob instead.
var editor = undefined;
var window = new Object();
var navigator = new Object();
navigator.userAgent = "chrome";
window.navigator = navigator;
window.location = new Object();
window.location.protocol = "";
window.location.host = "";
window.location.href = "";
window.NATIVE_EDITOR_ENJINE = true;
window.NATIVE_EDITOR_ENJINE_SYNC_RECALC = true;
window.__fonts_files = __fonts_files;
window.__fonts_infos = __fonts_infos;
var document = new Object();
window.document = document;
function Image()
{
this.src = "";
this.onload = function()
{
}
this.onerror = function()
{
}
}
function _image_data()
{
this.data = null;
this.length = 0;
}
function native_context2d(parent)
{
this.canvas = parent;
this.globalAlpha = 0;
this.globalCompositeOperation = "";
this.fillStyle = "";
this.strokeStyle = "";
this.lineWidth = 0;
this.lineCap = 0;
this.lineJoin = 0;
this.miterLimit = 0;
this.shadowOffsetX = 0;
this.shadowOffsetY = 0;
this.shadowBlur = 0;
this.shadowColor = 0;
this.font = "";
this.textAlign = 0;
this.textBaseline = 0;
}
native_context2d.prototype =
{
save : function() {},
restore : function() {},
scale : function(x,y) {},
rotate : function(angle) {},
translate : function(x,y) {},
transform : function(m11,m12,m21,m22,dx,dy) {},
setTransform : function(m11,m12,m21,m22,dx,dy) {},
createLinearGradient : function(x0,y0,x1,y1) { return null; },
createRadialGradient : function(x0,y0,r0,x1,y1,r1) { return null; },
createPattern : function(image,repetition) { return null; },
clearRect : function(x,y,w,h) {},
fillRect : function(x,y,w,h) {},
strokeRect : function(x,y,w,h) {},
beginPath : function() {},
closePath : function() {},
moveTo : function(x,y) {},
lineTo : function(x,y) {},
quadraticCurveTo : function(cpx,cpy,x,y) {},
bezierCurveTo : function(cp1x,cp1y,cp2x,cp2y,x,y) {},
arcTo : function(x1,y1,x2,y2,radius) {},
rect : function(x,y,w,h) {},
arc : function(x,y,radius,startAngle,endAngle,anticlockwise) {},
fill : function() {},
stroke : function() {},
clip : function() {},
isPointInPath : function(x,y) {},
drawFocusRing : function(element,xCaret,yCaret,canDrawCustom) {},
fillText : function(text,x,y,maxWidth) {},
strokeText : function(text,x,y,maxWidth) {},
measureText : function(text) {},
drawImage : function(img_elem,dx_or_sx,dy_or_sy,dw_or_sw,dh_or_sh,dx,dy,dw,dh) {},
createImageData : function(imagedata_or_sw,sh)
{
var _data = new _image_data();
_data.length = imagedata_or_sw * sh * 4;
_data.data = new Uint8Array(imagedata_or_sw * sh * 4);
return _data;
},
getImageData : function(sx,sy,sw,sh) {},
putImageData : function(image_data,dx,dy,dirtyX,dirtyY,dirtyWidth,dirtyHeight) {}
};
function native_canvas()
{
this.id = "";
this.width = 300;
this.height = 150;
this.nodeType = 1;
}
native_canvas.prototype =
{
getContext : function(type)
{
if (type == "2d")
return new native_context2d(this);
return null;
},
toDataUrl : function(type)
{
return "";
},
addEventListener : function()
{
},
attr : function()
{
}
};
window["Asc"] = new Object();
var _null_object = new Object();
_null_object.length = 0;
_null_object.nodeType = 1;
_null_object.offsetWidth = 1;
_null_object.offsetHeight = 1;
_null_object.clientWidth = 1;
_null_object.clientHeight = 1;
_null_object.scrollWidth = 1;
_null_object.scrollHeight = 1;
_null_object.style = new Object();
_null_object.documentElement = _null_object;
_null_object.body = _null_object;
_null_object.ownerDocument = _null_object;
_null_object.defaultView = _null_object;
_null_object.addEventListener = function(){};
_null_object.setAttribute = function(){};
_null_object.getElementsByTagName = function() { return []; };
_null_object.appendChild = function() {};
_null_object.removeChild = function() {};
_null_object.insertBefore = function() {};
_null_object.childNodes = [];
_null_object.parent = _null_object;
_null_object.parentNode = _null_object;
_null_object.find = function() { return this; };
_null_object.appendTo = function() { return this; };
_null_object.css = function() { return this; };
_null_object.width = function() { return 0; };
_null_object.height = function() { return 0; };
_null_object.attr = function() { return this; };
_null_object.prop = function() { return this; };
_null_object.val = function() { return this; };
_null_object.remove = function() {};
_null_object.getComputedStyle = function() { return null; };
_null_object.getContext = function(type) {
if (type == "2d")
return new native_context2d(this);
return null;
};
window._null_object = _null_object;
document.createElement = function(type)
{
if (type && type.toLowerCase)
{
if (type.toLowerCase() == "canvas")
return new native_canvas();
}
return _null_object;
}
function _return_empty_html_element() { return _null_object; };
document.createDocumentFragment = _return_empty_html_element;
document.getElementsByTagName = function(tag) {
var ret = [];
if ("head" == tag)
ret.push(_null_object);
return ret;
};
document.insertBefore = function() {};
document.appendChild = function() {};
document.removeChild = function() {};
document.getElementById = function() { return _null_object; };
document.createComment = function() { return undefined; };
document.documentElement = _null_object;
document.body = _null_object;
var native = CreateNativeEngine();
window.native = native;
window["native"] = native;
window.native.v6a = window.native.GetFontBinary;
var native_renderer = null;
var _api = null;
var Asc = null;
function NativeOpenFile()
{
var doc_bin = window.native.GetFileString(g_file_path);
if (NATIVE_DOCUMENT_TYPE == "presentation" || NATIVE_DOCUMENT_TYPE == "document")
{
_api = new window["asc_docs_api"]("");
_api.asc_nativeOpenFile(doc_bin);
}
else
{
Asc = window["Asc"];
_api = new window["Asc"]["spreadsheet_api"];
var doc_bin = window.native.GetFileString(g_file_path);
_api.asc_nativeOpenFile(doc_bin);
}
}
function NativeCalculateFile()
{
_api.asc_nativeCalculateFile();
}
function NativeApplyChanges()
{
if (NATIVE_DOCUMENT_TYPE == "presentation" || NATIVE_DOCUMENT_TYPE == "document")
{
var __changes = [];
var _count_main = window.native.GetCountChanges();
for (var i = 0; i < _count_main; i++)
{
var _changes_file = window.native.GetChangesFile(i);
var _changes = JSON.parse(window.native.GetFileString(_changes_file));
for (var j = 0; j < _changes.length; j++)
{
__changes.push(_changes[j]);
}
}
_api.asc_nativeApplyChanges(__changes);
}
else
{
var __changes = [];
var _count_main = window.native.GetCountChanges();
for (var i = 0; i < _count_main; i++)
{
var _changes_file = window.native.GetChangesFile(i);
var _changes = JSON.parse(window.native.GetFileString(_changes_file));
for (var j = 0; j < _changes.length; j++)
{
__changes.push(_changes[j]);
}
}
_api.asc_nativeApplyChanges(__changes);
}
}
function NativeGetFileString()
{
return _api.asc_nativeGetFile();
}
function GetNativeCountPages()
{
return _api.asc_nativePrintPagesCount();
}
window.memory1 = null;
window.memory2 = null;
function GetNativePageBase64(pageIndex)
{
if (null == window.memory1)
window.memory1 = CreateNativeMemoryStream();
else
window.memory1.ClearNoAttack();
if (null == window.memory2)
window.memory2 = CreateNativeMemoryStream();
else
window.memory2.ClearNoAttack();
if (native_renderer == null)
{
native_renderer = _api.asc_nativeCheckPdfRenderer(window.memory1, window.memory2);
}
else
{
window.memory1.ClearNoAttack();
window.memory2.ClearNoAttack();
}
_api.asc_nativePrint(native_renderer, pageIndex);
return window.memory1;
}
function GetNativeId()
{
return window.native.GetFileId();
}
function clearTimeout() {};
function setTimeout() {};
function clearInterval() {};
function setInterval() {};
window.clearTimeout = clearTimeout;
window.setTimeout = setTimeout;
window.clearInterval = clearInterval;
window.setInterval = setInterval;
\ No newline at end of file
#pragma once
#include "stdafx.h"
#include "../Common/DocxFormat/Source/SystemUtility/File.h"
#define GUID_STRING_LEN 40
//#pragma comment(lib, "../../../../../../../v8/build/Debug/lib/icui18n.lib")
//#pragma comment(lib, "../../../../../../../v8/build/Debug/lib/icuuc.lib")
//#pragma comment(lib, "../../../../../../../v8/build/Debug/lib/v8_base.ia32.lib")
//#pragma comment(lib, "../../../../../../../v8/build/Debug/lib/v8_nosnapshot.ia32.lib")
//#pragma comment(lib, "../../../../../../../v8/build/Debug/lib/v8_snapshot.lib")
#ifdef _DEBUG
#pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/icui18n.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/icuuc.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/v8_libbase.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/v8_base.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/v8_nosnapshot.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/v8_snapshot.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/v8_libplatform.lib")
#else
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/icui18n.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/icuuc.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/v8_libbase.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/v8_base.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/v8_nosnapshot.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/v8_snapshot.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/v8_libplatform.lib")
#endif
#include "../../../../../../v8_trunk/include/v8.h"
#include "../../../../../../v8_trunk/include/libplatform/libplatform.h"
class CMemoryStream
{
private:
//
BYTE* m_pBuffer;
BYTE* m_pBufferMem;
size_t m_lSize;
public:
CMemoryStream()
{
m_pBuffer = NULL;
m_pBufferMem = NULL;
m_lSize = 0;
}
~CMemoryStream()
{
RELEASEARRAYOBJECTS(m_pBuffer);
}
__forceinline BYTE* GetData()
{
return m_pBuffer;
}
__forceinline int GetSize()
{
return (int)(m_pBufferMem - m_pBuffer);
}
__forceinline void Clear()
{
m_lSize = 0;
m_pBuffer = NULL;
m_pBufferMem = NULL;
}
__forceinline void ClearNoAttack()
{
m_pBufferMem = m_pBuffer;
}
__forceinline void Copy(const CMemoryStream* pData, const size_t& nPos, const size_t& nLen)
{
CheckBufferSize(nLen);
memcpy(m_pBufferMem, pData->m_pBuffer + nPos, nLen);
m_pBufferMem += nLen;
};
__forceinline void CheckBufferSize(size_t lPlus)
{
if (NULL != m_pBuffer)
{
size_t nNewSize = (m_pBufferMem - m_pBuffer) + lPlus;
if (nNewSize >= m_lSize)
{
while (nNewSize >= m_lSize)
{
m_lSize *= 2;
}
BYTE* pNew = new BYTE[m_lSize];
memcpy(pNew, m_pBuffer, m_pBufferMem - m_pBuffer);
m_pBufferMem = pNew + (m_pBufferMem - m_pBuffer);
RELEASEARRAYOBJECTS(m_pBuffer);
m_pBuffer = pNew;
}
}
else
{
m_lSize = 1000;
m_pBuffer = new BYTE[m_lSize];
m_pBufferMem = m_pBuffer;
CheckBufferSize(lPlus);
}
}
__forceinline void WriteBYTE(const BYTE& lValue)
{
CheckBufferSize(sizeof(BYTE));
*m_pBufferMem = lValue;
m_pBufferMem += sizeof(BYTE);
}
__forceinline void WriteLONG(const LONG& lValue)
{
CheckBufferSize(sizeof(LONG));
*((LONG*)(m_pBufferMem)) = lValue;
m_pBufferMem += sizeof(LONG);
}
__forceinline void WriteDouble(const double& dValue)
{
CheckBufferSize(sizeof(double));
*((double*)(m_pBufferMem)) = dValue;
m_pBufferMem += sizeof(double);
}
__forceinline void WriteStringA(const char* pData, int nLen)
{
CheckBufferSize(nLen + sizeof(USHORT));
*((USHORT*)(m_pBufferMem)) = (USHORT)nLen;
m_pBufferMem += sizeof(USHORT);
memcpy(m_pBufferMem, pData, nLen);
m_pBufferMem += nLen;
}
__forceinline void WriteStringA2(const char* pData, int nLen)
{
CheckBufferSize(nLen + sizeof(LONG));
*((LONG*)(m_pBufferMem)) = (LONG)nLen;
m_pBufferMem += sizeof(LONG);
memcpy(m_pBufferMem, pData, nLen);
m_pBufferMem += nLen;
}
__forceinline void WriteString(const wchar_t* pData, int nLen)
{
CheckBufferSize(nLen + sizeof(USHORT));
*((USHORT*)(m_pBufferMem)) = (USHORT)nLen;
m_pBufferMem += sizeof(USHORT);
int nLen2 = nLen << 1;
memcpy(m_pBufferMem, pData, nLen2);
m_pBufferMem += nLen2;
}
__forceinline void WriteString2(const wchar_t* pData, int nLen)
{
int nLen2 = nLen << 1;
CheckBufferSize(nLen2 + sizeof(LONG));
*((LONG*)(m_pBufferMem)) = (LONG)nLen2;
m_pBufferMem += sizeof(LONG);
memcpy(m_pBufferMem, pData, nLen2);
m_pBufferMem += nLen2;
}
};
// wrap_methods -------------
CMemoryStream* unwrap_memorystream(v8::Handle<v8::Object> obj)
{
v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(obj->GetInternalField(0));
return static_cast<CMemoryStream*>(field->Value());
}
void _ms_write_byte(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
BYTE arg = (BYTE)args[0]->Int32Value();
pNative->WriteBYTE(arg);
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_write_bool(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
BYTE arg = (BYTE)args[0]->BooleanValue();
pNative->WriteBYTE(arg ? 1 : 0);
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_write_long(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
LONG arg = (LONG)args[0]->Int32Value();
pNative->WriteLONG(arg);
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_write_double(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
double arg = (double)args[0]->NumberValue();
pNative->WriteLONG((LONG)(arg * 100000));
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_writestring1(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
v8::String::Value data(args[0]);
pNative->WriteString((wchar_t*)*data, data.length());
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_writestring2(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
v8::String::Value data(args[0]);
pNative->WriteString2((wchar_t*)*data, data.length());
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_copy(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
CMemoryStream* pNative2 = unwrap_memorystream(args[0]->ToObject());
size_t pos = (size_t)args[1]->Uint32Value();
size_t len = (size_t)args[2]->Uint32Value();
pNative->Copy(pNative2, pos, len);
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_clearnoattack(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
pNative->ClearNoAttack();
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_pos(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
CMemoryStream* pNative = unwrap_memorystream(info.Holder());
info.GetReturnValue().Set(v8::Integer::New(v8::Isolate::GetCurrent(), pNative->GetSize()));
}
v8::Handle<v8::ObjectTemplate> CreateMemoryStreamTemplate(v8::Isolate* isolate)
{
//v8::HandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New();
result->SetInternalFieldCount(1); // CNativeControl
v8::Isolate* current = v8::Isolate::GetCurrent();
// property
result->SetAccessor(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "pos"), _ms_pos); //
// -
result->Set(v8::String::NewFromUtf8(current, "Copy"), v8::FunctionTemplate::New(current, _ms_copy));
result->Set(v8::String::NewFromUtf8(current, "ClearNoAttack"), v8::FunctionTemplate::New(current, _ms_clearnoattack));
result->Set(v8::String::NewFromUtf8(current, "WriteByte"), v8::FunctionTemplate::New(current, _ms_write_byte));
result->Set(v8::String::NewFromUtf8(current, "WriteBool"), v8::FunctionTemplate::New(current, _ms_write_bool));
result->Set(v8::String::NewFromUtf8(current, "WriteLong"), v8::FunctionTemplate::New(current, _ms_write_long));
result->Set(v8::String::NewFromUtf8(current, "WriteDouble"), v8::FunctionTemplate::New(current, _ms_write_double));
result->Set(v8::String::NewFromUtf8(current, "WriteString"), v8::FunctionTemplate::New(current, _ms_writestring1));
result->Set(v8::String::NewFromUtf8(current, "WriteString2"), v8::FunctionTemplate::New(current, _ms_writestring2));
// , HandleScope
// "" HandleScope - handle_scope
//return handle_scope.Close(result);
return result;
}
<Settings>
<file>../../../OfficeWeb/Common/Native/native.js</file>
<file>../../../OfficeWeb/Common/Native/jquery_native.js</file>
<file>../../../OfficeWeb/Common/3rdparty/XRegExp/xregexp-all-min.js</file>
<file>../../../OfficeWeb/Common/AllFonts.js</file>
<DoctSdk>../../../OfficeWeb/Word/sdk-all.js</DoctSdk>
<PpttSdk>../../../OfficeWeb/PowerPoint/sdk-all.js</PpttSdk>
<XlstSdk>../../../OfficeWeb/Excel/sdk-all.js</XlstSdk>
</Settings>
\ No newline at end of file
// DoctRenderer.cpp : Implementation of DLL Exports.
#include "stdafx.h"
#include "resource.h"
#include "DoctRenderer.h"
// The module attribute causes DllMain, DllRegisterServer and DllUnregisterServer to be automatically implemented for you
[ module(dll, uuid = "{8AFF13BF-79BE-4682-89AF-2CA81245D3E9}",
name = "DoctRenderer",
helpstring = "DoctRenderer 1.0 Type Library",
resource_name = "IDR_DOCTRENDERER") ]
class CDoctRendererModule
{
public:
// Override CAtlDllModuleT members
};
// DoctRenderer.h : Declaration of the CFontConverter
#pragma once
#include "resource.h" // main symbols
#include "stdafx.h"
#include "NativeControl.h"
#include "../../../../../../Common/TimeMeasurer.h"
#ifdef _DEBUG
#define _LOG_ERRORS_TO_FILE_
#endif
// TEST!!!
//#define _LOG_ERRORS_TO_FILE_
#ifdef _LOG_ERRORS_TO_FILE_
void __log_error_(const CString& strType, const CString& strError)
{
FILE* f = fopen("C:\\doct_renderer_errors.txt", "a+");
CStringA sT = (CStringA)strType;
fprintf(f, sT.GetBuffer());
fprintf(f, ": ");
CStringA s = (CStringA)strError;
fprintf(f, s.GetBuffer());
fprintf(f, "\n");
fclose(f);
}
#define _LOGGING_ERROR_(type, err) __log_error_(type, err);
#else
#define _LOGGING_ERROR_(type, err)
#endif
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "winmm.lib")
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif
void CreateNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Handle<v8::ObjectTemplate> NativeObjectTemplate = CreateNativeControlTemplate(isolate);
CNativeControl* pNativeObject = new CNativeControl();
v8::Local<v8::Object> obj = NativeObjectTemplate->NewInstance();
obj->SetInternalField(0, v8::External::New(v8::Isolate::GetCurrent(), pNativeObject));
args.GetReturnValue().Set(obj);
}
void CreateNativeMemoryStream(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Handle<v8::ObjectTemplate> MemoryObjectTemplate = CreateMemoryStreamTemplate(isolate);
CMemoryStream* pMemoryObject = new CMemoryStream();
v8::Local<v8::Object> obj = MemoryObjectTemplate->NewInstance();
obj->SetInternalField(0, v8::External::New(v8::Isolate::GetCurrent(), pMemoryObject));
args.GetReturnValue().Set(obj);
}
// IDoctRenderer
[ object, uuid("353508C9-F3EA-4ceb-8AF6-A5FF4498998C"), dual, pointer_default(unique) ]
__interface IDoctRenderer : IDispatch
{
[id(100)] HRESULT Execute([in] BSTR bsXml, [out] BSTR* pbsError);
//----- ----------------------------------------------------------------
[id(10001)] HRESULT SetAdditionalParam([in] BSTR ParamName, [in] VARIANT ParamValue);
[id(10002)] HRESULT GetAdditionalParam([in] BSTR ParamName, [out] VARIANT * ParamValue);
};
namespace DoctRendererFormat
{
enum FormatFile
{
DOCT = 0,
XLST = 1,
PPTT = 2,
PDF = 3,
INVALID = 255
};
}
class CExecuteParams
{
public:
DoctRendererFormat::FormatFile m_eSrcFormat;
DoctRendererFormat::FormatFile m_eDstFormat;
CString m_strFontsDirectory;
CString m_strImagesDirectory;
CString m_strThemesDirectory;
CString m_strSrcFilePath;
CString m_strDstFilePath;
CAtlArray<CString> m_arChanges;
int m_nCountChangesItems;
public:
CExecuteParams() : m_arChanges()
{
m_eSrcFormat = DoctRendererFormat::INVALID;
m_eDstFormat = DoctRendererFormat::INVALID;
m_strFontsDirectory = _T("");
m_strImagesDirectory = _T("");
m_strThemesDirectory = _T("");
m_strSrcFilePath = _T("");
m_strDstFilePath = _T("");
m_nCountChangesItems = -1;
}
~CExecuteParams()
{
m_arChanges.RemoveAll();
}
public:
BOOL FromXml(BSTR bsXml)
{
CString strXml = (CString)bsXml;
XmlUtils::CXmlNode oNode;
if (!oNode.FromXmlString(strXml))
return FALSE;
m_strSrcFilePath = oNode.ReadValueString(_T("SrcFilePath"));
m_strDstFilePath = oNode.ReadValueString(_T("DstFilePath"));
m_eSrcFormat = (DoctRendererFormat::FormatFile)(oNode.ReadValueInt(_T("SrcFileType")));
m_eDstFormat = (DoctRendererFormat::FormatFile)(oNode.ReadValueInt(_T("DstFileType")));
m_strFontsDirectory = oNode.ReadValueString(_T("FontsDirectory"));
m_strImagesDirectory = oNode.ReadValueString(_T("ImagesDirectory"));
m_strThemesDirectory = oNode.ReadValueString(_T("ThemesDirectory"));
XmlUtils::CXmlNode oNodeChanges;
if (oNode.GetNode(_T("Changes"), oNodeChanges))
{
m_nCountChangesItems = oNodeChanges.ReadAttributeInt(_T("TopItem"), -1);
XmlUtils::CXmlNodes oNodes;
oNodeChanges.GetNodes(_T("Change"), oNodes);
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode _node;
oNodes.GetAt(i, _node);
m_arChanges.Add(_node.GetText());
}
}
return TRUE;
}
};
// CDoctRenderer
[coclass, default(IDoctRenderer), threading(apartment), vi_progid("DoctRenderer.DoctRenderer"), progid("DoctRenderer.DoctRenderer.1"), version(1.0), uuid("E5FD7681-B077-48df-93E3-0345B6DBE8EE") ]
class ATL_NO_VTABLE CDoctRenderer : public IDoctRenderer
{
private:
//
CExecuteParams m_oParams;
IASCRenderer* m_pRenderer;
CString m_strConfigDir;
CString m_strConfigPath;
CAtlArray<CString> m_arrFiles;
CString m_strDoctSDK;
CString m_strPpttSDK;
CString m_strXlstSDK;
CString m_strEditorType;
CString m_strFilePath;
BOOL m_bIsInitTypedArrays;
public:
CDoctRenderer()
{
m_pRenderer = NULL;
m_bIsInitTypedArrays = FALSE;
}
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
m_strConfigDir = _T("");
m_strConfigPath = _T("");
HINSTANCE hModule = _AtlBaseModule.GetModuleInstance();
TCHAR szPathDLL[MAX_PATH] = {0}; ::GetModuleFileName(hModule, szPathDLL, MAX_PATH);
m_strConfigDir = CString(szPathDLL);
int nFind = m_strConfigDir.ReverseFind(TCHAR('\\'));
if (-1 != nFind)
m_strConfigDir.Delete(nFind + 1, m_strConfigDir.GetLength() - nFind - 1);
m_strConfigPath = m_strConfigDir + _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);
CString strFilePath = _node.GetText();
if (IsFileExists(strFilePath))
m_arrFiles.Add(_node.GetText());
else
m_arrFiles.Add(m_strConfigDir + strFilePath);
}
}
}
m_strDoctSDK = _T("");
m_strPpttSDK = _T("");
m_strXlstSDK = _T("");
XmlUtils::CXmlNode oNodeSdk = oNode.ReadNode(_T("DoctSdk"));
if (oNodeSdk.IsValid())
m_strDoctSDK = oNodeSdk.GetText();
oNodeSdk = oNode.ReadNode(_T("PpttSdk"));
if (oNodeSdk.IsValid())
m_strPpttSDK = oNodeSdk.GetText();
oNodeSdk = oNode.ReadNode(_T("XlstSdk"));
if (oNodeSdk.IsValid())
m_strXlstSDK = oNodeSdk.GetText();
if (!IsFileExists(m_strDoctSDK))
m_strDoctSDK = m_strConfigDir + m_strDoctSDK;
if (!IsFileExists(m_strPpttSDK))
m_strPpttSDK = m_strConfigDir + m_strPpttSDK;
if (!IsFileExists(m_strXlstSDK))
m_strXlstSDK = m_strConfigDir + m_strXlstSDK;
return S_OK;
}
void FinalRelease()
{
}
public:
STDMETHOD(SetAdditionalParam)(BSTR bsParamName, VARIANT vParamValue)
{
/*
CString sParamName; sParamName = bsParamName;
if (_T("Parent") == sParamName && vParamValue.punkVal != NULL)
{
vParamValue.punkVal->QueryInterface(AVSGraphics::IID_IAVSDocumentPainter, (void**)&m_pPainter);
}
*/
return S_OK;
}
STDMETHOD(GetAdditionalParam)(BSTR bsParamName, VARIANT *pvParamValue)
{
return S_OK;
}
STDMETHOD(Execute)(BSTR bsXml, BSTR* pbsError)
{
*pbsError = NULL;
m_oParams.FromXml(bsXml);
BOOL bIsInnerFonts = FALSE;
if (m_oParams.m_strFontsDirectory == _T(""))
bIsInnerFonts = TRUE;
CString strMainPart = _T("");
for (size_t i = 0; i < m_arrFiles.GetCount(); ++i)
{
if (bIsInnerFonts && (m_arrFiles[i].Find(_T("AllFonts.js")) != -1))
continue;
strMainPart += ReadScriptFile(m_arrFiles[i]);
strMainPart += _T("\n\n");
}
CString strCorrector = _T("");
CString sResourceFile;
switch (m_oParams.m_eSrcFormat)
{
case DoctRendererFormat::DOCT:
{
switch (m_oParams.m_eDstFormat)
{
case DoctRendererFormat::DOCT:
case DoctRendererFormat::PDF:
{
sResourceFile = m_strDoctSDK;
m_strEditorType = _T("document");
break;
}
default:
return S_FALSE;
}
break;
}
case DoctRendererFormat::PPTT:
{
switch (m_oParams.m_eDstFormat)
{
case DoctRendererFormat::PPTT:
case DoctRendererFormat::PDF:
{
sResourceFile = m_strPpttSDK;
m_strEditorType = _T("presentation");
break;
}
default:
return S_FALSE;
}
break;
}
case DoctRendererFormat::XLST:
{
switch (m_oParams.m_eDstFormat)
{
case DoctRendererFormat::XLST:
case DoctRendererFormat::PDF:
{
sResourceFile = m_strXlstSDK;
m_strEditorType = _T("spreadsheet");
break;
}
default:
return S_FALSE;
}
break;
}
default:
return S_FALSE;
}
if (bIsInnerFonts)
{
ASCGraphics::IASCFontManager* pFontManager = NULL;
CoCreateInstance(ASCGraphics::CLSID_CASCFontManager, NULL, CLSCTX_ALL, ASCGraphics::IID_IASCFontManager, (void**)&pFontManager);
pFontManager->Initialize(L"");
VARIANT var;
pFontManager->GetAdditionalParam(L"AllFonts.js", &var);
CString strAllFonts = (CString)var.bstrVal;
SysFreeString(var.bstrVal);
strMainPart += strAllFonts;
}
CString strFileName = m_oParams.m_strSrcFilePath;
strFileName += _T("\\");
strFileName.Replace(_T("/"), _T("\\"));
strFileName.Replace(_T("\\\\"), _T("\\"));
strFileName.Replace(_T("\\\\"), _T("\\"));
strFileName.Replace(_T("\\"), _T("\\\\"));
strFileName += _T("Editor.bin");
m_strFilePath = strFileName;
CString strScript = strMainPart;
strScript += ReadScriptFile(sResourceFile);
if (m_strEditorType == _T("spreadsheet"))
strScript += _T("\n$.ready();");
#if 0
CTimeMeasurer oMeasurer;
oMeasurer.Reset();
#endif
CString strError = _T("");
BOOL bResult = ExecuteScript(strScript, strError);
if (_T("") != strError)
{
CString sDestError = _T("<result><error ") + strError + _T(" /></result>");
*pbsError = sDestError.AllocSysString();
}
#if 0
int nTime = (int)(1000 * oMeasurer.GetTimeInterval());
CString strTime = _T("");
strTime.Format(_T("%d"), nTime);
_LOGGING_ERROR_(L"time_doct_renderer", strTime);
#endif
return bResult ? S_OK : S_FALSE;
}
private:
WCHAR* LoadResourceFile(HINSTANCE hInst, LPCTSTR sResName, LPCTSTR sResType)
{
HRSRC hrRes = FindResource(hInst, sResName, sResType);
if (!hrRes)
return NULL;
HGLOBAL hGlobal = LoadResource(hInst, hrRes);
DWORD sz = SizeofResource(hInst, hrRes);
void* ptrRes = LockResource(hGlobal);
// utf bom
WCHAR* pUnicodeString = GetCStringFromUTF8(((BYTE*)ptrRes) + 3, (LONG)sz - 3);
UnlockResource(hGlobal);
FreeResource(hGlobal);
return pUnicodeString;
}
WCHAR* GetCStringFromUTF8( BYTE* pBuffer, LONG lCount )
{
LONG lLenght = 0;
WCHAR* pUnicodeString = new WCHAR[lCount + 1];
LONG lIndexUnicode = 0;
for (LONG lIndex = 0; lIndex < lCount; ++lIndex)
{
if (0x00 == (0x80 & pBuffer[lIndex]))
{
//strRes += (TCHAR)pBuffer[lIndex];
pUnicodeString[lIndexUnicode++] = (WCHAR)pBuffer[lIndex];
continue;
}
else if (0x00 == (0x20 & pBuffer[lIndex]))
{
WCHAR mem = (WCHAR)(((pBuffer[lIndex] & 0x1F) << 6) + (pBuffer[lIndex + 1] & 0x3F));
//strRes += mem;
pUnicodeString[lIndexUnicode++] = mem;
lIndex += 1;
}
else if (0x00 == (0x10 & pBuffer[lIndex]))
{
WCHAR mem = (WCHAR)(((pBuffer[lIndex] & 0x0F) << 12) + ((pBuffer[lIndex + 1] & 0x3F) << 6) + (pBuffer[lIndex + 2] & 0x3F));
//strRes += mem;
pUnicodeString[lIndexUnicode++] = mem;
lIndex += 2;
}
else
{
BYTE mem = pBuffer[lIndex];
//pUnicodeString[lIndexUnicode++] = mem;
}
}
pUnicodeString[lIndexUnicode] = 0;
return pUnicodeString;
}
CString ReadScriptFile(const CString& strFile)
{
CFile oFile;
HRESULT hr = oFile.OpenFile(strFile);
if (S_OK != hr)
return _T("");
int nSize = (int)oFile.GetFileSize();
if (nSize < 3)
return _T("");
BYTE* pData = new BYTE[nSize];
oFile.ReadFile(pData, (DWORD)nSize);
CString strResult = _T("");
if (pData[0] == 0xEF && pData[1] == 0xBB && pData[2] == 0xBF)
{
WCHAR* pUnicode = GetCStringFromUTF8(pData + 3, nSize - 3);
strResult = CString(pUnicode);
RELEASEARRAYOBJECTS(pUnicode);
}
else
{
strResult = CString((char*)pData, nSize);
}
RELEASEARRAYOBJECTS(pData);
return strResult;
}
bool IsFileExists(LPCTSTR path)
{
WIN32_FIND_DATA findData;
ZeroMemory(&findData, sizeof(findData));
HANDLE handle = ::FindFirstFile(path, &findData);
bool fileExists = true;
if (handle == INVALID_HANDLE_VALUE)
fileExists = false;
FindClose(handle);
return fileExists;
}
private:
BOOL ExecuteScript(CString& strScript, CString& strError)
{
CString strException = _T("");
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
v8::V8::Initialize();
v8::V8::InitializeICU();
if (!m_bIsInitTypedArrays)
{
enableTypedArrays();
m_bIsInitTypedArrays = TRUE;
}
bool bIsBreak = false;
v8::Isolate* isolate = v8::Isolate::New();
if (true)
{
WCHAR* javascript = (WCHAR*)strScript.GetBuffer();
v8::Isolate::Scope isolate_cope(isolate);
v8::Locker isolate_locker(isolate);
v8::HandleScope handle_scope(isolate);
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
global->Set(v8::String::NewFromUtf8(isolate, "CreateNativeEngine"), v8::FunctionTemplate::New(isolate, CreateNativeObject));
global->Set(v8::String::NewFromUtf8(isolate, "CreateNativeMemoryStream"), v8::FunctionTemplate::New(isolate, CreateNativeMemoryStream));
v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
v8::Context::Scope context_scope(context);
v8::TryCatch try_catch;
v8::Local<v8::String> source = v8::String::NewFromTwoByte(isolate, (uint16_t*)javascript);
v8::Local<v8::Script> script = v8::Script::Compile(source);
// COMPILE
if (try_catch.HasCaught())
{
CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get());
_LOGGING_ERROR_(L"compile", strException)
strError = _T("code=\"compile\"");
bIsBreak = true;
}
// RUN
if (!bIsBreak)
{
v8::Local<v8::Value> result = script->Run();
if (try_catch.HasCaught())
{
CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get());
_LOGGING_ERROR_(L"run", strException)
strError = _T("code=\"run\"");
bIsBreak = true;
}
}
//---------------------------------------------------------------
v8::Local<v8::Object> global_js = context->Global();
v8::Handle<v8::Value> args[1];
args[0] = v8::Int32::New(isolate, 0);
CNativeControl* pNative = NULL;
// GET_NATIVE_ENGINE
if (!bIsBreak)
{
v8::Handle<v8::Value> js_func_get_native = global_js->Get(v8::String::NewFromUtf8(isolate, "GetNativeEngine"));
v8::Local<v8::Object> objNative;
if (js_func_get_native->IsFunction())
{
v8::Handle<v8::Function> func_get_native = v8::Handle<v8::Function>::Cast(js_func_get_native);
v8::Local<v8::Value> js_result2 = func_get_native->Call(global_js, 1, args);
if (try_catch.HasCaught())
{
int nLineError = try_catch.Message()->GetLineNumber();
strException = to_cstring(try_catch.Message()->Get());
strError = _T("code=\"run\"");
bIsBreak = true;
}
else
{
objNative = js_result2->ToObject();
v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(objNative->GetInternalField(0));
pNative = static_cast<CNativeControl*>(field->Value());
}
}
}
if (pNative != NULL)
{
pNative->m_pChanges = &m_oParams.m_arChanges;
pNative->m_strFontsDirectory = m_oParams.m_strFontsDirectory;
pNative->m_strImagesDirectory = m_oParams.m_strImagesDirectory;
pNative->m_strEditorType = m_strEditorType;
pNative->SetFilePath(m_strFilePath);
pNative->m_nMaxChangesNumber = m_oParams.m_nCountChangesItems;
}
// OPEN
if (!bIsBreak)
{
#if 1
v8::Handle<v8::Value> js_func_open = global_js->Get(v8::String::NewFromUtf8(isolate, "NativeOpenFileData"));
if (js_func_open->IsFunction())
{
v8::Handle<v8::Function> func_open = v8::Handle<v8::Function>::Cast(js_func_open);
CChangesWorker oWorkerLoader;
int nVersion = oWorkerLoader.OpenNative(pNative->GetFilePath());
v8::Handle<v8::Value> args_open[2];
args_open[0] = oWorkerLoader.GetDataFull();
args_open[1] = v8::Integer::New(isolate, nVersion);
func_open->Call(global_js, 2, args_open);
if (try_catch.HasCaught())
{
CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get()); // ?
_LOGGING_ERROR_(L"open", strException)
strError = _T("code=\"open\"");
bIsBreak = true;
}
}
#else
v8::Handle<v8::Value> js_func_open = global_js->Get(v8::String::NewFromUtf8(isolate, "NativeOpenFile"));
if (js_func_open->IsFunction())
{
v8::Handle<v8::Function> func_open = v8::Handle<v8::Function>::Cast(js_func_open);
func_open->Call(global_js, 1, args);
if (try_catch.HasCaught())
{
CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get()); // ?
_LOGGING_ERROR_(L"open", strException)
strError = _T("code=\"open\"");
bIsBreak = true;
}
}
#endif
}
// CHANGES
if (!bIsBreak)
{
#if 1
v8::Handle<v8::Value> js_func_apply_changes = global_js->Get(v8::String::NewFromUtf8(isolate, "NativeApplyChangesData"));
if (m_oParams.m_arChanges.GetCount() != 0)
{
//CTimeMeasurer oMeasurer;
//oMeasurer.Reset();
int nCurrentIndex = 0;
CChangesWorker oWorker;
int nFileType = 0;
if (m_strEditorType == _T("spreadsheet"))
nFileType = 1;
oWorker.SetFormatChanges(nFileType);
oWorker.CheckFiles(m_oParams.m_arChanges);
while (!bIsBreak)
{
nCurrentIndex = oWorker.Open(m_oParams.m_arChanges, nCurrentIndex);
bool bIsFull = (nCurrentIndex == m_oParams.m_arChanges.GetCount()) ? true : false;
if (js_func_apply_changes->IsFunction())
{
v8::Handle<v8::Function> func_apply_changes = v8::Handle<v8::Function>::Cast(js_func_apply_changes);
v8::Handle<v8::Value> args_changes[2];
args_changes[0] = oWorker.GetData();
args_changes[1] = v8::Boolean::New(isolate, bIsFull);
func_apply_changes->Call(global_js, 2, args_changes);
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()); // ?
_LOGGING_ERROR_(L"change_code", strCode)
_LOGGING_ERROR_(L"change", strException)
strError = _T("");
strError.Format(_T("index=\"%d\""), pNative->m_nCurrentChangesNumber);
bIsBreak = true;
}
}
if (bIsFull)
break;
}
//int nTime = (oMeasurer.GetTimeInterval() * 1000);
//CString strTime = _T("");
//strTime.Format(_T("%d"), nTime);
//_LOGGING_ERROR_(L"time_changes", strTime);
}
#else
v8::Handle<v8::Value> js_func_apply_changes = global_js->Get(v8::String::NewFromUtf8(isolate, "NativeApplyChanges"));
if (m_oParams.m_arChanges.GetCount() != 0)
{
if (js_func_apply_changes->IsFunction())
{
v8::Handle<v8::Function> func_apply_changes = v8::Handle<v8::Function>::Cast(js_func_apply_changes);
func_apply_changes->Call(global_js, 1, args);
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()); // ?
_LOGGING_ERROR_(L"change_code", strCode)
_LOGGING_ERROR_(L"change", strException)
strError = _T("");
strError.Format(_T("index=\"%d\""), pNative->m_nCurrentChangesNumber);
bIsBreak = true;
}
}
}
#endif
}
// SAVE
if (!bIsBreak)
{
switch (m_oParams.m_eDstFormat)
{
case DoctRendererFormat::DOCT:
case DoctRendererFormat::PPTT:
case DoctRendererFormat::XLST:
{
#if 1
v8::Handle<v8::Value> js_func_get_file_s = global_js->Get(v8::String::NewFromUtf8(isolate, "NativeGetFileData"));
if (js_func_get_file_s->IsFunction())
{
v8::Handle<v8::Function> func_get_file_s = v8::Handle<v8::Function>::Cast(js_func_get_file_s);
v8::Local<v8::Value> js_result2 = func_get_file_s->Call(global_js, 1, args);
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()); // ?
strError = _T("code=\"save\"");
_LOGGING_ERROR_(L"save", strException)
bIsBreak = true;
}
else
{
v8::Local<v8::Uint8Array> pArray = v8::Local<v8::Uint8Array>::Cast(js_result2);
BYTE* pData = (BYTE*)pArray->Buffer()->Externalize().Data();
CFile oFile;
if (S_OK == oFile.CreateFile(m_oParams.m_strDstFilePath))
{
oFile.WriteFile((void*)pNative->m_sHeader.GetBuffer(), (DWORD)pNative->m_sHeader.GetLength());
int nLen64 = Base64EncodeGetRequiredLength((DWORD)pNative->m_nSaveBinaryLen, ATL_BASE64_FLAG_NOCRLF);
char* pDst64 = new char[nLen64];
int nDstLen = nLen64;
Base64Encode(pData, pNative->m_nSaveBinaryLen, pDst64, &nDstLen, ATL_BASE64_FLAG_NOCRLF);
oFile.WriteFile((void*)pDst64, (DWORD)nDstLen);
RELEASEARRAYOBJECTS(pDst64);
oFile.CloseFile();
}
}
}
#else
v8::Handle<v8::Value> js_func_get_file_s = global_js->Get(v8::String::NewFromUtf8(isolate, "NativeGetFileString"));
if (js_func_get_file_s->IsFunction())
{
v8::Handle<v8::Function> func_get_file_s = v8::Handle<v8::Function>::Cast(js_func_get_file_s);
v8::Local<v8::Value> js_result2 = func_get_file_s->Call(global_js, 1, args);
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()); // ?
strError = _T("code=\"save\"");
_LOGGING_ERROR_(L"save", strException)
bIsBreak = true;
}
CStringA strSave = to_cstringA(js_result2);
CFile oFile;
if (S_OK == oFile.CreateFile(m_oParams.m_strDstFilePath))
{
oFile.WriteFile((void*)strSave.GetBuffer(), (DWORD)strSave.GetLength());
oFile.CloseFile();
}
}
#endif
break;
}
case DoctRendererFormat::PDF:
{
v8::Handle<v8::Value> js_func_calculate = global_js->Get(v8::String::NewFromUtf8(isolate, "NativeCalculateFile"));
v8::Handle<v8::Value> js_func_pages_count = global_js->Get(v8::String::NewFromUtf8(isolate, "GetNativeCountPages"));
v8::Handle<v8::Value> js_func_page = global_js->Get(v8::String::NewFromUtf8(isolate, "GetNativePageBase64"));
// CALCULATE
if (js_func_calculate->IsFunction())
{
v8::Handle<v8::Function> func_calculate = v8::Handle<v8::Function>::Cast(js_func_calculate);
func_calculate->Call(global_js, 1, args);
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()); // ?
strError = _T("code=\"calculate\"");
_LOGGING_ERROR_(L"calculate", strException)
bIsBreak = true;
}
}
LONG lPagesCount = 0;
// PAGESCOUNT
if (!bIsBreak)
{
if (js_func_pages_count->IsFunction())
{
v8::Handle<v8::Function> func_pages_count = v8::Handle<v8::Function>::Cast(js_func_pages_count);
v8::Local<v8::Value> js_result1 = func_pages_count->Call(global_js, 1, args);
if (try_catch.HasCaught())
{
CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get()); // ?
strError = _T("code=\"calculate\"");
bIsBreak = true;
}
else
{
v8::Local<v8::Int32> intValue = js_result1->ToInt32();
lPagesCount = (LONG)intValue->Value();
}
}
}
// RENDER
if (!bIsBreak)
{
if (js_func_page->IsFunction())
{
PDFWriter::IPDFWriter* pPDF = NULL;
CoCreateInstance(PDFWriter::CLSID_CPDFWriter, NULL, CLSCTX_ALL, PDFWriter::IID_IPDFWriter, (void**)&pPDF);
VARIANT var;
var.vt = VT_BSTR;
var.bstrVal = m_oParams.m_strFontsDirectory.AllocSysString();
pPDF->SetAdditionalParam(L"InitializeFromFolder", var);
SysFreeString(var.bstrVal);
pPDF->CreatePDF();
pPDF->SetPDFCompressionMode(15);
RELEASEINTERFACE(m_pRenderer);
pPDF->QueryInterface(__uuidof(IASCRenderer), (void**)&m_pRenderer);
v8::Handle<v8::Function> func_page = v8::Handle<v8::Function>::Cast(js_func_page);
for (LONG i = 0; i < lPagesCount; i++)
{
args[0] = v8::Int32::New(isolate, i);
v8::Local<v8::Value> js_result3 = func_page->Call(global_js, 1, args);
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()); // ?
_LOGGING_ERROR_(L"render", strException)
strError = _T("code=\"render\"");
bIsBreak = true;
break;
}
else
{
CMemoryStream* pPageStream = unwrap_memorystream(js_result3->ToObject());
ParsePageBinary(i, pPageStream->GetData(), pPageStream->GetSize(), true);
#if 0
CFile oFile;
CString sPageSave = _T("");
sPageSave.Format(_T("C:\\test\\DOCTRENDERER\\page%d.pagebin"), i + 1);
oFile.CreateFile(sPageSave);
oFile.WriteFile(pPageStream->GetData(), pPageStream->GetSize());
oFile.CloseFile();
#endif
}
}
RELEASEINTERFACE(m_pRenderer);
HRESULT hr = S_FALSE;
if (!bIsBreak)
{
BSTR bsFileDst = m_oParams.m_strDstFilePath.AllocSysString();
hr = pPDF->SaveToFile(bsFileDst);
SysFreeString(bsFileDst);
}
RELEASEINTERFACE(pPDF);
if (S_OK != hr)
{
_LOGGING_ERROR_(L"save", L"pdfsave")
strError = _T("code=\"save\"");
bIsBreak = true;
}
}
}
break;
}
default:
break;
}
}
}
isolate->Dispose();
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
delete platform;
return bIsBreak ? FALSE : TRUE;
}
void ParsePageBinary(LONG i, BYTE* pOutput, int lOutputLen, bool bIsPDF = false)
{
int* m = NULL;
USHORT* ms = NULL;
int _sLen = 0;
CString s = _T("");
double m1 = 0;
double m2 = 0;
double m3 = 0;
double m4 = 0;
double m5 = 0;
double m6 = 0;
CString imgPath = _T("");
CString base64Temp = _T("");
bool bIsPathOpened = false;
int nCountPages = 0;
int curindex = 0;
BYTE* current = pOutput;
CommandType eCommand;
while (curindex < lOutputLen)
{
eCommand = (CommandType)(*current);
current++;
curindex++;
switch (eCommand)
{
case ctPageWidth:
{
m = (int*)current;
current += 4;
curindex += 4;
m_pRenderer->put_Width((*m) / 100000.0);
break;
}
case ctPageHeight:
{
m = (int*)current;
current += 4;
curindex += 4;
m_pRenderer->put_Height((*m) / 100000.0);
break;
}
case ctPageStart:
{
m_pRenderer->NewPage();
m_pRenderer->BeginCommand(1);
++nCountPages;
break;
}
case ctPageEnd:
{
if (bIsPathOpened)
{
m_pRenderer->PathCommandEnd();
m_pRenderer->EndCommand(4);
}
bIsPathOpened = false;
m_pRenderer->EndCommand(1);
break;
}
case ctPenColor:
{
m = (int*)current;
m_pRenderer->put_PenColor(*m);
current += 4;
curindex += 4;
break;
}
case ctPenAlpha:
{
m_pRenderer->put_PenAlpha(*current);
current++;
curindex++;
break;
}
case ctPenSize:
{
m = (int*)current;
m_pRenderer->put_PenSize(*m / 100000.0);
current += 4;
curindex += 4;
break;
}
case ctPenLineJoin:
{
m_pRenderer->put_PenLineJoin(*current);
current++;
curindex++;
break;
}
case ctBrushType:
{
m = (int*)current;
m_pRenderer->put_BrushType(*m);
current += 4;
curindex += 4;
break;
}
case ctBrushColor1:
{
m = (int*)current;
m_pRenderer->put_BrushColor1(*m);
current += 4;
curindex += 4;
break;
}
case ctBrushAlpha1:
{
m_pRenderer->put_BrushAlpha1(*current);
current++;
curindex++;
break;
}
case ctBrushColor2:
{
m = (int*)current;
m_pRenderer->put_BrushColor2(*m);
current += 4;
curindex += 4;
break;
}
case ctBrushAlpha2:
{
m_pRenderer->put_BrushAlpha2(*current);
current++;
curindex++;
break;
}
case ctBrushRectable:
{
m = (int*)current;
current += 4 * 4;
curindex += 4 * 4;
m1 = (*m++) / 100000.0;
m2 = (*m++) / 100000.0;
m3 = (*m++) / 100000.0;
m4 = (*m++) / 100000.0;
// TODO:
//m_pRenderer->BrushRect(0, m1, m2, m3, m4);
break;
}
case ctBrushRectableEnabled:
{
VARIANT var;
var.vt = VT_BOOL;
var.boolVal = (1 == *current) ? VARIANT_TRUE : VARIANT_FALSE;
m_pRenderer->SetAdditionalParam(L"BrushFillBoundsEnable", var);
current += 1;
curindex += 1;
break;
}
case ctBrushTexturePath:
{
ms = (USHORT*)current;
current += 2;
curindex += 2;
_sLen = (int)(*ms);
CString s((WCHAR*)current, _sLen);
imgPath = s;
if (0 != s.Find(_T("http:")) &&
0 != s.Find(_T("https:")) &&
0 != s.Find(_T("ftp:")) &&
0 != s.Find(_T("file:")))
{
imgPath = m_oParams.m_strImagesDirectory + _T("\\") + s;
int _len = imgPath.GetLength();
int ind = imgPath.Find(_T(".svg"));
if (ind != -1)
{
if (ind == (_len - 4))
{
CString sInterest = imgPath.Mid(0, ind);
CFile oFile;
if (oFile.OpenFile(sInterest + _T(".emf")) == S_OK)
imgPath = sInterest + _T(".emf");
else if (oFile.OpenFile(sInterest + _T(".wmf")))
imgPath = sInterest + _T(".wmf");
}
}
}
base64Temp = _T("");
if (0 == s.Find(_T("data:")))
{
// TODO:
}
current += 2 * _sLen;
curindex += 2 * _sLen;
BSTR bsPath = imgPath.AllocSysString();
m_pRenderer->put_BrushTexturePath(bsPath);
SysFreeString(bsPath);
break;
}
case ctBrushGradient:
{
current++;
curindex++;
CString strAttrMain = _T("");
CString strColors = _T("");
bool bIsLinear = true;
while (true)
{
BYTE _command = *current;
current++;
curindex++;
if (251 == _command)
break;
LONG _R = 0;
LONG _G = 0;
LONG _B = 0;
LONG _A = 0;
switch (_command)
{
case 0:
{
current += 5;
curindex += 5;
m = (int*)current;
current += 4 * 4;
curindex += 4 * 4;
double d1 = (*m++) / 100000.0;
double d2 = (*m++) / 100000.0;
double d3 = (*m++) / 100000.0;
double d4 = (*m++) / 100000.0;
strAttrMain.Format(_T("x1=\"%.2lf\" y1=\"%.2lf\" x2=\"%.2lf\" y2=\"%.2lf\" gradientUnits=\"userSpaceOnUse\""), d1, d2, d3, d4);
strAttrMain.Replace(_T(","), _T("."));
break;
}
case 1:
{
bIsLinear = false;
current++;
curindex++;
m = (int*)current;
current += 6 * 4;
curindex += 6 * 4;
double d1 = (*m++) / 100000.0;
double d2 = (*m++) / 100000.0;
double d3 = (*m++) / 100000.0;
double d4 = (*m++) / 100000.0;
double d5 = (*m++) / 100000.0;
double d6 = (*m++) / 100000.0;
strAttrMain.Format(_T("cx=\"%.2lf\" cy=\"%.2lf\" r0=\"%.2lf\" r1=\"%.2lf\" rx=\"%.2lf\" ry=\"%.2lf\" gradientUnits=\"userSpaceOnUse\""), d1, d2, d5, d6, d1, d2);
strAttrMain.Replace(_T(","), _T("."));
break;
}
case 2:
{
int nCountColors = *((int*)current);
current += 4;
curindex += 4;
for (int nI = 0; nI < nCountColors; ++nI)
{
int pos = *((int*)current);
current += 4;
curindex += 4;
double dPos = pos / 100000.0;
BYTE _r = *current++;
BYTE _g = *current++;
BYTE _b = *current++;
BYTE _a = *current++;
_R += _r;
_G += _g;
_B += _b;
_A += _a;
curindex += 4;
int _color = ((_b << 16) & 0xFF0000) | ((_g << 8) & 0xFF00) | _r;
CString sColor;
sColor.Format(_T("<stop stop-color=\"%d\" stop-opacity=\"%.2lf\" offset=\"%.2lf\" />"), _color, _a / 255.0, dPos);
sColor.Replace(_T(","), _T("."));
strColors += sColor;
}
if (nCountColors != 0)
{
// TODO:
m_pRenderer->put_BrushType(1000);
_R = (BYTE)(_R / nCountColors);
_G = (BYTE)(_G / nCountColors);
_B = (BYTE)(_B / nCountColors);
_A = (BYTE)(_A / nCountColors);
LONG _Color = _B * 256 * 256 + _G * 256 + _R;
m_pRenderer->put_BrushColor1(_Color);
m_pRenderer->put_BrushAlpha1(_A);
}
break;
}
default:
break;
};
}
CString strXml = _T("");
// TODO:
if (bIsLinear)
{
strXml = _T("<linearGradient ") + strAttrMain + _T(">") + strColors + _T("</linearGradient>");
//m_pRenderer->SetAdditionalParam(L"Fill-LinearGradient", strXml);
}
else
{
strXml = _T("<radialGradient ") + strAttrMain + _T(">") + strColors + _T("</radialGradient>");
//m_pRenderer->SetAdditionalParam(L"Fill-RadialGradient", strXml);
}
break;
}
case ctBrushTextureMode:
{
int mode = (int)(*current);
m_pRenderer->put_BrushTextureMode(mode);
current += 1;
curindex += 1;
break;
}
case ctBrushTextureAlpha:
{
int txalpha = (int)(*current);
m_pRenderer->put_BrushTextureAlpha(txalpha);
current += 1;
curindex += 1;
break;
}
case ctSetTransform:
{
m = (int*)current;
current += 6 * 4;
curindex += 6 * 4;
m1 = (*m++) / 100000.0;
m2 = (*m++) / 100000.0;
m3 = (*m++) / 100000.0;
m4 = (*m++) / 100000.0;
m5 = (*m++) / 100000.0;
m6 = (*m++) / 100000.0;
m_pRenderer->SetTransform(m1, m2, m3, m4, m5, m6);
break;
}
case ctPathCommandStart:
{
if (bIsPathOpened)
{
m_pRenderer->PathCommandEnd();
m_pRenderer->EndCommand(4);
m_pRenderer->BeginCommand(4);
m_pRenderer->PathCommandStart();
}
else
{
m_pRenderer->BeginCommand(4);
m_pRenderer->PathCommandStart();
}
bIsPathOpened = true;
break;
}
case ctPathCommandEnd:
{
if (bIsPathOpened)
{
m_pRenderer->PathCommandEnd();
m_pRenderer->EndCommand(4);
bIsPathOpened = false;
}
break;
}
case ctPathCommandMoveTo:
{
m = (int*)current;
current += 2 * 4;
curindex += 2 * 4;
m1 = (*m++) / 100000.0;
m2 = (*m++) / 100000.0;
m_pRenderer->PathCommandMoveTo(m1, m2);
break;
}
case ctPathCommandLineTo:
{
m = (int*)current;
current += 2 * 4;
curindex += 2 * 4;
m1 = (*m++) / 100000.0;
m2 = (*m++) / 100000.0;
m_pRenderer->PathCommandLineTo(m1, m2);
break;
}
case ctPathCommandCurveTo:
{
m = (int*)current;
current += 6 * 4;
curindex += 6 * 4;
m1 = (*m++) / 100000.0;
m2 = (*m++) / 100000.0;
m3 = (*m++) / 100000.0;
m4 = (*m++) / 100000.0;
m5 = (*m++) / 100000.0;
m6 = (*m++) / 100000.0;
m_pRenderer->PathCommandCurveTo(m1, m2, m3, m4, m5, m6);
break;
}
case ctPathCommandClose:
{
m_pRenderer->PathCommandClose();
break;
}
case ctDrawPath:
{
m = (int*)current;
current += 4;
curindex += 4;
m_pRenderer->DrawPath(*m);
break;
}
case ctDrawImageFromFile:
{
m = (int*)current;
current += 4;
curindex += 4;
_sLen = (int)(*m);
_sLen /= 2;
CString s((WCHAR*)current, _sLen);
imgPath = s;
if (0 != s.Find(_T("http:")) &&
0 != s.Find(_T("https:")) &&
0 != s.Find(_T("ftp:")) &&
0 != s.Find(_T("file:")))
{
imgPath = m_oParams.m_strImagesDirectory + _T("\\") + s;
int _len = imgPath.GetLength();
int ind = imgPath.Find(_T(".svg"));
if (ind != -1)
{
if (ind == (_len - 4))
{
CString sInterest = imgPath.Mid(0, ind);
CFile oFile;
if (oFile.OpenFile(sInterest + _T(".emf")) == S_OK)
imgPath = sInterest + _T(".emf");
else if (oFile.OpenFile(sInterest + _T(".wmf")))
imgPath = sInterest + _T(".wmf");
}
}
}
if (0 == s.Find(_T("data:")))
{
// TODO:
}
current += 2 * _sLen;
curindex += 2 * _sLen;
m = (int*)current;
current += 4 * 4;
curindex += 4 * 4;
m1 = (*m++) / 100000.0;
m2 = (*m++) / 100000.0;
m3 = (*m++) / 100000.0;
m4 = (*m++) / 100000.0;
try
{
BSTR bsFile = imgPath.AllocSysString();
m_pRenderer->DrawImageFromFile(bsFile, m1, m2, m3, m4);
SysFreeString(bsFile);
}
catch (...)
{
}
break;
}
case ctFontName:
{
ms = (USHORT*)current;
current += 2;
curindex += 2;
_sLen = (int)(*ms);
CString s((WCHAR*)current, _sLen);
current += 2 * _sLen;
curindex += 2 * _sLen;
BSTR bsName = s.AllocSysString();
m_pRenderer->put_FontName(bsName);
SysFreeString(bsName);
break;
}
case ctFontSize:
{
m = (int*)current;
current += 4;
curindex += 4;
m1 = (*m++) / 100000.0;
// PDF
m_pRenderer->put_FontSize(min(m1, 1000));
break;
}
case ctFontStyle:
{
m = (int*)current;
current += 4;
curindex += 4;
m_pRenderer->put_FontStyle(*m);
break;
}
case ctDrawText:
{
ms = (USHORT*)current;
current += 2;
curindex += 2;
_sLen = (int)(*ms);
CString s((WCHAR*)current, _sLen);
current += 2 * _sLen;
curindex += 2 * _sLen;
m = (int*)current;
current += 2 * 4;
curindex += 2 * 4;
m1 = (*m++) / 100000.0;
m2 = (*m++) / 100000.0;
BSTR bsText = s.AllocSysString();
m_pRenderer->CommandDrawText(bsText, m1, m2, 0, 0, 0);
SysFreeString(bsText);
break;
}
case ctBeginCommand:
{
m = (int*)current;
current += 4;
curindex += 4;
if (bIsPDF)
{
if (bIsPathOpened)
{
m_pRenderer->PathCommandEnd();
m_pRenderer->EndCommand(4);
bIsPathOpened = false;
}
m_pRenderer->BeginCommand(*m);
}
else
{
m_pRenderer->BeginCommand(*m);
}
break;
}
case ctEndCommand:
{
m = (int*)current;
current += 4;
curindex += 4;
if (bIsPDF)
{
if (bIsPathOpened)
{
m_pRenderer->PathCommandEnd();
m_pRenderer->EndCommand(4);
bIsPathOpened = false;
}
m_pRenderer->EndCommand(*m);
m_pRenderer->PathCommandEnd();
}
else
{
m_pRenderer->EndCommand(*m);
}
break;
}
default:
break;
};
//if (nCountPages == 1 && eCommand == CommandType.ctPageEnd)
// break;
}
/*
if (NULL != m_pPainter)
{
VARIANT var;
var.vt = VT_I4;
m_pPainter->SetAdditionalParam(L"OnCompletePage", var);
}
*/
}
};
\ No newline at end of file
//Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define COMPONENT_NAME "DoctRenderer"
#include "../Common/FileInfo.h"
#include "version.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
LANGUAGE 25, 1
#pragma code_page(1251)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION INTVER
PRODUCTVERSION INTVER
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", COMPANY_NAME
VALUE "FileDescription", FILE_DESCRIPTION_ACTIVEX
VALUE "FileVersion", STRVER
VALUE "LegalCopyright", LEGAL_COPYRIGHT
VALUE "InternalName", COMPONENT_FILE_NAME_DLL
VALUE "OriginalFilename", COMPONENT_FILE_NAME_DLL
VALUE "ProductName", FILE_DESCRIPTION_ACTIVEX
VALUE "ProductVersion", STRVER
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 0x04B0
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_PROJNAME "DoctRenderer"
END
IDR_DOCTRENDERER REGISTRY "DoctRenderer.rgs"
////////////////////////////////////////////////////////////////////////////
#endif
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'DoctRenderer'
'DoctRenderer.DLL'
{
val AppID = s '%APPID%'
}
}
}

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DoctRenderer", "DoctRenderer.vcxproj", "{BC0A8A11-2017-473D-8AB1-86A55116A2F5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BC0A8A11-2017-473D-8AB1-86A55116A2F5}.Debug|Win32.ActiveCfg = Debug|Win32
{BC0A8A11-2017-473D-8AB1-86A55116A2F5}.Debug|Win32.Build.0 = Debug|Win32
{BC0A8A11-2017-473D-8AB1-86A55116A2F5}.Release|Win32.ActiveCfg = Release|Win32
{BC0A8A11-2017-473D-8AB1-86A55116A2F5}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="DoctRenderer"
ProjectGUID="{BC0A8A11-2017-473D-8AB1-86A55116A2F5}"
Keyword="AtlProj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine=""
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/DoctRenderer.tlb"
HeaderFileName="Control.h"
DLLDataFileName=""
InterfaceIdentifierFileName="DoctRenderer_i.c"
ProxyFileName="DoctRenderer_p.c"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL;_ATL_ATTRIBUTES"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1049"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
UseLibraryDependencyInputs="false"
OutputFile="$(OutDir)/DoctRenderer.dll"
LinkIncremental="2"
MergedIDLBaseFileName="_DoctRenderer.idl"
GenerateDebugInformation="true"
SubSystem="2"
ImportLibrary="$(OutDir)/DoctRenderer.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Performing registration"
CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="..\Redist\VersionControl.exe &quot;$(ProjectDir)\version.h&quot;"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/DoctRenderer.tlb"
HeaderFileName="Control.h"
DLLDataFileName=""
InterfaceIdentifierFileName="DoctRenderer_i.c"
ProxyFileName="DoctRenderer_p.c"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;_ATL_ATTRIBUTES"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1049"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
OutputFile="$(OutDir)/DoctRenderer.dll"
LinkIncremental="1"
MergedIDLBaseFileName="_DoctRenderer.idl"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/DoctRenderer.lib"
TargetMachine="1"
CLRThreadAttribute="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Performing registration"
CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;copy $(TargetPath) ..\Redist\DoctRenderer.dll&#x0D;&#x0A;"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\DoctRenderer.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\DocRenderer.h"
>
</File>
<File
RelativePath=".\DoctRenderer.h"
>
</File>
<File
RelativePath=".\NativeControl.h"
>
</File>
<File
RelativePath=".\Resource.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\version.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\DoctRenderer.rc"
>
</File>
<File
RelativePath=".\DoctRenderer.rgs"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
#pragma once
#include "stdafx.h"
#include "DocRenderer.h"
// string convert
static CString to_cstring(v8::Local<v8::Value> v)
{
v8::String::Value data(v);
const WCHAR* p = (WCHAR*)*data;
if (NULL == p)
return _T("");
return CString(p);
}
static CStringA to_cstringA(v8::Local<v8::Value> v)
{
v8::String::Utf8Value data(v);
const char* p = (char*)*data;
if (NULL == p)
return "";
return CStringA(p);
}
class CNativeControl
{
private:
CString m_strFilePath;
CString m_strFileId;
public:
CAtlArray<CString>* m_pChanges;
CString m_strFontsDirectory;
CString m_strImagesDirectory;
CString m_strEditorType;
int m_nCurrentChangesNumber;
int m_nMaxChangesNumber;
BYTE* m_pSaveBinary;
int m_nSaveLen;
int m_nSaveBinaryLen;
CStringA m_sHeader;
public:
CMemoryStream* m_pStream;
CNativeControl()
{
m_pStream = NULL;
m_pChanges = NULL;
m_nCurrentChangesNumber = -1;
m_nMaxChangesNumber = -1;
m_pSaveBinary = NULL;
m_nSaveLen = 0;
m_nSaveBinaryLen = 0;
}
~CNativeControl()
{
RELEASEOBJECT(m_pStream);
m_pChanges = NULL;
RELEASEARRAYOBJECTS(m_pSaveBinary);
m_nSaveLen = 0;
}
public:
void Save_Alloc(int nLen)
{
m_nSaveLen = nLen;
m_pSaveBinary = new BYTE[m_nSaveLen];
memset(m_pSaveBinary, 0xFF, m_nSaveLen);
}
void Save_ReAlloc(int pos, int len)
{
BYTE* pOld = m_pSaveBinary;
m_nSaveLen = len;
m_pSaveBinary = new BYTE[m_nSaveLen];
memcpy(m_pSaveBinary, pOld, pos);
RELEASEARRAYOBJECTS(pOld);
}
void Save_End(CStringA sHeader, int len)
{
m_sHeader = sHeader;
m_nSaveBinaryLen = len;
}
void Save_Destroy()
{
RELEASEARRAYOBJECTS(m_pSaveBinary);
m_nSaveLen = 0;
m_nSaveBinaryLen = 0;
}
public:
void getFileData(CString& strFile, BYTE*& pData, DWORD& dwLen)
{
CFile oFile;
oFile.OpenFile(strFile);
dwLen = (DWORD)oFile.GetFileSize();
pData = (BYTE*)malloc((size_t)dwLen);
oFile.ReadFile(pData, dwLen);
}
void SetFilePath(const CString& strPath)
{
m_strFilePath = strPath;
}
CString GetFilePath()
{
return m_strFilePath;
}
void SetFileId(const CString& strId)
{
m_strFileId = strId;
}
CString GetFileId()
{
return m_strFileId;
}
void ConsoleLog(CString& strVal)
{
#if 0
FILE* f = fopen("C:\\log.txt", "a+");
fprintf(f, (CStringA)strVal);
fprintf(f, "\n");
fclose(f);
#endif
}
};
// wrap_methods -------------
CNativeControl* unwrap_nativeobject(v8::Handle<v8::Object> obj)
{
v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(obj->GetInternalField(0));
return static_cast<CNativeControl*>(field->Value());
}
void _GetFilePath(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CNativeControl* pNative = unwrap_nativeobject(args.This());
args.GetReturnValue().Set(v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), (uint16_t*)pNative->GetFilePath().GetBuffer()));
}
void _SetFilePath(const v8::FunctionCallbackInfo<v8::Value>& args)
{
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
if (args.Length() < 1)
return;
CNativeControl* pNative = unwrap_nativeobject(args.This());
pNative->SetFilePath(to_cstring(args[0]));
}
void _GetFontsDirectory(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CNativeControl* pNative = unwrap_nativeobject(args.This());
args.GetReturnValue().Set(v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), (uint16_t*)pNative->m_strFontsDirectory.GetBuffer()));
}
void _GetEditorType(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CNativeControl* pNative = unwrap_nativeobject(args.This());
args.GetReturnValue().Set(v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), (uint16_t*)pNative->m_strEditorType.GetBuffer()));
}
void _GetChangesCount(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CNativeControl* pNative = unwrap_nativeobject(args.This());
int nCount = 0;
if (pNative->m_pChanges != NULL)
nCount = (int)pNative->m_pChanges->GetCount();
args.GetReturnValue().Set(v8::Integer::New(v8::Isolate::GetCurrent(), nCount));
}
void _GetChangesFile(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CNativeControl* pNative = unwrap_nativeobject(args.This());
if (args.Length() < 1)
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
v8::Local<v8::Int32> intValue = args[0]->ToInt32();
int nIndex = (int)intValue->Value();
CString strFile = _T("");
if (pNative->m_pChanges != NULL)
strFile = pNative->m_pChanges->GetAt((size_t)nIndex);
args.GetReturnValue().Set(v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), (uint16_t*)strFile.GetBuffer()));
}
void _GetFileId(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CNativeControl* pNative = unwrap_nativeobject(args.This());
args.GetReturnValue().Set(v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), (uint16_t*)pNative->GetFileId().GetBuffer()));
}
void _SetFileId(const v8::FunctionCallbackInfo<v8::Value>& args)
{
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
if (args.Length() < 1)
return;
CNativeControl* pNative = unwrap_nativeobject(args.This());
pNative->SetFileId(to_cstring(args[0]));
}
void _CheckNextChange(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CNativeControl* pNative = unwrap_nativeobject(args.This());
pNative->m_nCurrentChangesNumber++;
if (-1 != pNative->m_nMaxChangesNumber)
{
if (pNative->m_nCurrentChangesNumber >= pNative->m_nMaxChangesNumber)
{
args.GetReturnValue().Set(v8::Boolean::New(v8::Isolate::GetCurrent(), false));
return;
}
}
args.GetReturnValue().Set(v8::Boolean::New(v8::Isolate::GetCurrent(), true));
}
void _GetFileArrayBuffer(const v8::FunctionCallbackInfo<v8::Value>& args)
{
if (args.Length() < 1)
{
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
return;
}
CNativeControl* pNative = unwrap_nativeobject(args.This());
BYTE* pData = NULL;
DWORD len = 0;
pNative->getFileData(to_cstring(args[0]), pData, len);
v8::Local<v8::ArrayBuffer> _buffer = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), (void*)pData, (size_t)len);
v8::Local<v8::Uint8Array> _array = v8::Uint8Array::New(_buffer, 0, (size_t)len);
args.GetReturnValue().Set(_array);
}
void _GetFontArrayBuffer(const v8::FunctionCallbackInfo<v8::Value>& args)
{
if (args.Length() < 1)
{
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
return;
}
CNativeControl* pNative = unwrap_nativeobject(args.This());
BYTE* pData = NULL;
DWORD len = 0;
CString strDir = pNative->m_strFontsDirectory;
if (strDir != _T(""))
strDir += _T("\\");
strDir += to_cstring(args[0]);
pNative->getFileData(strDir, pData, len);
v8::Local<v8::ArrayBuffer> _buffer = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), (void*)pData, (size_t)len);
v8::Local<v8::Uint8Array> _array = v8::Uint8Array::New(_buffer, 0, (size_t)len);
args.GetReturnValue().Set(_array);
}
void _GetFileString(const v8::FunctionCallbackInfo<v8::Value>& args)
{
if (args.Length() < 1)
{
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
return;
}
CNativeControl* pNative = unwrap_nativeobject(args.This());
BYTE* pData = NULL;
DWORD len = 0;
pNative->getFileData(to_cstring(args[0]), pData, len);
args.GetReturnValue().Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), (char*)pData, v8::String::kNormalString, len));
}
void _Save_AllocNative(const v8::FunctionCallbackInfo<v8::Value>& args)
{
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
if (args.Length() < 1)
return;
CNativeControl* pNative = unwrap_nativeobject(args.This());
v8::Local<v8::Int32> intValue = args[0]->ToInt32();
int nLen = (int)intValue->Value();
pNative->Save_Alloc(nLen);
v8::Local<v8::ArrayBuffer> _buffer = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), (void*)pNative->m_pSaveBinary, (size_t)pNative->m_nSaveLen);
v8::Local<v8::Uint8Array> _array = v8::Uint8Array::New(_buffer, 0, (size_t)pNative->m_nSaveLen);
args.GetReturnValue().Set(_array);
}
void _Save_ReAllocNative(const v8::FunctionCallbackInfo<v8::Value>& args)
{
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
if (args.Length() < 2)
return;
CNativeControl* pNative = unwrap_nativeobject(args.This());
int _pos = args[0]->Int32Value();
int _len = args[1]->Int32Value();
pNative->Save_ReAlloc(_pos, _len);
v8::Local<v8::ArrayBuffer> _buffer = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), (void*)pNative->m_pSaveBinary, (size_t)pNative->m_nSaveLen);
v8::Local<v8::Uint8Array> _array = v8::Uint8Array::New(_buffer, 0, (size_t)pNative->m_nSaveLen);
args.GetReturnValue().Set(_array);
}
void _Save_End(const v8::FunctionCallbackInfo<v8::Value>& args)
{
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
if (args.Length() < 2)
return;
CNativeControl* pNative = unwrap_nativeobject(args.This());
CStringA sHeader = to_cstringA(args[0]);
int _len = args[1]->Int32Value();
pNative->Save_End(sHeader, _len);
}
void _ConsoleLog(const v8::FunctionCallbackInfo<v8::Value>& args)
{
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
if (args.Length() < 1)
return;
CNativeControl* pNative = unwrap_nativeobject(args.This());
pNative->ConsoleLog(to_cstring(args[0]));
}
v8::Handle<v8::ObjectTemplate> CreateNativeControlTemplate(v8::Isolate* isolate)
{
//v8::HandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New();
result->SetInternalFieldCount(1); // CNativeControl
v8::Isolate* current = v8::Isolate::GetCurrent();
// -
result->Set(v8::String::NewFromUtf8(current, "SetFilePath"), v8::FunctionTemplate::New(current, _SetFilePath));
result->Set(v8::String::NewFromUtf8(current, "GetFilePath"), v8::FunctionTemplate::New(current, _GetFilePath));
result->Set(v8::String::NewFromUtf8(current, "SetFileId"), v8::FunctionTemplate::New(current, _SetFileId));
result->Set(v8::String::NewFromUtf8(current, "GetFileId"), v8::FunctionTemplate::New(current, _GetFileId));
result->Set(v8::String::NewFromUtf8(current, "GetFileBinary"), v8::FunctionTemplate::New(current, _GetFileArrayBuffer));
result->Set(v8::String::NewFromUtf8(current, "GetFontBinary"), v8::FunctionTemplate::New(current, _GetFontArrayBuffer));
result->Set(v8::String::NewFromUtf8(current, "GetFontsDirectory"), v8::FunctionTemplate::New(current, _GetFontsDirectory));
result->Set(v8::String::NewFromUtf8(current, "GetFileString"), v8::FunctionTemplate::New(current, _GetFileString));
result->Set(v8::String::NewFromUtf8(current, "GetEditorType"), v8::FunctionTemplate::New(current, _GetEditorType));
result->Set(v8::String::NewFromUtf8(current, "CheckNextChange"), v8::FunctionTemplate::New(current, _CheckNextChange));
result->Set(v8::String::NewFromUtf8(current, "GetCountChanges"), v8::FunctionTemplate::New(current, _GetChangesCount));
result->Set(v8::String::NewFromUtf8(current, "GetChangesFile"), v8::FunctionTemplate::New(current, _GetChangesFile));
result->Set(v8::String::NewFromUtf8(current, "Save_AllocNative"), v8::FunctionTemplate::New(current, _Save_AllocNative));
result->Set(v8::String::NewFromUtf8(current, "Save_ReAllocNative"), v8::FunctionTemplate::New(current, _Save_ReAllocNative));
result->Set(v8::String::NewFromUtf8(current, "Save_End"), v8::FunctionTemplate::New(current, _Save_End));
result->Set(v8::String::NewFromUtf8(current, "ConsoleLog"), v8::FunctionTemplate::New(current, _ConsoleLog));
// , HandleScope
// "" HandleScope - handle_scope
//return handle_scope.Close(result);
return result;
}
// --------------------------
// create work with arraytypes
class MallocArrayBufferAllocator : public v8::ArrayBuffer::Allocator
{
public:
virtual void* Allocate(size_t length)
{
void* ret = malloc(length);
memset(ret, 0, length);
return ret;
}
virtual void* AllocateUninitialized(size_t length)
{
return malloc(length);
}
virtual void Free(void* data, size_t length)
{
free(data);
}
};
static void enableTypedArrays()
{
v8::V8::SetArrayBufferAllocator(new MallocArrayBufferAllocator());
}
enum CommandType
{
ctPenXML = 0,
ctPenColor = 1,
ctPenAlpha = 2,
ctPenSize = 3,
ctPenDashStyle = 4,
ctPenLineStartCap = 5,
ctPenLineEndCap = 6,
ctPenLineJoin = 7,
ctPenDashPatern = 8,
ctPenDashPatternCount = 9,
ctPenDashOffset = 10,
ctPenAlign = 11,
ctPenMiterLimit = 12,
// brush
ctBrushXML = 20,
ctBrushType = 21,
ctBrushColor1 = 22,
ctBrushColor2 = 23,
ctBrushAlpha1 = 24,
ctBrushAlpha2 = 25,
ctBrushTexturePath = 26,
ctBrushTextureAlpha = 27,
ctBrushTextureMode = 28,
ctBrushRectable = 29,
ctBrushRectableEnabled = 30,
ctBrushGradient = 31,
// font
ctFontXML = 40,
ctFontName = 41,
ctFontSize = 42,
ctFontStyle = 43,
ctFontPath = 44,
ctFontGID = 45,
ctFontCharSpace = 46,
// shadow
ctShadowXML = 50,
ctShadowVisible = 51,
ctShadowDistanceX = 52,
ctShadowDistanceY = 53,
ctShadowBlurSize = 54,
ctShadowColor = 55,
ctShadowAlpha = 56,
// edge
ctEdgeXML = 70,
ctEdgeVisible = 71,
ctEdgeDistance = 72,
ctEdgeColor = 73,
ctEdgeAlpha = 74,
// text
ctDrawText = 80,
ctDrawTextEx = 81,
// pathcommands
ctPathCommandMoveTo = 91,
ctPathCommandLineTo = 92,
ctPathCommandLinesTo = 93,
ctPathCommandCurveTo = 94,
ctPathCommandCurvesTo = 95,
ctPathCommandArcTo = 96,
ctPathCommandClose = 97,
ctPathCommandEnd = 98,
ctDrawPath = 99,
ctPathCommandStart = 100,
ctPathCommandGetCurrentPoint = 101,
ctPathCommandText = 102,
ctPathCommandTextEx = 103,
// image
ctDrawImage = 110,
ctDrawImageFromFile = 111,
ctSetParams = 120,
ctBeginCommand = 121,
ctEndCommand = 122,
ctSetTransform = 130,
ctResetTransform = 131,
ctClipMode = 140,
ctCommandLong1 = 150,
ctCommandDouble1 = 151,
ctCommandString1 = 152,
ctCommandLong2 = 153,
ctCommandDouble2 = 154,
ctCommandString2 = 155,
ctPageWidth = 200,
ctPageHeight = 201,
ctPageStart = 202,
ctPageEnd = 203,
ctError = 255
};
class CChangesWorker
{
private:
BYTE* m_pData;
BYTE* m_pDataCur;
int m_nLen;
int m_nMaxUnionSize = 100 * 1024 * 1024; // 100Mb
v8::Local<v8::ArrayBuffer> m_oArrayBuffer;
int m_nFileType; // 0 - docx; 1 - excel
public:
CChangesWorker()
{
m_pData = NULL;
m_pDataCur = m_pData;
m_nLen = 0;
m_nFileType = 0;
}
~CChangesWorker()
{
if (NULL != m_pData)
delete[] m_pData;
}
void SetFormatChanges(const int& nFileType)
{
m_nFileType = nFileType;
}
public:
void CheckFiles(CAtlArray<CString>& oFiles)
{
int nMax = 0;
int nLen = 0;
int nCount = (int)oFiles.GetCount();
for (int i = 0; i < nCount; ++i)
{
CFile oFile;
oFile.OpenFile(oFiles[i]);
int nSize = (int)oFile.GetFileSize();
if (nMax < nSize)
nMax = nSize;
nLen += nSize;
oFile.CloseFile();
}
if (nLen <= m_nMaxUnionSize)
{
// -
m_nLen = nLen + 4;
}
else
{
m_nLen = nMax + 4;
if (m_nLen < m_nMaxUnionSize)
m_nLen = m_nMaxUnionSize;
}
m_pData = new BYTE[m_nLen];
m_pDataCur = m_pData;
m_oArrayBuffer = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), (void*)m_pData, (size_t)m_nLen);
}
inline int Open(CAtlArray<CString>& oFiles, int nStart)
{
return Open_excel(oFiles, nStart);
}
int Open_docx(CAtlArray<CString>& oFiles, int nStart)
{
m_pDataCur = m_pData;
m_pDataCur += 4;
int nCountData = 0;
int nCount = oFiles.GetCount();
int nLenCurrect = 0;
int i = nStart;
for (; i < nCount; i++)
{
CFile oFile;
oFile.OpenFile(oFiles[i]);
int nLen = (int)oFile.GetFileSize();
nLenCurrect += nLen;
if (nLenCurrect > m_nLen)
break;
char* pData = new char[nLen];
oFile.ReadFile((BYTE*)pData, nLen);
// parse data
int nCur = 0;
while (nCur < nLen)
{
// Id
skip_name(pData, nCur, nLen);
if (nCur >= nLen)
break;
int nId = read_int(pData, nCur, nLen);
*((int*)m_pDataCur) = nId;
m_pDataCur += 4;
// data
skip_name(pData, nCur, nLen);
skip_int2(pData, nCur, nLen);
read_base64(pData, nCur, nLen);
++nCur;
++nCountData;
}
delete[]pData;
}
*((int*)m_pData) = nCountData;
return i;
}
int Open_excel(CAtlArray<CString>& oFiles, int nStart)
{
m_pDataCur = m_pData;
m_pDataCur += 4;
int nCountData = 0;
int nCount = oFiles.GetCount();
int nLenCurrect = 0;
int i = nStart;
for (; i < nCount; i++)
{
CFile oFile;
oFile.OpenFile(oFiles[i]);
int nLen = (int)oFile.GetFileSize();
nLenCurrect += nLen;
if (nLenCurrect > m_nLen)
break;
char* pData = new char[nLen];
oFile.ReadFile((BYTE*)pData, nLen);
// parse data
int nCur = 0;
while (nCur < nLen)
{
skip_int2(pData, nCur, nLen);
if (nCur >= nLen)
break;
read_base64(pData, nCur, nLen);
++nCur;
++nCountData;
}
delete[]pData;
}
*((int*)m_pData) = nCountData;
return i;
}
v8::Local<v8::Uint8Array> GetData()
{
size_t len = (size_t)(m_pDataCur - m_pData);
v8::Local<v8::Uint8Array> _array = v8::Uint8Array::New(m_oArrayBuffer, 0, len);
return _array;
}
public:
void OpenFull(CAtlArray<CString>& oFiles)
{
//
int nCount = (int)oFiles.GetCount();
for (int i = 0; i < nCount; ++i)
{
CFile oFile;
oFile.OpenFile(oFiles[i]);
m_nLen += (int)oFile.GetFileSize();
oFile.CloseFile();
}
m_pData = new BYTE[m_nLen];
m_pDataCur = m_pData;
m_pDataCur += 4;
int nCountData = 0;
for (int i = 0; i < nCount; i++)
{
CFile oFile;
oFile.OpenFile(oFiles[i]);
int nLen = (int)oFile.GetFileSize();
char* pData = new char[nLen];
oFile.ReadFile((BYTE*)pData, nLen);
// parse data
int nCur = 0;
while (nCur < nLen)
{
// Id
skip_name(pData, nCur, nLen);
if (nCur >= nLen)
break;
int nId = read_int(pData, nCur, nLen);
*((int*)m_pDataCur) = nId;
m_pDataCur += 4;
// data
skip_name(pData, nCur, nLen);
skip_int2(pData, nCur, nLen);
read_base64(pData, nCur, nLen);
++nCur;
++nCountData;
}
delete[]pData;
}
*((int*)m_pData) = nCountData;
}
void OpenFull_excel(CAtlArray<CString>& oFiles)
{
//
int nCount = (int)oFiles.GetCount();
for (int i = 0; i < nCount; ++i)
{
CFile oFile;
oFile.OpenFile(oFiles[i]);
m_nLen += (int)oFile.GetFileSize();
oFile.CloseFile();
}
m_pData = new BYTE[m_nLen];
m_pDataCur = m_pData;
m_pDataCur += 4;
int nCountData = 0;
for (int i = 0; i < nCount; i++)
{
CFile oFile;
oFile.OpenFile(oFiles[i]);
int nLen = (int)oFile.GetFileSize();
char* pData = new char[nLen];
oFile.ReadFile((BYTE*)pData, nLen);
// parse data
int nCur = 0;
while (nCur < nLen)
{
skip_int2(pData, nCur, nLen);
if (nCur >= nLen)
break;
read_base64(pData, nCur, nLen);
++nCur;
++nCountData;
}
delete[]pData;
}
*((int*)m_pData) = nCountData;
}
v8::Local<v8::Uint8Array> GetDataFull()
{
size_t len = (size_t)(m_pDataCur - m_pData);
v8::Local<v8::ArrayBuffer> _buffer = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), (void*)m_pData, len);
v8::Local<v8::Uint8Array> _array = v8::Uint8Array::New(_buffer, 0, len);
return _array;
}
int OpenNative(CString strFile)
{
CFile oFile;
oFile.OpenFile(strFile);
int nLen = (int)oFile.GetFileSize();
char* pData = new char[nLen];
oFile.ReadFile((BYTE*)pData, nLen);
int nCur = 0;
// DOCY
skip_int2(pData, nCur, nLen);
// v
skip_no_digit(pData, nCur, nLen);
int nVersion = read_int2(pData, nCur, nLen);
m_nLen = read_int2(pData, nCur, nLen);
m_pData = new BYTE[m_nLen];
m_pDataCur = m_pData;
read_base64_2(pData, nCur, nLen);
delete[]pData;
return nVersion;
}
__forceinline void skip_name(const char* data, int& cur, const int& len)
{
int nCount = 0;
while (cur < len)
{
if (data[cur] == '\"')
++nCount;
++cur;
if (3 == nCount)
break;
}
}
__forceinline int read_int(const char* data, int& cur, const int& len)
{
int res = 0;
while (cur < len)
{
if (data[cur] == '\"')
{
++cur;
break;
}
res *= 10;
res += (data[cur++] - '0');
}
return res;
}
__forceinline void skip_int2(const char* data, int& cur, const int& len)
{
while (cur < len)
{
if (data[cur++] == ';')
break;
}
}
__forceinline int read_int2(const char* data, int& cur, const int& len)
{
int res = 0;
while (cur < len)
{
if (data[cur] == ';')
{
++cur;
break;
}
res *= 10;
res += (data[cur++] - '0');
}
return res;
}
__forceinline void skip_no_digit(const char* data, int& cur, const int& len)
{
while (cur < len)
{
char _c = data[cur];
if (_c >= '0' && _c <= '9')
break;
++cur;
}
}
__forceinline void read_base64(const char* data, int& cur, const int& len)
{
Base64Decode(data, cur, len);
}
__forceinline void read_base64_2(const char* data, int& cur, const int& len)
{
Base64Decode2(data, cur, len);
}
private:
__forceinline int DecodeBase64Char(unsigned int ch)
{
// returns -1 if the character is invalid
// or should be skipped
// otherwise, returns the 6-bit code for the character
// from the encoding table
if (ch >= 'A' && ch <= 'Z')
return ch - 'A' + 0; // 0 range starts at 'A'
if (ch >= 'a' && ch <= 'z')
return ch - 'a' + 26; // 26 range starts at 'a'
if (ch >= '0' && ch <= '9')
return ch - '0' + 52; // 52 range starts at '0'
if (ch == '+')
return 62;
if (ch == '/')
return 63;
return -1;
}
void Base64Decode(const char* data, int& cur, const int& len)
{
// walk the source buffer
// each four character sequence is converted to 3 bytes
// CRLFs and =, and any characters not in the encoding table
// are skiped
BYTE* pDataLen = m_pDataCur;
m_pDataCur += 4;
int nWritten = 0;
while (cur < len && data[cur] != '\"')
{
DWORD dwCurr = 0;
int i;
int nBits = 0;
for (i = 0; i<4; i++)
{
if (data[cur] == '\"')
break;
int nCh = DecodeBase64Char(data[cur++]);
if (nCh == -1)
{
// skip this char
i--;
continue;
}
dwCurr <<= 6;
dwCurr |= nCh;
nBits += 6;
}
// dwCurr has the 3 bytes to write to the output buffer
// left to right
dwCurr <<= 24 - nBits;
for (i = 0; i<nBits / 8; i++)
{
*m_pDataCur = (BYTE)((dwCurr & 0x00ff0000) >> 16);
++m_pDataCur;
dwCurr <<= 8;
nWritten++;
}
}
*((int*)pDataLen) = nWritten;
}
void Base64Decode2(const char* data, int& cur, const int& len)
{
// walk the source buffer
// each four character sequence is converted to 3 bytes
// CRLFs and =, and any characters not in the encoding table
// are skiped
int nWritten = 0;
while (cur < len && data[cur] != '\"')
{
DWORD dwCurr = 0;
int i;
int nBits = 0;
for (i = 0; i<4; i++)
{
if (cur >= len)
break;
int nCh = DecodeBase64Char(data[cur++]);
if (nCh == -1)
{
// skip this char
i--;
continue;
}
dwCurr <<= 6;
dwCurr |= nCh;
nBits += 6;
}
// dwCurr has the 3 bytes to write to the output buffer
// left to right
dwCurr <<= 24 - nBits;
for (i = 0; i<nBits / 8; i++)
{
*m_pDataCur = (BYTE)((dwCurr & 0x00ff0000) >> 16);
++m_pDataCur;
dwCurr <<= 8;
nWritten++;
}
}
}
};
//////////////////////////////////////////////////////////////////////////////
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by DoctRenderer.rc
//
#define IDS_PROJNAME 100
#define IDR_DOCTRENDERER 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 301
#define _APS_NEXT_COMMAND_VALUE 32768
#define _APS_NEXT_CONTROL_VALUE 201
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif
// stdafx.cpp : source file that includes just the standard includes
// JS_Executer.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef STRICT
#define STRICT
#endif
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off ATL's hiding of some common and often safely ignored warning messages
#define _ATL_ALL_WARNINGS
#pragma warning(disable: 4996)
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
#include <atlcoll.h>
#define _USE_LIBXML2_READER_
#pragma comment(lib, "libxml2.lib")
using namespace ATL;
#include "../ASCImageStudio3/ASCGraphics/Interfaces/ASCRenderer.h"
#import "..\Redist\ASCGraphics.dll" named_guids raw_interfaces_only rename_namespace("ASCGraphics"), exclude("IASCRenderer")
#import "..\Redist\ASCOfficePDFWriter.dll" named_guids raw_interfaces_only rename_namespace("PDFWriter"), exclude("IASCRenderer")
\ No newline at end of file
#pragma once
//1
//0
//0
//15
#define INTVER 1,0,0,15
#define STRVER "1,0,0,15\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