[Libreoffice-commits] core.git: 3 commits - sc/qa sc/source svx/source

Marco Cecchetti marco.cecchetti at collabora.com
Fri Mar 31 17:25:05 UTC 2017


 sc/qa/unit/tiledrendering/data/smile.png     |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   44 +++++++++++++++++++++++++++
 sc/source/ui/inc/gridwin.hxx                 |    5 +++
 sc/source/ui/view/gridwin4.cxx               |    7 +---
 svx/source/svdraw/sdrpagewindow.cxx          |   20 +++++++++++-
 5 files changed, 70 insertions(+), 6 deletions(-)

New commits:
commit 325d211aae0ef54c8e0b90ca594c4af336818259
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Tue Jan 3 11:56:05 2017 +0100

    LOK: Calc: unit test for invalidation on insert image
    
    Change-Id: Ie7c55c3a5c366618cafa51f9f1a102fb3cb26ec5

diff --git a/sc/qa/unit/tiledrendering/data/smile.png b/sc/qa/unit/tiledrendering/data/smile.png
new file mode 100644
index 000000000000..ba0b89172b25
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/smile.png differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 2510d161387a..06fda94ff40b 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -79,6 +79,7 @@ public:
     void testCommentCallback();
     void testUndoLimiting();
     void testUndoRepairDispatch();
+    void testInsertGraphicInvalidations();
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
     CPPUNIT_TEST(testRowColumnSelections);
@@ -103,6 +104,7 @@ public:
     CPPUNIT_TEST(testCommentCallback);
     CPPUNIT_TEST(testUndoLimiting);
     CPPUNIT_TEST(testUndoRepairDispatch);
+    CPPUNIT_TEST(testInsertGraphicInvalidations);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1264,7 +1266,49 @@ void ScTiledRenderingTest::testUndoRepairDispatch()
 
     mxComponent->dispose();
     mxComponent.clear();
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
+void ScTiledRenderingTest::testInsertGraphicInvalidations()
+{
+    comphelper::LibreOfficeKit::setActive();
+
+    ScModelObj* pModelObj = createDoc("small.ods");
+    CPPUNIT_ASSERT(pModelObj);
+    ScViewData* pViewData = ScDocShell::GetViewData();
+    CPPUNIT_ASSERT(pViewData);
+
+    // view
+    ViewCallback aView;
+    SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView);
+
+    // we need to paint a tile in the view for triggering the tile invalidation solution
+    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());
+    pModelObj->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, /*nTilePosY=*/0, /*nTileWidth=*/3840, /*nTileHeight=*/3840);
+    Scheduler::ProcessEventsToIdle();
+
+    // insert an image in view and see if both views are invalidated
+    aView.m_bInvalidateTiles = false;
+    uno::Sequence<beans::PropertyValue> aArgs(1);
+    aArgs[0].Name = OUString::fromUtf8("FileName");
+    aArgs[0].Value <<= (m_directories.getURLFromSrc(DATA_DIRECTORY) + "smile.png");
+    comphelper::dispatchCommand(".uno:InsertGraphic", aArgs);
+    Scheduler::ProcessEventsToIdle();
+    CPPUNIT_ASSERT(aView.m_bInvalidateTiles);
 
+    // undo image insertion in view and see if both views are invalidated
+    aView.m_bInvalidateTiles = false;
+    uno::Sequence<beans::PropertyValue> aArgs2;
+    comphelper::dispatchCommand(".uno:Undo", aArgs2);
+    Scheduler::ProcessEventsToIdle();
+    CPPUNIT_ASSERT(aView.m_bInvalidateTiles);
+
+    mxComponent->dispose();
+    mxComponent.clear();
     comphelper::LibreOfficeKit::setActive(false);
 }
 
commit 83487c28d3e2d0b331dd161b97a804be8e9bc1b9
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Mar 31 18:17:23 2017 +0200

    lok sc: Don't depend on the OutputDevice existence when invalidating.
    
    We know that the drawinglayer operates in 100th of millimetre, and that we
    need twips for LOK.
    
    Change-Id: I8813f936ab66eaca4d6b9c03341e090d703decb8

