Strip the contents from the current webview in preparation for printing.
| 2826 | |
| 2827 | // Strip the contents from the current webview in preparation for printing. |
| 2828 | QString NBrowserWindow::stripContentsForPrint() { |
| 2829 | // Start removing object tags |
| 2830 | QString contents = this->editor->selectedHtml().trimmed(); |
| 2831 | if (contents == "") |
| 2832 | contents = editor->editorPage->mainFrame()->toHtml(); |
| 2833 | int pos = contents.indexOf("<object"); |
| 2834 | while (pos != -1) { |
| 2835 | int endPos = contents.indexOf(">", pos); |
| 2836 | QString lidString = contents.mid(contents.indexOf("lid=", pos)+5); |
| 2837 | lidString = lidString.mid(0,lidString.indexOf("\" ")); |
| 2838 | #ifndef _WIN32 |
| 2839 | contents = contents.mid(0,pos) + "<img src=\"file://" + |
| 2840 | global.fileManager.getTmpDirPath() + lidString + |
| 2841 | QString("-print.png\" width=\"10%\" height=\"10%\"></img>")+contents.mid(endPos+1); |
| 2842 | #else |
| 2843 | contents = contents.mid(0,pos) + "<img src=\"file:///" + |
| 2844 | global.fileManager.getTmpDirPath() + lidString + |
| 2845 | QString("-print.png\" width=\"10%\" height=\"10%\"></img>")+contents.mid(endPos+1); |
| 2846 | #endif |
| 2847 | pos = contents.indexOf("<object", endPos); |
| 2848 | } |
| 2849 | return contents.replace("src=\"file:////", "src=\"/"); |
| 2850 | } |
| 2851 | |
| 2852 | |
| 2853 | // Do a print preview of this note. This works |
no test coverage detected