XFA: rendering subform borders

This commit is contained in:
Jakub Melka 2021-12-11 17:46:46 +01:00
parent c7402519ec
commit 72000d25b9
1 changed files with 65 additions and 0 deletions

View File

@ -9671,6 +9671,8 @@ public:
QRectF nominalExtent;
const xfa::XFA_draw* draw = nullptr;
const xfa::XFA_field* field = nullptr;
const xfa::XFA_subform* subform = nullptr;
const xfa::XFA_exclGroup* exclGroup = nullptr;
size_t paragraphSettingsIndex = 0;
size_t captionParagraphSettingsIndex = 0;
};
@ -9748,6 +9750,16 @@ private:
size_t captionParagraphSettingsIndex,
QPainter* painter);
void drawItemSubform(const xfa::XFA_subform* item,
QList<PDFRenderError>& errors,
QRectF nominalExtentArea,
QPainter* painter);
void drawItemExclGroup(const xfa::XFA_exclGroup* item,
QList<PDFRenderError>& errors,
QRectF nominalExtentArea,
QPainter* painter);
void drawItemCaption(const xfa::XFA_caption* item,
QList<PDFRenderError>& errors,
QRectF& nominalExtentArea,
@ -9900,6 +9912,8 @@ private:
const xfa::XFA_draw* draw = nullptr;
const xfa::XFA_field* field = nullptr;
const xfa::XFA_subform* subform = nullptr;
const xfa::XFA_exclGroup* exclGroup = nullptr;
};
struct Layout
@ -10170,6 +10184,25 @@ void PDFXFALayoutEngine::layout(LayoutParameters layoutParameters)
}
}
if (currentLayoutParameters.nodeSubform || currentLayoutParameters.nodeExclGroup)
{
for (Layout& currentLayout : layout)
{
if (currentLayout.nominalExtent.isValid())
{
LayoutItem item;
item.nominalExtent = currentLayout.nominalExtent;
item.paragraphSettingsIndex = 0;
item.presence = currentLayoutParameters.nodeSubform ? currentLayoutParameters.nodeSubform->getPresence() :
currentLayoutParameters.nodeExclGroup->getPresence();
item.subform = currentLayoutParameters.nodeSubform;
item.exclGroup = currentLayoutParameters.nodeExclGroup;
item.captionParagraphSettingsIndex = 0;
currentLayout.items.insert(currentLayout.items.begin(), std::move(item));
}
}
}
currentLayoutParameters.tableRows.insert(currentLayoutParameters.tableRows.end(),
std::make_move_iterator(layoutParameters.tableRows.begin()),
std::make_move_iterator(layoutParameters.tableRows.end()));
@ -10623,6 +10656,8 @@ void PDFXFALayoutEngine::performLayout(PDFXFAEngineImpl* engine, const xfa::XFA_
engineLayoutItem.nominalExtent = layoutItem.nominalExtent;
engineLayoutItem.draw = layoutItem.draw;
engineLayoutItem.field = layoutItem.field;
engineLayoutItem.subform = layoutItem.subform;
engineLayoutItem.exclGroup = layoutItem.exclGroup;
engineLayoutItem.paragraphSettingsIndex = layoutItem.paragraphSettingsIndex;
engineLayoutItem.captionParagraphSettingsIndex = layoutItem.captionParagraphSettingsIndex;
layoutItems.emplace_back(std::move(engineLayoutItem));
@ -11407,6 +11442,8 @@ void PDFXFAEngineImpl::draw(const QMatrix& pagePointToDevicePointMatrix,
{
drawItemDraw(item.draw, 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);
drawItemExclGroup(item.exclGroup, errors, item.nominalExtent, painter);
}
}
@ -11599,6 +11636,34 @@ void PDFXFAEngineImpl::drawItemField(const xfa::XFA_field* item,
// TODO: implement this
}
void PDFXFAEngineImpl::drawItemSubform(const xfa::XFA_subform* item,
QList<PDFRenderError>& errors,
QRectF nominalExtentArea,
QPainter* painter)
{
if (!item)
{
// Not a form
return;
}
drawItemBorder(item->getBorder(), errors, nominalExtentArea, painter);
}
void PDFXFAEngineImpl::drawItemExclGroup(const xfa::XFA_exclGroup* item,
QList<PDFRenderError>& errors,
QRectF nominalExtentArea,
QPainter* painter)
{
if (!item)
{
// Not an excelusion group
return;
}
drawItemBorder(item->getBorder(), errors, nominalExtentArea, painter);
}
void PDFXFAEngineImpl::drawItemCaption(const xfa::XFA_caption* item,
QList<PDFRenderError>& errors,
QRectF& nominalExtentArea,