summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-01-22 18:34:27 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-01-22 19:21:14 +0100
commit4a0746108f93122c3d7b1f5504fda8afdc5ece6d (patch)
treed3f151fc8e27e2ad7d8fb3ecfd6318305fd96669
parent8347176bba09a2e77cecd3d69e81effb15fe1408 (diff)
sw tiled rendering: avoid unnecessary invalidation in SwView::SetVisArea()
SwWrtShell's visible area is set to the entire document since 12e3b51abe883202af09769873f87b27d7de118b (tdf#94237 tiled rendering: Use the entire document as the visual area., 2015-09-15). Let's be consistent and do the same for SwView, so that SwView::PageDown() and all other similar functions do not cause unnecessary invalidations, as this way later we'll realize that SwView's and SwWrtShell's visible area is the same. (cherry picked from commit 7b48a8fb2f0a0d8b854ec00d5f03ec09e8cfa4da) Conflicts: sw/qa/extras/tiledrendering/tiledrendering.cxx Change-Id: Ia22f07ddfb18c6f5ab6cbafede7cf8799b1177a1
-rw-r--r--sw/qa/extras/tiledrendering/data/pagedown-invalidation.odtbin0 -> 8528 bytes
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx26
-rw-r--r--sw/source/uibase/uiview/viewport.cxx6
3 files changed, 30 insertions, 2 deletions
diff --git a/sw/qa/extras/tiledrendering/data/pagedown-invalidation.odt b/sw/qa/extras/tiledrendering/data/pagedown-invalidation.odt
new file mode 100644
index 000000000000..0cad2d270ae0
--- /dev/null
+++ b/sw/qa/extras/tiledrendering/data/pagedown-invalidation.odt
Binary files differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 48757af68504..240899c602c0 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -54,6 +54,7 @@ public:
void testDocumentSizeChanged();
void testSearchAll();
void testSearchAllNotifications();
+ void testPageDownInvalidation();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -70,6 +71,7 @@ public:
CPPUNIT_TEST(testDocumentSizeChanged);
CPPUNIT_TEST(testSearchAll);
CPPUNIT_TEST(testSearchAllNotifications);
+ CPPUNIT_TEST(testPageDownInvalidation);
CPPUNIT_TEST_SUITE_END();
private:
@@ -84,12 +86,14 @@ private:
std::vector<int> m_aSearchResultPart;
int m_nSelectionBeforeSearchResult;
int m_nSelectionAfterSearchResult;
+ int m_nInvalidations;
};
SwTiledRenderingTest::SwTiledRenderingTest()
: m_bFound(true),
m_nSelectionBeforeSearchResult(0),
- m_nSelectionAfterSearchResult(0)
+ m_nSelectionAfterSearchResult(0),
+ m_nInvalidations(0)
{
}
@@ -125,6 +129,7 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
m_aInvalidation.setWidth(aSeq[2].toInt32());
m_aInvalidation.setHeight(aSeq[3].toInt32());
}
+ ++m_nInvalidations;
}
break;
case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
@@ -494,6 +499,25 @@ void SwTiledRenderingTest::testSearchAllNotifications()
comphelper::LibreOfficeKit::setActive(false);
}
+void SwTiledRenderingTest::testPageDownInvalidation()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ SwXTextDocument* pXTextDocument = createDoc("pagedown-invalidation.odt");
+ uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+ {
+ {".uno:HideWhitespace", uno::makeAny(true)},
+ }));
+ pXTextDocument->initializeForTiledRendering(aPropertyValues);
+ pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this);
+ comphelper::dispatchCommand(".uno:PageDown", uno::Sequence<beans::PropertyValue>());
+
+ // This was 2.
+ CPPUNIT_ASSERT_EQUAL(0, m_nInvalidations);
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx
index db2548a80b0b..39e908d21f85 100644
--- a/sw/source/uibase/uiview/viewport.cxx
+++ b/sw/source/uibase/uiview/viewport.cxx
@@ -49,6 +49,7 @@
#include <IDocumentSettingAccess.hxx>
#include <basegfx/tools/zoomtools.hxx>
+#include <comphelper/lok.hxx>
// The SetVisArea of the DocShell must not be called from InnerResizePixel.
// But our adjustments must take place.
@@ -212,7 +213,10 @@ m_aDocSz = rSz;
void SwView::SetVisArea( const Rectangle &rRect, bool bUpdateScrollbar )
{
- const Size aOldSz( m_aVisArea.GetSize() );
+ Size aOldSz( m_aVisArea.GetSize() );
+ if (comphelper::LibreOfficeKit::isActive() && m_pWrtShell)
+ // If m_pWrtShell's visible area is the whole document, do the same here.
+ aOldSz = m_pWrtShell->VisArea().SSize();
const Point aTopLeft( AlignToPixel( rRect.TopLeft() ));
const Point aBottomRight( AlignToPixel( rRect.BottomRight() ));