summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svx/EnhancedCustomShape2d.hxx2
-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
4 files changed, 37 insertions, 1 deletions
diff --git a/include/svx/EnhancedCustomShape2d.hxx b/include/svx/EnhancedCustomShape2d.hxx
index 18ce21437bcc..abe9319407ff 100644
--- a/include/svx/EnhancedCustomShape2d.hxx
+++ b/include/svx/EnhancedCustomShape2d.hxx
@@ -127,7 +127,6 @@ class SVXCORE_DLLPUBLIC EnhancedCustomShape2d final : public SfxItemSet
Degree100 nRotateAngle;
SAL_DLLPRIVATE bool SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex );
- SAL_DLLPRIVATE sal_Int32 GetLuminanceChange( sal_uInt32 nIndex ) const;
SAL_DLLPRIVATE Color GetColorData( const Color& rFillColor, sal_uInt32 nIndex, double dBrightness ) const;
SAL_DLLPRIVATE void AdaptObjColor(
SdrPathObj& rObj,
@@ -183,6 +182,7 @@ class SVXCORE_DLLPUBLIC EnhancedCustomShape2d final : public SfxItemSet
}
};
+ sal_Int32 GetLuminanceChange( sal_uInt32 nIndex ) const;
SAL_DLLPRIVATE bool IsFlipVert() const { return bFlipV; };
SAL_DLLPRIVATE bool IsFlipHorz() const { return bFlipH; };
SAL_DLLPRIVATE Degree100 GetRotateAngle() const { return nRotateAngle; };
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 26d1a0e973bb..62988f7fd3bf 100644
--- a/oox/qa/unit/export.cxx
+++ b/oox/qa/unit/export.cxx
@@ -530,6 +530,27 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf147978_subpath)
assertXPath(pXmlDoc, "//a:pathLst/a:path[4]", "h", "80");
}
+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_TEST_FIXTURE(Test, testFaultyPathCommandsAWT)
{
// The odp file contains shapes whose path starts with command A, W, T or L. That is a faulty
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index c2bdf39042a4..2a11fa507959 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3898,6 +3898,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
@@ -3920,6 +3921,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))
@@ -3964,6 +3978,7 @@ bool DrawingML::WriteCustomGeometry(
// step forward to next subpath
nSubpathStartIndex = nNextNcommandIndex + 1;
nPathSizeIndex++;
+ nSubPathIndex++;
} while (nSubpathStartIndex < aSegments.getLength());
mpFS->endElementNS(XML_a, XML_pathLst);