Compare commits

..

6 Commits

26 changed files with 327 additions and 136 deletions

View File

@ -1583,6 +1583,7 @@ public:
std::wstring UserName;
std::wstring UserId;
std::wstring Date;
std::wstring OOData;
bool Solved;
std::wstring Text;
std::wstring m_sParaId;
@ -1706,9 +1707,16 @@ public:
{
std::wstring sDate = XmlUtils::EncodeXmlString(pComment->Date);
sRes += L" w:date=\"";
sRes += sDate;
sRes += sDate;
sRes += L"\"";
}
if(false == pComment->OOData.empty())
{
std::wstring sData = XmlUtils::EncodeXmlString(pComment->OOData);
sRes += L" oodata=\"";
sRes += sData;
sRes += L"\"";
}
if(false == sInitials.empty())
{
sInitials = XmlUtils::EncodeXmlString(sInitials);

View File

@ -3039,6 +3039,11 @@ public:
std::wstring Date(m_oBufferedStream.GetString3(length));
pComment->Date = Date;
}
else if ( c_oSer_CommentsType::OOData == type )
{
std::wstring Data(m_oBufferedStream.GetString3(length));
pComment->OOData = Data;
}
else if ( c_oSer_CommentsType::Text == type )
{
std::wstring Text(m_oBufferedStream.GetString3(length));

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
{
@ -715,7 +716,8 @@ extern int g_nCurFormatVersion;
Text = 6,
QuoteText = 7,
Solved = 8,
Replies = 9
Replies = 9,
OOData = 10
};}
namespace c_oSer_SettingsType{enum c_oSer_SettingsType
{

View File

@ -7222,6 +7222,11 @@ namespace BinDocxRW
m_oBcw.m_oStream.WriteBYTE(c_oSer_CommentsType::Date);
m_oBcw.m_oStream.WriteStringW(pComment->m_oDate->ToString());
}
if(pComment->m_oOOData.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_CommentsType::OOData);
m_oBcw.m_oStream.WriteStringW(pComment->m_oOOData.get2());
}
if(pComment->m_oId.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_CommentsType::Id);
@ -7714,9 +7719,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

@ -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

@ -275,6 +275,7 @@ namespace OOX
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("w:author"), m_oAuthor )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("w:date"), m_oDate )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("oodata"), m_oOOData )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("w:id"), m_oId )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("w:initials"), m_oInitials )
WritingElement_ReadAttributes_End( oReader )
@ -289,6 +290,9 @@ namespace OOX
nullable<SimpleTypes::CDecimalNumber<> > m_oId;
nullable<std::wstring > m_oInitials;
//teamlab editor information!!!
nullable<std::wstring > m_oOOData;
// Childs
};

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
@ -655,7 +656,8 @@ namespace BinXlsxRW
Solved = 5,
Document = 6,
Replies = 7,
Reply = 8
Reply = 8,
OOTime = 9
};}
namespace c_oSer_ConditionalFormatting{enum c_oSer_ConditionalFormatting
{

View File

@ -51,6 +51,7 @@ namespace SerializeCommon
public :
std::wstring sText;
std::wstring sTime;
std::wstring sOOTime;
std::wstring sUserId;
std::wstring sUserName;
std::wstring sQuoteText;

View File

@ -3481,6 +3481,11 @@ namespace BinXlsxRW
m_oBcw.m_oStream.WriteBYTE(c_oSer_CommentData::Time);
m_oBcw.m_oStream.WriteStringW(pCommentData->sTime);
}
if(!pCommentData->sOOTime.empty())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_CommentData::OOTime);
m_oBcw.m_oStream.WriteStringW(pCommentData->sOOTime);
}
if (!pCommentData->sUserId.empty())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_CommentData::UserId);
@ -4244,7 +4249,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 +4291,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 +4387,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

@ -2254,6 +2254,8 @@ namespace BinXlsxRW {
pComments->sText = m_oBufferedStream.GetString4(length);
else if ( c_oSer_CommentData::Time == type )
pComments->sTime = m_oBufferedStream.GetString4(length);
else if ( c_oSer_CommentData::OOTime == type )
pComments->sOOTime = m_oBufferedStream.GetString4(length);
else if ( c_oSer_CommentData::UserId == type )
pComments->sUserId = m_oBufferedStream.GetString4(length);
else if ( c_oSer_CommentData::UserName == type )
@ -4262,25 +4264,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 +4339,13 @@ namespace BinXlsxRW {
}
bResultOk = true;
}
if (!bIsNoBase64)
{
RELEASEARRAYOBJECTS(pData);
}
}
RELEASEARRAYOBJECTS(pBase64Data);
}
return S_OK;
}