mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
XFA: arc
This commit is contained in:
@ -9734,6 +9734,11 @@ private:
|
|||||||
QRectF nominalContentArea,
|
QRectF nominalContentArea,
|
||||||
QPainter* painter);
|
QPainter* painter);
|
||||||
|
|
||||||
|
void drawItemArc(const xfa::XFA_arc* item,
|
||||||
|
QList<PDFRenderError>& errors,
|
||||||
|
QRectF nominalContentArea,
|
||||||
|
QPainter* painter);
|
||||||
|
|
||||||
void drawItemRectEdges(const std::vector<xfa::XFA_Node<xfa::XFA_edge>>& edges,
|
void drawItemRectEdges(const std::vector<xfa::XFA_Node<xfa::XFA_edge>>& edges,
|
||||||
const std::vector<xfa::XFA_Node<xfa::XFA_corner>>& corners,
|
const std::vector<xfa::XFA_Node<xfa::XFA_corner>>& corners,
|
||||||
QList<PDFRenderError>& errors,
|
QList<PDFRenderError>& errors,
|
||||||
@ -9792,6 +9797,13 @@ private:
|
|||||||
size_t paragraphSettingsIndex,
|
size_t paragraphSettingsIndex,
|
||||||
QPainter* painter);
|
QPainter* painter);
|
||||||
|
|
||||||
|
void drawUiChoiceList(const xfa::XFA_choiceList* choiceList,
|
||||||
|
const NodeValue& value,
|
||||||
|
QList<PDFRenderError>& errors,
|
||||||
|
QRectF nominalExtentArea,
|
||||||
|
size_t paragraphSettingsIndex,
|
||||||
|
QPainter* painter);
|
||||||
|
|
||||||
void drawUiDateTimeEdit(const xfa::XFA_dateTimeEdit* dateTimeEdit,
|
void drawUiDateTimeEdit(const xfa::XFA_dateTimeEdit* dateTimeEdit,
|
||||||
const NodeValue& value,
|
const NodeValue& value,
|
||||||
QList<PDFRenderError>& errors,
|
QList<PDFRenderError>& errors,
|
||||||
@ -11732,6 +11744,10 @@ void PDFXFAEngineImpl::drawItemValue(const xfa::XFA_value* value,
|
|||||||
{
|
{
|
||||||
drawItemLine(line, errors, nominalContentArea, painter);
|
drawItemLine(line, errors, nominalContentArea, painter);
|
||||||
}
|
}
|
||||||
|
else if (const xfa::XFA_arc* arc = value->getArc())
|
||||||
|
{
|
||||||
|
drawItemArc(arc, errors, nominalContentArea, painter);
|
||||||
|
}
|
||||||
else if (const xfa::XFA_text* text = value->getText())
|
else if (const xfa::XFA_text* text = value->getText())
|
||||||
{
|
{
|
||||||
nodeValue.emplace();
|
nodeValue.emplace();
|
||||||
@ -11853,8 +11869,6 @@ void PDFXFAEngineImpl::drawItemValue(const xfa::XFA_value* value,
|
|||||||
{
|
{
|
||||||
drawUi(ui, NodeValue(), errors, nominalContentArea, paragraphSettingsIndex, painter);
|
drawUi(ui, NodeValue(), errors, nominalContentArea, paragraphSettingsIndex, painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement draw arc (getArc())
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -12025,7 +12039,7 @@ void PDFXFAEngineImpl::drawUi(const xfa::XFA_ui* ui,
|
|||||||
barcode = ui->getBarcode();
|
barcode = ui->getBarcode();
|
||||||
button = ui->getButton();
|
button = ui->getButton();
|
||||||
checkButton = ui->getCheckButton();
|
checkButton = ui->getCheckButton();
|
||||||
choiceList = ui->getChoiceList(); // TODO: implement
|
choiceList = ui->getChoiceList();
|
||||||
dateTimeEdit = ui->getDateTimeEdit();
|
dateTimeEdit = ui->getDateTimeEdit();
|
||||||
defaultUi = ui->getDefaultUi();
|
defaultUi = ui->getDefaultUi();
|
||||||
imageEdit = ui->getImageEdit();
|
imageEdit = ui->getImageEdit();
|
||||||
@ -12078,8 +12092,14 @@ void PDFXFAEngineImpl::drawUi(const xfa::XFA_ui* ui,
|
|||||||
{
|
{
|
||||||
drawUiDateTimeEdit(dateTimeEdit, value, errors, nominalExtentArea, paragraphSettingsIndex, painter);
|
drawUiDateTimeEdit(dateTimeEdit, value, errors, nominalExtentArea, paragraphSettingsIndex, painter);
|
||||||
}
|
}
|
||||||
|
else if (choiceList)
|
||||||
// TODO: implement all ui
|
{
|
||||||
|
drawUiChoiceList(choiceList, value, errors, nominalExtentArea, paragraphSettingsIndex, painter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errors << PDFRenderError(RenderErrorType::NotSupported, PDFTranslationContext::tr("XFA: Uknown ui."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PDFXFAEngineImpl::drawUiTextEdit(const xfa::XFA_textEdit* textEdit,
|
void PDFXFAEngineImpl::drawUiTextEdit(const xfa::XFA_textEdit* textEdit,
|
||||||
@ -12244,6 +12264,34 @@ void PDFXFAEngineImpl::drawUiTextEdit(const xfa::XFA_textEdit* textEdit,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PDFXFAEngineImpl::drawUiChoiceList(const xfa::XFA_choiceList* choiceList,
|
||||||
|
const NodeValue& value,
|
||||||
|
QList<PDFRenderError>& errors,
|
||||||
|
QRectF nominalExtentArea,
|
||||||
|
size_t paragraphSettingsIndex,
|
||||||
|
QPainter* painter)
|
||||||
|
{
|
||||||
|
QRectF nominalExtent = nominalExtentArea;
|
||||||
|
QRectF nominalContentArea = nominalExtent;
|
||||||
|
QMarginsF contentMargins = choiceList ? createMargin(choiceList->getMargin()) : QMarginsF();
|
||||||
|
nominalContentArea = nominalExtent.marginsRemoved(contentMargins);
|
||||||
|
|
||||||
|
if (choiceList && choiceList->getBorder())
|
||||||
|
{
|
||||||
|
drawItemBorder(choiceList->getBorder(), errors, nominalExtentArea, painter);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString text = value.value.toString();
|
||||||
|
|
||||||
|
if (!text.isEmpty())
|
||||||
|
{
|
||||||
|
NodeValue textValue;
|
||||||
|
textValue.value = text;
|
||||||
|
|
||||||
|
drawUiTextEdit(nullptr, textValue, errors, nominalContentArea, paragraphSettingsIndex, painter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PDFXFAEngineImpl::drawUiDateTimeEdit(const xfa::XFA_dateTimeEdit* dateTimeEdit,
|
void PDFXFAEngineImpl::drawUiDateTimeEdit(const xfa::XFA_dateTimeEdit* dateTimeEdit,
|
||||||
const NodeValue& value,
|
const NodeValue& value,
|
||||||
QList<PDFRenderError>& errors,
|
QList<PDFRenderError>& errors,
|
||||||
@ -12752,6 +12800,60 @@ void PDFXFAEngineImpl::drawItemLine(const xfa::XFA_line* item,
|
|||||||
painter->drawLine(line);
|
painter->drawLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PDFXFAEngineImpl::drawItemArc(const xfa::XFA_arc* item,
|
||||||
|
QList<PDFRenderError>& errors,
|
||||||
|
QRectF nominalContentArea,
|
||||||
|
QPainter* painter)
|
||||||
|
{
|
||||||
|
if (!item)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw fill
|
||||||
|
drawItemFill(item->getFill(), errors, nominalContentArea, painter);
|
||||||
|
|
||||||
|
// Draw arc
|
||||||
|
QPen pen = createPenFromEdge(item->getEdge(), errors);
|
||||||
|
if (pen.style() == Qt::NoPen)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF arcArea = nominalContentArea;
|
||||||
|
if (item->getCircular())
|
||||||
|
{
|
||||||
|
qreal minEdge = qMin(arcArea.width(), arcArea.height());
|
||||||
|
arcArea.setWidth(minEdge);
|
||||||
|
arcArea.setHeight(minEdge);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (item->getHand())
|
||||||
|
{
|
||||||
|
case pdf::xfa::XFA_BaseNode::HAND::Even:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case pdf::xfa::XFA_BaseNode::HAND::Left:
|
||||||
|
{
|
||||||
|
const qreal halfEdgeWidth = pen.widthF() * 0.5;
|
||||||
|
arcArea.adjust(0, 0, -halfEdgeWidth, -halfEdgeWidth);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case pdf::xfa::XFA_BaseNode::HAND::Right:
|
||||||
|
{
|
||||||
|
const qreal halfEdgeWidth = pen.widthF() * 0.5;
|
||||||
|
arcArea.adjust(0, 0, +halfEdgeWidth, +halfEdgeWidth);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
arcArea.moveCenter(nominalContentArea.center());
|
||||||
|
|
||||||
|
painter->setPen(std::move(pen));
|
||||||
|
painter->drawArc(arcArea, item->getStartAngle() * 16, item->getSweepAngle() * 16);
|
||||||
|
}
|
||||||
|
|
||||||
void PDFXFAEngineImpl::drawItemRectEdges(const std::vector<xfa::XFA_Node<xfa::XFA_edge>>& edges,
|
void PDFXFAEngineImpl::drawItemRectEdges(const std::vector<xfa::XFA_Node<xfa::XFA_edge>>& edges,
|
||||||
const std::vector<xfa::XFA_Node<xfa::XFA_corner>>& corners,
|
const std::vector<xfa::XFA_Node<xfa::XFA_corner>>& corners,
|
||||||
QList<PDFRenderError>& errors,
|
QList<PDFRenderError>& errors,
|
||||||
|
Reference in New Issue
Block a user