Commit 8ed7718d authored by Ivan.Shulga's avatar Ivan.Shulga Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52653 954022d7-b5bf-4e40-9824-e11837661b57
parent 0efce702
This diff is collapsed.

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AVSOfficeHtmlFileTest", "AVSOfficeHtmlFileTest\AVSOfficeHtmlFileTest.vcproj", "{CF94E1BC-859B-4DD7-B8E1-3F48567C6BD3}"
ProjectSection(ProjectDependencies) = postProject
{FC17489B-5B4F-469B-BC78-147B40EC6533} = {FC17489B-5B4F-469B-BC78-147B40EC6533}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AVSOfficeHtmlFile", "AVSOfficeHtmlFile\prj\AVSOfficeHtmlFile.vcproj", "{FC17489B-5B4F-469B-BC78-147B40EC6533}"
ProjectSection(ProjectDependencies) = postProject
{56F6B346-D0EA-4149-88C4-B6D09E0E9BA6} = {56F6B346-D0EA-4149-88C4-B6D09E0E9BA6}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Utility", "..\Common\AvsDocxFormat\Projects\Utility.vcproj", "{56F6B346-D0EA-4149-88C4-B6D09E0E9BA6}"
ProjectSection(ProjectDependencies) = postProject
{3C7D3E76-9C62-4D0E-9645-8731700B1D70} = {3C7D3E76-9C62-4D0E-9645-8731700B1D70}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boost_filesystem", "..\Common\AvsDocxFormat\Projects\boost_filesystem.vcproj", "{3C7D3E76-9C62-4D0E-9645-8731700B1D70}"
ProjectSection(ProjectDependencies) = postProject
{7A3C0AE1-9FA1-4F56-99C0-139192364F57} = {7A3C0AE1-9FA1-4F56-99C0-139192364F57}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boost_system", "..\Common\AvsDocxFormat\Projects\boost_system.vcproj", "{7A3C0AE1-9FA1-4F56-99C0-139192364F57}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CF94E1BC-859B-4DD7-B8E1-3F48567C6BD3}.Debug|Win32.ActiveCfg = Debug|Win32
{CF94E1BC-859B-4DD7-B8E1-3F48567C6BD3}.Debug|Win32.Build.0 = Debug|Win32
{CF94E1BC-859B-4DD7-B8E1-3F48567C6BD3}.Release|Win32.ActiveCfg = Release|Win32
{CF94E1BC-859B-4DD7-B8E1-3F48567C6BD3}.Release|Win32.Build.0 = Release|Win32
{FC17489B-5B4F-469B-BC78-147B40EC6533}.Debug|Win32.ActiveCfg = Debug|Win32
{FC17489B-5B4F-469B-BC78-147B40EC6533}.Debug|Win32.Build.0 = Debug|Win32
{FC17489B-5B4F-469B-BC78-147B40EC6533}.Release|Win32.ActiveCfg = Release|Win32
{FC17489B-5B4F-469B-BC78-147B40EC6533}.Release|Win32.Build.0 = Release|Win32
{56F6B346-D0EA-4149-88C4-B6D09E0E9BA6}.Debug|Win32.ActiveCfg = Debug|Win32
{56F6B346-D0EA-4149-88C4-B6D09E0E9BA6}.Debug|Win32.Build.0 = Debug|Win32
{56F6B346-D0EA-4149-88C4-B6D09E0E9BA6}.Release|Win32.ActiveCfg = Release|Win32
{56F6B346-D0EA-4149-88C4-B6D09E0E9BA6}.Release|Win32.Build.0 = Release|Win32
{3C7D3E76-9C62-4D0E-9645-8731700B1D70}.Debug|Win32.ActiveCfg = Debug|Win32
{3C7D3E76-9C62-4D0E-9645-8731700B1D70}.Debug|Win32.Build.0 = Debug|Win32
{3C7D3E76-9C62-4D0E-9645-8731700B1D70}.Release|Win32.ActiveCfg = Release|Win32
{3C7D3E76-9C62-4D0E-9645-8731700B1D70}.Release|Win32.Build.0 = Release|Win32
{7A3C0AE1-9FA1-4F56-99C0-139192364F57}.Debug|Win32.ActiveCfg = Debug|Win32
{7A3C0AE1-9FA1-4F56-99C0-139192364F57}.Debug|Win32.Build.0 = Debug|Win32
{7A3C0AE1-9FA1-4F56-99C0-139192364F57}.Release|Win32.ActiveCfg = Release|Win32
{7A3C0AE1-9FA1-4F56-99C0-139192364F57}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
#ifndef _BASE_64_H
#define _BASE_64_H
#include <iostream>
static const std::string c_sBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
class CBase64
{
public:
CBase64()
{
}
~CBase64()
{
}
BYTE* GetBuffer(void)
{
return (BYTE*)m_sBuffer.c_str();
}
int GetSize(void)
{
return m_sBuffer.length();
}
std::string GetString()
{
return m_sBuffer;
}
void Encode(BYTE *pBytesToEncode, unsigned int unSize)
{
m_sBuffer = Base64Encode( pBytesToEncode, unSize );
}
void Encode(BYTE **ppBytesToEncode, unsigned int *punSize)
{
Encode( *ppBytesToEncode, *punSize );
*punSize = GetSize();
delete [](*ppBytesToEncode);
*ppBytesToEncode = new BYTE[*punSize];
if ( !(*ppBytesToEncode) )
return;
::memcpy( *ppBytesToEncode, GetBuffer(), sizeof(BYTE) * *punSize );
}
void Decode(BYTE *pBytesToDecode, unsigned int unSize)
{
std::string sEncodedString;
for ( unsigned int unIndex = 0; unIndex < unSize; unIndex++ )
{
sEncodedString += pBytesToDecode[unIndex];
}
m_sBuffer = Base64Decode( sEncodedString );
}
void Decode(BYTE **ppBytesToDecode, unsigned int *punSize)
{
Decode( *ppBytesToDecode, *punSize );
*punSize = GetSize();
delete [](*ppBytesToDecode);
*ppBytesToDecode = new BYTE[*punSize];
if ( !(*ppBytesToDecode) )
return;
::memcpy( *ppBytesToDecode, GetBuffer(), sizeof(BYTE) * *punSize );
}
private:
inline bool IsBase64(unsigned char nChar)
{
return ( isalnum(nChar) || ( '+' == nChar ) || ( '/' == nChar ) );
}
std::string Base64Encode(unsigned char const *pBuffer, unsigned int unSize)
{
std::string sResult;
unsigned char arrChar_3[3];
unsigned char arrChar_4[4];
int nI = 0;
int nJ = 0;
while ( unSize-- )
{
arrChar_3[nI++] = *(pBuffer++);
if ( 3 == nI )
{
arrChar_4[0] = ( arrChar_3[0] & 0xfc ) >> 2;
arrChar_4[1] = ( ( arrChar_3[0] & 0x03 ) << 4 ) + ( ( arrChar_3[1] & 0xf0 ) >> 4);
arrChar_4[2] = ( ( arrChar_3[1] & 0x0f ) << 2 ) + ( ( arrChar_3[2] & 0xc0 ) >> 6);
arrChar_4[3] = arrChar_3[2] & 0x3f;
for( nI = 0; nI < 4 ; nI++ )
{
sResult += c_sBase64Chars[arrChar_4[nI]];
}
nI = 0;
}
}
if ( nI )
{
for( nJ = nI; nJ < 3; nJ++ )
{
arrChar_3[nJ] = '\0';
}
arrChar_4[0] = ( arrChar_3[0] & 0xfc ) >> 2;
arrChar_4[1] = ( ( arrChar_3[0] & 0x03 ) << 4 ) + ( ( arrChar_3[1] & 0xf0 ) >> 4 );
arrChar_4[2] = ( ( arrChar_3[1] & 0x0f ) << 2 ) + ( ( arrChar_3[2] & 0xc0 ) >> 6 );
arrChar_4[3] = arrChar_3[2] & 0x3f;
for ( nJ = 0; nJ < nI + 1; nJ++ )
{
sResult += c_sBase64Chars[arrChar_4[nJ]];
}
while( nI++ < 3 )
{
sResult += '=';
}
}
return sResult;
}
std::string Base64Decode(std::string const& sEncodedString)
{
std::string sResult;
int nSize = sEncodedString.size();
int nI = 0;
int nJ = 0;
int nPos = 0;
unsigned char arrChar_3[3];
unsigned char arrChar_4[4];
while ( nSize-- && ( sEncodedString[nPos] != '=' ) && IsBase64( sEncodedString[nPos] ) )
{
arrChar_4[nI++] = sEncodedString[nPos];
nPos++;
if ( 4 == nI )
{
for ( nI = 0; nI < 4; nI++ )
{
arrChar_4[nI] = c_sBase64Chars.find( arrChar_4[nI] );
}
arrChar_3[0] = ( arrChar_4[0] << 2 ) + ( ( arrChar_4[1] & 0x30 ) >> 4 );
arrChar_3[1] = ( ( arrChar_4[1] & 0xf ) << 4 ) + ( ( arrChar_4[2] & 0x3c ) >> 2 );
arrChar_3[2] = ( ( arrChar_4[2] & 0x3 ) << 6 ) + arrChar_4[3];
for ( nI = 0; nI < 3; nI++ )
{
sResult += arrChar_3[nI];
}
nI = 0;
}
}
if ( nI )
{
for ( nJ = nI; nJ < 4; nJ++ )
{
arrChar_4[nJ] = 0;
}
for ( nJ = 0; nJ < 4; nJ++)
{
arrChar_4[nJ] = c_sBase64Chars.find( arrChar_4[nJ] );
}
arrChar_3[0] = ( arrChar_4[0] << 2 ) + ( ( arrChar_4[1] & 0x30 ) >> 4 );
arrChar_3[1] = ( ( arrChar_4[1] & 0xf ) << 4 ) + ( ( arrChar_4[2] & 0x3c ) >> 2 );
arrChar_3[2] = ( ( arrChar_4[2] & 0x3 ) << 6 ) + arrChar_4[3];
for ( nJ = 0; nJ < nI - 1; nJ++ )
{
sResult += arrChar_3[nJ];
}
}
return sResult;
}
private:
std::string m_sBuffer;
};
#endif /* _BASE_64_H */
\ No newline at end of file
#pragma once
#include "atldefine.h"
//------------------------------------------------------------------------------------------------------
// CBaseThread
//------------------------------------------------------------------------------------------------------
// ,
//------------------------------------------------------------------------------------------------------
class CBaseThread
{
public :
CBaseThread ( DWORD_PTR dwAffinityMask = 0 )
: m_bRunThread ( FALSE )
, m_hThread ( NULL )
, m_lPercents ( 0 )
, m_lError ( NO_ERROR )
, m_sError ( "" )
, m_dwAffinityMask ( dwAffinityMask )
, m_bSuspend ( FALSE )
{
if ( 0 == m_dwAffinityMask )
{
DWORD_PTR dwProcessAffinityMask = 0;
DWORD_PTR dwSystemAffinityMask = 0;
if ( GetProcessAffinityMask ( GetCurrentProcess (), &dwProcessAffinityMask, &dwSystemAffinityMask ) )
m_dwAffinityMask = dwProcessAffinityMask;
}
}
virtual ~CBaseThread ()
{
StopWork ();
}
virtual void StartWork ( LONG lPriority )
{
// -
if ( m_bRunThread )
return;
m_lPercents = 0;
m_lError = NO_ERROR;
m_sError = "";
m_bSuspend = FALSE;
StartThread ();
SetThreadPriority ( m_hThread, lPriority );
m_lThreadPriority = lPriority;
}
virtual void SuspendWork ()
{
m_bSuspend = TRUE;
}
virtual void ResumeWork ()
{
m_bSuspend = FALSE;
}
virtual void StopWork ()
{
if ( !m_bRunThread )
return;
m_bRunThread = FALSE;
if ( NULL != m_hThread )
WaitForSingleObject ( m_hThread, INFINITE );
RELEASEHANDLE ( m_hThread );
}
virtual void WaitThread ()
{
if ( !m_bRunThread )
return;
if ( NULL != m_hThread )
WaitForSingleObject ( m_hThread, INFINITE );
m_bRunThread = FALSE;
RELEASEHANDLE ( m_hThread );
}
BOOL IsSuspended () const
{
return m_bSuspend;
}
BOOL IsRunned () const
{
return m_bRunThread;
}
LONG GetPercents () const
{
return m_lPercents;
}
LONG GetError () const
{
return m_lError;
}
CString GetErrorString () const
{
return m_sError;
}
HANDLE GetHandle ()
{
return m_hThread;
}
LONG GetPriority () const
{
return GetThreadPriority ( m_hThread );
}
protected :
void StartThread ()
{
DWORD dwTmp;
m_bRunThread = TRUE;
m_hThread = CreateThread ( NULL, 0, &_ThreadProc, ( LPVOID ) this, 0, &dwTmp );
SetThreadAffinityMask ( m_hThread, m_dwAffinityMask );
}
void CheckSuspend ()
{
// , 10
while ( m_bSuspend && m_bRunThread )
Sleep ( 10 );
}
static DWORD WINAPI CBaseThread::_ThreadProc ( LPVOID pv )
{
CBaseThread *pThis = ( CBaseThread* ) pv;
return pThis->ThreadProc ();
}
virtual DWORD ThreadProc () = 0;
protected :
HANDLE m_hThread; //
BOOL m_bRunThread; //
BOOL m_bSuspend; //
DWORD_PTR m_dwAffinityMask; //
LONG m_lError; //
CString m_sError; //
LONG m_lThreadPriority; //
LONG m_lPercents; //
};
#pragma once
#include "BaseThread.h"
#include <wininet.h>
#pragma comment(lib, "Wininet")
//------------------------------------------------------------------------------------------------------
//
#define MAX_SIZE 256
//
#define DOWNLOAD_FILE_SIZE 32768
#define MAX_SINGLE_DOWNLOAD_FILE_SIZE 524288
//
#define CONTENT_RANGE _T("bytes 0-0/")
// CONTENT_RANGE
#define CONTENT_RANGE_SIZE ( 11/*sizeof ( CONTENT_RANGE )*/ - 1 )
//------------------------------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------------------------------
class CFileDownloader : public CBaseThread
{
public :
CFileDownloader (CString sFileUrl, BOOL bDelete = TRUE) : CBaseThread(0)
{
m_pFile = NULL;
m_sFilePath = _T("");
m_sFileUrl = sFileUrl;
m_bComplete = FALSE;
m_bDelete = bDelete;
}
~CFileDownloader ()
{
if ( m_pFile )
{
::fclose( m_pFile );
m_pFile = NULL;
}
if ( m_sFilePath.GetLength() > 0 && m_bDelete )
{
DeleteFileW( m_sFilePath.GetBuffer() );
m_sFilePath = _T("");
}
}
CString GetFilePath()
{
return m_sFilePath;
}
BOOL IsFileDownloaded()
{
return m_bComplete;
}
protected :
unsigned int DownloadFile(CString sFileUrl)
{
//
if ( FALSE == InternetGetConnectedState ( 0, 0 ) )
return S_FALSE;
char sTempPath[MAX_PATH], sTempFile[MAX_PATH];
if ( 0 == GetTempPathA( MAX_PATH, sTempPath ) )
return S_FALSE;
if ( 0 == GetTempFileNameA( sTempPath, "CSS", 0, sTempFile ) )
return S_FALSE;
m_pFile = ::fopen( sTempFile, "wb" );
if ( !m_pFile )
return S_FALSE;
m_sFilePath = CString( sTempFile );
//
HINTERNET hInternetSession = InternetOpen ( _T ("Mozilla/4.0 (compatible; MSIE 5.0; Windows 98)"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
if ( NULL == hInternetSession )
return S_FALSE;
// ( 0 ( ) )
CString sHTTPHdr = _T ("Range: bytes=0-0");
// ,
HINTERNET hInternetOpenURL = InternetOpenUrl ( hInternetSession, sFileUrl, sHTTPHdr, -1, INTERNET_FLAG_RESYNCHRONIZE, 0 );
if ( NULL != hInternetOpenURL )
{
// ,
if ( TRUE == QueryStatusCode ( hInternetOpenURL, TRUE ) )
{
// ,
LONGLONG nFileSize = IsAccept_Ranges ( hInternetOpenURL );
//
InternetCloseHandle ( hInternetOpenURL );
if ( -1 == nFileSize )
{
//
//
InternetCloseHandle ( hInternetSession );
// ( DownloadAll)
//
return S_FALSE;
}
else
{
//
LONGLONG nStartByte = 0;
while ( m_bRunThread )
{
// -
if ( nStartByte == nFileSize - 1 )
{
//
InternetCloseHandle ( hInternetSession );
return S_OK;
}
LONGLONG nEndByte = nStartByte + DOWNLOAD_FILE_SIZE;
// , ( 1 , , .. 0 )
if ( nEndByte >= nFileSize )
nEndByte = nFileSize - 1;
//
BYTE arrBuffer [ DOWNLOAD_FILE_SIZE ] = { 0 };
DWORD dwBytesDownload = DownloadFilePath ( hInternetSession, arrBuffer, nStartByte, nEndByte, sFileUrl );
nStartByte = nEndByte;
if ( -1 == dwBytesDownload )
{
// - !!!!
//
InternetCloseHandle ( hInternetSession );
// ( DownloadAll)
//
return S_FALSE;
}
//
::fwrite( (BYTE*)arrBuffer, 1, dwBytesDownload, m_pFile );
::fflush( m_pFile );
//
CheckSuspend ();
}
}
}
else
{
//
InternetCloseHandle ( hInternetSession );
// ( DownloadAll)
//
return S_FALSE;
}
}
else
{
//
InternetCloseHandle ( hInternetSession );
// ( DownloadAll)
//
return S_FALSE;
}
//
InternetCloseHandle ( hInternetSession );
return S_OK;
}
DWORD DownloadFilePath ( HINTERNET hInternet, LPBYTE pBuffer, LONGLONG nStartByte, LONGLONG nEndByte, CString sFileURL )
{
//
if ( NULL == hInternet )
return -1;
//
if ( nStartByte > nEndByte || !pBuffer )
return -1;
// ( nEndByte - nStartByte )
CString sHTTPHdr = _T (""); sHTTPHdr.Format ( _T ("Range: bytes=%I64d-%I64d"), nStartByte, nEndByte );
//
HINTERNET hInternetOpenURL = InternetOpenUrl ( hInternet, sFileURL, sHTTPHdr, -1, INTERNET_FLAG_RESYNCHRONIZE, 0 );
if ( NULL == hInternetOpenURL )
return -1;
// ,
if ( FALSE == QueryStatusCode ( hInternetOpenURL, TRUE ) )
{
//
InternetCloseHandle ( hInternetOpenURL );
return -1;
}
//
DWORD dwBytesRead = 0;
//
if ( FALSE == InternetReadFile ( hInternetOpenURL, pBuffer, DOWNLOAD_FILE_SIZE, &dwBytesRead ) )
{
//
InternetCloseHandle ( hInternetOpenURL );
return -1;
}
//
InternetCloseHandle ( hInternetOpenURL );
return dwBytesRead;
}
virtual DWORD ThreadProc ()
{
m_bComplete = FALSE;
CoInitialize ( NULL );
if ( S_OK != DownloadFile ( m_sFileUrl ) )
{
HRESULT hrResultAll = DownloadFileAll(m_sFileUrl, m_sFilePath);
if (S_OK != hrResultAll)
{
m_bRunThread = FALSE;
CoUninitialize ();
return 0;
}
}
m_bRunThread = FALSE;
CoUninitialize ();
m_bComplete = TRUE;
return 0;
}
BOOL QueryStatusCode ( HINTERNET hInternet, BOOL bIsRanges )
{
// -
if ( NULL == hInternet )
return FALSE;
//
INT nResult = 0;
// ( = 4 )
DWORD dwLengthDataSize = 4;
// , - FALSE
if ( FALSE == HttpQueryInfo ( hInternet, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &nResult, &dwLengthDataSize, NULL ) )
return FALSE;
// ,
if ( HTTP_STATUS_NOT_FOUND == nResult )
{
// , -
return FALSE;
}
else if ( ( HTTP_STATUS_OK != nResult && FALSE == bIsRanges ) || ( HTTP_STATUS_PARTIAL_CONTENT != nResult && TRUE == bIsRanges ) )
{
// -
return FALSE;
}
// ,
return TRUE;
}
// , -1 ,
LONGLONG IsAccept_Ranges ( HINTERNET hInternet )
{
// -
if ( NULL == hInternet )
return -1;
//
char arrResult [ MAX_SIZE ] = { 0 };
//
DWORD dwLengthDataSize = sizeof ( arrResult );
// , - FALSE
if ( FALSE == HttpQueryInfoA ( hInternet, HTTP_QUERY_CONTENT_RANGE, &arrResult, &dwLengthDataSize, NULL ) )
{
//
DWORD dwLastError = GetLastError ();
if ( dwLastError == ERROR_HTTP_HEADER_NOT_FOUND )
{
// ,
return -1;
}
// - - FALSE
return -1;
}
// 0,
if ( 0 >= dwLengthDataSize )
return -1;
// CString
CString strResult ( arrResult );
//
LONGLONG nFileSize = 0;
try
{
//
INT nStartIndex = strResult.Find ( CONTENT_RANGE );
if ( -1 == nStartIndex )
return -1;
//
strResult = strResult.Mid ( nStartIndex + CONTENT_RANGE_SIZE );
// , LONGLONG
nFileSize = _wtoi64 ( strResult.GetBuffer () );
// .. 0 ( 1 )
if ( 0 < nFileSize )
nFileSize += 1;
}
catch ( ... )
{
//
return -1;
}
// , ,
return nFileSize;
}
HRESULT DownloadFileAll(CString sFileURL, CString strFileOutput)
{
if ( m_pFile )
{
::fclose( m_pFile );
m_pFile = NULL;
}
//
return URLDownloadToFile (NULL, sFileURL, strFileOutput, NULL, NULL);
}
public:
static bool IsNeedDownload(CString FilePath)
{
int n1 = FilePath.Find(_T("www."));
int n2 = FilePath.Find(_T("http://"));
int n3 = FilePath.Find(_T("ftp://"));
int n4 = FilePath.Find(_T("https://"));
if (((n1 >= 0) && (n1 < 10)) || ((n2 >= 0) && (n2 < 10)) || ((n3 >= 0) && (n3 < 10)) || ((n4 >= 0) && (n4 < 10)))
return true;
return false;
}
protected :
FILE *m_pFile; //
CString m_sFilePath; //
CString m_sFileUrl; //
BOOL m_bComplete; //
BOOL m_bDelete; //
};
#pragma once
#import "shdocvw.dll" exclude ("OLECMDID", "OLECMDF", "OLECMDEXECOPT", "tagREADYSTATE")
#include "shdocvw.tlh"
#include <string>
#include <excpt.h>
#include <map>
#include <io.h>
#include "CHtmlCSS.h"
#include "..\..\HTMLReaderLib\LiteHTMLConverter.h"
#include <vector>
#include "..\src\MhtFile.h"
using namespace CSS;
typedef std::map< std::wstring, std::wstring > wstrmap;
class CHtmlToXhtmlSax:
public IXHTMLWriter
{
public:
CHtmlToXhtmlSax (CString sHtmlPath, CString sXhtmlPath, const MhtFile* pMhtFile);
virtual ~CHtmlToXhtmlSax(void);
public:
void SetDownloadImages(BOOL bDownload);
CSimpleArray<CString> GetTempImages ();
void AddTempImages (CSimpleArray<CString> &tempImages);
static bool FileExist (CString *sFilePath);
void SetDefaultCodePage (int aDefaultCodePage = CP_ACP);
bool Convert ();
BOOL SaveXML ();
MSXML2::IXMLDOMNodePtr getDoc();
MSXML2::IXMLDOMNodePtr getHtml();
MSXML2::IXMLDOMNodePtr getBody();
void parseCSS (const std::wstring& sCSS);
void InsertPair (wstrmap& map, const std::wstring &key, const std::wstring &val);
void convertElementFont (CHTMLTagWrapper* pHtmlNode);
void convertElementBodyBackgroundImage (CHTMLTagWrapper* pHtmlNode, MSXML2::IXMLDOMElementPtr pXmlNode);
std::wstring getElementCSS (CHTMLTagWrapper* pHtmlNode);
std::wstring convertElementAttr (CHTMLTagWrapper* pHtmlNode, const std::wstring& attribute);
//std::wstring SetLowerStyleNames (const std::wstring& style);
_bstr_t FindAttribute (CHTMLTagWrapper* oElement, const _bstr_t bsAttrName, const _bstr_t bsDefaultValue = _bstr_t( L"" ));
_bstr_t getFilePath () const;
static CString delComment (CString& style);
bool LoadExternalCSS (CString sHref, std::wstring *pwsBuffer, CString sPath, BOOL bWeb);
void nodeHtmlToXhtml (CHTMLTagWrapper* pHtmlNode, MSXML2::IXMLDOMNodePtr pXmlNode, double dEmValue = 16.0);
BOOL AddAttributesToNode (CLiteHTMLElemAttr &oAttr, MSXML2::IXMLDOMElement *xml_element); // copy atributes from our class to msxml node
static CString convertBase64ToImage (CString &pBase64);
void RemoveInvalidChars (BSTR *pbsString);
void HtmlTagsToText (CStringA *psString);
//static const std::wstring file2ansi (const std::vector<std::string>& file, const bool flag);
int filter (unsigned int code, struct _EXCEPTION_POINTERS *ep);
bool loadFile(LPCBYTE dataptr, DWORD datasize);
// tools
static void setAttrs (int & width, int & height, Gdiplus::Bitmap& img);
static const std::wstring encoding (const std::wstring& line);
static const std::wstring loadCSS (const CString& sCSS);
//#pragma region IXHTMLWriter_impl
// IXHTMLWriter implementation
protected:
BOOL CloseTagPrefix (CHTMLTagWrapper *pPrevTagWrapper, bool aCloseTag = false);
virtual DWORD ErrorCode ();
virtual void SetOutput (CString &aOut);
virtual BOOL BeginFile ();
virtual BOOL StartTag (CHTMLTagWrapper *pTagWrapper, CHTMLTagWrapper *pPrevTagWrapper = NULL);
virtual BOOL EndTag (CHTMLTagWrapper *pTagWrapper);
virtual BOOL EndFile ();
virtual void Characters (CHTMLTagWrapper *pTagWrapper, CString aText, bool aBeforeLastChild);
//#pragma region IXHTMLWriter_impl
private:
bool m_bMht; // Mht?
MhtFile m_oMhtFile;
CLiteHTMLConverter m_oConverter;
CString m_sHtmlPath; // HTML .
BYTE* m_pBuffer; // , HTML .
DWORD m_dwBufferSize; // .
CString m_sXhtmlPath;
wstrmap m_mStyles [4]; // 4 categories of selector-style maps.
CHtmlCSSList m_oCssList;
BOOL m_bDownloadImages;
CSimpleArray<CString> m_arrImageFileName;
int m_nDefaultCodePage;
// 2oox-document.xsl <w:pgSz w:w="11906" w:h="16838" /><w:pgMar w:top="1134" w:right="850" w:bottom="1134" w:left="1701"...
// margin twips: width - 9355, height - 14570
// (twips = 20*pt) : width - 467,35, height - 728,5
// dpi 96: width - 623 height - 971
static const int m_cnPageWidthPx = 623;
static const int m_cnPageHeightPx = 971;
CComBSTR m_bsStyle;
CComBSTR m_bsTitle;
MSXML2::IXMLDOMDocumentPtr m_pXmlDoc;
MSXML2::IXMLDOMNodePtr m_pXmlHtmlNodePtr;
MSXML2::IXMLDOMNodePtr m_pXmlBodyNodePtr;
MSXML2::IXMLDOMNodePtr m_pXmlFramesetNodePtr;
MSXML2::IXMLDOMNodePtr m_pXmlHeadNodePtr;
MSXML2::IXMLDOMNodePtr m_pXmlTitleNodePtr;
MSXML2::IXMLDOMNodePtr m_pXmlStyleNodePtr;
// current parsed node
MSXML2::IXMLDOMNodePtr m_pXmlCurrentNodePtr;
private:
// preprocess tag (common)
BOOL ProcessTag (CHTMLTagWrapper *pTagWrapper);
//
// preprocess default tag
BOOL PreprocessDefaultTag (CHTMLTagWrapper *pTagWrapper, CString &sStyle, const double dEmValue = 16.0);
// preprocess table tag
BOOL PreprocessTable (CHTMLTagWrapper *pTagWrapper, CString &sStyle, const double dEmValue = 16.0);
// preprocess p tag
BOOL PreprocessP (CHTMLTagWrapper *pTagWrapper, CString &sStyle, const double dEmValue = 16.0);
// preprocess img tag
BOOL PreprocessImg (CHTMLTagWrapper *pTagWrapper, CString &sStyle, const double dEmValue = 16.0);
// preprocess a tag
BOOL PreprocessA (CHTMLTagWrapper *pTagWrapper, CString &sStyle, const double dEmValue = 16.0);
// preprocess <frameset> tag
BOOL PreprocessFrameset (CHTMLTagWrapper *pTagWrapper, CString &sStyle, const double dEmValue = 16.0);
// preprocess body tag
BOOL PreprocessBody (CHTMLTagWrapper *pTagWrapper, CString &sStyle, const double dEmValue = 16.0);
// preprocess frame tag
BOOL PreprocessFrame (CHTMLTagWrapper *pTagWrapper, CString &sStyle, const double dEmValue = 16.0);
// preprocess font tag
BOOL PreprocessFontTag (CHTMLTagWrapper *pTagWrapper, CString &sStyle, const double dEmValue = 16.0);
// preprocess text
BOOL PreprocessText (CHTMLTagWrapper *pParentTagWrapper, const CString aText, bool aBeforeLastChild);
// preprocess textarea tag
BOOL PreprocessTextarea (CHTMLTagWrapper *pTagWrapper, CString &sStyle, const double dEmValue = 16.0);
};
for %%a in (.\..\res\XSL\*.xsl) do .\..\..\..\..\..\Redist\AVSOfficeStudio\EncryptRes.exe -e %%a
pause
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'AVSOfficeHtmlFile'
'AVSOfficeHtmlFile.DLL'
{
val AppID = s '%APPID%'
}
}
}
========================================================================
ACTIVE TEMPLATE LIBRARY : AVSOfficeHtmlFile Project Overview
========================================================================
AppWizard has created this AVSOfficeHtmlFile project for you to use as the starting point for
writing your Dynamic Link Library (DLL).
This project is implemented with Visual C++ attributes.
This file contains a summary of what you will find in each of the files that
make up your project.
AVSOfficeHtmlFile.vcproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
_AVSOfficeHtmlFile.idl
This file will be generated by the compiler when the project is built. It will contain the IDL
definitions of the type library, the interfaces and co-classes defined in your project.
This file will be processed by the MIDL compiler to generate:
C++ interface definitions and GUID declarations (_AVSOfficeHtmlFile.h)
GUID definitions (_AVSOfficeHtmlFile_i.c)
A type library (_AVSOfficeHtmlFile.tlb)
Marshaling code (_AVSOfficeHtmlFile_p.c and dlldata.c)
AVSOfficeHtmlFile.cpp
This file contains the object map and the implementation of your DLL's exports.
AVSOfficeHtmlFile.rc
This is a listing of all of the Microsoft Windows resources that the
program uses.
AVSOfficeHtmlFile.def
This module-definition file provides the linker with information about the exports
required by your DLL. It contains exports for:
DllGetClassObject
DllCanUnloadNow
GetProxyDllInfo
DllRegisterServer
DllUnregisterServer
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named AVSOfficeHtmlFile.pch and a precompiled types file named StdAfx.obj.
Resource.h
This is the standard header file that defines resource IDs.
/////////////////////////////////////////////////////////////////////////////
Proxy/stub DLL project and module definition file:
AVSOfficeHtmlFileps.vcproj
This file is the project file for building a proxy/stub DLL if necessary.
The IDL file in the main project must contain at least one interface and you must
first compile the IDL file before building the proxy/stub DLL. This process generates
dlldata.c, AVSOfficeHtmlFile_i.c and AVSOfficeHtmlFile_p.c which are required
to build the proxy/stub DLL.
AVSOfficeHtmlFileps.def
This module definition file provides the linker with information about the exports
required by the proxy/stub.
/////////////////////////////////////////////////////////////////////////////
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
xmlns:pzip="urn:cleverage:xmlns:post-processings:zip"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:oox="urn:oox"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="office text fo style dc meta pzip xlink w oox">
<xsl:template name="InsertComment">
<xsl:param name="Id"/>
<!--<office:annotation>
<xsl:if test="key('Part', 'word/comments.xml')/w:comments/w:comment[@w:id = $Id]/@w:author">
<dc:creator>
<xsl:value-of select="key('Part', 'word/comments.xml')/w:comments/w:comment[@w:id = $Id]/@w:author"/>
</dc:creator>
</xsl:if>
<xsl:if test="key('Part', 'word/comments.xml')/w:comments/w:comment[@w:id = $Id]/@w:date">
<dc:date>
<xsl:value-of select="key('Part', 'word/comments.xml')/w:comments/w:comment[@w:id = $Id]/@w:date"/>
</dc:date>
</xsl:if>
<xsl:apply-templates select="key('Part', 'word/comments.xml')/w:comments/w:comment[@w:id = $Id]/w:p"/>
</office:annotation>-->
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Copyright (c) 2006, Clever Age
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Clever Age nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
xmlns:oox="urn:oox"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="w dc xlink oox">
<xsl:template match="w:font">
<style:font-face xmlns="http://www.w3.org/1999/xhtml">
<xsl:attribute name="style:name">
<xsl:value-of select="@w:name"/>
</xsl:attribute>
<xsl:if test="w:charset/@w:val='02'">
<xsl:attribute name="style:font-charset">
<xsl:text>x-symbol</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="svg:font-family">
<xsl:value-of select="@w:name"/>
</xsl:attribute>
<xsl:if test="w:family/@w:val != 'auto' ">
<xsl:attribute name="style:font-family-generic">
<xsl:value-of select="w:family/@w:val"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="w:family/@w:val = 'auto' ">
<xsl:attribute name="style:font-family-generic">system</xsl:attribute>
</xsl:if>
<xsl:if test="w:pitch/@w:val != 'default' ">
<xsl:attribute name="style:font-pitch">
<xsl:value-of select="w:pitch/@w:val"/>
</xsl:attribute>
</xsl:if>
</style:font-face>
</xsl:template>
</xsl:stylesheet>
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