Compare commits

...

9 Commits

Author SHA1 Message Date
a607282285 refactoring... 2017-08-02 17:27:41 +03:00
62ea2bbc46 Editor.bin without base64 2017-07-27 14:49:57 +03:00
4071fa315b Added building hunspell 2017-07-26 13:22:00 +03:00
82eae7fc3e hunspell dynamic link 2017-07-26 11:18:25 +03:00
8efed345b0 fix bug #35412 2017-07-24 17:32:31 +03:00
f5dcb1bed7 Merge branch 'hotfix/v4.4.2' into develop
Conflicts:
	ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp
2017-07-24 15:46:05 +03:00
6b4695fc3a . 2017-07-24 15:06:01 +03:00
3982ac06d2 Merge pull request #35 from ONLYOFFICE/feature/lena_fix_2
fix not compiled
2017-07-21 17:38:16 +03:00
0a5d0af882 fix not compiled 2017-07-21 17:36:56 +03:00
27 changed files with 632 additions and 186 deletions

View File

@ -125,6 +125,7 @@ const double g_dKoef_mm_to_hps = 2 * g_dKoef_mm_to_pt;
const static wchar_t* g_sFormatSignature = L"DOCY";
const int g_nFormatVersion = 5;
const int g_nFormatVersionNoBase64 = 10;
extern int g_nCurFormatVersion;
namespace c_oAscWrapStyle{enum c_oSerFormat
{

View File

@ -7714,9 +7714,9 @@ namespace BinDocxRW
m_nLastFilePos = 0;
m_nRealTableCount = 0;
}
static std::wstring WriteFileHeader(long nDataSize)
static std::wstring WriteFileHeader(long nDataSize, int version)
{
std::wstring sHeader = std::wstring(g_sFormatSignature) + L";v" + std::to_wstring(g_nFormatVersion) + L";" + std::to_wstring(nDataSize) + L";";
std::wstring sHeader = std::wstring(g_sFormatSignature) + L";v" + std::to_wstring(version) + L";" + std::to_wstring(nDataSize) + L";";
return sHeader;
}
void WriteMainTableStart()

View File

@ -47,6 +47,7 @@ BinDocxRW::CDocxSerializer::CDocxSerializer()
m_pCurFileWriter = NULL;
m_bIsNoBase64Save = false;
m_bIsNoBase64 = false;
m_bSaveChartAsImg = false;
}
BinDocxRW::CDocxSerializer::~CDocxSerializer()
@ -54,52 +55,6 @@ BinDocxRW::CDocxSerializer::~CDocxSerializer()
RELEASEOBJECT(m_pParamsWriter);
RELEASEOBJECT(m_pCurFileWriter);
}
bool BinDocxRW::CDocxSerializer::ConvertDocxToDoct(const std::wstring& sSrcFileName, const std::wstring& sDstFileName, const std::wstring& sTmpDir, const std::wstring& sXMLOptions)
{
std::wstring strDirSrc = NSSystemPath::Combine(sTmpDir, L"from");
std::wstring strDirDst = NSSystemPath::Combine(sTmpDir, L"to");
std::wstring strEditorBin = NSSystemPath::Combine(strDirDst, L"Editor.bin");
NSDirectory::CreateDirectory(strDirSrc);
NSDirectory::CreateDirectory(strDirDst);
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.ExtractToDirectory(sSrcFileName, strDirSrc, NULL, 0))
if(saveToFile(strEditorBin, strDirSrc, sXMLOptions))
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName))
return true;
return false;
}
bool BinDocxRW::CDocxSerializer::ConvertDoctToDocx(const std::wstring& sSrcFileName, const std::wstring& sDstFileName, const std::wstring& sTmpDir, const std::wstring& sXMLOptions)
{
std::wstring strDirSrc = NSSystemPath::Combine(sTmpDir, L"from");
std::wstring strEditorBin = NSSystemPath::Combine(strDirSrc, L"Editor.bin");
std::wstring strDirDst = NSSystemPath::Combine(sTmpDir, L"to");
NSDirectory::CreateDirectory(strDirSrc);
NSDirectory::CreateDirectory(strDirDst);
std::wstring sEditorBin = strEditorBin;
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.ExtractToDirectory(sSrcFileName, strDirSrc, NULL, 0))
{
std::wstring sMediaPath;
std::wstring sThemePath;
std::wstring sEmbedPath;
CreateDocxFolders(strDirDst, sThemePath, sMediaPath, sEmbedPath);
if(loadFromFile(sEditorBin, strDirDst, sXMLOptions, sThemePath, sMediaPath, sEmbedPath))
{
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, true))
return true;
}
}
return false;
}
bool BinDocxRW::CDocxSerializer::saveToFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions)
{
OOX::CPath pathMain(sSrcFileName);
@ -144,13 +99,17 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const std::wstring& sSrcFileName, co
BinaryFileWriter oBinaryFileWriter(*m_pParamsWriter);
if (m_bIsNoBase64)
{
oBufferedStream.WriteStringUtf8(oBinaryFileWriter.WriteFileHeader(0, g_nFormatVersionNoBase64));
}
oBinaryFileWriter.intoBindoc(sDstPath);
BYTE* pbBinBuffer = oBufferedStream.GetBuffer();
int nBinBufferLen = oBufferedStream.GetPosition();
if (m_bIsNoBase64Save)
if (m_bIsNoBase64 || m_bIsNoBase64Save)
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(sSrcFileName);
@ -166,7 +125,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const std::wstring& sSrcFileName, co
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(sSrcFileName);
oFile.WriteStringUTF8(oBinaryFileWriter.WriteFileHeader(nBinBufferLen));
oFile.WriteStringUTF8(oBinaryFileWriter.WriteFileHeader(nBinBufferLen, g_nFormatVersion));
oFile.WriteFile(pbBase64Buffer, nBase64BufferLen);
oFile.CloseFile();
}
@ -268,27 +227,42 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
else
dst_len += _c;
}
int nDataSize = atoi(dst_len.c_str());
BYTE* pData = new BYTE[nDataSize];
if(false != Base64::Base64Decode((const char*)(pBase64Data + nIndex), nBase64DataSize - nIndex, pData, &nDataSize))
int nVersion = g_nFormatVersion;
if(!version.empty())
{
NSBinPptxRW::CDrawingConverter oDrawingConverter;
NSBinPptxRW::CBinaryFileReader& oBufferedStream = *oDrawingConverter.m_pReader;
oBufferedStream.Init(pData, 0, nDataSize);
version = version.substr(1);
g_nCurFormatVersion = nVersion = std::stoi(version.c_str());
}
bool bIsNoBase64 = nVersion == g_nFormatVersionNoBase64;
int nVersion = g_nFormatVersion;
if(!version.empty())
NSBinPptxRW::CDrawingConverter oDrawingConverter;
NSBinPptxRW::CBinaryFileReader& oBufferedStream = *oDrawingConverter.m_pReader;
int nDataSize = 0;
BYTE* pData = NULL;
if (!bIsNoBase64)
{
nDataSize = atoi(dst_len.c_str());
pData = new BYTE[nDataSize];
if(Base64::Base64Decode((const char*)(pBase64Data + nIndex), nBase64DataSize - nIndex, pData, &nDataSize))
{
version = version.substr(1);
int nTempVersion = atoi(version.c_str());
if(0 != nTempVersion)
{
g_nCurFormatVersion = nVersion = nTempVersion;
}
}
oBufferedStream.Init(pData, 0, nDataSize);
}
else
{
RELEASEARRAYOBJECTS(pData);
}
}
else
{
nDataSize = nBase64DataSize;
pData = pBase64Data;
oBufferedStream.Init(pData, 0, nDataSize);
oBufferedStream.Seek(nIndex);
}
if (NULL != pData)
{
oDrawingConverter.SetMainDocument(this);
oDrawingConverter.SetMediaDstPath(sMediaPath);
oDrawingConverter.SetEmbedDstPath(sEmbedPath);
@ -343,6 +317,11 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
bResultOk = true;
}
if (!bIsNoBase64)
{
RELEASEARRAYOBJECTS(pData);
}
}
RELEASEARRAYOBJECTS(pBase64Data);
}
@ -472,6 +451,10 @@ void BinDocxRW::CDocxSerializer::setIsNoBase64Save(bool bIsNoBase64Save)
{
m_bIsNoBase64Save = bIsNoBase64Save;
}
void BinDocxRW::CDocxSerializer::setIsNoBase64(bool bIsNoBase64)
{
m_bIsNoBase64 = bIsNoBase64;
}
void BinDocxRW::CDocxSerializer::setSaveChartAsImg(bool bSaveChartAsImg)
{
m_bSaveChartAsImg = bSaveChartAsImg;

View File

@ -54,6 +54,7 @@ namespace BinDocxRW
std::wstring m_sFontDir;
std::wstring m_sEmbeddedFontsDir;
bool m_bIsNoBase64Save;
bool m_bIsNoBase64;
bool m_bSaveChartAsImg;
ParamsWriter* m_pParamsWriter;
Writers::FileWriter* m_pCurFileWriter;
@ -61,9 +62,6 @@ namespace BinDocxRW
CDocxSerializer();
virtual ~CDocxSerializer();
bool ConvertDocxToDoct(const std::wstring& sSrcFileName, const std::wstring& sDstFileName, const std::wstring& sTmpDir, const std::wstring& sXMLOptions);
bool ConvertDoctToDocx(const std::wstring& sSrcFileName, const std::wstring& sDstFileName, const std::wstring& sTmpDir, const std::wstring& sXMLOptions);
bool loadFromFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sThemePath, const std::wstring& sMediaPath, const std::wstring& sEmbedPath);
bool saveToFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions);
@ -78,6 +76,7 @@ namespace BinDocxRW
void setFontDir (const std::wstring& sFontDir);
void setEmbeddedFontsDir(const std::wstring& sEmbeddedFontsDir);
void setIsNoBase64Save (bool bIsNoBase64Save);
void setIsNoBase64 (bool bIsNoBase64);
void setSaveChartAsImg (bool bSaveChartAsImg);
};
}

