mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Development AddAnnotField
This commit is contained in:
@ -43,9 +43,12 @@ CAnnotFieldInfo::CAnnotFieldInfo()
|
||||
m_dH = 0;
|
||||
|
||||
m_dBaseLineOffset = 0;
|
||||
|
||||
m_oTextPr = NULL;
|
||||
}
|
||||
CAnnotFieldInfo::~CAnnotFieldInfo()
|
||||
{
|
||||
RELEASEOBJECT(m_oTextPr);
|
||||
}
|
||||
|
||||
void CAnnotFieldInfo::SetType(int nType)
|
||||
@ -85,3 +88,19 @@ bool CAnnotFieldInfo::isWidget() const
|
||||
{
|
||||
return (m_nType != 0 && m_nType < 7);
|
||||
}
|
||||
bool CAnnotFieldInfo::IsText() const
|
||||
{
|
||||
return (m_nType == 7);
|
||||
}
|
||||
bool CAnnotFieldInfo::IsInk() const
|
||||
{
|
||||
return (m_nType == 8);
|
||||
}
|
||||
bool CAnnotFieldInfo::IsLine() const
|
||||
{
|
||||
return (m_nType == 9);
|
||||
}
|
||||
CAnnotFieldInfo::CTextAnnotPr* CAnnotFieldInfo::GetTextAnnotPr()
|
||||
{
|
||||
return m_oTextPr;
|
||||
}
|
||||
|
||||
@ -37,6 +37,24 @@
|
||||
|
||||
class GRAPHICS_DECL CAnnotFieldInfo : public IAnnotField
|
||||
{
|
||||
protected:
|
||||
class CMarkupAnnot
|
||||
{
|
||||
CMarkupAnnot();
|
||||
};
|
||||
public:
|
||||
class GRAPHICS_DECL CTextAnnotPr : public CMarkupAnnot
|
||||
{
|
||||
public:
|
||||
CTextAnnotPr();
|
||||
|
||||
private:
|
||||
bool m_bOpen;
|
||||
BYTE m_nName;
|
||||
BYTE m_nState;
|
||||
BYTE m_nStateModel;
|
||||
};
|
||||
|
||||
public:
|
||||
CAnnotFieldInfo();
|
||||
virtual ~CAnnotFieldInfo();
|
||||
@ -52,6 +70,11 @@ public:
|
||||
double GetBaseLineOffset() const;
|
||||
|
||||
bool isWidget() const;
|
||||
bool IsText() const;
|
||||
bool IsInk() const;
|
||||
bool IsLine() const;
|
||||
|
||||
CTextAnnotPr* GetTextAnnotPr();
|
||||
|
||||
protected:
|
||||
int m_nType;
|
||||
@ -62,6 +85,8 @@ private:
|
||||
double m_dW;
|
||||
double m_dH;
|
||||
double m_dBaseLineOffset;
|
||||
|
||||
CTextAnnotPr* m_oTextPr;
|
||||
};
|
||||
|
||||
#endif // _BUILD_ANNOTFIELD_H_
|
||||
|
||||
@ -1228,7 +1228,7 @@ namespace NSOnlineOfficeBinToPdf
|
||||
}
|
||||
|
||||
if (oInfo.IsValid())
|
||||
pRenderer->AddFormField(&oInfo);
|
||||
pRenderer->AddAnnotField(&oInfo);
|
||||
|
||||
current = nStartPos + nLen;
|
||||
curindex = nStartIndex + nLen;
|
||||
|
||||
@ -1187,7 +1187,7 @@ HRESULT CPdfWriter::AddFormField(NSFonts::IApplicationFonts* pAppFonts, IAnnotFi
|
||||
|
||||
if (oInfo.IsTextField())
|
||||
{
|
||||
const CFormFieldInfo::CTextFormPr* pPr = oInfo.GetTextPr();
|
||||
const CFormFieldInfo::CTextFormPr* pPr = oInfo.GetTextFormPr();
|
||||
std::wstring wsValue = pPr->GetTextValue();
|
||||
|
||||
unsigned int unLen;
|
||||
@ -1671,10 +1671,53 @@ HRESULT CPdfWriter::AddFormField(NSFonts::IApplicationFonts* pAppFonts, IAnnotFi
|
||||
}
|
||||
HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, IAnnotField* pFieldInfo)
|
||||
{
|
||||
unsigned int unPagesCount = m_pDocument->GetPagesCount();
|
||||
if (!m_pDocument || 0 == unPagesCount || !pFieldInfo)
|
||||
return S_OK;
|
||||
|
||||
CAnnotFieldInfo& oInfo = *((CAnnotFieldInfo*)pFieldInfo);
|
||||
|
||||
if (oInfo.isWidget())
|
||||
return AddFormField(pAppFonts, pFieldInfo);
|
||||
|
||||
if (m_bNeedUpdateTextFont)
|
||||
UpdateFont();
|
||||
|
||||
if (!m_pFont)
|
||||
return S_OK;
|
||||
|
||||
// TODO нам это нужно? Всегда иметь шрифт?
|
||||
// PdfWriter::CFontTrueType* pFontTT = m_pDocument->CreateTrueTypeFont(m_pFont);
|
||||
// if (!pFontTT)
|
||||
// return S_OK;
|
||||
|
||||
double dX, dY, dW, dH;
|
||||
oInfo.GetBounds(dX, dY, dW, dH);
|
||||
PdfWriter::TRect oRect(MM_2_PT(dX), m_pPage->GetHeight() - MM_2_PT(dY), MM_2_PT(dX + dW), m_pPage->GetHeight() - MM_2_PT(dY + dH));
|
||||
|
||||
PdfWriter::CAnnotation* pAnnot = NULL;
|
||||
|
||||
if (oInfo.IsText())
|
||||
{
|
||||
pAnnot = m_pDocument->CreateTextAnnot(m_pPage, oRect, "TEST");
|
||||
}
|
||||
else if (oInfo.IsInk())
|
||||
{
|
||||
|
||||
}
|
||||
else if (oInfo.IsLine())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (!pAnnot)
|
||||
return S_FALSE;
|
||||
|
||||
if (oInfo.IsText())
|
||||
{
|
||||
CAnnotFieldInfo::CTextAnnotPr* pPr = oInfo.GetTextAnnotPr();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -2345,7 +2388,7 @@ void CPdfWriter::AddLink(PdfWriter::CPage* pPage, const double& dX, const double
|
||||
return;
|
||||
|
||||
pDestination->SetXYZ(MM_2_PT(dDestX), pDestPage->GetHeight() - MM_2_PT(dDestY), 0);
|
||||
PdfWriter::CAnnotation* pAnnot = m_pDocument->CreateLinkAnnot(pCurPage, PdfWriter::TRect(MM_2_PT(dX), pCurPage->GetHeight() - MM_2_PT(dY), MM_2_PT(dX + dW), m_pPage->GetHeight() - MM_2_PT(dY + dH)), pDestination);
|
||||
PdfWriter::CAnnotation* pAnnot = m_pDocument->CreateLinkAnnot(pCurPage, PdfWriter::TRect(MM_2_PT(dX), pCurPage->GetHeight() - MM_2_PT(dY), MM_2_PT(dX + dW), pCurPage->GetHeight() - MM_2_PT(dY + dH)), pDestination);
|
||||
pAnnot->SetBorderStyle(PdfWriter::EBorderSubtype::border_subtype_Solid, 0);
|
||||
}
|
||||
bool CPdfWriter::IsValid()
|
||||
|
||||
@ -351,140 +351,6 @@ std::string getValue(Object* oV)
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
void getParents(XRef* xref, Object* oFieldRef, std::vector<CAnnotParent*>& arrParents)
|
||||
{
|
||||
if (!oFieldRef || !xref)
|
||||
return;
|
||||
|
||||
Object oField;
|
||||
if (!oFieldRef->isRef() || std::find_if(arrParents.begin(), arrParents.end(), [oFieldRef] (CAnnotParent* pAP) { return oFieldRef->getRefNum() == pAP->unRefNum; }) != arrParents.end() || !oFieldRef->fetch(xref, &oField)->isDict())
|
||||
{
|
||||
oField.free();
|
||||
return;
|
||||
}
|
||||
|
||||
CAnnotParent* pAnnotParent = new CAnnotParent();
|
||||
if (!pAnnotParent)
|
||||
{
|
||||
oField.free();
|
||||
return;
|
||||
}
|
||||
|
||||
pAnnotParent->unRefNum = oFieldRef->getRefNum();
|
||||
|
||||
Object oT;
|
||||
if (oField.dictLookup("T", &oT)->isString())
|
||||
{
|
||||
TextString* s = new TextString(oT.getString());
|
||||
std::string sStr = NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength());
|
||||
pAnnotParent->unFlags |= (1 << 0);
|
||||
pAnnotParent->sT = sStr;
|
||||
delete s;
|
||||
}
|
||||
oT.free();
|
||||
|
||||
Object oV;
|
||||
if (oField.dictLookup("V", &oV))
|
||||
{
|
||||
pAnnotParent->sV = getValue(&oV);
|
||||
if (!pAnnotParent->sV.empty())
|
||||
pAnnotParent->unFlags |= (1 << 1);
|
||||
}
|
||||
oV.free();
|
||||
|
||||
Object oDV;
|
||||
if (oField.dictLookup("DV", &oDV))
|
||||
{
|
||||
pAnnotParent->sDV = getValue(&oDV);
|
||||
if (!pAnnotParent->sDV.empty())
|
||||
pAnnotParent->unFlags |= (1 << 2);
|
||||
}
|
||||
oDV.free();
|
||||
|
||||
arrParents.push_back(pAnnotParent);
|
||||
|
||||
Object oParentRefObj;
|
||||
if (oField.dictLookupNF("Parent", &oParentRefObj)->isRef())
|
||||
{
|
||||
pAnnotParent->unFlags |= (1 << 3);
|
||||
pAnnotParent->unRefNumParent = oParentRefObj.getRefNum();
|
||||
getParents(xref, &oParentRefObj, arrParents);
|
||||
}
|
||||
oParentRefObj.free();
|
||||
}
|
||||
CBorderType* getBorder(Object* oBorder, bool bBSorBorder)
|
||||
{
|
||||
// Границы и Dash Pattern - Border/BS
|
||||
CBorderType* pBorderType = new CBorderType();
|
||||
if (!oBorder)
|
||||
return pBorderType;
|
||||
if (bBSorBorder)
|
||||
{
|
||||
pBorderType->nType = annotBorderSolid;
|
||||
Object oV;
|
||||
if (oBorder->dictLookup("S", &oV)->isName())
|
||||
{
|
||||
if (oV.isName("S"))
|
||||
pBorderType->nType = annotBorderSolid;
|
||||
else if (oV.isName("D"))
|
||||
pBorderType->nType = annotBorderDashed;
|
||||
else if (oV.isName("B"))
|
||||
pBorderType->nType = annotBorderBeveled;
|
||||
else if (oV.isName("I"))
|
||||
pBorderType->nType = annotBorderInset;
|
||||
else if (oV.isName("U"))
|
||||
pBorderType->nType = annotBorderUnderlined;
|
||||
}
|
||||
oV.free();
|
||||
if (oBorder->dictLookup("W", &oV)->isNum())
|
||||
pBorderType->dWidth = oV.getNum();
|
||||
oV.free();
|
||||
if (oBorder->dictLookup("D", &oV)->isArray())
|
||||
{
|
||||
Object oObj2;
|
||||
ARR_GET_NUM(oV, 0, pBorderType->dDashesAlternating);
|
||||
pBorderType->dGaps = pBorderType->dDashesAlternating;
|
||||
ARR_GET_NUM(oV, 1, pBorderType->dGaps);
|
||||
}
|
||||
oV.free();
|
||||
}
|
||||
else
|
||||
{
|
||||
pBorderType->nType = annotBorderSolid;
|
||||
Object oObj2;
|
||||
pBorderType->dWidth = 1.0;
|
||||
ARR_GET_NUM((*oBorder), 2, pBorderType->dWidth);
|
||||
|
||||
Object oObj;
|
||||
if (oBorder->arrayGetLength() > 3 && oBorder->arrayGet(3, &oObj)->isArray() && oObj.arrayGetLength() > 1)
|
||||
{
|
||||
pBorderType->nType = annotBorderDashed;
|
||||
ARR_GET_NUM(oObj, 0, pBorderType->dDashesAlternating);
|
||||
ARR_GET_NUM(oObj, 1, pBorderType->dGaps);
|
||||
}
|
||||
oObj.free();
|
||||
}
|
||||
|
||||
return pBorderType;
|
||||
}
|
||||
void WriteAppearance(int nWidth, int nHeight, BYTE* pBgraData, unsigned int nColor, CAnnotAPView* pView)
|
||||
{
|
||||
BYTE* pSubMatrix = new BYTE[nWidth * nHeight * 4];
|
||||
int p = 0;
|
||||
unsigned int* pTemp = (unsigned int*)pBgraData;
|
||||
unsigned int* pSubTemp = (unsigned int*)pSubMatrix;
|
||||
for (int y = 0; y < nHeight; ++y)
|
||||
{
|
||||
for (int x = 0; x < nWidth; ++x)
|
||||
{
|
||||
pSubTemp[p++] = pTemp[y * nWidth + x];
|
||||
pTemp[y * nWidth + x] = nColor;
|
||||
}
|
||||
}
|
||||
|
||||
pView->pAP = pSubMatrix;
|
||||
pView->pText = ((GlobalParamsAdaptor*)globalParams)->GetTextFormField();
|
||||
}
|
||||
void DrawAppearance(PDFDoc* pdfDoc, int nPage, AcroFormField* pField, Gfx* gfx, const char* sAPName, const char* sASName)
|
||||
{
|
||||
XRef* xref = pdfDoc->getXRef();
|
||||
@ -1232,7 +1098,7 @@ CAnnots::CAnnots(PDFDoc* pdfDoc)
|
||||
// Родители
|
||||
Object oParentRefObj;
|
||||
if (oField.dictLookupNF("Parent", &oParentRefObj)->isRef())
|
||||
getParents(xref, &oParentRefObj, m_arrParents);
|
||||
getParents(xref, &oParentRefObj);
|
||||
oParentRefObj.free();
|
||||
oField.free(); oFieldRef.free();
|
||||
|
||||
@ -1283,6 +1149,63 @@ CAnnots::~CAnnots()
|
||||
RELEASEOBJECT(m_arrAnnots[i]);
|
||||
}
|
||||
|
||||
void CAnnots::getParents(XRef* xref, Object* oFieldRef)
|
||||
{
|
||||
if (!oFieldRef || !xref || !oFieldRef->isRef() ||
|
||||
std::find_if(m_arrParents.begin(), m_arrParents.end(), [oFieldRef] (CAnnotParent* pAP) { return oFieldRef->getRefNum() == pAP->unRefNum; }) != m_arrParents.end())
|
||||
return;
|
||||
|
||||
Object oField;
|
||||
CAnnotParent* pAnnotParent = new CAnnotParent();
|
||||
if (!pAnnotParent || !oFieldRef->fetch(xref, &oField)->isDict())
|
||||
{
|
||||
oField.free();
|
||||
return;
|
||||
}
|
||||
|
||||
pAnnotParent->unRefNum = oFieldRef->getRefNum();
|
||||
|
||||
Object oT;
|
||||
if (oField.dictLookup("T", &oT)->isString())
|
||||
{
|
||||
TextString* s = new TextString(oT.getString());
|
||||
std::string sStr = NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength());
|
||||
pAnnotParent->unFlags |= (1 << 0);
|
||||
pAnnotParent->sT = sStr;
|
||||
delete s;
|
||||
}
|
||||
oT.free();
|
||||
|
||||
Object oV;
|
||||
if (oField.dictLookup("V", &oV))
|
||||
{
|
||||
pAnnotParent->sV = getValue(&oV);
|
||||
if (!pAnnotParent->sV.empty())
|
||||
pAnnotParent->unFlags |= (1 << 1);
|
||||
}
|
||||
oV.free();
|
||||
|
||||
Object oDV;
|
||||
if (oField.dictLookup("DV", &oDV))
|
||||
{
|
||||
pAnnotParent->sDV = getValue(&oDV);
|
||||
if (!pAnnotParent->sDV.empty())
|
||||
pAnnotParent->unFlags |= (1 << 2);
|
||||
}
|
||||
oDV.free();
|
||||
|
||||
m_arrParents.push_back(pAnnotParent);
|
||||
|
||||
Object oParentRefObj;
|
||||
if (oField.dictLookupNF("Parent", &oParentRefObj)->isRef())
|
||||
{
|
||||
pAnnotParent->unFlags |= (1 << 3);
|
||||
pAnnotParent->unRefNumParent = oParentRefObj.getRefNum();
|
||||
getParents(xref, &oParentRefObj);
|
||||
}
|
||||
oParentRefObj.free();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Markup
|
||||
//------------------------------------------------------------------------
|
||||
@ -1560,6 +1483,62 @@ CAnnot::~CAnnot()
|
||||
RELEASEOBJECT(m_pBorder);
|
||||
}
|
||||
|
||||
CAnnot::CBorderType* CAnnot::getBorder(Object* oBorder, bool bBSorBorder)
|
||||
{
|
||||
// Границы и Dash Pattern - Border/BS
|
||||
CBorderType* pBorderType = new CBorderType();
|
||||
if (!oBorder)
|
||||
return pBorderType;
|
||||
if (bBSorBorder)
|
||||
{
|
||||
pBorderType->nType = annotBorderSolid;
|
||||
Object oV;
|
||||
if (oBorder->dictLookup("S", &oV)->isName())
|
||||
{
|
||||
if (oV.isName("S"))
|
||||
pBorderType->nType = annotBorderSolid;
|
||||
else if (oV.isName("D"))
|
||||
pBorderType->nType = annotBorderDashed;
|
||||
else if (oV.isName("B"))
|
||||
pBorderType->nType = annotBorderBeveled;
|
||||
else if (oV.isName("I"))
|
||||
pBorderType->nType = annotBorderInset;
|
||||
else if (oV.isName("U"))
|
||||
pBorderType->nType = annotBorderUnderlined;
|
||||
}
|
||||
oV.free();
|
||||
if (oBorder->dictLookup("W", &oV)->isNum())
|
||||
pBorderType->dWidth = oV.getNum();
|
||||
oV.free();
|
||||
if (oBorder->dictLookup("D", &oV)->isArray())
|
||||
{
|
||||
Object oObj2;
|
||||
ARR_GET_NUM(oV, 0, pBorderType->dDashesAlternating);
|
||||
pBorderType->dGaps = pBorderType->dDashesAlternating;
|
||||
ARR_GET_NUM(oV, 1, pBorderType->dGaps);
|
||||
}
|
||||
oV.free();
|
||||
}
|
||||
else
|
||||
{
|
||||
pBorderType->nType = annotBorderSolid;
|
||||
Object oObj2;
|
||||
pBorderType->dWidth = 1.0;
|
||||
ARR_GET_NUM((*oBorder), 2, pBorderType->dWidth);
|
||||
|
||||
Object oObj;
|
||||
if (oBorder->arrayGetLength() > 3 && oBorder->arrayGet(3, &oObj)->isArray() && oObj.arrayGetLength() > 1)
|
||||
{
|
||||
pBorderType->nType = annotBorderDashed;
|
||||
ARR_GET_NUM(oObj, 0, pBorderType->dDashesAlternating);
|
||||
ARR_GET_NUM(oObj, 1, pBorderType->dGaps);
|
||||
}
|
||||
oObj.free();
|
||||
}
|
||||
|
||||
return pBorderType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// AP
|
||||
//------------------------------------------------------------------------
|
||||
@ -1764,7 +1743,7 @@ void CAnnotAP::Draw(PDFDoc* pdfDoc, Object* oAP, int nRasterH, int nBackgroundCo
|
||||
pView->sASName = "Yes";
|
||||
m_pRenderer->SetCoordTransformOffset(-m_dx1 * m_dWScale + 1 + m_dWTale / 2, m_dy2 * m_dHScale - nRasterH + 1 + m_dHTale / 2);
|
||||
DrawAppearance(pdfDoc, nPageIndex + 1, pField, m_gfx, arrAPName[j], pView->sASName.c_str());
|
||||
WriteAppearance(m_nWidth, m_nHeight, m_pFrame->get_Data(), nBackgroundColor, pView);
|
||||
WriteAppearance(nBackgroundColor, pView);
|
||||
}
|
||||
}
|
||||
else if (!oObj.isNull())
|
||||
@ -1773,7 +1752,7 @@ void CAnnotAP::Draw(PDFDoc* pdfDoc, Object* oAP, int nRasterH, int nBackgroundCo
|
||||
pView->sAPName = arrAPName[j];
|
||||
m_pRenderer->SetCoordTransformOffset(-m_dx1 * m_dWScale + 1 + m_dWTale / 2, m_dy2 * m_dHScale - nRasterH + 1 + m_dHTale / 2);
|
||||
DrawAppearance(pdfDoc, nPageIndex + 1, pField, m_gfx, arrAPName[j], NULL);
|
||||
WriteAppearance(m_nWidth, m_nHeight, m_pFrame->get_Data(), nBackgroundColor, pView);
|
||||
WriteAppearance(nBackgroundColor, pView);
|
||||
}
|
||||
oObj.free();
|
||||
|
||||
@ -1814,7 +1793,7 @@ void CAnnotAP::Draw(PDFDoc* pdfDoc, Object* oAP, int nRasterH, int nBackgroundCo
|
||||
}
|
||||
RELEASEOBJECT(annot);
|
||||
|
||||
WriteAppearance(m_nWidth, m_nHeight, m_pFrame->get_Data(), nBackgroundColor, pView);
|
||||
WriteAppearance(nBackgroundColor, pView);
|
||||
}
|
||||
oObj.free();
|
||||
|
||||
@ -1824,6 +1803,25 @@ void CAnnotAP::Draw(PDFDoc* pdfDoc, Object* oAP, int nRasterH, int nBackgroundCo
|
||||
oAnnot.free();
|
||||
}
|
||||
|
||||
void CAnnotAP::WriteAppearance(unsigned int nColor, CAnnotAPView* pView)
|
||||
{
|
||||
BYTE* pSubMatrix = new BYTE[m_nWidth * m_nHeight * 4];
|
||||
int p = 0;
|
||||
unsigned int* pTemp = (unsigned int*)m_pFrame->get_Data();
|
||||
unsigned int* pSubTemp = (unsigned int*)pSubMatrix;
|
||||
for (int y = 0; y < m_nHeight; ++y)
|
||||
{
|
||||
for (int x = 0; x < m_nWidth; ++x)
|
||||
{
|
||||
pSubTemp[p++] = pTemp[y * m_nWidth + x];
|
||||
pTemp[y * m_nWidth + x] = nColor;
|
||||
}
|
||||
}
|
||||
|
||||
pView->pAP = pSubMatrix;
|
||||
pView->pText = ((GlobalParamsAdaptor*)globalParams)->GetTextFormField();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// ToWASM
|
||||
//------------------------------------------------------------------------
|
||||
@ -1881,7 +1879,7 @@ void CAnnots::ToWASM(NSWasm::CData& oRes)
|
||||
m_arrAnnots[i]->ToWASM(oRes);
|
||||
}
|
||||
|
||||
void CAnnotParent::ToWASM(NSWasm::CData& oRes)
|
||||
void CAnnots::CAnnotParent::ToWASM(NSWasm::CData& oRes)
|
||||
{
|
||||
oRes.AddInt(unRefNum);
|
||||
oRes.AddInt(unFlags);
|
||||
@ -1921,7 +1919,7 @@ void CAnnot::ToWASM(NSWasm::CData& oRes)
|
||||
oRes.WriteString(m_sM);
|
||||
}
|
||||
|
||||
void CBorderType::ToWASM(NSWasm::CData& oRes)
|
||||
void CAnnot::CBorderType::ToWASM(NSWasm::CData& oRes)
|
||||
{
|
||||
BYTE nBP = nType;
|
||||
if (nBP == 1)
|
||||
|
||||
@ -47,64 +47,21 @@
|
||||
namespace PdfReader
|
||||
{
|
||||
|
||||
struct CAnnotParent final
|
||||
{
|
||||
CAnnotParent()
|
||||
{
|
||||
unFlags = 0;
|
||||
unRefNum = 0;
|
||||
unRefNumParent = 0;
|
||||
}
|
||||
|
||||
void ToWASM(NSWasm::CData& oRes);
|
||||
|
||||
unsigned int unFlags;
|
||||
unsigned int unRefNum; // Номер ссылки на объект
|
||||
unsigned int unRefNumParent; // Номер ссылки на объект родителя
|
||||
std::string sT;
|
||||
std::string sV;
|
||||
std::string sDV;
|
||||
};
|
||||
|
||||
struct CBorderType final
|
||||
{
|
||||
CBorderType()
|
||||
{
|
||||
nType = 5;
|
||||
dWidth = 1;
|
||||
dDashesAlternating = 3;
|
||||
dGaps = 3;
|
||||
}
|
||||
|
||||
void ToWASM(NSWasm::CData& oRes);
|
||||
|
||||
BYTE nType;
|
||||
double dWidth;
|
||||
double dDashesAlternating;
|
||||
double dGaps;
|
||||
};
|
||||
|
||||
struct CAnnotAPView
|
||||
{
|
||||
std::string sAPName;
|
||||
std::string sASName;
|
||||
BYTE* pAP;
|
||||
BYTE* pText;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// PdfReader::CAction
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
struct CAction
|
||||
class CAction
|
||||
{
|
||||
virtual void ToWASM(NSWasm::CData& oRes);
|
||||
|
||||
CAction() : pNext(NULL) {}
|
||||
public:
|
||||
virtual ~CAction() { RELEASEOBJECT(pNext); }
|
||||
|
||||
virtual void ToWASM(NSWasm::CData& oRes);
|
||||
|
||||
std::string sType;
|
||||
CAction* pNext;
|
||||
protected:
|
||||
CAction() : pNext(NULL) {}
|
||||
};
|
||||
struct CActionGoTo final : public CAction
|
||||
{
|
||||
@ -167,6 +124,15 @@ public:
|
||||
void ToWASM(NSWasm::CData& oRes);
|
||||
|
||||
private:
|
||||
struct CAnnotAPView final
|
||||
{
|
||||
std::string sAPName;
|
||||
std::string sASName;
|
||||
BYTE* pAP;
|
||||
BYTE* pText;
|
||||
};
|
||||
void WriteAppearance(unsigned int nColor, CAnnotAPView* pView);
|
||||
|
||||
unsigned int m_unRefNum; // Номер ссылки на объект
|
||||
double m_dx1, m_dy1, m_dx2, m_dy2;
|
||||
double m_dWScale, m_dHScale;
|
||||
@ -196,14 +162,36 @@ private:
|
||||
class CAnnot
|
||||
{
|
||||
public:
|
||||
CAnnot(PDFDoc* pdfDoc, AcroFormField* pField);
|
||||
CAnnot(PDFDoc* pdfDoc, Object* oAnnotRef, int nPageIndex);
|
||||
virtual ~CAnnot();
|
||||
|
||||
virtual void ToWASM(NSWasm::CData& oRes);
|
||||
|
||||
protected:
|
||||
CAnnot(PDFDoc* pdfDoc, AcroFormField* pField);
|
||||
CAnnot(PDFDoc* pdfDoc, Object* oAnnotRef, int nPageIndex);
|
||||
|
||||
double m_dHeight; // Высота холста, для Y трансормации
|
||||
|
||||
private:
|
||||
struct CBorderType final
|
||||
{
|
||||
CBorderType()
|
||||
{
|
||||
nType = 5;
|
||||
dWidth = 1;
|
||||
dDashesAlternating = 3;
|
||||
dGaps = 3;
|
||||
}
|
||||
|
||||
void ToWASM(NSWasm::CData& oRes);
|
||||
|
||||
BYTE nType;
|
||||
double dWidth;
|
||||
double dDashesAlternating;
|
||||
double dGaps;
|
||||
};
|
||||
CBorderType* getBorder(Object* oBorder, bool bBSorBorder);
|
||||
|
||||
unsigned int m_unAFlags;
|
||||
unsigned int m_unAnnotFlag; // Флаг аннотации - F
|
||||
unsigned int m_unRefNum; // Номер ссылки на объект
|
||||
@ -224,9 +212,11 @@ private:
|
||||
class CAnnotWidget : public CAnnot
|
||||
{
|
||||
public:
|
||||
CAnnotWidget(PDFDoc* pdfDoc, AcroFormField* pField);
|
||||
virtual ~CAnnotWidget();
|
||||
|
||||
protected:
|
||||
CAnnotWidget(PDFDoc* pdfDoc, AcroFormField* pField);
|
||||
|
||||
virtual void ToWASM(NSWasm::CData& oRes) override;
|
||||
|
||||
unsigned int m_unFlags;
|
||||
@ -321,7 +311,7 @@ private:
|
||||
|
||||
class CMarkupAnnot : public CAnnot
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
CMarkupAnnot(PDFDoc* pdfDoc, Object* oAnnotRef, int nPageIndex);
|
||||
|
||||
virtual void ToWASM(NSWasm::CData& oRes) override;
|
||||
@ -408,6 +398,27 @@ public:
|
||||
void ToWASM(NSWasm::CData& oRes);
|
||||
|
||||
private:
|
||||
struct CAnnotParent final
|
||||
{
|
||||
CAnnotParent()
|
||||
{
|
||||
unFlags = 0;
|
||||
unRefNum = 0;
|
||||
unRefNumParent = 0;
|
||||
}
|
||||
|
||||
void ToWASM(NSWasm::CData& oRes);
|
||||
|
||||
unsigned int unFlags;
|
||||
unsigned int unRefNum; // Номер ссылки на объект
|
||||
unsigned int unRefNumParent; // Номер ссылки на объект родителя
|
||||
std::string sT;
|
||||
std::string sV;
|
||||
std::string sDV;
|
||||
};
|
||||
|
||||
void getParents(XRef* xref, Object* oFieldRef);
|
||||
|
||||
std::vector<std::string> m_arrCO; // Порядок вычислений - CO
|
||||
std::vector<CAnnotParent*> m_arrParents; // Родительские Fields
|
||||
std::vector<CAnnot*> m_arrAnnots;
|
||||
|
||||
@ -212,4 +212,18 @@ namespace PdfWriter
|
||||
pAction->Add("S", "URI");
|
||||
pAction->Add("URI", new CStringObject(sUri));
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// CInkAnnotation
|
||||
//----------------------------------------------------------------------------------------
|
||||
CInkAnnotation::CInkAnnotation(CXref* pXref, const TRect& oRect) : CAnnotation(pXref, AnnotInk, oRect)
|
||||
{
|
||||
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// CLineAnnotation
|
||||
//----------------------------------------------------------------------------------------
|
||||
CLineAnnotation::CLineAnnotation(CXref* pXref, const TRect& oRect) : CAnnotation(pXref, AnnotLine, oRect)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +62,8 @@ namespace PdfWriter
|
||||
AnnotUnderline = 9,
|
||||
AnnotInk = 10,
|
||||
AnnotFileAttachment = 11,
|
||||
AnnotPopup = 12
|
||||
AnnotPopup = 12,
|
||||
AnnotLine = 13
|
||||
};
|
||||
enum EAnnotHighlightMode
|
||||
{
|
||||
@ -131,5 +132,23 @@ namespace PdfWriter
|
||||
return AnnotLink;
|
||||
}
|
||||
};
|
||||
class CInkAnnotation : public CAnnotation
|
||||
{
|
||||
public:
|
||||
CInkAnnotation(CXref* pXref, const TRect& oRect);
|
||||
EAnnotType GetAnnotationType() const
|
||||
{
|
||||
return AnnotInk;
|
||||
}
|
||||
};
|
||||
class CLineAnnotation : public CAnnotation
|
||||
{
|
||||
public:
|
||||
CLineAnnotation(CXref* pXref, const TRect& oRect);
|
||||
EAnnotType GetAnnotationType() const
|
||||
{
|
||||
return AnnotLine;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif // _PDF_WRITER_SRC_ANNOTATION_H
|
||||
|
||||
@ -541,50 +541,21 @@ namespace PdfWriter
|
||||
m_vFillAlpha.push_back(pExtGrState);
|
||||
return pExtGrState;
|
||||
}
|
||||
CAnnotation* CDocument::CreateTextAnnot(unsigned int unPageNum, TRect oRect, const char* sText)
|
||||
CAnnotation* CDocument::CreateTextAnnot(CPage* pPage, const TRect& oRect, const char* sText)
|
||||
{
|
||||
CAnnotation* pAnnot = new CTextAnnotation(m_pXref, oRect, sText);
|
||||
if (pAnnot)
|
||||
{
|
||||
CPage* pPage = m_pPageTree->GetPage(unPageNum);
|
||||
if (pPage)
|
||||
pPage->AddAnnotation(pAnnot);
|
||||
}
|
||||
|
||||
return pAnnot;
|
||||
}
|
||||
CAnnotation* CDocument::CreateLinkAnnot(const unsigned int& unPageNum, const TRect& oRect, CDestination* pDest)
|
||||
{
|
||||
CAnnotation* pAnnot = new CLinkAnnotation(m_pXref, oRect, pDest);
|
||||
|
||||
if (pAnnot)
|
||||
{
|
||||
CPage* pPage = m_pPageTree->GetPage(unPageNum);
|
||||
if (pPage)
|
||||
pPage->AddAnnotation(pAnnot);
|
||||
}
|
||||
|
||||
return pAnnot;
|
||||
}
|
||||
CAnnotation* CDocument::CreateLinkAnnot(CPage* pPage, const TRect& oRect, CDestination* pDest)
|
||||
{
|
||||
CAnnotation* pAnnot = new CLinkAnnotation(m_pXref, oRect, pDest);
|
||||
|
||||
if (pAnnot)
|
||||
if (pAnnot && pPage)
|
||||
pPage->AddAnnotation(pAnnot);
|
||||
|
||||
return pAnnot;
|
||||
}
|
||||
CAnnotation* CDocument::CreateUriLinkAnnot(const unsigned int& unPageNum, const TRect& oRect, const char* sUri)
|
||||
CAnnotation* CDocument::CreateLinkAnnot(CPage* pPage, const TRect& oRect, CDestination* pDest)
|
||||
{
|
||||
CAnnotation* pAnnot = new CUriLinkAnnotation(m_pXref, oRect, sUri);
|
||||
|
||||
if (pAnnot)
|
||||
{
|
||||
CPage* pPage = m_pPageTree->GetPage(unPageNum);
|
||||
if (pPage)
|
||||
pPage->AddAnnotation(pAnnot);
|
||||
}
|
||||
CAnnotation* pAnnot = new CLinkAnnotation(m_pXref, oRect, pDest);
|
||||
|
||||
if (pAnnot && pPage)
|
||||
pPage->AddAnnotation(pAnnot);
|
||||
|
||||
return pAnnot;
|
||||
}
|
||||
@ -592,7 +563,25 @@ namespace PdfWriter
|
||||
{
|
||||
CAnnotation* pAnnot = new CUriLinkAnnotation(m_pXref, oRect, sUrl);
|
||||
|
||||
if (pAnnot)
|
||||
if (pAnnot && pPage)
|
||||
pPage->AddAnnotation(pAnnot);
|
||||
|
||||
return pAnnot;
|
||||
}
|
||||
CAnnotation* CDocument::CreateInkAnnot(CPage* pPage, const TRect& oRect)
|
||||
{
|
||||
CAnnotation* pAnnot = new CInkAnnotation(m_pXref, oRect);
|
||||
|
||||
if (pAnnot && pPage)
|
||||
pPage->AddAnnotation(pAnnot);
|
||||
|
||||
return pAnnot;
|
||||
}
|
||||
CAnnotation* CDocument::CreateLineAnnot(CPage* pPage, const TRect& oRect)
|
||||
{
|
||||
CAnnotation* pAnnot = new CLineAnnotation(m_pXref, oRect);
|
||||
|
||||
if (pAnnot && pPage)
|
||||
pPage->AddAnnotation(pAnnot);
|
||||
|
||||
return pAnnot;
|
||||
|
||||
@ -129,11 +129,11 @@ namespace PdfWriter
|
||||
CExtGrState* GetFillAlpha(double dAlpha);
|
||||
CJbig2Global* GetJbig2Global();
|
||||
|
||||
CAnnotation* CreateTextAnnot(unsigned int unPageNum, TRect oRect, const char* sText);
|
||||
CAnnotation* CreateLinkAnnot(const unsigned int& unPageNum, const TRect& oRect, CDestination* pDest);
|
||||
CAnnotation* CreateLinkAnnot(CPage* pPage, const TRect& oRect, CDestination* pDest);
|
||||
CAnnotation* CreateUriLinkAnnot(const unsigned int& unPageNum, const TRect& oRect, const char* sUri);
|
||||
CAnnotation* CreateTextAnnot (CPage* pPage, const TRect& oRect, const char* sText);
|
||||
CAnnotation* CreateLinkAnnot (CPage* pPage, const TRect& oRect, CDestination* pDest);
|
||||
CAnnotation* CreateUriLinkAnnot(CPage* pPage, const TRect& oRect, const char* sUrl);
|
||||
CAnnotation* CreateInkAnnot (CPage* pPage, const TRect& oRect);
|
||||
CAnnotation* CreateLineAnnot (CPage* pPage, const TRect& oRect);
|
||||
|
||||
CImageDict* CreateImage();
|
||||
CFont14* CreateFont14(EStandard14Fonts eType);
|
||||
|
||||
Reference in New Issue
Block a user