Compare commits

..

8 Commits

11 changed files with 337 additions and 60 deletions

View File

@ -282,6 +282,12 @@ namespace NSBinPptxRW
m_pContentTypes->AddDefault(strExts.substr(1));
}
if (oleData.empty() == false)
{
//plugins data - generate ole
typeAdditional = 1;
}
_imageManager2Info oImageManagerInfo = GenerateImageExec(strImage, strExts, strAdditional, typeAdditional, oleData);
if (!oImageManagerInfo.sFilepathAdditional.empty())
@ -346,8 +352,11 @@ namespace NSBinPptxRW
{
oPathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strImage + strExts;
if (oPathOutput.GetPath() != strInput)
CDirectory::CopyFile(strInput, oPathOutput.GetPath());
if (oPathOutput.GetPath() != strInput && NSFile::CFileBinary::Exists(strInput))
{
NSFile::CFileBinary::Copy(strInput, oPathOutput.GetPath());
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
}
}
else
{
@ -355,8 +364,8 @@ namespace NSBinPptxRW
strExts = _T(".png");
oPathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strImage + strExts;
SaveImageAsPng(strInput, oPathOutput.GetPath());
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
}
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
if ((!strAdditionalImage.empty() || !oleData.empty() ) && (nAdditionalType == 1))
{
@ -374,13 +383,14 @@ namespace NSBinPptxRW
if(!oleData.empty())
{
WriteOleData(strAdditionalImageOut, oleData);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
else
else if (NSFile::CFileBinary::Exists(strAdditionalImage))
{
CDirectory::CopyFile(strAdditionalImage, strAdditionalImageOut);
NSFile::CFileBinary::Copy(strAdditionalImage, strAdditionalImageOut);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
else if (!strAdditionalImage.empty() && nAdditionalType == 2)
{
@ -395,8 +405,11 @@ namespace NSBinPptxRW
std::wstring strAdditionalImageOut = pathOutput.GetPath();
CDirectory::CopyFile(strAdditionalImage, strAdditionalImageOut);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
if (NSFile::CFileBinary::Exists(strAdditionalImage))
{
NSFile::CFileBinary::Copy(strAdditionalImage, strAdditionalImageOut);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
}
return oImageManagerInfo;
@ -1236,24 +1249,28 @@ namespace NSBinPptxRW
if (m_pManager->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX) strImageRelsPath = L"media/";
else strImageRelsPath = L"../media/";
strImageRelsPath += OOX::CPath(oImageManagerInfo.sFilepathImage).GetFilename();
std::map<std::wstring, _relsGeneratorInfo>::iterator pPair = m_mapImages.find(strImageRelsPath);
if (m_mapImages.end() != pPair)
{
return pPair->second;
}
_relsGeneratorInfo oRelsGeneratorInfo;
oRelsGeneratorInfo.nImageRId = m_lNextRelsID++;
oRelsGeneratorInfo.sFilepathImage = oImageManagerInfo.sFilepathImage;
std::wstring strRid = L"rId" + std::to_wstring(oRelsGeneratorInfo.nImageRId);
if (!oImageManagerInfo.sFilepathImage.empty())
{
strImageRelsPath += OOX::CPath(oImageManagerInfo.sFilepathImage).GetFilename();
m_pWriter->WriteString( L"<Relationship Id=\"" + strRid +
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\" Target=\"" + strImageRelsPath +
L"\"/>");
std::map<std::wstring, _relsGeneratorInfo>::iterator pPair = m_mapImages.find(strImageRelsPath);
if (m_mapImages.end() != pPair)
{
return pPair->second;
}
oRelsGeneratorInfo.nImageRId = m_lNextRelsID++;
oRelsGeneratorInfo.sFilepathImage = oImageManagerInfo.sFilepathImage;
std::wstring strRid = L"rId" + std::to_wstring(oRelsGeneratorInfo.nImageRId);
m_pWriter->WriteString( L"<Relationship Id=\"" + strRid +
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\" Target=\"" + strImageRelsPath +
L"\"/>");
}
if(additionalFile.is<OOX::OleObject>())
{
@ -1285,7 +1302,7 @@ namespace NSBinPptxRW
}
}
}
if(additionalFile.is<OOX::Media>())
else if(additionalFile.is<OOX::Media>())
{
smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();

View File

@ -447,7 +447,10 @@ namespace PPTX
if (!blip.is_init())
blip = new PPTX::Logic::Blip();
blip->embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId);
if (oRelsGeneratorInfo.nImageRId >= 0)
{
blip->embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId);
}
if(oRelsGeneratorInfo.nOleRId > 0)
{

View File

@ -1136,8 +1136,18 @@ namespace PPTX
}
}
if (spPr.Geometry.is_init())
bool bRect = bOle; //ole ВСЕГДА rect
if (spPr.Geometry.is<PPTX::Logic::PrstGeom>())
{
const PPTX::Logic::PrstGeom & lpGeom = spPr.Geometry.as<PPTX::Logic::PrstGeom>();
if( lpGeom.prst.get() == L"rect" )
bRect = true;
}
if (bRect == false)
{//custom vml shape
std::wstring strPath;
std::wstring strTextRect;
@ -1324,7 +1334,9 @@ namespace PPTX
}
if(oleObject->m_oId.IsInit())
{
blipFill.blip->oleRid = oleObject->m_oId.get().ToString();
if (blipFill.blip.IsInit() == false)
blipFill.blip.Init();
blipFill.blip->oleRid = oleObject->m_oId->get();
}
}
} // namespace Logic

