tdf#164945 writerfilter: RTF import: fix erroneous default paragraph...

... properties in empty table cell.

The problem is that for an empty table cell, there is a sequence of
buffer entries SETSTYLE, PROPS, SETSTYLE, PROPS, and the 2nd PROPS
sets a default value of the LN_CT_PrBase_pBdr SPRM, and that overwrites
the \brdrs value that was contained in the 1st PROPS.

All these buffer entries originate in \cell handler, which must use
ST_StyleType_character when buffering the character properties, then no
paragraph properties will be generated in getProperties() for the 2nd
PROPS.

(regression from commit 6f42a2c863)

Change-Id: Iefb939d8d8dace6dc58cb665b4bd1575f09701c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182835
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Tested-by: Jenkins
This commit is contained in:
Michael Stahl
2025-03-13 11:38:30 +01:00
parent 62f541674c
commit 1a7346e7f1
3 changed files with 60 additions and 1 deletions
@@ -0,0 +1,35 @@
{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff0\deff0\stshfdbch31505\stshfloch46\stshfhich46\stshfbi0\deflang1031\deflangfe1041\themelang1031\themelangfe1041\themelangcs0
{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Arial};}
{\f35\fbidi \fswiss\fcharset128\fprq2{\*\panose 020b0400000000000000}Yu Gothic{\*\falt ?a?S?V?b?N};}
{\f46\fbidi \fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Liberation Sans;}
{\fdbminor\f31505\fbidi \fswiss\fcharset128\fprq2{\*\panose 020b0400000000000000}Yu Gothic{\*\falt ?a?S?V?b?N};}
}
{\*\defchp \fs24\kerning2\loch\af46\hich\af46\dbch\af31505 }{\*\defpap \ql \li0\ri0\sa160\sl278\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 }\noqfpromote {\stylesheet{\ql \li0\ri0\sa160\sl278\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0
\fs24\lang1031\langfe1041\kerning2\loch\f46\hich\af46\dbch\af31505\cgrid\langnp1031\langfenp1041 \snext0 \sqformat \spriority0 Normal;}{\*\cs10 \additive \sunhideused \spriority1 Default Paragraph Font;}{\*
\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblind0\tblindtype3\tsvertalt \ql \li0\ri0\sa160\sl278\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0 \fs24\lang1031\langfe1041\kerning2\loch\f46\hich\af46\dbch\af31505\cgrid\langnp1031\langfenp1041 \snext11 \ssemihidden \sunhideused
Normal Table;}
{\s36\q \li0\ri0\widctlpar\brdrb\brdrs\brdrw10\brsp20 \wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0
\fs24\lang1031\langfe1041\kerning2\loch\f46\hich\af46\dbch\af31505\cgrid\langnp1031\langfenp1041 \snext36 \sqformat \spriority1 No Spacing;}}
\paperw11906\paperh16838\margl1417\margr1417\margt1417\margb1134\gutter0\ltrsect
\deftab708\widowctrl\ftnbj\aenddoc\hyphhotz425\trackmoves0\trackformatting1\donotembedsysfont1\relyonvml0\donotembedlingdata0\grfdocevents0\validatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0
\showxmlerrors1\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1417\dgvorigin1417\dghshow1\dgvshow1
\jexpand\viewkind1\viewscale270\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct
\asianbrkrule\newtblstyruls\nogrowautofit\usenormstyforlist\noindnmbrts\felnbrelev\nocxsptable\indrlsweleven\noafcnsttbl\afelev\utinl\hwelev\spltpgpar\notcvasp\notbrkcnstfrctbl\notvatxbx\krnprsnet\cachedcolbal \nouicompat \fet0
{\*\wgrffmtfilter 2450}\nofeaturethrottle1\ilfomacatclnup0\ltrpar \sectd \ltrsect\linex0\headery708\footery708\colsx708\endnhere\sectlinegrid360\sectdefaultcl\sftnbj
\ltrrow\trowd \irow0\irowband0\lastrow \ltrrow
\ts35\trgaph70\trleft-108\trftsWidth1\trftsWidthB3\trautofit1\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tbllkhdrrows\tbllkhdrcols\tbllknocolband\tblind0\tblindtype3 \clvertalt\clbrdrt\brdrtbl \clbrdrl\brdrtbl \clbrdrb
\brdrtbl \clbrdrr\brdrtbl \cltxlrtb\clftsWidth3\clwWidth4531\clshdrawnil \cellx4423\clvertalt\clbrdrt\brdrtbl \clbrdrl\brdrtbl \clbrdrb\brdrtbl \clbrdrr\brdrtbl \cltxlrtb\clftsWidth3\clwWidth4531\clshdrawnil \cellx8954\pard\plain \ltrpar
\s36\qc \li0\ri0\widctlpar\intbl\brdrb\brdrs\brdrw10\brsp20 \wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\yts35 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0
\fs24\lang1031\langfe1041\kerning2\loch\af46\hich\af46\dbch\af31505\cgrid\langnp1031\langfenp1041 {\rtlch\fcs1 \af0 \ltrch\fcs0 \cell }\pard \ltrpar\s36\qj \li0\ri0\widctlpar\intbl\brdrb\brdrs\brdrw10\brsp20
\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\yts35 {\rtlch\fcs1 \af0 \ltrch\fcs0 \hich\af46\dbch\af31505\loch\f46 xxx}{\rtlch\fcs1 \af0 \ltrch\fcs0 \cell }\pard\plain \ltrpar
\ql \li0\ri0\sa160\sl278\slmult1\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0 \fs24\lang1031\langfe1041\kerning2\loch\af46\hich\af46\dbch\af31505\cgrid\langnp1031\langfenp1041 {
\rtlch\fcs1 \af0 \ltrch\fcs0 \trowd \irow0\irowband0\lastrow \ltrrow
\ts35\trgaph70\trleft-108\trftsWidth1\trftsWidthB3\trautofit1\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tbllkhdrrows\tbllkhdrcols\tbllknocolband\tblind0\tblindtype3 \clvertalt\clbrdrt\brdrtbl \clbrdrl\brdrtbl \clbrdrb
\brdrtbl \clbrdrr\brdrtbl \cltxlrtb\clftsWidth3\clwWidth4531\clshdrawnil \cellx4423\clvertalt\clbrdrt\brdrtbl \clbrdrl\brdrtbl \clbrdrb\brdrtbl \clbrdrr\brdrtbl \cltxlrtb\clftsWidth3\clwWidth4531\clshdrawnil \cellx8954\row }\pard \ltrpar
\ql \li0\ri0\sa160\sl278\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 {\rtlch\fcs1 \af0 \ltrch\fcs0
\par }
}
+23
View File
@@ -200,6 +200,29 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf116436_tableBackground)
verify(/*bIsExport*/ true);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf164945)
{
auto verify = [this]() {
uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY_THROW);
uno::Reference<text::XText> xA1(xTable->getCellByName(u"A1"_ustr), uno::UNO_QUERY_THROW);
auto borderA1(
getProperty<table::BorderLine2>(getParagraphOfText(1, xA1), u"BottomBorder"_ustr));
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), borderA1.InnerLineWidth);
CPPUNIT_ASSERT_EQUAL(sal_Int16(18), borderA1.OuterLineWidth);
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), borderA1.LineDistance);
uno::Reference<text::XText> xB1(xTable->getCellByName(u"B1"_ustr), uno::UNO_QUERY_THROW);
auto borderB1(
getProperty<table::BorderLine2>(getParagraphOfText(1, xB1), u"BottomBorder"_ustr));
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), borderB1.InnerLineWidth);
CPPUNIT_ASSERT_EQUAL(sal_Int16(18), borderB1.OuterLineWidth);
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), borderB1.LineDistance);
};
createSwDoc("noparaborder.rtf");
verify();
saveAndReload(mpFilter);
verify();
}
CPPUNIT_TEST_FIXTURE(Test, testTdf122589_firstSection)
{
auto verify = [this]() {
@@ -202,7 +202,8 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
bufferProperties(m_aTableBufferStack.back(), pPValue, nullptr);
auto pCValue = new RTFValue(m_aStates.top().getCharacterAttributes(),
m_aStates.top().getCharacterSprms());
bufferProperties(m_aTableBufferStack.back(), pCValue, nullptr);
bufferProperties(m_aTableBufferStack.back(), pCValue, nullptr,
NS_ooxml::LN_Value_ST_StyleType_character);
}
RTFValue::Pointer_t pValue;