Write Redact

This commit is contained in:
Svetlana Kulikova
2025-07-21 16:09:12 +03:00
parent f45b3ba0da
commit 3b4097310b
6 changed files with 196 additions and 1 deletions

View File

@ -76,6 +76,7 @@ CAnnotFieldInfo::CAnnotFieldInfo() : IAdvancedCommand(AdvancedCommandType::Annot
m_pFreeTextPr = NULL;
m_pCaretPr = NULL;
m_pStampPr = NULL;
m_pRedactPr = NULL;
m_pWidgetPr = NULL;
}
CAnnotFieldInfo::~CAnnotFieldInfo()
@ -91,6 +92,7 @@ CAnnotFieldInfo::~CAnnotFieldInfo()
RELEASEOBJECT(m_pFreeTextPr);
RELEASEOBJECT(m_pCaretPr);
RELEASEOBJECT(m_pStampPr);
RELEASEOBJECT(m_pRedactPr);
RELEASEOBJECT(m_pWidgetPr);
}
@ -178,6 +180,13 @@ void CAnnotFieldInfo::SetType(int nType)
m_pPopupPr = new CAnnotFieldInfo::CPopupAnnotPr();
break;
}
case EAnnotType::Redact:
{
CreateMarkup();
RELEASEOBJECT(m_pRedactPr);
m_pRedactPr = new CAnnotFieldInfo::CRedactAnnotPr();
break;
}
case EAnnotType::Widget:
case EAnnotType::WidgetPushButton:
case EAnnotType::WidgetRadioButton:
@ -291,6 +300,10 @@ bool CAnnotFieldInfo::IsStamp() const
{
return (m_nType == 12);
}
bool CAnnotFieldInfo::IsRedact() const
{
return (m_nType == 25);
}
CAnnotFieldInfo::CMarkupAnnotPr* CAnnotFieldInfo::GetMarkupAnnotPr() { return m_pMarkupPr; }
CAnnotFieldInfo::CTextAnnotPr* CAnnotFieldInfo::GetTextAnnotPr() { return m_pTextPr; }
@ -303,6 +316,7 @@ CAnnotFieldInfo::CPopupAnnotPr* CAnnotFieldInfo::GetPopupAnnotPr()
CAnnotFieldInfo::CFreeTextAnnotPr* CAnnotFieldInfo::GetFreeTextAnnotPr() { return m_pFreeTextPr; }
CAnnotFieldInfo::CCaretAnnotPr* CAnnotFieldInfo::GetCaretAnnotPr() { return m_pCaretPr; }
CAnnotFieldInfo::CStampAnnotPr* CAnnotFieldInfo::GetStampAnnotPr() { return m_pStampPr; }
CAnnotFieldInfo::CRedactAnnotPr* CAnnotFieldInfo::GetRedactAnnotPr() { return m_pRedactPr; }
CAnnotFieldInfo::CWidgetAnnotPr* CAnnotFieldInfo::GetWidgetAnnotPr() { return m_pWidgetPr; }
bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
@ -388,6 +402,8 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
m_pCaretPr->Read(pReader, nFlags);
else if (IsStamp())
m_pStampPr->Read(pReader, nFlags);
else if (IsRedact())
m_pRedactPr->Read(pReader, nFlags);
}
else if (IsPopup())
m_pPopupPr->Read(pReader);
@ -662,6 +678,46 @@ void CAnnotFieldInfo::CStampAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader*
m_dInRect[3] = pReader->ReadDouble();
}
BYTE CAnnotFieldInfo::CRedactAnnotPr::GetQ() const { return m_nQ; }
int CAnnotFieldInfo::CRedactAnnotPr::GetFontStyle() const { return m_nFontStyle; }
double CAnnotFieldInfo::CRedactAnnotPr::GetFontSize() const { return m_dFS; }
const std::wstring& CAnnotFieldInfo::CRedactAnnotPr::GetFontName() { return m_wsFN; }
const std::wstring& CAnnotFieldInfo::CRedactAnnotPr::GetOverlayText() { return m_wsOverlayText; }
const std::vector<double>& CAnnotFieldInfo::CRedactAnnotPr::GetIC() { return m_arrIC; }
const std::vector<double>& CAnnotFieldInfo::CRedactAnnotPr::GetFontColor() { return m_arrFC; }
const std::vector<double>& CAnnotFieldInfo::CRedactAnnotPr::GetQuadPoints() { return m_arrQuadPoints; }
void CAnnotFieldInfo::CRedactAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags)
{
if (nFlags & (1 << 15))
{
int n = pReader->ReadInt();
m_arrQuadPoints.reserve(n);
for (int i = 0; i < n; ++i)
m_arrQuadPoints.push_back(pReader->ReadDouble());
}
if (nFlags & (1 << 16))
{
int n = pReader->ReadInt();
m_arrIC.reserve(n);
for (int i = 0; i < n; ++i)
m_arrIC.push_back(pReader->ReadDouble());
}
if (nFlags & (1 << 17))
m_wsOverlayText = pReader->ReadString();
if (nFlags & (1 << 19))
m_nQ = pReader->ReadByte();
if (nFlags & (1 << 20))
{
int n = pReader->ReadInt();
m_arrFC.reserve(n);
for (int i = 0; i < n; ++i)
m_arrFC.push_back(pReader->ReadDouble());
m_dFS = pReader->ReadDouble();
m_wsFN = pReader->ReadString();
m_nFontStyle = pReader->ReadInt();
}
}
bool CAnnotFieldInfo::CPopupAnnotPr::IsOpen() const { return m_bOpen; }
int CAnnotFieldInfo::CPopupAnnotPr::GetFlag() const { return m_nFlag; }
int CAnnotFieldInfo::CPopupAnnotPr::GetParentID() const { return m_nParentID; }

