Compare commits

...

4 Commits

Author SHA1 Message Date
867c09c85d x14:conditionalFormatting DxfId starts from 0 2017-06-23 19:26:03 +03:00
cd12777c68 up 2017-06-22 18:27:00 +03:00
0708c1f45a . 2017-06-22 12:32:00 +03:00
ee577e629a DocFormat - fix user file 2017-06-21 19:50:02 +03:00
9 changed files with 213 additions and 178 deletions

View File

@ -507,9 +507,9 @@ namespace DocFileFormat
class FileInformationBlock
{
public:
bool m_bOlderVersion;
int m_CodePage;
FibBase m_FibBase;
bool m_bOlderVersion;
int m_CodePage;
FibBase m_FibBase;
RgW97 m_RgW97;
RgLw97 m_RgLw97;

View File

@ -0,0 +1,60 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#include "RegularContainer.h"
namespace DocFileFormat
{
class OfficeArtFRITContainer: public RegularContainer
{
public:
static const unsigned short TYPE_CODE_0xF118 = 0xF118;
OfficeArtFRITContainer () : RegularContainer()
{
}
OfficeArtFRITContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : RegularContainer (_reader, size, typeCode, version, instance)
{
}
virtual ~OfficeArtFRITContainer()
{
}
virtual Record* NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance)
{
return new OfficeArtFRITContainer( _reader, bodySize, typeCode, version, instance );
}
};
}

View File

@ -50,6 +50,7 @@
#include "GroupShapeRecord.h"
#include "OfficeArtClientTextbox.h"
#include "UnknownRecord.h"
#include "OfficeArtFRITContainer.h"
namespace DocFileFormat
{
@ -135,6 +136,7 @@ namespace DocFileFormat
case GroupContainer::TYPE_CODE_0xF003 : return new GroupContainer();
case GroupShapeRecord::TYPE_CODE_0xF009 : return new GroupShapeRecord ();
case OfficeArtClientTextbox::TYPE_CODE_0xF00D : return new OfficeArtClientTextbox ();
case OfficeArtFRITContainer::TYPE_CODE_0xF118 : return new OfficeArtFRITContainer ();
default:
return new UnknownRecord();

View File

@ -247,9 +247,8 @@ namespace DocFileFormat
{
freeform = false;
m_pXmlWriter->WriteAttribute( L"type", (std::wstring(L"#") + VMLShapeTypeMapping::GenerateTypeId(pShape->GetShapeType())));
m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(pShape, pAnchor, options, pContainer->Index)));
}
m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(pShape, pAnchor, options, pContainer->Index)));
if (pShape->is<LineType>())
{
@ -446,7 +445,7 @@ namespace DocFileFormat
{
yCoord = iter->op;
}break;
// OUTLINE
// LINE
case lineColor:
{
RGBColor lineColor((int)iter->op, RedFirst);
@ -493,6 +492,21 @@ namespace DocFileFormat
{
appendValueAttribute(&m_stroke, L"startarrowwidth", getArrowWidth( iter->op ));
}break;
case cxstyle:
{
if (pShape->GetShapeType() == NULL)
{
freeform = false;
m_pXmlWriter->WriteAttribute(L"type", L"#_x0000_t32");
}
switch(iter->op)
{
case 0: m_pXmlWriter->WriteAttribute(L"o:connectortype", L"straight"); break;
case 1: m_pXmlWriter->WriteAttribute(L"o:connectortype", L"elbow"); break;
case 2: m_pXmlWriter->WriteAttribute(L"o:connectortype", L"curved"); break;
case 3: m_pXmlWriter->WriteAttribute(L"o:connectortype", L"none"); break;
}
}break;
// FILL
case fillColor:
{
@ -544,6 +558,14 @@ namespace DocFileFormat
appendValueAttribute(&m_fill, L"r:id", std::wstring(( L"rId" ) + FormatUtils::IntToWideString(m_nImageId) ));
}
}break;
case fillBlipName:
{
std::wstring name;
FormatUtils::GetSTLCollectionFromBytes<std::wstring>(&name, iter->opComplex.get(), iter->op, ENCODING_UTF16);
if (!name.empty())
appendValueAttribute(&m_fill, L"o:title", FormatUtils::XmlEncode(name));
}break;
case fillOpacity:
{
appendValueAttribute(&m_fill, L"opacity", ( FormatUtils::IntToWideString( iter->op ) + L"f" ));

View File

@ -163,8 +163,9 @@ namespace OOX
if (!m_pStyles->m_oDxfs.IsInit())
m_pStyles->m_oDxfs.Init();
m_pStyles->m_oDxfs->m_arrItems.push_back(rule->m_oDxf.GetPointerEmptyNullable());
//DxfId starts from 0
rule->m_oDxfId = std::to_wstring(m_pStyles->m_oDxfs->m_arrItems.size());
m_pStyles->m_oDxfs->m_arrItems.push_back(rule->m_oDxf.GetPointerEmptyNullable());
}
}
}

