Add ProcessEnv class for global process properties

This commit is contained in:
Oleg Korshul
2023-09-06 19:57:49 +03:00
parent ab079f6776
commit add2c29954
14 changed files with 5769 additions and 4975 deletions

View File

@ -42,14 +42,14 @@ namespace POLE
class COfficeFileFormatChecker class COfficeFileFormatChecker
{ {
public: public:
int nFileType; int nFileType;
bool bMacroEnabled; bool bMacroEnabled;
std::wstring sDocumentID; std::wstring sDocumentID;
COfficeFileFormatChecker() COfficeFileFormatChecker()
{ {
nFileType = AVS_OFFICESTUDIO_FILE_UNKNOWN; nFileType = AVS_OFFICESTUDIO_FILE_UNKNOWN;
bMacroEnabled = false; bMacroEnabled = false;
} }
COfficeFileFormatChecker(std::wstring sFileName) COfficeFileFormatChecker(std::wstring sFileName)
{ {
@ -57,53 +57,52 @@ public:
isOfficeFile(sFileName); isOfficeFile(sFileName);
} }
bool isOfficeFile(const std::wstring & fileName);
bool isVbaProjectFile(const std::wstring & fileName);
std::wstring GetFormatExtension(const std::wstring & fileName); bool isOfficeFile(const std::wstring& fileName);
bool isVbaProjectFile(const std::wstring& fileName);
std::wstring GetFormatExtension(const std::wstring& fileName);
std::wstring GetExtensionByType(int type); std::wstring GetExtensionByType(int type);
static int GetFormatByExtension(const std::wstring& ext); static int GetFormatByExtension(const std::wstring& ext);
bool isOOXFormatFile (const std::wstring & fileName, bool unpacked = false); bool isOOXFormatFile(const std::wstring& fileName, bool unpacked = false);
bool isOpenOfficeFormatFile (const std::wstring & fileName, std::wstring & documentID); bool isOpenOfficeFormatFile(const std::wstring& fileName, std::wstring& documentID);
bool isOnlyOfficeFormatFile (const std::wstring & fileName); bool isOnlyOfficeFormatFile(const std::wstring& fileName);
bool isDocFormatFile (const std::wstring & fileName); bool isDocFormatFile(const std::wstring& fileName);
bool isXlsFormatFile (const std::wstring & fileName); bool isXlsFormatFile(const std::wstring& fileName);
bool isOleObjectFile (POLE::Storage* storage); bool isOleObjectFile(POLE::Storage* storage);
bool isDocFormatFile (POLE::Storage *storage); bool isDocFormatFile(POLE::Storage* storage);
bool isXlsFormatFile (POLE::Storage *storage); bool isXlsFormatFile(POLE::Storage* storage);
bool isPptFormatFile (POLE::Storage *storage); bool isPptFormatFile(POLE::Storage* storage);
bool isMS_OFFICECRYPTOFormatFile(POLE::Storage * storage, std::wstring & documentID); bool isMS_OFFICECRYPTOFormatFile(POLE::Storage* storage, std::wstring& documentID);
bool isMS_MITCRYPTOFormatFile(POLE::Storage * storage, std::wstring & documentID); bool isMS_MITCRYPTOFormatFile(POLE::Storage* storage, std::wstring& documentID);
bool isVbaProjectFile(POLE::Storage * storage); bool isVbaProjectFile(POLE::Storage* storage);
bool isMS_OFFCRYPTOFormatFile (const std::wstring & fileName, std::wstring & documentID); bool isMS_OFFCRYPTOFormatFile(const std::wstring& fileName, std::wstring& documentID);
bool iXmlFile(const std::wstring & fileName); bool iXmlFile(const std::wstring& fileName);
std::wstring getDocumentID(const std::wstring& fileName);
bool isOOXFlatFormatFile(unsigned char* pBuffer, int dwBytes);
bool isDocFlatFormatFile(unsigned char* pBuffer, int dwBytes);
std::wstring getDocumentID (const std::wstring & fileName);
bool isOOXFlatFormatFile(unsigned char* pBuffer,int dwBytes);
bool isDocFlatFormatFile(unsigned char* pBuffer,int dwBytes);
bool isXlsFlatFormatFile(unsigned char* pBuffer, int dwBytes); bool isXlsFlatFormatFile(unsigned char* pBuffer, int dwBytes);
bool isRtfFormatFile (unsigned char* pBuffer,int dwBytes); bool isRtfFormatFile(unsigned char* pBuffer, int dwBytes);
bool isHtmlFormatFile (unsigned char* pBuffer,int dwBytes, bool testCloseTag); bool isHtmlFormatFile(unsigned char* pBuffer, int dwBytes, bool testCloseTag);
bool isMultiPartsHtmlFormatFile(unsigned char* pBuffer, int dwBytes); bool isMultiPartsHtmlFormatFile(unsigned char* pBuffer, int dwBytes);
bool isPdfFormatFile (unsigned char* pBuffer,int dwBytes, std::wstring & documentID); bool isPdfFormatFile(unsigned char* pBuffer, int dwBytes, std::wstring& documentID);
bool isOpenOfficeFlatFormatFile(unsigned char* pBuffer,int dwBytes); bool isOpenOfficeFlatFormatFile(unsigned char* pBuffer, int dwBytes);
bool isBinaryDoctFormatFile (unsigned char* pBuffer,int dwBytes); bool isBinaryDoctFormatFile(unsigned char* pBuffer, int dwBytes);
bool isBinaryXlstFormatFile (unsigned char* pBuffer,int dwBytes); bool isBinaryXlstFormatFile(unsigned char* pBuffer, int dwBytes);
bool isBinaryPpttFormatFile (unsigned char* pBuffer,int dwBytes); bool isBinaryPpttFormatFile(unsigned char* pBuffer, int dwBytes);
bool isDjvuFormatFile(unsigned char* pBuffer,int dwBytes);
bool isMobiFormatFile(unsigned char* pBuffer,int dwBytes);
bool isFB2FormatFile(unsigned char* pBuffer,int dwBytes);
bool isXpsFile(const std::wstring & fileName);
bool isDjvuFormatFile(unsigned char* pBuffer, int dwBytes);
bool isMobiFormatFile(unsigned char* pBuffer, int dwBytes);
bool isFB2FormatFile(unsigned char* pBuffer, int dwBytes);
bool isXpsFile(const std::wstring& fileName);
}; };

File diff suppressed because it is too large Load Diff

View File

