mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-20 00:03:33 +08:00
276 lines
6.0 KiB
C++
276 lines
6.0 KiB
C++
#ifndef _PAGE_H
|
|
#define _PAGE_H
|
|
|
|
#include "Object.h"
|
|
#include "GlobalParams.h"
|
|
|
|
class Dict;
|
|
class XRef;
|
|
class OutputDev;
|
|
class Links;
|
|
class Catalog;
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
class PDFRectangle
|
|
{
|
|
public:
|
|
|
|
PDFRectangle()
|
|
{
|
|
m_dLeft = m_dBottom = m_dRight = m_dTop = 0;
|
|
}
|
|
PDFRectangle(double dLeft, double dBottom, double dRight, double dTop)
|
|
{
|
|
m_dLeft = dLeft;
|
|
m_dBottom = dBottom;
|
|
m_dRight = dRight;
|
|
m_dTop = dTop;
|
|
}
|
|
BOOL IsValid()
|
|
{
|
|
return m_dLeft != 0 || m_dBottom != 0 || m_dRight != 0 || m_dTop != 0;
|
|
}
|
|
void ClipTo(PDFRectangle *pRect);
|
|
|
|
public:
|
|
|
|
double m_dLeft;
|
|
double m_dBottom;
|
|
double m_dRight;
|
|
double m_dTop;
|
|
};
|
|
|
|
//------------------------------------------------------------------------
|
|
// PageAttrs
|
|
//------------------------------------------------------------------------
|
|
|
|
class PageAttrs
|
|
{
|
|
public:
|
|
|
|
// Ñòðîèì íîâûé îáúåêò PageAttrs ëèáî ñ íà÷àëüíûìè íàñòðîéêàìè èç
|
|
// pAttrs, ëèáî ñî ñòàíäàðòíûìè íà÷àëüíûìè íàñòðîéêàìè(åñëè pAttrs =
|
|
// NULL).
|
|
PageAttrs(PageAttrs *pAttrs, Dict *pDict);
|
|
|
|
~PageAttrs();
|
|
|
|
PDFRectangle *GetMediaBox()
|
|
{
|
|
return &m_oMediaBox;
|
|
}
|
|
PDFRectangle *GetCropBox()
|
|
{
|
|
return &m_pCropBox;
|
|
}
|
|
BOOL IsCropped()
|
|
{
|
|
return m_bHaveCropBox;
|
|
}
|
|
PDFRectangle *GetBleedBox()
|
|
{
|
|
return &m_oBleedBox;
|
|
}
|
|
PDFRectangle *GetTrimBox()
|
|
{
|
|
return &m_oTrimBox;
|
|
}
|
|
PDFRectangle *GetArtBox()
|
|
{
|
|
return &m_oArtBox;
|
|
}
|
|
int GetRotate()
|
|
{
|
|
return m_nRotate;
|
|
}
|
|
StringExt *GetLastModified()
|
|
{
|
|
return ( m_oLastModified.IsString() ? m_oLastModified.GetString() : (StringExt *)NULL );
|
|
}
|
|
Dict *GetBoxColorInfo()
|
|
{
|
|
return ( m_oBoxColorInfo.IsDict() ? m_oBoxColorInfo.GetDict() : (Dict *)NULL );
|
|
}
|
|
Dict *GetGroup()
|
|
{
|
|
return ( m_oGroup.IsDict() ? m_oGroup.GetDict() : (Dict *)NULL );
|
|
}
|
|
Stream *GetMetadata()
|
|
{
|
|
return ( m_oMetadata.IsStream() ? m_oMetadata.GetStream() : (Stream *)NULL );
|
|
}
|
|
Dict *GetPieceInfo()
|
|
{
|
|
return ( m_oPieceInfo.IsDict() ? m_oPieceInfo.GetDict() : (Dict *)NULL );
|
|
}
|
|
Dict *GetSeparationInfo()
|
|
{
|
|
return ( m_oSeparationInfo.IsDict() ? m_oSeparationInfo.GetDict() : (Dict *)NULL );
|
|
}
|
|
Dict *GetResourceDict()
|
|
{
|
|
return ( m_oResources.IsDict() ? m_oResources.GetDict() : (Dict *)NULL );
|
|
}
|
|
|
|
private:
|
|
|
|
BOOL ReadBox(Dict *pDict, char *sKey, PDFRectangle *pBox);
|
|
|
|
private:
|
|
|
|
PDFRectangle m_oMediaBox;
|
|
PDFRectangle m_pCropBox;
|
|
BOOL m_bHaveCropBox;
|
|
PDFRectangle m_oBleedBox;
|
|
PDFRectangle m_oTrimBox;
|
|
PDFRectangle m_oArtBox;
|
|
|
|
int m_nRotate;
|
|
|
|
Object m_oLastModified;
|
|
Object m_oBoxColorInfo;
|
|
Object m_oGroup;
|
|
Object m_oMetadata;
|
|
Object m_oPieceInfo;
|
|
Object m_oSeparationInfo;
|
|
Object m_oResources;
|
|
};
|
|
|
|
//------------------------------------------------------------------------
|
|
// Page
|
|
//------------------------------------------------------------------------
|
|
|
|
class Page
|
|
{
|
|
public:
|
|
|
|
Page(GlobalParams *pGlobalParams, XRef *pXref, int nNum, Dict *pPageDict, PageAttrs *pAttrs);
|
|
|
|
~Page();
|
|
|
|
BOOL IsValid()
|
|
{
|
|
return m_bValid;
|
|
}
|
|
|
|
int GetNum()
|
|
{
|
|
return m_nNumber;
|
|
}
|
|
PDFRectangle *GetMediaBox()
|
|
{
|
|
return m_pAttrs->GetMediaBox();
|
|
}
|
|
PDFRectangle *GetCropBox()
|
|
{
|
|
return m_pAttrs->GetCropBox();
|
|
}
|
|
BOOL IsCropped()
|
|
{
|
|
return m_pAttrs->IsCropped();
|
|
}
|
|
double GetMediaWidth()
|
|
{
|
|
return m_pAttrs->GetMediaBox()->m_dRight - m_pAttrs->GetMediaBox()->m_dLeft;
|
|
}
|
|
double GetMediaHeight()
|
|
{
|
|
return m_pAttrs->GetMediaBox()->m_dTop - m_pAttrs->GetMediaBox()->m_dBottom;
|
|
}
|
|
double GetCropWidth()
|
|
{
|
|
return m_pAttrs->GetCropBox()->m_dRight - m_pAttrs->GetCropBox()->m_dLeft;
|
|
}
|
|
double GetCropHeight()
|
|
{
|
|
return m_pAttrs->GetCropBox()->m_dTop - m_pAttrs->GetCropBox()->m_dBottom;
|
|
}
|
|
PDFRectangle *GetBleedBox()
|
|
{
|
|
return m_pAttrs->GetBleedBox();
|
|
}
|
|
PDFRectangle *GetTrimBox()
|
|
{
|
|
return m_pAttrs->GetTrimBox();
|
|
}
|
|
PDFRectangle *GetArtBox()
|
|
{
|
|
return m_pAttrs->GetArtBox();
|
|
}
|
|
int GetRotate()
|
|
{
|
|
return m_pAttrs->GetRotate();
|
|
}
|
|
StringExt *GetLastModified()
|
|
{
|
|
return m_pAttrs->GetLastModified();
|
|
}
|
|
Dict *GetBoxColorInfo()
|
|
{
|
|
return m_pAttrs->GetBoxColorInfo();
|
|
}
|
|
Dict *GetGroup()
|
|
{
|
|
return m_pAttrs->GetGroup();
|
|
}
|
|
Stream *GetMetadata()
|
|
{
|
|
return m_pAttrs->GetMetadata();
|
|
}
|
|
Dict *GetPieceInfo()
|
|
{
|
|
return m_pAttrs->GetPieceInfo();
|
|
}
|
|
Dict *GetSeparationInfo()
|
|
{
|
|
return m_pAttrs->GetSeparationInfo();
|
|
}
|
|
|
|
// Resource
|
|
Dict *GetResourceDict()
|
|
{
|
|
return m_pAttrs->GetResourceDict();
|
|
}
|
|
|
|
// Annotations
|
|
Object *GetAnnots(Object *pObject)
|
|
{
|
|
return m_oAnnots.Fetch( m_pXref, pObject);
|
|
}
|
|
|
|
// Links
|
|
Links *GetLinks(Catalog *catalog);
|
|
|
|
// Contents
|
|
Object *GetContents(Object *pObject)
|
|
{
|
|
return m_oContents.Fetch( m_pXref, pObject);
|
|
}
|
|
|
|
//
|
|
void Display(OutputDev *pOut, double dHorizDPI, double dVertDPI, int nRotate, BOOL bUseMediaBox, BOOL bCrop, BOOL bPrinting, Catalog *pCatalog, BOOL (*abortCheckCbk)(void *pData) = NULL, void *abortCheckCbkData = NULL);
|
|
|
|
void DisplaySlice(OutputDev *pOut, double dHorizDPI, double dVertDPI, int nRotate, BOOL bUseMediaBox, BOOL bCrop, int nSliceX, int nSliceY, int nSliceW, int nSliceH, BOOL bPrinting, Catalog *pCatalog, BOOL (*abortCheckCbk)(void *pData) = NULL, void *abortCheckCbkData = NULL);
|
|
|
|
void MakeBox(double dHorizDPI, double dVertDPI, int nRotate, BOOL bUseMediaBox, BOOL bUpSideDown, double dSliceX, double dSliceY, double dSliceW, double dSliceH, PDFRectangle *pBox, BOOL *pbCrop);
|
|
|
|
void ProcessLinks(OutputDev *pOut, Catalog *pCatalog);
|
|
|
|
void GetDefaultCTM(double *pCTM, double dHorizDPI, double dVertDPI, int nRotate, BOOL bUseMediaBox, BOOL bUpSideDown);
|
|
|
|
private:
|
|
|
|
XRef *m_pXref; // Òàáëèöà xref äëÿ äàííîãî PDF äîêóìåíòà
|
|
int m_nNumber; // Íîìåð ñòðàíèöû
|
|
PageAttrs *m_pAttrs; // Page attributes
|
|
Object m_oAnnots; // Annotations
|
|
Object m_oContents; // Ñîäåðæèìîå ñòðàíèöû
|
|
Object m_oContents2;
|
|
BOOL m_bValid; //
|
|
|
|
GlobalParams *m_pGlobalParams;
|
|
};
|
|
|
|
#endif /* _PAGE_H */
|