Add ctPageRotate, AddPage and RemovePage

This commit is contained in:
Svetlana Kulikova
2024-04-08 17:17:06 +03:00
parent 8c522aa006
commit 4ddde8246d
8 changed files with 47 additions and 1 deletions

View File

@ -149,6 +149,7 @@ public:
WidgetsInfo = 6,
ShapeStart = 7,
ShapeEnd = 8,
PageRotate = 9,
Undefined = 255
};

View File

@ -927,6 +927,7 @@ namespace NSOnlineOfficeBinToPdf
case ctWidgetsInfo:
case ctShapeStart:
case ctShapeEnd:
case ctPageRotate:
{
IAdvancedCommand::AdvancedCommandType eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::Undefined;
switch (eCommand)
@ -937,6 +938,7 @@ namespace NSOnlineOfficeBinToPdf
case ctWidgetsInfo: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::WidgetsInfo; break;
case ctShapeStart: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::ShapeStart; break;
case ctShapeEnd: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::ShapeEnd; break;
case ctPageRotate: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::PageRotate; break;
default:
break;
}
@ -1256,6 +1258,10 @@ namespace NSOnlineOfficeBinToPdf
case ctFormField:
case ctAnnotField:
case ctAnnotFieldDelete:
case ctWidgetsInfo:
case ctShapeStart:
case ctShapeEnd:
case ctPageRotate:
default:
{
BYTE* cur = oReader.GetCurrentBuffer();

View File

@ -191,6 +191,7 @@ namespace NSOnlineOfficeBinToPdf
ctPageStart = 202,
ctPageEnd = 203,
ctPageRotate = 204,
// gradients

View File

@ -60,6 +60,7 @@ namespace NSOnlineOfficeBinToPdf
case ctWidgetsInfo: return Read_Command<CWidgetsInfo> (this, pCorrector);
case ctShapeStart: return Read_Command<CShapeStart> (this, pCorrector);
case ctShapeEnd: return Read_Command<CShapeEnd> (this, pCorrector);
case ctPageRotate: return Read_Command<CPageRotate> (this, pCorrector);
default: break;
}

View File

@ -1011,3 +1011,12 @@ bool CShapeStart::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafile
CShapeEnd::CShapeEnd() : IAdvancedCommand(AdvancedCommandType::ShapeEnd) {}
bool CShapeEnd::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector) { return true; }
CPageRotate::CPageRotate() : IAdvancedCommand(AdvancedCommandType::PageRotate) {}
int CPageRotate::GetPageRotate() { return m_nPageRotate; }
bool CPageRotate::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
{
m_nPageRotate = pReader->ReadInt();
return true;
}

View File

@ -529,4 +529,17 @@ public:
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
};
class GRAPHICS_DECL CPageRotate : public IAdvancedCommand
{
public:
CPageRotate();
int GetPageRotate();
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
private:
int m_nPageRotate;
};
#endif // _BUILD_ANNOTFIELD_H_

View File

@ -191,9 +191,16 @@ namespace NSOnlineOfficeBinToPdf
break;
}
case AddCommandType::AddPage:
{
pPdf->AddPage(nPageNum);
NSOnlineOfficeBinToPdf::ConvertBufferToRenderer(oReader.GetCurrentBuffer(), (LONG)(nLen - 9) , &oCorrector);
oReader.Skip(nLen - 9);
break;
}
case AddCommandType::RemovePage:
{
// TODO: version 7.6+
pPdf->DeletePage(nPageNum);
break;
}
case AddCommandType::WidgetInfo:

View File

@ -1158,6 +1158,7 @@ HRESULT CPdfFile::IsSupportAdvancedCommand(const IAdvancedCommand::AdvancedComma
case IAdvancedCommand::AdvancedCommandType::WidgetsInfo:
case IAdvancedCommand::AdvancedCommandType::ShapeStart:
case IAdvancedCommand::AdvancedCommandType::ShapeEnd:
case IAdvancedCommand::AdvancedCommandType::PageRotate:
return S_OK;
default:
break;
@ -1229,6 +1230,13 @@ HRESULT CPdfFile::AdvancedCommand(IAdvancedCommand* command)
m_pInternal->pEditor->EndMarkedContent();
return S_OK;
}
case IAdvancedCommand::AdvancedCommandType::PageRotate:
{
CPageRotate* pCommand = (CPageRotate*)command;
if (m_pInternal->pEditor && m_pInternal->pEditor->EditPage())
m_pInternal->pWriter->PageRotate(pCommand->GetPageRotate());
return S_OK;
}
default:
break;
}