summaryrefslogtreecommitdiffstats
path: root/oox
diff options
context:
space:
mode:
authorRegényi Balázs <regenyi.balazs@nisz.hu>2020-09-15 11:38:18 +0200
committerLászló Németh <nemeth@numbertext.org>2020-09-23 12:06:16 +0200
commitce405819f36496398e5ca389f12eafb3cfdc64ae (patch)
treedbfd3022c14605a498693e04039cbdd231f4558e /oox
parentRemoved duplicated include (diff)
downloadcore-ce405819f36496398e5ca389f12eafb3cfdc64ae.tar.gz
core-ce405819f36496398e5ca389f12eafb3cfdc64ae.zip
tdf#136566 XLSX export: fix lost scheme based line colors
by converting scheme color identifiers to colors temporarily. Because we haven't exported theme XML yet, we could not import shapes of these exported documents correctly, resulting missing lines. Co-authored-by: Szabolcs Toth Change-Id: I4f3d19cb8a9a851fb07a97f798195011e420d441 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102722 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/shape.cxx3
-rw-r--r--oox/source/export/drawingml.cxx57
2 files changed, 52 insertions, 8 deletions
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
{