mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
xml
This commit is contained in:
@ -80,6 +80,8 @@ public:
|
||||
bool isVbaProjectFile(POLE::Storage * storage);
|
||||
bool isMS_OFFCRYPTOFormatFile (const std::wstring & fileName, std::wstring & documentID);
|
||||
|
||||
bool iXmlFile(const std::wstring & fileName);
|
||||
|
||||
std::wstring getDocumentID (const std::wstring & fileName);
|
||||
|
||||
bool isOOXFlatFormatFile(unsigned char* pBuffer,int dwBytes);
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
|
||||
#include "../DesktopEditor/common/Directory.h"
|
||||
#include "../OfficeUtils/src/OfficeUtils.h"
|
||||
#include "../DesktopEditor/xml/include/xmlutils.h"
|
||||
|
||||
//#if defined FILE_FORMAT_CHECKER_WITH_MACRO
|
||||
// #include "../MsBinaryFile/PptFile/Main/PPTFormatLib.h"
|
||||
@ -68,6 +69,18 @@ bool COfficeFileFormatChecker::isMultiPartsHtmlFormatFile(unsigned char* pBuffer
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::iXmlFile(const std::wstring & fileName)
|
||||
{
|
||||
XmlUtils::CXmlLiteReader oReader;
|
||||
if (!oReader.FromFile(fileName))
|
||||
return false;
|
||||
if (!oReader.ReadNextNode())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isHtmlFormatFile(unsigned char* pBuffer, int dwBytes, bool testCloseTag)
|
||||
{
|
||||
if (pBuffer == NULL || dwBytes < 4) return false;
|
||||
@ -585,6 +598,11 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName)
|
||||
}
|
||||
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN) return true;
|
||||
//------------------------------------------------------------------------------------------------
|
||||
if (iXmlFile(fileName))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_XML;
|
||||
return true;
|
||||
}
|
||||
//// by Extension
|
||||
|
||||
std::wstring::size_type nExtPos = fileName.rfind(L'.');
|
||||
|
||||
@ -56,6 +56,8 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0015
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0016
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_XML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0030
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_PRESENTATION 0x0080
|
||||
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x0001
|
||||
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x0002
|
||||
|
||||
@ -1477,6 +1477,26 @@ namespace NExtractTools
|
||||
OOX::CContentTypes oContentTypes;
|
||||
nRes = oXlsx.Write(sTo, oContentTypes) ? S_OK : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
|
||||
return nRes;
|
||||
}
|
||||
//xml -> xlsx
|
||||
_UINT32 xml2xlsx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
|
||||
{
|
||||
std::wstring sResultXlsxDir = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked");
|
||||
NSDirectory::CreateDirectory(sResultXlsxDir);
|
||||
_UINT32 nRes = xml2xlsx_dir(sFrom, sResultXlsxDir, sTemp, params);
|
||||
|
||||
if (SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
nRes = dir2zipMscrypt(sResultXlsxDir, sTo, sTemp, params);
|
||||
}
|
||||
return nRes;
|
||||
}
|
||||
_UINT32 xml2xlsx_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
|
||||
{
|
||||
_UINT32 nRes = AVS_FILEUTILS_ERROR_CONVERT;
|
||||
|
||||
|
||||
return nRes;
|
||||
}
|
||||
// csv -> xslx
|
||||
@ -5468,6 +5488,10 @@ namespace NExtractTools
|
||||
{
|
||||
result = zip2dir (sFileFrom, sFileTo);
|
||||
}break;
|
||||
case TCD_XML2XLSX:
|
||||
{
|
||||
result = xml2xlsx(sFileFrom, sFileTo, sTempDir, oInputParams);
|
||||
}break;
|
||||
case TCD_CSV2XLSX:
|
||||
{
|
||||
result = csv2xlsx (sFileFrom, sFileTo, sTempDir, oInputParams);
|
||||
|
||||
@ -106,6 +106,9 @@ namespace NExtractTools
|
||||
_UINT32 pptt_bin2pptx_dir (const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sTo, const std::wstring &sThemeDir, InputParams& params);
|
||||
_UINT32 pptt2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams& params);
|
||||
|
||||
_UINT32 xml2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
|
||||
_UINT32 xml2xlsx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
|
||||
|
||||
_UINT32 csv2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
|
||||
_UINT32 csv2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
|
||||
_UINT32 csv2xlsx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
|
||||
|
||||
@ -108,6 +108,17 @@ namespace NExtractTools
|
||||
|
||||
switch (OfficeFileFormatChecker.nFileType)
|
||||
{
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_XML:
|
||||
{
|
||||
if (0 == sExt2.compare(_T(".docx")))
|
||||
{
|
||||
res = TCD_TXT2DOCX;
|
||||
}
|
||||
else if (0 == sExt2.compare(_T(".xlsx")))
|
||||
{
|
||||
res = TCD_XML2XLSX;
|
||||
}
|
||||
}break;
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX:
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM:
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX:
|
||||
|
||||
@ -150,6 +150,8 @@ namespace NExtractTools
|
||||
TCD_DOCT2RTF,
|
||||
TCD_DOCX2RTF,
|
||||
TCD_DOCT_BIN2RTF,
|
||||
//xml 2
|
||||
TCD_XML2XLSX,
|
||||
//txt 2
|
||||
TCD_TXT2DOCX,
|
||||
TCD_TXT2DOCT,
|
||||
|
||||
Reference in New Issue
Block a user