Commit 122a5cd0 authored by ElenaSubbotina's avatar ElenaSubbotina

x2t - return error code by PptConvert

parent b0994759
...@@ -860,13 +860,26 @@ namespace NExtractTools ...@@ -860,13 +860,26 @@ namespace NExtractTools
NSDirectory::CreateDirectory(sResultPptxDir); NSDirectory::CreateDirectory(sResultPptxDir);
int nRes = ppt2pptx_dir(sFrom, sResultPptxDir, sTemp, params); int hRes = ppt2pptx_dir(sFrom, sResultPptxDir, sTemp, params);
if(SUCCEEDED_X2T(nRes))
if(SUCCEEDED_X2T(hRes))
{ {
COfficeUtils oCOfficeUtils(NULL); COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultPptxDir, sTo, true)) if(S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultPptxDir, sTo, true))
return 0; return 0;
} }
else if (AVS_ERROR_DRM == hRes)
{
if(!params.getDontSaveAdditional())
{
copyOrigin(sFrom, *params.m_sFileTo);
}
return AVS_FILEUTILS_ERROR_CONVERT_DRM;
}
else if (AVS_ERROR_PASSWORD == hRes)
{
return AVS_FILEUTILS_ERROR_CONVERT_PASSWORD;
}
return AVS_FILEUTILS_ERROR_CONVERT; return AVS_FILEUTILS_ERROR_CONVERT;
} }
int ppt2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) int ppt2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
...@@ -874,7 +887,22 @@ namespace NExtractTools ...@@ -874,7 +887,22 @@ namespace NExtractTools
COfficePPTFile pptFile; COfficePPTFile pptFile;
pptFile.put_TempDirectory(sTemp); pptFile.put_TempDirectory(sTemp);
return S_OK == pptFile.LoadFromFile(sFrom, sTo, params.getPassword()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
long hRes = pptFile.LoadFromFile(sFrom, sTo, params.getPassword());
if (AVS_ERROR_DRM == hRes)
{
if(!params.getDontSaveAdditional())
{
copyOrigin(sFrom, *params.m_sFileTo);
}
return AVS_FILEUTILS_ERROR_CONVERT_DRM;
}
else if (AVS_ERROR_PASSWORD == hRes)
{
return AVS_FILEUTILS_ERROR_CONVERT_PASSWORD;
}
return 0 == hRes ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
} }
// ppt -> pptt // ppt -> pptt
int ppt2pptt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) int ppt2pptt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
...@@ -905,22 +933,36 @@ namespace NExtractTools ...@@ -905,22 +933,36 @@ namespace NExtractTools
pptFile.put_TempDirectory(sTemp); pptFile.put_TempDirectory(sTemp);
if ( pptFile.LoadFromFile(sFrom, sTempUnpackedPPTX, params.getPassword()) != S_OK) return AVS_FILEUTILS_ERROR_CONVERT; long nRes = pptFile.LoadFromFile(sFrom, sTempUnpackedPPTX, params.getPassword());
// convert unzipped pptx to unzipped pptt
CPPTXFile *pptx_file = new CPPTXFile(NULL, NULL, NULL, NULL);
int nRes = 0; if (SUCCEEDED_X2T(nRes))
{
// convert unzipped pptx to unzipped pptt
CPPTXFile *pptx_file = new CPPTXFile(NULL, NULL, NULL, NULL);
if (pptx_file) if (pptx_file)
{ {
pptx_file->SetFontDir (params.getFontPath()); pptx_file->SetFontDir (params.getFontPath());
nRes = (S_OK == pptx_file->OpenFileToPPTY (sTempUnpackedPPTX, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; nRes = (S_OK == pptx_file->OpenFileToPPTY (sTempUnpackedPPTX, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
delete pptx_file; delete pptx_file;
} }
return nRes;
return nRes; }
else if (AVS_ERROR_DRM == nRes)
{
if(!params.getDontSaveAdditional())
{
copyOrigin(sFrom, *params.m_sFileTo);
}
return AVS_FILEUTILS_ERROR_CONVERT_DRM;
}
else if (AVS_ERROR_PASSWORD == nRes)
{
return AVS_FILEUTILS_ERROR_CONVERT_PASSWORD;
}
return AVS_FILEUTILS_ERROR_CONVERT;
} }
// pptx -> odp // pptx -> odp
......
...@@ -138,13 +138,15 @@ static std::wstring utf8_to_unicode(const char *src) ...@@ -138,13 +138,15 @@ static std::wstring utf8_to_unicode(const char *src)
InputParams oInputParams; InputParams oInputParams;
oInputParams.m_sFileFrom = new std::wstring(sArg1); oInputParams.m_sFileFrom = new std::wstring(sArg1);
oInputParams.m_sFileTo = new std::wstring(sArg2); oInputParams.m_sFileTo = new std::wstring(sArg2);
oInputParams.m_sPassword = new std::wstring(L"password");
// get conversion direction from 3rd argument
if (argc > 3) if (argc > 3)
{ {
oInputParams.m_sFontDir = new std::wstring(sArg3); oInputParams.m_sFontDir = new std::wstring(sArg3);
} }
if (argc > 4)
{
oInputParams.m_sPassword = new std::wstring(sArg4);
}
result = NExtractTools::fromInputParams(oInputParams); result = NExtractTools::fromInputParams(oInputParams);
} }
......
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