sw/qa/extras/layout/data/572-min.rtf |  178 +++++++++++++++++++++++++++++++++++
 sw/qa/extras/layout/layout2.cxx      |   56 +++++++++++
 sw/source/core/text/txtfrm.cxx       |   38 ++++++-
 3 files changed, 267 insertions(+), 5 deletions(-)

New commits:
commit b1e08a890457b158d71e9d6a78f1c5739f40adde
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Nov 5 14:59:21 2024 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Mon Nov 11 01:42:36 2024 +0100

    tdf#162268 sw: layout: hidden formatting is ignored on cell end marker
    
    ... in Word, so ignore it in Writer on the last paragraph in a cell.
    
    (regression from commit 7b8cec8322b60673e686660caf875bc71117bbd0)
    
    Word also uses hidden character formatting on the row end marker to
    determine if a row should be hidden; this isn't possible yet.
    
    Change-Id: I7ceaea0d807193155631083616a93cdd058e20d1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176060
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins
    (cherry picked from commit a6d0b7f6832ed313b631484bee8d5bd83651530e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176075
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/sw/qa/extras/layout/data/572-min.rtf 
b/sw/qa/extras/layout/data/572-min.rtf
new file mode 100644
index 000000000000..cedad79b9160
--- /dev/null
+++ b/sw/qa/extras/layout/data/572-min.rtf
@@ -0,0 +1,178 @@
+{ tf1nsinsicpg1252\deff0deff1
+{onttbl{0bidiromancharset0prq2
+{\*\panose 02020603050405020304}
+{\*alt Arial}
+Times New Roman;}{1bidiswisscharset0prq2
+{\*\panose 020b0604020202020204}
+{\*alt Courier New}
+Arial;}{2bidiswisscharset0prq2
+{\*\panose 020b0502040204020203}
+Segoe UI;}{3bidiromancharset2prq2
+{\*\panose 05050102010706020507}
+Symbol;}{4bidiswisscharset0prq2
+{\*\panose 00000000000000000000}
+{\*alt Arial}
+Univers Condensed;}{40bidiromancharset204prq2
+{\*alt Arial}
+Times New Roman Cyr;}{31501dbmajorbidiromancharset0prq2
+{\*\panose 02020603050405020304}
+{\*alt Arial}
+Times New Roman;}{31502himajorbidiromancharset0prq2
+{\*\panose 02040503050406030204}
+Cambria;}{31503bimajorbidiromancharset0prq2
+{\*\panose 02020603050405020304}
+{\*alt Arial}
+Times New Roman;}{31505dbminorbidiromancharset0prq2
+{\*\panose 02020603050405020304}
+{\*alt Arial}
+Times New Roman;}{31506himinorbidiswisscharset0prq2
+{\*\panose 020f0502020204030204}
+Calibri;}{31507biminorbidiromancharset0prq2
+{\*\panose 02020603050405020304}
+{\*alt Arial}
+Times New Roman;}}
+{+ ed0\green255lue0; ed255\green0lue255; ed255\green0lue0; ed255
+\green255lue0; ed255\green255lue255; ed0\green0lue128; ed0
+\green128lue128; ed0\green128lue0; ed128\green0lue128; ed128
+\green0lue0; ed128\green128lue0; ed128\green128lue128; ed192
+\green192lue192;;;; ed0\green32lue96;}
+deflang1025\stshfdbch31505
+\stshfloch31506\stshfhich31506\stshfbi0\deflang1031\deflangfe1031
+       hemelang1031    hemelangfe0     hemelangcs0
+{\*\defchps22\lochf31506\hichf31506\dbchf31505}
+{\*\defpap\ql\li0 i0\sa200\sl276\slmult1\widctlpar\wrapdefaultspalpha
+spnumaautodjustright in0\lin0\itap0}
+{\stylesheet{\ql\li0 i0\widctlpar\wrapdefaultaautodjustright in0\lin0
+\itap0 tlchcs1f1fs20lang1025\ltrchcs0s20\lang1031\langfe1031
+\loch1\hichf1\dbchf31505+\sqformat\spriority0 Normal;}{\s1\ql\li0 
i0\keepn\widctlpar\wrapdefault
+aauto\outlinelevel0djustright in0\lin0\itap0 tlchcs1bf1fs20
+lang1025\ltrchcs0s20\lang1031\langfe1031\loch1\hichf1\dbch
+f31505+heading 1;}{\s3\ql\li0 i0
+\keepn\widctlpar\wrapdefaultaauto\outlinelevel2djustright in0\lin0
+\itap0 tlchcs1f1fs20lang1025\ltrchcs0s20+\langfe1031\loch
1\hichf1\dbchf31505+\sbasedon0\snext0\slink17\sqformat heading 3;}
+{\*+{\*        s11     srowd   rftsWidthB3     rpaddl108       rpaddr108       
rpaddfl3        rpaddft3
+       rpaddfb3        rpaddfr3        rcbpat1 rcfpat1 blind0  blindtype3      
scellwidthfts0
+       svertalt        sbrdrt  sbrdrl  sbrdrb  sbrdrr  sbrdrdgl        
sbrdrdgr        sbrdrh
+       sbrdrv\ql\li0 i0\sa200\sl276\slmult1\widctlpar\wrapdefaultspalpha
+spnumaautodjustright in0\lin0\itap0 tlchcs1f0fs22lang1025
+\ltrchcs0s22\lang1031\langfe1031\loch31506\hichf31506\dbchf31505
++Normal Table;}
+{\*+\loch31502\hichf31502\dbchf31501\sbasedon10\slink1\slocked\spriority9
+�berschrift 1 Zchn;}
+{\*+\hichf31502\dbchf31501\sbasedon10\slink3\slocked\ssemihidden\spriority9
+�berschrift 3 Zchn;}
+{\s23\ql\li0 i0\widctlpar\wrapdefaultaautodjustright in0\lin0\itap0
+ tlchcs1f1fs72lang1025\ltrchcs0s72+\loch
1\hichf1\dbchf31505+\snext23\slink24 Body Text;}
+{\*+\slink23\slocked\ssemihidden Textk�rper Zchn;}
+}
+\paperw11906\paperh16838\margl1418\margr851\margt1134\margb1134\gutter0
+\deftab708\widowctrltnbjenddoc\hyphhotz425   rackmoves1      rackformatting1
+\donotembedsysfont0 elyonvml0\donotembedlingdata1\grfdocevents0
+alidatexml0\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0
+\showxmlerrors0
oxlattoyenxpshrtn
oultrlspc\dntblnsbdb
ospaceforul
+\hyphcaps0ormshade\horzdoc\dgmargin\dghspace100\dgvspace120\dghorigin1418
+\dgvorigin1134\dghshow0\dgvshow3\jcompressiewkind1iewscale217iewzk2
+
olnhtadjtblet0
+{\*\wgrffmtfilter 2450}
+\ilfomacatclnup0
+{\*\generator CIB merge 3.13.9}
+\uc1
oqfpromote
+\ltrsect\pgbrdrhead\pgbrdrfoot\ltrpar\sectd\ltrsect\psz9\sbknone\linex0
+\headery709ootery284+\sectlinegrid272\sectdefaultcl\sftnbj
+\pard\plain\ltrpar\s1\ql\li0 i0\keepn\widctlpar\wrapdefault
+aauto\outlinelevel0djustright in0\lin0\itap0 tlchcs1bf1fs20
+lang1025\ltrchcs0s20\lang1031\langfe1031\lochf1\hichf1\dbch
+f31505++}
+
+       rowd\irow12\irowband12\ltrrow   s11     rgaph70 rleft-70        
rbrdrtrdrs
+rdrw10        rbrdrlrdrsrdrw10      rbrdrbrdrsrdrw10      
rbrdrrrdrsrdrw10
+       rbrdrhrdrsrdrw10      rbrdrvrdrsrdrw10      rftsWidth3      
rwWidth10204
+       rftsWidthB3     rftsWidthA3     rautofit1       rpaddl70        
rpaddr70        rpaddfl3
+       rpaddfr3        blind0  
blindtype3+++rdrnone++rdrnone++rdrnone++\intbl\wrapdefaultaautodjustright 
in0\lin0{ tlchcs1
+f1fs20\ltrchcs0s20+1 05.05.2008+}\pard\plain\ltrpar\s3\ql\li0 
i0\keepn\widctlpar\intbl\wrapdefaultaauto
+\outlinelevel2djustright in0\lin0 tlchcs1f1fs20
+lang1025\ltrchcs0
+
+s20+f31507+\hichf1\dbchf31507\loch1 Aufruf \par
+}\pard\plain\ltrpar\s24\ql\li0 i0\keepn\widctlpar\intbl\wrapdefaultaauto
+djustright in0\lin0 tlchcs1f1fs20lang1025\ltrch
+cs0s20+\langnp1031\langfenp1031{ tlchcs1f1\ltrchcs0\hichf1
+\dbchf31507\loch1\hich1 \loch1\hich1 IF MERGEFIELD Nr\par
+}
+\pard\plain\ltrpar\ql\li0 i0\keepn\widctlpar\intbl\wrapdefaultaauto
+djustright in0\lin0 tlchcs1f1fs22lang1025\ltrch
+cs0
s22\lang1031\langfe1031\lochf1\hichf1\dbchf31507+\langnp1031\langfenp1031{ 
tlchcs1f1fs20\ltrchcs0s20+\hichf1\dbchf31507\loch1\hich1 Feld+}
+\pard\ltrpar\ql\li0 i0\sa200\sl276\slmult1\widctlpar\intbl\wrapdefault
+spalphaspnumaautodjustright in0\lin0{ tlchcs1f1fs20\ltrch
+cs0s20+     rgaph70 rleft-70        rbrdrtrdrsrdrw10      
rbrdrlrdrsrdrw10      rbrdrb
+rdrsrdrw10   rbrdrrrdrsrdrw10      rbrdrhrdrsrdrw10      rbrdrvrdrs
+rdrw10        rftsWidth3      rwWidth10204    rftsWidthB3     rftsWidthA3     
rautofit1
+       rpaddl70        rpaddr70        rpaddfl3        rpaddfr3        blind0  
blindtype3
++rdrnone+++rdrnone++++}\pard\ltrpar\ql\li0 
i0\keepn\widctlpar\intbl\wrapdefaultaauto
+djustright in0\lin0{ tlchcs1f1fs20\ltrchcs0
+s20+\hichf1\dbchf31507\loch1 Neuer +}\pard\ltrpar\ql\li0 
i0\sa200\sl276\slmult1\widctlpar\intbl\wrapdefault
+spalphaspnumaautodjustright in0\lin0{ tlchcs1f1\ltrchcs0
++      rbrdrtrdrsrdrw10      rbrdrlrdrsrdrw10      rbrdrbrdrsrdrw10      
rbrdrr
+rdrsrdrw10   rbrdrhrdrsrdrw10      rbrdrvrdrsrdrw10      rftsWidth3
+       rwWidth10204    rftsWidthB3     rftsWidthA3     rautofit1       
rpaddl70        rpaddr70
+       rpaddfl3        rpaddfr3        blind0  
blindtype3+rdrnone++++rdrnone++rdrnone++}
+
+\pard\plain\ltrpar\ql\li0 i0\keepn\widctlpar   x1701\wrapdefaultaauto
+djustright in0\lin0\itap0 tlchcs1f1fs20lang1025\ltrchcs0s20
+\lang1031\langfe1031\lochf1\hichf1\dbchf31505+\langfenp1031{ tlch
cs1f1\ltrchcs0+}
+}
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 7fb6a0769473..6319e9335bba 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -2220,6 +2220,62 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf137819)
     CPPUNIT_ASSERT(sTextRightSidePosition.toInt32() < 
sShapeRightSidePosition.toInt32());
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testParagraphMarkInCell)
+{
+    createSwDoc("572-min.rtf");
+
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier(
+        xModel->getCurrentController(), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> 
xViewSettings(xViewSettingsSupplier->getViewSettings());
+    uno::Any aOldHidden{ 
xViewSettings->getPropertyValue(u"ShowHiddenCharacters"_ustr) };
+    uno::Any aOldNon{ 
xViewSettings->getPropertyValue(u"ShowNonprintingCharacters"_ustr) };
+    comphelper::ScopeGuard g([&] {
+        xViewSettings->setPropertyValue(u"ShowHiddenCharacters"_ustr, 
aOldHidden);
+        xViewSettings->setPropertyValue(u"ShowNonprintingCharacters"_ustr, 
aOldNon);
+    });
+
+    xViewSettings->setPropertyValue(u"ShowHiddenCharacters"_ustr, 
uno::Any(true));
+    xViewSettings->setPropertyValue(u"ShowNonprintingCharacters"_ustr, 
uno::Any(true));
+
+    {
+        xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+        assertXPath(pXmlDoc, "/root/page/body/txt[1]/infos/bounds"_ostr, 
"height"_ostr, "230");
+        assertXPath(pXmlDoc, 
"/root/page/body/tab[1]/row[1]/infos/bounds"_ostr, "height"_ostr,
+                    "690");
+        assertXPath(pXmlDoc, 
"/root/page/body/tab[1]/row[2]/infos/bounds"_ostr, "height"_ostr,
+                    "230");
+        assertXPath(pXmlDoc, "/root/page/body/txt[2]/infos/bounds"_ostr, 
"height"_ostr, "230");
+        discardDumpedLayout();
+    }
+
+    xViewSettings->setPropertyValue(u"ShowNonprintingCharacters"_ustr, 
uno::Any(false));
+
+    {
+        xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+        assertXPath(pXmlDoc, "/root/page/body/txt[1]/infos/bounds"_ostr, 
"height"_ostr, "230");
+        // the problem was that the table rows were not hidden
+        //TODO        assertXPath(pXmlDoc, 
"/root/page/body/tab[1]/row[1]/infos/bounds"_ostr, "height"_ostr,
+        //                    "0");
+        assertXPath(pXmlDoc, 
"/root/page/body/tab[1]/row[2]/infos/bounds"_ostr, "height"_ostr, "0");
+        assertXPath(pXmlDoc, "/root/page/body/txt[2]/infos/bounds"_ostr, 
"height"_ostr, "230");
+        discardDumpedLayout();
+    }
+
+    xViewSettings->setPropertyValue(u"ShowNonprintingCharacters"_ustr, 
uno::Any(true));
+
+    {
+        xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+        assertXPath(pXmlDoc, "/root/page/body/txt[1]/infos/bounds"_ostr, 
"height"_ostr, "230");
+        assertXPath(pXmlDoc, 
"/root/page/body/tab[1]/row[1]/infos/bounds"_ostr, "height"_ostr,
+                    "690");
+        assertXPath(pXmlDoc, 
"/root/page/body/tab[1]/row[2]/infos/bounds"_ostr, "height"_ostr,
+                    "230");
+        assertXPath(pXmlDoc, "/root/page/body/txt[2]/infos/bounds"_ostr, 
"height"_ostr, "230");
+        discardDumpedLayout();
+    }
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testParagraphMarkLineHeight)
 {
     createSwDoc("A020-min.rtf");
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index bbf18f79ef66..793a03b98903 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -1475,6 +1475,19 @@ void SwTextFrame::ResetPreps()
     }
 }
 
