");
+ for (int c = 0; c + 1 < xs.length(); c++) {
+ Okular::NormalizedRect cell(xs[c], ys[r], xs[c + 1], ys[r + 1]);
+ if (c)
+ selText += QLatin1Char('\t');
+ QString txt;
+ for (const TableSelectionPart &tsp : qAsConst(d->tableSelectionParts)) {
+ // first, crop the cell to this part
+ if (!tsp.rectInSelection.intersects(cell))
+ continue;
+ Okular::NormalizedRect cellPart = tsp.rectInSelection & cell; // intersection
+
+ // second, convert it from table coordinates to part coordinates
+ cellPart.left -= tsp.rectInSelection.left;
+ cellPart.left /= (tsp.rectInSelection.right - tsp.rectInSelection.left);
+ cellPart.right -= tsp.rectInSelection.left;
+ cellPart.right /= (tsp.rectInSelection.right - tsp.rectInSelection.left);
+ cellPart.top -= tsp.rectInSelection.top;
+ cellPart.top /= (tsp.rectInSelection.bottom - tsp.rectInSelection.top);
+ cellPart.bottom -= tsp.rectInSelection.top;
+ cellPart.bottom /= (tsp.rectInSelection.bottom - tsp.rectInSelection.top);
+
+ // third, convert from part coordinates to item coordinates
+ cellPart.left *= (tsp.rectInItem.right - tsp.rectInItem.left);
+ cellPart.left += tsp.rectInItem.left;
+ cellPart.right *= (tsp.rectInItem.right - tsp.rectInItem.left);
+ cellPart.right += tsp.rectInItem.left;
+ cellPart.top *= (tsp.rectInItem.bottom - tsp.rectInItem.top);
+ cellPart.top += tsp.rectInItem.top;
+ cellPart.bottom *= (tsp.rectInItem.bottom - tsp.rectInItem.top);
+ cellPart.bottom += tsp.rectInItem.top;
+
+ // now get the text
+ Okular::RegularAreaRect rects;
+ rects.append(cellPart);
+ txt += tsp.item->page()->text(&rects, Okular::TextPage::CentralPixelTextAreaInclusionBehaviour);
+ }
+ QString html = txt;
+ selText += txt.replace(QLatin1Char('\n'), QLatin1Char(' '));
+ html.replace(QLatin1Char('&'), QLatin1String("&")).replace(QLatin1Char('<'), QLatin1String("<")).replace(QLatin1Char('>'), QLatin1String(">"));
+ // Remove newlines, do not turn them into
, because
+ // Excel interprets
within cell as new cell...
+ html.replace(QLatin1Char('\n'), QLatin1String(" "));
+ selHtml += QStringLiteral("") + html + QStringLiteral(" | ");
+ }
+ selText += QLatin1Char('\n');
+ selHtml += QLatin1String("
\n");
+ }
+ selHtml += QLatin1String("