View File

@ -42,6 +42,8 @@
#include <xmlsec/templates.h>
#include <xmlsec/crypto.h>
#include "../../../common/File.h"
int sign_file(const char* xml_file, const char* key_file, const char* cert_file);
int
@ -50,13 +52,11 @@ main(int argc, char **argv) {
xsltSecurityPrefsPtr xsltSecPrefs = NULL;
#endif /* XMLSEC_NO_XSLT */
assert(argv);
if(argc != 4) {
fprintf(stderr, "Error: wrong number of arguments.\n");
fprintf(stderr, "Usage: %s <xml-file> <key-file> <cert-file>\n", argv[0]);
return(1);
}
std::wstring sFolderW = NSFile::GetProcessDirectory();
std::string sFolder = U_TO_UTF8(sFolderW);
std::string __file = sFolder + "/settings.xml";
std::string __key = sFolder + "/rsakey.pem";
std::string __cert = sFolder + "/rsacert.pem";
/* Init libxml and libxslt libraries */
xmlInitParser();
@ -117,7 +117,7 @@ main(int argc, char **argv) {
return(-1);
}
if(sign_file(argv[1], argv[2], argv[3]) < 0) {
if(sign_file(__file.c_str(), __key.c_str(), __cert.c_str()) < 0) {
return(-1);
}

View File

@ -138,22 +138,158 @@ namespace ParseAllCultureInfo
{
var index = aTemp[i];
if(nIndexD == index)
sShortDatePattern += "0";
else if (nIndexM == index)
sShortDatePattern += "1";
{
if (nIndexD + 1 < ShortDatePatternLower.Length && 'd' == ShortDatePatternLower[nIndexD + 1])
{
sShortDatePattern += "1";
}
else
{
sShortDatePattern += "0";
}
} else if (nIndexM == index)
{
if (nIndexM + 1 < ShortDatePatternLower.Length && 'm' == ShortDatePatternLower[nIndexM + 1])
{
sShortDatePattern += "3";
}
else
{
sShortDatePattern += "2";
}
}
else if (nIndexY == index)
sShortDatePattern += "2";
{
if (nIndexY + 2 < ShortDatePatternLower.Length && 'y' == ShortDatePatternLower[nIndexY + 2])
{
sShortDatePattern += "5";
}
else
{
sShortDatePattern += "4";
}
}
}
ShortDatePattern = sShortDatePattern;
}
}
static Dictionary<int, int> g_mapUsedValues = new Dictionary<int, int>() {
{4, 1},
{5, 1},
{7, 1},
{8, 1},
{9, 1},
{10, 1},
{11, 1},
{12, 1},
{16, 1},
{17, 1},
{18, 1},
{21, 1},
{22, 1},
{25, 1},
{31, 1},
{34, 1},
{36, 1},
{38, 1},
{42, 1},
{44, 1},
{1028, 1},
{1029, 1},
{1031, 1},
{1032, 1},
{1033, 1},
{1035, 1},
{1036, 1},
{1040, 1},
{1041, 1},
{1042, 1},
{1045, 1},
{1046, 1},
{1049, 1},
{1055, 1},
{1058, 1},
{1060, 1},
{1062, 1},
{1066, 1},
{1068, 1},
{2052, 1},
{2055, 1},
{2057, 1},
{2058, 1},
{2060, 1},
{2064, 1},
{2070, 1},
{2073, 1},
{2092, 1},
{3076, 1},
{3079, 1},
{3081, 1},
{3082, 1},
{3084, 1},
{4100, 1},
{4103, 1},
{4105, 1},
{4106, 1},
{4108, 1},
{5124, 1},
{5127, 1},
{5129, 1},
{5130, 1},
{5132, 1},
{6153, 1},
{6154, 1},
{6156, 1},
{7177, 1},
{7178, 1},
{7180, 1},
{8201, 1},
{8202, 1},
{8204, 1},
{9225, 1},
{9226, 1},
{9228, 1},
{10249, 1},
{10250, 1},
{10252, 1},
{11273, 1},
{11274, 1},
{11276, 1},
{12297, 1},
{12298, 1},
{12300, 1},
{13321, 1},
{13322, 1},
{13324, 1},
{14345, 1},
{14346, 1},
{14348, 1},
{15369, 1},
{15370, 1},
{15372, 1},
{16393, 1},
{16394, 1},
{17417, 1},
{17418, 1},
{18441, 1},
{18442, 1},
{19466, 1},
{20490, 1},
{21514, 1},
{22538, 1},
{23562, 1},
{29740, 1},
{30724, 1},
{30764, 1},
{31748, 1}
};
public static void parse()
{
List<int> aLcid = new List<int>();
Dictionary<int, CultureInfo> aInfos = new Dictionary<int, CultureInfo>();
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
{
if (!aInfos.ContainsKey(ci.LCID))
if (!aInfos.ContainsKey(ci.LCID) && g_mapUsedValues.ContainsKey(ci.LCID))
{
aLcid.Add(ci.LCID);
aInfos[ci.LCID] = ci;

View File

@ -7,7 +7,7 @@
QT -= core
QT -= gui
VERSION = 2.4.463.0
VERSION = 2.4.464.0
DEFINES += INTVER=$$VERSION
TARGET = x2t

View File

@ -2521,7 +2521,54 @@ namespace NExtractTools
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
int html2doct_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params)
{
std::wstring sResultDoctDir = NSFile::GetDirectoryName(sTo);
int nRes = html2doct_dir(sFrom, sResultDoctDir, sTemp, params);
return nRes;
}
int html2doct(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params)
{
std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
NSDirectory::CreateDirectory(sResultDoctDir);
int nRes = html2doct_dir(sFrom, sResultDoctDir, sTemp, params);
if (SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDoctDir, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
int html2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params)
{
std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
NSDirectory::CreateDirectory(sResultDoctDir);
int nRes = html2doct_dir(sFrom, sResultDoctDir, sTemp, params);
if (SUCCEEDED_X2T(nRes))
{
std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
NSDirectory::CreateDirectory(sDocxDir);
nRes = doct_bin2docx_dir(sResultDoctFileEditor, L"", sDocxDir, false, L"", params);
if (SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sDocxDir, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
}
return nRes;
}
//------------------------------------------------------------------------------------------------------------------
int fromInputParams(InputParams& oInputParams)
{
TConversionDirection conversion = oInputParams.getConversionDirection();
@ -2828,6 +2875,26 @@ namespace NExtractTools
result = mscrypt2oot_bin (sFileFrom, sFileTo, sTempDir, oInputParams);
{
}break;
case TCD_HTML2DOCX:
{
result = html2docx (sFileFrom, sFileTo, sTempDir, oInputParams);
}break;
case TCD_HTML2DOCT:
{
result = html2doct (sFileFrom, sFileTo, sTempDir, oInputParams);
}break;
case TCD_HTML2DOCT_BIN:
{
result = html2doct_bin (sFileFrom, sFileTo, sTempDir, oInputParams);
}break;
//TCD_FB22DOCX,
//TCD_FB22DOCT,
//TCD_FB22DOCT_BIN,
//TCD_EPUB2DOCX,
//TCD_EPUB2DOCT,
//TCD_EPUB2DOCT_BIN,
}
// delete temp dir

View File

@ -131,6 +131,10 @@ namespace NExtractTools
int oox2mscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
int html2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
int html2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
int html2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
//-------------------------------------------------------------------------------------------------------------------------------------------------
int dir2zip (const std::wstring &sFrom, const std::wstring &sTo);
int zip2dir (const std::wstring &sFrom, const std::wstring &sTo);

View File

@ -223,6 +223,24 @@ namespace NExtractTools
else if (0 == sExt2.compare(_T(".pptt"))) res = TCD_MSCRYPT2PPTT;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_MSCRYPT2BIN;
}break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML:
{
if (0 == sExt2.compare(_T(".docx"))) res = TCD_HTML2DOCX;
else if (0 == sExt2.compare(_T(".doct"))) res = TCD_HTML2DOCT;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_HTML2DOCT_BIN;
}break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_FB2:
{
if (0 == sExt2.compare(_T(".docx"))) res = TCD_FB22DOCX;
else if (0 == sExt2.compare(_T(".doct"))) res = TCD_FB22DOCT;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_FB22DOCT_BIN;
}break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB:
{
if (0 == sExt2.compare(_T(".docx"))) res = TCD_EPUB2DOCX;
else if (0 == sExt2.compare(_T(".doct"))) res = TCD_EPUB2DOCT;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_EPUB2DOCT_BIN;
}break;
}
}
}

