summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2017-09-22 16:02:00 +0200
committerAndras Timar <andras.timar@collabora.com>2017-09-23 13:37:14 +0200
commitcc591266f86e5d37aa5aa2e365ab80348b189b43 (patch)
tree965a10e2c361072b50ef22ecf7372fb2dbf0e925 /oox
parenteb5e45782b0e805455d383e9d020aae5bb70d619 (diff)
tdf#112552: Shape's gray background is lost after saving to PPTX
Reviewed-on: https://gerrit.libreoffice.org/42598 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> (cherry picked from commit 31919b8909fa7b34412dd52c3d4dff17bc5b6fab) Change-Id: I30f371ad301eede82ddcece4d91ffcd32e164115 Reviewed-on: https://gerrit.libreoffice.org/42649 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/drawingml.cxx89
-rw-r--r--oox/source/export/shapes.cxx2
2 files changed, 43 insertions, 48 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 3e9cc01e9ed7..2ae26e251d60 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -94,6 +94,7 @@
#include <svx/svdomedia.hxx>
#include <svx/unoapi.hxx>
#include <svx/unoshape.hxx>
+#include <svx/EnhancedCustomShape2d.hxx>
using namespace ::css;
using namespace ::css::beans;
@@ -2472,7 +2473,7 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool b
mpFS->endElementNS( XML_a, XML_prstGeom );
}
-bool DrawingML::WriteCustomGeometry( const Reference< XShape >& rXShape )
+bool DrawingML::WriteCustomGeometry( const Reference< XShape >& rXShape, const SdrObjCustomShape* pShape )
{
uno::Reference< beans::XPropertySet > aXPropSet;
uno::Any aAny( rXShape->queryInterface(cppu::UnoType<beans::XPropertySet>::get()));
@@ -2572,15 +2573,16 @@ bool DrawingML::WriteCustomGeometry( const Reference< XShape >& rXShape )
for ( int j = 0; j < aPairs.getLength(); ++j )
{
- sal_Int32 nCandidate(0);
- if ((aPairs[j].First.Value >>= nCandidate) && nCandidate < nXMin)
- nXMin = nCandidate;
- if ((aPairs[j].Second.Value >>= nCandidate) && nCandidate < nYMin)
- nYMin = nCandidate;
- if ((aPairs[j].First.Value >>= nCandidate) && nCandidate > nXMax)
- nXMax = nCandidate;
- if ((aPairs[j].Second.Value >>= nCandidate) && nCandidate > nYMax)
- nYMax = nCandidate;
+ sal_Int32 nX = GetCustomGeometryPointValue(aPairs[j].First, pShape);
+ sal_Int32 nY = GetCustomGeometryPointValue(aPairs[j].Second, pShape);
+ if (nX < nXMin)
+ nXMin = nX;
+ if (nY < nYMin)
+ nYMin = nY;
+ if (nX > nXMax)
+ nXMax = nX;
+ if (nY > nYMax)
+ nYMax = nY;
}
mpFS->startElementNS( XML_a, XML_path,
XML_w, I64S( nXMax - nXMin ),
@@ -2603,16 +2605,7 @@ bool DrawingML::WriteCustomGeometry( const Reference< XShape >& rXShape )
case drawing::EnhancedCustomShapeSegmentCommand::MOVETO :
{
mpFS->startElementNS( XML_a, XML_moveTo, FSEND );
-
- sal_Int32 nX(0), nY(0);
- aPairs[nPairIndex].First.Value >>= nX;
- aPairs[nPairIndex].Second.Value >>= nY;
-
- mpFS->singleElementNS( XML_a, XML_pt,
- XML_x, I64S(nX),
- XML_y, I64S(nY),
- FSEND );
-
+ WriteCustomGeometryPoint(aPairs[nPairIndex], pShape);
mpFS->endElementNS( XML_a, XML_moveTo );
nPairIndex++;
break;
@@ -2620,15 +2613,7 @@ bool DrawingML::WriteCustomGeometry( const Reference< XShape >& rXShape )
case drawing::EnhancedCustomShapeSegmentCommand::LINETO :
{
mpFS->startElementNS( XML_a, XML_lnTo, FSEND );
-
- sal_Int32 nX(0), nY(0);
- aPairs[nPairIndex].First.Value >>= nX;
- aPairs[nPairIndex].Second.Value >>= nY;
-
- mpFS->singleElementNS( XML_a, XML_pt,
- XML_x, I64S(nX),
- XML_y, I64S(nY),
- FSEND );
+ WriteCustomGeometryPoint(aPairs[nPairIndex], pShape);
mpFS->endElementNS( XML_a, XML_lnTo );
nPairIndex++;
break;
@@ -2638,15 +2623,7 @@ bool DrawingML::WriteCustomGeometry( const Reference< XShape >& rXShape )
mpFS->startElementNS( XML_a, XML_cubicBezTo, FSEND );
for( sal_uInt8 l = 0; l <= 2; ++l )
{
- sal_Int32 nX(0), nY(0);
- aPairs[nPairIndex+l].First.Value >>= nX;
- aPairs[nPairIndex+l].Second.Value >>= nY;
-
- mpFS->singleElementNS( XML_a, XML_pt,
- XML_x, I64S( nX ),
- XML_y, I64S( nY ),
- FSEND );
-
+ WriteCustomGeometryPoint(aPairs[nPairIndex+l], pShape);
}
mpFS->endElementNS( XML_a, XML_cubicBezTo );
nPairIndex += 3;
@@ -2677,15 +2654,7 @@ bool DrawingML::WriteCustomGeometry( const Reference< XShape >& rXShape )
mpFS->startElementNS( XML_a, XML_quadBezTo, FSEND );
for( sal_uInt8 l = 0; l < 2; ++l )
{
- sal_Int32 nX(0), nY(0);
- aPairs[nPairIndex+l].First.Value >>= nX;
- aPairs[nPairIndex+l].Second.Value >>= nY;
-
- mpFS->singleElementNS( XML_a, XML_pt,
- XML_x, I64S( nX ),
- XML_y, I64S( nY ),
- FSEND );
-
+ WriteCustomGeometryPoint(aPairs[nPairIndex+l], pShape);
}
mpFS->endElementNS( XML_a, XML_quadBezTo );
nPairIndex += 2;
@@ -2712,6 +2681,32 @@ bool DrawingML::WriteCustomGeometry( const Reference< XShape >& rXShape )
return false;
}
+void DrawingML::WriteCustomGeometryPoint(const drawing::EnhancedCustomShapeParameterPair& rParamPair, const SdrObjCustomShape* pShape)
+{
+ sal_Int32 nX = GetCustomGeometryPointValue(rParamPair.First, pShape);
+ sal_Int32 nY = GetCustomGeometryPointValue(rParamPair.Second, pShape);
+
+ mpFS->singleElementNS( XML_a, XML_pt,
+ XML_x, OString::number(nX).getStr(),
+ XML_y, OString::number(nY).getStr(),
+ FSEND );
+}
+
+sal_Int32 DrawingML::GetCustomGeometryPointValue(const css::drawing::EnhancedCustomShapeParameter& rParam, const SdrObjCustomShape* pShape)
+{
+ sal_Int32 nValue = 0;
+ if(pShape)
+ {
+ const EnhancedCustomShape2d aCustoShape2d (const_cast<SdrObjCustomShape*>(pShape));
+ double fValue = 0.0;
+ aCustoShape2d.GetParameter(fValue, rParam, false, false);
+ nValue = std::lround(fValue);
+ }
+ else
+ rParam.Value >>= nValue;
+ return nValue;
+}
+
void DrawingML::WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon )
{
// In case of Writer, the parent element is <wps:spPr>, and there the
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 767328311a69..c9661684535e 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -866,7 +866,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
else if (bCustGeom)
{
WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV );
- bool bSuccess = WriteCustomGeometry( xShape );
+ bool bSuccess = WriteCustomGeometry( xShape, pShape );
if (!bSuccess)
WritePresetShape( sPresetShape );
}