summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2022-04-20 18:16:50 +0200
committerRegina Henschel <rb.henschel@t-online.de>2022-04-21 12:53:41 +0200
commit5168d06b1302c43a305d0f670ee65079f21063b5 (patch)
tree4e3007012df4f34d9d68c81b74720a058e64272d /oox
parent8ac35ace9fca1e0d348e5f9c1ee777458661338c (diff)
tdf#109169 export Type encoded shading to OOXML
A shape might have the shading information not in commands in the enhanced-path, but generated in ctor of EnhancedCustomShape2d from the Type value of the shape. This shading information is a 32 bit value with first the number of the shadings and then the shadings. A shading is encoded with 1,2,3,4,5,6,7 for lighten 10 to 70 and 8,9,a,b,c,d,e,f for darken -80 to -10. To get this information from EnhanceCustomShape2d I have made its method GetLuminanceChange() public. Because OOXML only has darken, darkenLess, lighten and lightenLess our values are mapped: -10, -20, -30 to darkenLess -40, -50, -60, -70, -80 to darken 10, 20, 30 to lightenLess 40, 50, 60, 70 to lighten The bupreport mentions only 'Octagon Bevel' and 'Diamond Bevel'. But the patch fixes missing shading for shapes of Types 'ActionButton*' as well. Such shapes come in from MS binary import. Change-Id: I03f19496b915f3ced6346222e8806832b4ee2827 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133220 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'oox')
-rw-r--r--oox/qa/unit/data/tdf109169_OctagonBevel.odtbin0 -> 11122 bytes
-rw-r--r--oox/qa/unit/export.cxx21
-rw-r--r--oox/source/export/drawingml.cxx15
3 files changed, 36 insertions, 0 deletions
diff --git a/oox/qa/unit/data/tdf109169_OctagonBevel.odt b/oox/qa/unit/data/tdf109169_OctagonBevel.odt
new file mode 100644
index 000000000000..2ba39b102e1e
--- /dev/null
+++ b/oox/qa/unit/data/tdf109169_OctagonBevel.odt
Binary files differ
diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx
index 91b8d7608c24..b4eebc537250 100644
--- a/oox/qa/unit/export.cxx
+++ b/oox/qa/unit/export.cxx
@@ -611,6 +611,27 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf100391TextAreaRect)
// The test reflects the state of Apr 2022. It needs to be adapted when export of handles and
// guides is implemented.
}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf109169_OctagonBevel)
+{
+ // The odp file contains an "Octagon Bevel" shape. Such has shading not in commands H,I,J,K
+ // but shading is generated in ctor of EnhancedCustomShape2d from the Type value.
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf109169_OctagonBevel.odt";
+
+ // Export to docx had not written a:fill or a:stroke attributes at all.
+ loadAndSave(aURL, "Office Open XML Text");
+
+ // Verify the markup:
+ std::unique_ptr<SvStream> pStream = parseExportStream(getTempFile(), "word/document.xml");
+ xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get());
+ // File should have six subpaths, one with stroke and five with fill
+ assertXPath(pXmlDoc, "//a:pathLst/a:path[1]", "stroke", "0");
+ assertXPath(pXmlDoc, "//a:pathLst/a:path[2]", "fill", "darkenLess");
+ assertXPath(pXmlDoc, "//a:pathLst/a:path[3]", "fill", "darken");
+ assertXPath(pXmlDoc, "//a:pathLst/a:path[4]", "fill", "darken");
+ assertXPath(pXmlDoc, "//a:pathLst/a:path[5]", "fill", "lightenLess");
+ assertXPath(pXmlDoc, "//a:pathLst/a:path[6]", "fill", "lighten");
+}
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 1d2d601a40f0..327b567c4c40 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -4104,6 +4104,7 @@ bool DrawingML::WriteCustomGeometry(
sal_Int32 nPairIndex = 0; // index over "Coordinates"
sal_Int32 nPathSizeIndex = 0; // index over "SubViewSize"
sal_Int32 nSubpathStartIndex(0); // index over "Segments"
+ sal_Int32 nSubPathIndex(0); // serial number of current subpath
do
{
bool bOK(true); // catch faulty paths were commands do not correspond to points
@@ -4126,6 +4127,19 @@ bool DrawingML::WriteCustomGeometry(
else if (HasCommandInSubPath(LIGHTENLESS, nSubpathStartIndex, nNextNcommandIndex - 1,
aSegments))
sFill = "lightenLess";
+ else
+ {
+ // shading info might be in object type, e.g. "Octagon Bevel".
+ sal_Int32 nLuminanceChange(aCustomShape2d.GetLuminanceChange(nSubPathIndex));
+ if (nLuminanceChange <= -40)
+ sFill = "darken";
+ else if (nLuminanceChange <= -10)
+ sFill = "darkenLess";
+ else if (nLuminanceChange >= 40)
+ sFill = "lighten";
+ else if (nLuminanceChange >= 10)
+ sFill = "lightenLess";
+ }
// NOSTROKE
std::optional<OString> sStroke;
if (HasCommandInSubPath(NOSTROKE, nSubpathStartIndex, nNextNcommandIndex - 1, aSegments))
@@ -4170,6 +4184,7 @@ bool DrawingML::WriteCustomGeometry(
// step forward to next subpath
nSubpathStartIndex = nNextNcommandIndex + 1;
nPathSizeIndex++;
+ nSubPathIndex++;
} while (nSubpathStartIndex < aSegments.getLength());
mpFS->endElementNS(XML_a, XML_pathLst);