+static auto FindCellFrame(SwFrame const* pLower) -> SwLayoutFrame const*
+{
+    while (pLower)
+    {
+        if (pLower->IsCellFrame())
+        {
+            return static_cast<SwLayoutFrame const*>(pLower);
+        }
+        pLower = pLower->GetUpper();
+    }
+    return nullptr;
+}
+
 bool SwTextFrame::IsHiddenNow() const
 {
     SwFrameSwapper aSwapper( this, true );
@@ -1549,12 +1562,27 @@ bool SwTextFrame::IsHiddenNow() const
         SwTextNode const*const pNode{ m_pMergedPara
             ? m_pMergedPara->pLastNode
             : static_cast<SwTextNode const*>(SwFrame::GetDep()) };
-        SwFormatAutoFormat const& 
rListAutoFormat{pNode->GetAttr(RES_PARATR_LIST_AUTOFMT)};
-        std::shared_ptr<SfxItemSet> const 
pSet{rListAutoFormat.GetStyleHandle()};
-        SvxCharHiddenItem const*const pItem{pSet ? 
pSet->GetItemIfSet(RES_CHRATR_HIDDEN) : nullptr};
-        if (!pItem || !pItem->GetValue())
+        // Word ignores hidden formatting on the cell end marker
+        bool isLastInCell{false};
+        if (SwLayoutFrame const*const pCellFrame{FindCellFrame(this)})
         {
-            bHiddenCharsHidePara = false;
+            SwContentFrame const* pNext{GetNextContentFrame()};
+            // skip frame in hidden section ("this" is *not* in hidden 
section!)
+            while (pNext && pNext->SwContentFrame::IsHiddenNow())
+            {
+                pNext = pNext->GetNextContentFrame();
+            }
+            isLastInCell = pNext == nullptr || !pCellFrame->IsAnLower(pNext);
+        }
+        if (!isLastInCell)
+        {
+            SwFormatAutoFormat const& 
rListAutoFormat{pNode->GetAttr(RES_PARATR_LIST_AUTOFMT)};
+            std::shared_ptr<SfxItemSet> const 
pSet{rListAutoFormat.GetStyleHandle()};
+            SvxCharHiddenItem const*const pItem{pSet ? 
pSet->GetItemIfSet(RES_CHRATR_HIDDEN) : nullptr};
+            if (!pItem || !pItem->GetValue())
+            {
+                bHiddenCharsHidePara = false;
+            }
         }
     }
     const SwViewShell* pVsh = getRootFrame()->GetCurrShell();

Reply via email to