[Libreoffice-commits] core.git: include/xmloff schema/libreoffice sc/qa sc/source sw/qa sw/source xmloff/source
Michael Stahl (via logerrit)
logerrit at kemper.freedesktop.org
Wed Apr 7 08:03:59 UTC 2021
include/xmloff/shapeexport.hxx | 2
sc/qa/unit/data/fods/shapes_foreground_background.fods | 49 +++
sc/qa/unit/subsequent_export-test.cxx | 12
sc/source/filter/xml/xmlwrap.cxx | 17 +
schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng | 146 ++++++++++
sw/qa/extras/odfexport/data/Formcontrol needs high z-index.odt |binary
sw/qa/extras/odfexport/odfexport.cxx | 12
sw/source/filter/xml/wrtxml.cxx | 7
sw/source/filter/xml/xmlexp.cxx | 7
sw/source/filter/xml/zorder.hxx | 78 +++++
xmloff/source/draw/shapeexport.cxx | 43 ++
11 files changed, 351 insertions(+), 22 deletions(-)
New commits:
commit 79ef3c7ae3b2f7be5ba6fe38997e846fd9c7e0ee
Author: Michael Stahl <michael.stahl at allotropia.de>
AuthorDate: Tue Apr 6 18:54:51 2021 +0200
Commit: Michael Stahl <michael.stahl at allotropia.de>
CommitDate: Wed Apr 7 10:03:15 2021 +0200
tdf#141467 xmloff,sc,sw: ODF export: reorder flys' ZOrder/z-index harder
Also keep the control layer distinct from the foreground, as a follow-up
to tdf#133487.
Try to improve the detection of already sorted indexes a bit to avoid
unnecessary sorting.
Hilariously the test docs require adding 3 additional items to the
extension schema.
Change-Id: I629d5b09294f679717677b9d89537d905ac4c404
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113696
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>
diff --git a/include/xmloff/shapeexport.hxx b/include/xmloff/shapeexport.hxx
index e5012d84836d..d8641451cf4d 100644
--- a/include/xmloff/shapeexport.hxx
+++ b/include/xmloff/shapeexport.hxx
@@ -302,7 +302,7 @@ namespace xmloff {
XMLOFF_DLLPUBLIC void FixZOrder(
css::uno::Reference<css::drawing::XShapes> const& xShapes,
- std::function<bool(css::uno::Reference<css::beans::XPropertySet> const&)> const& rIsInBackground);
+ std::function<unsigned int (css::uno::Reference<css::beans::XPropertySet> const&)> const& rGetLayer);
} // namespace xmloff
diff --git a/sc/qa/unit/data/fods/shapes_foreground_background.fods b/sc/qa/unit/data/fods/shapes_foreground_background.fods
index 0f203a93dc20..497d8bf46d10 100644
--- a/sc/qa/unit/data/fods/shapes_foreground_background.fods
+++ b/sc/qa/unit/data/fods/shapes_foreground_background.fods
@@ -104,6 +104,12 @@
<style:style style:name="gr3" style:family="graphic">
<style:graphic-properties draw:fill-color="#0000ff" draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" draw:auto-grow-height="false" fo:min-height="0.914cm" fo:min-width="8.397cm"/>
</style:style>
+ <style:style style:name="gr4" style:family="graphic">
+ <style:graphic-properties fo:border="none"/>
+ </style:style>
+ <style:style style:name="gr5" style:family="graphic">
+ <style:graphic-properties draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" draw:auto-grow-height="false" fo:min-height="25.62mm" fo:min-width="1.48mm"/>
+ </style:style>
<style:page-layout style:name="pm1">
<style:page-layout-properties style:writing-mode="lr-tb"/>
<style:header-style>
@@ -170,6 +176,49 @@
<office:spreadsheet>
<table:calculation-settings table:automatic-find-labels="false" table:use-regular-expressions="false" table:use-wildcards="true"/>
<table:table table:name="Sheet1" table:style-name="ta1">
+ <office:forms form:automatic-focus="false" form:apply-design-mode="false">
+ <form:form form:name="Form" form:apply-filter="true" form:command-type="table" form:control-implementation="ooo:com.sun.star.form.component.Form" office:target-frame="">
+ <form:properties>
+ <form:property form:property-name="PropertyChangeNotificationEnabled" office:value-type="boolean" office:boolean-value="true"/>
+ <form:property form:property-name="TargetURL" office:value-type="string" office:string-value=""/>
+ </form:properties>
+ <form:listbox form:name="List Box 1" form:control-implementation="ooo:com.sun.star.form.component.ListBox" xml:id="control1" form:id="control1" form:dropdown="true" form:size="20" form:input-required="false" form:bound-column="1" form:linked-cell="Sheet1.E2" form:list-linkage-type="selection">
+ <form:properties>
+ <form:property form:property-name="ControlTypeinMSO" office:value-type="float" office:value="0"/>
+ <form:property form:property-name="DefaultControl" office:value-type="string" office:string-value="com.sun.star.form.control.ListBox"/>
+ <form:property form:property-name="MouseWheelBehavior" office:value-type="float" office:value="0"/>
+ <form:property form:property-name="ObjIDinMSO" office:value-type="float" office:value="65535"/>
+ <form:list-property form:property-name="TypedItemList" office:value-type="float"/>
+ </form:properties>
+ <form:option form:label="11"/>
+ <form:option form:label="12" form:current-selected="true"/>
+ <form:option form:label="13"/>
+ <form:option form:label="14"/>
+ <form:option form:label="15"/>
+ <form:option form:label="16"/>
+ <form:option form:label="17"/>
+ <form:option form:label="18"/>
+ <form:option form:label="19"/>
+ </form:listbox>
+ </form:form>
+ </office:forms>
+ <table:shapes>
+ <draw:control draw:z-index="3" draw:name="Control 1" draw:style-name="gr4" draw:text-style-name="P1" svg:width="21.78mm" svg:height="7.45mm" svg:x="41.78mm" svg:y="10.85mm" draw:control="control1"/>
+ <draw:custom-shape draw:z-index="4" draw:name="Shape 1" draw:style-name="gr5" draw:text-style-name="P2" svg:width="6.19mm" svg:height="27.24mm" svg:x="49.04mm" svg:y="12.34mm">
+ <text:p/>
+ <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" draw:text-areas="?f0 0 ?f2 ?f5" draw:type="down-arrow" draw:modifiers="17208.6605504587 7455.48387096774" draw:enhanced-path="M ?f0 0 L ?f0 ?f1 0 ?f1 10800 21600 21600 ?f1 ?f2 ?f1 ?f2 0 Z N">
+ <draw:equation draw:name="f0" draw:formula="$1 "/>
+ <draw:equation draw:name="f1" draw:formula="$0 "/>
+ <draw:equation draw:name="f2" draw:formula="21600-$1 "/>
+ <draw:equation draw:name="f3" draw:formula="21600-?f1 "/>
+ <draw:equation draw:name="f4" draw:formula="?f3 *?f0 /10800"/>
+ <draw:equation draw:name="f5" draw:formula="?f1 +?f4 "/>
+ <draw:equation draw:name="f6" draw:formula="?f1 *?f0 /10800"/>
+ <draw:equation draw:name="f7" draw:formula="?f1 -?f6 "/>
+ <draw:handle draw:handle-position="$1 $0" draw:handle-range-x-minimum="0" draw:handle-range-x-maximum="10800" draw:handle-range-y-minimum="0" draw:handle-range-y-maximum="21600"/>
+ </draw:enhanced-geometry>
+ </draw:custom-shape>
+ </table:shapes>
<table:table-column table:style-name="co1" table:number-columns-repeated="2" table:default-cell-style-name="Default"/>
<table:table-row table:style-name="ro1">
<table:table-cell>
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 204889815292..be2339b7f25d 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -3144,6 +3144,18 @@ void ScExportTest::testTdf133487()
// attribute is only written for value "true"
assertXPath(pXmlDoc, "/office:document-content/office:body/office:spreadsheet/table:table[1]/table:table-row[3]/table:table-cell[1]/draw:custom-shape"
"/attribute::table:table-background", 0);
+ // shape in foreground, previously index 4
+ assertXPath(pXmlDoc, "/office:document-content/office:body/office:spreadsheet/table:table[1]/table:shapes/draw:custom-shape",
+ "z-index", "3");
+ // attribute is only written for value "true"
+ assertXPath(pXmlDoc, "/office:document-content/office:body/office:spreadsheet/table:table[1]/table:shapes/draw:custom-shape"
+ "/attribute::table:table-background", 0);
+ // form control, previously index 3
+ assertXPath(pXmlDoc, "/office:document-content/office:body/office:spreadsheet/table:table[1]/table:shapes/draw:control",
+ "z-index", "4");
+ // attribute is only written for value "true"
+ assertXPath(pXmlDoc, "/office:document-content/office:body/office:spreadsheet/table:table[1]/table:shapes/draw:control"
+ "/attribute::table:table-background", 0);
xShell->DoClose();
}
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index 573f6886539c..4b390c412af5 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -22,6 +22,7 @@
#include <sfx2/objsh.hxx>
#include <sot/storage.hxx>
#include <osl/diagnose.h>
+#include <o3tl/unreachable.hxx>
#include <comphelper/fileformat.h>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
@@ -783,7 +784,21 @@ bool ScXMLImportWrapper::Export(bool bStylesOnly)
{
sal_Int16 nLayerID(0);
xShape->getPropertyValue("LayerID") >>= nLayerID;
- return SdrLayerID(nLayerID) == SC_LAYER_BACK;
+ switch (nLayerID)
+ {
+ case sal_uInt8(SC_LAYER_FRONT):
+ return 1;
+ case sal_uInt8(SC_LAYER_BACK):
+ return 0;
+ case sal_uInt8(SC_LAYER_INTERN):
+ return 2;
+ case sal_uInt8(SC_LAYER_CONTROLS):
+ return 3;
+ case sal_uInt8(SC_LAYER_HIDDEN):
+ return 1; // treat as equivalent to front
+ default:
+ O3TL_UNREACHABLE;
+ }
});
}
diff --git a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
index 3898ed2f73ab..8907ac4eb3b2 100644
--- a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
+++ b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
@@ -1579,6 +1579,138 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
</rng:choice>
</rng:define>
+ <rng:define name="style-graphic-fill-properties-attlist">
+ <rng:interleave>
+ <rng:optional>
+ <rng:attribute name="draw:fill">
+ <rng:choice>
+ <rng:value>none</rng:value>
+ <rng:value>solid</rng:value>
+ <rng:value>bitmap</rng:value>
+ <rng:value>gradient</rng:value>
+ <rng:value>hatch</rng:value>
+ </rng:choice>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:fill-color">
+ <rng:ref name="color"/>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:secondary-fill-color">
+ <rng:ref name="color"/>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:fill-gradient-name">
+ <rng:ref name="styleNameRef"/>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:gradient-step-count">
+ <rng:ref name="nonNegativeInteger"/>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:fill-hatch-name">
+ <rng:ref name="styleNameRef"/>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:fill-hatch-solid">
+ <rng:ref name="boolean"/>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:fill-image-name">
+ <rng:ref name="styleNameRef"/>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="style:repeat">
+ <rng:choice>
+ <rng:value>no-repeat</rng:value>
+ <rng:value>repeat</rng:value>
+ <rng:value>stretch</rng:value>
+ <!-- OFFICE-4106 7a5d79f2297a43d0a854e304b0792164272edfe0 in xmloff/source/forms/formenums.cxx -->
+ <rng:value>scale</rng:value>
+ </rng:choice>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:fill-image-width">
+ <rng:choice>
+ <rng:ref name="length"/>
+ <rng:ref name="percent"/>
+ </rng:choice>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:fill-image-height">
+ <rng:choice>
+ <rng:ref name="length"/>
+ <rng:ref name="percent"/>
+ </rng:choice>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:fill-image-ref-point-x">
+ <rng:ref name="percent"/>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:fill-image-ref-point-y">
+ <rng:ref name="percent"/>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:fill-image-ref-point">
+ <rng:choice>
+ <rng:value>top-left</rng:value>
+ <rng:value>top</rng:value>
+ <rng:value>top-right</rng:value>
+ <rng:value>left</rng:value>
+ <rng:value>center</rng:value>
+ <rng:value>right</rng:value>
+ <rng:value>bottom-left</rng:value>
+ <rng:value>bottom</rng:value>
+ <rng:value>bottom-right</rng:value>
+ </rng:choice>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:tile-repeat-offset">
+ <rng:list>
+ <rng:ref name="zeroToHundredPercent"/>
+ <rng:choice>
+ <rng:value>horizontal</rng:value>
+ <rng:value>vertical</rng:value>
+ </rng:choice>
+ </rng:list>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:opacity">
+ <rng:ref name="zeroToHundredPercent"/>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="draw:opacity-name">
+ <rng:ref name="styleNameRef"/>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
+ <rng:attribute name="svg:fill-rule">
+ <rng:choice>
+ <rng:value>nonzero</rng:value>
+ <rng:value>evenodd</rng:value>
+ </rng:choice>
+ </rng:attribute>
+ </rng:optional>
+ </rng:interleave>
+ </rng:define>
+
</rng:include>
<!-- TODO no proposal -->
@@ -2279,6 +2411,20 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
</rng:attribute>
</rng:optional>
</rng:define>
+ <rng:define name="form-image-frame-attlist" combine="interleave">
+ <rng:optional>
+ <rng:attribute name="form:input-required">
+ <rng:ref name="boolean"/>
+ </rng:attribute>
+ </rng:optional>
+ </rng:define>
+ <rng:define name="form-listbox-attlist" combine="interleave">
+ <rng:optional>
+ <rng:attribute name="form:input-required">
+ <rng:ref name="boolean"/>
+ </rng:attribute>
+ </rng:optional>
+ </rng:define>
<!-- https://issues.oasis-open.org/browse/OFFICE-4030 -->
<rng:define name="common-writing-mode-attlist" combine="interleave">
diff --git a/sw/qa/extras/odfexport/data/Formcontrol needs high z-index.odt b/sw/qa/extras/odfexport/data/Formcontrol needs high z-index.odt
new file mode 100644
index 000000000000..4b03bd7fd197
Binary files /dev/null and b/sw/qa/extras/odfexport/data/Formcontrol needs high z-index.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index f570e9f5d40a..6dc67ca58a1d 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -246,6 +246,18 @@ DECLARE_ODFEXPORT_EXPORTONLY_TEST(testTdf133487, "MadeByLO7.odt")
assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name = /office:document-content/office:body/office:text/text:p[3]/draw:custom-shape[@draw:z-index = '1']/attribute::draw:style-name]/style:graphic-properties", "run-through", "foreground");
}
+DECLARE_ODFEXPORT_EXPORTONLY_TEST(testTdf141467, "Formcontrol needs high z-index.odt")
+{
+ xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
+ // shape in foreground has lowest index
+ assertXPath(pXmlDoc, "/office:document-content/office:body/office:text/text:p[2]/draw:custom-shape", "z-index", "0");
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name = /office:document-content/office:body/office:text/text:p[2]/draw:custom-shape[@draw:z-index = '0']/attribute::draw:style-name]/style:graphic-properties", "run-through", "foreground");
+ // form control, previously index 0
+ assertXPath(pXmlDoc, "/office:document-content/office:body/office:text/text:p[2]/draw:control", "z-index", "1");
+ // no run-through on form's style
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name = /office:document-content/office:body/office:text/text:p[2]/draw:control[@draw:z-index = '1']/attribute::draw:style-name]/style:graphic-properties/attribute::run-through", 0);
+}
+
DECLARE_ODFEXPORT_TEST(testTdf139126, "tdf139126.odt")
{
CPPUNIT_ASSERT_EQUAL(1, getPages());
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
index 288814017c25..be2a21aeeefa 100644
--- a/sw/source/filter/xml/wrtxml.cxx
+++ b/sw/source/filter/xml/wrtxml.cxx
@@ -58,6 +58,7 @@
#include <unotools/ucbstreamhelper.hxx>
#include <swerror.h>
#include "wrtxml.hxx"
+#include "zorder.hxx"
#include <strings.hrc>
#include <comphelper/documentconstants.hxx>
@@ -186,11 +187,7 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
uno::Reference<lang::XComponent> const xModelComp(m_pDoc->GetDocShell()->GetModel());
uno::Reference<drawing::XDrawPageSupplier> const xDPS(xModelComp, uno::UNO_QUERY);
assert(xDPS.is());
- xmloff::FixZOrder(xDPS->getDrawPage(),
- [](uno::Reference<beans::XPropertySet> const& xShape)
- {
- return !*o3tl::doAccess<bool>(xShape->getPropertyValue("Opaque"));
- });
+ xmloff::FixZOrder(xDPS->getDrawPage(), sw::GetZOrderLayer(m_pDoc->getIDocumentDrawModelAccess()));
// save show redline mode ...
RedlineFlags const nOrigRedlineFlags = m_pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index 1e112f5a0367..387546eceda3 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -50,6 +50,7 @@
#include "xmltexte.hxx"
#include "xmlexp.hxx"
#include "xmlexpit.hxx"
+#include "zorder.hxx"
#include <comphelper/processfactory.hxx>
#include <docary.hxx>
#include <frameformats.hxx>
@@ -272,11 +273,7 @@ ErrCode SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
// tdf#133487 call this once in flat-ODF case
uno::Reference<drawing::XDrawPageSupplier> const xDPS(GetModel(), uno::UNO_QUERY);
assert(xDPS.is());
- xmloff::FixZOrder(xDPS->getDrawPage(),
- [](uno::Reference<beans::XPropertySet> const& xShape)
- {
- return !*o3tl::doAccess<bool>(xShape->getPropertyValue("Opaque"));
- });
+ xmloff::FixZOrder(xDPS->getDrawPage(), sw::GetZOrderLayer(m_pDoc->getIDocumentDrawModelAccess()));
// now save and switch redline mode
nRedlineFlags = pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
diff --git a/sw/source/filter/xml/zorder.hxx b/sw/source/filter/xml/zorder.hxx
new file mode 100644
index 000000000000..11cf17ef9c5d
--- /dev/null
+++ b/sw/source/filter/xml/zorder.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <IDocumentDrawModelAccess.hxx>
+
+#include <o3tl/any.hxx>
+#include <o3tl/unreachable.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+
+namespace sw
+{
+struct GetZOrderLayer
+{
+ GetZOrderLayer(IDocumentDrawModelAccess const& rIDDMA)
+ : m_nHeavenId(rIDDMA.GetHeavenId().get())
+ , m_nHellId(rIDDMA.GetHellId().get())
+ , m_nControlsId(rIDDMA.GetControlsId().get())
+ , m_nInvisibleHeavenId(rIDDMA.GetInvisibleHeavenId().get())
+ , m_nInvisibleHellId(rIDDMA.GetInvisibleHellId().get())
+ , m_nInvisibleControlsId(rIDDMA.GetInvisibleControlsId().get())
+ {
+ }
+
+ auto operator()(css::uno::Reference<css::beans::XPropertySet> const& xShape) -> unsigned int
+ {
+ sal_Int16 nLayerID(0);
+ if (xShape->getPropertySetInfo()->hasPropertyByName("LayerID"))
+ {
+ xShape->getPropertyValue("LayerID") >>= nLayerID;
+ if (nLayerID == m_nHellId || nLayerID == m_nInvisibleHellId)
+ {
+ return 0;
+ }
+ else if (nLayerID == m_nHeavenId || nLayerID == m_nInvisibleHeavenId)
+ {
+ return 1;
+ }
+ else if (nLayerID == m_nControlsId || nLayerID == m_nInvisibleControlsId)
+ {
+ return 2;
+ }
+ O3TL_UNREACHABLE;
+ }
+ else // SwXFrame only has "Opaque"
+ {
+ if (*o3tl::doAccess<bool>(xShape->getPropertyValue("Opaque")))
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ }
+
+private:
+ sal_Int16 m_nHeavenId;
+ sal_Int16 m_nHellId;
+ sal_Int16 m_nControlsId;
+ sal_Int16 m_nInvisibleHeavenId;
+ sal_Int16 m_nInvisibleHellId;
+ sal_Int16 m_nInvisibleControlsId;
+};
+
+} // namespace sw
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index 823f4dbefb3a..6dea19c1daf6 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -985,7 +985,7 @@ void XMLShapeExport::exportShapes( const uno::Reference < drawing::XShapes >& xS
namespace xmloff {
void FixZOrder(uno::Reference<drawing::XShapes> const& xShapes,
- std::function<bool(uno::Reference<beans::XPropertySet> const&)> const& rIsInBackground)
+ std::function<unsigned int (uno::Reference<beans::XPropertySet> const&)> const& rGetLayer)
{
uno::Reference<drawing::XShapes3> const xShapes3(xShapes, uno::UNO_QUERY);
assert(xShapes3.is());
@@ -993,29 +993,52 @@ void FixZOrder(uno::Reference<drawing::XShapes> const& xShapes,
{
return; // only SvxDrawPage implements this
}
- std::vector<sal_Int32> background;
- std::vector<sal_Int32> foreground;
+ struct Layer { std::vector<sal_Int32> shapes; sal_Int32 nMin = SAL_MAX_INT32; sal_Int32 nMax = 0; };
+ std::vector<Layer> layers;
// shapes are sorted by ZOrder
sal_Int32 const nCount(xShapes->getCount());
for (sal_Int32 i = 0; i < nCount; ++i)
{
uno::Reference<beans::XPropertySet> const xShape(xShapes->getByIndex(i), uno::UNO_QUERY);
- if (rIsInBackground(xShape))
+ unsigned int const nLayer(rGetLayer(xShape));
+ if (layers.size() <= nLayer)
{
- background.emplace_back(i);
+ layers.resize(nLayer + 1);
}
- else
+ layers[nLayer].shapes.emplace_back(i);
+ if (i < layers[nLayer].nMin)
+ {
+ layers[nLayer].nMin = i;
+ }
+ if (layers[nLayer].nMax < i)
+ {
+ layers[nLayer].nMax = i;
+ }
+ }
+ layers.erase(std::remove_if(layers.begin(), layers.end(),
+ [](Layer const& rLayer) { return rLayer.shapes.empty(); }),
+ layers.end());
+ bool isSorted(true);
+ for (size_t i = 1; i < layers.size(); ++i)
+ {
+ assert(layers[i].nMin != layers[i-1].nMax); // unique!
+ if (layers[i].nMin < layers[i-1].nMax)
{
- foreground.emplace_back(i);
+ isSorted = false;
+ break;
}
}
- if (background.empty() || foreground.empty())
+ if (isSorted)
{
return; // nothing to do
}
uno::Sequence<sal_Int32> aNewOrder(nCount);
- std::copy(background.begin(), background.end(), aNewOrder.begin());
- std::copy(foreground.begin(), foreground.end(), aNewOrder.begin() + background.size());
+ auto iterInsert(aNewOrder.begin());
+ for (auto const& rLayer : layers)
+ {
+ assert(rLayer.nMin <= rLayer.nMax); // empty layers have been removed
+ iterInsert = std::copy(rLayer.shapes.begin(), rLayer.shapes.end(), iterInsert);
+ }
try
{
xShapes3->sort(aNewOrder);
More information about the Libreoffice-commits
mailing list