sw/qa/core/layout/flycnt.cxx                                    |    7 +
 sw/qa/extras/ooxmlexport/data/tdf157136_TwoContentControls.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport19.cxx                      |   57 
++++++++++
 sw/source/core/layout/objectformatter.cxx                       |    7 +
 writerfilter/source/dmapper/SdtHelper.cxx                       |    5 
 5 files changed, 74 insertions(+), 2 deletions(-)

New commits:
commit e318b509b38fa27d873a225752d6d68ffc51085e
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri Sep 8 08:26:40 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Sep 11 13:20:02 2023 +0200

    sw floattable, nesting: fix PDF export
    
    The problem was that the bugdoc rendered fine when opened interactively,
    but not when converted to PDF via 'soffice --convert-to pdf'.
    
    The direct cause was that the interactive case also enabled the
    navigator that did one more calculation for each fly, and that fixes the
    layout. The headless export to PDF has no navigator, so that didn't
    happen.
    
    The root of the problem seems to be that:
    
    1) There is a bad left position for the inner follow fly (it's outside
       the page rectangle).
    
    2) SwTabFrame::Split() for the outer tab normally calls
       lcl_RecalcSplitLine() which moves flys away + back.
    
    3) Moving away happens in lcl_InvalidateLowerObjs() in the
       _bMoveObjsOutOfRange case, here we move away both fly 10 and 20 (both
      inner flys).
    
    4) Moving back happens in
       SwToContentAnchoredObjectPosition::CalcPosition(), but that's not
       invoked for the inner follow fly.
    
    Fix the problem by extending SwObjectFormatter::FormatObjsAtFrame_() to
    be more consistent here and move back both flys.
    
    This is related to tdf#55160.
    
    Change-Id: Ia264a828f36cf2bc1d67986ab3a97d57e9d167a7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156691
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit facdac2443d50339f81415d09c1869d19dded7bf)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156608
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 797d5d8c5691..1c69606c8a24 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -1068,6 +1068,13 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNested)
     // rendered and this way the inner anchor had no fly portion, either.
     CPPUNIT_ASSERT_GREATER(pPage2->getFrameArea().Top(), 
pPage2Fly1->getFrameArea().Top());
 
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected less than: 12523
+    // - Actual  : 15312
+    // i.e. the inner follow fly was not "moved back" to its place to have the 
wanted 4400 position,
+    // which makes the "Inner A2" text visible.
+    CPPUNIT_ASSERT_LESS(pPage2->getFrameArea().Right(), 
pPage2Fly1->getFrameArea().Right());
+
     auto pPage2Fly2 = 
rPage2Objs[1]->DynCastFlyFrame()->DynCastFlyAtContentFrame();
     CPPUNIT_ASSERT(pPage2Fly2);
     CPPUNIT_ASSERT(!pPage2Fly2->GetAnchorFrameContainingAnchPos()->IsInFly());
diff --git a/sw/source/core/layout/objectformatter.cxx 
b/sw/source/core/layout/objectformatter.cxx
index 15ca544a2d9c..b99da6a0fe4b 100644
--- a/sw/source/core/layout/objectformatter.cxx
+++ b/sw/source/core/layout/objectformatter.cxx
@@ -390,7 +390,12 @@ bool SwObjectFormatter::FormatObjsAtFrame_( SwTextFrame* 
_pMasterTextFrame )
                 pAnchorCharFrame != pAnchoredObj->GetAnchorFrame() &&
                 pAnchorCharFrame->FindBodyFrame() ==
                     
static_cast<SwTextFrame*>(pAnchoredObj->AnchorFrame())->FindBodyFrame();
-        if ( bAnchoredAtFollowInSameBodyAsMaster )
+        // Make sure that in case nested split flys are moved "out of range" in
+        // lcl_InvalidateLowerObjs(), then we moved them back here.
+        SwFlyFrame* pFly = pAnchoredObj->DynCastFlyFrame();
+        bool bSplitFly = pFly && pFly->IsFlySplitAllowed();
+        bool bNestedSplitFly = bSplitFly && pAnchorCharFrame && 
pAnchorCharFrame->IsInFly();
+        if (bAnchoredAtFollowInSameBodyAsMaster && !bNestedSplitFly)
         {
             continue;
         }
