diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 37 | ||||
-rw-r--r-- | sw/source/core/view/viewsh.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/docvw/PostItMgr.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/docvw/SidebarWin.cxx | 6 |
4 files changed, 44 insertions, 9 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 82f5b11d139e..7b441d67648a 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -77,6 +77,7 @@ public: void testRedlineColors(); void testCommentEndTextEdit(); void testCursorPosition(); + void testPaintCallbacks(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -118,6 +119,7 @@ public: CPPUNIT_TEST(testRedlineColors); CPPUNIT_TEST(testCommentEndTextEdit); CPPUNIT_TEST(testCursorPosition); + CPPUNIT_TEST(testPaintCallbacks); CPPUNIT_TEST_SUITE_END(); private: @@ -640,6 +642,8 @@ public: bool m_bGraphicViewSelection; bool m_bGraphicSelection; bool m_bViewLock; + /// Set if any callback was invoked. + bool m_bCalled; ViewCallback() : m_bOwnCursorInvalidated(false), @@ -651,7 +655,8 @@ public: m_bViewCursorVisible(false), m_bGraphicViewSelection(false), m_bGraphicSelection(false), - m_bViewLock(false) + m_bViewLock(false), + m_bCalled(false) { } @@ -663,6 +668,7 @@ public: void callbackImpl(int nType, const char* pPayload) { OString aPayload(pPayload); + m_bCalled = true; switch (nType) { case LOK_CALLBACK_INVALIDATE_TILES: @@ -1529,6 +1535,35 @@ void SwTiledRenderingTest::testCursorPosition() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testPaintCallbacks() +{ + // Test that paintTile() never results in callbacks, which can cause a + // paint <-> invalidate loop. + + // Load a document and register a callback for the first view. + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc(); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + + // Create a second view and paint a tile on that second view. + SfxLokHelper::createView(); + int nCanvasWidth = 256; + int nCanvasHeight = 256; + std::vector<unsigned char> aBuffer(nCanvasWidth * nCanvasHeight * 4); + ScopedVclPtrInstance<VirtualDevice> pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT); + pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), aBuffer.data()); + // Make sure that painting a tile in the second view doesn't invoke + // callbacks on the first view. + aView1.m_bCalled = false; + pXTextDocument->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, /*nTilePosY=*/0, /*nTileWidth=*/3840, /*nTileHeight=*/3840); + CPPUNIT_ASSERT(!aView1.m_bCalled); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 64b6f7b6b979..3f62822018b0 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -1842,7 +1842,7 @@ void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contex // TODO clean up SwViewShell's approach to output devices (the many of // them - mpBufferedOut, mpOut, mpWin, ...) OutputDevice *pSaveOut = mpOut; - GetSfxViewShell()->setTiledPainting(true); + comphelper::LibreOfficeKit::setTiledPainting(true); mpOut = &rDevice; // resizes the virtual device so to contain the entries context @@ -1895,7 +1895,7 @@ void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contex // SwViewShell's output device tear down mpOut = pSaveOut; - GetSfxViewShell()->setTiledPainting(false); + comphelper::LibreOfficeKit::setTiledPainting(false); } void SwViewShell::SetBrowseBorder( const Size& rNew ) diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index 2b8f5eeae3b7..962755d3ea51 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -735,13 +735,13 @@ void SwPostItMgr::LayoutPostIts() // view that has the comment focus emits callbacks, // so the editing view jumps to the comment, but // not the others. - bool bTiledPainting = mpView->getTiledPainting(); + bool bTiledPainting = comphelper::LibreOfficeKit::isTiledPainting(); if (!bTiledPainting) // No focus -> disable callbacks. - mpView->setTiledPainting(!(*i)->HasChildPathFocus()); + comphelper::LibreOfficeKit::setTiledPainting(!(*i)->HasChildPathFocus()); (*i)->ShowNote(); if (!bTiledPainting) - mpView->setTiledPainting(bTiledPainting); + comphelper::LibreOfficeKit::setTiledPainting(bTiledPainting); } else { diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx index 0b144e9e1ab8..c1560832a43d 100644 --- a/sw/source/uibase/docvw/SidebarWin.cxx +++ b/sw/source/uibase/docvw/SidebarWin.cxx @@ -1263,11 +1263,11 @@ void SwSidebarWin::DeactivatePostIt() // Make sure this view doesn't emit LOK callbacks during the update, as the // sidebar window's SidebarTextControl doesn't have a valid twip offset // (map mode origin) during that operation. - bool bTiledPainting = mrView.getTiledPainting(); - mrView.setTiledPainting(true); + bool bTiledPainting = comphelper::LibreOfficeKit::isTiledPainting(); + comphelper::LibreOfficeKit::setTiledPainting(true); // write the visible text back into the SwField UpdateData(); - mrView.setTiledPainting(bTiledPainting); + comphelper::LibreOfficeKit::setTiledPainting(bTiledPainting); if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) GetOutlinerView()->SetBackgroundColor(COL_TRANSPARENT); |