sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0equalA.docx              
|binary
 sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0equalB.docx              
|binary
 sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0max.docx                 
|binary
 sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_duplicate_compat15.docx       
|binary
 sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_max.docx                      
|binary
 sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_maxLessOne.docx               
|binary
 sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_zIndexDuplicate_compat15.docx 
|binary
 sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_zIndexMax.docx                
|binary
 sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_zIndexWins.docx               
|binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx                                   | 
 176 ++++++----
 writerfilter/source/dmapper/GraphicImport.cxx                                | 
   7 
 11 files changed, 112 insertions(+), 71 deletions(-)

New commits:
commit 3f50503a69bc92e3a0c6c36686d8ff37d77188bf
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Wed Jan 17 13:18:09 2024 -0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Jan 19 09:03:03 2024 +0100

    tdf#159158 DOCX import: relativeHeights of 0/1 are highest zOrder #2
    
    I thought I had removed all fallback stuff from the unit tests,
    but I was wrong. So do some general clean-up and simplification.
    
    I also needed to fix the maximum value for relativeHeight.
    Sadly, even my my unit test was wrong - since MS Word 2010 clearly
    showed the yellow star on the top for tdf159158_zOrder_max.docx. FIXED.
    
    I can't put my finger on why sometimes 0F00 0000 is a maximum...
    More testing suggests that generally the max is 01dff ffff.
    Again, this is based on testing
    since documentation makes no reference at all to a maximum.
    I also wonder if the last 10 bits aren't magical somehow...
    
    The previous max didn't sound right because
    there are so many unit tests with relativeHeights above 0F00 0000
    (and the values jump by 0400).
    
    RTF almost never uses GraphicImport, and no unit tests
    access relativeHeight, only behindDoc. It is used for
    IMPORT_AS_DETECTED_INLINE and passing arbitrary
    property-names and values to a shape (via \sp \sv).
    Thus, this change is DOCX only (effectively).
    
    Change-Id: I18c0e129a078abe5987b998b15697f4ae1a50a96
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162232
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0equalA.docx 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0equalA.docx
index 6c4e28769209..80a2e75deb01 100644
Binary files a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0equalA.docx 
and b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0equalA.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0equalB.docx 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0equalB.docx
index ae79fda6a78a..b6603df3d6e4 100644
Binary files a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0equalB.docx 
and b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0equalB.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0max.docx 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0max.docx
index edb1304b9922..6f77ba880014 100644
Binary files a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0max.docx and 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_1and0max.docx differ
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_duplicate_compat15.docx 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_duplicate_compat15.docx
index b39694ff9457..c09c854191b7 100644
Binary files 
a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_duplicate_compat15.docx and 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_duplicate_compat15.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_max.docx 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_max.docx
index 46119741d092..f787f359416b 100644
Binary files a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_max.docx and 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_max.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_maxLessOne.docx 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_maxLessOne.docx
new file mode 100644
index 000000000000..2a7b02404df4
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_maxLessOne.docx differ
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_zIndexDuplicate_compat15.docx 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_zIndexDuplicate_compat15.docx
new file mode 100644
index 000000000000..ba1e20ea98b2
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_zIndexDuplicate_compat15.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_zIndexMax.docx 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_zIndexMax.docx
new file mode 100644
index 000000000000..5ac9f191e2df
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_zIndexMax.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_zIndexWins.docx 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_zIndexWins.docx
new file mode 100644
index 000000000000..b7e7e97c4f5e
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_zIndexWins.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 76b0d0423831..40c4a42d4e8c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -868,97 +868,137 @@ DECLARE_OOXMLEXPORT_TEST(testTdf155736, 
"tdf155736_PageNumbers_footer.docx")
     CPPUNIT_ASSERT_EQUAL(OUString("Page * of *"), 
parseDump("/root/page[2]/footer/txt/text()"_ostr));
 }
 
