| 55 | } |
| 56 | |
| 57 | void 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 |
nothing calls this directly
no test coverage detected