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

убраны неиспользуемые подключения, ушли от GetFileAttributes для проверки...

убраны неиспользуемые подключения, ушли от GetFileAttributes для проверки существования файла и папки, некоторые файлы переведены в utf8.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58874 954022d7-b5bf-4e40-9824-e11837661b57
parent 12b7886d
...@@ -40,7 +40,7 @@ namespace Writers ...@@ -40,7 +40,7 @@ namespace Writers
if(false == IsEmpty()) if(false == IsEmpty())
{ {
CString sChartDir = m_sDir + _T("/word/charts"); CString sChartDir = m_sDir + _T("/word/charts");
CreateDirectory(sChartDir, NULL); NSDirectory::CreateDirectory(string2std_string(sChartDir));
for(int i = 0, length = m_aCharts.size(); i < length; ++i) for(int i = 0, length = m_aCharts.size(); i < length; ++i)
{ {
ChartElem* elem = m_aCharts[i]; ChartElem* elem = m_aCharts[i];
......
...@@ -21,7 +21,7 @@ namespace Writers ...@@ -21,7 +21,7 @@ namespace Writers
} }
void AddImage(CString& sImg) void AddImage(CString& sImg)
{ {
CreateDirectory(m_sMediaDir, NULL); NSDirectory::CreateDirectory(string2std_string(m_sMediaDir));
//TCHAR tExt[256]; //TCHAR tExt[256];
//TCHAR tFilename[256]; //TCHAR tFilename[256];
......
...@@ -18,7 +18,7 @@ public: ...@@ -18,7 +18,7 @@ public:
double Footer; double Footer;
bool TitlePg; bool TitlePg;
bool EvenAndOddHeaders; bool EvenAndOddHeaders;
byte SectionType; BYTE SectionType;
int PageNumStart; int PageNumStart;
bool bHeader; bool bHeader;
...@@ -115,9 +115,9 @@ public: ...@@ -115,9 +115,9 @@ public:
class CThemeColor{ class CThemeColor{
public: public:
bool Auto; bool Auto;
byte Color; BYTE Color;
byte Tint; BYTE Tint;
byte Shade; BYTE Shade;
bool bShade; bool bShade;
bool bTint; bool bTint;
...@@ -295,7 +295,7 @@ public: ...@@ -295,7 +295,7 @@ public:
bool Caps; bool Caps;
bool SmallCaps; bool SmallCaps;
double Position; double Position;
byte FontHint; BYTE FontHint;
bool BoldCs; bool BoldCs;
bool ItalicCs; bool ItalicCs;
long FontSizeCs; long FontSizeCs;
......
...@@ -2333,8 +2333,7 @@ public: ...@@ -2333,8 +2333,7 @@ public:
} }
// //
DWORD dwFileAttr = ::GetFileAttributes( sFilePath ); if(NSFile::CFileBinary::Exists(string2std_string(sFilePath)))
if( dwFileAttr != INVALID_FILE_ATTRIBUTES && 0 == (dwFileAttr & FILE_ATTRIBUTE_DIRECTORY ) )
{ {
m_oFileWriter.m_oMediaWriter.AddImage(sFilePath); m_oFileWriter.m_oMediaWriter.AddImage(sFilePath);
if(bDeleteFile) if(bDeleteFile)
...@@ -5552,8 +5551,7 @@ public: ...@@ -5552,8 +5551,7 @@ public:
// rels // rels
CString sRelsDir; CString sRelsDir;
sRelsDir.Format(_T("%s\\word\\charts\\_rels"), m_oFileWriter.m_oChartWriter.m_sDir); sRelsDir.Format(_T("%s\\word\\charts\\_rels"), m_oFileWriter.m_oChartWriter.m_sDir);
DWORD dwFileAttr = ::GetFileAttributes( sRelsDir ); if( !NSDirectory::Exists(string2std_string(sRelsDir)) )
if( dwFileAttr == INVALID_FILE_ATTRIBUTES )
OOX::CSystemUtility::CreateDirectories(sRelsDir); OOX::CSystemUtility::CreateDirectories(sRelsDir);
m_oFileWriter.m_pDrawingConverter->SetDstContentRels(); m_oFileWriter.m_pDrawingConverter->SetDstContentRels();
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "BinReaderWriterDefines.h" #include "BinReaderWriterDefines.h"
#include "../../Common/DocxFormat/Source/MathEquation/OutputDev.h" #include "../../Common/DocxFormat/Source/MathEquation/OutputDev.h"
#include "String.h" //#include "String.h"
#include <stack> #include <stack>
/*namespace BinDocxRW /*namespace BinDocxRW
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "../../Common/Base64.h" #include "../../Common/Base64.h"
#include "../../ASCOfficePPTXFile/Editor/FontCutter.h" #include "../../ASCOfficePPTXFile/Editor/FontCutter.h"
#include "../../XlsxSerializerCom/Reader/BinaryWriter.h" #include "../../XlsxSerializerCom/Reader/BinaryWriter.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../../Common/DocxFormat/Source/MathEquation/MathEquation.h" #include "../../Common/DocxFormat/Source/MathEquation/MathEquation.h"
#include "BinEquationWriter.h" #include "BinEquationWriter.h"
......
#include "DocxSerializer.h" #include "DocxSerializer.h"
#include "../../DesktopEditor/common/Directory.h" #include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/common/File.h" #include "../../DesktopEditor/common/File.h"
#include "../BinWriter/BinWriters.h" #include "../BinWriter/BinWriters.h"
#include "../BinReader/Readers.h" #include "../BinReader/Readers.h"
#include "../ASCOfficePPTXFile/Editor/FontPicker.h" #include "../../ASCOfficePPTXFile/Editor/FontPicker.h"
#ifndef _WIN32 #ifndef _WIN32
#include "../../DesktopEditor/common/Types.h" #include "../../DesktopEditor/common/Types.h"
...@@ -46,13 +46,13 @@ bool BinDocxRW::CDocxSerializer::saveToFile(CString& sSrcFileName, CString& sDst ...@@ -46,13 +46,13 @@ bool BinDocxRW::CDocxSerializer::saveToFile(CString& sSrcFileName, CString& sDst
pEmbeddedFontsManager = pFontPicker->GetNativeCutter(); pEmbeddedFontsManager = pFontPicker->GetNativeCutter();
// . //добавляем весь латинский алфавит для списков.
pEmbeddedFontsManager->CheckString(CString(_T("abcdefghijklmnopqrstuvwxyz"))); pEmbeddedFontsManager->CheckString(CString(_T("abcdefghijklmnopqrstuvwxyz")));
// //добавим мега шрифт
pEmbeddedFontsManager->CheckFont(_T("Wingdings 3"), fp.getFontManager()); pEmbeddedFontsManager->CheckFont(_T("Wingdings 3"), fp.getFontManager());
pEmbeddedFontsManager->CheckFont(_T("Arial"), fp.getFontManager()); pEmbeddedFontsManager->CheckFont(_T("Arial"), fp.getFontManager());
//pEmbeddedFontsManager //pEmbeddedFontsManager добавляются все цифры
} }
oDrawingConverter.SetFontDir(m_sFontDir); oDrawingConverter.SetFontDir(m_sFontDir);
...@@ -101,7 +101,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD ...@@ -101,7 +101,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD
oFile.ReadFile(pBase64Data, oFile.GetFileSize(), nBase64DataSize); oFile.ReadFile(pBase64Data, oFile.GetFileSize(), nBase64DataSize);
oFile.CloseFile(); oFile.CloseFile();
// //проверяем формат
bool bValidFormat = false; bool bValidFormat = false;
CString sSignature(g_sFormatSignature); CString sSignature(g_sFormatSignature);
int nSigLength = sSignature.GetLength(); int nSigLength = sSignature.GetLength();
...@@ -115,7 +115,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD ...@@ -115,7 +115,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD
} }
if(bValidFormat) if(bValidFormat)
{ {
// base64 //Читаем из файла версию и длину base64
int nIndex = nSigLength; int nIndex = nSigLength;
int nType = 0; int nType = 0;
CStringA version = ""; CStringA version = "";
...@@ -165,7 +165,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD ...@@ -165,7 +165,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD
oDrawingConverter.SetMediaDstPath(sMediaPath); oDrawingConverter.SetMediaDstPath(sMediaPath);
m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath); m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath);
// //папка с картинками
TCHAR tFolder[256]; TCHAR tFolder[256];
TCHAR tDrive[256]; TCHAR tDrive[256];
_tsplitpath( sSrcFileName, tDrive, tFolder, NULL, NULL ); _tsplitpath( sSrcFileName, tDrive, tFolder, NULL, NULL );
...@@ -193,11 +193,11 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD ...@@ -193,11 +193,11 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD
m_pCurFileWriter->m_oNumberingWriter.Write(); m_pCurFileWriter->m_oNumberingWriter.Write();
m_pCurFileWriter->m_oFontTableWriter.Write(); m_pCurFileWriter->m_oFontTableWriter.Write();
m_pCurFileWriter->m_oHeaderFooterWriter.Write(); m_pCurFileWriter->m_oHeaderFooterWriter.Write();
//Setting HeaderFooter, evenAndOddHeaders //Setting пишем после HeaderFooter, чтобы заполнить evenAndOddHeaders
m_pCurFileWriter->m_oSettingWriter.Write(); m_pCurFileWriter->m_oSettingWriter.Write();
//Document HeaderFooter, sectPr //Document пишем после HeaderFooter, чтобы заполнить sectPr
m_pCurFileWriter->m_oDocumentWriter.Write(); m_pCurFileWriter->m_oDocumentWriter.Write();
//Rels ContentTypes //Rels и ContentTypes пишем в конце
//m_pCurFileWriter->m_oDocumentRelsWriter.Write(_T("document.xml.rels")); //m_pCurFileWriter->m_oDocumentRelsWriter.Write(_T("document.xml.rels"));
m_pCurFileWriter->m_oContentTypesWriter.Write(); m_pCurFileWriter->m_oContentTypesWriter.Write();
......
//#include "stdafx.h" //#include "stdafx.h"
#include "FontProcessor.h" #include "FontProcessor.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Styles/Fonts.h" #include "../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../../Common/ASCUtils.h" #include "../../Common/ASCUtils.h"
namespace DocWrapper { namespace DocWrapper {
......
#pragma once #pragma once
#include "../stdafx.h" //#include "../stdafx.h"
#include <map> #include <map>
#ifdef _WIN32
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include "../../DesktopEditor/fontengine/ApplicationFonts.h" #include "../../DesktopEditor/fontengine/ApplicationFonts.h"
//#include "DocWrapper/Base.h" //#include "DocWrapper/Base.h"
namespace NSCommon{ namespace NSCommon{
template<class Type> class nullable; template<class Type> class nullable;
} }
namespace ComplexTypes{
namespace Spreadsheet{
class CString_;
}
}
namespace OOX namespace OOX
{ {
class CFont; class CFont;
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
#include "../../DesktopEditor/common/Directory.h" #include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/common/File.h" #include "../../DesktopEditor/common/File.h"
#include "../XlsxSerializerCom/Reader/BinaryWriter.h" #include "../../XlsxSerializerCom/Reader/BinaryWriter.h"
#include "../XlsxSerializerCom/Writer/BinaryReader.h" #include "../../XlsxSerializerCom/Writer/BinaryReader.h"
#include "../ASCOfficePPTXFile/Editor/FontPicker.h" #include "../../ASCOfficePPTXFile/Editor/FontPicker.h"
namespace BinXlsxRW{ namespace BinXlsxRW{
int g_nCurFormatVersion = 0; int g_nCurFormatVersion = 0;
...@@ -139,8 +139,7 @@ namespace BinXlsxRW{ ...@@ -139,8 +139,7 @@ namespace BinXlsxRW{
CString sRelsDir = sDrive + sFolder; CString sRelsDir = sDrive + sFolder;
sRelsDir.Append(_T("_rels")); sRelsDir.Append(_T("_rels"));
DWORD dwFileAttr = ::GetFileAttributes( sRelsDir ); if( !NSDirectory::Exists(string2std_string(sRelsDir)) )
if( dwFileAttr == INVALID_FILE_ATTRIBUTES )
OOX::CSystemUtility::CreateDirectories(sRelsDir); OOX::CSystemUtility::CreateDirectories(sRelsDir);
oChartSpace.write2(sFilepath); oChartSpace.write2(sFilepath);
......
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
#include "windows.h" #include "windows.h"
#include "windef.h" #include "windef.h"
#elif LINUX #elif LINUX
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "File.h"
#elif MAC #elif MAC
#endif #endif
...@@ -50,7 +54,32 @@ namespace NSDirectory ...@@ -50,7 +54,32 @@ namespace NSDirectory
#ifdef WIN32 #ifdef WIN32
::CreateDirectoryW(strDirectory.c_str(), NULL); ::CreateDirectoryW(strDirectory.c_str(), NULL);
#elif LINUX #elif LINUX
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
struct stat st;
if (stat((char*)pUtf8, &st) == -1) {
mkdir((char*)pUtf8, S_IRWXU | S_IRWXG | S_IRWXO);
}
delete [] pUtf8;
#elif MAC
#endif
}
static bool Exists(std::wstring& strDirectory)
{
#ifdef WIN32
DWORD dwAttrib = ::GetFileAttributesW(strDirectory.c_str());
return (dwAttrib != INVALID_FILE_ATTRIBUTES && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
#elif LINUX
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
struct stat st;
bool bRes = (0 == stat((char*)pUtf8, &st)) && S_ISDIR(st.st_mode);
delete [] pUtf8;
return bRes;
#elif MAC #elif MAC
return true;
#endif #endif
} }
} }
......
...@@ -504,7 +504,7 @@ namespace NSFile ...@@ -504,7 +504,7 @@ namespace NSFile
BYTE* pData = NULL; BYTE* pData = NULL;
LONG lLen = 0; LONG lLen = 0;
CUtf8Converter::GetUtf8StringFromUnicode(strXml.c_str(), strXml.size(), pData, lLen, bIsBOM); CUtf8Converter::GetUtf8StringFromUnicode(strXml.c_str(), strXml.length(), pData, lLen, bIsBOM);
WriteFile(pData, lLen); WriteFile(pData, lLen);
...@@ -518,6 +518,25 @@ namespace NSFile ...@@ -518,6 +518,25 @@ namespace NSFile
oFile.CloseFile(); oFile.CloseFile();
return true; return true;
} }
static bool Exists(const std::wstring& strFileName)
{
#if defined(WIN32) || defined(_WIN32_WCE)
FILE* pFile = _wfopen(strFileName.c_str(), L"rb");
#else
BYTE* pUtf8 = NULL;
LONG lLen = 0;
CUtf8Converter::GetUtf8StringFromUnicode(strFileName.c_str(), strFileName.length(), pUtf8, lLen, false);
FILE* pFile = fopen((char*)pUtf8, "rb");
delete [] pUtf8;
#endif
if(NULL != pFile)
{
fclose(pFile);
return true;
}
else
return false;
}
}; };
} }
......
...@@ -701,7 +701,7 @@ namespace BinXlsxRW { ...@@ -701,7 +701,7 @@ namespace BinXlsxRW {
{ {
m_oBcw.m_oStream.WriteBYTE(c_oSerBorderPropTypes::Style); m_oBcw.m_oStream.WriteBYTE(c_oSerBorderPropTypes::Style);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBYTE((byte)borderProp.m_oStyle->GetValue()); m_oBcw.m_oStream.WriteBYTE((BYTE)borderProp.m_oStyle->GetValue());
} }
}; };
void WriteCellStyleXfs(const OOX::Spreadsheet::CCellStyleXfs& cellStyleXfs) void WriteCellStyleXfs(const OOX::Spreadsheet::CCellStyleXfs& cellStyleXfs)
...@@ -2427,7 +2427,7 @@ namespace BinXlsxRW { ...@@ -2427,7 +2427,7 @@ namespace BinXlsxRW {
OOX::CPath oNormalizedPath = OOX::CPath(pDrawing->GetReadPath().GetDirectory()) / oRels->Target().GetPath(); OOX::CPath oNormalizedPath = OOX::CPath(pDrawing->GetReadPath().GetDirectory()) / oRels->Target().GetPath();
CString sChartPath = oNormalizedPath.GetPath(); CString sChartPath = oNormalizedPath.GetPath();
// //
if( INVALID_FILE_ATTRIBUTES != ::GetFileAttributes( sChartPath ) ) if( NSFile::CFileBinary::Exists(string2std_string(sChartPath)) )
{ {
CString sOldRelsPath = m_pOfficeDrawingConverter->GetRelsPath(); CString sOldRelsPath = m_pOfficeDrawingConverter->GetRelsPath();
m_pOfficeDrawingConverter->SetRelsPath(sChartPath); m_pOfficeDrawingConverter->SetRelsPath(sChartPath);
......
#include "CSVReader.h" #include "CSVReader.h"
#include "../../Common/MappingFile.h"
#include <map> #include <map>
namespace CSVReader namespace CSVReader
...@@ -108,17 +107,18 @@ namespace CSVReader ...@@ -108,17 +107,18 @@ namespace CSVReader
pWorkbook->m_oSheets.Init(); pWorkbook->m_oSheets.Init();
pWorkbook->m_oSheets->m_arrItems.push_back(pSheet); pWorkbook->m_oSheets->m_arrItems.push_back(pSheet);
MemoryMapping::CMappingFile oMappingFile = MemoryMapping::CMappingFile(); NSFile::CFileBinary oFile;
if(FALSE != oMappingFile.Open(sFileName)) if(oFile.OpenFile(string2std_string(sFileName)))
{ {
long nFileSize = oMappingFile.GetSize(); DWORD nFileSize = 0;
LPCSTR pFileData = (LPCSTR)oMappingFile.GetData(); BYTE* pFileData = new BYTE[oFile.GetFileSize()];
oFile.ReadFile(pFileData, oFile.GetFileSize(), nFileSize);
oFile.CloseFile();
INT nSize = MultiByteToWideChar(nCodePage, 0, pFileData, nFileSize, NULL, 0); INT nSize = MultiByteToWideChar(nCodePage, 0, (LPCSTR)pFileData, nFileSize, NULL, 0);
WCHAR *pTemp = new WCHAR [nSize]; WCHAR *pTemp = new WCHAR [nSize];
memset(pTemp, 0, sizeof(WCHAR) * nSize); memset(pTemp, 0, sizeof(WCHAR) * nSize);
MultiByteToWideChar (nCodePage, 0, pFileData, nFileSize, pTemp, nSize); MultiByteToWideChar (nCodePage, 0, (LPCSTR)pFileData, nFileSize, pTemp, nSize);
oMappingFile.Close();
CONST WCHAR wcNewLineN = _T('\n'); CONST WCHAR wcNewLineN = _T('\n');
CONST WCHAR wcNewLineR = _T('\r'); CONST WCHAR wcNewLineR = _T('\r');
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
namespace CSVReader namespace CSVReader
{ {
void AddCell(CString &sText, INT nStartCell, std::stack<INT> &oDeleteChars, OOX::Spreadsheet::CRow &oRow, INT nRow, INT nCol, BOOL bIsWrap); void AddCell(CString &sText, INT nStartCell, std::stack<INT> &oDeleteChars, OOX::Spreadsheet::CRow &oRow, INT nRow, INT nCol, BOOL bIsWrap);
void ReadFromCsvToXlsx(CString &sFileName, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, CONST WCHAR wcDelimiter); void ReadFromCsvToXlsx(CString &sFileName, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const WCHAR wcDelimiter);
} }
#endif //CSV_READER #endif //CSV_READER
#ifndef BINARY_READER #ifndef BINARY_READER
#define BINARY_READER #define BINARY_READER
#include "../../Common/FileWriter.h"
#include "../../Common/MappingFile.h"
#include "../../Common/Base64.h" #include "../../Common/Base64.h"
#include "../../Common/ATLDefine.h" #include "../../Common/ATLDefine.h"
...@@ -1597,7 +1595,8 @@ namespace BinXlsxRW { ...@@ -1597,7 +1595,8 @@ namespace BinXlsxRW {
CString sGfxdata; CString sGfxdata;
if(TRUE == Base64::Base64Encode(pWriteBuffer, nWriteBufferLength, (LPSTR)pbBase64Buffer, &nBase64BufferLen, Base64::B64_BASE64_FLAG_NONE)) if(TRUE == Base64::Base64Encode(pWriteBuffer, nWriteBufferLength, (LPSTR)pbBase64Buffer, &nBase64BufferLen, Base64::B64_BASE64_FLAG_NONE))
{ {
sGfxdata = CString((LPSTR)pbBase64Buffer, nBase64BufferLen); std::wstring strGfxdata = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(pbBase64Buffer, nBase64BufferLen);
sGfxdata = CString(strGfxdata.c_str());
// Excel // Excel
sGfxdata.Append(_T("\r\n")); sGfxdata.Append(_T("\r\n"));
} }
...@@ -1842,8 +1841,7 @@ namespace BinXlsxRW { ...@@ -1842,8 +1841,7 @@ namespace BinXlsxRW {
{ {
CString sRelsDir; CString sRelsDir;
sRelsDir.Format(_T("%s\\xl\\drawings\\_rels"), m_sDestinationDir); sRelsDir.Format(_T("%s\\xl\\drawings\\_rels"), m_sDestinationDir);
DWORD dwFileAttr = ::GetFileAttributes( sRelsDir ); if( !NSDirectory::Exists(string2std_string(sRelsDir)) )
if( dwFileAttr == INVALID_FILE_ATTRIBUTES )
OOX::CSystemUtility::CreateDirectories(sRelsDir); OOX::CSystemUtility::CreateDirectories(sRelsDir);
m_pOfficeDrawingConverter->SetDstContentRels(); m_pOfficeDrawingConverter->SetDstContentRels();
...@@ -2421,8 +2419,7 @@ namespace BinXlsxRW { ...@@ -2421,8 +2419,7 @@ namespace BinXlsxRW {
// rels // rels
CString sRelsDir; CString sRelsDir;
sRelsDir.Format(_T("%s\\xl\\charts\\_rels"), m_sDestinationDir); sRelsDir.Format(_T("%s\\xl\\charts\\_rels"), m_sDestinationDir);
DWORD dwFileAttr = ::GetFileAttributes( sRelsDir ); if( !NSDirectory::Exists(string2std_string(sRelsDir)) )
if( dwFileAttr == INVALID_FILE_ATTRIBUTES )
OOX::CSystemUtility::CreateDirectories(sRelsDir); OOX::CSystemUtility::CreateDirectories(sRelsDir);
m_pOfficeDrawingConverter->SetDstContentRels(); m_pOfficeDrawingConverter->SetDstContentRels();
...@@ -2544,8 +2541,7 @@ namespace BinXlsxRW { ...@@ -2544,8 +2541,7 @@ namespace BinXlsxRW {
if(pair->second->bNeedCreate) if(pair->second->bNeedCreate)
{ {
pair->second->bNeedCreate = false; pair->second->bNeedCreate = false;
DWORD dwFileAttr = ::GetFileAttributes( m_sMediaDir ); if( !NSDirectory::Exists(string2std_string(m_sMediaDir)) )
if( dwFileAttr == INVALID_FILE_ATTRIBUTES )
OOX::CSystemUtility::CreateDirectories(m_sMediaDir); OOX::CSystemUtility::CreateDirectories(m_sMediaDir);
::CopyFile(pair->second->sPath, sNewImagePath, FALSE); ::CopyFile(pair->second->sPath, sNewImagePath, FALSE);
} }
...@@ -2911,8 +2907,7 @@ namespace BinXlsxRW { ...@@ -2911,8 +2907,7 @@ namespace BinXlsxRW {
} }
} }
// //
DWORD dwFileAttr = ::GetFileAttributes( sImageSrc ); if(NSFile::CFileBinary::Exists(string2std_string(sImageSrc)))
if( dwFileAttr != INVALID_FILE_ATTRIBUTES && 0 == (dwFileAttr & FILE_ATTRIBUTE_DIRECTORY ) )
{ {
m_sCurSrc = sImageSrc; m_sCurSrc = sImageSrc;
if(bAddToDelete) if(bAddToDelete)
...@@ -2936,11 +2931,13 @@ namespace BinXlsxRW { ...@@ -2936,11 +2931,13 @@ namespace BinXlsxRW {
int ReadFile(CString sSrcFileName, CString sDstPath, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, CString& sXMLOptions) int ReadFile(CString sSrcFileName, CString sDstPath, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, CString& sXMLOptions)
{ {
bool bResultOk = false; bool bResultOk = false;
MemoryMapping::CMappingFile oMappingFile = MemoryMapping::CMappingFile(); NSFile::CFileBinary oFile;
if(FALSE != oMappingFile.Open(CString(sSrcFileName))) if(oFile.OpenFile(string2std_string(sSrcFileName)))
{ {
long nBase64DataSize = oMappingFile.GetSize(); DWORD nBase64DataSize = 0;
BYTE* pBase64Data = oMappingFile.GetData(); BYTE* pBase64Data = new BYTE[oFile.GetFileSize()];
oFile.ReadFile(pBase64Data, oFile.GetFileSize(), nBase64DataSize);
oFile.CloseFile();
// //
bool bValidFormat = false; bool bValidFormat = false;
...@@ -3042,7 +3039,6 @@ namespace BinXlsxRW { ...@@ -3042,7 +3039,6 @@ namespace BinXlsxRW {
bResultOk = true; bResultOk = true;
} }
} }
oMappingFile.Close();
} }
return S_OK; return S_OK;
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
namespace CSVWriter namespace CSVWriter
{ {
void WriteFile(NSFile::CFileBinary *pFile, WCHAR **pWriteBuffer, INT &nCurrentIndex, CString &sWriteString, UINT &nCodePage, BOOL bIsEnd = FALSE); void WriteFile(NSFile::CFileBinary *pFile, WCHAR **pWriteBuffer, INT &nCurrentIndex, CString &sWriteString, UINT &nCodePage, BOOL bIsEnd = FALSE);
void WriteFromXlsxToCsv(CString &sFileDst, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, CONST WCHAR wcDelimiter); void WriteFromXlsxToCsv(CString &sFileDst, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const WCHAR wcDelimiter);
} }
#endif //CSV_WRITER #endif //CSV_WRITER
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