sw/qa/extras/odfimport/data/PageAnchorZIndexFirstPage.fodt  |  120 ++++++++++++
 sw/qa/extras/odfimport/data/PageAnchorZIndexSecondPage.fodt |  120 ++++++++++++
 sw/qa/extras/odfimport/odfimport.cxx                        |   28 ++
 sw/source/core/layout/newfrm.cxx                            |    3 
 sw/source/core/layout/pagechg.cxx                           |    3 
 5 files changed, 272 insertions(+), 2 deletions(-)

New commits:
commit b3ca51fdaf51e7f1eb5e699d8964269bfd35f240
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Oct 30 10:03:33 2021 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Wed Nov 10 11:59:10 2021 +0100

    sw: Wrong ZOrder after import for images anchored to non-1nd page
    
    Importing a document that has images anchored to the non-1st
    page, can result in images having the wrong the wrong Z index
    (ZOrder). If there are overlapping objects in the document,
    this can become a problem.
    
    The issue is with the call to SwRootFrame::RemoveMasterObjs,
    which removed the "master objects" - SwFlyDrawObj* castable
    objects. Normally the SwFlyDrawObj* objects on the page are wrapped
    and replaced by SwVirtFlyDrawObj*, but when the call to the
    RemoveMasterObjs was made, this hasn't happen yet to all the
    objects (objects that were not on the 1st page).
    
    The fix is to move the RemoveMasterObjs call to a different place,
    where we processed all the pages, so we can safely remove the
    remaining master objects on the page.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124597
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 8b7dbd220dbdfd286de2d770503dae8bf6d2e53e)
    
    Change-Id: I7d2f31614d269c22a82e7e5dea960f3d0844a5d5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124752
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sw/qa/extras/odfimport/data/PageAnchorZIndexFirstPage.fodt 
b/sw/qa/extras/odfimport/data/PageAnchorZIndexFirstPage.fodt
new file mode 100644
index 000000000000..6acb5e6d8256
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/PageAnchorZIndexFirstPage.fodt
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns
 :config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="ur
 n:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:xforms="http://www.w3.org/2002/xforms"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+    <office:font-face-decls>
