[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 2 commits - sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 18 16:13:11 UTC 2019


 sw/qa/extras/layout/data/tdf123651.docx               |binary
 sw/qa/extras/layout/layout.cxx                        |   11 ++++++
 sw/qa/extras/tiledrendering/data/semi-transparent.odt |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx        |   33 ++++++++++++++++++
 sw/qa/extras/uiwriter/uiwriter2.cxx                   |   23 ++++--------
 sw/source/core/layout/paintfrm.cxx                    |    7 +++
 sw/source/core/text/txtfrm.cxx                        |    3 +
 7 files changed, 61 insertions(+), 16 deletions(-)

New commits:
commit 3d3564678bc11eefbc47547b665f1d11285aaa84
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue May 14 12:02:55 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Jun 18 18:12:12 2019 +0200

    sw lok: assume no windows in SwLayoutFrame::PaintSwFrame()
    
    The high-level problem was that a watermark shape in the background was
    rendered with lighter and darker gray as the user typed. The reason for
    this was that depending on what larger combined tile was rendered we did
    or did not repaint the layout frame.
    
    Handle the situation similar to when we have no vcl::Window at all,
    which ensures that we always paint only once. The rgb value matches the
    desktop rendering result this way.
    
    (Just assert that we render the gray light enough, the actual color
    channel value may be 190 or 191.)
    
    Reviewed-on: https://gerrit.libreoffice.org/72276
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 93abdf39b01bb7b404dc09ef37369a4350fb0d10)
    
    Conflicts:
            sw/qa/extras/tiledrendering/tiledrendering.cxx
    
    Change-Id: Ie8746ab70f49f7f1080632c39e3a826c4ce509df

diff --git a/sw/qa/extras/tiledrendering/data/semi-transparent.odt b/sw/qa/extras/tiledrendering/data/semi-transparent.odt
new file mode 100644
index 000000000000..eb76980e7406
Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/semi-transparent.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 06cd6bfa48b2..4a33b92a372d 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -40,6 +40,7 @@
 #include <IDocumentRedlineAccess.hxx>
 #include <vcl/scheduler.hxx>
 #include <vcl/vclevent.hxx>
+#include <vcl/bitmapaccess.hxx>
 #include <flddat.hxx>
 
 static char const DATA_DIRECTORY[] = "/sw/qa/extras/tiledrendering/data/";
@@ -108,6 +109,7 @@ public:
     void testSplitNodeRedlineCallback();
     void testDeleteNodeRedlineCallback();
     void testVisCursorInvalidation();
+    void testSemiTransparent();
 
     CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -163,6 +165,7 @@ public:
     CPPUNIT_TEST(testSplitNodeRedlineCallback);
     CPPUNIT_TEST(testDeleteNodeRedlineCallback);
     CPPUNIT_TEST(testVisCursorInvalidation);
+    CPPUNIT_TEST(testSemiTransparent);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2374,6 +2377,36 @@ void SwTiledRenderingTest::testVisCursorInvalidation()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void SwTiledRenderingTest::testSemiTransparent()
+{
+    // Load a document where the top left tile contains a semi-transparent rectangle shape.
+    comphelper::LibreOfficeKit::setActive();
+    SwXTextDocument* pXTextDocument = createDoc("semi-transparent.odt");
+
+    // Render a larger area, and then get the color of the bottom right corner of our tile.
+    size_t nCanvasWidth = 1024;
+    size_t nCanvasHeight = 512;
+    size_t nTileSize = 256;
+    std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
+    ScopedVclPtrInstance<VirtualDevice> pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT);
+    pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
+    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight),
+                                                    Fraction(1.0), Point(), aPixmap.data());
+    pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0,
+                              /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680);
+    pDevice->EnableMapMode(false);
+    Bitmap aBitmap = pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize));
+    Bitmap::ScopedReadAccess pAccess(aBitmap);
+    Color aColor(pAccess->GetPixel(255, 255).GetColor());
+
+    // Without the accompanying fix in place, this test would have failed with 'Expected greater or
+    // equal than: 190; Actual: 159'. This means the semi-transparent gray rectangle was darker than
+    // expected, as it was painted twice.
+    CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.GetRed()));
+    CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.GetGreen()));
+    CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.GetBlue()));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index de8d04311d64..0a9338f462b6 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -107,6 +107,7 @@
 #include <o3tl/typed_flags_set.hxx>
 
 #include <vcl/BitmapTools.hxx>
+#include <comphelper/lok.hxx>
 
 #define COL_NOTES_SIDEPANE                  Color(230,230,230)
 #define COL_NOTES_SIDEPANE_BORDER           Color(200,200,200)
@@ -3323,7 +3324,11 @@ void SwLayoutFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect cons
     }
 
     const SwPageFrame *pPage = nullptr;
