mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Add method for save added annotations
This commit is contained in:
@ -31,9 +31,7 @@
|
||||
*/
|
||||
#include "OnlineOfficeBinToPdf.h"
|
||||
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
#include "../../DesktopEditor/common/Base64.h"
|
||||
#include "../../DesktopEditor/graphics/MetafileToRenderer.h"
|
||||
|
||||
namespace NSOnlineOfficeBinToPdf
|
||||
@ -145,4 +143,64 @@ namespace NSOnlineOfficeBinToPdf
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
enum class AddCommandType
|
||||
{
|
||||
Annotation = 0,
|
||||
AddPage = 1,
|
||||
RemovePage = 2,
|
||||
Undefined = 255
|
||||
};
|
||||
|
||||
bool AddBinToPdf(CPdfFile* pPdf, BYTE* pBuffer, unsigned int nLen, CConvertFromBinParams* pParams)
|
||||
{
|
||||
CMetafileToRenderterPDF oCorrector(pPdf);
|
||||
oCorrector.SetTempDirectory(pPdf->GetTempDirectory());
|
||||
if (pParams)
|
||||
{
|
||||
oCorrector.SetMediaDirectory(pParams->m_sMediaDirectory);
|
||||
oCorrector.SetInternalMediaDirectory(pParams->m_sInternalMediaDirectory);
|
||||
oCorrector.SetThemesDirectory(pParams->m_sThemesDirectory);
|
||||
|
||||
if (pParams->m_bIsUsePicker)
|
||||
oCorrector.InitPicker(pPdf->GetFonts());
|
||||
}
|
||||
|
||||
NSOnlineOfficeBinToPdf::CBufferReader oReader(pBuffer, (int)nLen);
|
||||
|
||||
while (oReader.Check())
|
||||
{
|
||||
int nLen = oReader.ReadInt();
|
||||
AddCommandType CommandType = (AddCommandType)oReader.ReadByte();
|
||||
int nPageNum = oReader.ReadInt();
|
||||
|
||||
if (nPageNum < 0)
|
||||
{
|
||||
// ошибка в бинарнике
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: помечаем страницу в writer (nPageNum)
|
||||
|
||||
switch (CommandType)
|
||||
{
|
||||
case AddCommandType::Annotation:
|
||||
{
|
||||
NSOnlineOfficeBinToPdf::ConvertBufferToRenderer(oReader.GetCurrentBuffer(), (LONG)(nLen - 9) , &oCorrector);
|
||||
oReader.Skip(nLen - 9);
|
||||
break;
|
||||
}
|
||||
case AddCommandType::AddPage:
|
||||
case AddCommandType::RemovePage:
|
||||
{
|
||||
// TODO: version 7.6+
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
namespace NSOnlineOfficeBinToPdf
|
||||
{
|
||||
bool ConvertBinToPdf(CPdfFile* pPdf, const std::wstring& wsSrcFile, const std::wstring& wsDstFile, bool bBinary, CConvertFromBinParams* pParams);
|
||||
bool AddBinToPdf(CPdfFile* pPdf, BYTE* pBuffer, unsigned int nLen, CConvertFromBinParams* pParams);
|
||||
}
|
||||
|
||||
#endif // _PDF_WRITER_ONLINEOFFICEBINTOPDF_H
|
||||
|
||||
|
||||
@ -1584,3 +1584,11 @@ HRESULT CPdfFile::AdvancedCommand(IAdvancedCommand* command)
|
||||
}
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
bool CPdfFile::AddCommandsToFile(BYTE* pBuffer, unsigned int& nLen, CConvertFromBinParams* pParams)
|
||||
{
|
||||
if (!m_pInternal->pReader || !m_pInternal->pWriter)
|
||||
return false;
|
||||
|
||||
return NSOnlineOfficeBinToPdf::AddBinToPdf(this, pBuffer, nLen, pParams);
|
||||
}
|
||||
|
||||
@ -288,6 +288,8 @@ public:
|
||||
virtual HRESULT IsSupportAdvancedCommand(const IAdvancedCommand::AdvancedCommandType& type);
|
||||
virtual HRESULT AdvancedCommand(IAdvancedCommand* command);
|
||||
|
||||
bool AddCommandsToFile(BYTE* pBuffer, unsigned int& nLen, CConvertFromBinParams* pParams);
|
||||
|
||||
private:
|
||||
CPdfFile_Private* m_pInternal;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user