View File

@ -381,8 +381,8 @@ bool EncryptCipher(_buf & key, _buf & iv, _buf & data_inp, _buf & data_out, CRYP
return true;
}
ARC4::Decryption rc4Decryption;
//CipherARCFOUR rc4Decryption;
//ARC4::Decryption rc4Decryption;
CipherARCFOUR rc4Decryption;
bool DecryptCipher(_buf & key, _buf & iv, _buf & data_inp, _buf & data_out, CRYPT_METHOD::_cipherAlgorithm algorithm,
StreamTransformationFilter::BlockPaddingScheme padding = StreamTransformationFilter::NO_PADDING)
@ -398,8 +398,8 @@ bool DecryptCipher(_buf & key, _buf & iv, _buf & data_inp, _buf & data_out, CRY
}
else if (algorithm == CRYPT_METHOD::RC4)
{
//rc4Decryption.Decode(data_inp.ptr, data_inp.size, data_out.ptr, data_out.size);
rc4Decryption.ProcessData(data_out.ptr, data_inp.ptr, data_inp.size);
rc4Decryption.Decode(data_inp.ptr, data_inp.size, data_out.ptr, data_out.size);
//rc4Decryption.ProcessData(data_out.ptr, data_inp.ptr, data_inp.size);
}
else //AES
{
@ -485,7 +485,10 @@ bool ECMADecryptor::SetPassword(std::wstring _password)
CorrectHashSize(verifierKey, 16, 0); //40-bit crypt key !!!
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
rc4Decryption.SetKey(verifierKey.ptr, verifierKey.size);
{
//rc4Decryption.SetKey(verifierKey.ptr, verifierKey.size);
rc4Decryption.Init(CipherARCFOUR::rtl_Cipher_DirectionDecode, verifierKey.ptr, verifierKey.size, 0, 0);
}
//--------------------------------------------
_buf decryptedVerifierHashInputBytes;
@ -512,12 +515,12 @@ void ECMADecryptor::SetCryptData(_ecmaCryptData & data)
{
cryptData = data;
}
void ECMADecryptor::Decrypt(char* data , const size_t size, const unsigned long stream_pos)
void ECMADecryptor::Decrypt(char* data , const size_t size, const unsigned long start_iv_block)
{
if (bVerify)
{
unsigned char* data_out = NULL;
Decrypt((unsigned char*)data, size, data_out);
Decrypt((unsigned char*)data, size, data_out, start_iv_block);
if (data_out)
{
@ -565,7 +568,7 @@ bool ECMADecryptor::CheckDataIntegrity(unsigned char* data, int size)
return (hmac == expected);
}
void ECMADecryptor::Decrypt(unsigned char* data_ptr, int data_size, unsigned char*& data_out)
void ECMADecryptor::Decrypt(unsigned char* data_ptr, int data_size, unsigned char*& data_out, int start_iv_block)
{
data_out = NULL;
@ -592,7 +595,7 @@ void ECMADecryptor::Decrypt(unsigned char* data_ptr, int data_size, unsigned ch
_buf iv(cryptData.blockSize);
memset( iv.ptr, 0x00, cryptData.blockSize );
int i = 0, sz = 4096, pos = 0;
int i = start_iv_block, sz = 4096, pos = 0;
while (pos < size)
{
@ -611,50 +614,34 @@ void ECMADecryptor::Decrypt(unsigned char* data_ptr, int data_size, unsigned ch
pos += sz; i++;
}
//--------------------------------------------
_buf pEncVerKeyMac (cryptData.encryptedHmacKey);
_buf pEncVerValueMac (cryptData.encryptedHmacValue);
_buf iv1(cryptData.blockSize);
memset( iv1.ptr, 0x00, cryptData.blockSize );
i = 0;
_buf pIndex1((unsigned char*)&i, 4);
iv1 = HashAppend(pDataSalt, pIndex1, cryptData.hashAlgorithm);
CorrectHashSize(iv1, cryptData.blockSize, 0x36);
_buf pOut1(pEncVerKeyMac.size);
_buf pOut2(pEncVerValueMac.size);
DecryptCipher(pDecryptedKey, iv, pEncVerKeyMac, pOut1, cryptData.cipherAlgorithm);
DecryptCipher(pDecryptedKey, iv, pEncVerValueMac, pOut2, cryptData.cipherAlgorithm);
}
else
{
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
int i = 0, sz = 512, pos = 0;
int i = start_iv_block, sz = 512, pos = 0;
_buf pHashBuf = HashAppend(pSalt, pPassword, cryptData.hashAlgorithm);
while (pos < size)
{
if (pos + sz > size)
sz = size - pos;
_buf hashKey = GenerateHashKey(pSalt, pPassword, cryptData.hashSize, cryptData.spinCount, cryptData.hashAlgorithm, i);
CorrectHashSize(hashKey, cryptData.keySize, 0);
if (cryptData.keySize == 5)
CorrectHashSize(hashKey, 16, 0); //40-bit crypt key !!!
rc4Decryption.SetKey(hashKey.ptr, hashKey.size);
_buf pInp(data_inp + pos, sz, false);
_buf pOut(data_out + pos, sz, false);
_buf block ((unsigned char*)&i, 4, false);
DecryptCipher(empty, empty, pInp, pOut, cryptData.cipherAlgorithm);
_buf pDecryptedKey = HashAppend( pHashBuf, block, cryptData.hashAlgorithm);
CorrectHashSize(pDecryptedKey, cryptData.keySize, 0);
if (cryptData.keySize == 5)
CorrectHashSize(pDecryptedKey, 16, 0); //40-bit crypt key !!!
pos += sz; i++;
CipherARCFOUR rc4;
rc4.Init(CipherARCFOUR::rtl_Cipher_DirectionDecode, pDecryptedKey.ptr, pDecryptedKey.size, 0, 0);
rc4.Decode(data_inp + pos, sz, data_out + pos, sz);
pos += sz, i++;
}
}
else

View File

@ -128,9 +128,9 @@ public:
ECMADecryptor();
virtual ~ECMADecryptor();
void Decrypt (unsigned char* data, int size, unsigned char*& data_out);
void Decrypt (unsigned char* data, int size, unsigned char*& data_out, int start_iv_block = 0);
virtual void Decrypt (char* data, const size_t size, const unsigned long stream_pos);
virtual void Decrypt (char* data, const size_t size, const unsigned long start_iv_block);
virtual bool SetPassword (std::wstring password);
virtual bool IsVerify();

View File

@ -39,7 +39,6 @@
6967AFB11E2793A500A129E2 /* cextracttools.h in Headers */ = {isa = PBXBuildFile; fileRef = 6967AFAF1E2793A500A129E2 /* cextracttools.h */; };
6967AFB51E27940600A129E2 /* ASCConverters.h in Headers */ = {isa = PBXBuildFile; fileRef = 6967AFB31E27940600A129E2 /* ASCConverters.h */; };
6967AFDF1E279B3600A129E2 /* libTxtXmlFormatLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6967AFDC1E279B2300A129E2 /* libTxtXmlFormatLib.a */; };
6967B0B31E27A07100A129E2 /* libPPTFormatLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6967B0961E27A03800A129E2 /* libPPTFormatLib.a */; };
6967B0D41E27A36E00A129E2 /* libHtmlFile.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6967B0D11E27A35F00A129E2 /* libHtmlFile.a */; };
6967B10A1E27A41B00A129E2 /* libPdfWriter.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6967B1091E27A41400A129E2 /* libPdfWriter.a */; };
6967B10F1E27A65600A129E2 /* OfficeFileFormatChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 6967B10D1E27A65600A129E2 /* OfficeFileFormatChecker.h */; };
@ -242,20 +241,6 @@
remoteGlobalIDString = 6967AFBE1E2798B900A129E2;
remoteInfo = TxtXmlFormatLib;
};
6967B0951E27A03800A129E2 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 6967B0911E27A03800A129E2 /* PPTFormatLib.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 6967AFFB1E279D3900A129E2;
remoteInfo = PPTFormatLib;
};
6967B0B01E27A06900A129E2 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 6967B0911E27A03800A129E2 /* PPTFormatLib.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 6967AFFA1E279D3900A129E2;
remoteInfo = PPTFormatLib;
};
6967B0D01E27A35F00A129E2 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 6967B0CC1E27A35E00A129E2 /* HtmlFile.xcodeproj */;
@ -474,7 +459,6 @@
6967AFAF1E2793A500A129E2 /* cextracttools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cextracttools.h; path = ../../../../src/cextracttools.h; sourceTree = "<group>"; };
6967AFB31E27940600A129E2 /* ASCConverters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASCConverters.h; path = ../../../../src/ASCConverters.h; sourceTree = "<group>"; };
6967AFD71E279B2300A129E2 /* TxtXmlFormatLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = TxtXmlFormatLib.xcodeproj; path = ../../../../ASCOfficeTxtFile/TxtXmlFormatLib/Mac/TxtXmlFormatLib/TxtXmlFormatLib.xcodeproj; sourceTree = "<group>"; };
6967B0911E27A03800A129E2 /* PPTFormatLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PPTFormatLib.xcodeproj; path = ../../../../ASCOfficePPTFile/PPTFormatLib/Mac/PPTFormatLib.xcodeproj; sourceTree = "<group>"; };
6967B0CC1E27A35E00A129E2 /* HtmlFile.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = HtmlFile.xcodeproj; path = ../../../../HtmlFile/Mac/HtmlFile/HtmlFile.xcodeproj; sourceTree = "<group>"; };
6967B1031E27A41300A129E2 /* PdfWriter.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PdfWriter.xcodeproj; path = ../../../../DesktopEditor/ios_projects/PdfWriter/PdfWriter.xcodeproj; sourceTree = "<group>"; };
6967B10D1E27A65600A129E2 /* OfficeFileFormatChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OfficeFileFormatChecker.h; path = ../../../../../Common/OfficeFileFormatChecker.h; sourceTree = "<group>"; };
@ -503,7 +487,6 @@
6967B1D11E27B9D700A129E2 /* libRtfFormatLib.a in Frameworks */,
6967B10A1E27A41B00A129E2 /* libPdfWriter.a in Frameworks */,
6967B0D41E27A36E00A129E2 /* libHtmlFile.a in Frameworks */,
6967B0B31E27A07100A129E2 /* libPPTFormatLib.a in Frameworks */,
6967AFDF1E279B3600A129E2 /* libTxtXmlFormatLib.a in Frameworks */,
69EC66D91E01775B003527E2 /* libUnicodeConverter.a in Frameworks */,
69DA32F11CEE100E00E10AF0 /* libagg_ios.a in Frameworks */,
@ -548,7 +531,6 @@
6967B1C91E27B9C400A129E2 /* RtfFormatLib.xcodeproj */,
6967B1031E27A41300A129E2 /* PdfWriter.xcodeproj */,
6967B0CC1E27A35E00A129E2 /* HtmlFile.xcodeproj */,
6967B0911E27A03800A129E2 /* PPTFormatLib.xcodeproj */,
6967AFD71E279B2300A129E2 /* TxtXmlFormatLib.xcodeproj */,
69EC66CD1E01770C003527E2 /* UnicodeConverter.xcodeproj */,
69415FAE1CB5243F003E771B /* mng.xcodeproj */,
@ -704,14 +686,6 @@
name = Products;
sourceTree = "<group>";
};
6967B0921E27A03800A129E2 /* Products */ = {
isa = PBXGroup;
children = (
6967B0961E27A03800A129E2 /* libPPTFormatLib.a */,
);
name = Products;
sourceTree = "<group>";
};
6967B0CD1E27A35E00A129E2 /* Products */ = {
isa = PBXGroup;
children = (
@ -865,7 +839,6 @@
6967B1D01E27B9D000A129E2 /* PBXTargetDependency */,
6967B10C1E27A42500A129E2 /* PBXTargetDependency */,
6967B0D31E27A36800A129E2 /* PBXTargetDependency */,
6967B0B11E27A06900A129E2 /* PBXTargetDependency */,
6967AFDE1E279B2D00A129E2 /* PBXTargetDependency */,
69EC66D81E01774D003527E2 /* PBXTargetDependency */,
69DA32F01CEE100700E10AF0 /* PBXTargetDependency */,
@ -995,10 +968,6 @@
ProductGroup = 69415FB21CB5243F003E771B /* Products */;
ProjectRef = 69415FB11CB5243F003E771B /* png.xcodeproj */;
},
{
ProductGroup = 6967B0921E27A03800A129E2 /* Products */;
ProjectRef = 6967B0911E27A03800A129E2 /* PPTFormatLib.xcodeproj */;
},
{
ProductGroup = 69DA325D1CEE09BB00E10AF0 /* Products */;
ProjectRef = 69DA325C1CEE09BB00E10AF0 /* PPTXFormatLib.xcodeproj */;
@ -1128,13 +1097,6 @@
remoteRef = 6967AFDB1E279B2300A129E2 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
6967B0961E27A03800A129E2 /* libPPTFormatLib.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libPPTFormatLib.a;
remoteRef = 6967B0951E27A03800A129E2 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
6967B0D11E27A35F00A129E2 /* libHtmlFile.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
@ -1331,11 +1293,6 @@
name = TxtXmlFormatLib;
targetProxy = 6967AFDD1E279B2D00A129E2 /* PBXContainerItemProxy */;
};
6967B0B11E27A06900A129E2 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = PPTFormatLib;
targetProxy = 6967B0B01E27A06900A129E2 /* PBXContainerItemProxy */;
};
6967B0D31E27A36800A129E2 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = HtmlFile;