View File

@ -59,6 +59,7 @@ public:
Ink = 14,
Popup = 15,
FileAttachment = 16,
Redact = 25,
Widget = 26,
WidgetPushButton = 27,
WidgetRadioButton = 28,
@ -452,6 +453,31 @@ public:
double m_dInRect[4]{};
};
class GRAPHICS_DECL CRedactAnnotPr
{
public:
BYTE GetQ() const;
int GetFontStyle() const;
double GetFontSize() const;
const std::wstring& GetFontName();
const std::wstring& GetOverlayText();
const std::vector<double>& GetIC();
const std::vector<double>& GetFontColor();
const std::vector<double>& GetQuadPoints();
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags);
private:
BYTE m_nQ;
int m_nFontStyle;
double m_dFS;
std::wstring m_wsFN;
std::wstring m_wsOverlayText;
std::vector<double> m_arrIC;
std::vector<double> m_arrFC;
std::vector<double> m_arrQuadPoints;
};
CAnnotFieldInfo();
virtual ~CAnnotFieldInfo();
@ -490,6 +516,7 @@ public:
bool IsFreeText() const;
bool IsCaret() const;
bool IsStamp() const;
bool IsRedact() const;
CMarkupAnnotPr* GetMarkupAnnotPr();
CTextAnnotPr* GetTextAnnotPr();
@ -502,6 +529,7 @@ public:
CFreeTextAnnotPr* GetFreeTextAnnotPr();
CCaretAnnotPr* GetCaretAnnotPr();
CStampAnnotPr* GetStampAnnotPr();
CRedactAnnotPr* GetRedactAnnotPr();
CWidgetAnnotPr* GetWidgetAnnotPr();
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
@ -545,6 +573,7 @@ private:
CFreeTextAnnotPr* m_pFreeTextPr;
CCaretAnnotPr* m_pCaretPr;
CStampAnnotPr* m_pStampPr;
CRedactAnnotPr* m_pRedactPr;
CWidgetAnnotPr* m_pWidgetPr;
};