Commit 6e3a49bb authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

Пересобран pdfreader для linux64 с исправленной ошибкой с fclose.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@64590 954022d7-b5bf-4e40-9824-e11837661b57
parent 25fb120e
...@@ -35,11 +35,9 @@ namespace PdfReader ...@@ -35,11 +35,9 @@ namespace PdfReader
if (NULL != wsFilePath) if (NULL != wsFilePath)
{ {
NSFile::CFileBinary oFile; pFile = NSFile::CFileBinary::OpenFileNative(wsFilePath, L"rb");
if (!oFile.OpenFile(wsFilePath)) if (!pFile)
return NULL; return NULL;
pFile = oFile.GetFileNative();
} }
else else
{ {
......
...@@ -49,15 +49,14 @@ namespace PdfReader ...@@ -49,15 +49,14 @@ namespace PdfReader
{ {
char sBuffer[64]; char sBuffer[64];
Unicode nUnicode = 0; Unicode nUnicode = 0;
NSFile::CFileBinary oFile; FILE* pFile = NSFile::CFileBinary::OpenFileNative(seFileName->GetWString(), L"rb");
if (!oFile.OpenFile(seFileName->GetWString())) if (!pFile)
{ {
// TO DO: Error "Couldn't open cidToUnicode file" // TO DO: Error "Couldn't open cidToUnicode file"
return NULL; return NULL;
} }
FILE* pFile = oFile.GetFileNative();
unsigned int nSize = 32768; unsigned int nSize = 32768;
Unicode *pMap = (Unicode *)MemUtilsMallocArray(nSize, sizeof(Unicode)); Unicode *pMap = (Unicode *)MemUtilsMallocArray(nSize, sizeof(Unicode));
unsigned int nMapLen = 0; unsigned int nMapLen = 0;
...@@ -94,14 +93,13 @@ namespace PdfReader ...@@ -94,14 +93,13 @@ namespace PdfReader
Unicode nUnicode0; Unicode nUnicode0;
Unicode arrUnicodeBuffer[MaxUnicodeString]; Unicode arrUnicodeBuffer[MaxUnicodeString];
NSFile::CFileBinary oFile; FILE* pFile = NSFile::CFileBinary::OpenFileNative(seFileName->GetWString(), L"rb");
if (!oFile.OpenFile(seFileName->GetWString())) if (!pFile)
{ {
// TO DO: Error ""Couldn't open unicodeToUnicode file" // TO DO: Error ""Couldn't open unicodeToUnicode file"
return NULL; return NULL;
} }
FILE* pFile = oFile.GetFileNative();
unsigned int nSize = 4096; unsigned int nSize = 4096;
Unicode *pMap = (Unicode *)MemUtilsMallocArray(nSize, sizeof(Unicode)); Unicode *pMap = (Unicode *)MemUtilsMallocArray(nSize, sizeof(Unicode));
memset(pMap, 0, nSize * sizeof(Unicode)); memset(pMap, 0, nSize * sizeof(Unicode));
......
...@@ -102,14 +102,12 @@ namespace PdfReader ...@@ -102,14 +102,12 @@ namespace PdfReader
sprintf(m_sFileName, "%s\\%04d.jpg", m_sFilePrefix, m_nImageCount); sprintf(m_sFileName, "%s\\%04d.jpg", m_sFilePrefix, m_nImageCount);
NSFile::CFileBinary oFile; pFile = NSFile::CFileBinary::OpenFileNative(AStringToWString(m_sFileName), L"wb");
if (!oFile.CreateFileW(AStringToWString(m_sFileName))) if (!pFile)
{ {
// TO DO: Error "Couldn't open image file" // TO DO: Error "Couldn't open image file"
return; return;
} }
pFile = oFile.GetFileNative();
pStream = ((DCTStream *)pStream)->GetRawStream(); pStream = ((DCTStream *)pStream)->GetRawStream();
pStream->Reset(); pStream->Reset();
...@@ -141,13 +139,12 @@ namespace PdfReader ...@@ -141,13 +139,12 @@ namespace PdfReader
sprintf(m_sFileName, "%s\\%04d.bmp", m_sFilePrefix, m_nImageCount); sprintf(m_sFileName, "%s\\%04d.bmp", m_sFilePrefix, m_nImageCount);
NSFile::CFileBinary oFile; pFile = NSFile::CFileBinary::OpenFileNative(AStringToWString(m_sFileName), L"wb");
if (!oFile.CreateFileW(AStringToWString(m_sFileName))) if (!pFile)
{ {
// TO DO: Error "Couldn't open image file" // TO DO: Error "Couldn't open image file"
return; return;
} }
pFile = oFile.GetFileNative();
TBitmapFileHeader oFileHeader; TBitmapFileHeader oFileHeader;
oFileHeader.bfType = 'M' * 256 + 'B'; oFileHeader.bfType = 'M' * 256 + 'B';
...@@ -237,13 +234,12 @@ namespace PdfReader ...@@ -237,13 +234,12 @@ namespace PdfReader
return; return;
sprintf(m_sFileName, "%s\\%04d.jpg", m_sFilePrefix, m_nImageCount); sprintf(m_sFileName, "%s\\%04d.jpg", m_sFilePrefix, m_nImageCount);
NSFile::CFileBinary oFile; pFile = NSFile::CFileBinary::OpenFileNative(AStringToWString(m_sFileName), L"wb");
if (!oFile.CreateFileW(AStringToWString(m_sFileName))) if (!pFile)
{ {
// TO DO: Error "Couldn't open image file" // TO DO: Error "Couldn't open image file"
return; return;
} }
pFile = oFile.GetFileNative();
pStream = ((DCTStream *)pStream)->GetRawStream(); pStream = ((DCTStream *)pStream)->GetRawStream();
pStream->Reset(); pStream->Reset();
...@@ -276,14 +272,12 @@ namespace PdfReader ...@@ -276,14 +272,12 @@ namespace PdfReader
sprintf(m_sFileName, "%s\\%04d.bmp", m_sFilePrefix, m_nImageCount); sprintf(m_sFileName, "%s\\%04d.bmp", m_sFilePrefix, m_nImageCount);
NSFile::CFileBinary oFile; pFile = NSFile::CFileBinary::OpenFileNative(AStringToWString(m_sFileName), L"wb");
if (!oFile.CreateFileW(AStringToWString(m_sFileName))) if (!pFile)
{ {
// TO DO: Error "Couldn't open image file" // TO DO: Error "Couldn't open image file"
return; return;
} }
pFile = oFile.GetFileNative();
TBitmapFileHeader oFileHeader; TBitmapFileHeader oFileHeader;
oFileHeader.bfType = 'M' * 256 + 'B'; oFileHeader.bfType = 'M' * 256 + 'B';
oFileHeader.bfSize = sizeof(TBitmapFileHeader) + sizeof(TBitmapInfoHeader) + 2 * sizeof(ColorTableEntry) + nHeight * ((nWidth + 7) / 8); oFileHeader.bfSize = sizeof(TBitmapFileHeader) + sizeof(TBitmapInfoHeader) + 2 * sizeof(ColorTableEntry) + nHeight * ((nWidth + 7) / 8);
...@@ -365,14 +359,12 @@ namespace PdfReader ...@@ -365,14 +359,12 @@ namespace PdfReader
sprintf(m_sFileName, "%s\\%04d.bmp", m_sFilePrefix, m_nImageCount); sprintf(m_sFileName, "%s\\%04d.bmp", m_sFilePrefix, m_nImageCount);
NSFile::CFileBinary oFile; pFile = NSFile::CFileBinary::OpenFileNative(AStringToWString(m_sFileName), L"wb");
if (!oFile.CreateFileW(AStringToWString(m_sFileName))) if (!pFile)
{ {
// TO DO: Error "Couldn't open image file" // TO DO: Error "Couldn't open image file"
return; return;
} }
pFile = oFile.GetFileNative();
TBitmapFileHeader oFileHeader; TBitmapFileHeader oFileHeader;
oFileHeader.bfType = 'M' * 256 + 'B'; oFileHeader.bfType = 'M' * 256 + 'B';
oFileHeader.bfSize = sizeof(TBitmapFileHeader) + sizeof(TBitmapCoreHeader) + nWidth * nHeight * 4; oFileHeader.bfSize = sizeof(TBitmapFileHeader) + sizeof(TBitmapCoreHeader) + nWidth * nHeight * 4;
......
...@@ -24,12 +24,10 @@ namespace PdfReader ...@@ -24,12 +24,10 @@ namespace PdfReader
char *CFontFileBase::ReadFile(wchar_t *wsFileName, int *pnFileLen) char *CFontFileBase::ReadFile(wchar_t *wsFileName, int *pnFileLen)
{ {
NSFile::CFileBinary oFile; FILE* pFile = NSFile::CFileBinary::OpenFileNative(wsFileName, L"rb");
if (!oFile.OpenFile(wsFileName)) if (!pFile)
return NULL; return NULL;
FILE* pFile = oFile.GetFileNative();
fseek(pFile, 0, SEEK_END); fseek(pFile, 0, SEEK_END);
int nLen = (int)ftell(pFile); int nLen = (int)ftell(pFile);
fseek(pFile, 0, SEEK_SET); fseek(pFile, 0, SEEK_SET);
...@@ -41,7 +39,7 @@ namespace PdfReader ...@@ -41,7 +39,7 @@ namespace PdfReader
return NULL; return NULL;
} }
oFile.CloseFile(); fclose(pFile);
*pnFileLen = nLen; *pnFileLen = nLen;
return sBuffer; return sBuffer;
} }
......
...@@ -413,13 +413,12 @@ namespace PdfReader ...@@ -413,13 +413,12 @@ namespace PdfReader
char *GrFont::ReadExternalFontFile(int *pnLen) char *GrFont::ReadExternalFontFile(int *pnLen)
{ {
NSFile::CFileBinary oFile; FILE* pFile = NSFile::CFileBinary::OpenFileNative(m_wsExternalFontFilePath, L"rb");
if (!oFile.OpenFile(m_wsExternalFontFilePath)) if (!pFile)
{ {
// TO DO: Error "External font file vanished" // TO DO: Error "External font file vanished"
return NULL; return NULL;
} }
FILE* pFile = oFile.GetFileNative();
fseek(pFile, 0, SEEK_END); fseek(pFile, 0, SEEK_END);
*pnLen = (int)ftell(pFile); *pnLen = (int)ftell(pFile);
......
...@@ -151,9 +151,7 @@ namespace PdfReader ...@@ -151,9 +151,7 @@ namespace PdfReader
if (m_wsCMapDirectory != L"") if (m_wsCMapDirectory != L"")
{ {
std::wstring wsFilePath = m_wsCMapDirectory + seCMapName->GetWString(); std::wstring wsFilePath = m_wsCMapDirectory + seCMapName->GetWString();
NSFile::CFileBinary oFile; return NSFile::CFileBinary::OpenFileNative(wsFilePath, L"rb");
oFile.OpenFile(wsFilePath);
return oFile.GetFileNative();
} }
return NULL; return NULL;
......
...@@ -371,11 +371,7 @@ namespace PdfReader ...@@ -371,11 +371,7 @@ namespace PdfReader
{ {
#ifdef _DEBUG #ifdef _DEBUG
std::wstring wsFileName = L"D:\\Output\\PDF Dump\\DumpPDF_Page" + std::to_wstring(nPageNumber) + L".bin"; std::wstring wsFileName = L"D:\\Output\\PDF Dump\\DumpPDF_Page" + std::to_wstring(nPageNumber) + L".bin";
NSFile::CFileBinary oFile; m_pDumpFile = NSFile::CFileBinary::OpenFileNative(wsFileName, L"wb");
if (!oFile.CreateFileW(wsFileName))
m_pDumpFile = NULL;
else
m_pDumpFile = oFile.GetFileNative();
#endif #endif
m_pGlobalParams = pGlobalParams; m_pGlobalParams = pGlobalParams;
......
...@@ -53,9 +53,10 @@ namespace PdfReader ...@@ -53,9 +53,10 @@ namespace PdfReader
if (!m_pFileBuffer) if (!m_pFileBuffer)
{ {
oFile.CloseFile();
// Не смогли выделить память под весь файл, тогда работаем непосредственно с самим файлом // Не смогли выделить память под весь файл, тогда работаем непосредственно с самим файлом
m_pFileBuffer = NULL; m_pFileBuffer = NULL;
m_pFile = oFile.GetFileNative(); m_pFile = NSFile::CFileBinary::OpenFileNative(wsFileName, L"rb");
// Создаем поток // Создаем поток
Object oTemp; Object oTemp;
......
...@@ -637,9 +637,7 @@ namespace PdfReader ...@@ -637,9 +637,7 @@ namespace PdfReader
SpitPathExt(wsFileName, &wsSplitFileName, &wsSplitFileExt); SpitPathExt(wsFileName, &wsSplitFileName, &wsSplitFileExt);
std::wstring wsAfmPath = wsSplitFileName + L".afm"; std::wstring wsAfmPath = wsSplitFileName + L".afm";
NSFile::CFileBinary oFile; FILE* pFile = NSFile::CFileBinary::OpenFileNative(wsAfmPath, L"wb");
oFile.CreateFileW(wsAfmPath);
FILE* pFile = oFile.GetFileNative();
if (pFile) if (pFile)
{ {
Ref *pRef = pFont->GetID(); Ref *pRef = pFont->GetID();
...@@ -815,6 +813,7 @@ namespace PdfReader ...@@ -815,6 +813,7 @@ namespace PdfReader
oDictItem.Free(); oDictItem.Free();
} }
} }
fclose(pFile);
} }
// Загрузим сам файл со шрифтом, чтобы точно определить его тип // Загрузим сам файл со шрифтом, чтобы точно определить его тип
......
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