View File

@ -758,41 +758,41 @@ namespace NExtractTools
// ppsx -> pptx
int ppsx2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
{
std::wstring sTempUnpackedPPSX = sTemp + FILE_SEPARATOR_STR + L"ppsx_unpacked";
NSDirectory::CreateDirectory(sTempUnpackedPPSX);
int nRes = ppsx2pptx_dir(sFrom, sTempUnpackedPPSX, params);
if(SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedPPSX, sTo, -1))
return 0;
}
// std::wstring sTempUnpackedPPSX = sTemp + FILE_SEPARATOR_STR + L"ppsx_unpacked";
// NSDirectory::CreateDirectory(sTempUnpackedPPSX);
//
// int nRes = ppsx2pptx_dir(sFrom, sTempUnpackedPPSX, params);
// if(SUCCEEDED_X2T(nRes))
// {
// COfficeUtils oCOfficeUtils(NULL);
// if(S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedPPSX, sTo, -1))
// return 0;
// }
return AVS_FILEUTILS_ERROR_CONVERT;
}
int ppsx2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo, InputParams& params)
{
COfficeUtils oCOfficeUtils(NULL);
if (S_OK == oCOfficeUtils.ExtractToDirectory(sFrom, sTo, NULL, 0))
{
std::wstring sContentTypesPath = sTo + FILE_SEPARATOR_STR + L"[Content_Types].xml";
if(NSFile::CFileBinary::Exists(sContentTypesPath))
{
std::wstring sData;
if(NSFile::CFileBinary::ReadAllTextUtf8(sContentTypesPath, sData))
{
std::wstring sCTFrom = L"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml";
std::wstring sCTTo = L"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
sData = string_replaceAll(sData, sCTFrom, sCTTo);
if(NSFile::CFileBinary::SaveToFile(sContentTypesPath, sData, true))
{
return 0;
}
}
}
}
// COfficeUtils oCOfficeUtils(NULL);
// if (S_OK == oCOfficeUtils.ExtractToDirectory(sFrom, sTo, NULL, 0))
// {
// std::wstring sContentTypesPath = sTo + FILE_SEPARATOR_STR + L"[Content_Types].xml";
// if(NSFile::CFileBinary::Exists(sContentTypesPath))
// {
// std::wstring sData;
// if(NSFile::CFileBinary::ReadAllTextUtf8(sContentTypesPath, sData))
// {
// std::wstring sCTFrom = L"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml";
// std::wstring sCTTo = L"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
//
// sData = string_replaceAll(sData, sCTFrom, sCTTo);
//
// if(NSFile::CFileBinary::SaveToFile(sContentTypesPath, sData, true))
// {
// return 0;
// }
// }
// }
// }
return AVS_FILEUTILS_ERROR_CONVERT;
}
@ -812,70 +812,76 @@ namespace NExtractTools
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
int ppt2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
{
COfficePPTFile pptFile;
pptFile.put_TempDirectory(sTemp);
return S_OK == pptFile.LoadFromFile(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
int ppt2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
{
//COfficePPTFile pptFile;
//pptFile.put_TempDirectory(sTemp);
//return S_OK == pptFile.LoadFromFile(sFrom, sTo, params.getPassword()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
return AVS_FILEUTILS_ERROR_CONVERT;
}
// ppt -> pptt
int ppt2pptt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
{
std::wstring sResultPpttDir = sTemp + FILE_SEPARATOR_STR + L"pptt_unpacked";
std::wstring sTempPpttFileEditor = sResultPpttDir + FILE_SEPARATOR_STR + L"Editor.bin";
//std::wstring sResultPpttDir = sTemp + FILE_SEPARATOR_STR + L"pptt_unpacked";
//std::wstring sTempPpttFileEditor = sResultPpttDir + FILE_SEPARATOR_STR + L"Editor.bin";
NSDirectory::CreateDirectory(sResultPpttDir);
//NSDirectory::CreateDirectory(sResultPpttDir);
int nRes = ppt2pptt_bin(sFrom, sTempPpttFileEditor, sTemp, params);
if (SUCCEEDED_X2T(nRes))
{
// zip pptt folder to output file
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory (sResultPpttDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
//int nRes = ppt2pptt_bin(sFrom, sTempPpttFileEditor, sTemp, params);
//if (SUCCEEDED_X2T(nRes))
//{
// // zip pptt folder to output file
// COfficeUtils oCOfficeUtils(NULL);
// nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory (sResultPpttDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
//}
//return nRes;
return AVS_FILEUTILS_ERROR_CONVERT;
}
// ppt -> pptt_bin
int ppt2pptt_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
{
// unzip pptx to temp folder
std::wstring sTempUnpackedPPTX = sTemp + FILE_SEPARATOR_STR + L"pptx_unpacked"+ FILE_SEPARATOR_STR; // leading slash is very important!
NSDirectory::CreateDirectory(sTempUnpackedPPTX);
COfficePPTFile pptFile;
pptFile.put_TempDirectory(sTemp);
if ( pptFile.LoadFromFile(sFrom, sTempUnpackedPPTX) != S_OK) return AVS_FILEUTILS_ERROR_CONVERT;
// convert unzipped pptx to unzipped pptt
CPPTXFile *pptx_file = new CPPTXFile(NULL, NULL, NULL, NULL);
int nRes = 0;
if (pptx_file)
{
#if defined(_WIN32) || defined (_WIN64)
BSTR bstrFontPath = SysAllocString(params.getFontPath().c_str());
BSTR bstrTempUnpackedPPTX = SysAllocString(sTempUnpackedPPTX.c_str());
BSTR bstrTo = SysAllocString(sTo.c_str());
pptx_file->SetFontDir (bstrFontPath);
nRes = (S_OK == pptx_file->OpenFileToPPTY (bstrTempUnpackedPPTX, bstrTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
SysFreeString(bstrFontPath);
SysFreeString(bstrTempUnpackedPPTX);
SysFreeString(bstrTo);
#else
pptx_file->SetFontDir (params.getFontPath());
nRes = (S_OK == pptx_file->OpenFileToPPTY (sTempUnpackedPPTX, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
#endif
delete pptx_file;
}
return nRes;
// std::wstring sTempUnpackedPPTX = sTemp + FILE_SEPARATOR_STR + L"pptx_unpacked"+ FILE_SEPARATOR_STR; // leading slash is very important!
//
// NSDirectory::CreateDirectory(sTempUnpackedPPTX);
//
// COfficePPTFile pptFile;
//
// pptFile.put_TempDirectory(sTemp);
//
// if ( pptFile.LoadFromFile(sFrom, sTempUnpackedPPTX, params.getPassword()) != S_OK) return AVS_FILEUTILS_ERROR_CONVERT;
//
// // convert unzipped pptx to unzipped pptt
// CPPTXFile *pptx_file = new CPPTXFile(NULL, NULL, NULL, NULL);
//
// int nRes = 0;
//
// if (pptx_file)
// {
//#if defined(_WIN32) || defined (_WIN64)
// BSTR bstrFontPath = SysAllocString(params.getFontPath().c_str());
// BSTR bstrTempUnpackedPPTX = SysAllocString(sTempUnpackedPPTX.c_str());
// BSTR bstrTo = SysAllocString(sTo.c_str());
//
// pptx_file->SetFontDir (bstrFontPath);
// nRes = (S_OK == pptx_file->OpenFileToPPTY (bstrTempUnpackedPPTX, bstrTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
//
// SysFreeString(bstrFontPath);
// SysFreeString(bstrTempUnpackedPPTX);
// SysFreeString(bstrTo);
//#else
// pptx_file->SetFontDir (params.getFontPath());
// nRes = (S_OK == pptx_file->OpenFileToPPTY (sTempUnpackedPPTX, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
//#endif
// delete pptx_file;
// }
//
// return nRes;
return AVS_FILEUTILS_ERROR_CONVERT;
}
// rtf -> docx