View File

@ -49,6 +49,7 @@ namespace BinXlsxRW{
CXlsxSerializer::CXlsxSerializer()
{
m_pExternalDrawingConverter = NULL;
m_bIsNoBase64 = false;
}
CXlsxSerializer::~CXlsxSerializer()
{
@ -134,7 +135,7 @@ namespace BinXlsxRW{
oOfficeDrawingConverter.SetFontPicker(pFontPicker);
BinXlsxRW::BinaryFileWriter oBinaryFileWriter(fp);
oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions);
oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions, m_bIsNoBase64);
RELEASEOBJECT(pFontPicker);
return true;
@ -226,6 +227,11 @@ namespace BinXlsxRW{
{
m_pExternalDrawingConverter = pDrawingConverter;
}
void CXlsxSerializer::setIsNoBase64(bool bIsNoBase64)
{
m_bIsNoBase64 = bIsNoBase64;
}
void CXlsxSerializer::writeChartXlsx(const std::wstring& sDstFile, const OOX::Spreadsheet::CChartSpace& oChart)
{
//анализируем chart

View File

@ -55,6 +55,7 @@ namespace BinXlsxRW {
std::wstring m_sFontDir;
std::wstring m_sEmbeddedFontsDir;
NSBinPptxRW::CDrawingConverter* m_pExternalDrawingConverter;
bool m_bIsNoBase64;
public:
CXlsxSerializer();
~CXlsxSerializer();
@ -69,6 +70,7 @@ namespace BinXlsxRW {
void setFontDir (const std::wstring& sFontDir);
void setEmbeddedFontsDir(const std::wstring& sEmbeddedFontsDir);
void setDrawingConverter(NSBinPptxRW::CDrawingConverter* pDrawingConverter);
void setIsNoBase64 (bool bIsNoBase64);
void writeChartXlsx (const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);
};

View File

@ -594,8 +594,17 @@ void OoxConverter::convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle*
convert(oox_spPr->xfrm.GetPointer());
PPTX::Logic::PrstGeom* prstGeom = &oox_spPr->Geometry.as<PPTX::Logic::PrstGeom>();
PPTX::Logic::CustGeom* custGeom = &oox_spPr->Geometry.as<PPTX::Logic::CustGeom>();
PPTX::Logic::PrstGeom* prstGeom = NULL;
PPTX::Logic::CustGeom* custGeom = NULL;
if (oox_spPr->Geometry.is<PPTX::Logic::PrstGeom>())
{
prstGeom = &oox_spPr->Geometry.as<PPTX::Logic::PrstGeom>();
}
if (oox_spPr->Geometry.is<PPTX::Logic::CustGeom>())
{
custGeom = &oox_spPr->Geometry.as<PPTX::Logic::CustGeom>();
}
convert(prstGeom);
convert(custGeom);
@ -627,8 +636,13 @@ void OoxConverter::convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle*
}
odf_context()->drawing_context()->end_line_properties();
//-----------------------------------------------------------------------------------------------------------------------------
PPTX::Logic::EffectLst* effectLst = &oox_spPr->EffectList.as<PPTX::Logic::EffectLst>();
PPTX::Logic::EffectLst* effectLst = NULL;
if (oox_spPr->EffectList.is<PPTX::Logic::EffectLst>())
{
effectLst = &oox_spPr->EffectList.as<PPTX::Logic::EffectLst>();
}
if (effectLst) convert(effectLst);
else if (oox_sp_style) convert(&oox_sp_style->effectRef, 3);
@ -642,20 +656,14 @@ void OoxConverter::convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle*
void OoxConverter::convert(PPTX::Logic::UniFill *oox_fill, DWORD nARGB)
{
if (oox_fill == NULL) return;
PPTX::Logic::NoFill* noFill = &oox_fill->as<PPTX::Logic::NoFill>();
PPTX::Logic::BlipFill* blipFill = &oox_fill->as<PPTX::Logic::BlipFill>();
PPTX::Logic::GradFill* gradFill = &oox_fill->as<PPTX::Logic::GradFill>();
PPTX::Logic::SolidFill* solidFill = &oox_fill->as<PPTX::Logic::SolidFill>();
PPTX::Logic::PattFill* pattFill = &oox_fill->as<PPTX::Logic::PattFill>();
if (oox_fill == NULL) return;
if (solidFill) convert(solidFill, nARGB);
else if (blipFill) convert(blipFill);
else if (gradFill) convert(gradFill, nARGB);
else if (pattFill) convert(pattFill, nARGB);
else if (noFill) odf_context()->drawing_context()->set_no_fill();
if (oox_fill->is<PPTX::Logic::NoFill>()) odf_context()->drawing_context()->set_no_fill();
if (oox_fill->is<PPTX::Logic::BlipFill>()) convert(&oox_fill->as<PPTX::Logic::BlipFill>());
if (oox_fill->is<PPTX::Logic::GradFill>()) convert(&oox_fill->as<PPTX::Logic::GradFill>(), nARGB);
if (oox_fill->is<PPTX::Logic::SolidFill>()) convert(&oox_fill->as<PPTX::Logic::SolidFill>(),nARGB);
if (oox_fill->is<PPTX::Logic::PattFill>()) convert(&oox_fill->as<PPTX::Logic::PattFill>(), nARGB);
}
int OoxConverter::convert(PPTX::Logic::PrstTxWarp *oox_text_preset)
@ -783,8 +791,10 @@ void OoxConverter::convert(PPTX::Logic::Path2D *oox_geom_path)
for (size_t i = 0 ; i < oox_geom_path->Paths.size(); i++)
{
PPTX::Logic::PathBase* pathBase = &oox_geom_path->Paths[i].Path2D.as<PPTX::Logic::PathBase>();
convert(pathBase);
if (oox_geom_path->Paths[i].Path2D.is<PPTX::Logic::PathBase>())
{
convert(&oox_geom_path->Paths[i].Path2D.as<PPTX::Logic::PathBase>());
}
}
if (oox_geom_path->stroke.IsInit() && *oox_geom_path->stroke == false)
@ -1692,12 +1702,21 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
_CP_OPT(double) opacityText;
std::wstring hexColorText;
PPTX::Logic::GradFill* gradFill = &oox_run_pr->Fill.as<PPTX::Logic::GradFill>();
PPTX::Logic::GradFill* gradFill = NULL;
PPTX::Logic::SolidFill* solidFill = NULL;
if (oox_run_pr->Fill.is<PPTX::Logic::GradFill>())
{
gradFill = &oox_run_pr->Fill.as<PPTX::Logic::GradFill>();
}
if (gradFill && !gradFill->GsLst.empty())
{
convert(&gradFill->GsLst[0].color, hexColorText, opacityText);
}
PPTX::Logic::SolidFill* solidFill = &oox_run_pr->Fill.as<PPTX::Logic::SolidFill>();
if (oox_run_pr->Fill.is<PPTX::Logic::SolidFill>())
{
solidFill = &oox_run_pr->Fill.as<PPTX::Logic::SolidFill>();
}
if (solidFill)
{
convert(&solidFill->Color, hexColorText, opacityText);

View File

@ -61,6 +61,7 @@ private:
std::wstring m_strEmbeddedFontsDirectory;
std::wstring m_strFolderThemes;
bool m_bIsNoBase64;
extract_to_directory m_fCallbackExtract;
compress_from_directory m_fCallbackCompress;
@ -93,6 +94,7 @@ public:
HRESULT SetFontDir (std::wstring bsFontDir);
HRESULT SetThemesDir (std::wstring bsDir);
HRESULT SetUseSystemFonts (bool useSystemFonts);
void SetIsNoBase64 (bool bIsNoBase64);
HRESULT OpenFileToPPTY (std::wstring bsInput, std::wstring bsOutput);
HRESULT OpenDirectoryToPPTY (std::wstring bsInput, std::wstring bsOutput);
HRESULT ConvertPPTYToPPTX (std::wstring bsInput, std::wstring bsOutput, std::wstring bsThemesFolder);

View File

@ -67,6 +67,7 @@ CPPTXFile::CPPTXFile(extract_to_directory fCallbackExtract, compress_from_direct
m_strEmbeddedFontsDirectory = _T("");
m_strFolderThemes = _T("");
m_bIsNoBase64 = false;
//m_fCallbackResource = fCallbackResource;
m_fCallbackExtract = fCallbackExtract;
@ -232,6 +233,10 @@ HRESULT CPPTXFile::SetUseSystemFonts(bool val)
m_bIsUseSystemFonts = val;
return S_OK;
}
void CPPTXFile::SetIsNoBase64(bool bIsNoBase64)
{
m_bIsNoBase64 = bIsNoBase64;
}
HRESULT CPPTXFile::OpenFileToPPTY(std::wstring bsInput, std::wstring bsOutput)
{
if (m_strTempDir.empty())
@ -325,7 +330,7 @@ HRESULT CPPTXFile::OpenDirectoryToPPTY(std::wstring bsInput, std::wstring bsOutp
}
}
PPTX2EditorAdvanced::Convert(oBinaryWriter, *m_pFolder, m_strDirectory, pathDstFileOutput.GetPath());
PPTX2EditorAdvanced::Convert(oBinaryWriter, *m_pFolder, m_strDirectory, pathDstFileOutput.GetPath(), m_bIsNoBase64);
return S_OK;
}
@ -360,7 +365,7 @@ HRESULT CPPTXFile::ConvertPPTYToPPTX(std::wstring bsInput, std::wstring bsOutput
std::wstring strBsInput = bsInput;
std::wstring srcFolder = NSDirectory::GetFolderPath(strBsInput);
oWriter.OpenPPTY(pSrcBuffer, lFileSize, srcFolder, bsThemesFolder);
oWriter.OpenPPTY(pSrcBuffer, lFileSize, srcFolder, bsThemesFolder);
RELEASEARRAYOBJECTS(pSrcBuffer);
HRESULT hRes = S_OK;

View File

@ -42,6 +42,8 @@ namespace NSBinPptxRW
const BYTE g_nodeAttributeStart = 0xFA;
const BYTE g_nodeAttributeEnd = 0xFB;
const int g_nFormatVersionNoBase64 = 10;
namespace NSSerFormat
{
enum SerFormat

View File

@ -790,6 +790,17 @@ namespace NSBinPptxRW
{
_WriteString(sBuffer.c_str(), (_UINT32)sBuffer.length());
}
void CBinaryFileWriter::WriteStringUtf8(const std::wstring& sBuffer)
{
BYTE* pData = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sBuffer.c_str(), (LONG)sBuffer.length(), pData, lLen, false);
WriteBYTEArray(pData, lLen);
RELEASEARRAYOBJECTS(pData);
}
CBinaryFileWriter::CBinaryFileWriter()
{
m_pMainDocument = NULL;
@ -844,9 +855,9 @@ namespace NSBinPptxRW
m_lPosition += (_UINT32)lCount;
}
void CBinaryFileWriter::WriteMainPart()
void CBinaryFileWriter::WriteMainPart(_UINT32 nStartPos)
{
BYTE* pData = m_pStreamData;
BYTE* pData = m_pStreamData + nStartPos;
size_t nCount = m_arMainTables.size();
for (size_t i = 0; i < nCount; i++)

View File

@ -292,6 +292,7 @@ namespace NSBinPptxRW
void WriteStringW3 (const std::wstring& sBuffer);
void WriteStringW4 (const std::wstring& sBuffer);
void WriteStringUtf8(const std::wstring& sBuffer);
// --------------------------------------------------------
void WriteLONG64 (const _INT64& lValue);
void WriteDouble64 (const double& dValue);
@ -306,7 +307,7 @@ namespace NSBinPptxRW
void StartMainRecord(_INT32 lType);
void WriteReserved(size_t lCount);
void WriteMainPart();
void WriteMainPart(_UINT32 nStartPos);
void WriteString1 (int type, const std::wstring& val);
void WriteString2 (int type, const NSCommon::nullable_string& val);

View File

@ -38,7 +38,7 @@ namespace PPTX2EditorAdvanced
{
using namespace NSBinPptxRW;
DWORD Convert(NSBinPptxRW::CBinaryFileWriter& oBinaryWriter, PPTX::Folder& oFolder, const std::wstring& strSourceDirectory, const std::wstring& strDstFile)
DWORD Convert(NSBinPptxRW::CBinaryFileWriter& oBinaryWriter, PPTX::Folder& oFolder, const std::wstring& strSourceDirectory, const std::wstring& strDstFile, bool bIsNoBase64)
{
// сначала соберем все объекты для конвертации и сформируем main-таблицы
NSBinPptxRW::CCommonWriter* pCommon = oBinaryWriter.m_pCommon;
@ -230,6 +230,12 @@ namespace PPTX2EditorAdvanced
oBinaryWriter.m_pCommon->m_oNote_Rels.push_back(nMasterIndex);
}
if (bIsNoBase64)
{
std::wstring strPrefix = L"PPTY;v"+std::to_wstring(g_nFormatVersionNoBase64)+L";0;";
oBinaryWriter.WriteStringUtf8(strPrefix);
}
_UINT32 nStartPos = oBinaryWriter.GetPosition();
// нужно записать все в maintables. А кроме главных таблиц ничего и нету. Все остальное лежит в них
// на каждую таблицу - 5 байт (тип и сдвиг)
// число таблиц - заранее известно (сделаем 30. если потом не будет хватать - новая версия формата)
@ -516,29 +522,35 @@ namespace PPTX2EditorAdvanced
// ------------------------------------------------
oBinaryWriter.WriteEmbeddedFonts();
oBinaryWriter.WriteMainPart();
oBinaryWriter.WriteMainPart(nStartPos);
// все записалось нормально. осталось скинуть на диск
BYTE* pbBinBuffer = oBinaryWriter.GetBuffer();
int nBinBufferLen = (int)oBinaryWriter.GetPosition();
int nBase64BufferLen = Base64::Base64EncodeGetRequiredLength(nBinBufferLen, Base64::B64_BASE64_FLAG_NOCRLF);
BYTE* pbBase64Buffer = new BYTE[nBase64BufferLen+64];
// if (true == Base64::Base64Encode(pbBinBuffer, nBinBufferLen, (LPSTR)pbBase64Buffer, &nBase64BufferLen, Base64::B64_BASE64_FLAG_NOCRLF))
if (true == Base64_1::Base64Encode(pbBinBuffer, nBinBufferLen, pbBase64Buffer, &nBase64BufferLen))
{
CFile oFile;
#if defined(_WIN32) || defined (_WIN64)
oFile.CreateFileW(strDstFile);
#else
oFile.CreateFile(strDstFile);
#endif
std::string strPrefix = "PPTY;v1;" + std::to_string(nBinBufferLen) + ";";
oFile.WriteFile((void*)strPrefix.c_str(), (DWORD)strPrefix.length());
oFile.WriteFile(pbBase64Buffer, nBase64BufferLen);
if (bIsNoBase64)
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(strDstFile);
oFile.WriteFile(pbBinBuffer, nBinBufferLen);
oFile.CloseFile();
}
else
{
int nBase64BufferLen = Base64::Base64EncodeGetRequiredLength(nBinBufferLen, Base64::B64_BASE64_FLAG_NOCRLF);
BYTE* pbBase64Buffer = new BYTE[nBase64BufferLen+64];
// if (true == Base64::Base64Encode(pbBinBuffer, nBinBufferLen, (LPSTR)pbBase64Buffer, &nBase64BufferLen, Base64::B64_BASE64_FLAG_NOCRLF))
if (true == Base64_1::Base64Encode(pbBinBuffer, nBinBufferLen, pbBase64Buffer, &nBase64BufferLen))
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(strDstFile);
std::wstring strPrefix = L"PPTY;v1;" + std::to_wstring(nBinBufferLen) + L";";
oFile.WriteStringUTF8(strPrefix);
oFile.WriteFile(pbBase64Buffer, nBase64BufferLen);
oFile.CloseFile();
}
RELEASEARRAYOBJECTS(pbBase64Buffer);
RELEASEARRAYOBJECTS(pbBase64Buffer);
}
return 0;
}
}

View File

@ -118,7 +118,7 @@ namespace NSBinPptxRW
m_oReader.m_strFolderThemes = pathTheme.GetPath();
}
void OpenPPTY(BYTE* pBuffer, int len, std::wstring srcFolder, std::wstring strThemesFolder)
void OpenPPTY(BYTE* pBuffer, int len, std::wstring srcFolder, std::wstring strThemesFolder)
{
int start_pos = 0;
@ -158,11 +158,30 @@ namespace NSBinPptxRW
int dstLenTemp = XmlUtils::GetInteger(__str_decode_len);
//int dstLenTemp = Base64DecodeGetRequiredLength(len);
BYTE* pDstBuffer = new BYTE[dstLenTemp];
int dstLen = dstLenTemp;
Base64::Base64Decode((const char*)pBuffer, len, pDstBuffer, &dstLen);
int nVersion = 1;
if(__str_version.length() > 1)
{
nVersion = std::stoi(__str_version.substr(1).c_str());
}
bool bIsNoBase64 = nVersion == g_nFormatVersionNoBase64;
BYTE* pDstBuffer = NULL;
int dstLen = 0;
if(!bIsNoBase64)
{
BYTE* pDstBuffer = new BYTE[dstLenTemp];
int dstLen = dstLenTemp;
Base64::Base64Decode((const char*)pBuffer, len, pDstBuffer, &dstLen);
m_oReader.Init(pDstBuffer, 0, dstLen);
}
else
{
pDstBuffer = pBuffer - start_pos;
dstLen = len + start_pos;
m_oReader.Init(pDstBuffer, 0, dstLen);
m_oReader.Seek(start_pos);
}
m_oReader.Init(pDstBuffer, 0, dstLen);
m_oReader.m_strFolder = srcFolder;
m_oReader.m_strFolderExternalThemes = strThemesFolder;
@ -813,8 +832,10 @@ namespace NSBinPptxRW
bIsAuthors = true;
}
}
RELEASEARRAYOBJECTS(pDstBuffer);
if(!bIsNoBase64)
{
RELEASEARRAYOBJECTS(pDstBuffer);
}
// content types
OOX::CContentTypes *pContentTypes = m_oImageManager.m_pContentTypes;

View File

@ -0,0 +1,247 @@
/*
* (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 "../Logic/XmlId.h"
namespace PPTX
{
namespace Logic
{
class Section : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(Section)
nullable_string id;
nullable_string name;
std::vector<Logic::XmlId> arSldIdLst;
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"id", id);
node.ReadAttributeBase(L"name", name);
XmlUtils::CXmlNode oNodeSldIdLst;
if (node.GetNode(L"p14:sldIdLst", oNodeSldIdLst))
{
oNodeSldIdLst.LoadArray(L"p14:sldId", arSldIdLst);
}
}
virtual std::wstring toXML() const
{
return L"";
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(L"p14:section");
pWriter->StartAttributes();
pWriter->WriteAttribute2(L"name", name);
pWriter->WriteAttribute(L"id", id);
pWriter->EndAttributes();
pWriter->StartNode(L"p14:sldIdLst");
pWriter->WriteArray2(arSldIdLst);
pWriter->EndNode(L"p14:sldIdLst");
pWriter->EndNode(L"p14:section");
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteString2(0, id);
pWriter->WriteString2(1, name);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
pWriter->WriteRecordArray(0, 0, arSldIdLst);
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1); // start attributes
while (true)
{
BYTE _at = pReader->GetUChar_TypeNode();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
switch (_at)
{
case 0:
id = pReader->GetString2();
break;
case 1:
name = pReader->GetString2();
break;
default:
break;
}
}
while (pReader->GetPos() < _end_rec)
{
BYTE _rec = pReader->GetUChar();
switch (_rec)
{
case 0:
{
pReader->Skip(4); // len
ULONG lCount = pReader->GetULong();
for (ULONG i = 0; i < lCount; ++i)
{
pReader->Skip(1);
Logic::XmlId sldId(L"p14:sldId");
arSldIdLst.push_back(sldId);
arSldIdLst.back().fromPPTY(pReader);
}
break;
}
default:
{
pReader->SkipRecord();
break;
}
}
}
pReader->Seek(_end_rec);
}
virtual void FillParentPointersForChilds()
{
}
};
}
namespace nsPresentation
{
class SectionLst : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(SectionLst)
virtual void fromXML(XmlUtils::CXmlNode& node)
{
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
Logic::Section sect;
arSectionLst.push_back(sect);
arSectionLst.back().fromXML(oNode);
}
}
}
virtual std::wstring toXML() const
{
return L"";
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG end = pReader->GetPos() + pReader->GetLong() + 4;
while (pReader->GetPos() < end)
{
BYTE _rec = pReader->GetUChar();
switch (_rec)
{
case 0:
{
pReader->Skip(4); // len
ULONG lCount = pReader->GetULong();
for (ULONG i = 0; i < lCount; ++i)
{
pReader->Skip(1);
Logic::Section sect;
arSectionLst.push_back(sect);
arSectionLst.back().fromPPTY(pReader);
}
break;
}
default:
{
pReader->SkipRecord();
break;
}
}
}
pReader->Seek(end);
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteRecordArray(0, 0, arSectionLst);
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(L"p14:sectionLst");
pWriter->StartAttributes();
pWriter->WriteAttribute(L"xmlns:p14", PPTX::g_Namespaces.p14.m_strLink);
pWriter->EndAttributes();
pWriter->WriteArray2(arSectionLst);
pWriter->EndNode(L"p14:sectionLst");
}
std::vector<Logic::Section> arSectionLst;
protected:
virtual void FillParentPointersForChilds(){};
};
}
} // namespace PPTX

View File

@ -47,24 +47,21 @@
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 3) return 0;
if (argc < 2) return 0;
std::wstring sXMLOptions = _T("<Options><TXTOptions><Encoding>1000</Encoding></TXTOptions></Options>");
std::wstring sXMLOptions = _T("<Options><TXTOptions><Encoding>50</Encoding></TXTOptions></Options>");
std::wstring srcFileName = argv[1];
std::wstring dstFileName = argv[2];
std::wstring outputDir = NSDirectory::GetFolderPath(dstFileName);
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
int n1 = srcFileName.rfind(L".");
int n2 = dstFileName.rfind(L".");
std::wstring ext_1 = n1>=0 ? srcFileName.substr(n1+1, srcFileName.length() - n1): L""; //ext_1.MakeLower();
std::wstring ext_2 = n2>=0 ? dstFileName.substr(n2+1, dstFileName.length() - n2): L""; //ext_2.MakeLower();
int n1 = srcFileName.rfind(_T('.'));
std::wstring ext_1 = n1 >= 0 ? srcFileName.substr(n1+1, srcFileName.length() - n1) : _T("");
std::transform(ext_1.begin(), ext_1.end(), ext_1.begin(), ::tolower);
std::wstring dstFileName = argc > 2 ? argv[2] : srcFileName + L"_my." + (ext_1 == L"txt" ? L"docx" : L"txt");
std::wstring outputDir = NSDirectory::GetFolderPath(dstFileName);
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
CTxtXmlFile txtFile;
COfficeUtils oCOfficeUtils(NULL);
@ -77,7 +74,7 @@ int _tmain(int argc, _TCHAR* argv[])
if (S_OK != oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstFileName.c_str(), -1))
return S_FALSE;
}
if (ext_2 == L"txt")
else
{
// docx->txt
if (S_OK != oCOfficeUtils.ExtractToDirectory(srcFileName.c_str(), dstTempPath.c_str(), NULL, 0))

View File

@ -85,7 +85,7 @@ namespace Docx2Txt
OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles *pStyles);
size_t NoteCount;
std::list<std::wstring> Notes;
std::map<std::wstring, std::list<std::wstring>> Notes;
static std::wstring IntToLowerLetter (int number);
static std::wstring IntToUpperLetter (int number);
@ -198,10 +198,20 @@ namespace Docx2Txt
if(NoteCount != 0)
{
m_outputFile.m_listContent.push_back(_T("---------------------------"));
for(std::list<std::wstring>::const_iterator iter = Notes.begin(); iter != Notes.end(); iter++)
m_outputFile.m_listContent.push_back(L"");
m_outputFile.m_listContent.push_back(L"---------------------------");
for(std::map<std::wstring, std::list<std::wstring>>::const_iterator iter_map = Notes.begin(); iter_map != Notes.end(); iter_map++)
{
m_outputFile.m_listContent.push_back(*iter);
bool bFirst = true;
for(std::list<std::wstring>::const_iterator iter = iter_map->second.begin(); iter != iter_map->second.end(); iter++)
{
if (bFirst) m_outputFile.m_listContent.push_back(iter_map->first + L" " + *iter);
else m_outputFile.m_listContent.push_back(*iter);
bFirst = false;
}
}
}
}
@ -491,31 +501,52 @@ namespace Docx2Txt
if (run->m_arrItems[j]->getType() == OOX::et_w_footnoteReference || run->m_arrItems[j]->getType() == OOX::et_w_endnoteReference)
{// todooo Ref ????
std::list<std::wstring> notes_content;
OOX::Logic::CFootnoteReference* footnote_ref = dynamic_cast<OOX::Logic::CFootnoteReference*>(run->m_arrItems[j]);
OOX::Logic::CEndnoteReference* endnote_ref = dynamic_cast<OOX::Logic::CEndnoteReference*>(run->m_arrItems[j]);
NoteCount++;
std::wstring s = _T("[") + ToWString(NoteCount) + _T("]");
Notes.push_back(s);
if(run->m_arrItems[j]->getType() == OOX::et_w_footnoteReference)
if (footnote_ref)
{
smart_ptr<OOX::File> pFile = pDocument->Find(OOX::FileTypes::FootNote);
if (pFile.IsInit())
{
OOX::CFootnotes *pFootnotes = (OOX::CFootnotes*)pFile.operator->();
for (long r =0 ;r < pFootnotes->m_arrFootnote.size(); r++)
convert(pFootnotes->m_arrFootnote[r]->m_arrItems, Notes, Event, false, pDocument, pNumbering, pStyles);
for (size_t r = 0; r < pFootnotes->m_arrFootnote.size(); r++)
{
OOX::CFtnEdn* note = dynamic_cast<OOX::CFtnEdn*>(pFootnotes->m_arrFootnote[r]);
if (note && note->m_oId == footnote_ref->m_oId)
{
convert(pFootnotes->m_arrFootnote[r]->m_arrItems, notes_content, Event, false, pDocument, pNumbering, pStyles);
}
}
}
Notes.insert(std::make_pair(ToWString(NoteCount), notes_content));
}
else if(run->m_arrItems[j]->getType() == OOX::et_w_endnoteReference)
if (endnote_ref)
{
smart_ptr<OOX::File> pFile = pDocument->Find(OOX::FileTypes::EndNote);
if (pFile.IsInit())
{
OOX::CEndnotes *pEndnotes = (OOX::CEndnotes*)pFile.operator->();
for (long r =0 ;r < pEndnotes->m_arrEndnote.size(); r++)
convert(pEndnotes->m_arrEndnote[r]->m_arrItems, Notes, Event, false, pDocument, pNumbering, pStyles);
for (size_t r =0; r < pEndnotes->m_arrEndnote.size(); r++)
{
OOX::CFtnEdn* note = dynamic_cast<OOX::CFtnEdn*>(pEndnotes->m_arrEndnote[r]);
if (note && note->m_oId == endnote_ref->m_oId)
{
convert(pEndnotes->m_arrEndnote[r]->m_arrItems, notes_content, Event, false, pDocument, pNumbering, pStyles);
}
}
}
Notes.insert(std::make_pair(ToWString(NoteCount), notes_content));
}
wstr.replace(wstr.find(_T("_")), 1 , ToWString(NoteCount));
wstr += L"[" + ToWString(NoteCount) + L"]"; ;
}
line += wstr;
}

View File

@ -104,13 +104,6 @@ static int ParseTxtOptions(const std::wstring & sXmlOptions)
HRESULT CTxtXmlFile::txt_LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstPath, const std::wstring & sXMLOptions)
{
//проверка на структуру xml - если что не так выкинет быстро
//HRESULT hr = xml_LoadFromFile(sSrcFileName, sDstPath, sXMLOptions);
//if(hr == S_OK)
// return S_OK;
//As Text
Writers::FileWriter *pDocxWriter = new Writers::FileWriter(sDstPath, L"", true, 1, false, NULL, L"");
if (pDocxWriter == NULL) return S_FALSE;

View File

@ -2377,6 +2377,38 @@ namespace NSEditorApi
pEvent->Release();
}
};
class CAscCefMenuEvent : public CAscMenuEvent
{
public:
int m_nSenderId;
public:
CAscCefMenuEvent(int nType = -1) : CAscMenuEvent(nType)
{
m_nSenderId = -1;
}
virtual ~CAscCefMenuEvent()
{
}
LINK_PROPERTY_INT(SenderId)
};
class CAscCefMenuEventListener
{
public:
// memory release!!!
virtual void OnEvent(CAscCefMenuEvent* pEvent)
{
if (NULL != pEvent)
pEvent->Release();
}
virtual bool IsSupportEvent(int nEventType)
{
return true;
}
};
}
namespace NSEditorApi

View File

@ -1,4 +1,6 @@
hunspell_build_static {
DEFINES += HUNSPELL_STATIC
}
building_hunspell {
DEFINES += BUILDING_LIBHUNSPELL

View File

@ -9,7 +9,17 @@ QT -= core gui
TARGET = hunspell
TEMPLATE = lib
hunspell_build_static {
CONFIG += staticlib
} else {
CONFIG += shared
CONFIG += plugin
}
CONFIG += building_hunspell
CORE_ROOT_DIR = $$PWD/../../../..

View File

@ -61,6 +61,7 @@ ASCDOCUMENTSCORE := $(LIBDIR)/$(LIB_PREFIX)ascdocumentscore$(SHARED_EXT)
LIBXML := $(LIBDIR)/$(LIB_PREFIX)libxml$(LIB_EXT)
LICENSEMANAGER := $(LIBDIR)/$(LIB_PREFIX)LicenceManager$(LIB_EXT)
OOXMLSIGNATURE := $(LIBDIR)/$(LIB_PREFIX)ooxmlsignature$(LIB_EXT)
HUNSPELL := $(LIBDIR)/$(LIB_PREFIX)hunspell$(SHARED_EXT)
TARGETS += $(ALLFONTSGEN)
TARGETS += $(X2T)
@ -89,6 +90,7 @@ TARGETS += $(ASCDOCUMENTSCORE)
TARGETS += $(LIBXML)
TARGETS += $(LICENSEMANAGER)
TARGETS += $(OOXMLSIGNATURE)
TARGETS += $(HUNSPELL)
X2T_PRO := $(abspath X2tConverter/build/Qt/X2tSLN.pro)
HTMLFILEINTERNAL_PRO := $(abspath ../desktop-sdk/HtmlFile/Internal/Internal.pro)
@ -117,6 +119,7 @@ ASCDOCUMENTSCORE_PRO := $(abspath ../desktop-sdk/ChromiumBasedEditors/lib/AscDoc
LIBXML_PRO := $(abspath DesktopEditor/xml/build/qt/libxml2.pro)
LICENSEMANAGER_PRO := $(abspath LicenceManager/linux/LicenseManager.pro)
OOXMLSIGNATURE_PRO := $(abspath DesktopEditor/xmlsec/src/ooxmlsignature.pro)
HUNSPELL_PRO := $(abspath DesktopEditor/hunspell-1.3.3/src/qt/hunspell.pro)
# PROS += $(basename $(X2T_PRO)).build
# PROS += ALLFONTSGEN_PRO
@ -168,6 +171,7 @@ QT_PROJ += ASCDOCUMENTSCORE
QT_PROJ += LIBXML
QT_PROJ += LICENSEMANAGER
QT_PROJ += OOXMLSIGNATURE
QT_PROJ += HUNSPELL
# X2T_DEP += $(XLSFORMATLIB)
# X2T_DEP += $(ODFFILEWRITERLIB)
@ -217,6 +221,7 @@ ASCDOCUMENTSCORE_DEP += $(XPSFILE)
#ASCDOCUMENTSCORE_DEP += $(LICENSEMANAGER)
ASCDOCUMENTSCORE_DEP += $(LIBXML)
ASCDOCUMENTSCORE_DEP += $(OOXMLSIGNATURE)
ASCDOCUMENTSCORE_DEP += $(HUNSPELL)
OOXMLSIGNATURE_DEP += $(LIBXML)

View File

@ -128,6 +128,7 @@ namespace NExtractTools
// Save to file (from temp dir)
BinDocxRW::CDocxSerializer m_oCDocxSerializer;
m_oCDocxSerializer.setIsNoBase64(params.getIsNoBase64());
m_oCDocxSerializer.setFontDir(params.getFontPath());
//bool bRes = m_oCDocxSerializer.saveToFile (sResDoct, sSrcDocx, sTemp);
@ -188,7 +189,8 @@ namespace NExtractTools
BinDocxRW::CDocxSerializer m_oCDocxSerializer;
m_oCDocxSerializer.setFontDir(params.getFontPath());
m_oCDocxSerializer.setIsNoBase64(params.getIsNoBase64());
m_oCDocxSerializer.setFontDir(params.getFontPath());
std::wstring sXmlOptions = _T("");
std::wstring sThemePath; // will be filled by 'CreateDocxFolders' method
@ -255,6 +257,7 @@ namespace NExtractTools
// Save to file (from temp dir)
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
m_oCXlsxSerializer.setIsNoBase64(params.getIsNoBase64());
m_oCXlsxSerializer.setFontDir(params.getFontPath());
return m_oCXlsxSerializer.saveToFile (sTo, sXlsxDir, bXmlOptions ? params.getXmlOptions() : L"") ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
@ -309,7 +312,8 @@ namespace NExtractTools
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
m_oCXlsxSerializer.setFontDir(params.getFontPath());
m_oCXlsxSerializer.setIsNoBase64(params.getIsNoBase64());
m_oCXlsxSerializer.setFontDir(params.getFontPath());
std::wstring sXmlOptions = _T("");
std::wstring sMediaPath; // will be filled by 'CreateXlsxFolders' method
@ -377,6 +381,7 @@ namespace NExtractTools
if (pptx_file)
{
pptx_file->SetIsNoBase64(params.getIsNoBase64());
pptx_file->put_TempDirectory(sTemp);
pptx_file->SetFontDir (params.getFontPath());
nRes = (S_OK == pptx_file->OpenFileToPPTY (sFrom, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
@ -438,6 +443,7 @@ namespace NExtractTools
if (pptx_file)
{
pptx_file->SetIsNoBase64(params.getIsNoBase64());
pptx_file->SetFontDir(params.getFontPath());
nRes = (S_OK == pptx_file->ConvertPPTYToPPTX(sTargetBin, sTo, sThemeDir)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
@ -492,7 +498,8 @@ namespace NExtractTools
// Save to file (from temp dir)
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
m_oCXlsxSerializer.setFontDir(params.getFontPath());
m_oCXlsxSerializer.setIsNoBase64(params.getIsNoBase64());
m_oCXlsxSerializer.setFontDir(params.getFontPath());
int nRes = m_oCXlsxSerializer.saveToFile (sResultXlstFileEditor, sCSV, params.getXmlOptions()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
if (SUCCEEDED_X2T(nRes))
@ -517,6 +524,7 @@ namespace NExtractTools
// Save to file (from temp dir)
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
m_oCXlsxSerializer.setIsNoBase64(params.getIsNoBase64());
m_oCXlsxSerializer.setFontDir(params.getFontPath());
COfficeUtils oCOfficeUtils(NULL);
@ -541,6 +549,7 @@ namespace NExtractTools
// Save to file (from temp dir)
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
m_oCXlsxSerializer.setIsNoBase64(params.getIsNoBase64());
m_oCXlsxSerializer.setFontDir(params.getFontPath());
return m_oCXlsxSerializer.saveToFile(sTo, sFrom, params.getXmlOptions()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
@ -562,6 +571,7 @@ namespace NExtractTools
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
m_oCXlsxSerializer.setIsNoBase64(params.getIsNoBase64());
m_oCXlsxSerializer.setFontDir(params.getFontPath());
std::wstring sMediaPath;
@ -587,6 +597,7 @@ namespace NExtractTools
// Save to file (from temp dir)
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
m_oCXlsxSerializer.setIsNoBase64(params.getIsNoBase64());
m_oCXlsxSerializer.setFontDir(params.getFontPath());
std::wstring sXMLOptions = _T("");
@ -617,6 +628,7 @@ namespace NExtractTools
// Save to file (from temp dir)
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
m_oCXlsxSerializer.setIsNoBase64(params.getIsNoBase64());
m_oCXlsxSerializer.setFontDir(params.getFontPath());
std::wstring sToTemp = sTemp + FILE_SEPARATOR_STR + _T("output.csv");
@ -645,7 +657,14 @@ namespace NExtractTools
pdfWriter.SetTempFolder(sTemp);
pdfWriter.SetThemesPlace(sThemeDir);
int nReg = (bPaid == false) ? 0 : 1;
return S_OK == pdfWriter.OnlineWordToPdf(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
if (params.getIsNoBase64())
{
return S_OK == pdfWriter.OnlineWordToPdfFromBinary(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
else
{
return S_OK == pdfWriter.OnlineWordToPdf(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
}
int bin2image (const std::wstring &sTFileDir, BYTE* pBuffer, LONG lBufferLen, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams& params)
{
@ -1713,8 +1732,8 @@ namespace NExtractTools
std::wstring sTempDocx = sTemp + FILE_SEPARATOR_STR + wsFilePathInFilename + L"_DOCX";
NSDirectory::CreateDirectory(sTempDocx);
BinDocxRW::CDocxSerializer m_oCDocxSerializer;
BinDocxRW::CDocxSerializer m_oCDocxSerializer;
m_oCDocxSerializer.setIsNoBase64(params.getIsNoBase64());
m_oCDocxSerializer.setFontDir(params.getFontPath());
std::wstring sXmlOptions;

View File

@ -358,6 +358,7 @@ namespace NExtractTools
std::wstring* m_sHtmlFileInternalPath;
std::wstring* m_sPassword;
std::wstring* m_sTempDir;
bool* m_bIsNoBase64;
//output params
mutable bool m_bOutputConvertCorrupted;
public:
@ -383,6 +384,7 @@ namespace NExtractTools
m_sHtmlFileInternalPath = NULL;
m_sPassword = NULL;
m_sTempDir = NULL;
m_bIsNoBase64 = NULL;
m_bOutputConvertCorrupted = false;
}
@ -408,6 +410,7 @@ namespace NExtractTools
RELEASEOBJECT(m_sHtmlFileInternalPath);
RELEASEOBJECT(m_sPassword);
RELEASEOBJECT(m_sTempDir);
RELEASEOBJECT(m_bIsNoBase64);
}
bool FromXmlFile(const std::wstring& sFilename)
@ -496,6 +499,8 @@ namespace NExtractTools
m_sPassword = new std::wstring(sValue);
else if(_T("m_sTempDir") == sName)
m_sTempDir = new std::wstring(sValue);
else if(_T("m_bIsNoBase64") == sName)
m_bIsNoBase64 = new bool(XmlUtils::GetBoolean2(sValue));
}
else if(_T("m_nCsvDelimiterChar") == sName)
{
@ -523,6 +528,10 @@ namespace NExtractTools
{
return (NULL != m_sFontDir) ? (*m_sFontDir) : L"";
}
bool getIsNoBase64() const
{
return (NULL != m_bIsNoBase64) ? (*m_bIsNoBase64) : false;
}
std::wstring getXmlOptions()
{
std::wstring sRes;

View File

@ -41,6 +41,7 @@ namespace BinXlsxRW
const static wchar_t* g_sFormatSignature = L"XLSY";
const int g_nFormatVersion = 2;
const int g_nFormatVersionNoBase64 = 10;
extern int g_nCurFormatVersion;
namespace c_oFileTypes{enum c_oFileTypes

View File

@ -4244,7 +4244,7 @@ namespace BinXlsxRW
RELEASEOBJECT(m_oBcw);
}
void Open(const std::wstring& sInputDir, const std::wstring& sFileDst, NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager,
NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, const std::wstring& sXMLOptions)
NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, const std::wstring& sXMLOptions, bool bIsNoBase64)
{
OOX::CPath path(sFileDst);
//создаем папку для media
@ -4286,21 +4286,35 @@ namespace BinXlsxRW
}
else
{
if (bIsNoBase64)
{
oBufferedStream.WriteStringUtf8(WriteFileHeader(0, g_nFormatVersionNoBase64));
}
intoBindoc(*pXlsx, oBufferedStream, pEmbeddedFontsManager, pOfficeDrawingConverter);
BYTE* pbBinBuffer = oBufferedStream.GetBuffer();
int nBinBufferLen = oBufferedStream.GetPosition();
int nBase64BufferLen = Base64::Base64EncodeGetRequiredLength(nBinBufferLen, Base64::B64_BASE64_FLAG_NOCRLF);
BYTE* pbBase64Buffer = new BYTE[nBase64BufferLen+64];
if(true == Base64_1::Base64Encode(pbBinBuffer, nBinBufferLen, pbBase64Buffer, &nBase64BufferLen))
if (bIsNoBase64)
{
CFile oFile;
oFile.CreateFile(sFileDst);
oFile.WriteStringUTF8(WriteFileHeader(nBinBufferLen));
oFile.WriteFile(pbBase64Buffer, nBase64BufferLen);
NSFile::CFileBinary oFile;
oFile.CreateFileW(sFileDst);
oFile.WriteFile(pbBinBuffer, nBinBufferLen);
oFile.CloseFile();
}
RELEASEARRAYOBJECTS(pbBase64Buffer);
else
{
int nBase64BufferLen = Base64::Base64EncodeGetRequiredLength(nBinBufferLen, Base64::B64_BASE64_FLAG_NOCRLF);
BYTE* pbBase64Buffer = new BYTE[nBase64BufferLen+64];
if(true == Base64_1::Base64Encode(pbBinBuffer, nBinBufferLen, pbBase64Buffer, &nBase64BufferLen))
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(sFileDst);
oFile.WriteStringUTF8(WriteFileHeader(nBinBufferLen, g_nFormatVersion));
oFile.WriteFile(pbBase64Buffer, nBase64BufferLen);
oFile.CloseFile();
}
RELEASEARRAYOBJECTS(pbBase64Buffer);
}
}
RELEASEOBJECT(pXlsx);
@ -4368,9 +4382,9 @@ namespace BinXlsxRW
WriteMainTableEnd();
}
private:
std::wstring WriteFileHeader(int nDataSize)
std::wstring WriteFileHeader(int nDataSize, int version)
{
std::wstring sHeader = std::wstring(g_sFormatSignature) + L";v" + std::to_wstring(g_nFormatVersion)+ L";" + std::to_wstring(nDataSize) + L";";
std::wstring sHeader = std::wstring(g_sFormatSignature) + L";v" + std::to_wstring(version)+ L";" + std::to_wstring(nDataSize) + L";";
return sHeader;
}
void WriteMainTableStart()

View File

@ -4262,25 +4262,41 @@ namespace BinXlsxRW {
else
dst_len += _c;
}
int nDataSize = atoi(dst_len.c_str());
BYTE* pData = new BYTE[nDataSize];
if(false != Base64::Base64Decode((const char*)(pBase64Data + nIndex), nBase64DataSize - nIndex, pData, &nDataSize))
int nVersion = g_nFormatVersion;
if(!version.empty())
{
NSBinPptxRW::CBinaryFileReader& oBufferedStream = *pOfficeDrawingConverter->m_pReader;
oBufferedStream.Init(pData, 0, nDataSize);
version = version.substr(1);
g_nCurFormatVersion = nVersion = std::stoi(version.c_str());
}
bool bIsNoBase64 = nVersion == g_nFormatVersionNoBase64;
int nVersion = g_nFormatVersion;
if(version.length() > 0)
NSBinPptxRW::CBinaryFileReader& oBufferedStream = *pOfficeDrawingConverter->m_pReader;
int nDataSize = 0;
BYTE* pData = NULL;
if (!bIsNoBase64)
{
nDataSize = atoi(dst_len.c_str());
pData = new BYTE[nDataSize];
if(Base64::Base64Decode((const char*)(pBase64Data + nIndex), nBase64DataSize - nIndex, pData, &nDataSize))
{
version = version.substr(1);
int nTempVersion = atoi(version.c_str());
if(0 != nTempVersion)
{
g_nCurFormatVersion = nVersion = nTempVersion;
}
oBufferedStream.Init(pData, 0, nDataSize);
}
else
{
RELEASEARRAYOBJECTS(pData);
}
}
else
{
nDataSize = nBase64DataSize;
pData = pBase64Data;
oBufferedStream.Init(pData, 0, nDataSize);
oBufferedStream.Seek(nIndex);
}
if(NULL != pData)
{
// File Type
std::wstring sDstPathCSV = sDstPath;
BYTE fileType;
@ -4321,7 +4337,13 @@ namespace BinXlsxRW {
}
bResultOk = true;
}
if (!bIsNoBase64)
{
RELEASEARRAYOBJECTS(pData);
}
}
RELEASEARRAYOBJECTS(pBase64Data);
}
return S_OK;
}