include/test/unoapi_test.hxx                                     |    5 ++
 sw/qa/extras/ooxmlexport/data/tdf159207_footerFramePrBorder.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport21.cxx                       |   18 
++++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx                |    4 ++
 4 files changed, 27 insertions(+)

New commits:
commit 4d3e10fe4503810f17c60443b84a300a543a44b6
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Sat Jan 20 19:54:54 2024 -0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Jan 24 09:16:42 2024 +0100

    tdf#159207 writerfilter framePr: avoid unexpected frame borders
    
    This backport includes some extra code to simplify
    future unit test backports: loadFromFile -> loadFromURL
    
    This fixes my regressive 7.6 commit
    31ea6305b6a763ee48f639562313d9bd109a2923
    
    The text's first border checked (the left one) returned void
    because the property SetState was DONTCARE.
    Then it SETS the text's left border to be nothing
    (I presume to remove the border from the paragraph since
    it is moving it onto frame).
    Well, apparently that act of setting one border sets all of them
    (which makes sense since it would be one box item,
    and once the box item exists, it has a definition for each border).
    
    Therefore on the the next steps of the for loop,
    the remaining borders will exist (as nothing)
    and be dutifully moved to the frame.
    
    Apparently the default for a frame is a box with DEFINED borders,
    so omitting the moving of a nothing border resulted in a stray edge.
    
    make CppunitTest_sw_ooxmlexport21 \
        CPPUNIT_TEST_NAME=testTdf159207_footerFramePrBorder
    
    Change-Id: I217d02678b368f70643be91c4466927b4ca53988
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162409
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    (cherry picked from commit f43efd5473862edbdad0feb7f78c7be02914e997)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162375
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162443
    Tested-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/include/test/unoapi_test.hxx b/include/test/unoapi_test.hxx
index 4ba209c44d39..bd6a2082eb6f 100644
--- a/include/test/unoapi_test.hxx
+++ b/include/test/unoapi_test.hxx
@@ -39,6 +39,11 @@ public:
     void loadWithParams(const OUString& rURL,
                         const css::uno::Sequence<css::beans::PropertyValue>& 
rParams);
     OUString loadFromURL(std::u16string_view aFileBase, const char* pPassword 
= nullptr);
+    OUString loadFromFile(std::u16string_view aFileBase, const char* pPassword 
= nullptr)
+    {
+        //simplify backports
+        return loadFromURL(aFileBase, pPassword);
+    }
 
     css::uno::Any executeMacro(const OUString& rScriptURL,
                                const css::uno::Sequence<css::uno::Any>& 
rParams = {});
diff --git a/sw/qa/extras/ooxmlexport/data/tdf159207_footerFramePrBorder.docx 
b/sw/qa/extras/ooxmlexport/data/tdf159207_footerFramePrBorder.docx
new file mode 100644
index 000000000000..7a4c54cc5c75
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf159207_footerFramePrBorder.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
index 9f6de0d155d5..a6df0bff9300 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -44,6 +44,24 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153909_followTextFlow, 
"tdf153909_followTextFlow
     CPPUNIT_ASSERT(nTableTop > nRectBottom);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf159207_footerFramePrBorder)
+{
+    loadFromFile(u"tdf159207_footerFramePrBorder.docx"); // re-imports as 
editeng Frame/Shape
+
+    // given a doc with footer paragraphs frame (with a top border, but no 
left border)
+    uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> 
xIndexAccess(xTextFramesSupplier->getTextFrames(),
+                                                         uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xFrame0(xIndexAccess->getByIndex(0), 
uno::UNO_QUERY);
+    auto aBorder = getProperty<table::BorderLine2>(xFrame0, "LeftBorder");
+    sal_uInt32 nBorderWidth
+        = aBorder.OuterLineWidth + aBorder.InnerLineWidth + 
aBorder.LineDistance;
+    // Without patch it failed with Expected 0, Actual 26
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Left border:", static_cast<sal_uInt32>(0), 
nBorderWidth);
+
+    // TODO: there SHOULD BE a top border, and even if loaded, it would be 
lost on re-import...
+}
+
 } // end of anonymous namespace
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index d6775189d8cb..d4da6625be61 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1694,7 +1694,11 @@ static void 
lcl_MoveBorderPropertiesToFrame(std::vector<beans::PropertyValue>& r
             aValue.Name = sPropertyName;
             aValue.Value = 
xTextRangeProperties->getPropertyValue(sPropertyName);
             if( nProperty < 4 )
+            {
                 xTextRangeProperties->setPropertyValue( sPropertyName, 
uno::Any(table::BorderLine2()));
+                if (!aValue.Value.hasValue())
+                    aValue.Value <<= table::BorderLine2();
+            }
             else // border spacing
             {
                 sal_Int32 nDistance = 0;

Reply via email to