[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Mar 11 14:55:26 UTC 2020


 sw/qa/extras/layout/data/btlr-table-row-span.odt |binary
 sw/qa/extras/layout/layout.cxx                   |   18 ++++++++++++++++++
 sw/source/core/layout/ssfrm.cxx                  |   14 +++++++++++++-
 sw/source/core/text/atrhndl.hxx                  |    3 ++-
 sw/source/core/text/atrstck.cxx                  |    6 ++++--
 sw/source/core/text/redlnitr.cxx                 |    9 +++++----
 6 files changed, 42 insertions(+), 8 deletions(-)

New commits:
commit 5e191ec6b99c10454837cadf350102f370aac42b
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Mar 9 22:11:35 2020 +0100
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Wed Mar 11 15:54:53 2020 +0100

    tdf#128880 sw btlr: fix SwFrame::GetPaintArea() for the row span case
    
    To be specific, this focuses on the case where a single cell has btlr
    direction, but the containing row does not, and there is a row span.
    
    The old code that took the logical right of the cell frame served two
    purposes, it seems to me:
    
    - in the rare case where the 1st row is wider then a subsequent row, we
      make sure that as the cell frame is expanded downwards, we're still
      inside the table polygon
    
    - in the tb-rl ("Japanese") case, the logical right maps to physical
      bottom, and this way the cell frame is OK to render not only into its
      own row frame, but can expand also downwards.
    
    Given that btlr maps left to bottom, this mechanism is broken there. Be
    consistent with the working tbrl case, so just expand towards the
    logical left in the btlr case.
    
    The rest of the changes just make sure that SwAttrHandler::FontChg()
    calls SwFont::SetVertical() with the correct bVertLayoutLRBT parameter,
    which instantly fixes the actual position of the text.
    
    (cherry picked from commit 74f0105a2c140d078932576b457a327f3d2490a6)
    
    Conflicts:
            sw/qa/core/layout/layout.cxx
    
    Change-Id: I9032e7c6de72cec704843f3aae3c7848e139ebfa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90251
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    Signed-off-by: Xisco Fauli <xiscofauli at libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90327

diff --git a/sw/qa/extras/layout/data/btlr-table-row-span.odt b/sw/qa/extras/layout/data/btlr-table-row-span.odt
new file mode 100644
index 000000000000..ca4b6872fb3b
Binary files /dev/null and b/sw/qa/extras/layout/data/btlr-table-row-span.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index eaa790cb9878..331f25773253 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3305,6 +3305,24 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128399)
     CPPUNIT_ASSERT_EQUAL(nExpected, aPosition.nNode.GetIndex());
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testBtlrTableRowSpan)
+{
+    // Load a document which has a table. The A1 cell has btlr text direction, and the A1..A3 cells
+    // are merged.
+    load(DATA_DIRECTORY, "btlr-table-row-span.odt");
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    SwDocShell* pShell = pTextDoc->GetDocShell();
+    std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
+    MetafileXmlDump aDumper;
+    xmlDocPtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile);
+
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: USA
+    // - Actual  : West
+    // i.e. the "USA" text completely disappeared.
+    assertXPathContent(pXmlDoc, "//textarray[1]/text", "USA");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/ssfrm.cxx b/sw/source/core/layout/ssfrm.cxx
index 90b5e2958af2..caf0add1565f 100644
--- a/sw/source/core/layout/ssfrm.cxx
+++ b/sw/source/core/layout/ssfrm.cxx
@@ -645,7 +645,19 @@ const SwRect SwFrame::GetPaintArea() const
             if( pTmp->IsVertical() )
                 nTmpLeft = (pNxt->getFrameArea().*fnRect->fnGetLeft)();
             else
