summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/oox/export/drawingml.hxx2
-rw-r--r--oox/source/drawingml/shape.cxx3
-rw-r--r--oox/source/export/drawingml.cxx57
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport6.cxx7
4 files changed, 58 insertions, 11 deletions
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 2760d2fe64a0..11bf303e92ff 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -188,6 +188,7 @@ public:
void WriteColor( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT );
void WriteColor( const OUString& sColorSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
+ void WriteColor( const ::Color nColor, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
void WriteColorTransformations( const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
void WriteGradientStop(sal_uInt16 nStop, ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT);
void WriteLineArrow( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, bool bLineStart );
@@ -195,6 +196,7 @@ public:
void WriteSolidFill( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT );
void WriteSolidFill( const OUString& sSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
+ void WriteSolidFill( const ::Color nColor, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
void WriteSolidFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
void WriteGradientFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 90d9e5379dde..02b89312d200 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1279,6 +1279,9 @@ Reference< XShape > const & Shape::createAndInsert(
if( !aLineProperties.maLineFill.maFillColor.isPlaceHolder() && !sLnColorFillScheme.isEmpty() )
{
aProperties.push_back(comphelper::makePropertyValue("SpPrLnSolidFillSchemeClr", sLnColorFillScheme));
+ auto aResolvedSchemeClr = aLineProperties.maLineFill.maFillColor;
+ aResolvedSchemeClr.clearTransformations();
+ aProperties.push_back(comphelper::makePropertyValue("SpPrLnSolidFillResolvedSchemeClr", aResolvedSchemeClr.getColor(rGraphicHelper, nFillPhClr)));
aProperties.push_back(comphelper::makePropertyValue("SpPrLnSolidFillSchemeClrTransformations", aLineProperties.maLineFill.maFillColor.getTransformations()));
}
putPropertiesToGrabBag(comphelper::containerToSequence(aProperties));
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 87e80e4ce12a..8d3cbd23a6a7 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -273,25 +273,35 @@ bool DrawingML::GetPropertyAndState( const Reference< XPropertySet >& rXProperty
return false;
}
-void DrawingML::WriteColor( ::Color nColor, sal_Int32 nAlpha )
+namespace
+{
+/// Gets hexa value of color on string format.
+OString getColorStr(const ::Color nColor)
{
// Transparency is a separate element.
- OString sColor = OString::number( sal_uInt32(nColor) & 0x00FFFFFF, 16 );
- if( sColor.getLength() < 6 )
+ OString sColor = OString::number(sal_uInt32(nColor) & 0x00FFFFFF, 16);
+ if (sColor.getLength() < 6)
{
- OStringBuffer sBuf( "0" );
+ OStringBuffer sBuf("0");
int remains = 5 - sColor.getLength();
- while( remains > 0 )
+ while (remains > 0)
{
- sBuf.append( "0" );
+ sBuf.append("0");
remains--;
}
- sBuf.append( sColor );
+ sBuf.append(sColor);
sColor = sBuf.getStr();
}
+ return sColor;
+}
+}
+
+void DrawingML::WriteColor( ::Color nColor, sal_Int32 nAlpha )
+{
+ const auto sColor = getColorStr(nColor);
if( nAlpha < MAX_PERCENT )
{
mpFS->startElementNS(XML_a, XML_srgbClr, XML_val, sColor);
@@ -329,6 +339,27 @@ void DrawingML::WriteColor( const OUString& sColorSchemeName, const Sequence< Pr
}
}
+void DrawingML::WriteColor( const ::Color nColor, const Sequence< PropertyValue >& aTransformations, sal_Int32 nAlpha )
+{
+ const auto sColor = getColorStr(nColor);
+ if( aTransformations.hasElements() )
+ {
+ mpFS->startElementNS(XML_a, XML_srgbClr, XML_val, sColor);
+ WriteColorTransformations(aTransformations, nAlpha);
+ mpFS->endElementNS(XML_a, XML_srgbClr);
+ }
+ else if(nAlpha < MAX_PERCENT)
+ {
+ mpFS->startElementNS(XML_a, XML_srgbClr, XML_val, sColor);
+ mpFS->singleElementNS(XML_a, XML_alpha, XML_val, OString::number(nAlpha));
+ mpFS->endElementNS(XML_a, XML_srgbClr);
+ }
+ else
+ {
+ mpFS->singleElementNS(XML_a, XML_srgbClr, XML_val, sColor);
+ }
+}
+
void DrawingML::WriteColorTransformations( const Sequence< PropertyValue >& aTransformations, sal_Int32 nAlpha )
{
for( const auto& rTransformation : aTransformations )
@@ -363,6 +394,13 @@ void DrawingML::WriteSolidFill( const OUString& sSchemeName, const Sequence< Pro
mpFS->endElementNS( XML_a, XML_solidFill );
}
+void DrawingML::WriteSolidFill( const ::Color nColor, const Sequence< PropertyValue >& aTransformations, sal_Int32 nAlpha )
+{
+ mpFS->startElementNS(XML_a, XML_solidFill);
+ WriteColor(nColor, aTransformations, nAlpha);
+ mpFS->endElementNS(XML_a, XML_solidFill);
+}
+
void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet )
{
// get fill color
@@ -778,6 +816,7 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet, Referenc
// get InteropGrabBag and search the relevant attributes
OUString sColorFillScheme;
+ ::Color aResolvedColorFillScheme;
::Color nOriginalColor;
::Color nStyleColor;
@@ -798,6 +837,8 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet, Referenc
{
if( rProp.Name == "SpPrLnSolidFillSchemeClr" )
rProp.Value >>= sColorFillScheme;
+ if( rProp.Name == "SpPrLnSolidFillResolvedSchemeClr" )
+ rProp.Value >>= aResolvedColorFillScheme;
else if( rProp.Name == "OriginalLnSolidFillClr" )
rProp.Value >>= nOriginalColor;
else if( rProp.Name == "StyleLnRef" )
@@ -900,7 +941,7 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet, Referenc
else if( !sColorFillScheme.isEmpty() )
{
// the line had a scheme color and the user didn't change it
- WriteSolidFill( sColorFillScheme, aTransformations );
+ WriteSolidFill( aResolvedColorFillScheme, aTransformations );
}
else
{
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index e5bc49ddd189..44d0bc8c27bd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -789,9 +789,10 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testShapeThemePreservation, "shape-theme-pre
assertXPath(pXmlDocument,
"/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:solidFill/a:schemeClr",
"val", "accent6");
+ // check whether theme color has been converted into native color
assertXPath(pXmlDocument,
- "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:solidFill/a:schemeClr",
- "val", "accent3");
+ "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:solidFill/a:srgbClr",
+ "val", "9bbb59");
// check color transformations applied to theme colors have been preserved
assertXPath(pXmlDocument,
@@ -801,7 +802,7 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testShapeThemePreservation, "shape-theme-pre
"/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:solidFill/a:schemeClr/a:lumOff",
"val", "60000");
assertXPath(pXmlDocument,
- "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:solidFill/a:schemeClr/a:lumMod",
+ "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:solidFill/a:srgbClr/a:lumMod",
"val", "50000");
// check direct color assignments have been preserved