Commit 2b4580eb authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

полностью работающая версия

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63649 954022d7-b5bf-4e40-9824-e11837661b57
parent ff97ae9a
......@@ -8,6 +8,9 @@ namespace NSHtmlRenderer
class CASCHTMLRenderer3_Private;
class CASCHTMLRenderer3 : public IRenderer
{
public:
CASCHTMLRenderer3();
virtual ~CASCHTMLRenderer3();
public:
// тип рендерера-----------------------------------------------------------------------------
virtual HRESULT get_Type(LONG* lType);
......
......@@ -316,6 +316,7 @@ namespace NSHtmlRenderer
public:
void LoadFontMetrics()
{
m_pManager->AfterLoad();
m_oFont.m_dAscent = m_pManager->m_lAscender;
m_oFont.m_dDescent = m_pManager->m_lDescender;
m_oFont.m_dLineSpacing = m_pManager->m_lLineHeight;
......
......@@ -67,6 +67,7 @@ namespace NSHtmlRenderer
m_pFontManager = NULL;
m_oWriter.SetSimpleConverter(&m_oSimpleGraphicsConverter, &m_oTransform);
m_oWriter.SetApplicationFonts(&m_oApplicationFonts);
m_bIsMetafileDrawing = false;
m_bIsTextGraphicType = false;
......@@ -210,6 +211,15 @@ namespace NSHtmlRenderer
}
};
CASCHTMLRenderer3::CASCHTMLRenderer3()
{
m_pInternal = new CASCHTMLRenderer3_Private();
}
CASCHTMLRenderer3::~CASCHTMLRenderer3()
{
RELEASEOBJECT(m_pInternal);
}
HRESULT CASCHTMLRenderer3::get_Type(LONG* lType)
{
*lType = c_nHtmlRendrerer2;
......
......@@ -280,6 +280,8 @@ namespace NSHtmlRenderer
// клип для картинок. для конвертации сложной векторной графики в растр
CMetafile m_oClipMetafile;
int m_nDEBUG_svg_index;
#ifdef USE_SIMPLE_GRAPHICS_NOSVG
CMetafile m_oVectors;
......@@ -332,6 +334,8 @@ namespace NSHtmlRenderer
m_bIsCurveToExist = false;
m_nDEBUG_svg_index = 0;
#ifdef USE_SIMPLE_GRAPHICS_NOSVG
m_bIsSimpleGraphics = true;
m_bIsSimpleSetupBrush = false;
......@@ -401,6 +405,24 @@ namespace NSHtmlRenderer
return m_oDocument.GetData();
}
void DEBUG_DumpSVG(const std::wstring& sTempPath)
{
std::wstring sEndDebug = L"";
int nCountWriteClips = m_oClip.m_lCountWriteClips;
while (nCountWriteClips > 0)
{
sEndDebug += L"</g>\n";
--nCountWriteClips;
}
sEndDebug += L"</svg>";
m_nDEBUG_svg_index++;
std::wstring sDocument = m_oDocument.GetData() + sEndDebug;
NSFile::CFileBinary::SaveToFile(sTempPath + L"/svg_" + std::to_wstring(m_nDEBUG_svg_index) + L".svg", sDocument);
}
void CloseFile2(std::wstring strFile, bool bIsNeedEnd = true)
{
if (bIsNeedEnd)
......
......@@ -396,6 +396,7 @@ namespace NSHtmlRenderer
public:
void LoadFontMetrics()
{
m_pManager->AfterLoad();
m_oCurrentInfo.m_lAscent = (m_pManager->m_lAscender < 0) ? ((USHORT)(-m_pManager->m_lAscender)) : (USHORT)m_pManager->m_lAscender;
m_oCurrentInfo.m_lDescent = (m_pManager->m_lDescender < 0) ? ((USHORT)(-m_pManager->m_lDescender)) : (USHORT)m_pManager->m_lDescender;
m_oCurrentInfo.m_lLineHeight = (m_pManager->m_lLineHeight < 0) ? ((USHORT)(-m_pManager->m_lLineHeight)) : (USHORT)m_pManager->m_lLineHeight;
......
......@@ -860,7 +860,7 @@ namespace NSHtmlRenderer
public:
void AddString(const int* sText, const int& len)
{
if (NULL == sText || 0 == len)
if (NULL != sText)
{
for (int i = 0; i < len; ++i)
{
......@@ -1114,7 +1114,7 @@ namespace NSHtmlRenderer
char* pOutput = NULL;
int nOutputLen = 0;
NSFile::CBase64Converter::Encode(pData, nInputLen, pOutput, nOutputLen);
NSFile::CBase64Converter::Encode(pData, nInputLen, pOutput, nOutputLen, NSBase64::B64_BASE64_FLAG_NOCRLF);
NSFile::CFileBinary oFileFontFileJS;
oFileFontFileJS.CreateFileW(sDstF + L"/embedded" + std::to_wstring(lIndex) + L".js");
......@@ -1204,6 +1204,8 @@ namespace NSHtmlRenderer
bool m_bIsGids;
CApplicationFonts* m_pApplicationFonts;
public:
double m_dWidth;
......@@ -1238,9 +1240,43 @@ namespace NSHtmlRenderer
bool m_bIsSimpleGraphics;
public:
void SetApplicationFonts(CApplicationFonts* pFonts)
CWriter()
{
m_dDpiX = 96.0;
m_dDpiY = 96.0;
m_dWidth = 0;
m_dHeight = 0;
m_lNextIDImage = 0;
m_lNextIDShape = 0;
m_lCurrentPage = -1;
m_bPathClosed = true;
m_pSimpleConverter = NULL;
m_lMaxSizeImage = 800;
m_dWidthDocMM = 0;
m_dHeightDocMM = 0;
m_dHeightPageMM = 0;
m_lPagesCount = 0;
m_bIsImageFromVectors = false;
m_lSrcFileType = 0;
m_bIsClipping = false;
m_bIsSimpleGraphics = false;
m_lTilingCounter = 0;
}
void SetApplicationFonts(CApplicationFonts* pFonts)
{
m_pApplicationFonts = pFonts;
}
void SetSimpleConverter(Aggplus::CGraphicsPathSimpleConverter* pSimpleConverter, Aggplus::CMatrix* pMatrix)
......@@ -1600,6 +1636,7 @@ namespace NSHtmlRenderer
}
else
{
pFrame->put_Data(NULL);
oInfo = pPair->second;
}
......@@ -1651,6 +1688,7 @@ namespace NSHtmlRenderer
int lWidth = pFrame->get_Width();
int lHeight = pFrame->get_Height();
bool bIsResized = false;
if (true || (lWidth <= m_lMaxSizeImage) && (lHeight <= m_lMaxSizeImage))
{
// не ресайзим
......@@ -1672,11 +1710,15 @@ namespace NSHtmlRenderer
lW = (LONG)(dAspect * lH);
}
bIsResized = true;
pFrame->Resize(lW, lH, bIsDestroy);
}
std::wstring strSave = m_strDstMedia + L"/image" + std::to_wstring(oInfo.m_lID) + ((itJPG == oInfo.m_eType) ? L".jpg" : L".png");
pFrame->SaveFile(strSave, (itJPG == oInfo.m_eType) ? 3 : 4);
if (!bIsDestroy && !bIsResized)
pFrame->put_Data(NULL);
}
inline void WriteImage2(NSHtmlRenderer::CImageInfo& oID, const double& x, const double& y, const double& w, const double& h)
......@@ -1792,6 +1834,10 @@ namespace NSHtmlRenderer
m_oSmartText.DumpLine();
SetTransformToDocument(true);
#if 0
m_oSVGWriter.DEBUG_DumpSVG(m_strDstMedia);
#endif
bool bIsBIG = false;
#ifdef USE_SIMPLE_GRAPHICS_NOSVG
......@@ -1995,7 +2041,7 @@ namespace NSHtmlRenderer
char* pOutput = NULL;
int nOutputLen = 0;
NSFile::CBase64Converter::Encode(pData, lSizeAll, pOutput, nOutputLen);
NSFile::CBase64Converter::Encode(pData, lSizeAll, pOutput, nOutputLen, NSBase64::B64_BASE64_FLAG_NOCRLF);
RELEASEARRAYOBJECTS(pData);
......@@ -2003,14 +2049,16 @@ namespace NSHtmlRenderer
sDstLen += ";";
NSFile::CFileBinary _file;
_file.CreateFile(m_strDstDirectoryFiles + L"/document.js");
_file.CreateFile(m_strDstDirectoryFiles + L"/Editor.bin");
_file.WriteFile((BYTE*)sDstLen.c_str(), (DWORD)sDstLen.length());
_file.WriteFile((BYTE*)pOutput, (DWORD)nOutputLen);
_file.CloseFile();
m_oDstFontGenerator.WriteFonts(NULL, m_strDstDirectoryFiles + L"/fonts", m_bIsGids);
::CFontManager* pFontManager = m_pApplicationFonts->GenerateFontManager();
m_oDstFontGenerator.WriteFonts(pFontManager, m_strDstDirectoryFiles + L"/fonts", m_bIsGids);
RELEASEOBJECT(pFontManager);
}
void CreateFile(std::wstring& strDir, std::wstring& strFileName)
......
......@@ -8,11 +8,13 @@ int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
std::wstring sFile = L"\\\\KIRILLOV8\\_Office\\PDF\\Android intro(2p).pdf";
//std::wstring sFile = L"\\\\KIRILLOV8\\_Office\\PDF\\Android intro(2p).pdf";
std::wstring sFile = L"\\\\kirillov8\\_Office\\PDF\\Main Window(15p).pdf";
CApplicationFonts oFonts;
oFonts.Initialize();
PdfReader::CPdfReader oReader(&oFonts);
oReader.SetTempFolder(L"D:\\test\\Document");
bool bResult = oReader.LoadFromFile(sFile.c_str());
NSHtmlRenderer::CASCHTMLRenderer3 oHtmlRenderer;
......@@ -21,15 +23,6 @@ int main(int argc, char *argv[])
int nPagesCount = oReader.GetPagesCount();
for (int i = 0; i < nPagesCount; ++i)
{
double dWidth = 0;
double dHeight = 0;
oReader.GetPageSize(i, &dWidth, &dHeight);
oHtmlRenderer.NewPage();
oHtmlRenderer.put_Width(dWidth);
oHtmlRenderer.put_Height(dHeight);
oReader.DrawPageOnRenderer(&oHtmlRenderer, i, NULL);
}
......
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