@ -87,6 +87,10 @@ SOURCES += ./../DesktopEditor/common/Directory.cpp
HEADERS += ./../DesktopEditor/common/SystemUtils.h HEADERS += ./../DesktopEditor/common/SystemUtils.h
SOURCES += ./../DesktopEditor/common/SystemUtils.cpp SOURCES += ./../DesktopEditor/common/SystemUtils.cpp
# PROCESSENV
HEADERS += ./../DesktopEditor/common/ProcessEnv.h
SOURCES += ./../DesktopEditor/common/ProcessEnv.cpp
core_windows { core_windows {
LIBS += -lRpcrt4 LIBS += -lRpcrt4
LIBS += -lShell32 LIBS += -lShell32

View File

@ -0,0 +1,210 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "./ProcessEnv.h"
#include <map>
#include "./StringBuilder.h"
#include "./File.h"
namespace NSProcessEnv
{
class CProps
{
public:
std::map<std::string, std::string> m_props;
public:
CProps()
{
}
static CProps& getInstance()
{
static CProps props;
return props;
}
void Load(XmlUtils::CXmlNode& node)
{
std::vector<XmlUtils::CXmlNode> childs;
if (node.GetChilds(childs))
{
for (std::vector<XmlUtils::CXmlNode>::iterator iter = childs.begin(); iter != childs.end(); iter++)
{
m_props.insert(std::make_pair(iter->GetNameA(), iter->GetTextA()));
}
}
}
std::string Save()
{
if (0 == m_props.size())
return "";
NSStringUtils::CStringBuilder oBuilder;
oBuilder.WriteString(L"<options>");
for (std::map<std::string, std::string>::iterator iter = m_props.begin(); iter != m_props.end(); iter++)
{
std::wstring name = UTF8_TO_U(iter->first);
oBuilder.AddCharSafe('<');
oBuilder.WriteString(name);
oBuilder.AddCharSafe('>');
const std::string& value = iter->second;
oBuilder.WriteEncodeXmlString(UTF8_TO_U(value));
oBuilder.WriteString(L"</");
oBuilder.WriteString(name);
oBuilder.AddCharSafe('>');
}
oBuilder.WriteString(L"</options>");
std::wstring sData = oBuilder.GetData();
return U_TO_UTF8(sData);
}
inline bool IsPresent(const char* key)
{
std::map<std::string, std::string>::const_iterator iter = m_props.find(std::string(key));
return (iter == m_props.end()) ? false : true;
}
inline bool GetBoolValue(const char* key)
{
std::map<std::string, std::string>::const_iterator iter = m_props.find(std::string(key));
if (iter == m_props.end())
return false;
if ("1" == iter->second || "true" == iter->second)
return true;
return false;
}
inline int GetIntValue(const char* key)
{
std::map<std::string, std::string>::const_iterator iter = m_props.find(std::string(key));
if (iter == m_props.end())
return 0;
return std::stoi(iter->second);
}
inline std::string GetStringValueA(const char* key)
{
std::map<std::string, std::string>::const_iterator iter = m_props.find(std::string(key));
if (iter == m_props.end())
return "";
return iter->second;
}
inline std::wstring GetStringValue(const char* key)
{
std::map<std::string, std::string>::const_iterator iter = m_props.find(std::string(key));
if (iter == m_props.end())
return L"";
return UTF8_TO_U(iter->second);
}
};
void Load(XmlUtils::CXmlNode& node)
{
CProps::getInstance().Load(node);
}
void Load(const std::string& strUtf8)
{
XmlUtils::CXmlNode node;
if (node.FromXmlStringA(strUtf8))
Load(node);
}
void Load(const std::wstring& str)
{
XmlUtils::CXmlNode node;
if (node.FromXmlString(str))
Load(node);
}
std::string Save()
{
return CProps::getInstance().Save();
}
// GET
bool IsPresent(const char* key)
{
return CProps::getInstance().IsPresent(key);
}
bool GetBoolValue(const char* key)
{
return CProps::getInstance().GetBoolValue(key);
}
int GetIntValue(const char* key)
{
return CProps::getInstance().GetIntValue(key);
}
std::string GetStringValueA(const char* key)
{
return CProps::getInstance().GetStringValueA(key);
}
std::wstring GetStringValue(const char* key)
{
return CProps::getInstance().GetStringValue(key);
}
// SET
bool SetBoolValue(const char* key, const bool& value)
{
bool res = IsPresent(key);
CProps::getInstance().m_props.insert(std::make_pair<std::string, std::string>(key, value ? "1" : "0"));
return res;
}
bool SetIntValue(const char* key, const int& value)
{
bool res = IsPresent(key);
CProps::getInstance().m_props.insert(std::make_pair<std::string, std::string>(key, std::to_string(value)));
return res;
}
bool SetStringValueA(const char* key, const char* value)
{
bool res = IsPresent(key);
CProps::getInstance().m_props.insert(std::make_pair<std::string, std::string>(key, value));
return res;
}
bool SetStringValue(const char* key, const wchar_t* value)
{
bool res = IsPresent(key);
std::wstring tmp(value);
CProps::getInstance().m_props.insert(std::make_pair<std::string, std::string>(key, U_TO_UTF8(tmp)));
return res;
}
} // namespace NSProcessEnv

View File

@ -0,0 +1,71 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef _PROCESS_ENV_H
#define _PROCESS_ENV_H
#include "../../Common/kernel_config.h"
#include "../xml/include/xmlutils.h"
#include <string>
namespace NSProcessEnv
{
namespace Converter
{
static const char* gc_allowNetworkRequest = "allowNetworkRequest";
static const char* gc_allowPrivateIP = "allowPrivateIP";
static const char* gc_proxy = "proxy";
static const char* gc_proxyUser = "proxyUser";
static const char* gc_proxyHeader = "proxyHeader";
}
// serialize
KERNEL_DECL void Load(XmlUtils::CXmlNode& node);
KERNEL_DECL void Load(const std::string& strUtf8);
KERNEL_DECL void Load(const std::wstring& str);
KERNEL_DECL std::string Save();
// props
KERNEL_DECL bool IsPresent(const char* key);
KERNEL_DECL bool GetBoolValue(const char* key);
KERNEL_DECL int GetIntValue(const char* key);
KERNEL_DECL std::string GetStringValueA(const char* key);
KERNEL_DECL std::wstring GetStringValue(const char* key);
// return is override
KERNEL_DECL bool SetBoolValue(const char* key, const bool& value);
KERNEL_DECL bool SetIntValue(const char* key, const int& value);
KERNEL_DECL bool SetStringValueA(const char* key, const char* value);
KERNEL_DECL bool SetStringValue(const char* key, const wchar_t* value);
}
#endif // _PROCESS_ENV_H

View File

@ -1512,6 +1512,10 @@ namespace NSDoctRenderer
{ {
m_pInternal->m_oParams.m_arFontDirs.push_back(std::wstring(value)); m_pInternal->m_oParams.m_arFontDirs.push_back(std::wstring(value));
} }
else if (sParam == "--options")
{
NSProcessEnv::Load(std::wstring(value));
}
} }
void CDocBuilder::SetPropertyW(const wchar_t* param, const wchar_t* value) void CDocBuilder::SetPropertyW(const wchar_t* param, const wchar_t* value)
{ {

View File

@ -61,6 +61,8 @@
#include "../fontengine/ApplicationFontsWorker.h" #include "../fontengine/ApplicationFontsWorker.h"
#include "../../OfficeUtils/src/OfficeUtils.h" #include "../../OfficeUtils/src/OfficeUtils.h"
#include "../common/ProcessEnv.h"
#ifdef CreateFile #ifdef CreateFile
#undef CreateFile #undef CreateFile
#endif #endif
@ -739,6 +741,11 @@ namespace NSDoctRenderer
oBuilder.WriteString(L"<m_bIsNoBase64>true</m_bIsNoBase64>"); oBuilder.WriteString(L"<m_bIsNoBase64>true</m_bIsNoBase64>");
oBuilder.WriteString(L"<m_sThemeDir>./sdkjs/slide/themes</m_sThemeDir><m_bDontSaveAdditional>true</m_bDontSaveAdditional>"); oBuilder.WriteString(L"<m_sThemeDir>./sdkjs/slide/themes</m_sThemeDir><m_bDontSaveAdditional>true</m_bDontSaveAdditional>");
oBuilder.WriteString(sParams); oBuilder.WriteString(sParams);
std::string sOptions = NSProcessEnv::Save();
if (!sOptions.empty())
oBuilder.WriteString(UTF8_TO_U(sOptions));
oBuilder.WriteString(L"</TaskQueueDataConvert>"); oBuilder.WriteString(L"</TaskQueueDataConvert>");
std::wstring sXmlConvert = oBuilder.GetData(); std::wstring sXmlConvert = oBuilder.GetData();
@ -1066,6 +1073,10 @@ namespace NSDoctRenderer
oBuilder.WriteEncodeXmlString(sDstTmpDir); oBuilder.WriteEncodeXmlString(sDstTmpDir);
oBuilder.WriteString(L"</m_sTempDir>"); oBuilder.WriteString(L"</m_sTempDir>");
std::string sOptions = NSProcessEnv::Save();
if (!sOptions.empty())
oBuilder.WriteString(UTF8_TO_U(sOptions));
oBuilder.WriteString(L"</TaskQueueDataConvert>"); oBuilder.WriteString(L"</TaskQueueDataConvert>");
std::wstring sXmlConvert = oBuilder.GetData(); std::wstring sXmlConvert = oBuilder.GetData();

View File

@ -168,6 +168,7 @@ namespace XmlUtils
void Clear(); void Clear();
std::wstring GetName(); std::wstring GetName();
std::string GetNameA();
std::wstring GetText(); std::wstring GetText();
std::string GetTextA(); std::string GetTextA();

View File

@ -35,13 +35,13 @@
namespace XmlUtils namespace XmlUtils
{ {
std::wstring GetNameNoNS(const std::wstring & strNodeName) std::wstring GetNameNoNS(const std::wstring& strNodeName)
{ {
int nFind = (int)strNodeName.find(L":"); int nFind = (int)strNodeName.find(L":");
if (-1 == nFind) if (-1 == nFind)
return strNodeName; return strNodeName;
return strNodeName.substr(nFind + 1); return strNodeName.substr(nFind + 1);
} }
const char* GetNameNoNS(const char* strNodeName) const char* GetNameNoNS(const char* strNodeName)
{ {
const char* find = strchr(strNodeName, ':'); const char* find = strchr(strNodeName, ':');
@ -54,42 +54,42 @@ namespace XmlUtils
return strNodeName; return strNodeName;
} }
} }
std::wstring GetNamespace(const std::wstring& strNodeName) std::wstring GetNamespace(const std::wstring& strNodeName)
{ {
int nFind = (int)strNodeName.find(L":"); int nFind = (int)strNodeName.find(L":");
if (-1 == nFind) if (-1 == nFind)
return L""; return L"";
return strNodeName.substr(0, nFind); return strNodeName.substr(0, nFind);
} }
} } // namespace XmlUtils
namespace XmlUtils namespace XmlUtils
{ {
class CXmlNodeBase : public IXmlDOMDocument class CXmlNodeBase : public IXmlDOMDocument
{ {
public: public:
IXmlDOMDocument* m_pDocument; IXmlDOMDocument* m_pDocument;
std::map<std::string, std::string> m_attributes; std::map<std::string, std::string> m_attributes;
std::vector<CXmlNodeBase*> m_nodes; std::vector<CXmlNodeBase*> m_nodes;
std::string m_sText; std::string m_sText;
std::wstring m_sName; std::wstring m_sName;
public: public:
CXmlNodeBase(); CXmlNodeBase();
~CXmlNodeBase(); ~CXmlNodeBase();
void AddRefDoc(); void AddRefDoc();
void ReleaseDoc(); void ReleaseDoc();
std::wstring GetXml(); std::wstring GetXml();
void GetXml(NSStringUtils::CStringBuilder& oWriter); void GetXml(NSStringUtils::CStringBuilder& oWriter);
}; };
CXmlNodeBase::CXmlNodeBase() CXmlNodeBase::CXmlNodeBase()
{ {
m_pDocument = NULL; m_pDocument = NULL;
m_sText = ""; m_sText = "";
m_sName = L""; m_sName = L"";
} }
CXmlNodeBase::~CXmlNodeBase() CXmlNodeBase::~CXmlNodeBase()
@ -145,17 +145,17 @@ namespace XmlUtils
{ {
m_nodes[i]->GetXml(oWriter); m_nodes[i]->GetXml(oWriter);
} }
oWriter.WriteEncodeXmlString(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)m_sText.c_str(), (LONG)m_sText.length()).c_str()); oWriter.WriteEncodeXmlString(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)m_sText.c_str(), (LONG)m_sText.length()).c_str());
oWriter.WriteString(L"</", 2); oWriter.WriteString(L"</", 2);
oWriter.WriteEncodeXmlString(m_sName.c_str()); oWriter.WriteEncodeXmlString(m_sName.c_str());
oWriter.WriteString(L">", 1); oWriter.WriteString(L">", 1);
} }
} } // namespace XmlUtils
namespace XmlUtils namespace XmlUtils
{ {
class CXmlDOMDocument : public IXmlDOMDocument, public CXmlLiteReader_Private class CXmlDOMDocument : public IXmlDOMDocument, public CXmlLiteReader_Private
{ {
public: public:
CXmlNodeBase* m_pNode; CXmlNodeBase* m_pNode;
@ -256,11 +256,11 @@ namespace XmlUtils
nCurDepth = GetDepth(); nCurDepth = GetDepth();
if (eNodeType == XmlNodeType_Text || eNodeType == XmlNodeType_Whitespace || eNodeType == XmlNodeType_SIGNIFICANT_WHITESPACE) if (eNodeType == XmlNodeType_Text || eNodeType == XmlNodeType_Whitespace || eNodeType == XmlNodeType_SIGNIFICANT_WHITESPACE)
{ {
m_pCurrentNode->m_sText += GetTextA(); m_pCurrentNode->m_sText += GetTextA();
} }
else if (eNodeType == XmlNodeType_CDATA) else if (eNodeType == XmlNodeType_CDATA)
{ {
m_pCurrentNode->m_sText += GetTextA(); m_pCurrentNode->m_sText += GetTextA();
} }
else if (eNodeType == XmlNodeType_Element) else if (eNodeType == XmlNodeType_Element)
{ {
@ -292,7 +292,7 @@ namespace XmlUtils
} }
} }
}; };
} } // namespace XmlUtils
namespace XmlUtils namespace XmlUtils
{ {
@ -316,7 +316,7 @@ namespace XmlUtils
} }
bool CXmlNode::FromXmlFile(const std::wstring& sFile, bool bRemoveRootNode) bool CXmlNode::FromXmlFile(const std::wstring& sFile, bool bRemoveRootNode)
{ {
//ignore bRemoveRootNode // ignore bRemoveRootNode
CXmlDOMDocument* m_pDocument = new CXmlDOMDocument(); CXmlDOMDocument* m_pDocument = new CXmlDOMDocument();
bool bRes = m_pDocument->FromFile(sFile); bool bRes = m_pDocument->FromFile(sFile);
@ -333,9 +333,9 @@ namespace XmlUtils
delete m_pDocument; delete m_pDocument;
return false; return false;
} }
//присваиваем m_pBase без AddRef, чтобы при удалении CXmlNode начался удаляться m_pBase(после конструктора RefCount==1, а если сделать AddRef то не удалится) // присваиваем m_pBase без AddRef, чтобы при удалении CXmlNode начался удаляться m_pBase(после конструктора RefCount==1, а если сделать AddRef то не удалится)
m_pBase = m_pDocument->m_pNode; m_pBase = m_pDocument->m_pNode;
//после Parse все Node из m_pDocument сделали ему AddRef, поэтому можем вызвать Release(потому что напрямую нигде его не используем), а окончательно он удалится после удаления всех Node // после Parse все Node из m_pDocument сделали ему AddRef, поэтому можем вызвать Release(потому что напрямую нигде его не используем), а окончательно он удалится после удаления всех Node
m_pDocument->Release(); m_pDocument->Release();
return true; return true;
@ -359,15 +359,15 @@ namespace XmlUtils
delete m_pDocument; delete m_pDocument;
return false; return false;
} }
//присваиваем m_pBase без AddRef, чтобы при удалении CXmlNode начался удаляться m_pBase(после конструктора RefCount==1, а если сделать AddRef то не удалится) // присваиваем m_pBase без AddRef, чтобы при удалении CXmlNode начался удаляться m_pBase(после конструктора RefCount==1, а если сделать AddRef то не удалится)
m_pBase = m_pDocument->m_pNode; m_pBase = m_pDocument->m_pNode;
//после Parse все Node из m_pDocument сделали ему AddRef, поэтому можем вызвать Release(потому что напрямую нигде его не используем), а окончательно он удалится после удаления всех Node // после Parse все Node из m_pDocument сделали ему AddRef, поэтому можем вызвать Release(потому что напрямую нигде его не используем), а окончательно он удалится после удаления всех Node
m_pDocument->Release(); m_pDocument->Release();
return true; return true;
} }
bool CXmlNode::FromXmlString(const wchar_t* sString) bool CXmlNode::FromXmlString(const wchar_t* sString)
{ {
return FromXmlString(std::wstring(sString)); return FromXmlString(std::wstring(sString));
} }
bool CXmlNode::FromXmlString(const std::wstring& sString) bool CXmlNode::FromXmlString(const std::wstring& sString)
{ {
@ -386,37 +386,41 @@ namespace XmlUtils
{ {
return (IsValid() ? m_pBase->m_sName : L""); return (IsValid() ? m_pBase->m_sName : L"");
} }
std::string CXmlNode::GetTextA() std::string CXmlNode::GetNameA()
{
if (IsValid())
{
return m_pBase->m_sText;
}
else
return "";
}
std::wstring CXmlNode::GetText()
{ {
if (IsValid()) return (IsValid() ? U_TO_UTF8(m_pBase->m_sName) : "");
{ }
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)m_pBase->m_sText.c_str(), (LONG)m_pBase->m_sText.length()); std::string CXmlNode::GetTextA()
} {
else if (IsValid())
return L""; {
return m_pBase->m_sText;
}
else
return "";
}
std::wstring CXmlNode::GetText()
{
if (IsValid())
{
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)m_pBase->m_sText.c_str(), (LONG)m_pBase->m_sText.length());
}
else
return L"";
} }
bool CXmlNode::GetTextIfExist(std::wstring& sOutput) bool CXmlNode::GetTextIfExist(std::wstring& sOutput)
{ {
bool bRes = false; bool bRes = false;
if (IsValid() && !m_pBase->m_sText.empty()) if (IsValid() && !m_pBase->m_sText.empty())
{ {
sOutput = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)m_pBase->m_sText.c_str(), (LONG)m_pBase->m_sText.length()); sOutput = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)m_pBase->m_sText.c_str(), (LONG)m_pBase->m_sText.length());
bRes = true; bRes = true;
} }
return bRes; return bRes;
} }
std::wstring CXmlNode::GetTextExt(const std::wstring& strDefaultValue) std::wstring CXmlNode::GetTextExt(const std::wstring& strDefaultValue)
{ {
//todo xml:space preserve // todo xml:space preserve
std::wstring sRes; std::wstring sRes;
if (!GetTextIfExist(sRes)) if (!GetTextIfExist(sRes))
sRes = strDefaultValue; sRes = strDefaultValue;
@ -436,31 +440,31 @@ namespace XmlUtils
return GetAttribute(std::wstring(strAttibuteName)); return GetAttribute(std::wstring(strAttibuteName));
} }
void CXmlNode::ReadAllAttributesA(std::vector<std::string>& strNames, std::vector<std::string>& strValues) void CXmlNode::ReadAllAttributesA(std::vector<std::string>& strNames, std::vector<std::string>& strValues)
{ {
if (!IsValid()) if (!IsValid())
return; return;
std::map<std::string, std::string>::iterator p; std::map<std::string, std::string>::iterator p;
for (p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p) for (p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p)
{ {
strNames.push_back(p->first); strNames.push_back(p->first);
strValues.push_back(p->second); strValues.push_back(p->second);
} }
} }
void CXmlNode::ReadAllAttributes(std::vector<std::wstring>& strNames, std::vector<std::wstring>& strValues) void CXmlNode::ReadAllAttributes(std::vector<std::wstring>& strNames, std::vector<std::wstring>& strValues)
{ {
if (!IsValid()) if (!IsValid())
return; return;
std::map<std::string, std::string>::iterator p; std::map<std::string, std::string>::iterator p;
for (p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p) for (p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p)
{ {
strNames.push_back (NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)p->first.c_str(), (long)p->first.length())); strNames.push_back(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)p->first.c_str(), (long)p->first.length()));
strValues.push_back (NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)p->second.c_str(), (long)p->second.length())); strValues.push_back(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)p->second.c_str(), (long)p->second.length()));
} }
} }
std::string CXmlNode::GetAttributeA(const std::string& sName, const std::string& _default) std::string CXmlNode::GetAttributeA(const std::string& sName, const std::string& _default)
{ {
@ -515,41 +519,41 @@ namespace XmlUtils
{ {
return m_pBase->m_attributes.size(); return m_pBase->m_attributes.size();
} }
else else
return 0; return 0;
} }
void CXmlNode::GetAllAttributes(std::vector<std::wstring>& names, std::vector<std::wstring>& values) void CXmlNode::GetAllAttributes(std::vector<std::wstring>& names, std::vector<std::wstring>& values)
{ {
for (std::map<std::string, std::string>::iterator p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p) for (std::map<std::string, std::string>::iterator p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p)
{ {
names.push_back(UTF8_TO_U(p->first)); names.push_back(UTF8_TO_U(p->first));
values.push_back(UTF8_TO_U(p->second)); values.push_back(UTF8_TO_U(p->second));
} }
} }
void CXmlNode::GetAllAttributes(std::vector<std::string>& names, std::vector<std::string>& values) void CXmlNode::GetAllAttributes(std::vector<std::string>& names, std::vector<std::string>& values)
{ {
for (std::map<std::string, std::string>::iterator p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p) for (std::map<std::string, std::string>::iterator p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p)
{ {
names.push_back(p->first); names.push_back(p->first);
values.push_back(p->second); values.push_back(p->second);
} }
} }
void CXmlNode::GetAllAttributes(std::list<std::wstring>& names, std::list<std::wstring>& values) void CXmlNode::GetAllAttributes(std::list<std::wstring>& names, std::list<std::wstring>& values)
{ {
for (std::map<std::string, std::string>::iterator p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p) for (std::map<std::string, std::string>::iterator p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p)
{ {
names.push_back(UTF8_TO_U(p->first)); names.push_back(UTF8_TO_U(p->first));
values.push_back(UTF8_TO_U(p->second)); values.push_back(UTF8_TO_U(p->second));
} }
} }
void CXmlNode::GetAllAttributes(std::list<std::string>& names, std::list<std::string>& values) void CXmlNode::GetAllAttributes(std::list<std::string>& names, std::list<std::string>& values)
{ {
for (std::map<std::string, std::string>::iterator p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p) for (std::map<std::string, std::string>::iterator p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p)
{ {
names.push_back(p->first); names.push_back(p->first);
values.push_back(p->second); values.push_back(p->second);
} }
} }
bool CXmlNode::GetAttributeIfExist(const std::wstring& sName, std::wstring& sOutput) bool CXmlNode::GetAttributeIfExist(const std::wstring& sName, std::wstring& sOutput)
{ {
bool bRes = false; bool bRes = false;
@ -674,16 +678,16 @@ namespace XmlUtils
{ {
std::wstring sText; std::wstring sText;
if (oTemp.GetTextIfExist(sText)) if (oTemp.GetTextIfExist(sText))
{ {
try try
{ {
nRes = std::stoi(sText); nRes = std::stoi(sText);
} }
catch (...) catch (...)
{ {
nRes = nDef; nRes = nDef;
} }
} }
} }
return nRes; return nRes;
} }
@ -693,11 +697,11 @@ namespace XmlUtils
std::wstring sRes; std::wstring sRes;
if (!GetAttributeIfExist(strAttributeName, sRes)) if (!GetAttributeIfExist(strAttributeName, sRes))
{ {
CXmlNode oTemp; CXmlNode oTemp;
if (GetNode(strAttributeName, oTemp)) if (GetNode(strAttributeName, oTemp))
sRes = oTemp.GetText(); sRes = oTemp.GetText();
else else
sRes = strDefaultValue; sRes = strDefaultValue;
} }
return sRes; return sRes;
} }
@ -736,7 +740,7 @@ namespace XmlUtils
{ {
std::vector<CXmlNode> oNodes; std::vector<CXmlNode> oNodes;
if (IsValid()) if (IsValid())
{ {
bool bGetAll = false; bool bGetAll = false;
if (L"*" == sName) if (L"*" == sName)
@ -750,7 +754,7 @@ namespace XmlUtils
CXmlNodeBase* pBase = m_pBase->m_nodes[i]; CXmlNodeBase* pBase = m_pBase->m_nodes[i];
oNode.SetBase(pBase); oNode.SetBase(pBase);
oNodes.push_back(oNode); oNodes.push_back(oNode);
} }
} }
} }
@ -780,7 +784,7 @@ namespace XmlUtils
CXmlNode oNode; CXmlNode oNode;
CXmlNodeBase* pBase = m_pBase->m_nodes[i]; CXmlNodeBase* pBase = m_pBase->m_nodes[i];
oNode.SetBase(pBase); oNode.SetBase(pBase);
oNodes.push_back(oNode); oNodes.push_back(oNode);
} }
} }
} }
@ -801,7 +805,7 @@ namespace XmlUtils
CXmlNode oNode; CXmlNode oNode;
CXmlNodeBase* pBase = m_pBase->m_nodes[i]; CXmlNodeBase* pBase = m_pBase->m_nodes[i];
oNode.SetBase(pBase); oNode.SetBase(pBase);
oXmlNodes.push_back(oNode); oXmlNodes.push_back(oNode);
} }
} }
} }
@ -827,10 +831,10 @@ namespace XmlUtils
} }
return bRes; return bRes;
} }
bool CXmlNode::GetNodes(const std::wstring& sName, std::vector<CXmlNode>& oNodes) bool CXmlNode::GetNodes(const std::wstring& sName, std::vector<CXmlNode>& oNodes)
{ {
oNodes = GetNodes(sName); oNodes = GetNodes(sName);
return (0 != oNodes.size()); return (0 != oNodes.size());
} }
CXmlNode& CXmlNode::operator=(const CXmlNode& oSrc) CXmlNode& CXmlNode::operator=(const CXmlNode& oSrc)
@ -860,7 +864,7 @@ namespace XmlUtils
NSStringUtils::CStringBuilder oWriter; NSStringUtils::CStringBuilder oWriter;
m_pBase->GetXml(oWriter); m_pBase->GetXml(oWriter);
return oWriter.GetData(); return oWriter.GetData();
} }
void CXmlNode::SetBase(CXmlNodeBase* pBase) void CXmlNode::SetBase(CXmlNodeBase* pBase)
{ {
@ -871,181 +875,178 @@ namespace XmlUtils
if (NULL != pBaseOld) if (NULL != pBaseOld)
pBaseOld->Release(); pBaseOld->Release();
} }
std::wstring CXmlNode::GetNamespace(const std::wstring& strNodeName) std::wstring CXmlNode::GetNamespace(const std::wstring& strNodeName)
{ {
int nFind = strNodeName.find(wchar_t(':')); int nFind = strNodeName.find(wchar_t(':'));
if (-1 == nFind) if (-1 == nFind)
return L""; return L"";
return strNodeName.substr(0, nFind); return strNodeName.substr(0, nFind);
} }
std::wstring CXmlNode::GetNameNoNS(const std::wstring& strNodeName) std::wstring CXmlNode::GetNameNoNS(const std::wstring& strNodeName)
{ {
int nFind = strNodeName.find(wchar_t(':')); int nFind = strNodeName.find(wchar_t(':'));
if (-1 == nFind) if (-1 == nFind)
return strNodeName; return strNodeName;
return strNodeName.substr(nFind + 1); return strNodeName.substr(nFind + 1);
} }
} } // namespace XmlUtils
namespace XmlUtils namespace XmlUtils
{ {
class CXmlBuffer class CXmlBuffer
{ {
public: public:
NSStringUtils::CStringBuilderA builder; NSStringUtils::CStringBuilderA builder;
public: public:
CXmlBuffer() CXmlBuffer()
{ {
} }
~CXmlBuffer() ~CXmlBuffer()
{ {
} }
}; };
static int buffer_xmlBufferIOWrite(CXmlBuffer* buf, const char* buffer, int len) static int buffer_xmlBufferIOWrite(CXmlBuffer* buf, const char* buffer, int len)
{ {
buf->builder.WriteString(buffer, (size_t)len); buf->builder.WriteString(buffer, (size_t)len);
return len; return len;
} }
static int buffer_xmlBufferIOClose(CXmlBuffer* buf) static int buffer_xmlBufferIOClose(CXmlBuffer* buf)
{ {
XML_UNUSED(buf); XML_UNUSED(buf);
return 0; return 0;
} }
static int buffer_xmlC14NIsVisibleCallback(void * user_data, xmlNodePtr node, xmlNodePtr parent) static int buffer_xmlC14NIsVisibleCallback(void* user_data, xmlNodePtr node, xmlNodePtr parent)
{ {
XML_UNUSED(user_data); XML_UNUSED(user_data);
XML_UNUSED(parent); XML_UNUSED(parent);
if (node->type == XML_TEXT_NODE) if (node->type == XML_TEXT_NODE)
{ {
const char* cur = (char*)node->content; const char* cur = (char*)node->content;
size_t size = strlen(cur); size_t size = strlen(cur);
for (size_t i = 0; i < size; ++i, ++cur) for (size_t i = 0; i < size; ++i, ++cur)
{ {
if (*cur != '\n' && *cur != '\r' && *cur != '\t') if (*cur != '\n' && *cur != '\r' && *cur != '\t')
return 1; return 1;
} }
return 0; return 0;
} }
return 1; return 1;
} }
std::string NSXmlCanonicalizator::Execute(const std::string& sXml, int mode, bool withComments) std::string NSXmlCanonicalizator::Execute(const std::string& sXml, int mode, bool withComments)
{ {
#ifdef LIBXML_C14N_ENABLED #ifdef LIBXML_C14N_ENABLED
xmlDocPtr xmlDoc = xmlParseMemory((char*)sXml.c_str(), (int)sXml.length()); xmlDocPtr xmlDoc = xmlParseMemory((char*)sXml.c_str(), (int)sXml.length());
CXmlBuffer bufferC14N; CXmlBuffer bufferC14N;
xmlOutputBufferPtr _buffer = xmlOutputBufferCreateIO((xmlOutputWriteCallback)buffer_xmlBufferIOWrite, xmlOutputBufferPtr _buffer = xmlOutputBufferCreateIO((xmlOutputWriteCallback)buffer_xmlBufferIOWrite, (xmlOutputCloseCallback)buffer_xmlBufferIOClose, &bufferC14N, NULL);
(xmlOutputCloseCallback)buffer_xmlBufferIOClose,
&bufferC14N,
NULL);
xmlC14NExecute(xmlDoc, buffer_xmlC14NIsVisibleCallback, NULL, mode, NULL, withComments ? 1 : 0, _buffer); xmlC14NExecute(xmlDoc, buffer_xmlC14NIsVisibleCallback, NULL, mode, NULL, withComments ? 1 : 0, _buffer);
xmlOutputBufferClose(_buffer); xmlOutputBufferClose(_buffer);
return bufferC14N.builder.GetData(); return bufferC14N.builder.GetData();
#else #else
return ""; return "";
#endif #endif
} }
std::string NSXmlCanonicalizator::Execute(const std::wstring& sXmlFile, int mode, bool withComments) std::string NSXmlCanonicalizator::Execute(const std::wstring& sXmlFile, int mode, bool withComments)
{ {
std::string sXml; std::string sXml;
NSFile::CFileBinary::ReadAllTextUtf8A(sXmlFile, sXml); NSFile::CFileBinary::ReadAllTextUtf8A(sXmlFile, sXml);
return Execute(sXml, mode, withComments); return Execute(sXml, mode, withComments);
} }
} } // namespace XmlUtils
std::string XmlUtils::GetUtf8FromFileContent(unsigned char* pData, unsigned int len) std::string XmlUtils::GetUtf8FromFileContent(unsigned char* pData, unsigned int len)
{ {
if (4 > len) if (4 > len)
return std::string((char*)pData, (size_t)len); return std::string((char*)pData, (size_t)len);
if (pData[0] == 0xEF && pData[1] == 0xBB && pData[2] == 0xFE && pData[3] == 0xBF) if (pData[0] == 0xEF && pData[1] == 0xBB && pData[2] == 0xFE && pData[3] == 0xBF)
{ {
return std::string((char*)pData + 3, (size_t)(len - 3)); return std::string((char*)pData + 3, (size_t)(len - 3));
} }
char markerUtf16 = 0; char markerUtf16 = 0;
if (pData[0] == 0xFF && pData[1] == 0xFE && !(pData[2] == 0x00 && pData[3] == 0x00)) if (pData[0] == 0xFF && pData[1] == 0xFE && !(pData[2] == 0x00 && pData[3] == 0x00))
markerUtf16 = 1; markerUtf16 = 1;
if (pData[0] == 0xFE && pData[1] == 0xFF) if (pData[0] == 0xFE && pData[1] == 0xFF)
markerUtf16 = 2; markerUtf16 = 2;
if (0 != markerUtf16) if (0 != markerUtf16)
{ {
int nCountSymbols = (len - 2) >> 1; int nCountSymbols = (len - 2) >> 1;
int nCountSymbolsNatural = 0; int nCountSymbolsNatural = 0;
unsigned int* pUnicodes = new unsigned int[nCountSymbols]; unsigned int* pUnicodes = new unsigned int[nCountSymbols];
unsigned char* pCurrent = pData + 2; unsigned char* pCurrent = pData + 2;
for (int i = 0; i < nCountSymbols; ++i) for (int i = 0; i < nCountSymbols; ++i)
{ {
unsigned short nLeading = (markerUtf16 == 1) ? (pCurrent[0] | (pCurrent[1] << 8)) : (pCurrent[1] | (pCurrent[0] << 8)); unsigned short nLeading = (markerUtf16 == 1) ? (pCurrent[0] | (pCurrent[1] << 8)) : (pCurrent[1] | (pCurrent[0] << 8));
pCurrent += 2; pCurrent += 2;
if (nLeading < 0xD800 || nLeading > 0xDFFF) if (nLeading < 0xD800 || nLeading > 0xDFFF)
{ {
pUnicodes[nCountSymbolsNatural++] = nLeading; pUnicodes[nCountSymbolsNatural++] = nLeading;
} }
else else
{ {
i++; i++;
if (i == nCountSymbols) if (i == nCountSymbols)
break; break;
unsigned short nTrailing = (markerUtf16 == 1) ? (pCurrent[0] | (pCurrent[1] << 8)) : (pCurrent[1] | (pCurrent[0] << 8)); unsigned short nTrailing = (markerUtf16 == 1) ? (pCurrent[0] | (pCurrent[1] << 8)) : (pCurrent[1] | (pCurrent[0] << 8));
pCurrent += 2; pCurrent += 2;
if (nTrailing >= 0xDC00 && nTrailing <= 0xDFFF) if (nTrailing >= 0xDC00 && nTrailing <= 0xDFFF)
{ {
pUnicodes[nCountSymbolsNatural++] = 0x10000 + (((nLeading & 0x03FF) << 10) | (nTrailing & 0x03FF)); pUnicodes[nCountSymbolsNatural++] = 0x10000 + (((nLeading & 0x03FF) << 10) | (nTrailing & 0x03FF));
} }
} }
} }
std::string sRet = NSStringExt::CConverter::GetUtf8FromUTF32(pUnicodes, nCountSymbolsNatural); std::string sRet = NSStringExt::CConverter::GetUtf8FromUTF32(pUnicodes, nCountSymbolsNatural);
RELEASEARRAYOBJECTS(pUnicodes); RELEASEARRAYOBJECTS(pUnicodes);
return sRet; return sRet;
} }
char markerUtf32 = 0; char markerUtf32 = 0;
if (pData[0] == 0xFF && pData[1] == 0xFE && pData[2] == 0x00 && pData[3] == 0x00) if (pData[0] == 0xFF && pData[1] == 0xFE && pData[2] == 0x00 && pData[3] == 0x00)
markerUtf32 = 1; markerUtf32 = 1;
if (pData[0] == 0 && pData[1] == 0 && pData[2] == 0xFE && pData[3] == 0xFF) if (pData[0] == 0 && pData[1] == 0 && pData[2] == 0xFE && pData[3] == 0xFF)
markerUtf32 = 2; markerUtf32 = 2;
if (0 != markerUtf16) if (0 != markerUtf16)
{ {
int nCountSymbols = (len - 4) >> 2; int nCountSymbols = (len - 4) >> 2;
int nCountSymbolsNatural = 0; int nCountSymbolsNatural = 0;
unsigned int* pUnicodes = new unsigned int[nCountSymbols]; unsigned int* pUnicodes = new unsigned int[nCountSymbols];
unsigned char* pCurrent = pData + 4; unsigned char* pCurrent = pData + 4;
if (markerUtf32 == 1) if (markerUtf32 == 1)
{ {
for (int i = 0; i < nCountSymbols; ++i, pCurrent += 4) for (int i = 0; i < nCountSymbols; ++i, pCurrent += 4)
pUnicodes[nCountSymbolsNatural++] = (pCurrent[0] | (pCurrent[1] << 8) | (pCurrent[2] << 16) | (pCurrent[3] << 24)); pUnicodes[nCountSymbolsNatural++] = (pCurrent[0] | (pCurrent[1] << 8) | (pCurrent[2] << 16) | (pCurrent[3] << 24));
} }
else else
{ {
for (int i = 0; i < nCountSymbols; ++i, pCurrent += 4) for (int i = 0; i < nCountSymbols; ++i, pCurrent += 4)
pUnicodes[nCountSymbolsNatural++] = (pCurrent[3] | (pCurrent[2] << 8) | (pCurrent[1] << 16) | (pCurrent[0] << 24)); pUnicodes[nCountSymbolsNatural++] = (pCurrent[3] | (pCurrent[2] << 8) | (pCurrent[1] << 16) | (pCurrent[0] << 24));
} }
std::string sRet = NSStringExt::CConverter::GetUtf8FromUTF32(pUnicodes, nCountSymbolsNatural); std::string sRet = NSStringExt::CConverter::GetUtf8FromUTF32(pUnicodes, nCountSymbolsNatural);
RELEASEARRAYOBJECTS(pUnicodes); RELEASEARRAYOBJECTS(pUnicodes);
return sRet; return sRet;
} }
return std::string((char*)pData, (size_t)len); return std::string((char*)pData, (size_t)len);
} }

