Commit 71527517 authored by konovalovsergey's avatar konovalovsergey

return same error code for doc, mscrypt as xls file

parent 9a33361a
...@@ -902,8 +902,20 @@ namespace NExtractTools ...@@ -902,8 +902,20 @@ namespace NExtractTools
{ {
COfficeDocFile docFile; COfficeDocFile docFile;
docFile.m_sTempFolder = sTemp; docFile.m_sTempFolder = sTemp;
long hRes = docFile.LoadFromFile( sFrom, sTo, params.m_sPassword ? *params.m_sPassword : L"", NULL);
return S_OK == docFile.LoadFromFile( sFrom, sTo, params.m_sPassword ? *params.m_sPassword : L"", NULL) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; 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;
} }
// doc -> doct // doc -> doct
...@@ -1305,7 +1317,40 @@ namespace NExtractTools ...@@ -1305,7 +1317,40 @@ namespace NExtractTools
} }
return AVS_FILEUTILS_ERROR_CONVERT; return AVS_FILEUTILS_ERROR_CONVERT;
} }
int fromMscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath, InputParams& params)
{
std::wstring sResultDecryptFile = sTemp + FILE_SEPARATOR_STR + L"uncrypt_file.oox";
int nRes = mscrypt2oox(sFrom, sResultDecryptFile, sTemp, sFontPath, params);
if (SUCCEEDED_X2T(nRes))
{
COfficeFileFormatChecker OfficeFileFormatChecker;
if (OfficeFileFormatChecker.isOfficeFile(sResultDecryptFile))
{
switch (OfficeFileFormatChecker.nFileType)
{
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX:
{
return fromDocument(sResultDecryptFile, AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX, sTemp, params.getXmlOptions(), params);
}break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX:
{
return fromSpreadsheet(sResultDecryptFile, AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX, sTemp, params.getXmlOptions(), params);
}break;
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX:
{
return fromPresentation(sResultDecryptFile, AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX, sTemp, params.getXmlOptions(), params);
}break;
}
}
}
else if (AVS_FILEUTILS_ERROR_CONVERT_DRM == nRes && !params.getDontSaveAdditional())
{
copyOrigin(sFrom, sTo);
}
return nRes;
}
//html //html
int html2doct_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const InputParams& params) int html2doct_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const InputParams& params)
{ {
...@@ -1590,8 +1635,25 @@ namespace NExtractTools ...@@ -1590,8 +1635,25 @@ namespace NExtractTools
nRes = AVS_FILEUTILS_ERROR_CONVERT; nRes = AVS_FILEUTILS_ERROR_CONVERT;
return nRes; return nRes;
} }
int fromDocument(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params) int fromDocument(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTemp, const std::wstring &sXmlOptions, const InputParams& params)
{ {
std::wstring sTo = *params.m_sFileTo;
int nFormatTo = AVS_OFFICESTUDIO_FILE_UNKNOWN;
if(NULL != params.m_nFormatTo)
nFormatTo = *params.m_nFormatTo;
std::wstring sFontPath;
if(NULL != params.m_sFontDir)
sFontPath = *params.m_sFontDir;
std::wstring sThemeDir;
if(NULL != params.m_sThemeDir)
sThemeDir = *params.m_sThemeDir;
bool bFromChanges = false;
if(NULL != params.m_bFromChanges)
bFromChanges = *params.m_bFromChanges;
bool bPaid = true;
if(NULL != params.m_bPaid)
bPaid = *params.m_bPaid;
int nRes = 0; int nRes = 0;
if(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML == nFormatFrom || AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT == nFormatFrom || AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB == nFormatFrom) if(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML == nFormatFrom || AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT == nFormatFrom || AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB == nFormatFrom)
{ {
...@@ -1732,8 +1794,25 @@ namespace NExtractTools ...@@ -1732,8 +1794,25 @@ namespace NExtractTools
nRes = AVS_FILEUTILS_ERROR_CONVERT; nRes = AVS_FILEUTILS_ERROR_CONVERT;
return nRes; return nRes;
} }
int fromSpreadsheet(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params) int fromSpreadsheet(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTemp, const std::wstring &sXmlOptions, const InputParams& params)
{ {
std::wstring sTo = *params.m_sFileTo;
int nFormatTo = AVS_OFFICESTUDIO_FILE_UNKNOWN;
if(NULL != params.m_nFormatTo)
nFormatTo = *params.m_nFormatTo;
std::wstring sFontPath;
if(NULL != params.m_sFontDir)
sFontPath = *params.m_sFontDir;
std::wstring sThemeDir;
if(NULL != params.m_sThemeDir)
sThemeDir = *params.m_sThemeDir;
bool bFromChanges = false;
if(NULL != params.m_bFromChanges)
bFromChanges = *params.m_bFromChanges;
bool bPaid = true;
if(NULL != params.m_bPaid)
bPaid = *params.m_bPaid;
int nRes = 0; int nRes = 0;
if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatFrom) if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatFrom)
{ {
...@@ -1838,8 +1917,25 @@ namespace NExtractTools ...@@ -1838,8 +1917,25 @@ namespace NExtractTools
nRes = AVS_FILEUTILS_ERROR_CONVERT; nRes = AVS_FILEUTILS_ERROR_CONVERT;
return nRes; return nRes;
} }
int fromPresentation(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params) int fromPresentation(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTemp, const std::wstring &sXmlOptions, const InputParams& params)
{ {
std::wstring sTo = *params.m_sFileTo;
int nFormatTo = AVS_OFFICESTUDIO_FILE_UNKNOWN;
if(NULL != params.m_nFormatTo)
nFormatTo = *params.m_nFormatTo;
std::wstring sFontPath;
if(NULL != params.m_sFontDir)
sFontPath = *params.m_sFontDir;
std::wstring sThemeDir;
if(NULL != params.m_sThemeDir)
sThemeDir = *params.m_sThemeDir;
bool bFromChanges = false;
if(NULL != params.m_bFromChanges)
bFromChanges = *params.m_bFromChanges;
bool bPaid = true;
if(NULL != params.m_bPaid)
bPaid = *params.m_bPaid;
int nRes = 0; int nRes = 0;
std::wstring sPptxDir = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked"); std::wstring sPptxDir = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked");
FileSystem::Directory::CreateDirectory(sPptxDir); FileSystem::Directory::CreateDirectory(sPptxDir);
......
...@@ -115,6 +115,7 @@ namespace NExtractTools ...@@ -115,6 +115,7 @@ namespace NExtractTools
int xlsx2ods (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath); int xlsx2ods (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath);
int xlsx_dir2ods (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath); int xlsx_dir2ods (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath);
int fromMscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath, InputParams& params);
int mscrypt2oox (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath, const InputParams& params); int mscrypt2oox (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath, const InputParams& params);
int mscrypt2oot (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath, InputParams& params); int mscrypt2oot (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath, InputParams& params);
int mscrypt2oot_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath, InputParams& params); int mscrypt2oot_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath, InputParams& params);
...@@ -127,15 +128,15 @@ namespace NExtractTools ...@@ -127,15 +128,15 @@ namespace NExtractTools
int fromDocxDir (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params); int fromDocxDir (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromDoctBin (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params); int fromDoctBin (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromDocument (const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params); int fromDocument (const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTemp, const std::wstring &sXmlOptions, const InputParams& params);
int fromXlsxDir (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params); int fromXlsxDir (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromXlstBin (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params); int fromXlstBin (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromSpreadsheet (const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params); int fromSpreadsheet (const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTemp, const std::wstring &sXmlOptions, const InputParams& params);
int fromPptxDir (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params); int fromPptxDir (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromPpttBin (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params); int fromPpttBin (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromPresentation(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params); int fromPresentation(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTemp, const std::wstring &sXmlOptions, const InputParams& params);
int fromT(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params); int fromT(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromCrossPlatform(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params); int fromCrossPlatform(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
......
...@@ -132,7 +132,8 @@ namespace NExtractTools ...@@ -132,7 +132,8 @@ namespace NExtractTools
TCD_XML2DOCX, TCD_XML2DOCX,
TCD_DOCX2XML, TCD_DOCX2XML,
// //
TCD_MSCRYPT2,
TCD_MSCRYPT2DOCT, TCD_MSCRYPT2DOCT,
TCD_MSCRYPT2XLST, TCD_MSCRYPT2XLST,
TCD_MSCRYPT2PPTT, TCD_MSCRYPT2PPTT,
...@@ -466,6 +467,8 @@ namespace NExtractTools ...@@ -466,6 +467,8 @@ namespace NExtractTools
eRes = TCD_CROSSPLATFORM2; eRes = TCD_CROSSPLATFORM2;
else if(AVS_OFFICESTUDIO_FILE_CANVAS_PDF == nFormatFrom) else if(AVS_OFFICESTUDIO_FILE_CANVAS_PDF == nFormatFrom)
eRes = TCD_CANVAS_PDF2; eRes = TCD_CANVAS_PDF2;
else if(AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO == nFormatFrom)
eRes = TCD_MSCRYPT2;
else if(AVS_OFFICESTUDIO_FILE_OTHER_ZIP == nFormatFrom && AVS_OFFICESTUDIO_FILE_UNKNOWN == nFormatTo) else if(AVS_OFFICESTUDIO_FILE_OTHER_ZIP == nFormatFrom && AVS_OFFICESTUDIO_FILE_UNKNOWN == nFormatTo)
eRes = TCD_UNZIPDIR; eRes = TCD_UNZIPDIR;
else if(AVS_OFFICESTUDIO_FILE_UNKNOWN == nFormatFrom && AVS_OFFICESTUDIO_FILE_OTHER_ZIP == nFormatTo) else if(AVS_OFFICESTUDIO_FILE_UNKNOWN == nFormatFrom && AVS_OFFICESTUDIO_FILE_OTHER_ZIP == nFormatTo)
...@@ -483,9 +486,7 @@ namespace NExtractTools ...@@ -483,9 +486,7 @@ namespace NExtractTools
{ {
TConversionDirection eRes = TCD_AUTO; TConversionDirection eRes = TCD_AUTO;
int nFormatFrom = *m_nFormatFrom; int nFormatFrom = *m_nFormatFrom;
if(AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO == nFormatFrom) if(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT == nFormatFrom && NULL == m_nCsvTxtEncoding)
eRes = TCD_ERROR;
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT == nFormatFrom && NULL == m_nCsvTxtEncoding)
{ {
int nCodePage = getEncodingByContent(); int nCodePage = getEncodingByContent();
if(nCodePage < 0) if(nCodePage < 0)
......
...@@ -180,9 +180,7 @@ int main(int argc, char *argv[]) ...@@ -180,9 +180,7 @@ int main(int argc, char *argv[])
if (TCD_ERROR == conversion) if (TCD_ERROR == conversion)
{ {
if(AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO == nFormatFrom) if(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT == nFormatFrom || AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatFrom)
return getReturnErrorCode(AVS_FILEUTILS_ERROR_CONVERT_MS_OFFCRYPTO);
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT == nFormatFrom || AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatFrom)
return getReturnErrorCode(AVS_FILEUTILS_ERROR_CONVERT_NEED_PARAMS); return getReturnErrorCode(AVS_FILEUTILS_ERROR_CONVERT_NEED_PARAMS);
else{ else{
// print out conversion direction error // print out conversion direction error
...@@ -415,15 +413,15 @@ int main(int argc, char *argv[]) ...@@ -415,15 +413,15 @@ int main(int argc, char *argv[])
}break; }break;
case TCD_DOCUMENT2: case TCD_DOCUMENT2:
{ {
result = fromDocument(sFileFrom, nFormatFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, oInputParams); result = fromDocument(sFileFrom, nFormatFrom, sTempDir, sXmlOptions, oInputParams);
}break; }break;
case TCD_SPREADSHEET2: case TCD_SPREADSHEET2:
{ {
result = fromSpreadsheet(sFileFrom, nFormatFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, oInputParams); result = fromSpreadsheet(sFileFrom, nFormatFrom, sTempDir, sXmlOptions, oInputParams);
}break; }break;
case TCD_PRESENTATION2: case TCD_PRESENTATION2:
{ {
result = fromPresentation(sFileFrom, nFormatFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, oInputParams); result = fromPresentation(sFileFrom, nFormatFrom, sTempDir, sXmlOptions, oInputParams);
}break; }break;
case TCD_T2: case TCD_T2:
{ {
...@@ -449,6 +447,10 @@ int main(int argc, char *argv[]) ...@@ -449,6 +447,10 @@ int main(int argc, char *argv[])
{ {
result = fromCanvasPdf(sFileFrom, nFormatFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid); result = fromCanvasPdf(sFileFrom, nFormatFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid);
}break; }break;
case TCD_MSCRYPT2:
{
result = fromMscrypt (sFileFrom, sFileTo, sTempDir, sFontPath, oInputParams);
}break;
case TCD_MSCRYPT2DOCT: case TCD_MSCRYPT2DOCT:
case TCD_MSCRYPT2XLST: case TCD_MSCRYPT2XLST:
case TCD_MSCRYPT2PPTT: case TCD_MSCRYPT2PPTT:
......
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