commit 1b69007a820ac5ca42e237b85744ff4143abfe57
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Sep 7 19:32:54 2023 +0300
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Sep 11 13:19:56 2023 +0200

    tdf#157136: apply top context properties to the text input field
    
    Change-Id: Ie3877811e482c1ec395a00ec6bf67155220b2b64
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156675
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit b7a5c2502434d3da92d1fbcad528cabeb61a2719)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156606
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf157136_TwoContentControls.docx 
b/sw/qa/extras/ooxmlexport/data/tdf157136_TwoContentControls.docx
new file mode 100644
index 000000000000..f4e898cb057f
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf157136_TwoContentControls.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
index d6573d98bb21..7a54119b5714 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
@@ -17,6 +17,8 @@
 #include <com/sun/star/view/XSelectionSupplier.hpp>
 #include <com/sun/star/style/ParagraphAdjust.hpp>
 #include <com/sun/star/text/SizeType.hpp>
+#include <com/sun/star/text/XTextContent.hpp>
+#include <com/sun/star/text/XTextField.hpp>
 #include <com/sun/star/text/XTextTable.hpp>
 
 #include <tools/UnitConversion.hxx>
@@ -1070,6 +1072,61 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156548)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf157136)
+{
+    // Given a document with two content controls - one block, one inline
+    createSwDoc("tdf157136_TwoContentControls.docx");
+
+    // Both of them must import with the correct character style
+
+    {
+        // 1st paragraph - block content control
+        auto xRun = getRun(getParagraph(1), 1);
+        CPPUNIT_ASSERT_EQUAL(OUString("Click or tap here to enter text.\r"), 
xRun->getString());
+        // Without the fix in place, this would fail with
+        // - Expected: Placeholder Text
+        // - Actual  :
+        CPPUNIT_ASSERT_EQUAL(OUString("Placeholder Text"),
+                             getProperty<OUString>(xRun, "CharStyleName"));
+    }
+
+    {
+        // 2nd paragraph - inline content control
+        auto xRun = getRun(getParagraph(2), 1);
+        auto xContentControl
+            = getProperty<css::uno::Reference<css::text::XTextRange>>(xRun, 
"ContentControl");
+        CPPUNIT_ASSERT_EQUAL(OUString("Click or tap here to enter text."),
+                             xContentControl->getString());
+        CPPUNIT_ASSERT_EQUAL(OUString("Placeholder Text"),
+                             getProperty<OUString>(xRun, "CharStyleName"));
+    }
+
+    // Test the same after round-trip
+    saveAndReload("Office Open XML Text");
+
+    {
+        // 1st paragraph - becomes inline content control after roundtrip
+        auto xRun = getRun(getParagraph(1), 1);
+        auto xContentControl
+            = getProperty<css::uno::Reference<css::text::XTextRange>>(xRun, 
"ContentControl");
+        CPPUNIT_ASSERT_EQUAL(OUString("Click or tap here to enter text."),
+                             xContentControl->getString());
+        CPPUNIT_ASSERT_EQUAL(OUString("Placeholder Text"),
+                             getProperty<OUString>(xRun, "CharStyleName"));
+    }
+
+    {
+        // 2nd paragraph - inline content control
+        auto xRun = getRun(getParagraph(2), 1);
+        auto xContentControl
+            = getProperty<css::uno::Reference<css::text::XTextRange>>(xRun, 
"ContentControl");
+        CPPUNIT_ASSERT_EQUAL(OUString("Click or tap here to enter text."),
+                             xContentControl->getString());
+        CPPUNIT_ASSERT_EQUAL(OUString("Placeholder Text"),
+                             getProperty<OUString>(xRun, "CharStyleName"));
+    }
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx 
b/writerfilter/source/dmapper/SdtHelper.cxx
index 4f94c46f2f55..041802147605 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -350,8 +350,11 @@ void SdtHelper::createPlainTextControl()
 
     xPropertySet->setPropertyValue("Content", uno::Any(aDefaultText));
 
+    PropertyMap aMap;
+    aMap.InsertProps(m_rDM_Impl.GetTopContext());
+
     // add it into document
-    m_rDM_Impl.appendTextContent(xControlModel, 
uno::Sequence<beans::PropertyValue>());
+    m_rDM_Impl.appendTextContent(xControlModel, aMap.GetPropertyValues());
 
     // Store all unused sdt parameters from grabbag
     xPropertySet->setPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG,

Reply via email to