mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Writer Polygon, PolyLine annots
This commit is contained in:
@ -59,6 +59,7 @@ CAnnotFieldInfo::CAnnotFieldInfo()
|
||||
m_pLinePr = NULL;
|
||||
m_pTextMarkupPr = NULL;
|
||||
m_pSquareCirclePr = NULL;
|
||||
m_pPolygonLinePr = NULL;
|
||||
m_pPopupPr = NULL;
|
||||
}
|
||||
CAnnotFieldInfo::~CAnnotFieldInfo()
|
||||
@ -69,6 +70,7 @@ CAnnotFieldInfo::~CAnnotFieldInfo()
|
||||
RELEASEOBJECT(m_pLinePr);
|
||||
RELEASEOBJECT(m_pTextMarkupPr);
|
||||
RELEASEOBJECT(m_pSquareCirclePr);
|
||||
RELEASEOBJECT(m_pPolygonLinePr);
|
||||
RELEASEOBJECT(m_pPopupPr);
|
||||
}
|
||||
|
||||
@ -111,6 +113,18 @@ void CAnnotFieldInfo::SetType(int nType)
|
||||
m_pSquareCirclePr = new CAnnotFieldInfo::CSquareCircleAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
case 7:
|
||||
{
|
||||
m_nType = 12;
|
||||
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
RELEASEOBJECT(m_pPolygonLinePr);
|
||||
m_pPolygonLinePr = new CAnnotFieldInfo::CPolygonLineAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
@ -209,6 +223,10 @@ bool CAnnotFieldInfo::IsSquareCircle() const
|
||||
{
|
||||
return (m_nType == 11);
|
||||
}
|
||||
bool CAnnotFieldInfo::IsPolygonLine() const
|
||||
{
|
||||
return (m_nType == 12);
|
||||
}
|
||||
bool CAnnotFieldInfo::IsPopup() const
|
||||
{
|
||||
return (m_nType == 24);
|
||||
|
||||
@ -183,6 +183,29 @@ public:
|
||||
std::vector<double> m_arrIC;
|
||||
};
|
||||
|
||||
class CPolygonLineAnnotPr
|
||||
{
|
||||
public:
|
||||
void SetIT(const BYTE& nIT) { m_nIT = nIT; }
|
||||
void SetSubtype(const BYTE& nSubtype) { m_nSubtype = nSubtype; }
|
||||
void SetLE(const BYTE& nLE1, const BYTE& nLE2) { m_nLE[0] = nLE1; m_nLE[1] = nLE2; }
|
||||
void SetIC(const std::vector<double>& arrIC) { m_arrIC = arrIC; }
|
||||
void SetVertices(const std::vector<double>& arrVertices) { m_arrVertices = arrVertices; }
|
||||
|
||||
BYTE GetIT() const { return m_nIT; }
|
||||
BYTE GetSubtype() const { return m_nSubtype; }
|
||||
void GetLE(BYTE& nLE1, BYTE& nLE2) const { nLE1 = m_nLE[0]; nLE2 = m_nLE[1]; }
|
||||
const std::vector<double>& GetIC() const { return m_arrIC; }
|
||||
const std::vector<double>& GetVertices() const { return m_arrVertices; }
|
||||
|
||||
private:
|
||||
BYTE m_nIT;
|
||||
BYTE m_nSubtype;
|
||||
BYTE m_nLE[2];
|
||||
std::vector<double> m_arrIC;
|
||||
std::vector<double> m_arrVertices;
|
||||
};
|
||||
|
||||
class CPopupAnnotPr
|
||||
{
|
||||
public:
|
||||
@ -243,6 +266,7 @@ public:
|
||||
bool IsLine() const;
|
||||
bool IsTextMarkup() const;
|
||||
bool IsSquareCircle() const;
|
||||
bool IsPolygonLine() const;
|
||||
bool IsPopup() const;
|
||||
|
||||
CMarkupAnnotPr* GetMarkupAnnotPr() { return m_pMarkupPr; }
|
||||
@ -251,6 +275,7 @@ public:
|
||||
CLineAnnotPr* GetLineAnnotPr() { return m_pLinePr; }
|
||||
CTextMarkupAnnotPr* GetTextMarkupAnnotPr() { return m_pTextMarkupPr; }
|
||||
CSquareCircleAnnotPr* GetSquareCircleAnnotPr() { return m_pSquareCirclePr; }
|
||||
CPolygonLineAnnotPr* GetPolygonLineAnnotPr() { return m_pPolygonLinePr; }
|
||||
CPopupAnnotPr* GetPopupAnnotPr() { return m_pPopupPr; }
|
||||
|
||||
protected:
|
||||
@ -276,6 +301,7 @@ private:
|
||||
CLineAnnotPr* m_pLinePr;
|
||||
CTextMarkupAnnotPr* m_pTextMarkupPr;
|
||||
CSquareCircleAnnotPr* m_pSquareCirclePr;
|
||||
CPolygonLineAnnotPr* m_pPolygonLinePr;
|
||||
CPopupAnnotPr* m_pPopupPr;
|
||||
};
|
||||
|
||||
|
||||
@ -1409,6 +1409,34 @@ namespace NSOnlineOfficeBinToPdf
|
||||
pPr->SetIC(arrIC);
|
||||
}
|
||||
}
|
||||
else if (oInfo.IsPolygonLine())
|
||||
{
|
||||
CAnnotFieldInfo::CPolygonLineAnnotPr* pPr = oInfo.GetPolygonLineAnnotPr();
|
||||
|
||||
int n = ReadInt(current, curindex);
|
||||
std::vector<double> arrVertices;
|
||||
for (int i = 0; i < n; ++i)
|
||||
arrVertices.push_back(ReadDouble(current, curindex));
|
||||
pPr->SetVertices(arrVertices);
|
||||
|
||||
pPr->SetSubtype(nType);
|
||||
if (nFlags & (1 << 15))
|
||||
{
|
||||
BYTE nLE1 = ReadByte(current, curindex);
|
||||
BYTE nLE2 = ReadByte(current, curindex);
|
||||
pPr->SetLE(nLE1, nLE2);
|
||||
}
|
||||
if (nFlags & (1 << 16))
|
||||
{
|
||||
int n = ReadInt(current, curindex);
|
||||
std::vector<double> arrIC;
|
||||
for (int i = 0; i < n; ++i)
|
||||
arrIC.push_back(ReadDouble(current, curindex));
|
||||
pPr->SetIC(arrIC);
|
||||
}
|
||||
if (nFlags & (1 << 20))
|
||||
pPr->SetIT(ReadByte(current, curindex));
|
||||
}
|
||||
else if (oInfo.IsPopup())
|
||||
{
|
||||
CAnnotFieldInfo::CPopupAnnotPr* pPr = oInfo.GetPopupAnnotPr();
|
||||
|
||||
@ -1711,6 +1711,10 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, IAnnotF
|
||||
{
|
||||
pAnnot = m_pDocument->CreateSquareCircleAnnot();
|
||||
}
|
||||
else if (oInfo.IsPolygonLine())
|
||||
{
|
||||
pAnnot = m_pDocument->CreatePolygonLineAnnot();
|
||||
}
|
||||
else if (oInfo.IsPopup())
|
||||
{
|
||||
pAnnot = m_pDocument->CreatePopupAnnot();
|
||||
@ -1849,6 +1853,24 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, IAnnotF
|
||||
if (nFlags & (1 << 16))
|
||||
pSquareCircleAnnot->SetIC(pPr->GetIC());
|
||||
}
|
||||
else if (oInfo.IsPolygonLine())
|
||||
{
|
||||
CAnnotFieldInfo::CPolygonLineAnnotPr* pPr = oInfo.GetPolygonLineAnnotPr();
|
||||
PdfWriter::CPolygonLineAnnotation* pPolygonLineAnnot = (PdfWriter::CPolygonLineAnnotation*)pAnnot;
|
||||
|
||||
pPolygonLineAnnot->SetVertices(pPr->GetVertices());
|
||||
pPolygonLineAnnot->SetSubtype(pPr->GetSubtype());
|
||||
if (nFlags & (1 << 15))
|
||||
{
|
||||
BYTE nLE1, nLE2;
|
||||
pPr->GetLE(nLE1, nLE2);
|
||||
pPolygonLineAnnot->SetLE(nLE1, nLE2);
|
||||
}
|
||||
if (nFlags & (1 << 16))
|
||||
pPolygonLineAnnot->SetIC(pPr->GetIC());
|
||||
if (nFlags & (1 << 20))
|
||||
pPolygonLineAnnot->SetIT(pPr->GetIT());
|
||||
}
|
||||
else if (oInfo.IsPopup())
|
||||
{
|
||||
CAnnotFieldInfo::CPopupAnnotPr* pPr = oInfo.GetPopupAnnotPr();
|
||||
|
||||
@ -57,7 +57,9 @@ namespace PdfWriter
|
||||
"FileAttachment",
|
||||
"Popup",
|
||||
"Line",
|
||||
"Squiggly"
|
||||
"Squiggly",
|
||||
"Polygon",
|
||||
"PolyLine"
|
||||
};
|
||||
const static char* c_sAnnotIconNames[] =
|
||||
{
|
||||
@ -449,7 +451,7 @@ namespace PdfWriter
|
||||
if (!pArray)
|
||||
return;
|
||||
|
||||
Add("L", pArray);
|
||||
Add("LE", pArray);
|
||||
|
||||
AddLE(pArray, nLE1);
|
||||
AddLE(pArray, nLE2);
|
||||
@ -582,4 +584,64 @@ namespace PdfWriter
|
||||
{
|
||||
AddIC(this, arrIC);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// CPolygonLineAnnotation
|
||||
//----------------------------------------------------------------------------------------
|
||||
CPolygonLineAnnotation::CPolygonLineAnnotation(CXref* pXref) : CMarkupAnnotation(pXref, AnnotSquare)
|
||||
{
|
||||
m_nSubtype = AnnotPolygon;
|
||||
}
|
||||
void CPolygonLineAnnotation::SetIT(const BYTE& nIT)
|
||||
{
|
||||
std::string sValue;
|
||||
switch (nIT)
|
||||
{
|
||||
case 0:
|
||||
{ sValue = "PolygonCloud"; break; }
|
||||
case 1:
|
||||
{ sValue = "PolyLineDimension"; break; }
|
||||
case 2:
|
||||
{ sValue = "PolygonDimension"; break; }
|
||||
}
|
||||
|
||||
Add("IT", new CStringObject(sValue.c_str()));
|
||||
}
|
||||
void CPolygonLineAnnotation::SetSubtype(const BYTE& nSubtype)
|
||||
{
|
||||
switch (nSubtype)
|
||||
{
|
||||
case 6:
|
||||
{ m_nSubtype = AnnotPolygon; break; }
|
||||
case 7:
|
||||
{ m_nSubtype = AnnotPolyLine; break; }
|
||||
}
|
||||
|
||||
Add("Subtype", c_sAnnotTypeNames[(int)m_nSubtype]);
|
||||
}
|
||||
void CPolygonLineAnnotation::SetLE(const BYTE& nLE1, const BYTE& nLE2)
|
||||
{
|
||||
CArrayObject* pArray = new CArrayObject();
|
||||
if (!pArray)
|
||||
return;
|
||||
|
||||
Add("LE", pArray);
|
||||
|
||||
AddLE(pArray, nLE1);
|
||||
AddLE(pArray, nLE2);
|
||||
}
|
||||
void CPolygonLineAnnotation::SetIC(const std::vector<double>& arrIC)
|
||||
{
|
||||
AddIC(this, arrIC);
|
||||
}
|
||||
void CPolygonLineAnnotation::SetVertices(const std::vector<double>& arrVertices)
|
||||
{
|
||||
CArrayObject* pArray = new CArrayObject();
|
||||
if (!pArray)
|
||||
return;
|
||||
|
||||
Add("Vertices", pArray);
|
||||
|
||||
for (const double& dVertices : arrVertices)
|
||||
pArray->Add(dVertices);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,9 @@ namespace PdfWriter
|
||||
AnnotFileAttachment = 11,
|
||||
AnnotPopup = 12,
|
||||
AnnotLine = 13,
|
||||
AnnotSquiggly = 14
|
||||
AnnotSquiggly = 14,
|
||||
AnnotPolygon = 15,
|
||||
AnnotPolyLine = 16
|
||||
};
|
||||
enum EAnnotHighlightMode
|
||||
{
|
||||
@ -268,5 +270,22 @@ namespace PdfWriter
|
||||
void SetRD(const double& dRD1, const double& dRD2, const double& dRD3, const double& dRD4);
|
||||
void SetIC(const std::vector<double>& arrIC);
|
||||
};
|
||||
class CPolygonLineAnnotation : public CMarkupAnnotation
|
||||
{
|
||||
private:
|
||||
EAnnotType m_nSubtype;
|
||||
public:
|
||||
CPolygonLineAnnotation(CXref* pXref);
|
||||
EAnnotType GetAnnotationType() const override
|
||||
{
|
||||
return m_nSubtype;
|
||||
}
|
||||
|
||||
void SetIT(const BYTE& nIT);
|
||||
void SetSubtype(const BYTE& nSubtype);
|
||||
void SetLE(const BYTE& nLE1, const BYTE& nLE2);
|
||||
void SetIC(const std::vector<double>& arrIC);
|
||||
void SetVertices(const std::vector<double>& arrVertices);
|
||||
};
|
||||
}
|
||||
#endif // _PDF_WRITER_SRC_ANNOTATION_H
|
||||
|
||||
@ -573,6 +573,10 @@ namespace PdfWriter
|
||||
{
|
||||
return new CSquareCircleAnnotation(m_pXref);
|
||||
}
|
||||
CAnnotation* CDocument::CreatePolygonLineAnnot()
|
||||
{
|
||||
return new CPolygonLineAnnotation(m_pXref);
|
||||
}
|
||||
CAnnotation* CDocument::CreatePopupAnnot()
|
||||
{
|
||||
return new CPopupAnnotation(m_pXref);
|
||||
|
||||
@ -136,6 +136,7 @@ namespace PdfWriter
|
||||
CAnnotation* CreateLineAnnot();
|
||||
CAnnotation* CreateTextMarkupAnnot();
|
||||
CAnnotation* CreateSquareCircleAnnot();
|
||||
CAnnotation* CreatePolygonLineAnnot();
|
||||
CAnnotation* CreatePopupAnnot();
|
||||
void AddAnnotation(const int& nID, CAnnotation* pAnnot);
|
||||
void MatchAnnotation();
|
||||
|
||||
Reference in New Issue
Block a user