mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Copy AP
This commit is contained in:
@ -224,6 +224,7 @@ int CAnnotFieldInfo::GetFlag() const { return m_nFlag; }
|
|||||||
int CAnnotFieldInfo::GetID() const { return m_nID; }
|
int CAnnotFieldInfo::GetID() const { return m_nID; }
|
||||||
int CAnnotFieldInfo::GetAnnotFlag() const { return m_nAnnotFlag; }
|
int CAnnotFieldInfo::GetAnnotFlag() const { return m_nAnnotFlag; }
|
||||||
int CAnnotFieldInfo::GetPage() const { return m_nPage; }
|
int CAnnotFieldInfo::GetPage() const { return m_nPage; }
|
||||||
|
int CAnnotFieldInfo::GetCopyAP() const { return m_nCopyAP; }
|
||||||
void CAnnotFieldInfo::GetBE(BYTE& nS, double& dI) { nS = m_pBE.first; dI = m_pBE.second; }
|
void CAnnotFieldInfo::GetBE(BYTE& nS, double& dI) { nS = m_pBE.first; dI = m_pBE.second; }
|
||||||
BYTE* CAnnotFieldInfo::GetRender(LONG& nLen)
|
BYTE* CAnnotFieldInfo::GetRender(LONG& nLen)
|
||||||
{
|
{
|
||||||
@ -367,6 +368,8 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
|||||||
}
|
}
|
||||||
if (nFlags & (1 << 7))
|
if (nFlags & (1 << 7))
|
||||||
m_wsOUserID = pReader->ReadString();
|
m_wsOUserID = pReader->ReadString();
|
||||||
|
if (nFlags & (1 << 8))
|
||||||
|
m_nCopyAP = pReader->ReadInt();
|
||||||
|
|
||||||
if (IsMarkup())
|
if (IsMarkup())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -431,6 +431,7 @@ public:
|
|||||||
int GetID() const;
|
int GetID() const;
|
||||||
int GetAnnotFlag() const;
|
int GetAnnotFlag() const;
|
||||||
int GetPage() const;
|
int GetPage() const;
|
||||||
|
int GetCopyAP() const;
|
||||||
void GetBE(BYTE& nS, double& dI);
|
void GetBE(BYTE& nS, double& dI);
|
||||||
BYTE* GetRender(LONG& nLen);
|
BYTE* GetRender(LONG& nLen);
|
||||||
const std::wstring& GetNM();
|
const std::wstring& GetNM();
|
||||||
@ -488,6 +489,7 @@ private:
|
|||||||
int m_nID;
|
int m_nID;
|
||||||
int m_nAnnotFlag;
|
int m_nAnnotFlag;
|
||||||
int m_nPage;
|
int m_nPage;
|
||||||
|
int m_nCopyAP;
|
||||||
std::wstring m_wsNM;
|
std::wstring m_wsNM;
|
||||||
std::wstring m_wsLM;
|
std::wstring m_wsLM;
|
||||||
std::wstring m_wsOUserID;
|
std::wstring m_wsOUserID;
|
||||||
|
|||||||
@ -1231,7 +1231,15 @@ HRESULT CPdfFile::AdvancedCommand(IAdvancedCommand* command)
|
|||||||
{
|
{
|
||||||
CAnnotFieldInfo* pCommand = (CAnnotFieldInfo*)command;
|
CAnnotFieldInfo* pCommand = (CAnnotFieldInfo*)command;
|
||||||
if (m_pInternal->pEditor && m_pInternal->pEditor->IsEditPage())
|
if (m_pInternal->pEditor && m_pInternal->pEditor->IsEditPage())
|
||||||
|
{
|
||||||
m_pInternal->pEditor->EditAnnot(pCommand->GetPage(), pCommand->GetID());
|
m_pInternal->pEditor->EditAnnot(pCommand->GetPage(), pCommand->GetID());
|
||||||
|
if (pCommand->IsStamp())
|
||||||
|
{
|
||||||
|
int nFlags = pCommand->GetMarkupAnnotPr()->GetFlag();
|
||||||
|
if (nFlags & (1 << 15))
|
||||||
|
m_pInternal->pEditor->EditAnnot(pCommand->GetPage(), pCommand->GetCopyAP());
|
||||||
|
}
|
||||||
|
}
|
||||||
return m_pInternal->pWriter->AddAnnotField(m_pInternal->pAppFonts, pCommand);
|
return m_pInternal->pWriter->AddAnnotField(m_pInternal->pAppFonts, pCommand);
|
||||||
}
|
}
|
||||||
case IAdvancedCommand::AdvancedCommandType::DeleteAnnot:
|
case IAdvancedCommand::AdvancedCommandType::DeleteAnnot:
|
||||||
|
|||||||
@ -1810,6 +1810,7 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
|
|||||||
bool bRender = (nFlags >> 6) & 1;
|
bool bRender = (nFlags >> 6) & 1;
|
||||||
if (nFlags & (1 << 7))
|
if (nFlags & (1 << 7))
|
||||||
pAnnot->SetOUserID(oInfo.GetOUserID());
|
pAnnot->SetOUserID(oInfo.GetOUserID());
|
||||||
|
bool bRenderCopy = (nFlags >> 8) & 1;
|
||||||
|
|
||||||
if (oInfo.IsMarkup())
|
if (oInfo.IsMarkup())
|
||||||
{
|
{
|
||||||
@ -2102,7 +2103,6 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
|
|||||||
|
|
||||||
if (bRender)
|
if (bRender)
|
||||||
{
|
{
|
||||||
pMarkupAnnot->RemoveAP();
|
|
||||||
LONG nLen = 0;
|
LONG nLen = 0;
|
||||||
BYTE* pRender = oInfo.GetRender(nLen);
|
BYTE* pRender = oInfo.GetRender(nLen);
|
||||||
PdfWriter::CAnnotAppearanceObject* pAP = DrawAP(pAnnot, pRender, nLen);
|
PdfWriter::CAnnotAppearanceObject* pAP = DrawAP(pAnnot, pRender, nLen);
|
||||||
@ -2117,6 +2117,17 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
|
|||||||
pArray->Add(MM_2_PT(m_dPageHeight) - dRD2);
|
pArray->Add(MM_2_PT(m_dPageHeight) - dRD2);
|
||||||
pStampAnnot->SetAPStream(pAP);
|
pStampAnnot->SetAPStream(pAP);
|
||||||
}
|
}
|
||||||
|
else if (bRenderCopy)
|
||||||
|
{
|
||||||
|
int nID = oInfo.GetCopyAP();
|
||||||
|
PdfWriter::CAnnotation* pAnnot2 = m_pDocument->GetAnnot(nID);
|
||||||
|
if (pAnnot2->GetAnnotationType() == PdfWriter::EAnnotType::AnnotStamp)
|
||||||
|
{
|
||||||
|
PdfWriter::CStampAnnotation* pStampAnnot2 = (PdfWriter::CStampAnnotation*)pAnnot2;
|
||||||
|
PdfWriter::CDictObject* pAPN = (PdfWriter::CDictObject*)pStampAnnot2->GetAPStream();
|
||||||
|
pStampAnnot->SetAPStream(pAPN, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pStampAnnot->SetRotate(nRotate);
|
pStampAnnot->SetRotate(nRotate);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1442,10 +1442,27 @@ namespace PdfWriter
|
|||||||
std::string sValue = U_TO_UTF8(wsName);
|
std::string sValue = U_TO_UTF8(wsName);
|
||||||
Add("Name", sValue.c_str());
|
Add("Name", sValue.c_str());
|
||||||
}
|
}
|
||||||
void CStampAnnotation::SetAPStream(CDictObject* pStream)
|
void CStampAnnotation::SetAPStream(CDictObject* pStream, bool bCopy)
|
||||||
{
|
{
|
||||||
|
if (bCopy)
|
||||||
|
{
|
||||||
|
CDictObject* pStreamNew = (CDictObject*)pStream->Copy();
|
||||||
|
CStream* pStr = new CMemoryStream();
|
||||||
|
pStreamNew->SetStream(m_pXref, pStr, true);
|
||||||
|
pStr->WriteStream(pStream->GetStream(), 0, NULL);
|
||||||
|
pStreamNew->SetFilter(STREAM_FILTER_FLATE_DECODE);
|
||||||
|
pStream = pStreamNew;
|
||||||
|
|
||||||
|
CDictObject* pAP = new PdfWriter::CDictObject();
|
||||||
|
Add("AP", pAP);
|
||||||
|
pAP->Add("N", pStreamNew);
|
||||||
|
}
|
||||||
m_pAPStream = pStream;
|
m_pAPStream = pStream;
|
||||||
}
|
}
|
||||||
|
CDictObject* CStampAnnotation::GetAPStream()
|
||||||
|
{
|
||||||
|
return m_pAPStream;
|
||||||
|
}
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
// CWidgetAnnotation
|
// CWidgetAnnotation
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -400,7 +400,9 @@ namespace PdfWriter
|
|||||||
|
|
||||||
void SetRotate(double nRotate);
|
void SetRotate(double nRotate);
|
||||||
void SetName(const std::wstring& wsName);
|
void SetName(const std::wstring& wsName);
|
||||||
void SetAPStream(CDictObject* pStream);
|
void SetAPStream(CDictObject* pStream, bool bCopy = false);
|
||||||
|
|
||||||
|
CDictObject* GetAPStream();
|
||||||
};
|
};
|
||||||
class CWidgetAnnotation : public CAnnotation
|
class CWidgetAnnotation : public CAnnotation
|
||||||
{
|
{
|
||||||
|
|||||||
@ -669,7 +669,7 @@ namespace PdfWriter
|
|||||||
pXref->Add((CObjectBase*)this);
|
pXref->Add((CObjectBase*)this);
|
||||||
pXref->Add((CObjectBase*)pLength);
|
pXref->Add((CObjectBase*)pLength);
|
||||||
|
|
||||||
Add("Length", (CObjectBase*)pLength);
|
Add("Length", pLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pStream = pStream;
|
m_pStream = pStream;
|
||||||
|
|||||||
Reference in New Issue
Block a user