File diff suppressed because it is too large Load Diff

View File

@ -39,204 +39,204 @@
#define X2T_DECL_EXPORT Q_DECL_EXPORT #define X2T_DECL_EXPORT Q_DECL_EXPORT
#endif #endif
#include <string>
#include "../../OOXML/Base/Base.h" #include "../../OOXML/Base/Base.h"
#include <string>
namespace NExtractTools namespace NExtractTools
{ {
class InputParams; class InputParams;
class InputParamsMailMerge; class InputParamsMailMerge;
} } // namespace NExtractTools
namespace NExtractTools namespace NExtractTools
{ {
_UINT32 docx2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 docx2doct_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 docx2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 docx2doct(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 docx_dir2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params, const std::wstring &sDocxFile); _UINT32 docx_dir2doct(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params, const std::wstring &sDocxFile);
_UINT32 docx_dir2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params, const std::wstring &sDocxFile); _UINT32 docx_dir2doct_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params, const std::wstring &sDocxFile);
_UINT32 doct_bin2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams& params); _UINT32 doct_bin2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams &params);
_UINT32 doct_bin2docx_dir (const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sTo, const std::wstring &sThemeDir, InputParams& params); _UINT32 doct_bin2docx_dir(const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sTo, const std::wstring &sThemeDir, InputParams &params);
_UINT32 doct2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams& params); _UINT32 doct2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams &params);
_UINT32 docxflat2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 docxflat2doct(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 docxflat2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 docxflat2doct_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 docxflat2odt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 docxflat2odt(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 docxflat2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 docxflat2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 package2ooxml (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 package2ooxml(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 package2ooxml_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 package2ooxml_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 package2bin_t (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 package2bin_t(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 package2bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 package2bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 dotm2docm (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 dotm2docm(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 dotm2docm_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params); _UINT32 dotm2docm_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 dotx2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 dotx2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 dotx2docx_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params); _UINT32 dotx2docx_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 docm2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 docm2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 docm2docx_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params); _UINT32 docm2docx_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 dotm2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 dotm2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 dotm2docx_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params); _UINT32 dotm2docx_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 xlsx2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xlsx2xlst(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xlsx2xlst_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xlsx2xlst_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xlsxflat2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xlsxflat2xlst(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xlsxflat2xlst_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xlsxflat2xlst_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xlsxflat2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xlsxflat2xlsx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xlsxflat2xlsx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xlsxflat2xlsx_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xlsx_dir2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params, bool bXmlOptions, const std::wstring &sXlsxFile); _UINT32 xlsx_dir2xlst(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params, bool bXmlOptions, const std::wstring &sXlsxFile);
_UINT32 xlsx_dir2xlst_bin (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params, bool bXmlOptions, const std::wstring &sXlsxFile); _UINT32 xlsx_dir2xlst_bin(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params, bool bXmlOptions, const std::wstring &sXlsxFile);
_UINT32 xlst_bin2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams& params); _UINT32 xlst_bin2xlsx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams &params);
_UINT32 xlst_bin2xlsx_dir (const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sTo, const std::wstring &sThemeDir, InputParams& params); _UINT32 xlst_bin2xlsx_dir(const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sTo, const std::wstring &sThemeDir, InputParams &params);
_UINT32 xlst2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams& params); _UINT32 xlst2xlsx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams &params);
_UINT32 xltx2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 xltx2xlsx_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params);
_UINT32 xltm2xlsm (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 xltm2xlsm_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params);
_UINT32 xlsm2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 xlsm2xlsx_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params);
_UINT32 xltm2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 xltm2xlsx_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params);
_UINT32 xlsb2xlsx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 xlsx2xlsb (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 xlsx_dir2xlsb (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 pptx2pptt_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xltx2xlsx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 pptx_dir2pptt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params, const std::wstring &sPptxFile); _UINT32 xltx2xlsx_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 pptx_dir2pptt_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params, const std::wstring &sPptxFile); _UINT32 xltm2xlsm(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 pptx2pptt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xltm2xlsm_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 pptt_bin2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams& params); _UINT32 xlsm2xlsx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 pptt_bin2pptx_dir (const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sTo, const std::wstring &sThemeDir, InputParams& params); _UINT32 xlsm2xlsx_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 pptt2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams& params); _UINT32 xltm2xlsx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xltm2xlsx_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 xlsb2xlsx_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xlsx2xlsb(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xlsx_dir2xlsb(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xml2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 pptx2pptt_bin(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 pptx_dir2pptt(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params, const std::wstring &sPptxFile);
_UINT32 pptx_dir2pptt_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params, const std::wstring &sPptxFile);
_UINT32 pptx2pptt(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 pptt_bin2pptx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams &params);
_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 csv2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xml2xlsx(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 xml2xlsx_dir(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);
_UINT32 csv2xlst_bin (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params);
_UINT32 xlst2csv (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 xlsx_dir2csv (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 xlsx2csv (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 xlst_bin2csv (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 bin2pdf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bPaid, const std::wstring &sThemeDir, 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);
_UINT32 csv2xlst_bin(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 xlst2csv(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xlsx_dir2csv(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xlsx2csv(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xlst_bin2csv(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 ppsx2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 bin2pdf(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bPaid, const std::wstring &sThemeDir, InputParams &params);
_UINT32 ppsx2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params);
_UINT32 potx2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 potx2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params);
_UINT32 ppsm2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 ppsm2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params);
_UINT32 potm2pptm (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 potm2pptm_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params);
_UINT32 ppsm2pptm (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 ppsm2pptm_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params);
_UINT32 pptm2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 pptm2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params);
_UINT32 potm2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 potm2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params);
_UINT32 ppt2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 ppsx2pptx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 ppt2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 ppsx2pptx_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 ppt2pptt_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 potx2pptx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 ppt2pptt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 potx2pptx_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 ppt2pptm (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 ppsm2pptx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 ppt2pptm_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 ppsm2pptx_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 potm2pptm(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 potm2pptm_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 ppsm2pptm(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 ppsm2pptm_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 pptm2pptx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 pptm2pptx_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 potm2pptx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 potm2pptx_dir(const std::wstring &sFrom, const std::wstring &sTo, InputParams &params);
_UINT32 rtf2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 ppt2pptx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 rtf2docx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 ppt2pptx_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 rtf2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 ppt2pptt_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 rtf2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 ppt2pptt(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 docx2rtf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 ppt2pptm(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 docx_dir2rtf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 ppt2pptm_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 doct2rtf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams& params);
_UINT32 doct_bin2rtf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams& params);
_UINT32 doc2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 rtf2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 doc2docx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 rtf2docx_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 doc2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 rtf2doct(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 doc2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 rtf2doct_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 docx_dir2doc (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 docx2rtf(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 doc2docm (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 docx_dir2rtf(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 doc2docm_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 doct2rtf(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams &params);
_UINT32 doct_bin2rtf(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams &params);
_UINT32 xls2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 doc2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xls2xlsx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 doc2docx_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xls2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 doc2doct(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xls2xlst_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 doc2doct_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xls2xlsm (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 docx_dir2doc(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xls2xlsm_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 doc2docm(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 doc2docm_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 txt2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xls2xlsx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 txt2docx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xls2xlsx_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 txt2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xls2xlst(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 txt2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xls2xlst_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 docx_dir2txt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params); _UINT32 xls2xlsm(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xls2xlsm_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 odf2oox (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 txt2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 odf2oox_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 txt2docx_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 odf2oot (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 txt2doct(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 odf2oot_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 txt2doct_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 docx_dir2txt(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 odf_flat2oox (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 odf2oox(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 odf_flat2oox_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 odf2oox_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 odf_flat2oot (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 odf2oot(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 odf_flat2oot_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 odf2oot_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 docx2odt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 odf_flat2oox(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 docx_dir2odt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params, bool bTemplate); _UINT32 odf_flat2oox_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xlsx2ods (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 odf_flat2oot(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 xlsx_dir2ods (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params, bool bTemplate); _UINT32 odf_flat2oot_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 pptx2odp (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
_UINT32 pptx_dir2odp (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params, bool bTemplate);
_UINT32 fromMscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 docx2odt(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 fromMitcrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 docx_dir2odt(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params, bool bTemplate);
_UINT32 mscrypt2oox (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 xlsx2ods(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 mitcrypt2oox (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 xlsx_dir2ods(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params, bool bTemplate);
_UINT32 mscrypt2oot (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 pptx2odp(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 mscrypt2oot_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 pptx_dir2odp(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params, bool bTemplate);
_UINT32 mitcrypt2oot_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
_UINT32 oox2mscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
_UINT32 msVbaProject2dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 fromMscrypt(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 fromMitcrypt(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 html2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 mscrypt2oox(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 html2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 mitcrypt2oox(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 html2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 mscrypt2oot(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 mscrypt2oot_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 mitcrypt2oot_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
//------------------------------------------------------------------------------------------------------------------------------------------------- _UINT32 oox2mscrypt(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 dir2zip (const std::wstring &sFrom, const std::wstring &sTo, bool bSorted = false, int method = 8/*Z_DEFLATED*/, short level = -1, bool bDateTime = false);
_UINT32 dir2zipMscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params);
_UINT32 zip2dir (const std::wstring &sFrom, const std::wstring &sTo);
_UINT32 convertmailmerge (const InputParamsMailMerge& oMailMergeSend,const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bPaid, const std::wstring &sThemeDir, InputParams& params); _UINT32 msVbaProject2dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 fromDocxDir (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams& params, const std::wstring &sDocxFile); _UINT32 html2doct_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 fromDoctBin (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams& params); _UINT32 html2doct(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 fromDocument (const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTemp, InputParams& params); _UINT32 html2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 fromXlsxDir (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams& params, const std::wstring &sXlsxFile); //-------------------------------------------------------------------------------------------------------------------------------------------------
_UINT32 fromXlsbXlsxDir (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams& params, const std::wstring &sXlsxFile); _UINT32 dir2zip(const std::wstring &sFrom, const std::wstring &sTo, bool bSorted = false, int method = 8 /*Z_DEFLATED*/, short level = -1, bool bDateTime = false);
_UINT32 fromXlstBin (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams& params); _UINT32 dir2zipMscrypt(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams &params);
_UINT32 fromSpreadsheet (const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTemp, InputParams& params); _UINT32 zip2dir(const std::wstring &sFrom, const std::wstring &sTo);
_UINT32 fromPptxDir (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams& params, const std::wstring &sPptxFile); _UINT32 convertmailmerge(const InputParamsMailMerge &oMailMergeSend, const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bPaid, const std::wstring &sThemeDir, InputParams &params);
_UINT32 fromPpttBin (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams& params);
_UINT32 fromPresentation(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTemp, InputParams& params);
_UINT32 fromT(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams& params); _UINT32 fromDocxDir(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams &params, const std::wstring &sDocxFile);
_UINT32 fromCrossPlatform(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams& params); _UINT32 fromDoctBin(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams &params);
_UINT32 fromCanvasPdf(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams& params); _UINT32 fromDocument(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTemp, InputParams &params);
_UINT32 fromInputParams(InputParams& oInputParams); _UINT32 fromXlsxDir(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams &params, const std::wstring &sXlsxFile);
_UINT32 detectMacroInFile(InputParams& oInputParams); _UINT32 fromXlsbXlsxDir(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams &params, const std::wstring &sXlsxFile);
_UINT32 fromXlstBin(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams &params);
_UINT32 fromSpreadsheet(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTemp, InputParams &params);
_UINT32 fromPptxDir(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams &params, const std::wstring &sPptxFile);
_UINT32 fromPpttBin(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams &params);
_UINT32 fromPresentation(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTemp, InputParams &params);
_UINT32 fromT(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams &params);
_UINT32 fromCrossPlatform(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams &params);
_UINT32 fromCanvasPdf(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bPaid, InputParams &params);
_UINT32 fromInputParams(InputParams &oInputParams);
_UINT32 detectMacroInFile(InputParams &oInputParams);
void createJSCaches(); void createJSCaches();
X2T_DECL_EXPORT _UINT32 FromFile(const std::wstring& file); X2T_DECL_EXPORT _UINT32 FromFile(const std::wstring &file);
X2T_DECL_EXPORT _UINT32 FromXml(const std::wstring& xml); X2T_DECL_EXPORT _UINT32 FromXml(const std::wstring &xml);
} } // namespace NExtractTools
#endif // ASCCONVERTERS_H #endif // ASCCONVERTERS_H

View File

@ -30,14 +30,14 @@
* *
*/ */
#include "cextracttools.h" #include "cextracttools.h"
#include "../../DesktopEditor/common/StringBuilder.h"
#include "../../DesktopEditor/common/Directory.h" #include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/common/Path.h" #include "../../DesktopEditor/common/Path.h"
#include "../../DesktopEditor/common/StringBuilder.h"
#include "../../OfficeUtils/src/OfficeUtils.h" #include "../../OfficeUtils/src/OfficeUtils.h"
namespace NExtractTools namespace NExtractTools
{ {
const TConversionDirection getConversionDirectionFromExt (const std::wstring &sFile1, const std::wstring &sFile2) const TConversionDirection getConversionDirectionFromExt(const std::wstring& sFile1, const std::wstring& sFile2)
{ {
TConversionDirection res = TCD_ERROR; TConversionDirection res = TCD_ERROR;
@ -59,7 +59,8 @@ namespace NExtractTools
} }
// check for directory in name // check for directory in name
bool bIsFile1Directory = (std::wstring::npos != nExt1Pos) ? ((std::wstring::npos != nSeparator1Pos) && (nExt1Pos < nSeparator1Pos)) : (std::wstring::npos != nSeparator1Pos); // i.e: /root1/child1.lalala/folder bool bIsFile1Directory =
(std::wstring::npos != nExt1Pos) ? ((std::wstring::npos != nSeparator1Pos) && (nExt1Pos < nSeparator1Pos)) : (std::wstring::npos != nSeparator1Pos); // i.e: /root1/child1.lalala/folder
bool bIsFile2Directory = (std::wstring::npos != nExt2Pos) ? ((std::wstring::npos != nSeparator2Pos) && (nExt2Pos < nSeparator2Pos)) : (std::wstring::npos != nSeparator2Pos); bool bIsFile2Directory = (std::wstring::npos != nExt2Pos) ? ((std::wstring::npos != nSeparator2Pos) && (nExt2Pos < nSeparator2Pos)) : (std::wstring::npos != nSeparator2Pos);
// automatic zip/unzip task detection // automatic zip/unzip task detection
@ -72,10 +73,10 @@ namespace NExtractTools
} }
else else
{ {
// dir ( ??? файл без расширения???) -> zip // dir ( ??? файл без расширения???) -> zip
if (NSDirectory::Exists(sFile1)) if (NSDirectory::Exists(sFile1))
return TCD_ZIPDIR; return TCD_ZIPDIR;
} }
} }
else if (bIsFile2Directory) else if (bIsFile2Directory)
@ -103,9 +104,9 @@ namespace NExtractTools
COfficeFileFormatChecker OfficeFileFormatChecker; COfficeFileFormatChecker OfficeFileFormatChecker;
if (OfficeFileFormatChecker.isOfficeFile(sFile1)) if (OfficeFileFormatChecker.isOfficeFile(sFile1))
{ {
int &type = OfficeFileFormatChecker.nFileType; int& type = OfficeFileFormatChecker.nFileType;
switch (OfficeFileFormatChecker.nFileType) switch (OfficeFileFormatChecker.nFileType)
{ {
case AVS_OFFICESTUDIO_FILE_DOCUMENT_XML: case AVS_OFFICESTUDIO_FILE_DOCUMENT_XML:
@ -118,7 +119,8 @@ namespace NExtractTools
{ {
res = TCD_XML2XLSX; res = TCD_XML2XLSX;
} }
}break; }
break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX: case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM: case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX: case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX:
@ -126,314 +128,437 @@ namespace NExtractTools
case AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM: case AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF: case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF:
{ {
if (0 == sExt2.compare(L".doct")) res = TCD_DOCX2DOCT; if (0 == sExt2.compare(L".doct"))
else if (0 == sExt2.compare(L".bin")) res = TCD_DOCX2DOCT_BIN; res = TCD_DOCX2DOCT;
else if (0 == sExt2.compare(L".rtf")) res = TCD_DOCX2RTF; else if (0 == sExt2.compare(L".bin"))
else if (0 == sExt2.compare(L".odt")) res = TCD_DOCX2ODT; res = TCD_DOCX2DOCT_BIN;
else if (0 == sExt2.compare(L".docx")) else if (0 == sExt2.compare(L".rtf"))
{ res = TCD_DOCX2RTF;
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX) else if (0 == sExt2.compare(L".odt"))
res = TCD_DOTX2DOCX; res = TCD_DOCX2ODT;
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM) else if (0 == sExt2.compare(L".docx"))
res = TCD_DOCM2DOCX; {
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM) if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX)
res = TCD_DOTM2DOCX; res = TCD_DOTX2DOCX;
//oform 2 docx ??? if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM)
//docxf 2 docx ??? res = TCD_DOCM2DOCX;
} if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM)
else if (0 == sExt2.compare(L".docm")) res = TCD_DOTM2DOCM; res = TCD_DOTM2DOCX;
else if (0 == sExt2.compare(L".txt")) res = TCD_DOCX2TXT; // oform 2 docx ???
}break; // docxf 2 docx ???
}
else if (0 == sExt2.compare(L".docm"))
res = TCD_DOTM2DOCM;
else if (0 == sExt2.compare(L".txt"))
res = TCD_DOCX2TXT;
}
break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_PACKAGE: case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_PACKAGE:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_PACKAGE: case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_PACKAGE:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX_PACKAGE: case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX_PACKAGE:
{ {
if (0 == sExt2.compare(L".doct")) res = TCD_PKG2BIN_T; if (0 == sExt2.compare(L".doct"))
else if (0 == sExt2.compare(L".pptt")) res = TCD_PKG2BIN_T; res = TCD_PKG2BIN_T;
else if (0 == sExt2.compare(L".xlst")) res = TCD_PKG2BIN_T; else if (0 == sExt2.compare(L".pptt"))
else if (0 == sExt2.compare(L".docx")) res = TCD_PKG2OOXML; res = TCD_PKG2BIN_T;
else if (0 == sExt2.compare(L".xlsx")) res = TCD_PKG2OOXML; else if (0 == sExt2.compare(L".xlst"))
else if (0 == sExt2.compare(L".pptx")) res = TCD_PKG2OOXML; res = TCD_PKG2BIN_T;
else if (0 == sExt2.compare(L".bin")) res = TCD_PKG2BIN; else if (0 == sExt2.compare(L".docx"))
}break; res = TCD_PKG2OOXML;
else if (0 == sExt2.compare(L".xlsx"))
res = TCD_PKG2OOXML;
else if (0 == sExt2.compare(L".pptx"))
res = TCD_PKG2OOXML;
else if (0 == sExt2.compare(L".bin"))
res = TCD_PKG2BIN;
}
break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_FLAT: case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_FLAT:
{ {
if (0 == sExt2.compare(L".doct")) res = TCD_DOCXFLAT2DOCT; if (0 == sExt2.compare(L".doct"))
else if (0 == sExt2.compare(L".bin")) res = TCD_DOCXFLAT2DOCT_BIN; res = TCD_DOCXFLAT2DOCT;
}break; else if (0 == sExt2.compare(L".bin"))
res = TCD_DOCXFLAT2DOCT_BIN;
}
break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_FLAT: case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_FLAT:
{ {
if (0 == sExt2.compare(L".xlst")) res = TCD_XLSXFLAT2XLST; if (0 == sExt2.compare(L".xlst"))
else if (0 == sExt2.compare(L".bin")) res = TCD_XLSXFLAT2XLST_BIN; res = TCD_XLSXFLAT2XLST;
else if (0 == sExt2.compare(L".xlsx")) res = TCD_XLSXFLAT2XLSX; else if (0 == sExt2.compare(L".bin"))
}break; res = TCD_XLSXFLAT2XLST_BIN;
else if (0 == sExt2.compare(L".xlsx"))
res = TCD_XLSXFLAT2XLSX;
}
break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX: case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM: case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX: case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM: case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM:
{ {
if (0 == sExt2.compare(L".xlst")) res = TCD_XLSX2XLST; if (0 == sExt2.compare(L".xlst"))
else if (0 == sExt2.compare(L".bin")) res = TCD_XLSX2XLST_BIN; res = TCD_XLSX2XLST;
else if (0 == sExt2.compare(L".csv")) res = TCD_XLSX2CSV; else if (0 == sExt2.compare(L".bin"))
else if (0 == sExt2.compare(L".ods")) res = TCD_XLSX2ODS; res = TCD_XLSX2XLST_BIN;
else if (0 == sExt2.compare(L".xlsx")) else if (0 == sExt2.compare(L".csv"))
{ res = TCD_XLSX2CSV;
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX) else if (0 == sExt2.compare(L".ods"))
res = TCD_XLTX2XLSX; res = TCD_XLSX2ODS;
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM) else if (0 == sExt2.compare(L".xlsx"))
res = TCD_XLSM2XLSX; {
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM) if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX)
res = TCD_XLTM2XLSX; res = TCD_XLTX2XLSX;
} if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM)
else if (0 == sExt2.compare(L".xlsm")) res = TCD_XLTM2XLSM; res = TCD_XLSM2XLSX;
else if (0 == sExt2.compare(L".xlsb")) res = TCD_XLSX2XLSB; if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM)
}break; res = TCD_XLTM2XLSX;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSB: }
{ else if (0 == sExt2.compare(L".xlsm"))
if (0 == sExt2.compare(L".xlst")) res = TCD_XLSB2XLST; res = TCD_XLTM2XLSM;
} else if (0 == sExt2.compare(L".xlsb"))
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX: res = TCD_XLSX2XLSB;
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM: }
break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSB:
{
if (0 == sExt2.compare(L".xlst"))
res = TCD_XLSB2XLST;
}
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX: case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_POTX: case AVS_OFFICESTUDIO_FILE_PRESENTATION_POTX:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM: case AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM: case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM:
{
if (0 == sExt2.compare(L".bin"))
res = TCD_PPTX2PPTT_BIN;
else if (0 == sExt2.compare(L".pptt"))
res = TCD_PPTX2PPTT;
else if (0 == sExt2.compare(L".pptx"))
{ {
if (0 == sExt2.compare(L".bin")) res = TCD_PPTX2PPTT_BIN; if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX)
else if (0 == sExt2.compare(L".pptt")) res = TCD_PPTX2PPTT; res = TCD_PPSX2PPTX;
else if (0 == sExt2.compare(L".pptx")) if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_POTX)
{ res = TCD_POTX2PPTX;
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX) if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM)
res = TCD_PPSX2PPTX; res = TCD_PPTM2PPTX;
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_POTX) if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM)
res = TCD_POTX2PPTX; res = TCD_POTM2PPTX;
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM) if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM)
res = TCD_PPTM2PPTX; res = TCD_PPSM2PPTX;
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM) }
res = TCD_POTM2PPTX; else if (0 == sExt2.compare(L".pptm"))
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM) {
res = TCD_PPSM2PPTX; if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM)
} res = TCD_PPSM2PPTM;
else if (0 == sExt2.compare(L".pptm")) if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM)
{ res = TCD_POTM2PPTM;
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM) }
res = TCD_PPSM2PPTM; else if (0 == sExt2.compare(L".odp"))
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM) res = TCD_PPTX2ODP;
res = TCD_POTM2PPTM; }
} break;
else if (0 == sExt2.compare(L".odp")) res = TCD_PPTX2ODP;
}break;
case AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY: case AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY:
{ {
if (0 == sExt2.compare(L".oform")) res = TCD_DOCT2OFORM; if (0 == sExt2.compare(L".oform"))
else if (0 == sExt2.compare(L".docxf")) res = TCD_DOCT2DOCXF; res = TCD_DOCT2OFORM;
else if (0 == sExt2.compare(L".docx")) res = TCD_DOCT2DOCX; else if (0 == sExt2.compare(L".docxf"))
else if (0 == sExt2.compare(L".docm")) res = TCD_DOCT2DOCM; res = TCD_DOCT2DOCXF;
else if (0 == sExt2.compare(L".dotx")) res = TCD_DOCT2DOTX; else if (0 == sExt2.compare(L".docx"))
else if (0 == sExt2.compare(L".bin")) res = TCD_T2BIN; res = TCD_DOCT2DOCX;
else if (0 == sExt2.compare(L".rtf")) res = TCD_DOCT2RTF; else if (0 == sExt2.compare(L".docm"))
}break; res = TCD_DOCT2DOCM;
else if (0 == sExt2.compare(L".dotx"))
res = TCD_DOCT2DOTX;
else if (0 == sExt2.compare(L".bin"))
res = TCD_T2BIN;
else if (0 == sExt2.compare(L".rtf"))
res = TCD_DOCT2RTF;
}
break;
case AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY: case AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY:
{ {
if (0 == sExt2.compare(L".xlsx")) res = TCD_XLST2XLSX; if (0 == sExt2.compare(L".xlsx"))
else if (0 == sExt2.compare(L".xlsm")) res = TCD_XLST2XLSM; res = TCD_XLST2XLSX;
else if (0 == sExt2.compare(L".xltx")) res = TCD_XLST2XLTX; else if (0 == sExt2.compare(L".xlsm"))
else if (0 == sExt2.compare(L".bin")) res = TCD_T2BIN; res = TCD_XLST2XLSM;
else if (0 == sExt2.compare(L".csv")) res = TCD_XLST2CSV; else if (0 == sExt2.compare(L".xltx"))
}break; res = TCD_XLST2XLTX;
else if (0 == sExt2.compare(L".bin"))
res = TCD_T2BIN;
else if (0 == sExt2.compare(L".csv"))
res = TCD_XLST2CSV;
}
break;
case AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY: case AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY:
{ {
if (0 == sExt2.compare(L".pptx")) res = TCD_PPTT2PPTX; if (0 == sExt2.compare(L".pptx"))
else if (0 == sExt2.compare(L".pptm")) res = TCD_PPTT2PPTM; res = TCD_PPTT2PPTX;
else if (0 == sExt2.compare(L".potx")) res = TCD_PPTT2POTX; else if (0 == sExt2.compare(L".pptm"))
else if (0 == sExt2.compare(L".bin")) res = TCD_T2BIN; res = TCD_PPTT2PPTM;
}break; else if (0 == sExt2.compare(L".potx"))
res = TCD_PPTT2POTX;
else if (0 == sExt2.compare(L".bin"))
res = TCD_T2BIN;
}
break;
case AVS_OFFICESTUDIO_FILE_CANVAS_WORD: case AVS_OFFICESTUDIO_FILE_CANVAS_WORD:
{ {
if (0 == sExt2.compare(L".docx")) res = TCD_DOCT_BIN2DOCX; if (0 == sExt2.compare(L".docx"))
else if (0 == sExt2.compare(L".docm")) res = TCD_DOCT_BIN2DOCX; res = TCD_DOCT_BIN2DOCX;
else if (0 == sExt2.compare(L".oform")) res = TCD_DOCT_BIN2DOCX; else if (0 == sExt2.compare(L".docm"))
else if (0 == sExt2.compare(L".dotx")) res = TCD_DOCT_BIN2DOCX; res = TCD_DOCT_BIN2DOCX;
else if (0 == sExt2.compare(L".doct")) res = TCD_BIN2T; else if (0 == sExt2.compare(L".oform"))
else if (0 == sExt2.compare(L".rtf")) res = TCD_DOCT_BIN2RTF; res = TCD_DOCT_BIN2DOCX;
}break; else if (0 == sExt2.compare(L".dotx"))
res = TCD_DOCT_BIN2DOCX;
else if (0 == sExt2.compare(L".doct"))
res = TCD_BIN2T;
else if (0 == sExt2.compare(L".rtf"))
res = TCD_DOCT_BIN2RTF;
}
break;
case AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET: case AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET:
{ {
if (0 == sExt2.compare(L".xlsx")) res = TCD_XLST_BIN2XLSX; if (0 == sExt2.compare(L".xlsx"))
else if (0 == sExt2.compare(L".xlsm")) res = TCD_XLST_BIN2XLSX; res = TCD_XLST_BIN2XLSX;
else if (0 == sExt2.compare(L".xltx")) res = TCD_XLST_BIN2XLSX; else if (0 == sExt2.compare(L".xlsm"))
else if (0 == sExt2.compare(L".xlst")) res = TCD_BIN2T; res = TCD_XLST_BIN2XLSX;
else if (0 == sExt2.compare(L".csv")) res = TCD_XLST_BIN2CSV; else if (0 == sExt2.compare(L".xltx"))
}break; res = TCD_XLST_BIN2XLSX;
else if (0 == sExt2.compare(L".xlst"))
res = TCD_BIN2T;
else if (0 == sExt2.compare(L".csv"))
res = TCD_XLST_BIN2CSV;
}
break;
case AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION: case AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION:
{ {
if (0 == sExt2.compare(L".pptx")) res = TCD_PPTT_BIN2PPTX; if (0 == sExt2.compare(L".pptx"))
else if (0 == sExt2.compare(L".pptm")) res = TCD_PPTT_BIN2PPTX; res = TCD_PPTT_BIN2PPTX;
else if (0 == sExt2.compare(L".potx")) res = TCD_PPTT_BIN2PPTX; else if (0 == sExt2.compare(L".pptm"))
else if (0 == sExt2.compare(L".pptt")) res = TCD_BIN2T; res = TCD_PPTT_BIN2PPTX;
}break; else if (0 == sExt2.compare(L".potx"))
res = TCD_PPTT_BIN2PPTX;
else if (0 == sExt2.compare(L".pptt"))
res = TCD_BIN2T;
}
break;
case AVS_OFFICESTUDIO_FILE_CANVAS_PDF: case AVS_OFFICESTUDIO_FILE_CANVAS_PDF:
{ {
if (0 == sExt2.compare(L".pdf")) res = TCD_BIN2PDF; if (0 == sExt2.compare(L".pdf"))
}break; res = TCD_BIN2PDF;
}
break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV: case AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV:
{ {
if (0 == sExt2.compare(L".xlsx")) res = TCD_CSV2XLSX; if (0 == sExt2.compare(L".xlsx"))
else if (0 == sExt2.compare(L".xlsm")) res = TCD_CSV2XLSX; res = TCD_CSV2XLSX;
else if (0 == sExt2.compare(L".xlst")) res = TCD_CSV2XLST; else if (0 == sExt2.compare(L".xlsm"))
else if (0 == sExt2.compare(L".bin")) res = TCD_CSV2XLST_BIN; res = TCD_CSV2XLSX;
}break; else if (0 == sExt2.compare(L".xlst"))
res = TCD_CSV2XLST;
else if (0 == sExt2.compare(L".bin"))
res = TCD_CSV2XLST_BIN;
}
break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF: case AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF:
{ {
if (0 == sExt2.compare(L".docx")) res = TCD_RTF2DOCX; if (0 == sExt2.compare(L".docx"))
else if (0 == sExt2.compare(L".docm")) res = TCD_RTF2DOCX; res = TCD_RTF2DOCX;
else if (0 == sExt2.compare(L".doct")) res = TCD_RTF2DOCT; else if (0 == sExt2.compare(L".docm"))
else if (0 == sExt2.compare(L".bin")) res = TCD_RTF2DOCT_BIN; res = TCD_RTF2DOCX;
}break; else if (0 == sExt2.compare(L".doct"))
res = TCD_RTF2DOCT;
else if (0 == sExt2.compare(L".bin"))
res = TCD_RTF2DOCT_BIN;
}
break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC: case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC_FLAT: case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC_FLAT:
{ {
if (0 == sExt2.compare(L".docx")) res = TCD_DOC2DOCX; if (0 == sExt2.compare(L".docx"))
else if (0 == sExt2.compare(L".docm")) res = TCD_DOC2DOCM; res = TCD_DOC2DOCX;
else if (0 == sExt2.compare(L".doct")) res = TCD_DOC2DOCT; else if (0 == sExt2.compare(L".docm"))
else if (0 == sExt2.compare(L".bin")) res = TCD_DOC2DOCT_BIN; res = TCD_DOC2DOCM;
}break; else if (0 == sExt2.compare(L".doct"))
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS: res = TCD_DOC2DOCT;
{ else if (0 == sExt2.compare(L".bin"))
if (0 == sExt2.compare(L".xlsx")) res = TCD_XLS2XLSX; res = TCD_DOC2DOCT_BIN;
else if (0 == sExt2.compare(L".xlsm")) res = TCD_XLS2XLSM; }
else if (0 == sExt2.compare(L".xlst")) res = TCD_XLS2XLST; break;
else if (0 == sExt2.compare(L".bin")) res = TCD_XLS2XLST_BIN; case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS:
}break; {
case AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT: if (0 == sExt2.compare(L".xlsx"))
{ res = TCD_XLS2XLSX;
if (0 == sExt2.compare(L".docx")) res = TCD_TXT2DOCX; else if (0 == sExt2.compare(L".xlsm"))
else if (0 == sExt2.compare(L".docm")) res = TCD_TXT2DOCX; res = TCD_XLS2XLSM;
else if (0 == sExt2.compare(L".doct")) res = TCD_TXT2DOCT; else if (0 == sExt2.compare(L".xlst"))
else if (0 == sExt2.compare(L".bin")) res = TCD_TXT2DOCT_BIN; res = TCD_XLS2XLST;
}break; else if (0 == sExt2.compare(L".bin"))
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT: res = TCD_XLS2XLST_BIN;
{//pot,pps - by extension - potx(potm), ppsx(ppsm) }
if (0 == sExt2.compare(L".pptx")) res = TCD_PPT2PPTX; break;
else if (0 == sExt2.compare(L".pptm")) res = TCD_PPT2PPTM; case AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT:
else if (0 == sExt2.compare(L".bin")) res = TCD_PPT2PPTT_BIN; {
else if (0 == sExt2.compare(L".pptt")) res = TCD_PPT2PPTT; if (0 == sExt2.compare(L".docx"))
}break; res = TCD_TXT2DOCX;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT: else if (0 == sExt2.compare(L".docm"))
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS: res = TCD_TXT2DOCX;
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP: else if (0 == sExt2.compare(L".doct"))
case AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT: res = TCD_TXT2DOCT;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS: else if (0 == sExt2.compare(L".bin"))
case AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP: res = TCD_TXT2DOCT_BIN;
{ }
if (0 == sExt2.compare(L".bin")) res = TCD_ODF2OOT_BIN; break;
else if (0 == sExt2.compare(L".doct") || case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT:
0 == sExt2.compare(L".xlst") || { // pot,pps - by extension - potx(potm), ppsx(ppsm)
0 == sExt2.compare(L".pptt")) res = TCD_ODF2OOT; if (0 == sExt2.compare(L".pptx"))
else if (0 == sExt2.compare(L".docx") || res = TCD_PPT2PPTX;
0 == sExt2.compare(L".xlsx") || else if (0 == sExt2.compare(L".pptm"))
0 == sExt2.compare(L".pptx")) res = TCD_ODF2OOX; res = TCD_PPT2PPTM;
else if (0 == sExt2.compare(L".docm") || else if (0 == sExt2.compare(L".bin"))
0 == sExt2.compare(L".xlsm") || res = TCD_PPT2PPTT_BIN;
0 == sExt2.compare(L".pptm")) res = TCD_ODF2OOX; else if (0 == sExt2.compare(L".pptt"))
else if (0 == sExt2.compare(L".odt") res = TCD_PPT2PPTT;
&& type == AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT) res = TCD_OTF2ODF; }
else if (0 == sExt2.compare(L".ods") break;
&& type == AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS) res = TCD_OTF2ODF; case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT:
else if (0 == sExt2.compare(L".odp") case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS:
&& type == AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP) res = TCD_OTF2ODF; case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP:
}break; case AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP:
{
if (0 == sExt2.compare(L".bin"))
res = TCD_ODF2OOT_BIN;
else if (0 == sExt2.compare(L".doct") || 0 == sExt2.compare(L".xlst") || 0 == sExt2.compare(L".pptt"))
res = TCD_ODF2OOT;
else if (0 == sExt2.compare(L".docx") || 0 == sExt2.compare(L".xlsx") || 0 == sExt2.compare(L".pptx"))
res = TCD_ODF2OOX;
else if (0 == sExt2.compare(L".docm") || 0 == sExt2.compare(L".xlsm") || 0 == sExt2.compare(L".pptm"))
res = TCD_ODF2OOX;
else if (0 == sExt2.compare(L".odt") && type == AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT)
res = TCD_OTF2ODF;
else if (0 == sExt2.compare(L".ods") && type == AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS)
res = TCD_OTF2ODF;
else if (0 == sExt2.compare(L".odp") && type == AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP)
res = TCD_OTF2ODF;
}
break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT_FLAT: case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT_FLAT:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT: case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP_FLAT: case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP_FLAT:
{ {
if (0 == sExt2.compare(L".bin")) res = TCD_ODF_FLAT2OOT_BIN; if (0 == sExt2.compare(L".bin"))
else if (0 == sExt2.compare(L".doct") || res = TCD_ODF_FLAT2OOT_BIN;
0 == sExt2.compare(L".xlst") || else if (0 == sExt2.compare(L".doct") || 0 == sExt2.compare(L".xlst") || 0 == sExt2.compare(L".pptt"))
0 == sExt2.compare(L".pptt")) res = TCD_ODF_FLAT2OOT; res = TCD_ODF_FLAT2OOT;
else if (0 == sExt2.compare(L".docx") || else if (0 == sExt2.compare(L".docx") || 0 == sExt2.compare(L".xlsx") || 0 == sExt2.compare(L".pptx"))
0 == sExt2.compare(L".xlsx") || res = TCD_ODF_FLAT2OOX;
0 == sExt2.compare(L".pptx")) res = TCD_ODF_FLAT2OOX; else if (0 == sExt2.compare(L".docm") || 0 == sExt2.compare(L".xlsm") || 0 == sExt2.compare(L".pptm"))
else if (0 == sExt2.compare(L".docm") || res = TCD_ODF_FLAT2OOX;
0 == sExt2.compare(L".xlsm") || }
0 == sExt2.compare(L".pptm")) res = TCD_ODF_FLAT2OOX; break;
}break;
case AVS_OFFICESTUDIO_FILE_OTHER_MS_VBAPROJECT: case AVS_OFFICESTUDIO_FILE_OTHER_MS_VBAPROJECT:
{ {
res = TCD_VBAPROJECT2XML; res = TCD_VBAPROJECT2XML;
}break; }
break;
case AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO: case AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO:
{ {
if (0 == sExt2.compare(L".doct")) res = TCD_MSCRYPT2DOCT; if (0 == sExt2.compare(L".doct"))
else if (0 == sExt2.compare(L".xlst")) res = TCD_MSCRYPT2XLST; res = TCD_MSCRYPT2DOCT;
else if (0 == sExt2.compare(L".pptt")) res = TCD_MSCRYPT2PPTT; else if (0 == sExt2.compare(L".xlst"))
else if (0 == sExt2.compare(L".bin")) res = TCD_MSCRYPT2BIN; res = TCD_MSCRYPT2XLST;
}break; else if (0 == sExt2.compare(L".pptt"))
res = TCD_MSCRYPT2PPTT;
else if (0 == sExt2.compare(L".bin"))
res = TCD_MSCRYPT2BIN;
}
break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER: case AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER:
{ {
if (0 == sExt2.compare(L".docx")) res = TCD_HTMLZIP2DOCX; if (0 == sExt2.compare(L".docx"))
else if (0 == sExt2.compare(L".doct")) res = TCD_HTMLZIP2DOCT; res = TCD_HTMLZIP2DOCX;
else if (0 == sExt2.compare(L".bin")) res = TCD_HTMLZIP2DOCT_BIN; else if (0 == sExt2.compare(L".doct"))
}break; res = TCD_HTMLZIP2DOCT;
else if (0 == sExt2.compare(L".bin"))
res = TCD_HTMLZIP2DOCT_BIN;
}
break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML: case AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML:
{ {
if (0 == sExt2.compare(L".docx")) res = TCD_HTML2DOCX; if (0 == sExt2.compare(L".docx"))
else if (0 == sExt2.compare(L".doct")) res = TCD_HTML2DOCT; res = TCD_HTML2DOCX;
else if (0 == sExt2.compare(L".bin")) res = TCD_HTML2DOCT_BIN; else if (0 == sExt2.compare(L".doct"))
}break; res = TCD_HTML2DOCT;
else if (0 == sExt2.compare(L".bin"))
res = TCD_HTML2DOCT_BIN;
}
break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_FB2: case AVS_OFFICESTUDIO_FILE_DOCUMENT_FB2:
{ {
if (0 == sExt2.compare(L".docx")) res = TCD_FB22DOCX; if (0 == sExt2.compare(L".docx"))
else if (0 == sExt2.compare(L".doct")) res = TCD_FB22DOCT; res = TCD_FB22DOCX;
else if (0 == sExt2.compare(L".bin")) res = TCD_FB22DOCT_BIN; else if (0 == sExt2.compare(L".doct"))
}break; res = TCD_FB22DOCT;
else if (0 == sExt2.compare(L".bin"))
res = TCD_FB22DOCT_BIN;
}
break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB: case AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB:
{ {
if (0 == sExt2.compare(L".docx")) res = TCD_EPUB2DOCX; if (0 == sExt2.compare(L".docx"))
else if (0 == sExt2.compare(L".doct")) res = TCD_EPUB2DOCT; res = TCD_EPUB2DOCX;
else if (0 == sExt2.compare(L".bin")) res = TCD_EPUB2DOCT_BIN; else if (0 == sExt2.compare(L".doct"))
}break; res = TCD_EPUB2DOCT;
} else if (0 == sExt2.compare(L".bin"))
} res = TCD_EPUB2DOCT_BIN;
}
break;
}
}
} }
return res; return res;
} }
std::wstring getMailMergeXml(const std::wstring& sJsonPath, int nRecordFrom, int nRecordTo, const std::wstring& sField) std::wstring getMailMergeXml(const std::wstring& sJsonPath, int nRecordFrom, int nRecordTo, const std::wstring& sField)
{ {
NSStringUtils::CStringBuilder oBuilder; NSStringUtils::CStringBuilder oBuilder;
oBuilder.WriteString(L"<MailMergeData DatabasePath=\""); oBuilder.WriteString(L"<MailMergeData DatabasePath=\"");
oBuilder.WriteEncodeXmlString(sJsonPath.c_str()); oBuilder.WriteEncodeXmlString(sJsonPath.c_str());
oBuilder.WriteString(L"\" Start=\""); oBuilder.WriteString(L"\" Start=\"");
oBuilder.AddInt(nRecordFrom); oBuilder.AddInt(nRecordFrom);
oBuilder.WriteString(L"\" End=\""); oBuilder.WriteString(L"\" End=\"");
oBuilder.AddInt(nRecordTo); oBuilder.AddInt(nRecordTo);
oBuilder.WriteString(L"\" Field=\""); oBuilder.WriteString(L"\" Field=\"");
oBuilder.WriteEncodeXmlString(sField.c_str()); oBuilder.WriteEncodeXmlString(sField.c_str());
oBuilder.WriteString(L"\" />"); oBuilder.WriteString(L"\" />");
return oBuilder.GetData(); return oBuilder.GetData();
} }
std::wstring getDoctXml(NSDoctRenderer::DoctRendererFormat::FormatFile eFromType, NSDoctRenderer::DoctRendererFormat::FormatFile eToType, std::wstring getDoctXml(
const std::wstring& sTFileSrc, const std::wstring& sPdfBinFile, const std::wstring& sImagesDirectory, NSDoctRenderer::DoctRendererFormat::FormatFile eFromType, NSDoctRenderer::DoctRendererFormat::FormatFile eToType, const std::wstring& sTFileSrc, const std::wstring& sPdfBinFile,
const std::wstring& sThemeDir, int nTopIndex, const std::wstring& sMailMerge, const InputParams& params) const std::wstring& sImagesDirectory, const std::wstring& sThemeDir, int nTopIndex, const std::wstring& sMailMerge, const InputParams& params)
{ {
NSStringUtils::CStringBuilder oBuilder; NSStringUtils::CStringBuilder oBuilder;
oBuilder.WriteString(L"<Settings><SrcFileType>"); oBuilder.WriteString(L"<Settings><SrcFileType>");
oBuilder.AddInt((int)eFromType); oBuilder.AddInt((int)eFromType);
oBuilder.WriteString(L"</SrcFileType><DstFileType>"); oBuilder.WriteString(L"</SrcFileType><DstFileType>");
oBuilder.AddInt((int)eToType); oBuilder.AddInt((int)eToType);
oBuilder.WriteString(L"</DstFileType><SrcFilePath>"); oBuilder.WriteString(L"</DstFileType><SrcFilePath>");
oBuilder.WriteEncodeXmlString(sTFileSrc.c_str()); oBuilder.WriteEncodeXmlString(sTFileSrc.c_str());
oBuilder.WriteString(L"</SrcFilePath><DstFilePath>"); oBuilder.WriteString(L"</SrcFilePath><DstFilePath>");
oBuilder.WriteEncodeXmlString(sPdfBinFile.c_str()); oBuilder.WriteEncodeXmlString(sPdfBinFile.c_str());
oBuilder.WriteString(L"</DstFilePath><FontsDirectory>"); oBuilder.WriteString(L"</DstFilePath><FontsDirectory>");
oBuilder.WriteEncodeXmlString(params.getFontPath().c_str()); oBuilder.WriteEncodeXmlString(params.getFontPath().c_str());
oBuilder.WriteString(L"</FontsDirectory><ImagesDirectory>"); oBuilder.WriteString(L"</FontsDirectory><ImagesDirectory>");
oBuilder.WriteEncodeXmlString(sImagesDirectory.c_str()); oBuilder.WriteEncodeXmlString(sImagesDirectory.c_str());
oBuilder.WriteString(L"</ImagesDirectory><ThemesDirectory>"); oBuilder.WriteString(L"</ImagesDirectory><ThemesDirectory>");
oBuilder.WriteEncodeXmlString(sThemeDir.c_str()); oBuilder.WriteEncodeXmlString(sThemeDir.c_str());
oBuilder.WriteString(L"</ThemesDirectory>"); oBuilder.WriteString(L"</ThemesDirectory>");
if(NULL != params.m_nLcid) if (NULL != params.m_nLcid)
{ {
oBuilder.WriteString(L"<Lcid>"); oBuilder.WriteString(L"<Lcid>");
oBuilder.AddInt(*params.m_nLcid); oBuilder.AddInt(*params.m_nLcid);
@ -444,7 +569,8 @@ namespace NExtractTools
if (NULL != params.m_sJsonParams) if (NULL != params.m_sJsonParams)
{ {
sJsonParams = *params.m_sJsonParams; sJsonParams = *params.m_sJsonParams;
if (bOnlyOnePage){ if (bOnlyOnePage)
{
sJsonParams.insert(1, L"\"printOptions\":{\"onlyFirstPage\":true},"); sJsonParams.insert(1, L"\"printOptions\":{\"onlyFirstPage\":true},");
} }
} }
@ -464,124 +590,126 @@ namespace NExtractTools
oBuilder.WriteEncodeXmlString(*params.m_sScriptsCacheDirectory); oBuilder.WriteEncodeXmlString(*params.m_sScriptsCacheDirectory);
oBuilder.WriteString(L"</ScriptsCacheDirectory>"); oBuilder.WriteString(L"</ScriptsCacheDirectory>");
} }
oBuilder.WriteString(L"<Changes TopItem=\""); oBuilder.WriteString(L"<Changes TopItem=\"");
oBuilder.AddInt(nTopIndex); oBuilder.AddInt(nTopIndex);
oBuilder.WriteString(L"\">"); oBuilder.WriteString(L"\">");
std::wstring sChangesDir = NSDirectory::GetFolderPath(sTFileSrc) + FILE_SEPARATOR_STR + L"changes"; std::wstring sChangesDir = NSDirectory::GetFolderPath(sTFileSrc) + FILE_SEPARATOR_STR + L"changes";
if (NSDirectory::Exists(sChangesDir)) if (NSDirectory::Exists(sChangesDir))
{ {
std::vector<std::wstring> aChangesFiles; std::vector<std::wstring> aChangesFiles;
std::vector<std::wstring> oArray; std::vector<std::wstring> oArray;
std::vector<std::wstring> aFiles; std::vector<std::wstring> aFiles;
NSDirectory::GetFiles2(sChangesDir, oArray, false); NSDirectory::GetFiles2(sChangesDir, oArray, false);
for(size_t i = 0; i < oArray.size(); ++i) for (size_t i = 0; i < oArray.size(); ++i)
{ {
aChangesFiles.push_back(oArray[i]); aChangesFiles.push_back(oArray[i]);
} }
std::sort (aChangesFiles.begin(), aChangesFiles.end(), compare_string_by_length); std::sort(aChangesFiles.begin(), aChangesFiles.end(), compare_string_by_length);
for(size_t i = 0; i < aChangesFiles.size(); ++i) for (size_t i = 0; i < aChangesFiles.size(); ++i)
{ {
oBuilder.WriteString(L"<Change>"); oBuilder.WriteString(L"<Change>");
oBuilder.WriteEncodeXmlString(aChangesFiles[i]); oBuilder.WriteEncodeXmlString(aChangesFiles[i]);
oBuilder.WriteString(L"</Change>"); oBuilder.WriteString(L"</Change>");
} }
} }
oBuilder.WriteString(L"</Changes>"); oBuilder.WriteString(L"</Changes>");
oBuilder.WriteString(sMailMerge); oBuilder.WriteString(sMailMerge);
oBuilder.WriteString(L"</Settings>"); oBuilder.WriteString(L"</Settings>");
return oBuilder.GetData(); return oBuilder.GetData();
} }
_UINT32 apply_changes(const std::wstring &sBinFrom, const std::wstring &sToResult, NSDoctRenderer::DoctRendererFormat::FormatFile eType, const std::wstring &sThemeDir, std::wstring &sBinTo, const InputParams& params) _UINT32 apply_changes(
const std::wstring& sBinFrom, const std::wstring& sToResult, NSDoctRenderer::DoctRendererFormat::FormatFile eType, const std::wstring& sThemeDir, std::wstring& sBinTo,
const InputParams& params)
{ {
std::wstring sBinDir = NSDirectory::GetFolderPath(sBinFrom); std::wstring sBinDir = NSDirectory::GetFolderPath(sBinFrom);
std::wstring sChangesDir = sBinDir + FILE_SEPARATOR_STR + L"changes"; std::wstring sChangesDir = sBinDir + FILE_SEPARATOR_STR + L"changes";
if (NSDirectory::Exists(sChangesDir)) if (NSDirectory::Exists(sChangesDir))
{ {
std::wstring sBinFromFileName = NSFile::GetFileName(sBinFrom); std::wstring sBinFromFileName = NSFile::GetFileName(sBinFrom);
std::wstring sBinFromExt = NSFile::GetFileExtention(sBinFromFileName); std::wstring sBinFromExt = NSFile::GetFileExtention(sBinFromFileName);
sBinTo = sBinDir + FILE_SEPARATOR_STR + sBinFromFileName.substr(0, sBinFromFileName.length() - sBinFromExt.length() - 1) + L"WithChanges." + sBinFromExt; sBinTo = sBinDir + FILE_SEPARATOR_STR + sBinFromFileName.substr(0, sBinFromFileName.length() - sBinFromExt.length() - 1) + L"WithChanges." + sBinFromExt;
std::wstring sImagesDirectory = sBinDir + FILE_SEPARATOR_STR + L"media"; std::wstring sImagesDirectory = sBinDir + FILE_SEPARATOR_STR + L"media";
NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : L""); NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : L"");
int nChangeIndex = -1; int nChangeIndex = -1;
while (true) while (true)
{ {
std::wstring sXml = getDoctXml(eType, eType, sBinFrom, sBinTo, sImagesDirectory, sThemeDir, nChangeIndex, L"", params); std::wstring sXml = getDoctXml(eType, eType, sBinFrom, sBinTo, sImagesDirectory, sThemeDir, nChangeIndex, L"", params);
std::wstring sResult; std::wstring sResult;
oDoctRenderer.Execute(sXml, sResult); oDoctRenderer.Execute(sXml, sResult);
bool bContinue = false; bool bContinue = false;
if (!sResult.empty() && -1 != sResult.find(L"error")) if (!sResult.empty() && -1 != sResult.find(L"error"))
{ {
std::wcerr << L"DoctRenderer:" << sResult << std::endl; std::wcerr << L"DoctRenderer:" << sResult << std::endl;
params.m_bOutputConvertCorrupted = true; params.m_bOutputConvertCorrupted = true;
int nErrorIndex = -1; int nErrorIndex = -1;
int nErrorIndexStart = sResult.find(L"index"); int nErrorIndexStart = sResult.find(L"index");
if (-1 != nErrorIndexStart) if (-1 != nErrorIndexStart)
{
nErrorIndexStart = sResult.find(L"\"", nErrorIndexStart + 1);
int nErrorIndexEnd = sResult.find(L"\"", nErrorIndexStart + 1);
nErrorIndex = XmlUtils::GetInteger(sResult.substr(nErrorIndexStart + 1, nErrorIndexEnd - nErrorIndexStart - 1));
}
if (nErrorIndex > 0 && nChangeIndex != nErrorIndex)
{
nChangeIndex = nErrorIndex;
bContinue = true;
}
else
{ {
sBinTo = sBinFrom; nErrorIndexStart = sResult.find(L"\"", nErrorIndexStart + 1);
int nErrorIndexEnd = sResult.find(L"\"", nErrorIndexStart + 1);
nErrorIndex = XmlUtils::GetInteger(sResult.substr(nErrorIndexStart + 1, nErrorIndexEnd - nErrorIndexStart - 1));
} }
} if (nErrorIndex > 0 && nChangeIndex != nErrorIndex)
if (!bContinue) {
{ nChangeIndex = nErrorIndex;
if(!sToResult.empty() && !params.getDontSaveAdditional()) bContinue = true;
{ }
std::vector<std::wstring> aImages = oDoctRenderer.GetImagesInChanges(); else
//todo сделать interface у COfficeUtils, чтобы можно было делать архив из файлов в разных папках. {
for(size_t i = 0; i < aImages.size(); ++i) sBinTo = sBinFrom;
{ }
std::wstring sImageName = aImages[i]; }
std::wstring sImage = sImagesDirectory + FILE_SEPARATOR_STR + sImageName; if (!bContinue)
std::wstring sImageCopy = sChangesDir + FILE_SEPARATOR_STR + sImageName; {
NSFile::CFileBinary::Copy(sImage, sImageCopy); if (!sToResult.empty() && !params.getDontSaveAdditional())
} {
std::vector<std::wstring> aImages = oDoctRenderer.GetImagesInChanges();
// todo сделать interface у COfficeUtils, чтобы можно было делать архив из файлов в разных папках.
for (size_t i = 0; i < aImages.size(); ++i)
{
std::wstring sImageName = aImages[i];
std::wstring sImage = sImagesDirectory + FILE_SEPARATOR_STR + sImageName;
std::wstring sImageCopy = sChangesDir + FILE_SEPARATOR_STR + sImageName;
NSFile::CFileBinary::Copy(sImage, sImageCopy);
}
////copy doct for version history ////copy doct for version history
// std::wstring sBinCopy = sChangesDir + FILE_SEPARATOR_STR + NSSystemPath::GetFileName(sBinFrom); // std::wstring sBinCopy = sChangesDir + FILE_SEPARATOR_STR + NSSystemPath::GetFileName(sBinFrom);
// NSFile::CFileBinary::Copy(sBinFrom, sBinCopy); // NSFile::CFileBinary::Copy(sBinFrom, sBinCopy);
std::wstring sToResultDir = NSDirectory::GetFolderPath(sToResult); std::wstring sToResultDir = NSDirectory::GetFolderPath(sToResult);
std::wstring sTo = sToResultDir + FILE_SEPARATOR_STR + L"changes.zip"; std::wstring sTo = sToResultDir + FILE_SEPARATOR_STR + L"changes.zip";
COfficeUtils oCOfficeUtils(NULL); COfficeUtils oCOfficeUtils(NULL);
oCOfficeUtils.CompressFileOrDirectory(sChangesDir, sTo); oCOfficeUtils.CompressFileOrDirectory(sChangesDir, sTo);
} }
break; break;
} }
} }
} }
else else
sBinTo = sBinFrom; sBinTo = sBinFrom;
return 0; return 0;
} }
bool InputParams::checkInputLimits() bool InputParams::checkInputLimits()
{ {
std::wstring& sFrom = *this->m_sFileFrom; std::wstring& sFrom = *this->m_sFileFrom;
int nFormatFrom = *this->m_nFormatFrom; int nFormatFrom = *this->m_nFormatFrom;
boost::unordered_map<int, std::vector<InputLimit>>::const_iterator itLimit = this->m_mapInputLimits.find(nFormatFrom); boost::unordered_map<int, std::vector<InputLimit>>::const_iterator itLimit = this->m_mapInputLimits.find(nFormatFrom);
if(itLimit != this->m_mapInputLimits.end()) if (itLimit != this->m_mapInputLimits.end())
{ {
for (size_t i = 0; i < itLimit->second.size(); ++i) for (size_t i = 0; i < itLimit->second.size(); ++i)
{ {
const InputLimit& oLimit = itLimit->second[i]; const InputLimit& oLimit = itLimit->second[i];
if(oLimit.compressed > 0 || oLimit.uncompressed > 0) if (oLimit.compressed > 0 || oLimit.uncompressed > 0)
{ {
ULONG64 nCompressed = 0; ULONG64 nCompressed = 0;
ULONG64 nUncompressed = 0; ULONG64 nUncompressed = 0;
COfficeUtils oCOfficeUtils(NULL); COfficeUtils oCOfficeUtils(NULL);
oCOfficeUtils.GetFilesSize(sFrom, oLimit.pattern, nCompressed, nUncompressed); oCOfficeUtils.GetFilesSize(sFrom, oLimit.pattern, nCompressed, nUncompressed);
if((oLimit.compressed > 0 && nCompressed > oLimit.compressed) || (oLimit.uncompressed > 0 && nUncompressed > oLimit.uncompressed)) if ((oLimit.compressed > 0 && nCompressed > oLimit.compressed) || (oLimit.uncompressed > 0 && nUncompressed > oLimit.uncompressed))
{ {
return false; return false;
} }
@ -590,4 +718,4 @@ namespace NExtractTools
} }
return true; return true;
} }
} } // namespace NExtractTools

File diff suppressed because it is too large Load Diff

View File

@ -30,11 +30,11 @@
* *
*/ */
#include "cextracttools.h"
#include "ASCConverters.h"
#include "../../DesktopEditor/common/SystemUtils.h"
#include "../../DesktopEditor/common/StringExt.h"
#include "../../Common/3dParty/misc/proclimits.h" #include "../../Common/3dParty/misc/proclimits.h"
#include "../../DesktopEditor/common/StringExt.h"
#include "../../DesktopEditor/common/SystemUtils.h"
#include "ASCConverters.h"
#include "cextracttools.h"
#include <iostream> #include <iostream>
@ -43,57 +43,57 @@
using namespace NExtractTools; using namespace NExtractTools;
#if !defined(_WIN32) && !defined (_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
static std::wstring utf8_to_unicode(const char *src) static std::wstring utf8_to_unicode(const char *src)
{ {
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)src, (LONG)strlen(src)); return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE *)src, (LONG)strlen(src));
} }
#endif #endif
#ifdef BUILD_X2T_AS_LIBRARY_DYLIB #ifdef BUILD_X2T_AS_LIBRARY_DYLIB
#if !defined(_WIN32) && !defined (_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
int main_lib(int argc, char *argv[]) int main_lib(int argc, char *argv[])
#else #else
int wmain_lib(int argc, wchar_t *argv[]) int wmain_lib(int argc, wchar_t *argv[])
#endif #endif
#endif #endif
#ifndef BUILD_X2T_AS_LIBRARY_DYLIB #ifndef BUILD_X2T_AS_LIBRARY_DYLIB
#if !defined(_WIN32) && !defined (_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
#else #else
int wmain(int argc, wchar_t *argv[]) int wmain(int argc, wchar_t *argv[])
#endif #endif
#endif #endif
{ {
//#define __CRTDBG_MAP_ALLOC // #define __CRTDBG_MAP_ALLOC
//#include <crtdbg.h> // #include <crtdbg.h>
//#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) // #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
//#define new DEBUG_NEW // #define new DEBUG_NEW
// check arguments // check arguments
if (argc < 2) if (argc < 2)
{ {
// print out help topic // print out help topic
std::cout << std::endl; std::cout << std::endl;
std::cout << std::endl; std::cout << std::endl;
std::cout << "-------------------------------------------------------------------------------" << std::endl; std::cout << "-------------------------------------------------------------------------------" << std::endl;
std::cout << "\t\tOOX/binary file converter. Version: " VALUE(INTVER) << std::endl; std::cout << "\t\tOOX/binary file converter. Version: " VALUE(INTVER) << std::endl;
std::cout << "-------------------------------------------------------------------------------" << std::endl; std::cout << "-------------------------------------------------------------------------------" << std::endl;
std::cout << std::endl; std::cout << std::endl;
std::cout << "USAGE: x2t \"path_to_params_xml\"" << std::endl; std::cout << "USAGE: x2t \"path_to_params_xml\"" << std::endl;
std::cout << "or" << std::endl; std::cout << "or" << std::endl;
std::cout << "USAGE: x2t \"path_to_file_1\" \"path_to_file_2\" [\"path_to_font_selection\"]" << std::endl; std::cout << "USAGE: x2t \"path_to_file_1\" \"path_to_file_2\" [\"path_to_font_selection\"]" << std::endl;
std::cout << "WHERE:" << std::endl; std::cout << "WHERE:" << std::endl;
std::cout << "\t\"path_to_file_1\" is a path to file to be converted" << std::endl; std::cout << "\t\"path_to_file_1\" is a path to file to be converted" << std::endl;
std::cout << "\t\"path_to_file_2\" is a path to the corresponding output file" << std::endl; std::cout << "\t\"path_to_file_2\" is a path to the corresponding output file" << std::endl;
std::cout << "\t\"path_to_font_selection\" is a path to 'font_selection.bin' location" << std::endl << std::endl; std::cout << "\t\"path_to_font_selection\" is a path to 'font_selection.bin' location" << std::endl << std::endl;
std::cout << "NOTE: conversion direction will be calculated from file extensions" << std::endl << std::endl; std::cout << "NOTE: conversion direction will be calculated from file extensions" << std::endl << std::endl;
return getReturnErrorCode(AVS_FILEUTILS_ERROR_CONVERT_PARAMS); return getReturnErrorCode(AVS_FILEUTILS_ERROR_CONVERT_PARAMS);
} }
//set memory limit // set memory limit
std::wstring sMemoryLimit = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvMemoryLimit); std::wstring sMemoryLimit = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvMemoryLimit);
if (sMemoryLimit.empty()) if (sMemoryLimit.empty())
sMemoryLimit = NSSystemUtils::gc_EnvMemoryLimitDefault; sMemoryLimit = NSSystemUtils::gc_EnvMemoryLimitDefault;
@ -105,19 +105,21 @@ static std::wstring utf8_to_unicode(const char *src)
#endif #endif
std::wstring sArg1, sArg2, sExePath; std::wstring sArg1, sArg2, sExePath;
#if !defined(_WIN32) && !defined (_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
sExePath = utf8_to_unicode(argv [0]); sExePath = utf8_to_unicode(argv[0]);
sArg1 = utf8_to_unicode(argv [1]); sArg1 = utf8_to_unicode(argv[1]);
if (argc >= 3) sArg2 = utf8_to_unicode(argv [2]); if (argc >= 3)
sArg2 = utf8_to_unicode(argv[2]);
#else #else
sExePath = std::wstring(argv [0]); sExePath = std::wstring(argv[0]);
sArg1 = std::wstring(argv [1]); sArg1 = std::wstring(argv[1]);
if (argc >= 3) sArg2 = std::wstring(argv [2]); if (argc >= 3)
sArg2 = std::wstring(argv[2]);
#endif #endif
_UINT32 result = 0; _UINT32 result = 0;
std::wstring sXmlExt = _T(".xml"); std::wstring sXmlExt = _T(".xml");
if((sArg1.length() > 3) && (sXmlExt == sArg1.substr(sArg1.length() - sXmlExt.length(), sXmlExt.length()))) if ((sArg1.length() > 3) && (sXmlExt == sArg1.substr(sArg1.length() - sXmlExt.length(), sXmlExt.length())))
{ {
NExtractTools::InputParams oInputParams; NExtractTools::InputParams oInputParams;
if (oInputParams.FromXmlFile(sArg1) && (sArg2.empty() || oInputParams.FromXml(sArg2))) if (oInputParams.FromXmlFile(sArg1) && (sArg2.empty() || oInputParams.FromXml(sArg2)))
@ -133,20 +135,26 @@ static std::wstring utf8_to_unicode(const char *src)
{ {
std::wstring sArg3, sArg4, sArg5; std::wstring sArg3, sArg4, sArg5;
#if !defined(_WIN32) && !defined (_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
if (argc >= 4) sArg3 = utf8_to_unicode(argv [3]); if (argc >= 4)
if (argc >= 5) sArg4 = utf8_to_unicode(argv [4]); sArg3 = utf8_to_unicode(argv[3]);
if (argc >= 6) sArg5 = utf8_to_unicode(argv [5]); if (argc >= 5)
sArg4 = utf8_to_unicode(argv[4]);
if (argc >= 6)
sArg5 = utf8_to_unicode(argv[5]);
#else #else
if (argc >= 4) sArg3 = std::wstring(argv [3]); if (argc >= 4)
if (argc >= 5) sArg4 = std::wstring(argv [4]); sArg3 = std::wstring(argv[3]);
if (argc >= 6) sArg5 = std::wstring(argv [5]); if (argc >= 5)
sArg4 = std::wstring(argv[4]);
if (argc >= 6)
sArg5 = std::wstring(argv[5]);
#endif #endif
if (sArg1 == L"-detectmacro") if (sArg1 == L"-detectmacro")
{ {
InputParams oInputParams; InputParams oInputParams;
oInputParams.m_sFileFrom = new std::wstring(sArg2); oInputParams.m_sFileFrom = new std::wstring(sArg2);
result = NExtractTools::detectMacroInFile(oInputParams); result = NExtractTools::detectMacroInFile(oInputParams);
} }
else if (sArg1 == L"-create-js-cache") else if (sArg1 == L"-create-js-cache")
@ -157,8 +165,8 @@ static std::wstring utf8_to_unicode(const char *src)
else else
{ {
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);
if (argc > 3) if (argc > 3)
{ {
@ -172,6 +180,6 @@ static std::wstring utf8_to_unicode(const char *src)
result = NExtractTools::fromInputParams(oInputParams); result = NExtractTools::fromInputParams(oInputParams);
} }
} }
//_CrtDumpMemoryLeaks(); //_CrtDumpMemoryLeaks();
return getReturnErrorCode(result); return getReturnErrorCode(result);
} }