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{0bidi roman
charset0prq2{\*\panose 02020603050405020304}Times New Roman{\*alt Times New 
Roman};}
+{0bidi romancharset0prq2{\*\panose 02020603050405020304}Times New 
Roman{\*alt Times New Roman};}{39bidi swisscharset0prq2{\*\panose 
020f0502020204030204}Calibri;}
+{lomajor31500bidi romancharset0prq2{\*\panose 02020603050405020304}Times 
New Roman{\*alt Times New Roman};}{dbmajor31501bidi romancharset0
prq2{\*\panose 02020603050405020304}Times New Roman{\*alt Times New Roman};}
+{himajor31502bidi swisscharset0prq2{\*\panose 
020f0302020204030204}Calibri Light;}{bimajor31503bidi romancharset0
prq2{\*\panose 02020603050405020304}Times New Roman{\*alt Times New Roman};}
+{lominor31504bidi romancharset0prq2{\*\panose 02020603050405020304}Times 
New Roman{\*alt Times New Roman};}{dbminor31505bidi romancharset0
prq2{\*\panose 02020603050405020304}Times New Roman{\*alt Times New Roman};}
+{himinor31506bidi swisscharset0prq2{\*\panose 
020f0502020204030204}Calibri;}{biminor31507bidi romancharset0
prq2{\*\panose 02020603050405020304}Times New Roman{\*alt Times New Roman};}
+{364bidi romancharset238prq2 Times New Roman CE{\*alt Times New 
Roman};}{365bidi romancharset204prq2 Times New Roman Cyr{\*alt Times New 
Roman};}
+{367bidi romancharset161prq2 Times New Roman Greek{\*alt Times New 
Roman};}{368bidi romancharset162prq2 Times New Roman Tur{\*alt Times New 
Roman};}
+{369bidi romancharset177prq2 Times New Roman (Hebrew){\*alt Times New 
Roman};}{370bidi romancharset178prq2 Times New Roman (Arabic){\*alt Times 
New Roman};}
+{371bidi romancharset186prq2 Times New Roman Baltic{\*alt Times New 
Roman};}{372bidi romancharset163prq2 Times New Roman (Vietnamese){\*alt 
Times New Roman};}
+{364bidi romancharset238prq2 Times New Roman CE{\*alt Times New 
Roman};}{365bidi romancharset204prq2 Times New Roman Cyr{\*alt Times New 
Roman};}
+{367bidi romancharset161prq2 Times New Roman Greek{\*alt Times New 
Roman};}{368bidi romancharset162prq2 Times New Roman Tur{\*alt Times New 
Roman};}
+{369bidi romancharset177prq2 Times New Roman (Hebrew){\*alt Times New 
Roman};}{370bidi romancharset178prq2 Times New Roman (Arabic){\*alt Times 
New Roman};}
+{371bidi romancharset186prq2 Times New Roman Baltic{\*alt Times New 
Roman};}{372bidi romancharset163prq2 Times New Roman (Vietnamese){\*alt 
Times New Roman};}{754bidi swisscharset238prq2 Calibri CE;}
+{755bidi swisscharset204prq2 Calibri Cyr;}{757bidi swisscharset161
prq2 Calibri Greek;}{758bidi swisscharset162prq2 Calibri Tur;}{759bidi 
swisscharset177prq2 Calibri (Hebrew);}
+{760bidi swisscharset178prq2 Calibri (Arabic);}{761bidi swiss
charset186prq2 Calibri Baltic;}{762bidi swisscharset163prq2 Calibri 
(Vietnamese);}
+{lomajor31508bidi romancharset238prq2 Times New Roman CE{\*alt Times 
New Roman};}{lomajor31509bidi romancharset204prq2 Times New Roman Cyr{\*
alt Times New Roman};}
+{lomajor31511bidi romancharset161prq2 Times New Roman Greek{\*alt Times 
New Roman};}{lomajor31512bidi romancharset162prq2 Times New Roman Tur{\*
alt Times New Roman};}
+{lomajor31513bidi romancharset177prq2 Times New Roman (Hebrew){\*alt 
Times New Roman};}{lomajor31514bidi romancharset178prq2 Times New Roman 
(Arabic){\*alt Times New Roman};}
+{lomajor31515bidi romancharset186prq2 Times New Roman Baltic{\*alt 
Times New Roman};}{lomajor31516bidi romancharset163prq2 Times New Roman 
(Vietnamese){\*alt Times New Roman};}
+{dbmajor31518bidi romancharset238prq2 Times New Roman CE{\*alt Times 
New Roman};}{dbmajor31519bidi romancharset204prq2 Times New Roman Cyr{\*
alt Times New Roman};}
+{dbmajor31521bidi romancharset161prq2 Times New Roman Greek{\*alt Times 
New Roman};}{dbmajor31522bidi romancharset162prq2 Times New Roman Tur{\*
alt Times New Roman};}
+{dbmajor31523bidi romancharset177prq2 Times New Roman (Hebrew){\*alt 
Times New Roman};}{dbmajor31524bidi romancharset178prq2 Times New Roman 
(Arabic){\*alt Times New Roman};}
+{dbmajor31525bidi romancharset186prq2 Times New Roman Baltic{\*alt 
Times New Roman};}{dbmajor31526bidi romancharset163prq2 Times New Roman 
(Vietnamese){\*alt Times New Roman};}
+{himajor31528bidi swisscharset238prq2 Calibri Light CE;}{himajor31529
bidi swisscharset204prq2 Calibri Light Cyr;}{himajor31531bidi swiss
charset161prq2 Calibri Light Greek;}
+{himajor31532bidi swisscharset162prq2 Calibri Light Tur;}{himajor31533
bidi swisscharset177prq2 Calibri Light (Hebrew);}{himajor31534bidi swiss
charset178prq2 Calibri Light (Arabic);}
+{himajor31535bidi swisscharset186prq2 Calibri Light Baltic;}{himajor
31536bidi swisscharset163prq2 Calibri Light (Vietnamese);}{bimajor31538
bidi romancharset238prq2 Times New Roman CE{\*alt Times New Roman};}
+{bimajor31539bidi romancharset204prq2 Times New Roman Cyr{\*alt Times 
New Roman};}{bimajor31541bidi romancharset161prq2 Times New Roman 
Greek{\*alt Times New Roman};}
+{bimajor31542bidi romancharset162prq2 Times New Roman Tur{\*alt Times 
New Roman};}{bimajor31543bidi romancharset177prq2 Times New Roman 
(Hebrew){\*alt Times New Roman};}
+{bimajor31544bidi romancharset178prq2 Times New Roman (Arabic){\*alt 
Times New Roman};}{bimajor31545bidi romancharset186prq2 Times New Roman 
Baltic{\*alt Times New Roman};}
+{bimajor31546bidi romancharset163prq2 Times New Roman (Vietnamese){\*
alt Times New Roman};}{lominor31548bidi romancharset238prq2 Times New 
Roman CE{\*alt Times New Roman};}
+{lominor31549bidi romancharset204prq2 Times New Roman Cyr{\*alt Times 
New Roman};}{lominor31551bidi romancharset161prq2 Times New Roman 
Greek{\*alt Times New Roman};}
+{lominor31552bidi romancharset162prq2 Times New Roman Tur{\*alt Times 
New Roman};}{lominor31553bidi romancharset177prq2 Times New Roman 
(Hebrew){\*alt Times New Roman};}
+{lominor31554bidi romancharset178prq2 Times New Roman (Arabic){\*alt 
Times New Roman};}{lominor31555bidi romancharset186prq2 Times New Roman 
Baltic{\*alt Times New Roman};}
+{lominor31556bidi romancharset163prq2 Times New Roman (Vietnamese){\*
alt Times New Roman};}{dbminor31558bidi romancharset238prq2 Times New 
Roman CE{\*alt Times New Roman};}
+{dbminor31559bidi romancharset204prq2 Times New Roman Cyr{\*alt Times 
New Roman};}{dbminor31561bidi romancharset161prq2 Times New Roman 
Greek{\*alt Times New Roman};}
+{dbminor31562bidi romancharset162prq2 Times New Roman Tur{\*alt Times 
New Roman};}{dbminor31563bidi romancharset177prq2 Times New Roman 
(Hebrew){\*alt Times New Roman};}
+{dbminor31564bidi romancharset178prq2 Times New Roman (Arabic){\*alt 
Times New Roman};}{dbminor31565bidi romancharset186prq2 Times New Roman 
Baltic{\*alt Times New Roman};}
+{dbminor31566bidi romancharset163prq2 Times New Roman (Vietnamese){\*
alt Times New Roman};}{himinor31568bidi swisscharset238prq2 Calibri CE;}{
himinor31569bidi swisscharset204prq2 Calibri Cyr;}
+{himinor31571bidi swisscharset161prq2 Calibri Greek;}{himinor31572
bidi swisscharset162prq2 Calibri Tur;}{himinor31573bidi swisscharset177
prq2 Calibri (Hebrew);}
+{himinor31574bidi swisscharset178prq2 Calibri (Arabic);}{himinor31575
bidi swisscharset186prq2 Calibri Baltic;}{himinor31576bidi swiss
charset163prq2 Calibri (Vietnamese);}
+{biminor31578bidi romancharset238prq2 Times New Roman CE{\*alt Times 
New Roman};}{biminor31579bidi romancharset204prq2 Times New Roman Cyr{\*
alt Times New Roman};}
+{biminor31581bidi romancharset161prq2 Times New Roman Greek{\*alt Times 
New Roman};}{biminor31582bidi romancharset162prq2 Times New Roman Tur{\*
alt Times New Roman};}
+{biminor31583bidi romancharset177prq2 Times New Roman (Hebrew){\*alt 
Times New Roman};}{biminor31584bidi romancharset178prq2 Times New Roman 
(Arabic){\*alt Times New Roman};}
+{biminor31585bidi romancharset186prq2 Times New Roman Baltic{\*alt 
Times New Roman};}{biminor31586bidi romancharset163prq2 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 31506s22\lang1038\langfe1033\langfenp1033 
}{\*\defpap \ql \li0 i0\sa160\sl259\slmult1
+\widctlpar\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0 }
oqfpromote {\stylesheet{\ql \li0 
i0\sa160\sl259\slmult1\widctlpar\wrapdefaultspalphaspnumaautodjustright 
in0\lin0\itap0  tlchcs1 f31507fs22lang1025 
+\ltrchcs0 31506s22\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\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0  tlchcs1 
f31507fs22lang1025 \ltrchcs0 31506s22\lang1038\langfe1033+\s15\ql \li0 
i0\widctlpar       qc      x4513   qr      x9026\wrapdefaultspalphaspnum
aautodjustright in0\lin0\itap0  tlchcs1 f31507fs22lang1025 \ltrchcs0 
31506s22\lang1038\langfe1033+\sbasedon0 \snext15 \slink16 \sunhideused 
\styrsid13502046 header;}{\*+       qc      x4513   qr      
x9026\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0  tlchcs1 
f31507fs22lang1025 \ltrchcs0 31506s22\lang1038\langfe1033+\sbasedon0 
\snext17 \slink18 \sunhideused \styrsid13502046 
footer;}{\*+\paperw11906\paperh16838\margl1440\margr1440\margt1440\margb1440\gutter0\ltrsect
 
+\deftab708\widowctrltnbjenddoc\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
oindnmbrtselnbrelev
ocxsptable\indrlsweleven
oafcnsttblfelev\utinl\hwelev\spltpgpar
otcvasp
otbrkcnstfrctbl
otvatxbx\krnprsnet+
ofeaturethrottle1\ilfomacatclnup0
+\ltrpar \sectd \ltrsect\psz9\sbkeven\linex0\headery0ootery397+        qc      
x4513   qr      x9026\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0 
 tlchcs1 f31507fs22lang1025 \ltrchcs0 31506s22\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\wrapdefaultspalphaspnumaautodjustright in0\lin0\itap0  tlchcs1 
f31507fs22lang1025 \ltrchcs0 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\wrapdefaultspalphaspnumaautodjustright 
in0\lin0\itap0\pararsid13502046 { tlchcs1 f31507 \ltrchcs0 
\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 }{ tlchcs1 f31507 \ltrchcs0 \insrsid13502046 
+\par }{ tlchcs1 f31507 \ltrchcs0 \insrsid13502046+  qc      x4513   qr      
x9026\wrapdefaultspalphaspnumaautodjustright 
in0\lin0\itap0\pararsid13502046  tlchcs1 f31507fs22lang1025 \ltrchcs0 
31506s22\lang1038\langfe1033+\insrsid13502046 Other footer}{ tlchcs1 f31507 
\ltrchcs0 \insrsid13502046+\par }}\pard\plain \ltrpar\ql \li0 
i0\sa160\sl259\slmult1\widctlpar\wrapdefaultspalphaspnumaautodjustright 
in0\lin0\itap0  tlchcs1 f31507fs22lang1025 \ltrchcs0 31506
s22\lang1038\langfe1033+f31507 \ltrchcs0 \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.}{ tlchcs1 
f31507 \ltrchcs0 \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));

Reply via email to