sw/qa/extras/rtfexport/data/para-border.rtf | 27 ++++++++++++ sw/qa/extras/rtfexport/rtfexport4.cxx | 62 ++++++++++++++++++++++++++++ writerfilter/source/rtftok/rtfsprm.cxx | 16 +++++++ 3 files changed, 105 insertions(+)
New commits: commit c63093aad97550f7d7a6698f72956656d39ce659 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri Aug 12 14:10:31 2022 +0200 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Aug 16 14:05:54 2022 +0200 tdf#150382 writerfilter,sw: RTF import of paragraph border override The style (default unnamed \s0, applied via \pard) defines green borders, which are overridden at the 2nd paragraph and cleared. Of course there isn't a single border control word to be found on the 2nd paragraph, the override happens by omitting the borders of the implicitly applied style. Hence handle LN_CT_PrBase_pBdr in getDefaultSPRM(). The export of the override relies on changes from commit 967a03eb8760fb498c5ea6c32d03d1eea486bbe2. Change-Id: I081eb2908d76123e7828cab6c31ceb7b11760183 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138193 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 8f76052839b8558149d1effa28bd7b1b412d78d8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138277 Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/qa/extras/rtfexport/data/para-border.rtf b/sw/qa/extras/rtfexport/data/para-border.rtf new file mode 100644 index 000000000000..d7f55c746757 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/para-border.rtf @@ -0,0 +1,27 @@ +{\rtf1\adeflang1025\ansi\ansicpg1250\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1038\deflangfe1038\themelang1038\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Times New Roman};} +{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Times New Roman};} +{\fhiminor\f31506\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\fbiminor\f31507\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Times New Roman};} +}{\colortbl;\red0\green0\blue0; +\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128; +\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;\caccentsix\ctint255\cshade255\red112\green173\blue71;}{\*\defchp \f31506\fs22\lang1038\langfe1033\langfenp1033 }{\*\defpap \ql \li0\ri0\sa160\sl259\slmult1 +\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 }\noqfpromote {\stylesheet{\ql \li0\ri0\sa160\sl259\slmult1\widctlpar\brdrt\brdrs\brdrw20\brsp20\brdrcf17 \brdrl\brdrs\brdrw20\brsp80\brdrcf17 \brdrb\brdrs\brdrw20\brsp20\brdrcf17 +\brdrr\brdrs\brdrw20\brsp80\brdrcf17 \wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1038\langfe1033\cgrid\langnp1038\langfenp1033 +\snext0 \sqformat \spriority0 \styrsid3957916 Normal,Bordered;}{\*\cs10 \additive \ssemihidden \sunhideused \spriority1 Default Paragraph Font;}{\* +\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblind0\tblindtype3\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv \ql \li0\ri0\sa160\sl259\slmult1 +\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1038\langfe1033\cgrid\langnp1038\langfenp1033 \snext11 \ssemihidden \sunhideused Normal Table;}} +{\*\rsidtbl \rsid3957916\rsid7626595\rsid14618113}{\mmathPr\mmathFont34\mbrkBin0\mbrkBinSub0\msmallFrac0\mdispDef1\mlMargin0\mrMargin0\mdefJc1\mwrapIndent1440\mintLim0\mnaryLim1}{\info{\author G\'e1bor Kelemen2010}{\operator G\'e1bor Kelemen2010} +{\creatim\yr2022\mo8\dy12\hr12\min9}{\revtim\yr2022\mo8\dy12\hr12\min38}{\version3}{\edmins27}{\nofpages1}{\nofwords9}{\nofchars63}{\nofcharsws71}{\vern49169}}{\*\xmlnstbl {\xmlns1 http://schemas.microsoft.com/office/word/2003/wordml}} +\paperw11906\paperh16838\margl1440\margr1440\margt1440\margb1440\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\dghorigin1440\dgvorigin1440\dghshow1\dgvshow1 +\jexpand\viewkind1\viewscale162\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct +\asianbrkrule\rsidroot3957916\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 {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2 +\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6 +\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang +{\pntxtb (}{\pntxta )}}\pard\plain \ltrpar\ql \li0\ri0\sa160\sl259\slmult1\widctlpar\brdrt\brdrs\brdrw20\brsp20\brdrcf17 \brdrl\brdrs\brdrw20\brsp80\brdrcf17 \brdrb\brdrs\brdrw20\brsp20\brdrcf17 \brdrr\brdrs\brdrw20\brsp80\brdrcf17 +\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1038\langfe1033\cgrid\langnp1038\langfenp1033 {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid3957916 one para}{\rtlch\fcs1 +\af31507 \ltrch\fcs0 \insrsid14618113 with border from para style}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid7626595 +\par }\pard \ltrpar\ql \li0\ri0\sa160\sl259\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid3957916 {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid3957916 second para with border turned off +\par } +} diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx index dbcbeaee9d77..f74b067359a1 100644 --- a/sw/qa/extras/rtfexport/rtfexport4.cxx +++ b/sw/qa/extras/rtfexport/rtfexport4.cxx @@ -174,6 +174,68 @@ DECLARE_RTFEXPORT_TEST(test129758, "tdf129631_lostBorders3.rtf") CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); } +DECLARE_RTFEXPORT_TEST(test150382, "para-border.rtf") +{ + uno::Reference<container::XNameAccess> xStyles(getStyles("ParagraphStyles")); + uno::Reference<beans::XPropertySet> xStyle(xStyles->getByName("Normal,Bordered"), + uno::UNO_QUERY); + // style has borders + table::BorderLine2 border; + border = getProperty<table::BorderLine2>(xStyle, "RightBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + border = getProperty<table::BorderLine2>(xStyle, "LeftBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + border = getProperty<table::BorderLine2>(xStyle, "TopBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + border = getProperty<table::BorderLine2>(xStyle, "BottomBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + // first paragraph: style applied, no override + uno::Reference<beans::XPropertySet> xPara1(getParagraph(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Normal,Bordered"), + getProperty<OUString>(xPara1, "ParaStyleName")); + border = getProperty<table::BorderLine2>(xPara1, "RightBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + border = getProperty<table::BorderLine2>(xPara1, "LeftBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + border = getProperty<table::BorderLine2>(xPara1, "TopBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + border = getProperty<table::BorderLine2>(xPara1, "BottomBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + // second paragraph: style applied + uno::Reference<beans::XPropertySet> xPara2(getParagraph(2), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Normal,Bordered"), + getProperty<OUString>(xPara2, "ParaStyleName")); + // but no borders + border = getProperty<table::BorderLine2>(xPara2, "RightBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); + border = getProperty<table::BorderLine2>(xPara2, "LeftBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); + border = getProperty<table::BorderLine2>(xPara2, "TopBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); + border = getProperty<table::BorderLine2>(xPara2, "BottomBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); +} + DECLARE_RTFEXPORT_TEST(testAnchoredAtSamePosition, "anchor.fodt") { SwXTextDocument* const pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx index 2edfec829edf..90bc97001d27 100644 --- a/writerfilter/source/rtftok/rtfsprm.cxx +++ b/writerfilter/source/rtftok/rtfsprm.cxx @@ -199,6 +199,22 @@ static RTFValue::Pointer_t getDefaultSPRM(Id const id, Id nStyleType) // presumably this means 100%, cf. static const int nSingleLineSpacing = 240; return new RTFValue(240); + case NS_ooxml::LN_CT_PrBase_pBdr: + { // tdf#150382 default all paragraph borders to none + RTFSprms attributes; + RTFSprms sprms; + for (int i = 0; i < 4; ++i) + { + auto const nBorder = getParagraphBorder(i); + RTFSprms aAttributes; + RTFSprms aSprms; + aAttributes.set(NS_ooxml::LN_CT_Border_val, + new RTFValue(NS_ooxml::LN_Value_ST_Border_none)); + sprms.set(nBorder, new RTFValue(aAttributes, aSprms)); + } + return new RTFValue(attributes, sprms); + } + default: break; }