mirror of https://github.com/JakubMelka/PDF4QT.git
Signature plugin: Layout algorithm bugfixing
This commit is contained in:
parent
a5cd109a6e
commit
2a478c2af7
|
@ -1751,16 +1751,18 @@ void PDFPageContentElementManipulator::performOperation(Operation operation)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create pairs of left/right elements
|
// Create pairs of left/right elements
|
||||||
while (!elementsLeft.empty())
|
while (!elementsLeft.empty() && !elementsRight.empty())
|
||||||
{
|
|
||||||
if (!elementsLeft.empty() && !elementsRight.empty())
|
|
||||||
{
|
{
|
||||||
PDFPageContentElement* elementRight = nullptr;
|
PDFPageContentElement* elementRight = nullptr;
|
||||||
PDFPageContentElement* elementLeft = elementsLeft.back();
|
PDFPageContentElement* elementLeft = nullptr;
|
||||||
QRectF leftBoundingBox = elementLeft->getBoundingBox();
|
|
||||||
elementsLeft.pop_back();
|
|
||||||
qreal overlap = 0.0;
|
qreal overlap = 0.0;
|
||||||
|
|
||||||
|
// Iterate trough element on the left
|
||||||
|
for (PDFPageContentElement* elementLeftCurrent : elementsLeft)
|
||||||
|
{
|
||||||
|
QRectF leftBoundingBox = elementLeftCurrent->getBoundingBox();
|
||||||
|
|
||||||
// Find matching element on the right
|
// Find matching element on the right
|
||||||
for (PDFPageContentElement* elementRightCurrent : elementsRight)
|
for (PDFPageContentElement* elementRightCurrent : elementsRight)
|
||||||
{
|
{
|
||||||
|
@ -1774,19 +1776,34 @@ void PDFPageContentElementManipulator::performOperation(Operation operation)
|
||||||
{
|
{
|
||||||
overlap = currentOverlap;
|
overlap = currentOverlap;
|
||||||
elementRight = elementRightCurrent;
|
elementRight = elementRightCurrent;
|
||||||
|
elementLeft = elementLeftCurrent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elementRight)
|
Q_ASSERT((elementLeft != nullptr) == (elementRight != nullptr));
|
||||||
|
|
||||||
|
if (elementLeft && elementRight)
|
||||||
{
|
{
|
||||||
auto it = std::find(elementsRight.begin(), elementsRight.end(), elementRight);
|
auto itLeft = std::find(elementsLeft.begin(), elementsLeft.end(), elementLeft);
|
||||||
elementsRight.erase(it);
|
elementsLeft.erase(itLeft);
|
||||||
}
|
|
||||||
|
auto itRight = std::find(elementsRight.begin(), elementsRight.end(), elementRight);
|
||||||
|
elementsRight.erase(itRight);
|
||||||
|
|
||||||
formLayout.emplace_back(elementLeft, elementRight);
|
formLayout.emplace_back(elementLeft, elementRight);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (PDFPageContentElement* leftElement : elementsLeft)
|
||||||
|
{
|
||||||
|
formLayout.emplace_back(leftElement, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PDFPageContentElement* rightElement : elementsRight)
|
for (PDFPageContentElement* rightElement : elementsRight)
|
||||||
|
|
Loading…
Reference in New Issue