mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
XFA: Buttons, comb text, etc.
This commit is contained in:
@ -11697,6 +11697,7 @@ void PDFXFAEngineImpl::draw(const QMatrix& pagePointToDevicePointMatrix,
|
|||||||
const LayoutItems& items = it->second;
|
const LayoutItems& items = it->second;
|
||||||
for (const LayoutItem& item : items)
|
for (const LayoutItem& item : items)
|
||||||
{
|
{
|
||||||
|
PDFPainterStateGuard guard(painter);
|
||||||
drawItemDraw(item.draw, errors, item.nominalExtent, item.paragraphSettingsIndex, item.captionParagraphSettingsIndex, painter);
|
drawItemDraw(item.draw, errors, item.nominalExtent, item.paragraphSettingsIndex, item.captionParagraphSettingsIndex, painter);
|
||||||
drawItemField(item.field, errors, item.nominalExtent, item.paragraphSettingsIndex, item.captionParagraphSettingsIndex, painter);
|
drawItemField(item.field, errors, item.nominalExtent, item.paragraphSettingsIndex, item.captionParagraphSettingsIndex, painter);
|
||||||
drawItemSubform(item.subform, errors, item.nominalExtent, painter);
|
drawItemSubform(item.subform, errors, item.nominalExtent, painter);
|
||||||
@ -11847,7 +11848,6 @@ void PDFXFAEngineImpl::drawItemValue(const xfa::XFA_value* value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement draw arc (getArc())
|
// TODO: implement draw arc (getArc())
|
||||||
// TODO: implement draw value
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -11891,6 +11891,13 @@ void PDFXFAEngineImpl::drawItemField(const xfa::XFA_field* item,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item->getUi() && item->getUi()->getButton())
|
||||||
|
{
|
||||||
|
// We do not display buttons - we do not implement click functionality
|
||||||
|
errors << PDFRenderError(RenderErrorType::NotImplemented, PDFTranslationContext::tr("XFA: Buttons not implemented."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QRectF nominalExtent = nominalExtentArea;
|
QRectF nominalExtent = nominalExtentArea;
|
||||||
QRectF nominalContentArea = nominalExtent;
|
QRectF nominalContentArea = nominalExtent;
|
||||||
QMarginsF contentMargins = createMargin(item->getMargin());
|
QMarginsF contentMargins = createMargin(item->getMargin());
|
||||||
@ -12009,7 +12016,7 @@ void PDFXFAEngineImpl::drawUi(const xfa::XFA_ui* ui,
|
|||||||
if (ui)
|
if (ui)
|
||||||
{
|
{
|
||||||
barcode = ui->getBarcode();
|
barcode = ui->getBarcode();
|
||||||
button = ui->getButton(); // TODO: implement
|
button = ui->getButton();
|
||||||
checkButton = ui->getCheckButton();
|
checkButton = ui->getCheckButton();
|
||||||
choiceList = ui->getChoiceList(); // TODO: implement
|
choiceList = ui->getChoiceList(); // TODO: implement
|
||||||
dateTimeEdit = ui->getDateTimeEdit(); // TODO: implement
|
dateTimeEdit = ui->getDateTimeEdit(); // TODO: implement
|
||||||
@ -12054,6 +12061,10 @@ void PDFXFAEngineImpl::drawUi(const xfa::XFA_ui* ui,
|
|||||||
{
|
{
|
||||||
drawUiBarcode(barcode, errors, nominalExtentArea, painter);
|
drawUiBarcode(barcode, errors, nominalExtentArea, painter);
|
||||||
}
|
}
|
||||||
|
else if (button)
|
||||||
|
{
|
||||||
|
errors << PDFRenderError(RenderErrorType::NotImplemented, PDFTranslationContext::tr("XFA: Buttons not implemented."));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: implement all ui
|
// TODO: implement all ui
|
||||||
}
|
}
|
||||||
@ -12101,13 +12112,13 @@ void PDFXFAEngineImpl::drawUiTextEdit(const xfa::XFA_textEdit* textEdit,
|
|||||||
combNumberOfCells = qMax(combNumberOfCells, PDFInteger(1));
|
combNumberOfCells = qMax(combNumberOfCells, PDFInteger(1));
|
||||||
const xfa::XFA_ParagraphSettings& settings = m_layout.paragraphSettings.at(paragraphSettingsIndex);
|
const xfa::XFA_ParagraphSettings& settings = m_layout.paragraphSettings.at(paragraphSettingsIndex);
|
||||||
|
|
||||||
|
QRectF textRect = nominalContentArea;
|
||||||
|
textRect = textRect.marginsRemoved(settings.getMargins());
|
||||||
|
|
||||||
if (!isComb)
|
if (!isComb)
|
||||||
{
|
{
|
||||||
painter->setFont(settings.getFont());
|
painter->setFont(settings.getFont());
|
||||||
|
|
||||||
QRectF textRect = nominalContentArea;
|
|
||||||
textRect = textRect.marginsRemoved(settings.getMargins());
|
|
||||||
|
|
||||||
// Do we have space for at least one line?
|
// Do we have space for at least one line?
|
||||||
if (isMultiline && textRect.height() < 1.8 * painter->fontMetrics().lineSpacing())
|
if (isMultiline && textRect.height() < 1.8 * painter->fontMetrics().lineSpacing())
|
||||||
{
|
{
|
||||||
@ -12196,7 +12207,27 @@ void PDFXFAEngineImpl::drawUiTextEdit(const xfa::XFA_textEdit* textEdit,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: We draw comb
|
qreal combWidth = textRect.width() / combNumberOfCells;
|
||||||
|
QRectF combRect(0.0, 0.0, combWidth, textRect.height());
|
||||||
|
painter->setFont(settings.getFont());
|
||||||
|
|
||||||
|
QString text = value.value.toString();
|
||||||
|
|
||||||
|
QColor textColor = Qt::black;
|
||||||
|
painter->setPen(textColor);
|
||||||
|
|
||||||
|
for (int i = 0; i < text.size(); ++i)
|
||||||
|
{
|
||||||
|
if (i >= combNumberOfCells)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString text = QString(text[i]);
|
||||||
|
painter->drawText(combRect, Qt::AlignCenter, text);
|
||||||
|
|
||||||
|
combRect.translate(combWidth, 0.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user