Commit 305ebda7 authored by ElenaSubbotina's avatar ElenaSubbotina

OfficeUtils - add sort for compress

parent 114050c2
...@@ -61,7 +61,7 @@ bool BinDocxRW::CDocxSerializer::ConvertDocxToDoct(const std::wstring& sSrcFileN ...@@ -61,7 +61,7 @@ bool BinDocxRW::CDocxSerializer::ConvertDocxToDoct(const std::wstring& sSrcFileN
if(S_OK == oCOfficeUtils.ExtractToDirectory(sSrcFileName, strDirSrc, NULL, 0)) if(S_OK == oCOfficeUtils.ExtractToDirectory(sSrcFileName, strDirSrc, NULL, 0))
if(saveToFile(strEditorBin, strDirSrc, sXMLOptions)) if(saveToFile(strEditorBin, strDirSrc, sXMLOptions))
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, -1)) if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName))
return true; return true;
return false; return false;
} }
...@@ -88,7 +88,7 @@ bool BinDocxRW::CDocxSerializer::ConvertDoctToDocx(const std::wstring& sSrcFileN ...@@ -88,7 +88,7 @@ bool BinDocxRW::CDocxSerializer::ConvertDoctToDocx(const std::wstring& sSrcFileN
if(loadFromFile(sEditorBin, strDirDst, sXMLOptions, sThemePath, sMediaPath, sEmbedPath)) if(loadFromFile(sEditorBin, strDirDst, sXMLOptions, sThemePath, sMediaPath, sEmbedPath))
{ {
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, -1)) if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, true))
return true; return true;
} }
} }
......
...@@ -275,7 +275,7 @@ namespace BinXlsxRW{ ...@@ -275,7 +275,7 @@ namespace BinXlsxRW{
oXlsx.Write(oPath, sAdditionalContentTypes); oXlsx.Write(oPath, sAdditionalContentTypes);
//zip //zip
COfficeUtils oOfficeUtils(NULL); COfficeUtils oOfficeUtils(NULL);
oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, -1); oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, true);
//clean //clean
NSDirectory::DeleteDirectory(sTempDir); NSDirectory::DeleteDirectory(sTempDir);
} }
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include <stdio.h> #include <stdio.h>
#include <tchar.h> #include <tchar.h>
#include "../../OfficeUtils/src/OfficeUtils.h" #include "../../OfficeUtils/src/OfficeUtils.h"
#include "../../DesktopEditor/common/Directory.h" #include "../../DesktopEditor/common/Directory.h"
#include "../src/ConvertOO2OOX.h" #include "../src/ConvertOO2OOX.h"
...@@ -55,7 +54,7 @@ int _tmain(int argc, _TCHAR* argv[]) ...@@ -55,7 +54,7 @@ int _tmain(int argc, _TCHAR* argv[])
HRESULT hr = S_OK; HRESULT hr = S_OK;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
std::wstring srcFileName = argv[1]; std::wstring srcFileName = argv[1];
std::wstring dstPath = argc > 2 ? argv[2] : srcFileName + L"-my.docx"; //xlsx pptx std::wstring dstPath = argc > 2 ? argv[2] : srcFileName + L"-my.xlsx"; //xlsx pptx docx
std::wstring outputDir = NSDirectory::GetFolderPath(dstPath); std::wstring outputDir = NSDirectory::GetFolderPath(dstPath);
...@@ -73,7 +72,7 @@ int _tmain(int argc, _TCHAR* argv[]) ...@@ -73,7 +72,7 @@ int _tmain(int argc, _TCHAR* argv[])
if (hr != S_OK) return hr; if (hr != S_OK) return hr;
if (S_OK != oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath.c_str(), -1)) if (S_OK != oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath.c_str(), true))
return hr; return hr;
NSDirectory::DeleteDirectory(dstTempPath); NSDirectory::DeleteDirectory(dstTempPath);
......
...@@ -64,6 +64,8 @@ ...@@ -64,6 +64,8 @@
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="gdi32.lib Rpcrt4.lib" AdditionalDependencies="gdi32.lib Rpcrt4.lib"
ShowProgress="0"
Version=""
LinkIncremental="2" LinkIncremental="2"
GenerateDebugInformation="true" GenerateDebugInformation="true"
SubSystem="1" SubSystem="1"
......
...@@ -47,12 +47,12 @@ docx_content_types_file::docx_content_types_file() ...@@ -47,12 +47,12 @@ docx_content_types_file::docx_content_types_file()
content()->add_default(L"jpg", L"image/jpeg"); content()->add_default(L"jpg", L"image/jpeg");
content()->add_default(L"png", L"image/png"); content()->add_default(L"png", L"image/png");
// //
content()->add_override(L"/_rels/.rels", L"application/vnd.openxmlformats-package.relationships+xml");
content()->add_override(L"/word/_rels/document.xml.rels", L"application/vnd.openxmlformats-package.relationships+xml");
content()->add_override(L"/word/document.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"); content()->add_override(L"/word/document.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml");
content()->add_override(L"/word/settings.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"); content()->add_override(L"/word/settings.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml");
content()->add_override(L"/word/styles.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"); content()->add_override(L"/word/styles.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml");
content()->add_override(L"/word/fontTable.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"); content()->add_override(L"/word/fontTable.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml");
//content()->add_override(L"/word/_rels/document.xml.rels", L"application/vnd.openxmlformats-package.relationships+xml");
//content()->add_override(L"/_rels/.rels", L"application/vnd.openxmlformats-package.relationships+xml");
content()->add_override(L"/docProps/app.xml", L"application/vnd.openxmlformats-officedocument.extended-properties+xml"); content()->add_override(L"/docProps/app.xml", L"application/vnd.openxmlformats-officedocument.extended-properties+xml");
content()->add_override(L"/docProps/core.xml", L"application/vnd.openxmlformats-package.core-properties+xml"); content()->add_override(L"/docProps/core.xml", L"application/vnd.openxmlformats-package.core-properties+xml");
} }
......
...@@ -381,7 +381,7 @@ std::wstring draw_object::office_convert(odf_document * odfDocument, int type) ...@@ -381,7 +381,7 @@ std::wstring draw_object::office_convert(odf_document * odfDocument, int type)
std::wstring temp_file = folderPath + FILE_SEPARATOR_STR + href_result; std::wstring temp_file = folderPath + FILE_SEPARATOR_STR + href_result;
COfficeUtils oCOfficeUtils(NULL); COfficeUtils oCOfficeUtils(NULL);
oCOfficeUtils.CompressFileOrDirectory(objectOutPath.c_str(), temp_file.c_str(), -1); oCOfficeUtils.CompressFileOrDirectory(objectOutPath.c_str(), temp_file.c_str(), true);
} }
NSDirectory::DeleteDirectory(objectOutPath); NSDirectory::DeleteDirectory(objectOutPath);
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include "Array.h" #include <vector>
#include "File.h" #include "File.h"
#if defined(_WIN32) || defined (_WIN64) #if defined(_WIN32) || defined (_WIN64)
...@@ -109,9 +109,9 @@ namespace NSDirectory ...@@ -109,9 +109,9 @@ namespace NSDirectory
#endif #endif
#ifdef _IOS #ifdef _IOS
void GetFiles2_ios(std::wstring strDirectory, CArray<std::wstring>& oArray, bool bIsRecursion); void GetFiles2_ios(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion);
#endif #endif
static void GetFiles2(std::wstring strDirectory, CArray<std::wstring>& oArray, bool bIsRecursion = false) static void GetFiles2(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion = false)
{ {
#if defined(_WIN32) || defined (_WIN64) #if defined(_WIN32) || defined (_WIN64)
WIN32_FIND_DATAW oFD; WIN32_FIND_DATAW oFD;
...@@ -128,7 +128,7 @@ namespace NSDirectory ...@@ -128,7 +128,7 @@ namespace NSDirectory
sSpec = strDirectory + L"\\" + sSpec; sSpec = strDirectory + L"\\" + sSpec;
if( !( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ) if( !( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
{ {
oArray.Add(sSpec); oArray.push_back(sSpec);
} }
else if (bIsRecursion) else if (bIsRecursion)
{ {
...@@ -169,7 +169,7 @@ namespace NSDirectory ...@@ -169,7 +169,7 @@ namespace NSDirectory
if (2 == nType) if (2 == nType)
{ {
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name)); std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
oArray.Add(strDirectory + L"/" + sName); oArray.push_back(strDirectory + L"/" + sName);
} }
if (bIsRecursion && (1 == nType)) if (bIsRecursion && (1 == nType))
...@@ -199,7 +199,7 @@ namespace NSDirectory ...@@ -199,7 +199,7 @@ namespace NSDirectory
if(DT_REG == dirp->d_type) if(DT_REG == dirp->d_type)
{ {
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name)); std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
oArray.Add(strDirectory + L"/" + sName); oArray.push_back(strDirectory + L"/" + sName);
} }
if (bIsRecursion && DT_DIR == dirp->d_type) if (bIsRecursion && DT_DIR == dirp->d_type)
...@@ -218,9 +218,9 @@ namespace NSDirectory ...@@ -218,9 +218,9 @@ namespace NSDirectory
#endif #endif
} }
static CArray<std::wstring> GetFiles(std::wstring strDirectory, bool bIsRecursion = false) static std::vector<std::wstring> GetFiles(std::wstring strDirectory, bool bIsRecursion = false)
{ {
CArray<std::wstring> oArray; std::vector<std::wstring> oArray;
if (!strDirectory.empty()) if (!strDirectory.empty())
{ {
...@@ -228,10 +228,9 @@ namespace NSDirectory ...@@ -228,10 +228,9 @@ namespace NSDirectory
} }
return oArray; return oArray;
} }
static std::vector<std::wstring> GetDirectories(std::wstring strDirectory)
static CArray<std::wstring> GetDirectories(std::wstring strDirectory)
{ {
CArray<std::wstring> oArray; std::vector<std::wstring> oArray;
#if defined(_WIN32) || defined (_WIN64) #if defined(_WIN32) || defined (_WIN64)
WIN32_FIND_DATAW oFD; WIN32_FIND_DATAW oFD;
...@@ -248,7 +247,7 @@ namespace NSDirectory ...@@ -248,7 +247,7 @@ namespace NSDirectory
sSpec = strDirectory + L"\\" + sSpec; sSpec = strDirectory + L"\\" + sSpec;
if( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) if( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{ {
oArray.Add(sSpec); oArray.push_back(sSpec);
} }
} }
} while( FindNextFileW( hRes, &oFD ) ); } while( FindNextFileW( hRes, &oFD ) );
...@@ -280,7 +279,7 @@ namespace NSDirectory ...@@ -280,7 +279,7 @@ namespace NSDirectory
if(dirp->d_name[0] != '.') if(dirp->d_name[0] != '.')
{ {
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name)); std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
oArray.Add(strDirectory + L"/" + sName); oArray.push_back(strDirectory + L"/" + sName);
} }
} }
} }
...@@ -302,7 +301,7 @@ namespace NSDirectory ...@@ -302,7 +301,7 @@ namespace NSDirectory
if(dirp->d_name[0] != '.') if(dirp->d_name[0] != '.')
{ {
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name)); std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
oArray.Add(strDirectory + L"/" + sName); oArray.push_back(strDirectory + L"/" + sName);
} }
} }
} }
...@@ -381,13 +380,13 @@ namespace NSDirectory ...@@ -381,13 +380,13 @@ namespace NSDirectory
} }
static void DeleteDirectory(const std::wstring& strDirectory, bool deleteRoot = true) static void DeleteDirectory(const std::wstring& strDirectory, bool deleteRoot = true)
{ {
CArray<std::wstring> aFiles = GetFiles(strDirectory); std::vector<std::wstring> aFiles = GetFiles(strDirectory);
for(int i = 0; i < aFiles.GetCount(); ++i) for(size_t i = 0; i < aFiles.size(); ++i)
{ {
NSFile::CFileBinary::Remove(aFiles[i]); NSFile::CFileBinary::Remove(aFiles[i]);
} }
CArray<std::wstring> aDirectories = GetDirectories(strDirectory); std::vector<std::wstring> aDirectories = GetDirectories(strDirectory);
for(int i = 0; i < aDirectories.GetCount(); ++i) for(size_t i = 0; i < aDirectories.size(); ++i)
{ {
DeleteDirectory(aDirectories[i]); DeleteDirectory(aDirectories[i]);
} }
...@@ -473,11 +472,11 @@ namespace NSDirectory ...@@ -473,11 +472,11 @@ namespace NSDirectory
static int GetFilesCount(const std::wstring& path, const bool& recursive) static int GetFilesCount(const std::wstring& path, const bool& recursive)
{ {
CArray<std::wstring> arrFiles = NSDirectory::GetFiles(path, recursive); std::vector<std::wstring> arrFiles = NSDirectory::GetFiles(path, recursive);
#if defined(_WIN32) || defined (_WIN64) #if defined(_WIN32) || defined (_WIN64)
return arrFiles.GetCount(); return (int)arrFiles.size();
#endif #endif
return arrFiles.GetCount() + 1; return (int)arrFiles.size() + 1;
// ??? // ???
} }
#if !defined(_WIN32) && !defined (_WIN64) #if !defined(_WIN32) && !defined (_WIN64)
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include <string> #include <string>
#include <fstream> #include <fstream>
#include <time.h> #include <time.h>
#include "Array.h"
#include "errno.h" #include "errno.h"
#include "Base64.h" #include "Base64.h"
#include <time.h> #include <time.h>
......
...@@ -1327,9 +1327,9 @@ void CFontList::SetDefaultFont(std::wstring& sName) ...@@ -1327,9 +1327,9 @@ void CFontList::SetDefaultFont(std::wstring& sName)
} }
} }
void CFontList::LoadFromArrayFiles(CArray<std::wstring>& oArray, int nFlag) void CFontList::LoadFromArrayFiles(std::vector<std::wstring>& oArray, int nFlag)
{ {
int nCount = oArray.GetCount(); size_t nCount = oArray.size();
FT_Library pLibrary = NULL; FT_Library pLibrary = NULL;
if (FT_Init_FreeType(&pLibrary)) if (FT_Init_FreeType(&pLibrary))
...@@ -1347,7 +1347,7 @@ void CFontList::LoadFromArrayFiles(CArray<std::wstring>& oArray, int nFlag) ...@@ -1347,7 +1347,7 @@ void CFontList::LoadFromArrayFiles(CArray<std::wstring>& oArray, int nFlag)
// определяем размер буфера, чтобы не выделять много кусков, а обойтись одним // определяем размер буфера, чтобы не выделять много кусков, а обойтись одним
int nMaxFontSize = 0; int nMaxFontSize = 0;
for (int nIndex = 0; nIndex < nCount; ++nIndex) for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
{ {
NSFile::CFileBinary oFile; NSFile::CFileBinary oFile;
if (oFile.OpenFile(oArray[nIndex])) if (oFile.OpenFile(oArray[nIndex]))
...@@ -1356,7 +1356,7 @@ void CFontList::LoadFromArrayFiles(CArray<std::wstring>& oArray, int nFlag) ...@@ -1356,7 +1356,7 @@ void CFontList::LoadFromArrayFiles(CArray<std::wstring>& oArray, int nFlag)
if (nSizeTmp > 100000000) if (nSizeTmp > 100000000)
{ {
// такие огромные шрифты не учитываем // такие огромные шрифты не учитываем
oArray.RemoveAt(nIndex); oArray.erase(oArray.begin() + nIndex, oArray.begin() + nIndex + 1);
nIndex--; nIndex--;
nCount--; nCount--;
} }
...@@ -1596,7 +1596,7 @@ void CFontList::LoadFromArrayFiles(CArray<std::wstring>& oArray, int nFlag) ...@@ -1596,7 +1596,7 @@ void CFontList::LoadFromArrayFiles(CArray<std::wstring>& oArray, int nFlag)
} }
void CFontList::LoadFromFolder(const std::wstring& strDirectory) void CFontList::LoadFromFolder(const std::wstring& strDirectory)
{ {
CArray<std::wstring> oArray = NSDirectory::GetFiles(strDirectory, true); std::vector<std::wstring> oArray = NSDirectory::GetFiles(strDirectory, true);
this->LoadFromArrayFiles(oArray); this->LoadFromArrayFiles(oArray);
} }
...@@ -1765,7 +1765,7 @@ static long GetNextNameValue(HKEY key, const std::wstring& sSubkey, std::wstring ...@@ -1765,7 +1765,7 @@ static long GetNextNameValue(HKEY key, const std::wstring& sSubkey, std::wstring
#endif #endif
CArray<std::wstring> CApplicationFonts::GetSetupFontFiles() std::vector<std::wstring> CApplicationFonts::GetSetupFontFiles()
{ {
#if defined(_WIN32) || defined (_WIN64) #if defined(_WIN32) || defined (_WIN64)
// Ищем директорию с фонтами (обычно это C:\Windows\Fonts) // Ищем директорию с фонтами (обычно это C:\Windows\Fonts)
...@@ -1791,8 +1791,9 @@ CArray<std::wstring> CApplicationFonts::GetSetupFontFiles() ...@@ -1791,8 +1791,9 @@ CArray<std::wstring> CApplicationFonts::GetSetupFontFiles()
std::wstring sName; std::wstring sName;
std::wstring sData; std::wstring sData;
std::map<std::wstring, bool> map_files; std::map<std::wstring, bool> map_files;
CArray<std::wstring> oArray; std::vector<std::wstring> oArray;
while (GetNextNameValue( HKEY_LOCAL_MACHINE, wsPath, sName, sData ) == ERROR_SUCCESS) while (GetNextNameValue( HKEY_LOCAL_MACHINE, wsPath, sName, sData ) == ERROR_SUCCESS)
{ {
if (wsPath.length()) if (wsPath.length())
...@@ -1805,7 +1806,7 @@ CArray<std::wstring> CApplicationFonts::GetSetupFontFiles() ...@@ -1805,7 +1806,7 @@ CArray<std::wstring> CApplicationFonts::GetSetupFontFiles()
if (map_files.find(sData) == map_files.end()) if (map_files.find(sData) == map_files.end())
{ {
oArray.Add(sData); oArray.push_back(sData);
map_files.insert(map_files.begin(), std::pair<std::wstring,bool>(sData,true)); map_files.insert(map_files.begin(), std::pair<std::wstring,bool>(sData,true));
} }
continue; continue;
...@@ -1820,7 +1821,7 @@ CArray<std::wstring> CApplicationFonts::GetSetupFontFiles() ...@@ -1820,7 +1821,7 @@ CArray<std::wstring> CApplicationFonts::GetSetupFontFiles()
if (map_files.find(sFileInDir) == map_files.end()) if (map_files.find(sFileInDir) == map_files.end())
{ {
oArray.Add(sFileInDir); oArray.push_back(sFileInDir);
map_files.insert(map_files.begin(), std::pair<std::wstring,bool>(sFileInDir,true)); map_files.insert(map_files.begin(), std::pair<std::wstring,bool>(sFileInDir,true));
} }
continue; continue;
...@@ -1830,16 +1831,16 @@ CArray<std::wstring> CApplicationFonts::GetSetupFontFiles() ...@@ -1830,16 +1831,16 @@ CArray<std::wstring> CApplicationFonts::GetSetupFontFiles()
#endif #endif
#if defined(__linux__) && !defined(_MAC) #if defined(__linux__) && !defined(_MAC)
CArray<std::wstring> _array = NSDirectory::GetFiles(L"/usr/share/fonts", true); std::vector<std::wstring> _array = NSDirectory::GetFiles(L"/usr/share/fonts", true);
NSDirectory::GetFiles2(L"/usr/share/X11/fonts", _array, true); NSDirectory::GetFiles2(L"/usr/share/X11/fonts", _array, true);
NSDirectory::GetFiles2(L"/usr/X11R6/lib/X11/fonts", _array, true); NSDirectory::GetFiles2(L"/usr/X11R6/lib/X11/fonts", _array, true);
return _array; return _array;
#endif #endif
#if defined(_MAC) && !defined(_IOS) #if defined(_MAC) && !defined(_IOS)
CArray<std::wstring> _array = NSDirectory::GetFiles(L"/Library/Fonts", true); std::vector<std::wstring> _array = NSDirectory::GetFiles(L"/Library/Fonts", true);
NSDirectory::GetFiles2(L"/System/Library/Fonts", _array, true); NSDirectory::GetFiles2(L"/System/Library/Fonts", _array, true);
return _array; return _array;
#endif #endif
#ifdef _IOS #ifdef _IOS
...@@ -1847,11 +1848,11 @@ CArray<std::wstring> CApplicationFonts::GetSetupFontFiles() ...@@ -1847,11 +1848,11 @@ CArray<std::wstring> CApplicationFonts::GetSetupFontFiles()
return GetSetupFontFiles_ios(); return GetSetupFontFiles_ios();
#endif #endif
CArray<std::wstring> ret; std::vector<std::wstring> ret;
return ret; return ret;
} }
void CApplicationFonts::InitializeFromArrayFiles(CArray<std::wstring>& files, int nFlag) void CApplicationFonts::InitializeFromArrayFiles(std::vector<std::wstring>& files, int nFlag)
{ {
m_oList.LoadFromArrayFiles(files, nFlag); m_oList.LoadFromArrayFiles(files, nFlag);
} }
...@@ -1860,7 +1861,7 @@ void CApplicationFonts::InitializeFromArrayFiles(CArray<std::wstring>& files, in ...@@ -1860,7 +1861,7 @@ void CApplicationFonts::InitializeFromArrayFiles(CArray<std::wstring>& files, in
void CApplicationFonts::InitFromReg() void CApplicationFonts::InitFromReg()
{ {
CArray<std::wstring> oArray = GetSetupFontFiles(); std::vector<std::wstring> oArray = GetSetupFontFiles();
m_oList.LoadFromArrayFiles(oArray); m_oList.LoadFromArrayFiles(oArray);
} }
......
...@@ -240,13 +240,13 @@ public: ...@@ -240,13 +240,13 @@ public:
void ToBuffer(BYTE** pDstData, LONG* pLen, std::wstring strDirectory = L"", bool bIsOnlyFileName = false); void ToBuffer(BYTE** pDstData, LONG* pLen, std::wstring strDirectory = L"", bool bIsOnlyFileName = false);
public: public:
void LoadFromArrayFiles(CArray<std::wstring>& arrFiles, int nFlag = 0); void LoadFromArrayFiles (std::vector<std::wstring>& arrFiles, int nFlag = 0);
void LoadFromFolder(const std::wstring& strDirectory); void LoadFromFolder (const std::wstring& strDirectory);
bool CheckLoadFromFolderBin(const std::wstring& strDirectory); bool CheckLoadFromFolderBin (const std::wstring& strDirectory);
void Add(CFontInfo* pInfo); void Add (CFontInfo* pInfo);
CFontInfo* GetByParams(CFontSelectFormat& oSelect, bool bIsDictionaryUse = true); CFontInfo* GetByParams (CFontSelectFormat& oSelect, bool bIsDictionaryUse = true);
CArray<CFontInfo*> GetAllByName(const std::wstring& strFontName); CArray<CFontInfo*> GetAllByName (const std::wstring& strFontName);
void SetDefaultFont(std::wstring& sName); void SetDefaultFont (std::wstring& sName);
}; };
class CApplicationFonts class CApplicationFonts
...@@ -268,8 +268,8 @@ public: ...@@ -268,8 +268,8 @@ public:
void InitializeFromFolder(std::wstring strFolder, bool bIsCheckSelection = true); void InitializeFromFolder(std::wstring strFolder, bool bIsCheckSelection = true);
void Initialize(bool bIsCheckSelection = true); void Initialize(bool bIsCheckSelection = true);
CArray<std::wstring> GetSetupFontFiles(); std::vector<std::wstring> GetSetupFontFiles();
void InitializeFromArrayFiles(CArray<std::wstring>& files, int nFlag = 0); void InitializeFromArrayFiles(std::vector<std::wstring>& files, int nFlag = 0);
#if defined(_WIN32) || defined (_WIN64) #if defined(_WIN32) || defined (_WIN64)
void InitFromReg(); void InitFromReg();
......
...@@ -52,12 +52,12 @@ HRESULT COfficeUtils::ExtractToDirectory(const std::wstring& zipFile, const std: ...@@ -52,12 +52,12 @@ HRESULT COfficeUtils::ExtractToDirectory(const std::wstring& zipFile, const std:
} }
HRESULT COfficeUtils::CompressFileOrDirectory(const std::wstring& name, const std::wstring& outputFile, SHORT level) HRESULT COfficeUtils::CompressFileOrDirectory(const std::wstring& name, const std::wstring& outputFile, bool bSorted, short level)
{ {
HRESULT result = S_FALSE; HRESULT result = S_FALSE;
if(NSDirectory::Exists(name)) if(NSDirectory::Exists(name))
{ {
if ( ZLibZipUtils::ZipDir( name.c_str(), outputFile.c_str(), m_fCallback, level ) == 0 ) if ( ZLibZipUtils::ZipDir( name.c_str(), outputFile.c_str(), m_fCallback, bSorted, level ) == 0 )
{ {
result = S_OK; result = S_OK;
} }
...@@ -92,7 +92,7 @@ HRESULT COfficeUtils::Uncompress(BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf ...@@ -92,7 +92,7 @@ HRESULT COfficeUtils::Uncompress(BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf
} }
} }
HRESULT COfficeUtils::Compress(BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf, ULONG sourceSize, SHORT level) HRESULT COfficeUtils::Compress(BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf, ULONG sourceSize, short level)
{ {
if ( ZLibZipUtils::CompressBytes( destBuf, destSize, sourceBuf, sourceSize, level ) == Z_OK ) if ( ZLibZipUtils::CompressBytes( destBuf, destSize, sourceBuf, sourceSize, level ) == Z_OK )
{ {
......
...@@ -39,20 +39,19 @@ class COfficeUtils ...@@ -39,20 +39,19 @@ class COfficeUtils
private: private:
OnProgressCallback* m_fCallback; OnProgressCallback* m_fCallback;
public: public:
COfficeUtils(OnProgressCallback* fCallback); COfficeUtils(OnProgressCallback* bCallback = NULL);
public: HRESULT ExtractToDirectory (const std::wstring& zipFile, const std::wstring& unzipDir, wchar_t* password, short extract_without_path);
HRESULT CompressFileOrDirectory (const std::wstring& name, const std::wstring& outputFile, bool bSorted = false, short level = -1);
HRESULT ExtractToDirectory(const std::wstring& zipFile, const std::wstring& unzipDir, wchar_t* password, SHORT extract_without_path);
HRESULT CompressFileOrDirectory(const std::wstring& name, const std::wstring& outputFile, SHORT level); HRESULT Uncompress (BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf, ULONG sourceSize);
HRESULT Uncompress(BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf, ULONG sourceSize); HRESULT Compress (BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf, ULONG sourceSize, short level = -1);
HRESULT Compress(BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf, ULONG sourceSize, SHORT level);
HRESULT IsArchive(const std::wstring& filename); HRESULT IsArchive (const std::wstring& filename);
HRESULT IsFileExistInArchive(const std::wstring& zipFile, const std::wstring& filePath); HRESULT IsFileExistInArchive (const std::wstring& zipFile, const std::wstring& filePath);
HRESULT LoadFileFromArchive(const std::wstring& zipFile, const std::wstring& filePath, BYTE** fileInBytes, ULONG& nFileSize); HRESULT LoadFileFromArchive (const std::wstring& zipFile, const std::wstring& filePath, BYTE** fileInBytes, ULONG& nFileSize);
HRESULT ExtractFilesToMemory(const std::wstring& zipFile, const ExtractedFileCallback& data_receiver, void* pParam, bool* result); HRESULT ExtractFilesToMemory (const std::wstring& zipFile, const ExtractedFileCallback& data_receiver, void* pParam, bool* result);
HRESULT CompressFilesFromMemory(const std::wstring& zipFile, const RequestFileCallback& data_source, void* pParam, SHORT compression_level, bool* result); HRESULT CompressFilesFromMemory (const std::wstring& zipFile, const RequestFileCallback& data_source, void* pParam, short compression_level, bool* result);
}; };
......
...@@ -499,7 +499,7 @@ int oneZipFile(zipFile & zf, zip_fileinfo & zi, std::wstring & file_name, std::w ...@@ -499,7 +499,7 @@ int oneZipFile(zipFile & zf, zip_fileinfo & zi, std::wstring & file_name, std::w
} }
return 0; return 0;
} }
int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback* progress, int compressionLevel ) int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback* progress, bool sorted, int compressionLevel )
{ {
if ( ( dir != NULL ) && ( outputFile != NULL ) ) if ( ( dir != NULL ) && ( outputFile != NULL ) )
{ {
...@@ -548,38 +548,40 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback* ...@@ -548,38 +548,40 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback*
zipDeque.pop_front(); zipDeque.pop_front();
} }
CArray<std::wstring> aCurFiles = NSDirectory::GetFiles(szText); std::vector<std::wstring> aCurFiles = NSDirectory::GetFiles(szText);
CArray<std::wstring> aCurDirectories = NSDirectory::GetDirectories(szText); std::vector<std::wstring> aCurDirectories = NSDirectory::GetDirectories(szText);
for(int i = 0; i < aCurDirectories.GetCount(); ++i) if (sorted)
{ {
std::wstring sCurDirectory = aCurDirectories[i]; std::sort(aCurFiles.begin(), aCurFiles.end());
std::wstring sDirName = NSSystemPath::GetFileName(sCurDirectory); std::sort(aCurDirectories.begin(), aCurDirectories.end());
StringDeque.push_back( sCurDirectory ); }
for(size_t i = 0; i < aCurDirectories.size(); ++i)
{
std::wstring sDirName = NSSystemPath::GetFileName(aCurDirectories[i]);
StringDeque.push_back( aCurDirectories[i] );
zipDeque.push_back( zipDir + sDirName ); zipDeque.push_back( zipDir + sDirName );
} }
for (int i = 0; i < aCurFiles.GetCount(); ++i) for (size_t i = 0; i < aCurFiles.size(); ++i)
{ {
std::wstring cFileName = NSSystemPath::GetFileName(aCurFiles[i]); std::wstring cFileName = NSSystemPath::GetFileName(aCurFiles[i]);
if (std::wstring::npos != cFileName.find(L"mimetype")) // возможно и полное соответствие if (std::wstring::npos != cFileName.find(L"mimetype")) // возможно и полное соответствие
{ {
std::wstring cFilePath = aCurFiles[i];
file = NSSystemPath::Combine(szText, cFileName); file = NSSystemPath::Combine(szText, cFileName);
zipFileName = zipDir + cFileName; zipFileName = zipDir + cFileName;
oneZipFile(zf, zi, file, zipFileName, 0, compressionLevel); oneZipFile(zf, zi, file, zipFileName, 0, compressionLevel);
aCurFiles.RemoveAt(i); aCurFiles.erase(aCurFiles.begin() + i, aCurFiles.begin() + i + 1);
break; break;
} }
} }
for (int i = 0; i < aCurFiles.GetCount(); ++i) for (size_t i = 0; i < aCurFiles.size(); ++i)
{ {
std::wstring cFilePath = aCurFiles[i]; std::wstring cFileName = NSSystemPath::GetFileName(aCurFiles[i]);
std::wstring cFileName = NSSystemPath::GetFileName(cFilePath);
file = NSSystemPath::Combine(szText, cFileName); file = NSSystemPath::Combine(szText, cFileName);
zipFileName = zipDir + cFileName; zipFileName = zipDir + cFileName;
...@@ -953,10 +955,12 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback* ...@@ -953,10 +955,12 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback*
StringDeque.pop_front(); StringDeque.pop_front();
CArray<std::wstring> aCurFiles = NSDirectory::GetFiles(szText); std::vector<std::wstring> aCurFiles = NSDirectory::GetFiles(szText);
filescount += aCurFiles.GetCount();
CArray<std::wstring> aCurDirectories = NSDirectory::GetDirectories(szText); filescount += aCurFiles.size();
for(int i = 0; i < aCurDirectories.GetCount(); ++i) std::vector<std::wstring> aCurDirectories = NSDirectory::GetDirectories(szText);
for(size_t i = 0; i < aCurDirectories.size(); ++i)
{ {
std::wstring sCurDirectory = aCurDirectories[i]; std::wstring sCurDirectory = aCurDirectories[i];
StringDeque.push_back( sCurDirectory ); StringDeque.push_back( sCurDirectory );
......
...@@ -43,22 +43,17 @@ ...@@ -43,22 +43,17 @@
#include "OfficeUtilsCommon.h" #include "OfficeUtilsCommon.h"
#include "../../DesktopEditor/common/Types.h" #include "../../DesktopEditor/common/Types.h"
using namespace std; using namespace std;
//#define ZLIB_WINAPI #include "zlib-1.2.3/contrib/minizip/unzip.h"
//#define CODEPAGE_ISSUE_FIX #include "zlib-1.2.3/contrib/minizip/zip.h"
//#pragma comment(lib, "zlibstat.lib") #include <zlib.h>
//#if defined(_WIN32) || defined (_WIN64)
#include "zlib-1.2.3/contrib/minizip/unzip.h"
#include "zlib-1.2.3/contrib/minizip/zip.h"
//#else
#include <zlib.h>
//#endif
namespace ZLibZipUtils namespace ZLibZipUtils
{ {
int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback* progress, int compressionLevel = -1 ); int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback* progress, bool sorted = false , int compressionLevel = -1);
int ZipFile( const WCHAR* inputFile, const WCHAR* outputFile, int compressionLevel = -1 ); int ZipFile( const WCHAR* inputFile, const WCHAR* outputFile, int compressionLevel = -1 );
bool ClearDirectory( const WCHAR* dir, bool delDir = false ); bool ClearDirectory( const WCHAR* dir, bool delDir = false );
int UnzipToDir( const WCHAR* zipFile, const WCHAR* unzipDir, const OnProgressCallback* progress, const WCHAR* password = NULL, bool opt_extract_without_path = false, bool clearOutputDirectory = false ); int UnzipToDir( const WCHAR* zipFile, const WCHAR* unzipDir, const OnProgressCallback* progress, const WCHAR* password = NULL, bool opt_extract_without_path = false, bool clearOutputDirectory = false );
......
This diff is collapsed.
...@@ -360,7 +360,7 @@ namespace NExtractTools ...@@ -360,7 +360,7 @@ namespace NExtractTools
std::wstring sToResultDir = NSDirectory::GetFolderPath(sToResult); std::wstring sToResultDir = NSDirectory::GetFolderPath(sToResult);
std::wstring sTo = sToResultDir + FILE_SEPARATOR_STR + _T("changes.zip"); std::wstring sTo = sToResultDir + FILE_SEPARATOR_STR + _T("changes.zip");
COfficeUtils oCOfficeUtils(NULL); COfficeUtils oCOfficeUtils(NULL);
oCOfficeUtils.CompressFileOrDirectory(sChangesDir, sTo, -1); oCOfficeUtils.CompressFileOrDirectory(sChangesDir, sTo);
} }
break; break;
} }
......
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