diff --git a/svx/source/svdraw/sdrpagewindow.cxx b/svx/source/svdraw/sdrpagewindow.cxx
index add2130a32be..729c65ea997e 100644
--- a/svx/source/svdraw/sdrpagewindow.cxx
+++ b/svx/source/svdraw/sdrpagewindow.cxx
@@ -36,7 +36,7 @@
 #include <osl/mutex.hxx>
 #include <svx/fmview.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
-
+#include <sfx2/lokhelper.hxx>
 
 using namespace ::com::sun::star;
 
@@ -409,7 +409,23 @@ void SdrPageWindow::RedrawLayer(const SdrLayerID* pId,
 // Invalidate call, used from ObjectContact(OfPageView) in InvalidatePartOfView(...)
 void SdrPageWindow::InvalidatePageWindow(const basegfx::B2DRange& rRange)
 {
-    if(GetPageView().IsVisible() && GetPaintWindow().OutputToWindow())
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        // we don't really have a paint window with LOK; OTOH we know that the
+        // drawinglayer units are 100ths of mm, so they are easy to convert to
+        // twips
+        const Rectangle aRect100thMM(
+            static_cast<long>(floor(rRange.getMinX())),
+            static_cast<long>(floor(rRange.getMinY())),
+            static_cast<long>(ceil(rRange.getMaxX())),
+            static_cast<long>(ceil(rRange.getMaxY())));
+
+        const Rectangle aRectTwips = OutputDevice::LogicToLogic(aRect100thMM, MapUnit::Map100thMM, MapUnit::MapTwip);
+
+        if (SfxViewShell* pViewShell = SfxViewShell::Current())
+            SfxLokHelper::notifyInvalidation(pViewShell, aRectTwips.toString());
+    }
+    else if (GetPageView().IsVisible() && GetPaintWindow().OutputToWindow())
     {
         const SvtOptionsDrawinglayer aDrawinglayerOpt;
         vcl::Window& rWindow(static_cast< vcl::Window& >(GetPaintWindow().GetOutputDevice()));
commit 3b65c1660427e66642f63f24ba35c85c48c7a08c
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Mar 31 17:47:46 2017 +0200

    sc lok: Make the FmFormView we need for drawinglayer persistent.
    
    Based on Marco Cecchetti's research - thanks! :-)
    
    Change-Id: I579b6c8e54311a679f5d684f7ca1e2d7373d0ec9

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index a9c33ea6555f..cc30dd92a4ed 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -38,6 +38,7 @@ namespace sc {
     struct SpellCheckContext;
 }
 
+class FmFormView;
 struct ScTableInfo;
 class ScDPObject;
 class ScCheckListMenuWindow;
@@ -103,6 +104,10 @@ class ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSou
 
     std::unique_ptr<tools::Rectangle> mpAutoFillRect;
 
+    /// LibreOfficeKit needs a persistent FmFormView for tiled rendering,
+    /// otherwise the invalidations from drawinglayer do not work.
+    std::unique_ptr<FmFormView> mpLOKDrawView;
+
     struct MouseEventState;
 
     /**
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 67b0d76fafcd..150f1f125571 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1191,12 +1191,11 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
 
     // setup the SdrPage so that drawinglayer works correctly
     ScDrawLayer* pModel = pDoc->GetDrawLayer();
-    std::unique_ptr<FmFormView> pDrawView;
     if (pModel)
     {
-        pDrawView.reset(new FmFormView(pModel, &rDevice));
-        pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
-        aOutputData.SetDrawView( pDrawView.get() );
+        mpLOKDrawView.reset(new FmFormView(pModel, &rDevice));
+        mpLOKDrawView->ShowSdrPage(mpLOKDrawView->GetModel()->GetPage(nTab));
+        aOutputData.SetDrawView(mpLOKDrawView.get());
     }
 
     // draw the content


More information about the Libreoffice-commits mailing list