sw/qa/extras/ooxmlimport/data/tdf156078_rightTabOutsideParaRightIndent.docx 
|binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx                                   |  
 34 ++++++++++
 sw/source/core/text/itrpaint.cxx                                            |  
  7 +-
 3 files changed, 39 insertions(+), 2 deletions(-)

New commits:
commit a4195a77ca005d866c6b055db5b21fc7dc7e2b26
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Jun 27 17:42:49 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Jun 28 08:23:42 2023 +0200

    tdf#156078: also consider TabOverflow for tabs outside of line bounds
    
    Before commit 29bd00f7628e7a54e69cabcc7e2a1792c24aa55c, TabOverMargin
    compat option was set for DOCX with any compat mode. After that commit,
    the unset option disallowed output of content after a tab stop outside
    of the paragraph indents, even within page margins.
    
    SwTabPortion::PreFormat consults TabOverflow when checking if position
    is outside the frame; so let's consult it also when painting.
    
    Change-Id: I05ada0da6cd765c70b7bad1287ccc8c11d9b60ba
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153672
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit dbfa56424f3d41bb58b7c9137f25f4ccb76dc92d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153691
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git 
a/sw/qa/extras/ooxmlimport/data/tdf156078_rightTabOutsideParaRightIndent.docx 
b/sw/qa/extras/ooxmlimport/data/tdf156078_rightTabOutsideParaRightIndent.docx
new file mode 100644
index 000000000000..cc2715cf6acd
Binary files /dev/null and 
b/sw/qa/extras/ooxmlimport/data/tdf156078_rightTabOutsideParaRightIndent.docx 
differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index ff96e81b8d08..cc4bb7fe00d8 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -23,6 +23,9 @@
 #include <com/sun/star/text/XTextDocument.hpp>
 #include <com/sun/star/text/XTextTable.hpp>
 
+#include <comphelper/propertysequence.hxx>
+#include <vcl/BitmapReadAccess.hxx>
+#include <vcl/graphicfilter.hxx>
 #include <xmloff/odffields.hxx>
 
 #include <wrtsh.hxx>
@@ -1146,6 +1149,37 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf154695)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf156078)
+{
+    // Given a DOCX with compat level 15, and a tab stop outside of paragraph 
right indent
+    createSwDoc("tdf156078_rightTabOutsideParaRightIndent.docx");
+
+    // Export it to a PNG (96 ppi)
+    uno::Sequence<beans::PropertyValue> aFilterData(
+        comphelper::InitPropertySequence({ { "PixelWidth", 
uno::Any(sal_Int32(816)) },
+                                           { "PixelHeight", 
uno::Any(sal_Int32(1056)) } }));
+    uno::Sequence<beans::PropertyValue> 
aDescriptor(comphelper::InitPropertySequence(
+        { { "FilterName", uno::Any(OUString("writer_png_Export")) },
+          { "FilterData", uno::Any(aFilterData) } }));
+    uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+    xStorable->storeToURL(maTempFile.GetURL(), aDescriptor);
+    CPPUNIT_ASSERT(maTempFile.IsValid());
+
+    Graphic exported;
+    GraphicFilter::LoadGraphic(maTempFile.GetURL(), {}, exported);
+    Bitmap bmp = exported.GetBitmapEx().GetBitmap();
+    Bitmap::ScopedReadAccess pAccess(bmp);
+
+    // "1" must export to the top right corner; check its pixels
+    bool numberPixelsFound = false;
+    for (tools::Long y = 90; y < 130; ++y)
+        for (tools::Long x = 680; x < 720; ++x)
+            if (Color(pAccess->GetPixel(y, x)).IsDark())
+                numberPixelsFound = true;
+
+    CPPUNIT_ASSERT(numberPixelsFound);
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index a66d358645f0..3709e4a56869 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -146,8 +146,11 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, 
SwSaveClip &rClip,
     // Optimization!
     SwTwips nMaxRight = std::min<SwTwips>( rPaint.Right(), Right() );
     const SwTwips nTmpLeft = GetInfo().X();
-    //compatibility setting: allow tabstop text to exceed right margin
-    if 
(GetInfo().GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::TAB_OVER_MARGIN))
+    //compatibility settings: allow tabstop text to exceed right margin
+    const auto& iDSA = 
GetInfo().GetTextFrame()->GetDoc().getIDocumentSettingAccess();
+    const bool bTabOverMargin = iDSA.get(DocumentSettingId::TAB_OVER_MARGIN);
+    const bool bTabOverflow = iDSA.get(DocumentSettingId::TAB_OVERFLOW);
+    if (bTabOverMargin || bTabOverflow)
     {
         SwLinePortion* pPorIter = pPor;
         while( pPorIter )

Reply via email to