mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Rotate form
This commit is contained in:
@ -2261,6 +2261,7 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
|
||||
pWidgetAnnot->SetFlag(pPr->GetFlag());
|
||||
|
||||
int nFlags = pPr->GetFlags();
|
||||
int nR = 0;
|
||||
if (nFlags & (1 << 0))
|
||||
pWidgetAnnot->SetTU(pPr->GetTU());
|
||||
if (nFlags & (1 << 1))
|
||||
@ -2270,7 +2271,10 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
|
||||
if (nFlags & (1 << 5))
|
||||
pWidgetAnnot->SetBC(pPr->GetBC());
|
||||
if (nFlags & (1 << 6))
|
||||
pWidgetAnnot->SetR(pPr->GetR());
|
||||
{
|
||||
nR = pPr->GetR();
|
||||
pWidgetAnnot->SetR(nR);
|
||||
}
|
||||
if (nFlags & (1 << 7))
|
||||
pWidgetAnnot->SetBG(pPr->GetBG());
|
||||
if (nFlags & (1 << 8))
|
||||
@ -2373,6 +2377,7 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
|
||||
if (!pButtonWidget->Get("DA"))
|
||||
{
|
||||
PdfWriter::CFontDict* pFont = pFontTT;
|
||||
dFontSize = oInfo.GetWidgetAnnotPr()->GetFontSize();
|
||||
if (!wsFontName.empty())
|
||||
{
|
||||
put_FontName(wsFontName);
|
||||
@ -2400,7 +2405,7 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
|
||||
|
||||
// ВНЕШНИЙ ВИД
|
||||
if (!pButtonWidget->Get("AP"))
|
||||
pButtonWidget->SetAP();
|
||||
pButtonWidget->SetAP(nR);
|
||||
|
||||
if (nFlags & (1 << 9))
|
||||
{
|
||||
@ -2442,13 +2447,25 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
|
||||
|
||||
LONG nLen = 0;
|
||||
BYTE* pRender = pPr->GetRender(nLen);
|
||||
DrawWidgetAP(pAnnot, pRender, nLen);
|
||||
DrawWidgetAP(pAnnot, pRender, nLen, nR);
|
||||
|
||||
PdfWriter::CFontDict* pFont = NULL;
|
||||
if (m_pFont14)
|
||||
pFont = m_pFont14;
|
||||
else if (m_pFont)
|
||||
pFont = m_pDocument->CreateTrueTypeFont(m_pFont);
|
||||
else
|
||||
{
|
||||
dFontSize = oInfo.GetWidgetAnnotPr()->GetFontSize();
|
||||
put_FontName(wsFontName);
|
||||
put_FontStyle(nStyle);
|
||||
put_FontSize(dFontSize);
|
||||
|
||||
if (m_bNeedUpdateTextFont)
|
||||
UpdateFont();
|
||||
if (m_pFont)
|
||||
pFont = m_pDocument->CreateTrueTypeFont(m_pFont);
|
||||
}
|
||||
if (pFont)
|
||||
pWidgetAnnot->SetDA(pFont, oInfo.GetWidgetAnnotPr()->GetFontSize(), dFontSize, oInfo.GetWidgetAnnotPr()->GetTC());
|
||||
}
|
||||
@ -2497,13 +2514,25 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
|
||||
|
||||
LONG nLen = 0;
|
||||
BYTE* pRender = pPr->GetRender(nLen);
|
||||
DrawWidgetAP(pAnnot, pRender, nLen);
|
||||
DrawWidgetAP(pAnnot, pRender, nLen, nR);
|
||||
|
||||
PdfWriter::CFontDict* pFont = NULL;
|
||||
if (m_pFont14)
|
||||
pFont = m_pFont14;
|
||||
else if (m_pFont)
|
||||
pFont = m_pDocument->CreateTrueTypeFont(m_pFont);
|
||||
else
|
||||
{
|
||||
dFontSize = oInfo.GetWidgetAnnotPr()->GetFontSize();
|
||||
put_FontName(wsFontName);
|
||||
put_FontStyle(nStyle);
|
||||
put_FontSize(dFontSize);
|
||||
|
||||
if (m_bNeedUpdateTextFont)
|
||||
UpdateFont();
|
||||
if (m_pFont)
|
||||
pFont = m_pDocument->CreateTrueTypeFont(m_pFont);
|
||||
}
|
||||
if (pFont)
|
||||
pWidgetAnnot->SetDA(pFont, oInfo.GetWidgetAnnotPr()->GetFontSize(), dFontSize, oInfo.GetWidgetAnnotPr()->GetTC());
|
||||
}
|
||||
@ -3895,7 +3924,7 @@ PdfWriter::CAnnotAppearanceObject* CPdfWriter::DrawAP(PdfWriter::CAnnotation* pA
|
||||
m_pDocument->SetCurPage(pFakePage);
|
||||
m_pPage->StartTransform(1, 0, 0, 1, -pAnnot->GetPageX(), 0);
|
||||
|
||||
PdfWriter::CAnnotAppearanceObject* pAP = pAnnot->StartAP();
|
||||
PdfWriter::CAnnotAppearanceObject* pAP = pAnnot->StartAP(0);
|
||||
|
||||
pFakePage->SetStream(pAP->GetStream());
|
||||
pFakePage->Add("Resources", pAP->Get("Resources"));
|
||||
@ -3912,7 +3941,7 @@ PdfWriter::CAnnotAppearanceObject* CPdfWriter::DrawAP(PdfWriter::CAnnotation* pA
|
||||
|
||||
return pAP;
|
||||
}
|
||||
void CPdfWriter::DrawWidgetAP(PdfWriter::CAnnotation* pA, BYTE* pRender, LONG nLenRender)
|
||||
void CPdfWriter::DrawWidgetAP(PdfWriter::CAnnotation* pA, BYTE* pRender, LONG nLenRender, int nRotate)
|
||||
{
|
||||
if (!pA || !pRender)
|
||||
return;
|
||||
@ -3923,9 +3952,17 @@ void CPdfWriter::DrawWidgetAP(PdfWriter::CAnnotation* pA, BYTE* pRender, LONG nL
|
||||
PdfWriter::CPage* pFakePage = new PdfWriter::CPage(m_pDocument);
|
||||
m_pPage = pFakePage;
|
||||
m_pDocument->SetCurPage(pFakePage);
|
||||
m_oTransform.Set(1, 0, 0, 1, PT_2_MM(-pAnnot->GetPageX() - pAnnot->GetRect().fLeft), PT_2_MM(pAnnot->GetRect().fBottom));
|
||||
if (nRotate == 0 || nRotate == 180)
|
||||
m_oTransform.Set(1, 0, 0, 1, PT_2_MM(-pAnnot->GetPageX() - pAnnot->GetRect().fLeft), PT_2_MM(pAnnot->GetRect().fBottom));
|
||||
else if (nRotate == 90 || nRotate == 270)
|
||||
{
|
||||
double dW = pAnnot->GetWidth();
|
||||
double dH = pAnnot->GetHeight();
|
||||
double dDiff = dW / 2.0 - dH / 2.0;
|
||||
m_oTransform.Set(1, 0, 0, 1, PT_2_MM(-pAnnot->GetPageX() - pAnnot->GetRect().fLeft), PT_2_MM(pAnnot->GetRect().fBottom - dDiff));
|
||||
}
|
||||
|
||||
PdfWriter::CAnnotAppearanceObject* pAP = pAnnot->StartAP();
|
||||
PdfWriter::CAnnotAppearanceObject* pAP = pAnnot->StartAP(nRotate);
|
||||
|
||||
pFakePage->SetStream(pAP->GetStream());
|
||||
pFakePage->Add("Resources", pAP->Get("Resources"));
|
||||
@ -3941,8 +3978,6 @@ void CPdfWriter::DrawWidgetAP(PdfWriter::CAnnotation* pA, BYTE* pRender, LONG nL
|
||||
pAP->EndDraw();
|
||||
pFakePage->EndMarkedContent();
|
||||
|
||||
pAnnot->APFromFakePage();
|
||||
|
||||
m_pPage = pCurPage;
|
||||
m_pDocument->SetCurPage(pCurPage);
|
||||
RELEASEOBJECT(pFakePage);
|
||||
@ -4011,7 +4046,7 @@ void CPdfWriter::DrawTextWidget(NSFonts::IApplicationFonts* pAppFonts, PdfWriter
|
||||
|
||||
m_oLinesManager.CalculateLines(dFontSize, dWidth - dShiftBorder * 4);
|
||||
|
||||
pTextWidget->StartAP();
|
||||
pTextWidget->StartAP(0);
|
||||
|
||||
unsigned int unLinesCount = m_oLinesManager.GetLinesCount();
|
||||
double dLineShiftY = dHeight - dShiftBorder * 2 - dLineHeight;
|
||||
@ -4223,7 +4258,7 @@ void CPdfWriter::DrawChoiceWidget(NSFonts::IApplicationFonts* pAppFonts, PdfWrit
|
||||
double dKoef = dFontSize / pFontTT->m_dUnitsPerEm;
|
||||
double dLineHeight = pFontTT->m_dHeight * dKoef;
|
||||
pChoiceWidget->SetListBoxHeight(dLineHeight);
|
||||
pChoiceWidget->StartAP();
|
||||
pChoiceWidget->StartAP(0);
|
||||
|
||||
// double dKoef = dFontSize / pFontTT->m_dUnitsPerEm;
|
||||
// double dDescent = std::abs(pFontTT->m_dDescent * dFontSize / pFontTT->m_dUnitsPerEm);
|
||||
|
||||
Reference in New Issue
Block a user