+        <style:font-face style:name="Droid Sans Devanagari" 
svg:font-family="&apos;Droid Sans Devanagari&apos;" 
style:font-family-generic="system" style:font-pitch="variable"/>
+        <style:font-face style:name="Droid Sans Devanagari1" 
svg:font-family="&apos;Droid Sans Devanagari&apos;" 
style:font-family-generic="swiss"/>
+        <style:font-face style:name="Liberation Sans" 
svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" 
style:font-pitch="variable"/>
+        <style:font-face style:name="Liberation Serif" 
svg:font-family="&apos;Liberation Serif&apos;" 
style:font-family-generic="roman" style:font-pitch="variable"/>
+        <style:font-face style:name="Noto Serif CJK SC" 
svg:font-family="&apos;Noto Serif CJK SC&apos;" 
style:font-family-generic="system" style:font-pitch="variable"/>
+        <style:font-face style:name="Source Han Sans CN" 
svg:font-family="&apos;Source Han Sans CN&apos;" 
style:font-family-generic="system" style:font-pitch="variable"/>
+    </office:font-face-decls>
+    <office:automatic-styles>
+        <style:style style:name="P1" style:family="paragraph" 
style:parent-style-name="Standard">
+            <style:paragraph-properties fo:text-align="center" 
style:justify-single-word="false" style:writing-mode="lr-tb"/>
+            <style:text-properties fo:font-size="40pt" 
style:font-size-asian="40pt" style:font-size-complex="40pt"/>
+        </style:style>
+        <style:style style:name="P2" style:family="paragraph" 
style:parent-style-name="Standard">
+            <loext:graphic-properties draw:fill-color="#eeeeee"/>
+            <style:paragraph-properties fo:text-align="center" 
style:justify-single-word="false" style:writing-mode="lr-tb"/>
+            <style:text-properties fo:font-size="40pt" 
style:font-size-asian="40pt" style:font-size-complex="40pt"/>
+        </style:style>
+        <style:style style:name="P3" style:family="paragraph">
+            <style:paragraph-properties fo:text-align="center" 
style:writing-mode="lr-tb"/>
+            <style:text-properties fo:font-size="40pt" 
style:font-size-asian="40pt" style:font-size-complex="40pt"/>
+        </style:style>
+        <style:style style:name="P4" style:family="paragraph">
+            <loext:graphic-properties draw:fill-color="#eeeeee"/>
+            <style:paragraph-properties fo:text-align="center" 
style:writing-mode="lr-tb"/>
+            <style:text-properties fo:font-size="40pt" 
style:font-size-asian="40pt" style:font-size-complex="40pt"/>
+        </style:style>
+        <style:style style:name="T1" style:family="text">
+            <style:text-properties fo:font-size="40pt" 
style:font-size-asian="40pt" style:font-size-complex="40pt"/>
+        </style:style>
+        <style:style style:name="fr1" style:family="graphic" 
style:parent-style-name="Graphics">
+            <style:graphic-properties style:vertical-pos="from-top" 
style:vertical-rel="page" style:horizontal-pos="from-left" 
style:horizontal-rel="page" style:mirror="none" fo:clip="rect(0cm, 0cm, 0cm, 
0.145cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" 
draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" 
draw:image-opacity="100%" draw:color-mode="standard"/>
+        </style:style>
+        <style:style style:name="fr2" style:family="graphic" 
style:parent-style-name="Graphics">
+            <style:graphic-properties style:vertical-pos="from-top" 
style:vertical-rel="page" style:horizontal-pos="from-left" 
style:horizontal-rel="page" style:mirror="none" fo:clip="rect(0.046cm, 0cm, 
0.046cm, 0cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" 
draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" 
draw:image-opacity="100%" draw:color-mode="standard"/>
+        </style:style>
+        <style:style style:name="gr1" style:family="graphic">
+            <style:graphic-properties draw:fill-color="#eeeeee" 
draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" 
draw:auto-grow-height="false" fo:min-height="1.452cm" fo:min-width="1.637cm" 
style:run-through="foreground" style:wrap="none" style:vertical-pos="from-top" 
style:vertical-rel="page" style:horizontal-pos="from-left" 
style:horizontal-rel="page" draw:wrap-influence-on-position="once-concurrent" 
loext:allow-overlap="true" style:flow-with-text="false"/>
+            <style:paragraph-properties style:writing-mode="lr-tb"/>
+        </style:style>
+        <style:style style:name="gr2" style:family="graphic">
+            <style:graphic-properties draw:fill-color="#eeeeee" 
draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" 
draw:auto-grow-height="false" fo:min-height="1.515cm" fo:min-width="2.18cm" 
style:run-through="foreground" style:wrap="none" style:vertical-pos="from-top" 
style:vertical-rel="page" style:horizontal-pos="from-left" 
style:horizontal-rel="page" draw:wrap-influence-on-position="once-concurrent" 
loext:allow-overlap="true" style:flow-with-text="false"/>
+            <style:paragraph-properties style:writing-mode="lr-tb"/>
+        </style:style>
+        <style:page-layout style:name="pm1">
+            <style:page-layout-properties fo:page-width="21.001cm" 
fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" 
fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" 
fo:margin-right="2cm" style:writing-mode="lr-tb" 
style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" 
style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" 
style:layout-grid-mode="none" style:layout-grid-ruby-below="false" 
style:layout-grid-print="false" style:layout-grid-display="false" 
style:footnote-max-height="0cm" loext:margin-gutter="0cm">
+                <style:footnote-sep style:width="0.018cm" 
style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" 
style:line-style="solid" style:adjustment="left" style:rel-width="25%" 
style:color="#000000"/>
+            </style:page-layout-properties>
+            <style:header-style/>
+            <style:footer-style/>
+        </style:page-layout>
+        <style:style style:name="dp1" style:family="drawing-page">
+            <style:drawing-page-properties draw:background-size="full"/>
+        </style:style>
+    </office:automatic-styles>
+    <office:master-styles>
+        <style:master-page style:name="Standard" style:page-layout-name="pm1" 
draw:style-name="dp1"/>
+    </office:master-styles>
+    <office:body>
+        <office:text>
+            <text:sequence-decls>
+                <text:sequence-decl text:display-outline-level="0" 
text:name="Illustration"/>
+                <text:sequence-decl text:display-outline-level="0" 
text:name="Table"/>
+                <text:sequence-decl text:display-outline-level="0" 
text:name="Text"/>
+                <text:sequence-decl text:display-outline-level="0" 
text:name="Drawing"/>
+                <text:sequence-decl text:display-outline-level="0" 
text:name="Figure"/>
+            </text:sequence-decls>
+            <draw:frame draw:style-name="fr1" draw:name="Image2" 
text:anchor-type="page" text:anchor-page-number="1" svg:x="9.14cm" 
svg:y="7.703cm" svg:width="8.62cm" svg:height="8.652cm" draw:z-index="1">
+                <draw:image draw:mime-type="image/jpeg">
+                    
<office:binary-data>/9j/4AAQSkZJRgABAQEASABIAAD/2wBDABcQERQRDhcUEhQaGBcbIjklIh8fIkYyNSk5UkhX
+                        
VVFIUE5bZoNvW2F8Yk5QcptzfIeLkpSSWG2grJ+OqoOPko3/2wBDARgaGiIeIkMlJUONXlBe
+                        
jY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY3/wAAR
+                        
CAARABADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA
+                        
AgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK
+                        
FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWG
+                        
h4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl
+                        
5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREA
+                        
AgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYk
+                        
NOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOE
+                        
hYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk
+                        
5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDmbO2a6uBEpx3J9BU2oWBsypDbkbuR0NJp
+                        
lyttdhpOFYbSfSrGsXkU4SOJg2DkkdKxcp+0SWxulD2bb3MyiiitjA//2Q==</office:binary-data>
+                </draw:image>
+            </draw:frame>
+            <draw:frame draw:style-name="fr2" draw:name="Image1" 
text:anchor-type="page" text:anchor-page-number="1" svg:x="7.541cm" 
svg:y="0.123cm" svg:width="11.536cm" svg:height="6.879cm" draw:z-index="0">
+                <draw:image draw:mime-type="image/jpeg">
+                    
<office:binary-data>/9j/4AAQSkZJRgABAQEARwBHAAD/2wBDABMNDhAODBMQDxAVFBMWHC4eHBoaHDkpKyIuQztH
+                        
RkI7QUBKVGtaSk9lUEBBXX5eZW5yd3l3SFmDjIJ0i2t1d3P/2wBDARQVFRwYHDceHjdzTUFN
+                        
c3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3P/wAAR
+                        
CAANABYDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA
+                        
AgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK
+                        
FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWG
+                        
h4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl
+                        
5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREA
+                        
AgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYk
+                        
NOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOE
+                        
hYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk
+                        
5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDjYImnnSJerkAZre/4R6ARf62Tfj73GPyr
+                        
nkZkcOpIZTkEdq1P7fu/L27Y9397Fc9aNVtezZ0UZUknzozp4mgmeJiCUODiimu7O5ZjlmOS
+                        T3oroW2pg7X0P//Z</office:binary-data>
+                </draw:image>
+            </draw:frame>
+            <draw:custom-shape text:anchor-type="page" 
text:anchor-page-number="1" draw:z-index="3" draw:name="Shape2" 
draw:style-name="gr1" draw:text-style-name="P4" svg:width="1.638cm" 
svg:height="1.452cm" svg:x="13.571cm" svg:y="8.13cm">
+                <text:p text:style-name="P3">
+                    <text:span text:style-name="T1">2</text:span>
+                </text:p>
+                <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" 
draw:type="rectangle" draw:enhanced-path="M 0 0 L 21600 0 21600 21600 0 21600 0 
0 Z N"/>
+            </draw:custom-shape>
+            <draw:custom-shape text:anchor-type="page" 
text:anchor-page-number="1" draw:z-index="2" draw:name="Shape1" 
draw:style-name="gr2" draw:text-style-name="P4" svg:width="2.181cm" 
svg:height="1.516cm" svg:x="16.718cm" svg:y="0.187cm">
+                <text:p text:style-name="P3">
+                    <text:span text:style-name="T1">1</text:span>
+                </text:p>
+                <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" 
draw:type="rectangle" draw:enhanced-path="M 0 0 L 21600 0 21600 21600 0 21600 0 
0 Z N"/>
+            </draw:custom-shape>
+            <text:p text:style-name="Standard"/>
+        </office:text>
+    </office:body>
+</office:document>
diff --git a/sw/qa/extras/odfimport/data/PageAnchorZIndexSecondPage.fodt 
b/sw/qa/extras/odfimport/data/PageAnchorZIndexSecondPage.fodt
new file mode 100644
index 000000000000..e335eee449bd
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/PageAnchorZIndexSecondPage.fodt
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns
 :config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="ur
 n:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:xforms="http://www.w3.org/2002/xforms"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+    <office:font-face-decls>
