sw/qa/extras/rtfimport/data/tdf153196.rtf | 114 ++++++++++++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 20 +++ sw/source/uibase/utlui/uitool.cxx | 1 writerfilter/source/dmapper/DomainMapper_Impl.cxx | 8 + writerfilter/source/dmapper/DomainMapper_Impl.hxx | 4 writerfilter/source/dmapper/PropertyMap.cxx | 34 +++++- 6 files changed, 178 insertions(+), 3 deletions(-)
New commits: commit 340f8ea4ae7f11b4d3a95499188a29fe801867cf Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Tue Feb 20 11:54:13 2024 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Feb 20 22:28:57 2024 +0100 tdf#153196 writerfilter: fix page style for even/odd section break This is a bit of a special case, where the first section starts with an evenPage break (\sbkeven), which causes a Left-only page style to be created. In completeCopyHeaderFooter(), the HeaderTextFirst and FooterTextFirst are copied from the source style to the Left-only page style, but then they also need to be deleted from the source style, because the Left-only page style is the one that is used for the first page of the section, and the source style is used for the subsequent pages. Additionally, when there is *only* a "first" header/footer, and no previous section has one to inherit, Word will not display a header/footer at all on subsequent pages; a PageStyle will always have a header/footer if it has a HeaderTextFirst/FooterTextFirst. In this case, delete the header/footer from the source style. Unfortunately exporting this doesn't work ideally, a spurious evenPage footer will be created, both due to the FooterShare being automatically reset for no obvious reason in ItemSetToPageDesc(), and setProperty("FooterIsShared", true) "stashing" the left footer since commit b802ab694a8a7357d4657f3e11b571144fa7c7bf. (presumably regression from commit b32881b6723072c8d1a652ea147d12e75766d504) Change-Id: Ie4f9c49605df690e9705e14777c0e4bcb0dfad8e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163668 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/qa/extras/rtfimport/data/tdf153196.rtf b/sw/qa/extras/rtfimport/data/tdf153196.rtf new file mode 100644 index 000000000000..835cdeeb41b8 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/tdf153196.rtf @@ -0,0 +1,114 @@ +{ tf1deflang1025nsinsicpg1250\uc1deff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1038\deflangfe1038 hemelang1038 hemelangfe0 hemelangcs0{onttbl{0bidi roman charset0prq2{\*\panose 02020603050405020304}Times New Roman{\*alt Times New Roman};} +{0bidi romancharset0prq2{\*\panose 02020603050405020304}Times New Roman{\*alt Times New Roman};}{39bidi swisscharset0prq2{\*\panose 020f0502020204030204}Calibri;} +{lomajor31500bidi romancharset0prq2{\*\panose 02020603050405020304}Times New Roman{\*alt Times New Roman};}{dbmajor31501bidi romancharset0 prq2{\*\panose 02020603050405020304}Times New Roman{\*alt Times New Roman};} +{himajor31502bidi swisscharset0prq2{\*\panose 020f0302020204030204}Calibri Light;}{bimajor31503bidi romancharset0 prq2{\*\panose 02020603050405020304}Times New Roman{\*alt Times New Roman};} +{lominor31504bidi romancharset0prq2{\*\panose 02020603050405020304}Times New Roman{\*alt Times New Roman};}{dbminor31505bidi romancharset0 prq2{\*\panose 02020603050405020304}Times New Roman{\*alt Times New Roman};} +{himinor31506bidi swisscharset0prq2{\*\panose 020f0502020204030204}Calibri;}{biminor31507bidi romancharset0 prq2{\*\panose 02020603050405020304}Times New Roman{\*alt Times New Roman};} +{364bidi romancharset238prq2 Times New Roman CE{\*alt Times New Roman};}{365bidi romancharset204prq2 Times New Roman Cyr{\*alt Times New Roman};} +{367bidi romancharset161prq2 Times New Roman Greek{\*alt Times New Roman};}{368bidi romancharset162prq2 Times New Roman Tur{\*alt Times New Roman};} +{369bidi romancharset177prq2 Times New Roman (Hebrew){\*alt Times New Roman};}{370bidi romancharset178prq2 Times New Roman (Arabic){\*alt Times New Roman};} +{371bidi romancharset186prq2 Times New Roman Baltic{\*alt Times New Roman};}{372bidi romancharset163prq2 Times New Roman (Vietnamese){\*alt Times New Roman};} +{364bidi romancharset238prq2 Times New Roman CE{\*alt Times New Roman};}{365bidi romancharset204prq2 Times New Roman Cyr{\*alt Times New Roman};} +{367bidi romancharset161prq2 Times New Roman Greek{\*alt Times New Roman};}{368bidi romancharset162prq2 Times New Roman Tur{\*alt Times New Roman};} +{369bidi romancharset177prq2 Times New Roman (Hebrew){\*alt Times New Roman};}{370bidi romancharset178prq2 Times New Roman (Arabic){\*alt Times New Roman};} +{371bidi romancharset186prq2 Times New Roman Baltic{\*alt Times New Roman};}{372bidi romancharset163prq2 Times New Roman (Vietnamese){\*alt Times New Roman};}{754bidi swisscharset238prq2 Calibri CE;} +{755bidi swisscharset204prq2 Calibri Cyr;}{757bidi swisscharset161 prq2 Calibri Greek;}{758bidi swisscharset162prq2 Calibri Tur;}{759bidi swisscharset177prq2 Calibri (Hebrew);} +{760bidi swisscharset178prq2 Calibri (Arabic);}{761bidi swiss charset186prq2 Calibri Baltic;}{762bidi swisscharset163prq2 Calibri (Vietnamese);} +{lomajor31508bidi romancharset238prq2 Times New Roman CE{\*alt Times New Roman};}{lomajor31509bidi romancharset204prq2 Times New Roman Cyr{\* alt Times New Roman};} +{lomajor31511bidi romancharset161prq2 Times New Roman Greek{\*alt Times New Roman};}{lomajor31512bidi romancharset162prq2 Times New Roman Tur{\* alt Times New Roman};} +{lomajor31513bidi romancharset177prq2 Times New Roman (Hebrew){\*alt Times New Roman};}{lomajor31514bidi romancharset178prq2 Times New Roman (Arabic){\*alt Times New Roman};} +{lomajor31515bidi romancharset186prq2 Times New Roman Baltic{\*alt Times New Roman};}{lomajor31516bidi romancharset163prq2 Times New Roman (Vietnamese){\*alt Times New Roman};} +{dbmajor31518bidi romancharset238prq2 Times New Roman CE{\*alt Times New Roman};}{dbmajor31519bidi romancharset204prq2 Times New Roman Cyr{\* alt Times New Roman};} +{dbmajor31521bidi romancharset161prq2 Times New Roman Greek{\*alt Times New Roman};}{dbmajor31522bidi romancharset162prq2 Times New Roman Tur{\* alt Times New Roman};} +{dbmajor31523bidi romancharset177prq2 Times New Roman (Hebrew){\*alt Times New Roman};}{dbmajor31524bidi romancharset178prq2 Times New Roman (Arabic){\*alt Times New Roman};} +{dbmajor31525bidi romancharset186prq2 Times New Roman Baltic{\*alt Times New Roman};}{dbmajor31526bidi romancharset163prq2 Times New Roman (Vietnamese){\*alt Times New Roman};} +{himajor31528bidi swisscharset238prq2 Calibri Light CE;}{himajor31529 bidi swisscharset204prq2 Calibri Light Cyr;}{himajor31531bidi swiss charset161prq2 Calibri Light Greek;} +{himajor31532bidi swisscharset162prq2 Calibri Light Tur;}{himajor31533 bidi swisscharset177prq2 Calibri Light (Hebrew);}{himajor31534bidi swiss charset178prq2 Calibri Light (Arabic);} +{himajor31535bidi swisscharset186prq2 Calibri Light Baltic;}{himajor 31536bidi swisscharset163prq2 Calibri Light (Vietnamese);}{bimajor31538 bidi romancharset238prq2 Times New Roman CE{\*alt Times New Roman};} +{bimajor31539bidi romancharset204prq2 Times New Roman Cyr{\*alt Times New Roman};}{bimajor31541bidi romancharset161prq2 Times New Roman Greek{\*alt Times New Roman};} +{bimajor31542bidi romancharset162prq2 Times New Roman Tur{\*alt Times New Roman};}{bimajor31543bidi romancharset177prq2 Times New Roman (Hebrew){\*alt Times New Roman};} +{bimajor31544bidi romancharset178prq2 Times New Roman (Arabic){\*alt Times New Roman};}{bimajor31545bidi romancharset186prq2 Times New Roman Baltic{\*alt Times New Roman};} +{bimajor31546bidi romancharset163prq2 Times New Roman (Vietnamese){\* alt Times New Roman};}{lominor31548bidi romancharset238prq2 Times New Roman CE{\*alt Times New Roman};} +{lominor31549bidi romancharset204prq2 Times New Roman Cyr{\*alt Times New Roman};}{lominor31551bidi romancharset161prq2 Times New Roman Greek{\*alt Times New Roman};} +{lominor31552bidi romancharset162prq2 Times New Roman Tur{\*alt Times New Roman};}{lominor31553bidi romancharset177prq2 Times New Roman (Hebrew){\*alt Times New Roman};} +{lominor31554bidi romancharset178prq2 Times New Roman (Arabic){\*alt Times New Roman};}{lominor31555bidi romancharset186prq2 Times New Roman Baltic{\*alt Times New Roman};} +{lominor31556bidi romancharset163prq2 Times New Roman (Vietnamese){\* alt Times New Roman};}{dbminor31558bidi romancharset238prq2 Times New Roman CE{\*alt Times New Roman};} +{dbminor31559bidi romancharset204prq2 Times New Roman Cyr{\*alt Times New Roman};}{dbminor31561bidi romancharset161prq2 Times New Roman Greek{\*alt Times New Roman};} +{dbminor31562bidi romancharset162prq2 Times New Roman Tur{\*alt Times New Roman};}{dbminor31563bidi romancharset177prq2 Times New Roman (Hebrew){\*alt Times New Roman};} +{dbminor31564bidi romancharset178prq2 Times New Roman (Arabic){\*alt Times New Roman};}{dbminor31565bidi romancharset186prq2 Times New Roman Baltic{\*alt Times New Roman};} +{dbminor31566bidi romancharset163prq2 Times New Roman (Vietnamese){\* alt Times New Roman};}{himinor31568bidi swisscharset238prq2 Calibri CE;}{ himinor31569bidi swisscharset204prq2 Calibri Cyr;} +{himinor31571bidi swisscharset161prq2 Calibri Greek;}{himinor31572 bidi swisscharset162prq2 Calibri Tur;}{himinor31573bidi swisscharset177 prq2 Calibri (Hebrew);} +{himinor31574bidi swisscharset178prq2 Calibri (Arabic);}{himinor31575 bidi swisscharset186prq2 Calibri Baltic;}{himinor31576bidi swiss charset163prq2 Calibri (Vietnamese);} +{biminor31578bidi romancharset238prq2 Times New Roman CE{\*alt Times New Roman};}{biminor31579bidi romancharset204prq2 Times New Roman Cyr{\* alt Times New Roman};} +{biminor31581bidi romancharset161prq2 Times New Roman Greek{\*alt Times New Roman};}{biminor31582bidi romancharset162prq2 Times New Roman Tur{\* alt Times New Roman};} +{biminor31583bidi romancharset177prq2 Times New Roman (Hebrew){\*alt Times New Roman};}{biminor31584bidi romancharset178prq2 Times New Roman (Arabic){\*alt Times New Roman};} +{biminor31585bidi romancharset186prq2 Times New Roman Baltic{\*alt Times New Roman};}{biminor31586bidi romancharset163prq2 Times New Roman (Vietnamese){\*alt Times New Roman};}}{+ ed0\green0lue255; ed0\green255lue255; 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;}{\*\defchp 31506s22\lang1038\langfe1033\langfenp1033 }{\*\defpap \ql \li0 i0\sa160\sl259\slmult1 +\widctlpar\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0 } oqfpromote {\stylesheet{\ql \li0 i0\sa160\sl259\slmult1\widctlpar\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0 tlchcs1 f31507fs22lang1025 +\ltrchcs0 31506s22\lang1038\langfe1033+ s11 srowd rftsWidthB3 rpaddl108 rpaddr108 rpaddfl3 rpaddft3 rpaddfb3 rpaddfr3 blind0 blindtype3 svertalt sbrdrt sbrdrl sbrdrb sbrdrr sbrdrdgl sbrdrdgr sbrdrh sbrdrv \ql \li0 i0\sa160\sl259\slmult1 +\widctlpar\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0 tlchcs1 f31507fs22lang1025 \ltrchcs0 31506s22\lang1038\langfe1033+\s15\ql \li0 i0\widctlpar qc x4513 qr x9026\wrapdefaultspalphaspnum aautodjustright in0\lin0\itap0 tlchcs1 f31507fs22lang1025 \ltrchcs0 31506s22\lang1038\langfe1033+\sbasedon0 \snext15 \slink16 \sunhideused \styrsid13502046 header;}{\*+ qc x4513 qr x9026\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0 tlchcs1 f31507fs22lang1025 \ltrchcs0 31506s22\lang1038\langfe1033+\sbasedon0 \snext17 \slink18 \sunhideused \styrsid13502046 footer;}{\*+\paperw11906\paperh16838\margl1440\margr1440\margt1440\margb1440\gutter0\ltrsect +\deftab708\widowctrltnbjenddoc\hyphhotz425 rackmoves0 rackformatting1\donotembedsysfont1 elyonvml1\donotembedlingdata0\grfdocevents0 alidatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0 +\showxmlerrors1 oxlattoyenxpshrtn oultrlspc\dntblnsbdb ospaceforul ormshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1440\dgvorigin1440\dghshow1\dgvshow1 +\jexpandiewkind1iewscale70\pgbrdrhead\pgbrdrfoot\splytwnine tnlytwnine\htmautsp olnhtadjtbl\useltbalnlntblind\lytcalctblwd\lyttblrtgr\lnbrkrule obrkwrptbl\snaptogridincellllowfieldendsel\wrppunct +sianbrkrule sidroot13502046 ewtblstyruls ogrowautofit\usenormstyforlist oindnmbrtselnbrelev ocxsptable\indrlsweleven oafcnsttblfelev\utinl\hwelev\spltpgpar otcvasp otbrkcnstfrctbl otvatxbx\krnprsnet+ ofeaturethrottle1\ilfomacatclnup0 +\ltrpar \sectd \ltrsect\psz9\sbkeven\linex0\headery0ootery397+ qc x4513 qr x9026\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0 tlchcs1 f31507fs22lang1025 \ltrchcs0 31506s22\lang1038\langfe1033+Hello world! +\par }}{\*\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 i0\sa160\sl259\slmult1 +\widctlpar\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0 tlchcs1 f31507fs22lang1025 \ltrchcs0 31506 s22\lang1038\langfe1033+\lang1024\langfe1024 oproof\insrsid13502046 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. + +\par Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. +\par Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. +\par Aenean nec lorem. In porttitor. Donec laoreet nonummy augue. +\par Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy. +\par Fusce aliquet pede non pede. Suspendisse dapibus lorem pellentesque magna. Integer nulla. +\par Donec blandit feugiat ligula. Donec hendrerit, felis et imperdiet euismod, purus ipsum pretium metus, in lacinia nulla nisl eget sapien. Donec ut est in lectus consequat consequat. +\par Etiam eget dui. Aliquam erat volutpat. Sed at lorem in nunc porta tristique. +\par Proin nec augue. Quisque aliquam tempor magna. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. +\par Nunc ac magna. Maecenas odio dolor, vulputate vel, auctor ac, accumsan id, felis. Pellentesque cursus sagittis felis. +\par Pellentesque porttitor, velit lacinia egestas auctor, diam eros tempus arcu, nec vulputate augue magna vel risus. Cras non magna vel ante adipiscing rhoncus. Vivamus a mi. +\par Morbi neque. Aliquam erat volutpat. Integer ultrices lobortis eros. +\par Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egest +as. Proin semper, ante vitae sollicitudin posuere, metus quam iaculis nibh, vitae scelerisque nunc massa eget pede. Sed velit urna, interdum vel, ultricies vel, faucibus at, quam. +\par Donec elit est, consectetuer eget, consequat quis, tempus quis, wisi. In in nunc. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. +\par Donec ullamcorper fringilla eros. Fusce in sapien eu purus dapibus commodo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. +\par Cras faucibus condimentum odio. Sed ac ligula. Aliquam at eros. +\par Etiam at ligula et tellus ullamcorper ultrices. In fermentum, lorem non cursus porttitor, diam urna accumsan lacus, sed interdum wisi nibh nec nisl. Ut tincidunt volutpat urna. +\par Mauris eleifend nulla eget mauris. Sed cursus quam id felis. Curabitur posuere quam vel nibh. +\par Cras dapibus dapibus nisl. Vestibulum quis dolor a felis congue vehicula. Maecenas pede purus, tristique ac, tempus eget, egestas quis, mauris. +\par Curabitur non eros. Nullam hendrerit bibendum justo. Fusce iaculis, est quis lacinia pretium, pede metus molestie lacus, at gravida wisi ante at libero. +\par Quisque ornare placerat risus. Ut molestie magna at mi. Integer aliquet mauris et nibh. +\par Ut mattis ligula posuere velit. Nunc sagittis. Curabitur varius fringilla nisl. +\par Duis pretium mi euismod erat. Maecenas id augue. Nam vulputate. +\par Duis a quam non neque lobortis malesuada. Praesent euismod. Donec nulla augue, venenatis scelerisque, dapibus a, consequat at, leo. +\par Pellentesque libero lectus, tristique ac, consectetuer sit amet, imperdiet ut, justo. Sed aliquam odio vitae tortor. Proin hendrerit tempus arcu. +\par In hac habitasse platea dictumst. Suspendisse potenti. Vivamus vitae massa adipiscing est lacinia sodales. +\par Donec metus massa, mollis vel, tempus placerat, vestibulum condimentum, ligula. Nunc lacus metus, posuere eget, lacinia eu, varius quis, libero. Aliquam nonummy adipiscing augue. +\par Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. +\par Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. +\par }\pard \ltrpar\ql \li0 i0\sa160\sl259\slmult1\widctlpar\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0\pararsid13502046 { tlchcs1 f31507 \ltrchcs0 \lang1024\langfe1024 oproof\insrsid13502046 +Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. +\par }{ tlchcs1 f31507 \ltrchcs0 \insrsid13502046 +\par }{ tlchcs1 f31507 \ltrchcs0 \insrsid13502046+ qc x4513 qr x9026\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0\pararsid13502046 tlchcs1 f31507fs22lang1025 \ltrchcs0 31506s22\lang1038\langfe1033+\insrsid13502046 Other footer}{ tlchcs1 f31507 \ltrchcs0 \insrsid13502046+\par }}\pard\plain \ltrpar\ql \li0 i0\sa160\sl259\slmult1\widctlpar\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0 tlchcs1 f31507fs22lang1025 \ltrchcs0 31506 s22\lang1038\langfe1033+f31507 \ltrchcs0 \lang1024\langfe1024 oproof\insrsid13502046 +Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. +\par Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. +\par Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. +\par Aenean nec lorem. In porttitor. Donec laoreet nonummy augue. +\par Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.}{ tlchcs1 f31507 \ltrchcs0 \insrsid12983264 +\par } +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index b1971ecc478c..aa6365a40f0e 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1604,6 +1604,26 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf115242) getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin")); } +CPPUNIT_TEST_FIXTURE(Test, testTdf153196) +{ + createSwDoc("tdf153196.rtf"); + + const auto& pLayout = parseLayoutDump(); + + CPPUNIT_ASSERT_EQUAL(4, getPages()); + + // TODO: Writer creates an empty page 1 here, which Word does not + assertXPath(pLayout, "/root/page[1]/footer"_ostr, 0); + assertXPath(pLayout, "/root/page[2]/footer"_ostr, 1); + // the first page (2) has a page style applied, which has a follow page + // style; the problem was that the follow page style had a footer. + assertXPath(pLayout, "/root/page[3]/footer"_ostr, 0); + assertXPath(pLayout, "/root/page[4]/footer"_ostr, 1); + + // TODO exporting this, wrongly produces "even" footer from stashed one + // TODO importing that, wrongly creates a footer even without evenAndOddHeaders +} + CPPUNIT_TEST_FIXTURE(Test, testDefaultValues) { createSwDoc("default-values.rtf"); diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx index 17e24de51caa..72c67ce7ab1b 100644 --- a/sw/source/uibase/utlui/uitool.cxx +++ b/sw/source/uibase/utlui/uitool.cxx @@ -392,6 +392,7 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) if(rMaster.GetFooter().IsActive()) { rMaster.SetFormatAttr(SwFormatFooter(false)); + // why reset this? but not doing it causes testTdf112694 to fail rPageDesc.ChgFooterShare(false); } } diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 73287b929f0c..d5c6d553ea11 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -3902,6 +3902,11 @@ void DomainMapper_Impl::prepareHeaderFooterContent(uno::Reference<beans::XProper m_aHeaderFooterTextAppendStack.push(std::make_pair(TextAppendContext(xTextAppend, xTextCursor), ePagePartType)); } +bool DomainMapper_Impl::SeenHeaderFooter(PagePartType const partType, PageType const pageType) const +{ + return m_HeaderFooterSeen.find({partType, pageType}) != m_HeaderFooterSeen.end(); +} + /** Checks if the header and footer content on the text appended stack is empty. */ void DomainMapper_Impl::checkIfHeaderFooterIsEmpty(PagePartType ePagePartType, PageType eType) @@ -3960,7 +3965,10 @@ void DomainMapper_Impl::PopPageHeaderFooter(PagePartType ePagePartType, PageType // content is not copied from the previous section SectionPropertyMap* pSectionContext = GetSectionContext(); if (pSectionContext) + { pSectionContext->clearHeaderFooterLinkToPrevious(ePagePartType, eType); + m_HeaderFooterSeen.emplace(ePagePartType, eType); + } if (!m_aTextAppendStack.empty()) { diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 9d1a3aaa3b75..163c92c04d31 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -653,6 +653,8 @@ private: css::uno::Reference< css::text::XTextCursor > m_xTOCMarkerCursor; + ::std::set<::std::pair<PagePartType, PageType>> m_HeaderFooterSeen; + //annotation import css::uno::Reference< css::beans::XPropertySet > m_xAnnotationField; sal_Int32 m_nAnnotationId; @@ -1214,6 +1216,8 @@ public: bool IsParaWithInlineObject() const { return m_StreamStateStack.top().bParaWithInlineObject; } + bool SeenHeaderFooter(PagePartType, PageType) const; + css::uno::Reference< css::embed::XStorage > m_xDocumentStorage; /// Handles <w:altChunk>. diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 79ee185ad17d..2301bc24893a 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -518,7 +518,7 @@ void SectionPropertyMap::removeXTextContent(uno::Reference<text::XText> const& r xParagraph->dispose(); } -/** Set the header/footer sharing as defined by titlePage and eveoAndOdd flags +/** Set the header/footer sharing as defined by titlePage and evenAndOdd flags * in the document and clear the content of anything not written during the import. */ void SectionPropertyMap::setHeaderFooterProperties(DomainMapper_Impl& rDM_Impl) @@ -918,7 +918,9 @@ void copyHeaderFooterTextProperty(const uno::Reference<beans::XPropertySet>& xSo } // Copies all the header and footer content and relevant flags from the source style to the target. -void completeCopyHeaderFooter(const uno::Reference<beans::XPropertySet>& xSourceStyle, const uno::Reference<beans::XPropertySet>& xTargetStyle) +void completeCopyHeaderFooter(const uno::Reference<beans::XPropertySet>& xSourceStyle, + const uno::Reference<beans::XPropertySet>& xTargetStyle, + bool const bMissingHeader, bool const bMissingFooter) { if (!xSourceStyle.is() || !xTargetStyle.is()) return; @@ -964,6 +966,25 @@ void completeCopyHeaderFooter(const uno::Reference<beans::XPropertySet>& xSource copyHeaderFooterTextProperty(xSourceStyle, xTargetStyle, PROP_FOOTER_TEXT_LEFT); copyHeaderFooterTextProperty(xSourceStyle, xTargetStyle, PROP_FOOTER_TEXT); } + // tdf#153196 the copy is used for the first page, the source will be used + // on subsequent pages, so clear source's first page header/footer + if (!bSourceFirstIsShared) + { + xSourceStyle->setPropertyValue(sFirstIsShared, uno::Any(true)); + } + // if there is *only* a first-footer, and no previous section from which + // to inherit a footer, the import process has created an empty footer + // that didn't exist in the file; remove it + if (bSourceHasHeader && bMissingHeader) + { + xSourceStyle->setPropertyValue(sHeaderIsOn, uno::Any(false)); + } + if (bSourceHasFooter && bMissingFooter) + { + // setting "FooterIsShared" to true here does nothing, because it causes + // left footer to be stashed, which means it will be exported anyway + xSourceStyle->setPropertyValue(sFooterIsOn, uno::Any(false)); + } } // Copy headers and footers from the previous page style. @@ -1463,7 +1484,14 @@ void SectionPropertyMap::CreateEvenOddPageStyleCopy(DomainMapper_Impl& rDM_Impl, rDM_Impl.GetPageStyles()->insertByName(evenOddStyleName, uno::Any(evenOddStyle)); if (rDM_Impl.IsNewDoc()) - completeCopyHeaderFooter(pageProperties, evenOddStyle); + { + bool const bEvenAndOdd(rDM_Impl.GetSettingsTable()->GetEvenAndOddHeaders()); + completeCopyHeaderFooter(pageProperties, evenOddStyle, + !rDM_Impl.SeenHeaderFooter(PagePartType::Header, PageType::RIGHT) + && (!bEvenAndOdd || !rDM_Impl.SeenHeaderFooter(PagePartType::Header, PageType::LEFT)), + !rDM_Impl.SeenHeaderFooter(PagePartType::Footer, PageType::RIGHT) + && (!bEvenAndOdd || !rDM_Impl.SeenHeaderFooter(PagePartType::Footer, PageType::LEFT))); + } if (eBreakType == PageBreakType::Even) evenOddStyle->setPropertyValue(getPropertyName(PROP_PAGE_STYLE_LAYOUT), uno::Any(style::PageStyleLayout_LEFT));