-                nTmpRight = (pNxt->getFrameArea().*fnRect->fnGetRight)();
+            {
+                // pTmp is a row frame, but it's not vertical.
+                if (IsVertLRBT())
+                {
+                    // This frame cell is OK to expand towards the physical down direction.
+                    // Physical down is left.
+                    nTmpLeft = (pNxt->getFrameArea().*fnRect->fnGetLeft)();
+                }
+                else
+                {
+                    nTmpRight = (pNxt->getFrameArea().*fnRect->fnGetRight)();
+                }
+            }
         }
         OSL_ENSURE( pTmp, "GetPaintArea lost in time and space" );
         if( pTmp->IsPageFrame() || pTmp->IsFlyFrame() ||
diff --git a/sw/source/core/text/atrhndl.hxx b/sw/source/core/text/atrhndl.hxx
index 81a141327e30..c2fd8d1a447e 100644
--- a/sw/source/core/text/atrhndl.hxx
+++ b/sw/source/core/text/atrhndl.hxx
@@ -90,6 +90,7 @@ private:
     std::unique_ptr<SwFont> m_pFnt;
 
     bool m_bVertLayout;
+    bool m_bVertLayoutLRBT;
 
     // change font according to pool item
     void FontChg(const SfxPoolItem& rItem, SwFont& rFnt, bool bPush );
@@ -113,7 +114,7 @@ public:
     void Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAttrSet,
                const IDocumentSettingAccess& rIDocumentSettingAccess,
                const SwViewShell* pShell, SwFont& rFnt,
-               bool bVertLayout );
+               bool bVertLayout, bool bVertLayoutLRBT );
 
     bool IsVertLayout() const { return m_bVertLayout; }
 
diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx
index eb2762fffb40..a49772fdf923 100644
--- a/sw/source/core/text/atrstck.cxx
+++ b/sw/source/core/text/atrstck.cxx
@@ -346,6 +346,7 @@ SwAttrHandler::SwAttrHandler()
     : m_pIDocumentSettingAccess(nullptr)
     , m_pShell(nullptr)
     , m_bVertLayout(false)
+    , m_bVertLayoutLRBT(false)
 {
     memset( m_pDefaultArray, 0, NUM_DEFAULT_VALUES * sizeof(SfxPoolItem*) );
 }
@@ -367,7 +368,7 @@ void SwAttrHandler::Init( const SwAttrSet& rAttrSet,
 void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAS,
                           const IDocumentSettingAccess& rIDocumentSettingAcces,
                           const SwViewShell* pSh,
-                          SwFont& rFnt, bool bVL )
+                          SwFont& rFnt, bool bVL, bool bVertLayoutLRBT )
 {
     // initialize default array
     memcpy( m_pDefaultArray, pPoolItem,
@@ -378,6 +379,7 @@ void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAS,
 
     // do we have to apply additional paragraph attributes?
     m_bVertLayout = bVL;
+    m_bVertLayoutLRBT = bVertLayoutLRBT;
 
     if ( pAS && pAS->Count() )
     {
@@ -832,7 +834,7 @@ void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, bool bPush )
 
             if ( !bTwoLineAct )
                 rFnt.SetVertical( static_cast<const SvxCharRotateItem&>(rItem).GetValue(),
-                                   m_bVertLayout );
+                                   m_bVertLayout, m_bVertLayoutLRBT );
 
             break;
         }
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 6133b08ce1bb..3af6560df2d7 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -328,11 +328,11 @@ void SwAttrIter::InitFontAndAttrHandler(
 
     // set font to vertical if frame layout is vertical
     // if it's a re-init, the vert flag never changes
+    bool bVertLayoutLRBT = false;
+    if (pbVertLayoutLRBT)
+        bVertLayoutLRBT = *pbVertLayoutLRBT;
     if (pbVertLayout ? *pbVertLayout : m_aAttrHandler.IsVertLayout())
     {
-        bool bVertLayoutLRBT = false;
-        if (pbVertLayoutLRBT)
-            bVertLayoutLRBT = *pbVertLayoutLRBT;
         m_pFont->SetVertical(m_pFont->GetOrientation(), true, bVertLayoutLRBT);
     }
 
@@ -343,7 +343,8 @@ void SwAttrIter::InitFontAndAttrHandler(
     // them to the font
     m_aAttrHandler.Init(aFontAccess.Get()->GetDefault(), rTextNode.GetpSwAttrSet(),
            *rTextNode.getIDocumentSettingAccess(), m_pViewShell, *m_pFont,
-           pbVertLayout ? *pbVertLayout : m_aAttrHandler.IsVertLayout() );
+           pbVertLayout ? *pbVertLayout : m_aAttrHandler.IsVertLayout(),
+           bVertLayoutLRBT );
 
     m_aFontCacheIds[SwFontScript::Latin] = m_aFontCacheIds[SwFontScript::CJK] = m_aFontCacheIds[SwFontScript::CTL] = nullptr;
 


More information about the Libreoffice-commits mailing list