Fix old server

This commit is contained in:
Svetlana Kulikova
2024-10-28 18:06:04 +03:00
parent 492b821472
commit b80ada4b4e
3 changed files with 50 additions and 29 deletions

View File

@ -2104,19 +2104,6 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
double dFontSize = pPr->GetFontSizeAP();
PdfWriter::CFontTrueType* pFontTT = NULL;
if (nWidgetType == 27)
{
put_FontName(wsFontName);
put_FontStyle(nStyle);
put_FontSize(dFontSize);
if (m_bNeedUpdateTextFont)
UpdateFont();
if (m_pFont)
pFontTT = m_pDocument->CreateTrueTypeFont(m_pFont);
pWidgetAnnot->SetDA(pFontTT, pPr->GetFontSize(), dFontSize, pPr->GetTC());
}
BYTE nAlign = pPr->GetQ();
if (nWidgetType != 27 && nWidgetType != 28 && nWidgetType != 29)
pWidgetAnnot->SetQ(nAlign);
@ -2292,6 +2279,16 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
if (nIFFlags & (1 << 7))
pButtonWidget->SetIX(pPr->GetIX());
put_FontName(wsFontName);
put_FontStyle(nStyle);
put_FontSize(dFontSize);
if (m_bNeedUpdateTextFont)
UpdateFont();
if (m_pFont)
pFontTT = m_pDocument->CreateTrueTypeFont(m_pFont);
pWidgetAnnot->SetDA(pFontTT, oInfo.GetWidgetAnnotPr()->GetFontSize(), dFontSize, oInfo.GetWidgetAnnotPr()->GetTC());
// ВНЕШНИЙ ВИД
pButtonWidget->SetFont(m_pFont, dFontSize, isBold, isItalic);
if (nFlags & (1 << 10))
@ -2338,9 +2335,12 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
return S_OK;
}
put_FontName(wsFontName);
put_FontStyle(nStyle);
put_FontSize(dFontSize);
if (m_bNeedUpdateTextFont)
UpdateFont();
if (m_pFont)
pFontTT = m_pDocument->CreateTrueTypeFont(m_pFont);
pWidgetAnnot->SetDA(pFontTT, pPr->GetFontSize(), dFontSize, pPr->GetTC());
@ -2396,6 +2396,16 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
}
else if ((bValue && pTextWidget->Get("T")) || bAPValue)
{
put_FontName(wsFontName);
put_FontStyle(nStyle);
put_FontSize(dFontSize);
if (m_bNeedUpdateTextFont)
UpdateFont();
if (m_pFont)
pFontTT = m_pDocument->CreateTrueTypeFont(m_pFont);
pWidgetAnnot->SetDA(pFontTT, oInfo.GetWidgetAnnotPr()->GetFontSize(), dFontSize, oInfo.GetWidgetAnnotPr()->GetTC());
pTextWidget->SetFont(m_pFont, dFontSize, isBold, isItalic);
DrawTextWidget(pAppFonts, pTextWidget, wsValue);
}
@ -2441,6 +2451,16 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
}
else if (!arrValue.empty())
{
put_FontName(wsFontName);
put_FontStyle(nStyle);
put_FontSize(dFontSize);
if (m_bNeedUpdateTextFont)
UpdateFont();
if (m_pFont)
pFontTT = m_pDocument->CreateTrueTypeFont(m_pFont);
pWidgetAnnot->SetDA(pFontTT, oInfo.GetWidgetAnnotPr()->GetFontSize(), dFontSize, oInfo.GetWidgetAnnotPr()->GetTC());
pChoiceWidget->SetFont(m_pFont, dFontSize, isBold, isItalic);
DrawChoiceWidget(pAppFonts, pChoiceWidget, arrValue);
}
@ -3614,6 +3634,12 @@ void CPdfWriter::DrawAP(PdfWriter::CAnnotation* pAnnot, BYTE* pRender, LONG nLen
m_pDocument->SetCurPage(pFakePage);
m_pPage->StartTransform(1, 0, 0, 1, -pAnnot->GetPageX(), 0);
PdfWriter::CAnnotAppearanceObject* pAP = pAnnot->StartAP();
pAP->EndText();
pFakePage->SetStream(pAP->GetStream());
pFakePage->Add("Resources", (PdfWriter::CObjectBase*)m_pDocument->GetFieldsResources());
IMetafileToRenderter* pCorrector = new IMetafileToRenderter(m_pRenderer);
NSOnlineOfficeBinToPdf::ConvertBufferToRenderer(pRender, nLenRender, pCorrector);
RELEASEOBJECT(pCorrector);

View File

@ -303,16 +303,19 @@ namespace PdfWriter
sRes.append(" ] 0 d\012");
return sRes;
}
CAnnotAppearanceObject* CAnnotation::StartAP()
{
m_pAppearance = new CAnnotAppearance(m_pXref, this);
if (!m_pAppearance)
return NULL;
Add("AP", m_pAppearance);
return m_pAppearance->GetNormal();
}
void CAnnotation::APFromFakePage(CPage* pFakePage)
{
// xref NULL - тогда у CAnnotAppearanceObject не будет создан stream
m_pAppearance = new CAnnotAppearance(NULL, this);
if (!m_pAppearance)
return;
Add("AP", m_pAppearance);
CAnnotAppearanceObject* pNormal = m_pAppearance->GetNormal((CResourcesDict*)pFakePage->Get("Resources"));
m_pXref->Add(pNormal);
m_pAppearance->Add("N", pNormal);
CAnnotAppearanceObject* pNormal = m_pAppearance->GetNormal();
CArrayObject* pArray = new CArrayObject();
if (!pArray)
@ -335,15 +338,6 @@ namespace PdfWriter
pArray->Add(1);
pArray->Add(-GetRect().fLeft);
pArray->Add(-GetRect().fBottom);
CDictObject* pFPStream = pFakePage->GetContent();
pNormal->SetStream(m_pXref, pFPStream->GetStream(), false);
#ifndef FILTER_FLATE_DECODE_DISABLED
if (m_pDocument->GetCompressionMode() & COMP_TEXT)
pNormal->SetFilter(STREAM_FILTER_FLATE_DECODE);
#endif
pFPStream->SetStream(NULL);
// RELEASEOBJECT(pFPStream); Нельзя удалять - это объект стрима, он уже в xref
}
//----------------------------------------------------------------------------------------
// CMarkupAnnotation

View File

@ -184,6 +184,7 @@ namespace PdfWriter
void SetC(const std::vector<double>& arrC);
void APFromFakePage(CPage* pFakePage);
CAnnotAppearanceObject* StartAP();
TRect& GetRect() { return m_oRect; }
void SetXref(CXref* pXref) { m_pXref = pXref; }
void SetDocument(CDocument* pDocument);