View File

@ -136,7 +136,7 @@ namespace NExtractTools
TCD_PPTT2ODP,
TCD_PPTX_BIN2ODP,
TCD_XML2DOCX,
TCD_XML2DOCX,
TCD_DOCX2XML,
//
TCD_MSCRYPT2,
@ -145,6 +145,18 @@ namespace NExtractTools
TCD_MSCRYPT2PPTT,
TCD_MSCRYPT2BIN,
//
TCD_HTML2DOCX,
TCD_HTML2DOCT,
TCD_HTML2DOCT_BIN,
TCD_FB22DOCX,
TCD_FB22DOCT,
TCD_FB22DOCT_BIN,
TCD_EPUB2DOCX,
TCD_EPUB2DOCT,
TCD_EPUB2DOCT_BIN,
TCD_MAILMERGE,
TCD_T2,
TCD_DOCT_BIN2,

View File

@ -2766,7 +2766,7 @@ namespace BinXlsxRW {
res = Read1(length, &BinaryWorksheetsTableReader::ReadDrawing, this, pCellAnchor);
pCellAnchor->m_bShapeOle = false;
if (pCellAnchor->m_oElement->is<PPTX::Logic::Pic>())
if (pCellAnchor->m_oElement.is_init() && pCellAnchor->m_oElement->is<PPTX::Logic::Pic>())
{
PPTX::Logic::Pic& oPic = pCellAnchor->m_oElement->as<PPTX::Logic::Pic>();
if(oPic.oleObject.IsInit() && oPic.oleObject->m_OleObjectFile.IsInit())
@ -2825,24 +2825,29 @@ namespace BinXlsxRW {
m_pCurVmlDrawing->m_lObjectIdVML = oWriter.m_lObjectIdVML;
pOleObject->m_oShapeId = *oPic.oleObject->m_sShapeId;
//add image rels to VmlDrawing
OOX::CPath pathImageCache = pOleObject->m_OleObjectFile->filename_cache();
NSCommon::smart_ptr<OOX::Image> pImageFileVml(new OOX::Image(false));
pImageFileVml->set_filename(pathImageCache);
OOX::CPath pathImageCache = pOleObject->m_OleObjectFile->filename_cache();
smart_ptr<OOX::RId> oRIdImg;
smart_ptr<OOX::File> pFileVml = pImageFileVml.smart_dynamic_cast<OOX::File>();
m_pCurVmlDrawing->Add(*oPic.blipFill.blip->embed, pFileVml);
if (pathImageCache.GetPath().empty() == false)
{
//add image rels to VmlDrawing
NSCommon::smart_ptr<OOX::Image> pImageFileVml(new OOX::Image(false));
pImageFileVml->set_filename(pathImageCache);
smart_ptr<OOX::File> pFileVml = pImageFileVml.smart_dynamic_cast<OOX::File>();
m_pCurVmlDrawing->Add(*oPic.blipFill.blip->embed, pFileVml);
//add image rels to Worksheet
NSCommon::smart_ptr<OOX::Image> pImageFileWorksheet(new OOX::Image(false));
//add image rels to Worksheet
NSCommon::smart_ptr<OOX::Image> pImageFileWorksheet(new OOX::Image(false));
pImageFileWorksheet->set_filename(pathImageCache);
smart_ptr<OOX::File> pFileWorksheet = pImageFileWorksheet.smart_dynamic_cast<OOX::File>();
const OOX::RId oRIdImg = m_pCurWorksheet->Add(pFileWorksheet);
//add oleObject rels
pImageFileWorksheet->set_filename(pathImageCache);
smart_ptr<OOX::File> pFileWorksheet = pImageFileWorksheet.smart_dynamic_cast<OOX::File>();
oRIdImg = new OOX::RId(m_pCurWorksheet->Add(pFileWorksheet));
}
//add oleObject rels
if(!m_pCurWorksheet->m_oOleObjects.IsInit())
{
m_pCurWorksheet->m_oOleObjects.Init();
@ -2861,7 +2866,10 @@ namespace BinXlsxRW {
pOleObject->m_oObjectPr->m_oDefaultSize.Init();
pOleObject->m_oObjectPr->m_oDefaultSize->FromBool(false);
pOleObject->m_oObjectPr->m_oRid.Init();
pOleObject->m_oObjectPr->m_oRid->SetValue(oRIdImg.get());
if (oRIdImg.IsInit())
pOleObject->m_oObjectPr->m_oRid->SetValue(oRIdImg->get());
pOleObject->m_oObjectPr->m_oAnchor.Init();
SimpleTypes::Spreadsheet::ECellAnchorType eAnchorType = pCellAnchor->m_oAnchorType.GetValue();