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

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Sun Jul 26 18:51:50 UTC 2020


 sw/qa/extras/layout/data/tdf106234.fodt |   31 +++++++++++++++++++++++++++++++
 sw/qa/extras/layout/layout.cxx          |   21 +++++++++++++++++++++
 sw/source/core/text/itradj.cxx          |   17 ++++++++++++++++-
 3 files changed, 68 insertions(+), 1 deletion(-)

New commits:
commit 2674d9d09d85ac268a6f0279bf2a9777a95c153f
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Tue Jun 16 08:13:19 2020 +0200
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Sun Jul 26 20:51:20 2020 +0200

    tdf#106234 sw: don't justify after centered tabs
    
    (also after right-aligned and decimal-aligned tabs)
    before manual line break in a justified paragraph.
    Justify only after left-aligned tabs, like MSO does.
    
    Regression from commit 07dcbed5fb6d88f69d84313ddede81c222a5a7a6
      (INTEGRATION: CWS fmebugs01 (1.15.104); FILE MERGED
      2004/02/09 15:13:57 fme 1.15.104.1: #i13507# Justified
      alignment for lines containing manual breaks).
    
    See also commit 5d7b3475278f59a423c2139ae51f9b4849621890
      (INTEGRATION: CWS swqbf34 (1.17.96); FILE MERGED
      2005/06/29 12:12:25 fme 1.17.96.2: #i49277# New
      compatibility option bDoNotJustifyLinesWithManualBreak).
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96438
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit d5325013c4f71595dc4edd08e3957d27bc5e0d9b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96426
    Tested-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
    (cherry picked from commit 0d963060b612977139138d25b9e4649f84800a28)
    
    Change-Id: Ib92e301aaf46eec283c0850d23549b1b54106068
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99400
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/sw/qa/extras/layout/data/tdf106234.fodt b/sw/qa/extras/layout/data/tdf106234.fodt
new file mode 100644
index 000000000000..18667c4ab152
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf106234.fodt
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:styles>
+  <style:style style:name="Standard" style:family="paragraph" style:class="text"/>
+  <style:default-style style:family="paragraph">
+   <style:text-properties fo:language="rn" fo:country="US"/>
+  </style:default-style>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
+   <style:paragraph-properties fo:text-align="justify" style:justify-single-word="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="2.554cm"/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+  <style:style style:name="P2" style:family="paragraph" style:parent-style-name="Standard">
+   <style:paragraph-properties fo:text-align="justify" style:justify-single-word="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="2.554cm" style:type="center"/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+ </office:automatic-styles>
+ <office:body>
+  <office:text>
+   <text:p text:style-name="P1"><text:tab/>Lorem ipsum<text:line-break/>dolor sit amet, consectetur adipiscing elit. (Justify after left-aligned tab)</text:p>
+   <text:p text:style-name="P2"><text:span text:style-name="T1"><text:tab/>Lorem ipsum<text:line-break/>dolor sit amet, consectetur adipiscing elit. (Don’t justify after centered tab!)</text:span></text:p>
+  </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 7155b5e7551c..ee4ecea6be69 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2975,6 +2975,27 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf120287)
     assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak", 1);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf106234)
+{
+    createDoc("tdf106234.fodt");
+    // Ensure that all text portions are calculated before testing.
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+    SwViewShell* pViewShell
+        = pTextDoc->GetDocShell()->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell();
+    CPPUNIT_ASSERT(pViewShell);
+    pViewShell->Reformat();
+
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    // In justified paragraphs, there is justification between left tabulators and page breaks
+    assertXPath(pXmlDoc, "/root/page/body/txt[1]/Special", "nType", "PortionType::Margin");
+    assertXPathNoAttribute(pXmlDoc, "/root/page/body/txt[1]/Special", "nWidth");
+    // but not after centered, right and decimal tabulators
+    assertXPath(pXmlDoc, "/root/page/body/txt[2]/Special", "nType", "PortionType::Margin");
+    // This was a justified line, without nWidth
+    assertXPath(pXmlDoc, "/root/page/body/txt[2]/Special", "nWidth", "7881");
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf120287b)
 {
     createDoc("tdf120287b.fodt");
diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx
index f32bc444712e..d35082c4f3c8 100644
--- a/sw/source/core/text/itradj.cxx
+++ b/sw/source/core/text/itradj.cxx
@@ -287,18 +287,33 @@ void SwTextAdjuster::CalcNewBlock( SwLineLayout *pCurrent,
     // #i49277#
     const bool bDoNotJustifyLinesWithManualBreak =
         GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK);
+    bool bDoNotJustifyTab = false;
 
     SwLinePortion *pPos = pCurrent->GetNextPortion();
 
     while( pPos )
     {
-        if ( bDoNotJustifyLinesWithManualBreak &&
+        if ( ( bDoNotJustifyLinesWithManualBreak || bDoNotJustifyTab ) &&
              pPos->IsBreakPortion() && !IsLastBlock() )
         {
            pCurrent->FinishSpaceAdd();
            break;
         }
 
+        switch ( pPos->GetWhichPor() )
+        {
+            case PortionType::TabCenter :
+            case PortionType::TabRight :
+            case PortionType::TabDecimal :
+                bDoNotJustifyTab = true;
+                break;
+            case PortionType::TabLeft :
+            case PortionType::Break:
+                bDoNotJustifyTab = false;
+                break;
+            default: break;
+        }
+
         if ( pPos->InTextGrp() )
             nGluePortion = nGluePortion + static_cast<SwTextPortion*>(pPos)->GetSpaceCnt( GetInfo(), nCharCnt );
         else if( pPos->IsMultiPortion() )


More information about the Libreoffice-commits mailing list