+        <style:font-face style:name="Droid Sans Devanagari" 
svg:font-family="&apos;Droid Sans Devanagari&apos;" 
style:font-family-generic="system" style:font-pitch="variable"/>
+        <style:font-face style:name="Droid Sans Devanagari1" 
svg:font-family="&apos;Droid Sans Devanagari&apos;" 
style:font-family-generic="swiss"/>
+        <style:font-face style:name="Liberation Sans" 
svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" 
style:font-pitch="variable"/>
+        <style:font-face style:name="Liberation Serif" 
svg:font-family="&apos;Liberation Serif&apos;" 
style:font-family-generic="roman" style:font-pitch="variable"/>
+        <style:font-face style:name="Noto Serif CJK SC" 
svg:font-family="&apos;Noto Serif CJK SC&apos;" 
style:font-family-generic="system" style:font-pitch="variable"/>
+        <style:font-face style:name="Source Han Sans CN" 
svg:font-family="&apos;Source Han Sans CN&apos;" 
style:font-family-generic="system" style:font-pitch="variable"/>
+    </office:font-face-decls>
+    <office:automatic-styles>
+        <style:style style:name="P1" style:family="paragraph" 
style:parent-style-name="Standard">
+            <style:paragraph-properties fo:text-align="center" 
style:justify-single-word="false" style:writing-mode="lr-tb"/>
+            <style:text-properties fo:font-size="40pt" 
style:font-size-asian="40pt" style:font-size-complex="40pt"/>
+        </style:style>
+        <style:style style:name="P2" style:family="paragraph" 
style:parent-style-name="Standard">
+            <loext:graphic-properties draw:fill-color="#eeeeee"/>
+            <style:paragraph-properties fo:text-align="center" 
style:justify-single-word="false" style:writing-mode="lr-tb"/>
+            <style:text-properties fo:font-size="40pt" 
style:font-size-asian="40pt" style:font-size-complex="40pt"/>
+        </style:style>
+        <style:style style:name="P3" style:family="paragraph">
+            <style:paragraph-properties fo:text-align="center" 
style:writing-mode="lr-tb"/>
+            <style:text-properties fo:font-size="40pt" 
style:font-size-asian="40pt" style:font-size-complex="40pt"/>
+        </style:style>
+        <style:style style:name="P4" style:family="paragraph">
+            <loext:graphic-properties draw:fill-color="#eeeeee"/>
+            <style:paragraph-properties fo:text-align="center" 
style:writing-mode="lr-tb"/>
+            <style:text-properties fo:font-size="40pt" 
style:font-size-asian="40pt" style:font-size-complex="40pt"/>
+        </style:style>
+        <style:style style:name="T1" style:family="text">
+            <style:text-properties fo:font-size="40pt" 
style:font-size-asian="40pt" style:font-size-complex="40pt"/>
+        </style:style>
+        <style:style style:name="fr1" style:family="graphic" 
style:parent-style-name="Graphics">
+            <style:graphic-properties style:vertical-pos="from-top" 
style:vertical-rel="page" style:horizontal-pos="from-left" 
style:horizontal-rel="page" style:mirror="none" fo:clip="rect(0cm, 0cm, 0cm, 
0.145cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" 
draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" 
draw:image-opacity="100%" draw:color-mode="standard"/>
+        </style:style>
+        <style:style style:name="fr2" style:family="graphic" 
style:parent-style-name="Graphics">
+            <style:graphic-properties style:vertical-pos="from-top" 
style:vertical-rel="page" style:horizontal-pos="from-left" 
style:horizontal-rel="page" style:mirror="none" fo:clip="rect(0.046cm, 0cm, 
0.046cm, 0cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" 
draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" 
draw:image-opacity="100%" draw:color-mode="standard"/>
+        </style:style>
+        <style:style style:name="gr1" style:family="graphic">
+            <style:graphic-properties draw:fill-color="#eeeeee" 
draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" 
draw:auto-grow-height="false" fo:min-height="1.452cm" fo:min-width="1.637cm" 
style:run-through="foreground" style:wrap="none" style:vertical-pos="from-top" 
style:vertical-rel="page" style:horizontal-pos="from-left" 
style:horizontal-rel="page" draw:wrap-influence-on-position="once-concurrent" 
loext:allow-overlap="true" style:flow-with-text="false"/>
+            <style:paragraph-properties style:writing-mode="lr-tb"/>
+        </style:style>
+        <style:style style:name="gr2" style:family="graphic">
+            <style:graphic-properties draw:fill-color="#eeeeee" 
draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" 
draw:auto-grow-height="false" fo:min-height="1.515cm" fo:min-width="2.18cm" 
style:run-through="foreground" style:wrap="none" style:vertical-pos="from-top" 
style:vertical-rel="page" style:horizontal-pos="from-left" 
style:horizontal-rel="page" draw:wrap-influence-on-position="once-concurrent" 
loext:allow-overlap="true" style:flow-with-text="false"/>
+            <style:paragraph-properties style:writing-mode="lr-tb"/>
+        </style:style>
+        <style:page-layout style:name="pm1">
+            <style:page-layout-properties fo:page-width="21.001cm" 
fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" 
fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" 
fo:margin-right="2cm" style:writing-mode="lr-tb" 
style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" 
style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" 
style:layout-grid-mode="none" style:layout-grid-ruby-below="false" 
style:layout-grid-print="false" style:layout-grid-display="false" 
style:footnote-max-height="0cm" loext:margin-gutter="0cm">
+                <style:footnote-sep style:width="0.018cm" 
style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" 
style:line-style="solid" style:adjustment="left" style:rel-width="25%" 
style:color="#000000"/>
+            </style:page-layout-properties>
+            <style:header-style/>
+            <style:footer-style/>
+        </style:page-layout>
+        <style:style style:name="dp1" style:family="drawing-page">
+            <style:drawing-page-properties draw:background-size="full"/>
+        </style:style>
+    </office:automatic-styles>
+    <office:master-styles>
+        <style:master-page style:name="Standard" style:page-layout-name="pm1" 
draw:style-name="dp1"/>
+    </office:master-styles>
+    <office:body>
+        <office:text>
+            <text:sequence-decls>
+                <text:sequence-decl text:display-outline-level="0" 
text:name="Illustration"/>
+                <text:sequence-decl text:display-outline-level="0" 
text:name="Table"/>
+                <text:sequence-decl text:display-outline-level="0" 
text:name="Text"/>
+                <text:sequence-decl text:display-outline-level="0" 
text:name="Drawing"/>
+                <text:sequence-decl text:display-outline-level="0" 
text:name="Figure"/>
+            </text:sequence-decls>
+            <draw:frame draw:style-name="fr1" draw:name="Image2" 
text:anchor-type="page" text:anchor-page-number="2" svg:x="9.14cm" 
svg:y="7.703cm" svg:width="8.62cm" svg:height="8.652cm" draw:z-index="1">
+                <draw:image draw:mime-type="image/jpeg">
+                    
<office:binary-data>/9j/4AAQSkZJRgABAQEASABIAAD/2wBDABcQERQRDhcUEhQaGBcbIjklIh8fIkYyNSk5UkhX
+                        
VVFIUE5bZoNvW2F8Yk5QcptzfIeLkpSSWG2grJ+OqoOPko3/2wBDARgaGiIeIkMlJUONXlBe
+                        
jY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY3/wAAR
+                        
CAARABADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA
+                        
AgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK
+                        
FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWG
+                        
h4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl
+                        
5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREA
+                        
AgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYk
+                        
NOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOE
+                        
hYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk
+                        
5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDmbO2a6uBEpx3J9BU2oWBsypDbkbuR0NJp
+                        
lyttdhpOFYbSfSrGsXkU4SOJg2DkkdKxcp+0SWxulD2bb3MyiiitjA//2Q==</office:binary-data>
+                </draw:image>
+            </draw:frame>
+            <draw:frame draw:style-name="fr2" draw:name="Image1" 
text:anchor-type="page" text:anchor-page-number="2" svg:x="7.541cm" 
svg:y="0.123cm" svg:width="11.536cm" svg:height="6.879cm" draw:z-index="0">
+                <draw:image draw:mime-type="image/jpeg">
+                    
<office:binary-data>/9j/4AAQSkZJRgABAQEARwBHAAD/2wBDABMNDhAODBMQDxAVFBMWHC4eHBoaHDkpKyIuQztH
+                        
RkI7QUBKVGtaSk9lUEBBXX5eZW5yd3l3SFmDjIJ0i2t1d3P/2wBDARQVFRwYHDceHjdzTUFN
+                        
c3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3P/wAAR
+                        
CAANABYDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA
+                        
AgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK
+                        
FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWG
+                        
h4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl
+                        
5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREA
+                        
AgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYk
+                        
NOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOE
+                        
hYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk
+                        
5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDjYImnnSJerkAZre/4R6ARf62Tfj73GPyr
+                        
nkZkcOpIZTkEdq1P7fu/L27Y9397Fc9aNVtezZ0UZUknzozp4mgmeJiCUODiimu7O5ZjlmOS
+                        T3oroW2pg7X0P//Z</office:binary-data>
+                </draw:image>
+            </draw:frame>
+            <draw:custom-shape text:anchor-type="page" 
text:anchor-page-number="2" draw:z-index="3" draw:name="Shape2" 
draw:style-name="gr1" draw:text-style-name="P4" svg:width="1.638cm" 
svg:height="1.452cm" svg:x="13.571cm" svg:y="8.13cm">
+                <text:p text:style-name="P3">
+                    <text:span text:style-name="T1">2</text:span>
+                </text:p>
+                <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" 
draw:type="rectangle" draw:enhanced-path="M 0 0 L 21600 0 21600 21600 0 21600 0 
0 Z N"/>
+            </draw:custom-shape>
+            <draw:custom-shape text:anchor-type="page" 
text:anchor-page-number="2" draw:z-index="2" draw:name="Shape1" 
draw:style-name="gr2" draw:text-style-name="P4" svg:width="2.181cm" 
svg:height="1.516cm" svg:x="16.718cm" svg:y="0.187cm">
+                <text:p text:style-name="P3">
+                    <text:span text:style-name="T1">1</text:span>
+                </text:p>
+                <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" 
draw:type="rectangle" draw:enhanced-path="M 0 0 L 21600 0 21600 21600 0 21600 0 
0 Z N"/>
+            </draw:custom-shape>
+            <text:p text:style-name="Standard"/>
+        </office:text>
+    </office:body>
+</office:document>
diff --git a/sw/qa/extras/odfimport/odfimport.cxx 
b/sw/qa/extras/odfimport/odfimport.cxx
index 27e1809eaeff..5dd1bccbe924 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -1000,5 +1000,33 @@ DECLARE_ODFIMPORT_TEST(testTdf133459, "tdf133459.odt")
     CPPUNIT_ASSERT_EQUAL(OUString("QQ YYYY"), getProperty<OUString>(xFormat, 
"FormatString"));
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testPageAnchorZIndexFirstPage)
+{
+    load(mpTestDocumentPath, "PageAnchorZIndexFirstPage.fodt");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Image1 index not 0",
+        sal_Int32(0), getProperty<sal_Int32>(getShapeByName(u"Image1"), 
"ZOrder"));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Image2 index not 1",
+        sal_Int32(1), getProperty<sal_Int32>(getShapeByName(u"Image2"), 
"ZOrder"));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Shape1 index not 2",
+        sal_Int32(2), getProperty<sal_Int32>(getShapeByName(u"Shape1"), 
"ZOrder"));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Shape2 index not 3",
+        sal_Int32(3), getProperty<sal_Int32>(getShapeByName(u"Shape2"), 
"ZOrder"));
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testPageAnchorZIndexSecondPage)
+{
+    load(mpTestDocumentPath, "PageAnchorZIndexSecondPage.fodt");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Image1 index not 0",
+        sal_Int32(0), getProperty<sal_Int32>(getShapeByName(u"Image1"), 
"ZOrder"));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Image2 index not 1",
+        sal_Int32(1), getProperty<sal_Int32>(getShapeByName(u"Image2"), 
"ZOrder"));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Shape1 index not 2",
+        sal_Int32(2), getProperty<sal_Int32>(getShapeByName(u"Shape1"), 
"ZOrder"));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Shape2 index not 3",
+        sal_Int32(3), getProperty<sal_Int32>(getShapeByName(u"Shape2"), 
"ZOrder"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx
index 1d1f4597fcf2..711a68765991 100644
--- a/sw/source/core/layout/newfrm.cxx
+++ b/sw/source/core/layout/newfrm.cxx
@@ -500,8 +500,7 @@ void SwRootFrame::Init( SwFrameFormat* pFormat )
 
     SwNodeIndex aTmp( 
*pDoc->GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
     ::InsertCnt_( pLay, pDoc, aTmp.GetIndex(), true );
-    //Remove masters that haven't been replaced yet from the list.
-    RemoveMasterObjs( mpDrawPage );
+
     if( rSettingAccess.get(DocumentSettingId::GLOBAL_DOCUMENT) )
         rFieldsAccess.UpdateRefFields();
     //b6433357: Update page fields after loading
diff --git a/sw/source/core/layout/pagechg.cxx 
b/sw/source/core/layout/pagechg.cxx
index a684b1602a1a..4f8ca7f585bc 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1632,6 +1632,9 @@ void SwRootFrame::AssertFlyPages()
         AssertPageFlys(pFirstRevivedEmptyPage);
     }
 
+    //Remove masters that haven't been replaced yet from the list.
+    RemoveMasterObjs( mpDrawPage );
+
 #if OSL_DEBUG_LEVEL > 0
     pPage = static_cast<SwPageFrame*>(Lower());
     while ( pPage && pPage->GetNext() &&

Reply via email to