summaryrefslogtreecommitdiff
path: root/sw/source/filter/xml
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-04-06 18:54:51 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2021-04-07 10:03:15 +0200
commit79ef3c7ae3b2f7be5ba6fe38997e846fd9c7e0ee (patch)
treec36b3f4838cffbcabf628d88f572cc6fa001b0c2 /sw/source/filter/xml
parent795a3ad8efa8b418f3c6477379c13560c3b4b890 (diff)
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@allotropia.de>
Diffstat (limited to 'sw/source/filter/xml')
-rw-r--r--sw/source/filter/xml/wrtxml.cxx7
-rw-r--r--sw/source/filter/xml/xmlexp.cxx7
-rw-r--r--sw/source/filter/xml/zorder.hxx78
3 files changed, 82 insertions, 10 deletions
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: */