-    const bool bWin   = gProp.pSGlobalShell->GetWin() != nullptr;
+    bool bWin = gProp.pSGlobalShell->GetWin() != nullptr;
+    if (comphelper::LibreOfficeKit::isTiledPainting())
+        // Tiled rendering is similar to printing in this case: painting transparently multiple
+        // times will result in darker colors: avoid that.
+        bWin = false;
 
     while ( IsAnLower( pFrame ) )
     {
commit 59c23d88ef82c6aa6cc5eb83138df72a6be259bb
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Mar 25 21:36:02 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Jun 18 18:12:12 2019 +0200

    tdf#123651 sw AddVerticalFrameOffsets: make vert offset depend on hori offset
    
    Regression from commit 961ba62df045473e5793d9e103be86eaad8d9575
    (tdf#123032 sw, AddVerticalFrameOffsets: fix shape pos after mouse move,
    2019-02-07), the vertical position of the bugdoc was too large, and
    turns out Word only works with vertical offsets if there is already a
    horizontal offset.
    
    For example open tdf98987.docx in Word, remove the left square shape,
    notice how the other square shape jumps up due to no longer working with
    a vertical offset (while the doc model vertical position of the shape is
    unchanged).
    
    Change our layout, so that in case the AddVerticalFrameOffsets
    compatibility flag is on (which was added to emulate Word's behavior),
    we also consider the horizontal offset before setting the vertical
    offset.
    
    Also improve the SwUiWriterTest2::testTdf122942() test that asserted doc
    model positions, which are now different (needed so that at the end the
    layout position visible to the user is unchanged).
    
    Reviewed-on: https://gerrit.libreoffice.org/69716
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    (cherry picked from commit 27894be916d5d03ee820e757d2f4abbf21d54615)
    
     Conflicts:
            sw/qa/extras/layout/layout.cxx
            sw/qa/extras/uiwriter/uiwriter2.cxx
    
    Change-Id: I8ac451efbacefdd3578b3a578260e7b2060c16a6

diff --git a/sw/qa/extras/layout/data/tdf123651.docx b/sw/qa/extras/layout/data/tdf123651.docx
new file mode 100644
index 000000000000..4cda0b4e7f36
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf123651.docx differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index c2c6d2cd5b9d..3239b1cac3aa 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -67,6 +67,7 @@ public:
     void testTdf122878();
     void testTdf115094();
     void testTdf118719();
+    void testTdf123651();
 
     CPPUNIT_TEST_SUITE(SwLayoutWriter);
     CPPUNIT_TEST(testRedlineFootnotes);
@@ -106,6 +107,7 @@ public:
     CPPUNIT_TEST(testTdf122878);
     CPPUNIT_TEST(testTdf115094);
     CPPUNIT_TEST(testTdf118719);
+    CPPUNIT_TEST(testTdf123651);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2728,6 +2730,15 @@ void SwLayoutWriter::testTdf118719()
     CPPUNIT_ASSERT_GREATER(nOther, nLast);
 }
 
+void SwLayoutWriter::testTdf123651()
+{
+    createDoc("tdf123651.docx");
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    // Without the accompanying fix in place, this test would have failed with 'Expected: 7639;
+    // Actual: 12926'. The shape was below the second "Lorem ipsum" text, not above it.
+    assertXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds", "top", "7639");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 745e2459de6c..d6410d60888b 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -635,12 +635,6 @@ void SwUiWriterTest2::testTdf122942()
     const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats.size());
 
-    // Without the accompanying fix in place, this test would have failed with
-    // 'Expected less than: 0; Actual  : 1030', i.e. the shape was below the
-    // paragraph mark, not above it.
-    const SwFormatVertOrient& rVert = rFormats[1]->GetVertOrient();
-    CPPUNIT_ASSERT_LESS(static_cast<SwTwips>(0), rVert.GetPos());
-
     reload("writer8", "tdf122942.odt");
     pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
     pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
@@ -648,14 +642,15 @@ void SwUiWriterTest2::testTdf122942()
     const SwFrameFormats& rFormats2 = *pDoc->GetSpzFrameFormats();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats2.size());
 
-    SdrObject* pObject = rFormats2[1]->FindSdrObject();
-    CPPUNIT_ASSERT(pObject);
-
-    const tools::Rectangle& rOutRect = pObject->GetLastBoundRect();
-    // Without the accompanying fix in place, this test would have failed with
-    // 'Expected greater than: 5000; Actual  : 2817', i.e. the shape moved up
-    // after a reload(), while it's expected to not change its position (5773).
-    CPPUNIT_ASSERT_GREATER(static_cast<SwTwips>(5000), rOutRect.Top());
+    // Make sure the top of the inserted shape does not move outside the existing shape, even after
+    // reload.
+    SdrObject* pObject1 = rFormats2[0]->FindSdrObject();
+    CPPUNIT_ASSERT(pObject1);
+    const tools::Rectangle& rOutRect1 = pObject1->GetLastBoundRect();
+    SdrObject* pObject2 = rFormats2[1]->FindSdrObject();
+    CPPUNIT_ASSERT(pObject2);
+    const tools::Rectangle& rOutRect2 = pObject2->GetLastBoundRect();
+    CPPUNIT_ASSERT(rOutRect2.Top() > rOutRect1.Top() && rOutRect2.Top() < rOutRect1.Bottom());
 }
 
 void SwUiWriterTest2::testDocxAttributeTableExport()
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index d5a71ed936a7..e7f221c705e9 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -3928,7 +3928,8 @@ void SwTextFrame::CalcBaseOfstForFly()
     if (!GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS))
         return;
 
-    mnFlyAnchorVertOfstNoWrap = nFlyAnchorVertOfstNoWrap;
+    if (mnFlyAnchorOfstNoWrap > 0)
+        mnFlyAnchorVertOfstNoWrap = nFlyAnchorVertOfstNoWrap;
 }
 
 SwTwips SwTextFrame::GetBaseVertOffsetForFly(bool bIgnoreFlysAnchoredAtThisFrame) const


More information about the Libreoffice-commits mailing list