MCPcopy Create free account
hub / github.com/Robotips/uConfig / loadBoxes

Method loadBoxes

src/pdf_extract/controller/pdfloader.cpp:57–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57void PDFLoader::loadBoxes(PDFPage *pdfPage)
58{
59 PDFTextBox *parentTextBox = Q_NULLPTR;
60 foreach (Poppler::TextBox *ptextBox, pdfPage->page()->textList())
61 {
62 PDFTextBox *textBox = new PDFTextBox(ptextBox->text(), ptextBox->boundingBox());
63 textBox->_page = pdfPage;
64
65 bool padName = textBox->isPadName();
66 if (padName)
67 {
68 textBox->_type = PDFTextBox::Pad;
69 }
70 if (parentTextBox == Q_NULLPTR)
71 {
72 if (ptextBox->nextWord() == Q_NULLPTR || padName)
73 {
74 pdfPage->_textBoxes.append(textBox);
75 }
76 else
77 {
78 parentTextBox = new PDFTextBox(QString(), ptextBox->boundingBox());
79 parentTextBox->_page = pdfPage;
80 if (ptextBox->hasSpaceAfter())
81 textBox->_text.append(QChar(' '));
82 textBox->_parentBox = parentTextBox;
83 textBox->_type = PDFTextBox::SubText;
84 parentTextBox->_subBoxes.append(textBox);
85 }
86 }
87 else
88 {
89 if (padName)
90 {
91 pdfPage->_textBoxes.append(textBox);
92 }
93 else
94 {
95 textBox->_parentBox = parentTextBox;
96 textBox->_type = PDFTextBox::SubText;
97 parentTextBox->_subBoxes.append(textBox);
98 }
99 if (ptextBox->nextWord() == Q_NULLPTR || padName)
100 {
101 QRectF boundingRect;
102 QString text;
103 foreach (PDFTextBox *subBox, parentTextBox->subBoxes())
104 {
105 text.append(subBox->text());
106 boundingRect = boundingRect.united(subBox->boundingRect());
107 }
108 parentTextBox->_text = text;
109 parentTextBox->_boundingRect = boundingRect.adjusted(-1, -1, 1, 1);
110
111 pdfPage->_textBoxes.append(parentTextBox);
112 parentTextBox = Q_NULLPTR;
113 }
114 else

Callers

nothing calls this directly

Calls 5

textMethod · 0.80
isPadNameMethod · 0.80
foreachFunction · 0.50
pageMethod · 0.45
boundingRectMethod · 0.45

Tested by

no test coverage detected