Commit 8e91112c authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander Trofimov

ASCHTMLRendererLib Linux build,некоторые файла переведены в utf8.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58853 954022d7-b5bf-4e40-9824-e11837661b57
parent 778b60d5
...@@ -167,7 +167,6 @@ ...@@ -167,7 +167,6 @@
/> />
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
Description=""
CommandLine="" CommandLine=""
/> />
</Configuration> </Configuration>
...@@ -226,10 +225,6 @@ ...@@ -226,10 +225,6 @@
RelativePath=".\Writer\Const.h" RelativePath=".\Writer\Const.h"
> >
</File> </File>
<File
RelativePath="..\DesktopEditor\editor\DibPainter.h"
>
</File>
<File <File
RelativePath=".\IBaseMatrixUpdater.h" RelativePath=".\IBaseMatrixUpdater.h"
> >
...@@ -242,10 +237,6 @@ ...@@ -242,10 +237,6 @@
<Filter <Filter
Name="Writer" Name="Writer"
> >
<File
RelativePath=".\Writer\CanvasWriter.h"
>
</File>
<File <File
RelativePath=".\Writer\StringWriter.h" RelativePath=".\Writer\StringWriter.h"
> >
......
#include "ASCSVGWriter.h" #include "ASCSVGWriter.h"
#include "../DesktopEditor/graphics/GraphicsPath.h" #include "../DesktopEditor/graphics/GraphicsPath.h"
#include "Writer/VectorGraphicsWriter2.h" #include "Writer/VectorGraphicsWriter2.h"
...@@ -32,7 +32,7 @@ namespace NSHtmlRenderer ...@@ -32,7 +32,7 @@ namespace NSHtmlRenderer
m_pTransform = new Aggplus::CMatrix(); m_pTransform = new Aggplus::CMatrix();
m_pFullTransform = new Aggplus::CMatrix(); m_pFullTransform = new Aggplus::CMatrix();
//todo , ? //todo вроде как подбора нет, но может нужно передавать?
m_pFontManager = new CFontManager(); m_pFontManager = new CFontManager();
m_pFontManager->Initialize(); m_pFontManager->Initialize();
...@@ -62,7 +62,7 @@ namespace NSHtmlRenderer ...@@ -62,7 +62,7 @@ namespace NSHtmlRenderer
*lType = c_nSVGRendrerer; *lType = c_nSVGRendrerer;
return S_OK; return S_OK;
} }
//-------- -------------------------------------------------- //-------- Функции для работы со страницей --------------------------------------------------
HRESULT CASCSVGWriter::NewPage() HRESULT CASCSVGWriter::NewPage()
{ {
return S_OK; return S_OK;
...@@ -393,7 +393,7 @@ namespace NSHtmlRenderer ...@@ -393,7 +393,7 @@ namespace NSHtmlRenderer
m_pFont->FaceIndex = lFaceIndex; m_pFont->FaceIndex = lFaceIndex;
return S_OK; return S_OK;
} }
//-------- -------------------------------------------------------- //-------- Функции для вывода текста --------------------------------------------------------
HRESULT CASCSVGWriter::CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset) HRESULT CASCSVGWriter::CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset)
{ {
//todo new command //todo new command
...@@ -433,7 +433,7 @@ namespace NSHtmlRenderer ...@@ -433,7 +433,7 @@ namespace NSHtmlRenderer
PathCommandEnd(); PathCommandEnd();
return S_OK; return S_OK;
} }
//-------- --------------------------------------------------------------- //-------- Маркеры для команд ---------------------------------------------------------------
HRESULT CASCSVGWriter::BeginCommand(const DWORD& lType) HRESULT CASCSVGWriter::BeginCommand(const DWORD& lType)
{ {
if (m_bIsRaster) if (m_bIsRaster)
...@@ -467,7 +467,7 @@ namespace NSHtmlRenderer ...@@ -467,7 +467,7 @@ namespace NSHtmlRenderer
m_lCurrentCommandType = -1; m_lCurrentCommandType = -1;
return S_OK; return S_OK;
} }
//-------- Graphics Path ----------------------------------------------- //-------- Функции для работы с Graphics Path -----------------------------------------------
HRESULT CASCSVGWriter::PathCommandMoveTo(const double& fX, const double& fY) HRESULT CASCSVGWriter::PathCommandMoveTo(const double& fX, const double& fY)
{ {
if (m_bIsRaster) if (m_bIsRaster)
...@@ -641,7 +641,7 @@ namespace NSHtmlRenderer ...@@ -641,7 +641,7 @@ namespace NSHtmlRenderer
m_pFont->StringGID = bGid; m_pFont->StringGID = bGid;
return S_OK; return S_OK;
} }
//-------- --------------------------------------------------- //-------- Функции для вывода изображений ---------------------------------------------------
HRESULT CASCSVGWriter::DrawImage(IGrObject* pImage, const double& fX, const double& fY, const double& fWidth, const double& fHeight) HRESULT CASCSVGWriter::DrawImage(IGrObject* pImage, const double& fX, const double& fY, const double& fWidth, const double& fHeight)
{ {
m_bIsRaster = true; m_bIsRaster = true;
...@@ -797,7 +797,7 @@ namespace NSHtmlRenderer ...@@ -797,7 +797,7 @@ namespace NSHtmlRenderer
} }
HRESULT CASCSVGWriter::IsRaster(bool* bVal) HRESULT CASCSVGWriter::IsRaster(bool* bVal)
{ {
*bVal = m_bIsRaster ? VARIANT_TRUE : VARIANT_FALSE; *bVal = m_bIsRaster;
return S_OK; return S_OK;
} }
// additiaonal params ---------------------------------------------------------------------- // additiaonal params ----------------------------------------------------------------------
...@@ -924,4 +924,4 @@ namespace NSHtmlRenderer ...@@ -924,4 +924,4 @@ namespace NSHtmlRenderer
*m_pInstalledFont = *m_pFont; *m_pInstalledFont = *m_pFont;
} }
} }
\ No newline at end of file
#pragma once #pragma once
#include "../DesktopEditor/graphics/IRenderer.h" #include "../DesktopEditor/graphics/IRenderer.h"
#include "IBaseMatrixUpdater.h" #include "IBaseMatrixUpdater.h"
...@@ -27,9 +27,9 @@ namespace NSHtmlRenderer ...@@ -27,9 +27,9 @@ namespace NSHtmlRenderer
~CASCSVGWriter(); ~CASCSVGWriter();
public: public:
// ----------------------------------------------------------------------------- // тип рендерера-----------------------------------------------------------------------------
HRESULT get_Type(LONG* lType); HRESULT get_Type(LONG* lType);
//-------- -------------------------------------------------- //-------- Функции для работы со страницей --------------------------------------------------
HRESULT NewPage(); HRESULT NewPage();
HRESULT get_Height(double* dHeight); HRESULT get_Height(double* dHeight);
HRESULT put_Height(const double& dHeight); HRESULT put_Height(const double& dHeight);
...@@ -101,18 +101,18 @@ namespace NSHtmlRenderer ...@@ -101,18 +101,18 @@ namespace NSHtmlRenderer
HRESULT get_FontFaceIndex(int* lFaceIndex); HRESULT get_FontFaceIndex(int* lFaceIndex);
HRESULT put_FontFaceIndex(const int& lFaceIndex); HRESULT put_FontFaceIndex(const int& lFaceIndex);
//-------- -------------------------------------------------------- //-------- Функции для вывода текста --------------------------------------------------------
HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset); HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset);
HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset); HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset);
HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags); HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags);
HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags); HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags);
//-------- --------------------------------------------------------------- //-------- Маркеры для команд ---------------------------------------------------------------
HRESULT BeginCommand(const DWORD& lType); HRESULT BeginCommand(const DWORD& lType);
HRESULT EndCommand(const DWORD& lType); HRESULT EndCommand(const DWORD& lType);
//-------- Graphics Path ----------------------------------------------- //-------- Функции для работы с Graphics Path -----------------------------------------------
HRESULT PathCommandMoveTo(const double& x, const double& y); HRESULT PathCommandMoveTo(const double& x, const double& y);
HRESULT PathCommandLineTo(const double& x, const double& y); HRESULT PathCommandLineTo(const double& x, const double& y);
HRESULT PathCommandLinesTo(double* points, const int& count); HRESULT PathCommandLinesTo(double* points, const int& count);
...@@ -131,7 +131,7 @@ namespace NSHtmlRenderer ...@@ -131,7 +131,7 @@ namespace NSHtmlRenderer
HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags); HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags);
HRESULT PathCommandTextEx(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags); HRESULT PathCommandTextEx(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags);
//-------- --------------------------------------------------- //-------- Функции для вывода изображений ---------------------------------------------------
HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h); HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h);
HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha); HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha);
...@@ -160,17 +160,17 @@ namespace NSHtmlRenderer ...@@ -160,17 +160,17 @@ namespace NSHtmlRenderer
NSHtmlRenderer::CSVGGraphicsWriter* m_pVectorWriter; NSHtmlRenderer::CSVGGraphicsWriter* m_pVectorWriter;
Aggplus::CGraphicsPathSimpleConverter* m_pSimpleGraphicsConverter; // Aggplus::CGraphicsPathSimpleConverter* m_pSimpleGraphicsConverter; // конвертер сложных гафических путей в простые
CFontManager* m_pFontManager; // CFontManager* m_pFontManager; // менеджер шрифтов
bool m_bDeleteFontManager; bool m_bDeleteFontManager;
Aggplus::CMatrix* m_pBaseTransform; // (: -> ) Aggplus::CMatrix* m_pBaseTransform; // матрица перерасчета координатных осей (здесь: миллиметры -> пикселы)
Aggplus::CMatrix* m_pTransform; // Aggplus::CMatrix* m_pTransform; // текущая матрица преобразований рендерера
Aggplus::CMatrix* m_pFullTransform; // (m_oBaseTransform * m_oTransform) Aggplus::CMatrix* m_pFullTransform; // полная матрица преобразований (m_oBaseTransform * m_oTransform)
double m_dTransformAngle; double m_dTransformAngle;
LONG m_lCurrentCommandType; // LONG m_lCurrentCommandType; // текущая команда
double m_dDpiX; double m_dDpiX;
double m_dDpiY; double m_dDpiY;
...@@ -180,7 +180,7 @@ namespace NSHtmlRenderer ...@@ -180,7 +180,7 @@ namespace NSHtmlRenderer
LONG m_lClipMode; LONG m_lClipMode;
NSStructures::CPen* m_pPen; // ( AVSGraphics) NSStructures::CPen* m_pPen; // настройки всей графики (скопирован ашник из AVSGraphics)
NSStructures::CBrush* m_pBrush; NSStructures::CBrush* m_pBrush;
NSStructures::CFont* m_pFont; NSStructures::CFont* m_pFont;
......
#include "CASCImage.h" #include "CASCImage.h"
#include "../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfFile.h" #include "../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfFile.h"
#include "../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/RendererOutput.h" #include "../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/RendererOutput.h"
...@@ -105,21 +105,21 @@ namespace NSHtmlRenderer ...@@ -105,21 +105,21 @@ namespace NSHtmlRenderer
} }
void CASCImage::Open(const std::wstring& bsFilePath) void CASCImage::Open(const std::wstring& bsFilePath)
{ {
// ( ) // Закроем раннее открытый файл (если он был открыт)
Close(); Close();
// WMF // Сначала попытаемя открыть файл как WMF
m_pWmfFile->OpenFromFile( bsFilePath.c_str() ); m_pWmfFile->OpenFromFile( bsFilePath.c_str() );
m_pWmfFile->Scan( m_pRect ); m_pWmfFile->Scan( m_pRect );
// // Файл открылся нормально
if ( !m_pWmfFile->CheckError() ) if ( !m_pWmfFile->CheckError() )
{ {
m_lImageType = c_lImageTypeMetafile | c_lMetaWmf; m_lImageType = c_lImageTypeMetafile | c_lMetaWmf;
return; return;
} }
// Wmf, Emf // Это не Wmf, попробуем открыть его как Emf
m_pWmfFile->Close(); m_pWmfFile->Close();
#ifdef _WIN32 #ifdef _WIN32
CGdiPlusInit oCGdiPlusInit; CGdiPlusInit oCGdiPlusInit;
...@@ -127,7 +127,7 @@ namespace NSHtmlRenderer ...@@ -127,7 +127,7 @@ namespace NSHtmlRenderer
Gdiplus::Metafile *pMetaFile = new Gdiplus::Metafile( bsFilePath.c_str() ); Gdiplus::Metafile *pMetaFile = new Gdiplus::Metafile( bsFilePath.c_str() );
if ( NULL != pMetaFile ) if ( NULL != pMetaFile )
{ {
// , Wmf Gdi // Похоже это метафайл, конвертируем его в Wmf с помощью Gdi
HENHMETAFILE hEmf = pMetaFile->GetHENHMETAFILE(); HENHMETAFILE hEmf = pMetaFile->GetHENHMETAFILE();
if ( NULL != hEmf ) if ( NULL != hEmf )
{ {
...@@ -155,17 +155,17 @@ namespace NSHtmlRenderer ...@@ -155,17 +155,17 @@ namespace NSHtmlRenderer
{ {
::fclose( pFile ); ::fclose( pFile );
// Wmf // Сохраняем Wmf
HMETAFILE hTempWmf = CopyMetaFile( hWmf, m_wsTempFilePath.GetBuffer() ); HMETAFILE hTempWmf = CopyMetaFile( hWmf, m_wsTempFilePath.GetBuffer() );
DeleteMetaFile( hTempWmf ); DeleteMetaFile( hTempWmf );
// Wmf // Открываем Wmf
m_pWmfFile->OpenFromFile( m_wsTempFilePath.GetBuffer() ); m_pWmfFile->OpenFromFile( m_wsTempFilePath.GetBuffer() );
m_pWmfFile->Scan( m_pRect ); m_pWmfFile->Scan( m_pRect );
if ( !m_pWmfFile->CheckError() ) if ( !m_pWmfFile->CheckError() )
{ {
// Wmf // Wmf нормально открылся
m_lImageType = c_lImageTypeMetafile | c_lMetaWmf; m_lImageType = c_lImageTypeMetafile | c_lMetaWmf;
DeleteMetaFile( hWmf ); DeleteMetaFile( hWmf );
...@@ -177,12 +177,12 @@ namespace NSHtmlRenderer ...@@ -177,12 +177,12 @@ namespace NSHtmlRenderer
} }
else if ( m_pWmfFile->UnSupportedWmf() ) else if ( m_pWmfFile->UnSupportedWmf() )
{ {
// Emf, Wmf // Исходный файл Emf, но после конвертации в Wmf он не открылся
m_lImageType = c_lImageTypeMetafile | c_lMetaEmf; m_lImageType = c_lImageTypeMetafile | c_lMetaEmf;
} }
else else
{ {
// // Сконвертированный файл не прочитался
m_pWmfFile->Close(); m_pWmfFile->Close();
m_lImageType = c_lImageTypeUnknown; m_lImageType = c_lImageTypeUnknown;
} }
...@@ -225,8 +225,8 @@ namespace NSHtmlRenderer ...@@ -225,8 +225,8 @@ namespace NSHtmlRenderer
//} //}
//else //else
{ {
// (Wmf/Emf) // Исходный файл не явлется метафайлом (Wmf/Emf)
// TODO: Bitmap // TODO: Сделать чтение Bitmap
m_pMediaData = new Aggplus::CImage(bsFilePath); m_pMediaData = new Aggplus::CImage(bsFilePath);
if(Aggplus::Ok != m_pMediaData->GetLastStatus()) if(Aggplus::Ok != m_pMediaData->GetLastStatus())
m_lImageType = c_lImageTypeBitmap; m_lImageType = c_lImageTypeBitmap;
...@@ -244,8 +244,15 @@ namespace NSHtmlRenderer ...@@ -244,8 +244,15 @@ namespace NSHtmlRenderer
m_pWmfFile->Close(); m_pWmfFile->Close();
if ( m_lImageType & c_lMetaEmf ) if ( m_lImageType & c_lMetaEmf )
{ {
// // Удаляем временный файл
::_wunlink( m_wsTempFilePath.GetBuffer() ); //todo может проверять не пустой ли m_wsTempFilePath, а не m_lImageType & c_lMetaEmf
#ifdef _WIN32
::_wunlink( m_wsTempFilePath.GetBuffer() );
#else
std::string sTempFilePath = U_TO_UTF8(m_wsTempFilePath);
::unlink( sTempFilePath.c_str() );
#endif
} }
} }
...@@ -335,7 +342,7 @@ namespace NSHtmlRenderer ...@@ -335,7 +342,7 @@ namespace NSHtmlRenderer
} }
HRESULT CASCImage::LoadFromFile(const std::wstring& bsFilePath) HRESULT CASCImage::LoadFromFile(const std::wstring& bsFilePath)
{ {
// Open Close // Внутри комманды Open выполняется команда Close
Open( bsFilePath ); Open( bsFilePath );
return S_OK; return S_OK;
...@@ -438,4 +445,4 @@ namespace NSHtmlRenderer ...@@ -438,4 +445,4 @@ namespace NSHtmlRenderer
{ {
return m_pMediaData; return m_pMediaData;
} }
} }
\ No newline at end of file
#include "CASCSVGRenderer.h" #include "CASCSVGRenderer.h"
#include "../DesktopEditor/graphics/GraphicsPath.h" #include "../DesktopEditor/graphics/GraphicsPath.h"
#include "Writer/StringWriter.h" #include "Writer/StringWriter.h"
#include "CMetafile.h" #include "CMetafile.h"
...@@ -30,22 +30,22 @@ namespace NSSVG ...@@ -30,22 +30,22 @@ namespace NSSVG
namespace NSHtmlRenderer namespace NSHtmlRenderer
{ {
static CString g_string_svgOpen = _T("<svg width=\"%dpx\" height=\"%dpx\" viewBox=\"0 0 %d %d\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"); static CString g_string_svgOpen = _T("<svg width=\"%dpx\" height=\"%dpx\" viewBox=\"0 0 %d %d\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n");
static _bstr_t g_bstr_svgClose = L"</svg>"; static CString g_bstr_svgClose = L"</svg>";
static CString g_string_image = _T("<image x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" xlink:href=\"%s\" preserveAspectRatio=\"none\"/>\n"); static CString g_string_image = _T("<image x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" xlink:href=\"%s\" preserveAspectRatio=\"none\"/>\n");
static _bstr_t g_bstr_graphicOpen = L"<g>\n"; static CString g_bstr_graphicOpen = L"<g>\n";
static _bstr_t g_bstr_graphicClose = L"</g>\n"; static CString g_bstr_graphicClose = L"</g>\n";
static _bstr_t g_bstr_path_d = L" d=\""; static CString g_bstr_path_d = L" d=\"";
static _bstr_t g_bstr_path_d_end = L"\" "; static CString g_bstr_path_d_end = L"\" ";
static _bstr_t g_bstr_vml_ClosePath = L"Z "; static CString g_bstr_vml_ClosePath = L"Z ";
static CString g_string_vml_MoveTo = _T("M %d,%d "); static CString g_string_vml_MoveTo = _T("M %d,%d ");
static CString g_string_vml_LineTo = _T("L %d,%d "); static CString g_string_vml_LineTo = _T("L %d,%d ");
static CString g_string_vml_CurveTo = _T("C %d,%d %d,%d %d,%d "); static CString g_string_vml_CurveTo = _T("C %d,%d %d,%d %d,%d ");
static _bstr_t g_bstr_vml_Path = L"<path "; static CString g_bstr_vml_Path = L"<path ";
static _bstr_t g_bstr_nodeClose = L" />\n"; static CString g_bstr_nodeClose = L" />\n";
static CString g_string_vml_StyleStroke = _T("style=\"fill:none;stroke:#%06x;stroke-width:%dpx;stroke-opacity:%.2lf\" "); static CString g_string_vml_StyleStroke = _T("style=\"fill:none;stroke:#%06x;stroke-width:%dpx;stroke-opacity:%.2lf\" ");
static CString g_string_vml_StyleStroke_class = _T("class=\"stroke%d\" style=\"fill:none;stroke-width:%dpx;stroke-opacity:%.2lf\" "); static CString g_string_vml_StyleStroke_class = _T("class=\"stroke%d\" style=\"fill:none;stroke-width:%dpx;stroke-opacity:%.2lf\" ");
static CString g_string_vml_StyleFill = _T("style=\"fill:#%06x;fill-opacity:%.2lf;fill-rule:%s;stroke:none\" "); static CString g_string_vml_StyleFill = _T("style=\"fill:#%06x;fill-opacity:%.2lf;fill-rule:%s;stroke:none\" ");
...@@ -106,7 +106,7 @@ namespace NSHtmlRenderer ...@@ -106,7 +106,7 @@ namespace NSHtmlRenderer
*lType = c_nSVGRendrerer; *lType = c_nSVGRendrerer;
return S_OK; return S_OK;
} }
//-------- -------------------------------------------------- //-------- Функции для работы со страницей --------------------------------------------------
HRESULT CASCSVGRenderer::NewPage() HRESULT CASCSVGRenderer::NewPage()
{ {
return S_OK; return S_OK;
...@@ -460,7 +460,7 @@ namespace NSHtmlRenderer ...@@ -460,7 +460,7 @@ namespace NSHtmlRenderer
m_pFont->FaceIndex = lFaceIndex; m_pFont->FaceIndex = lFaceIndex;
return S_OK; return S_OK;
} }
//-------- -------------------------------------------------------- //-------- Функции для вывода текста --------------------------------------------------------
HRESULT CASCSVGRenderer::CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset) HRESULT CASCSVGRenderer::CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset)
{ {
//todo new command //todo new command
...@@ -518,7 +518,7 @@ namespace NSHtmlRenderer ...@@ -518,7 +518,7 @@ namespace NSHtmlRenderer
m_pFont->StringGID = FALSE; m_pFont->StringGID = FALSE;
return CommandDrawText(bsUnicodeText, x, y, w, h, baselineOffset); return CommandDrawText(bsUnicodeText, x, y, w, h, baselineOffset);
} }
//-------- --------------------------------------------------------------- //-------- Маркеры для команд ---------------------------------------------------------------
HRESULT CASCSVGRenderer::BeginCommand(const DWORD& lType) HRESULT CASCSVGRenderer::BeginCommand(const DWORD& lType)
{ {
if (c_nClipType == lType) if (c_nClipType == lType)
...@@ -551,7 +551,7 @@ namespace NSHtmlRenderer ...@@ -551,7 +551,7 @@ namespace NSHtmlRenderer
return S_OK; return S_OK;
} }
//-------- Graphics Path ----------------------------------------------- //-------- Функции для работы с Graphics Path -----------------------------------------------
HRESULT CASCSVGRenderer::PathCommandMoveTo(const double& fX, const double& fY) HRESULT CASCSVGRenderer::PathCommandMoveTo(const double& fX, const double& fY)
{ {
if (c_nSimpleGraphicType == m_lCurrentCommandType) if (c_nSimpleGraphicType == m_lCurrentCommandType)
...@@ -793,7 +793,7 @@ namespace NSHtmlRenderer ...@@ -793,7 +793,7 @@ namespace NSHtmlRenderer
m_pFont->StringGID = FALSE; m_pFont->StringGID = FALSE;
return PathCommandText(bsUnicodeText, x, y, w, h, baselineOffset); return PathCommandText(bsUnicodeText, x, y, w, h, baselineOffset);
} }
//-------- --------------------------------------------------- //-------- Функции для вывода изображений ---------------------------------------------------
HRESULT CASCSVGRenderer::DrawImage(IGrObject* pImage, const double& fX, const double& fY, const double& fWidth, const double& fHeight) HRESULT CASCSVGRenderer::DrawImage(IGrObject* pImage, const double& fX, const double& fY, const double& fWidth, const double& fHeight)
{ {
double x = fX; double x = fX;
...@@ -823,7 +823,7 @@ namespace NSHtmlRenderer ...@@ -823,7 +823,7 @@ namespace NSHtmlRenderer
if ((1 == lFileType) || (2 == lFileType)) if ((1 == lFileType) || (2 == lFileType))
{ {
// // метафайл
oExt.DrawOnRenderer(this, sVal, fX, fY, fWidth, fHeight, TRUE); oExt.DrawOnRenderer(this, sVal, fX, fY, fWidth, fHeight, TRUE);
return S_OK; return S_OK;
} }
...@@ -930,7 +930,7 @@ namespace NSHtmlRenderer ...@@ -930,7 +930,7 @@ namespace NSHtmlRenderer
NSFile::CFileBinary oFile; NSFile::CFileBinary oFile;
if (S_OK == oFile.CreateFile(m_strDstFile)) if (S_OK == oFile.CreateFileW(m_strDstFile))
{ {
CString strData = m_pWriter->GetCString(); CString strData = m_pWriter->GetCString();
oFile.WriteFile((BYTE*)strData.GetBuffer(), sizeof(WCHAR) * strData.GetLength()); oFile.WriteFile((BYTE*)strData.GetBuffer(), sizeof(WCHAR) * strData.GetLength());
...@@ -1057,4 +1057,4 @@ namespace NSHtmlRenderer ...@@ -1057,4 +1057,4 @@ namespace NSHtmlRenderer
*m_pInstalledFont = *m_pFont; *m_pInstalledFont = *m_pFont;
} }
} }
\ No newline at end of file
#-------------------------------------------------
#
# Project created by QtCreator 2014-10-10T14:24:04
#
#-------------------------------------------------
QT -= core gui
TARGET = ASCHTMLRendererLib
TEMPLATE = lib
CONFIG += staticlib
QMAKE_CXXFLAGS += -std=c++11 -Wall -Wno-ignored-qualifiers -g
DEFINES += UNICODE _UNICODE _LINUX_QT NODOCX DESKTOP_EDITOR_GRAPHICS
INCLUDEPATH += \
../../DesktopEditor/freetype-2.5.2/include \
../../DesktopEditor/agg-2.4/include
SOURCES += ../ASCSVGWriter.cpp \
../CASCImage.cpp \
../CASCSVGRenderer.cpp \
../CMetafile.cpp \
HEADERS += ../ASCSVGWriter.h \
../CASCImage.h \
../CASCSVGRenderer.h \
../CMetafile.h \
../Writer/Common.h \
../Writer/Const.h \
../IBaseMatrixUpdater.h \
../Writer/TextItem.h \
../Writer/StringWriter.h \
../Writer/SVGWriter.h \
../Writer/VectorGraphicsWriter2.h \
../Writer/VMLWriter.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/RendererOutput.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfCharsets.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfCodePage932.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfCodePage936.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfCodePage949.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfCodePage950.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfCodePage1361.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfColor.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfFile.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfMemory.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfOutputDevice.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfRegion.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfTypes.h \
../../ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfUtils.h
unix {
target.path = /usr/lib
INSTALLS += target
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.1.2, 2014-10-14T12:16:08. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">-1</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
<value type="QByteArray">{dddbb3a8-974f-495c-bf78-01c688e01f07}</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">15</value>
</data>
</qtcreator>
...@@ -43,7 +43,8 @@ namespace NSHtmlRenderer ...@@ -43,7 +43,8 @@ namespace NSHtmlRenderer
} }
#ifdef _WIN32
#import "../Redist/ASCMediaCore3.dll" named_guids raw_interfaces_only rename_namespace("MediaCore"), exclude("tagRECT")
static RECT GetImageBounds(MediaCore::IAVSUncompressedVideoFrame* pFrame) static RECT GetImageBounds(MediaCore::IAVSUncompressedVideoFrame* pFrame)
{ {
BYTE* pBuffer = NULL; BYTE* pBuffer = NULL;
...@@ -244,6 +245,7 @@ namespace NSHtmlRenderer ...@@ -244,6 +245,7 @@ namespace NSHtmlRenderer
} }
#endif
const double c_ag_Inch_to_MM = 25.4; const double c_ag_Inch_to_MM = 25.4;
const double c_ag_1pxWidth = 25.4 / 96; const double c_ag_1pxWidth = 25.4 / 96;
...@@ -277,12 +279,12 @@ namespace NSHtmlRenderer ...@@ -277,12 +279,12 @@ namespace NSHtmlRenderer
} }
}; };
__forceinline static double FABS(double dVal) AVSINLINE static double FABS(double dVal)
{ {
return (dVal >= 0) ? dVal : -dVal; return (dVal >= 0) ? dVal : -dVal;
} }
__forceinline static int round(double dVal) AVSINLINE static int round(double dVal)
{ {
return (int)(dVal + 0.5); return (int)(dVal + 0.5);
} }
} }
\ No newline at end of file
This diff is collapsed.
#pragma once #pragma once
#include "..\stdafx.h" //#include "..\stdafx.h"
#include "StringWriter.h" #include "StringWriter.h"
#include <atlbase.h> #include <vector>
#include <atlcoll.h>
namespace NSHtmlRenderer namespace NSHtmlRenderer
{ {
using namespace NSStrings; using namespace NSStrings;
static CString g_svg_string_svgOpen = _T("<svg width=\"%dpx\" height=\"%dpx\" viewBox=\"0 0 %d %d\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"); static CString g_svg_string_svgOpen = _T("<svg width=\"%dpx\" height=\"%dpx\" viewBox=\"0 0 %d %d\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n");
static _bstr_t g_svg_bstr_svgClose = L"</svg>"; static CString g_svg_bstr_svgClose = L"</svg>";
static CString g_svg_string_image = _T("<image x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" xlink:href=\"%s\" preserveAspectRatio=\"none\"/>\n"); static CString g_svg_string_image = _T("<image x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" xlink:href=\"%s\" preserveAspectRatio=\"none\"/>\n");
static _bstr_t g_svg_bstr_graphicOpen = L"<g>\n"; static CString g_svg_bstr_graphicOpen = L"<g>\n";
static _bstr_t g_svg_bstr_graphicClose = L"</g>\n"; static CString g_svg_bstr_graphicClose = L"</g>\n";
static _bstr_t g_svg_bstr_path_d = L" d=\""; static CString g_svg_bstr_path_d = L" d=\"";
static _bstr_t g_svg_bstr_path_d_end = L"\" "; static CString g_svg_bstr_path_d_end = L"\" ";
static CString g_svg_string_clip = _T("clip-path=\"url(#clip%d)\" "); static CString g_svg_string_clip = _T("clip-path=\"url(#clip%d)\" ");
static CString g_svg_string_clipCreate = _T("<clipPath id=\"clip%d\"><path id=\"path%d\" d=\""); static CString g_svg_string_clipCreate = _T("<clipPath id=\"clip%d\"><path id=\"path%d\" d=\"");
static _bstr_t g_svg_bstr_clipendWinding = _T("\" clip-rule=\"nonzero\" /></clipPath>"); static CString g_svg_bstr_clipendWinding = _T("\" clip-rule=\"nonzero\" /></clipPath>");
static _bstr_t g_svg_bstr_clipendEvenodd = _T("\" clip-rule=\"evenodd\" /></clipPath>"); static CString g_svg_bstr_clipendEvenodd = _T("\" clip-rule=\"evenodd\" /></clipPath>");
static CString g_svg_string_gclip = _T("<g clip-path=\"url(#clip%d)\">"); static CString g_svg_string_gclip = _T("<g clip-path=\"url(#clip%d)\">");
static _bstr_t g_svg_bstr_vml_ClosePath = L"Z "; static CString g_svg_bstr_vml_ClosePath = L"Z ";
static CString g_svg_string_vml_MoveTo = _T("M %d,%d "); static CString g_svg_string_vml_MoveTo = _T("M %d,%d ");
static CString g_svg_string_vml_LineTo = _T("L %d,%d "); static CString g_svg_string_vml_LineTo = _T("L %d,%d ");
static CString g_svg_string_vml_CurveTo = _T("C %d,%d %d,%d %d,%d "); static CString g_svg_string_vml_CurveTo = _T("C %d,%d %d,%d %d,%d ");
static _bstr_t g_svg_bstr_vml_Path = L"<path "; static CString g_svg_bstr_vml_Path = L"<path ";
static _bstr_t g_svg_bstr_nodeClose = L" />\n"; static CString g_svg_bstr_nodeClose = L" />\n";
static CString g_svg_string_vml_StyleStrokeDash = _T("style=\"fill:none;stroke:#%06x;stroke-width:%dpx;stroke-opacity:%.2lf;stroke-dasharray: 2,2;\" "); static CString g_svg_string_vml_StyleStrokeDash = _T("style=\"fill:none;stroke:#%06x;stroke-width:%dpx;stroke-opacity:%.2lf;stroke-dasharray: 2,2;\" ");
static CString g_svg_string_vml_StyleStroke = _T("style=\"fill:none;stroke:#%06x;stroke-width:%dpx;stroke-opacity:%.2lf;\" "); static CString g_svg_string_vml_StyleStroke = _T("style=\"fill:none;stroke:#%06x;stroke-width:%dpx;stroke-opacity:%.2lf;\" ");
static CString g_svg_string_vml_StyleFill = _T("style=\"fill:#%06x;fill-opacity:%.2lf;fill-rule:%s;stroke:none\" "); static CString g_svg_string_vml_StyleFill = _T("style=\"fill:#%06x;fill-opacity:%.2lf;fill-rule:%s;stroke:none\" ");
...@@ -75,15 +74,15 @@ namespace NSHtmlRenderer ...@@ -75,15 +74,15 @@ namespace NSHtmlRenderer
static CString g_svg_string_vml_StyleTx = _T("style=\"fill:url(#pt%d);fill-opacity:%.2lf;fill-rule:%s;stroke:#%06x;stroke-width:%dpx;stroke-opacity:%.2lf\" "); static CString g_svg_string_vml_StyleTx = _T("style=\"fill:url(#pt%d);fill-opacity:%.2lf;fill-rule:%s;stroke:#%06x;stroke-width:%dpx;stroke-opacity:%.2lf\" ");
static CString g_svg_object_start = _T("<object class=\"_svg\" data=\"page%d.svg\" type=\"image/svg+xml\">"); static CString g_svg_object_start = _T("<object class=\"_svg\" data=\"page%d.svg\" type=\"image/svg+xml\">");
static _bstr_t g_svg_object_end = L"</object>"; static CString g_svg_object_end = L"</object>";
static CString g_string_intersect_clip = _T("<clipPath id=\"clip%d\" clip-path=\"url(#clip%d)\"><use x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" xlink:href=\"#path%d\"/></clipPath>"); static CString g_string_intersect_clip = _T("<clipPath id=\"clip%d\" clip-path=\"url(#clip%d)\"><use x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" xlink:href=\"#path%d\"/></clipPath>");
class CClipSVG class CClipSVG
{ {
public: public:
CAtlArray<CString> m_arPaths; std::vector<CString> m_arPaths;
CAtlArray<LONG> m_arTypes; std::vector<LONG> m_arTypes;
LONG m_lWidth; LONG m_lWidth;
LONG m_lHeight; LONG m_lHeight;
...@@ -99,8 +98,8 @@ namespace NSHtmlRenderer ...@@ -99,8 +98,8 @@ namespace NSHtmlRenderer
void Write(NSHtmlRenderer::CStringWriter& oWriter, LONG& lCurrentClipPath) void Write(NSHtmlRenderer::CStringWriter& oWriter, LONG& lCurrentClipPath)
{ {
// // сначала запишем все пути
size_t nCount = m_arPaths.GetCount(); size_t nCount = m_arPaths.size();
for (size_t i = 0; i < nCount; ++i) for (size_t i = 0; i < nCount; ++i)
{ {
...@@ -118,7 +117,7 @@ namespace NSHtmlRenderer ...@@ -118,7 +117,7 @@ namespace NSHtmlRenderer
} }
LONG lWritePathID = (LONG)lCurrentClipPath - 2; LONG lWritePathID = (LONG)lCurrentClipPath - 2;
// // теперь запишем пересечения
for (size_t i = 1; i < nCount; ++i) for (size_t i = 1; i < nCount; ++i)
{ {
CString strWrite = _T(""); CString strWrite = _T("");
...@@ -131,8 +130,8 @@ namespace NSHtmlRenderer ...@@ -131,8 +130,8 @@ namespace NSHtmlRenderer
void Write2(NSHtmlRenderer::CStringWriter& oWriter, LONG& lCurrentClipPath) void Write2(NSHtmlRenderer::CStringWriter& oWriter, LONG& lCurrentClipPath)
{ {
// // сначала запишем все пути
size_t nCount = m_arPaths.GetCount(); size_t nCount = m_arPaths.size();
double dMemoryClipTypes = 0; double dMemoryClipTypes = 0;
for (size_t i = 0; i < nCount; ++i) for (size_t i = 0; i < nCount; ++i)
{ {
...@@ -159,22 +158,22 @@ namespace NSHtmlRenderer ...@@ -159,22 +158,22 @@ namespace NSHtmlRenderer
++lCurrentClipPath; ++lCurrentClipPath;
} }
__forceinline void Clear() AVSINLINE void Clear()
{ {
m_arPaths.RemoveAll(); m_arPaths.clear();
m_arTypes.RemoveAll(); m_arTypes.clear();
} }
__forceinline bool IsInit() AVSINLINE bool IsInit()
{ {
return (0 != m_arPaths.GetCount()); return (0 != m_arPaths.size());
} }
}; };
class CClipSVG2 class CClipSVG2
{ {
public: public:
CAtlArray<CString> m_arPaths; std::vector<CString> m_arPaths;
CAtlArray<LONG> m_arTypes; std::vector<LONG> m_arTypes;
LONG m_lWidth; LONG m_lWidth;
LONG m_lHeight; LONG m_lHeight;
...@@ -194,8 +193,8 @@ namespace NSHtmlRenderer ...@@ -194,8 +193,8 @@ namespace NSHtmlRenderer
void Write(NSHtmlRenderer::CStringWriter& oWriter, LONG& lCurrentClipPath) void Write(NSHtmlRenderer::CStringWriter& oWriter, LONG& lCurrentClipPath)
{ {
// // сначала запишем все пути
size_t nCount = m_arPaths.GetCount(); size_t nCount = m_arPaths.size();
LONG lOld = lCurrentClipPath; LONG lOld = lCurrentClipPath;
for (size_t i = 0; i < nCount; ++i) for (size_t i = 0; i < nCount; ++i)
...@@ -232,14 +231,14 @@ namespace NSHtmlRenderer ...@@ -232,14 +231,14 @@ namespace NSHtmlRenderer
} }
} }
__forceinline void Clear() AVSINLINE void Clear()
{ {
m_arPaths.RemoveAll(); m_arPaths.clear();
m_arTypes.RemoveAll(); m_arTypes.clear();
} }
__forceinline bool IsInit() AVSINLINE bool IsInit()
{ {
return (0 != m_arPaths.GetCount()); return (0 != m_arPaths.size());
} }
}; };
...@@ -319,9 +318,12 @@ namespace NSHtmlRenderer ...@@ -319,9 +318,12 @@ namespace NSHtmlRenderer
m_oDocument.WriteString(g_svg_bstr_svgClose); m_oDocument.WriteString(g_svg_bstr_svgClose);
//CDirectory::SaveToFile(strFile, m_oDocument.GetCString()); //CDirectory::SaveToFile(strFile, m_oDocument.GetCString());
NSFile::CFileBinary oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(std::wstring(strFile.GetString())); oFile.CreateFileW(std::wstring(strFile.GetString()));
CStringA strA(m_oDocument.GetBuffer(), (int)m_oDocument.GetCurSize()); BYTE* pData;
oFile.WriteFile((BYTE*)strA.GetBuffer(), strA.GetLength()); LONG nDataSize;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(m_oDocument.GetBuffer(), m_oDocument.GetCurSize(), pData, nDataSize);
oFile.WriteFile(pData, nDataSize);
RELEASEARRAYOBJECTS(pData);
} }
if (3000000 < m_oDocument.GetSize()) if (3000000 < m_oDocument.GetSize())
...@@ -557,7 +559,7 @@ namespace NSHtmlRenderer ...@@ -557,7 +559,7 @@ namespace NSHtmlRenderer
int _w = round(r - x); int _w = round(r - x);
int _h = round(b - y); int _h = round(b - y);
// // пока заглушка
return WriteImage(oInfo, _x, _y, _w, _h, dAngle); return WriteImage(oInfo, _x, _y, _w, _h, dAngle);
CString strPattern = _T(""); CString strPattern = _T("");
...@@ -656,8 +658,8 @@ namespace NSHtmlRenderer ...@@ -656,8 +658,8 @@ namespace NSHtmlRenderer
if (0 == m_oPath.GetCurSize()) if (0 == m_oPath.GetCurSize())
return; return;
m_oClip.m_arPaths.Add(m_oPath.GetCString()); m_oClip.m_arPaths.push_back(m_oPath.GetCString());
m_oClip.m_arTypes.Add(m_lClipMode); m_oClip.m_arTypes.push_back(m_lClipMode);
} }
void WritePathResetClip() void WritePathResetClip()
{ {
...@@ -786,4 +788,4 @@ namespace NSHtmlRenderer ...@@ -786,4 +788,4 @@ namespace NSHtmlRenderer
} }
} }
}; };
} }
\ No newline at end of file
...@@ -47,11 +47,6 @@ namespace NSStrings ...@@ -47,11 +47,6 @@ namespace NSStrings
public: public:
AVSINLINE void WriteString(_bstr_t& bsString)
{
size_t nLen = bsString.length();
CTextItem::WriteString(bsString.GetBSTR(), nLen);
}
AVSINLINE void WriteString(CString& sString) AVSINLINE void WriteString(CString& sString)
{ {
size_t nLen = (size_t)sString.GetLength(); size_t nLen = (size_t)sString.GetLength();
......
#pragma once #pragma once
#include "../stdafx.h" //#include "../stdafx.h"
#ifdef _WIN32
#include <atlbase.h>
#include <atlcom.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#ifndef AVSINLINE #ifndef AVSINLINE
#if defined(_MSC_VER) #if defined(_MSC_VER)
...@@ -99,7 +106,7 @@ namespace NSStrings ...@@ -99,7 +106,7 @@ namespace NSStrings
{ {
if (NULL == m_pData) if (NULL == m_pData)
{ {
m_lSize = max(nSize, 1000); m_lSize = nSize > 1000 ? nSize : 1000;
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t)); m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
m_lSizeCur = 0; m_lSizeCur = 0;
...@@ -117,7 +124,7 @@ namespace NSStrings ...@@ -117,7 +124,7 @@ namespace NSStrings
wchar_t* pRealloc = (wchar_t*)realloc(m_pData, m_lSize * sizeof(wchar_t)); wchar_t* pRealloc = (wchar_t*)realloc(m_pData, m_lSize * sizeof(wchar_t));
if (NULL != pRealloc) if (NULL != pRealloc)
{ {
// // реаллок сработал
m_pData = pRealloc; m_pData = pRealloc;
m_pDataCur = m_pData + m_lSizeCur; m_pDataCur = m_pData + m_lSizeCur;
} }
...@@ -139,11 +146,6 @@ namespace NSStrings ...@@ -139,11 +146,6 @@ namespace NSStrings
{ {
WriteString(oTemp.m_pData, oTemp.m_lSizeCur); WriteString(oTemp.m_pData, oTemp.m_lSizeCur);
} }
AVSINLINE void operator+=(_bstr_t& oTemp)
{
size_t nLen = oTemp.length();
WriteString(oTemp.GetBSTR(), nLen);
}
AVSINLINE void operator+=(CString& oTemp) AVSINLINE void operator+=(CString& oTemp)
{ {
size_t nLen = (size_t)oTemp.GetLength(); size_t nLen = (size_t)oTemp.GetLength();
...@@ -216,7 +218,7 @@ namespace NSStrings ...@@ -216,7 +218,7 @@ namespace NSStrings
} }
public: public:
AVSINLINE void WriteString(wchar_t* pString, const size_t& nLen) AVSINLINE void WriteString(const wchar_t* pString, const size_t& nLen)
{ {
AddSize(nLen); AddSize(nLen);
//memcpy(m_pDataCur, pString, nLen * sizeof(wchar_t)); //memcpy(m_pDataCur, pString, nLen * sizeof(wchar_t));
...@@ -253,9 +255,9 @@ namespace NSStrings ...@@ -253,9 +255,9 @@ namespace NSStrings
m_lSizeCur = 0; m_lSizeCur = 0;
} }
AVSINLINE size_t GetStringLen(wchar_t* pData) AVSINLINE size_t GetStringLen(const wchar_t* pData)
{ {
wchar_t* s = pData; const wchar_t* s = pData;
for (; *s != 0; ++s); for (; *s != 0; ++s);
return (size_t)(s - pData); return (size_t)(s - pData);
} }
...@@ -374,4 +376,4 @@ namespace NSStrings ...@@ -374,4 +376,4 @@ namespace NSStrings
++m_lSizeCur; ++m_lSizeCur;
} }
}; };
} }
\ No newline at end of file
#pragma once #pragma once
#include "..\stdafx.h" //#include "..\stdafx.h"
#include "StringWriter.h" #include "StringWriter.h"
namespace NSHtmlRenderer namespace NSHtmlRenderer
{ {
using namespace NSStrings; using namespace NSStrings;
static _bstr_t g_vml_bstr_ClosePath = L"x"; static CString g_vml_bstr_ClosePath = L"x";
static CString g_vml_string_MoveTo = _T("m%d,%d "); static CString g_vml_string_MoveTo = _T("m%d,%d ");
static CString g_vml_string_LineTo = _T("l%d,%d "); static CString g_vml_string_LineTo = _T("l%d,%d ");
static CString g_vml_string_CurveTo = _T("c%d,%d,%d,%d,%d,%d "); static CString g_vml_string_CurveTo = _T("c%d,%d,%d,%d,%d,%d ");
...@@ -24,7 +24,7 @@ namespace NSHtmlRenderer ...@@ -24,7 +24,7 @@ namespace NSHtmlRenderer
static CString g_vml_string_shape_image_png = _T("<v:image src=\"media/image%d.png\" style=\"left:%d;top:%d;width:%d;height:%d;\"/>"); static CString g_vml_string_shape_image_png = _T("<v:image src=\"media/image%d.png\" style=\"left:%d;top:%d;width:%d;height:%d;\"/>");
static CString g_vml_string_document = _T("<xml xmlns:v=\"urn:schemas-microsoft-com:vml\">\n<v:group id=\"page%d\" style=\"position: absolute; width:1; height:1;\" coordsize=\"1 1\">\n"); static CString g_vml_string_document = _T("<xml xmlns:v=\"urn:schemas-microsoft-com:vml\">\n<v:group id=\"page%d\" style=\"position: absolute; width:1; height:1;\" coordsize=\"1 1\">\n");
static _bstr_t g_vml_bstr_document_end = L"</v:group>\n</xml>"; static CString g_vml_bstr_document_end = L"</v:group>\n</xml>";
static CString g_vml_string_frame = _T("<v:vmlframe clip=\"true\" origin=\"0,0\" size=\"%d,%d\" src=\"page%d.vml#page%d\" unselectable=\"on\"/>\n"); static CString g_vml_string_frame = _T("<v:vmlframe clip=\"true\" origin=\"0,0\" size=\"%d,%d\" src=\"page%d.vml#page%d\" unselectable=\"on\"/>\n");
...@@ -82,9 +82,12 @@ namespace NSHtmlRenderer ...@@ -82,9 +82,12 @@ namespace NSHtmlRenderer
m_oDocument.WriteString(g_vml_bstr_document_end); m_oDocument.WriteString(g_vml_bstr_document_end);
//CDirectory::SaveToFile(strFile, m_oDocument.GetCString()); //CDirectory::SaveToFile(strFile, m_oDocument.GetCString());
NSFile::CFileBinary oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(std::wstring(strFile.GetString())); oFile.CreateFileW(std::wstring(strFile.GetString()));
CStringA strA(m_oDocument.GetBuffer(), (int)m_oDocument.GetCurSize()); BYTE* pData;
oFile.WriteFile((BYTE*)strA.GetBuffer(), strA.GetLength()); LONG nDataSize;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(m_oDocument.GetBuffer(), m_oDocument.GetCurSize(), pData, nDataSize);
oFile.WriteFile(pData, nDataSize);
RELEASEARRAYOBJECTS(pData);
} }
if (3000000 < m_oDocument.GetSize()) if (3000000 < m_oDocument.GetSize())
...@@ -297,4 +300,4 @@ namespace NSHtmlRenderer ...@@ -297,4 +300,4 @@ namespace NSHtmlRenderer
} }
} }
}; };
} }
\ No newline at end of file
#pragma once #pragma once
//#include "Const.h" //#include "Const.h"
#include "SVGWriter.h" #include "SVGWriter.h"
#include "VMLWriter.h" #include "VMLWriter.h"
#include "CanvasWriter.h" //#include "CanvasWriter.h"
#include "../DesktopEditor/graphics/GraphicsPath.h" #include "../../DesktopEditor/graphics/GraphicsPath.h"
namespace NSHtmlRenderer namespace NSHtmlRenderer
{ {
...@@ -13,7 +13,7 @@ namespace NSHtmlRenderer ...@@ -13,7 +13,7 @@ namespace NSHtmlRenderer
public: public:
CSVGWriter m_oSVG; CSVGWriter m_oSVG;
CVMLWriter m_oVML; CVMLWriter m_oVML;
CCanvasWriter m_oCanvas; //CCanvasWriter m_oCanvas;
Aggplus::CGraphicsPathSimpleConverter* m_pSimpleConverter; Aggplus::CGraphicsPathSimpleConverter* m_pSimpleConverter;
...@@ -29,7 +29,7 @@ namespace NSHtmlRenderer ...@@ -29,7 +29,7 @@ namespace NSHtmlRenderer
double m_dHeight; double m_dHeight;
public: public:
CVectorGraphicsWriter() : m_oSVG(), m_oVML(), m_oCanvas() CVectorGraphicsWriter() : m_oSVG(), m_oVML()/*, m_oCanvas()*/
{ {
m_pSimpleConverter = NULL; m_pSimpleConverter = NULL;
m_lCurrentObjectInPage = 0; m_lCurrentObjectInPage = 0;
...@@ -108,10 +108,10 @@ namespace NSHtmlRenderer ...@@ -108,10 +108,10 @@ namespace NSHtmlRenderer
} }
inline void WriteDrawPath(LONG lType, CImageInfo& oInfo, const double& dAngle) inline void WriteDrawPath(LONG lType, CImageInfo& oInfo, const double& dAngle)
{ {
// pdf // вот мега заглушка под некоторые таблицы из pdf
// , path - - . // проблема в том, что приходит path нулевой толщины - а след-но он не рисуется.
// . , // здесь это отслеживаем и правим пат. Не очень хорошо, так как всякие пунктирности
// - // в таких патах - теряются при таком подходе
if (0x00 == (lType & 0xFF)) if (0x00 == (lType & 0xFF))
{ {
double x = 0; double x = 0;
...@@ -196,7 +196,7 @@ namespace NSHtmlRenderer ...@@ -196,7 +196,7 @@ namespace NSHtmlRenderer
inline bool IsGraphics() inline bool IsGraphics()
{ {
// 10 // 10 цифр на номер страницы
return ((g_vml_string_document.GetLength() + 10) < (int)m_oVML.m_oDocument.GetCurSize()); return ((g_vml_string_document.GetLength() + 10) < (int)m_oVML.m_oDocument.GetCurSize());
} }
...@@ -307,8 +307,8 @@ namespace NSHtmlRenderer ...@@ -307,8 +307,8 @@ namespace NSHtmlRenderer
inline bool IsGraphics() inline bool IsGraphics()
{ {
// 10 // 10 цифр на номер страницы
return ((g_vml_string_document.GetLength() + 10) < (int)m_oSVG.m_oDocument.GetCurSize()); return ((g_vml_string_document.GetLength() + 10) < (int)m_oSVG.m_oDocument.GetCurSize());
} }
}; };
} }
\ No newline at end of file
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