+// The following zOrder tests are checking the shapes "stacking height".
+// getShape(nZOrder) already gets them in lowest-to-highest order,
+// so for any overlapping shapes the highest numbered shape is expected to be 
the one on top.
+// Which shape that actually is can be usually be verified based on the shape 
name.
 DECLARE_OOXMLEXPORT_TEST(testTdf159158_zOrder_duplicate, 
"tdf159158_zOrder_duplicate_compat15.docx")
 {
     // given a yellow star with relativeHeight 2, followed by an overlapping 
blue star also with 2
-    uno::Reference<drawing::XShape> image1 = getShape(1), image2 = getShape(2);
-    sal_Int32 zOrder1, zOrder2;
-    OUString descr1, descr2;
-    uno::Reference<beans::XPropertySet> imageProperties1(image1, 
uno::UNO_QUERY);
-    imageProperties1->getPropertyValue( "ZOrder" ) >>= zOrder1;
-    imageProperties1->getPropertyValue( "Name" ) >>= descr1;
-    uno::Reference<beans::XPropertySet> imageProperties2(image2, 
uno::UNO_QUERY);
-    imageProperties2->getPropertyValue( "ZOrder" ) >>= zOrder2;
-    imageProperties2->getPropertyValue( "Name" ) >>= descr2;
-    CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), zOrder1 ); // lower
-    CPPUNIT_ASSERT_EQUAL( sal_Int32( 1 ), zOrder2 ); // higher
-    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Yellow"), descr1);
-    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), descr2); // last one 
defined wins
+    uno::Reference<beans::XPropertySet> zOrder0(getShape(1), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> zOrder1(getShape(2), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(zOrder0, 
"ZOrder")); // lower
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(zOrder1, 
"ZOrder")); // higher
+    // the zOrder of the stars should remain consistent between round-trips - 
last duplicate wins
+    // and compatibility has nothing to do with this for relativeHeight (other 
tests are compat12).
+    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Yellow"), 
getProperty<OUString>(zOrder0, "Name"));
+    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), 
getProperty<OUString>(zOrder1,"Name"));
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf159158_zOrder_1and0equalA, 
"tdf159158_zOrder_1and0equalA.docx")
 {
     // given a yellow star with relativeHeight 1, followed by an overlapping 
blue star with 0
-    uno::Reference<drawing::XShape> image1 = getShape(1), image2 = getShape(2);
-    sal_Int32 zOrder1, zOrder2;
-    OUString descr1, descr2;
-    uno::Reference<beans::XPropertySet> imageProperties1(image1, 
uno::UNO_QUERY);
-    imageProperties1->getPropertyValue("ZOrder") >>= zOrder1;
-    imageProperties1->getPropertyValue("Name") >>= descr1;
-    uno::Reference<beans::XPropertySet> imageProperties2(image2, 
uno::UNO_QUERY);
-    imageProperties2->getPropertyValue("ZOrder") >>= zOrder2;
-    imageProperties2->getPropertyValue("Name") >>= descr2;
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), zOrder1); // lower
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), zOrder2); // higher
-    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Yellow"), descr1);
-    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), descr2); // 0 >= 1 
(last one wins)
+    uno::Reference<beans::XPropertySet> zOrder0(getShape(1), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> zOrder1(getShape(2), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(zOrder0, 
"ZOrder")); // lower
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(zOrder1, 
"ZOrder")); // higher
+    // 0 is treated the same as 1 - the maximum value, so blue is duplicate - 
last duplicate wins
+    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Yellow"), 
getProperty<OUString>(zOrder0, "Name"));
+    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), 
getProperty<OUString>(zOrder1,"Name"));
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf159158_zOrder_1and0equalB, 
"tdf159158_zOrder_1and0equalB.docx")
 {
     // given a yellow star with relativeHeight 0, followed by an overlapping 
blue star with 1
     // since they have the same zOrder value, last one wins, so same result as 
version A
-    uno::Reference<drawing::XShape> image1 = getShape(1), image2 = getShape(2);
-    sal_Int32 zOrder1, zOrder2;
-    OUString descr1, descr2;
-    uno::Reference<beans::XPropertySet> imageProperties1(image1, 
uno::UNO_QUERY);
-    imageProperties1->getPropertyValue("ZOrder") >>= zOrder1;
-    imageProperties1->getPropertyValue("Name") >>= descr1;
-    uno::Reference<beans::XPropertySet> imageProperties2(image2, 
uno::UNO_QUERY);
-    imageProperties2->getPropertyValue("ZOrder") >>= zOrder2;
-    imageProperties2->getPropertyValue("Name") >>= descr2;
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), zOrder1); // lower
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), zOrder2); // higher
-    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Yellow"), descr1);
-    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), descr2); // 1 >= 0 
(last one wins)
+    uno::Reference<beans::XPropertySet> zOrder0(getShape(1), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> zOrder1(getShape(2), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(zOrder0, 
"ZOrder")); // lower
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(zOrder1, 
"ZOrder")); // higher
+    // 1 is treated the same as 0 - the maximum value, so blue is duplicate - 
last duplicate wins
+    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Yellow"), 
getProperty<OUString>(zOrder0, "Name"));
+    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), 
getProperty<OUString>(zOrder1,"Name"));
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf159158_zOrder_1and0max, 
"tdf159158_zOrder_1and0max.docx")
 {
-    // given a yellow star with relativeHeight 251658240 (0F00 0000)
+    // given a yellow star with maximum relativeHeight 503316479 (1DFF FFFF)
     // followed by an overlapping blue star with 0.
-    uno::Reference<drawing::XShape> image1 = getShape(1), image2 = getShape(2);
-    sal_Int32 zOrder1, zOrder2;
-    OUString descr1, descr2;
-    uno::Reference<beans::XPropertySet> imageProperties1(image1, 
uno::UNO_QUERY);
-    imageProperties1->getPropertyValue("ZOrder") >>= zOrder1;
-    imageProperties1->getPropertyValue("Name") >>= descr1;
-    uno::Reference<beans::XPropertySet> imageProperties2(image2, 
uno::UNO_QUERY);
-    imageProperties2->getPropertyValue("ZOrder") >>= zOrder2;
-    imageProperties2->getPropertyValue("Name") >>= descr2;
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), zOrder1); // lower
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), zOrder2); // higher
-    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Yellow"), descr1);
-    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), descr2); // 0 >= 0F00 
0000 (last one wins)
+    uno::Reference<beans::XPropertySet> zOrder0(getShape(1), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> zOrder1(getShape(2), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(zOrder0, 
"ZOrder")); // lower
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(zOrder1, 
"ZOrder")); // higher
+    // 0 is treated the same as the maximum value, last duplicate wins, so 
blue is on top
+    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Yellow"), 
getProperty<OUString>(zOrder0, "Name"));
+    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), 
getProperty<OUString>(zOrder1,"Name"));
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf159158_zOrder_maxLessOne, 
"tdf159158_zOrder_maxLessOne.docx")
+{
+    // given a yellow star with relativeHeight 503316479 (1DFF FFFF)
+    // followed by a partially hidden blue star with lower relativeHeight 
503316478 (1DFF FFFE)
+    uno::Reference<beans::XPropertySet> zOrder0(getShape(1), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> zOrder1(getShape(2), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(zOrder0, 
"ZOrder")); // lower
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(zOrder1, 
"ZOrder")); // higher
+    // since yellow is a higher value, it should be on top
+    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), 
getProperty<OUString>(zOrder0,"Name"));
+    CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Yellow"), 
getProperty<OUString>(zOrder1, "Name"));
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf159158_zOrder_max, "tdf159158_zOrder_max.docx")
 {
-    // given a yellow star with relativeHeight 251658241 (0F00 0001)
-    // followed by an overlapping blue star with relativeHeight 251658240 
(0F00 0000)
-    uno::Reference<drawing::XShape> image1 = getShape(1), image2 = getShape(2);
-    sal_Int32 zOrder1, zOrder2;
-    OUString descr1, descr2;
-    uno::Reference<beans::XPropertySet> imageProperties1(image1, 
uno::UNO_QUERY);
-    imageProperties1->getPropertyValue("ZOrder") >>= zOrder1;
-    imageProperties1->getPropertyValue("Name") >>= descr1;
-    uno::Reference<beans::XPropertySet> imageProperties2(image2, 
uno::UNO_QUERY);
-    imageProperties2->getPropertyValue("ZOrder") >>= zOrder2;
-    imageProperties2->getPropertyValue("Name") >>= descr2;
-//     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), zOrder1); // lower
-//     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), zOrder2); // higher
-//     CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Yellow"), descr1);
-//     CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), descr2); // 0F00 
0000 == 0F00 0001
+    // given a yellow star with (one higher than maximum) relativeHeight 
503316480 (1E00 0000)
+    // followed by an overlapping blue star with maximum relativeHeight  
503316479 (1DFF FFFF)
+    uno::Reference<beans::XPropertySet> zOrder0(getShape(1), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> zOrder1(getShape(2), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(zOrder0, 
"ZOrder")); // lower
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(zOrder1, 
"ZOrder")); // higher
+    // while yellow is a higher value, last duplicate wins, so lower value 
blue must be the maximum
+    // CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Yellow"), 
getProperty<OUString>(zOrder0, "Name"));
+    // CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), 
getProperty<OUString>(zOrder1,"Name"));
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf159158_zOrder_zIndexMax, 
"tdf159158_zOrder_zIndexMax.docx")
+{
+    // given a yellow star with a heaven z-index of MAX_SAL_INT32
+    // followed by overlapped blue star with a heaven z-index of MAX_SAL_INT32 
- 1
+    uno::Reference<beans::XPropertySet> zOrder0(getShape(1), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> zOrder1(getShape(2), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(zOrder0, 
"ZOrder")); // lower
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(zOrder1, 
"ZOrder")); // higher
+    // there is no artificial maximum for z-index. All values are unique. 
Yellow is on top
+    if (!isExported()) //somehow the name is lost on this export
+        CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), 
getProperty<OUString>(zOrder0, "Name"));
+    if (!isExported()) //somehow the name is lost on this export
+        CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Yellow"), 
getProperty<OUString>(zOrder1,"Name"));
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf159158_zOrder_zIndexDuplicate_compat15, 
"tdf159158_zOrder_zIndexDuplicate_compat15.docx")
+{
+    // given a yellow star with a heaven z-index of MAX_SAL_INT32 - 1
+    // followed by overlapping blue star with the same heaven z-index (last 
duplicate wins)
+    uno::Reference<beans::XPropertySet> zOrder0(getShape(1), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> zOrder1(getShape(2), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(zOrder0, 
"ZOrder")); // lower
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(zOrder1, 
"ZOrder")); // higher
+    // should be the same as relativeHeight - last duplicate wins so blue is 
on top.
+    // CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Yellow"), 
getProperty<OUString>(zOrder0, "Name"));
+    // CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), 
getProperty<OUString>(zOrder1,"Name"));
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf159158_zOrder_zIndexWins, 
"tdf159158_zOrder_zIndexWins.docx")
+{
+    // given a yellow star with relativeHeight 0 (typically a maximum value, 
but not today)
+    // followed by an overlapping-everything textbox at z-index 0 (the lowest 
heaven-layer z-index)
+    // followed by a partially overlapping blue star with a
+    // seems-to-be-a-magic-number relativeHeight 251658240 (0F00 0000)
+    uno::Reference<beans::XPropertySet> zOrder0(getShape(1), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> zOrder1(getShape(2), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> zOrder2(getShape(3), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(zOrder0, 
"ZOrder")); // lower
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(zOrder1, 
"ZOrder"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(zOrder2, 
"ZOrder")); // higher
+    // If zOrder is defined by z-index, it seems that it goes above everything 
set by relativeHeight
+    if (isExported()) // not named on import
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("DID YOU FIX ME? Frame1 really should be 
at the very top",
+                                     OUString("Frame1"), 
getProperty<OUString>(zOrder0,"Name"));
+    // I'm puzzled. Somehow 0 is larger than 0EFF FFFF, but not larger than 
0F00 0000
+    // and yet the maximum value was established earlier as 1DFF FFFF. 
Something doesn't line up.
+    // Perhaps 0 and 1 don't mean maximum value at all, but something 
completely different?
+    CPPUNIT_ASSERT_MESSAGE("DID YOU FIX ME? I really should be yellow, not 
blue",
+                            "5-Point Star Yellow" != 
getProperty<OUString>(zOrder1, "Name"));
+    // CPPUNIT_ASSERT_EQUAL(OUString("5-Point Star Blue"), 
getProperty<OUString>(zOrder2,"Name"));
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf155903, "tdf155903.odt")
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx 
b/writerfilter/source/dmapper/GraphicImport.cxx
index c8a1e166d472..cacae807b48d 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -739,9 +739,10 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
         break;
         case NS_ooxml::LN_CT_Anchor_relativeHeight: // unsigned content
         {
-            // undocumented - based on testing: both 0 and 1 are equivalent to 
the maximum 251658240
-            if (nIntValue < 2/* || nIntValue > 0x0F000000*/)
-                m_pImpl->m_zOrder = 0x0F000000;
+            // undocumented - based on testing: both 0 and 1 are equivalent to 
the maximum 503316479
+            const sal_Int32 nMaxAllowed = 0x1DFFFFFF;
+            if (nIntValue < 2/* || nIntValue > nMaxAllowed*/)
+                m_pImpl->m_zOrder = nMaxAllowed;
             else
                 m_pImpl->m_zOrder = nIntValue;
         }

Reply via email to