| 2317 | } |
| 2318 | |
| 2319 | void WorksheetView::print(QPrinter* printer) { |
| 2320 | m_isPrinting = true; |
| 2321 | m_worksheet->setPrinting(true); |
| 2322 | bool magnificationActive = false; |
| 2323 | if (m_magnificationWindow && m_magnificationWindow->isVisible()) { |
| 2324 | magnificationActive = true; |
| 2325 | m_magnificationWindow->setVisible(false); |
| 2326 | } |
| 2327 | |
| 2328 | QPainter painter(printer); |
| 2329 | painter.setRenderHint(QPainter::Antialiasing); |
| 2330 | |
| 2331 | // draw background |
| 2332 | const auto& page_rect = printer->pageLayout().paintRectPixels(printer->resolution()); |
| 2333 | const auto& scene_rect = scene()->sceneRect(); |
| 2334 | float scale = std::max(scene_rect.width() / page_rect.width(), scene_rect.height() / page_rect.height()); |
| 2335 | drawBackgroundItems(&painter, QRectF(0, 0, scene_rect.width() / scale, scene_rect.height() / scale)); |
| 2336 | |
| 2337 | // draw scene |
| 2338 | scene()->render(&painter); |
| 2339 | m_worksheet->setPrinting(false); |
| 2340 | m_isPrinting = false; |
| 2341 | |
| 2342 | if (magnificationActive) |
| 2343 | m_magnificationWindow->setVisible(true); |
| 2344 | } |
| 2345 | |
| 2346 | void WorksheetView::updateBackground() { |
| 2347 | invalidateScene(sceneRect(), QGraphicsScene::BackgroundLayer); |
nothing calls this directly
no test coverage detected