summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorAndras Timar <andras.timar@collabora.com>2015-02-05 22:36:24 +0100
committerAndras Timar <andras.timar@collabora.com>2015-02-06 15:06:02 +0100
commit8cba3c12cb900925dc0aa9b10ef2d3e2a16e9f49 (patch)
treeb5e0a323237cfeffee282a7ec3ff641514c8b4d4 /oox
parent9c1d2558a9ebe0ffd35f633be7c74fc9dc22c96e (diff)
bnc#637947 improve DrawingML export of custom shapes
Reviewed-on: https://gerrit.libreoffice.org/14346 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit b1751e6ed0fd6d6d26141e4405df92520e3c04cd) Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport4.cxx Change-Id: Iaa880528cf3c899ce66e4349c6d989dfbe5cbeb6
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/shapes.cxx113
1 files changed, 109 insertions, 4 deletions
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 0b5a8ef35890..5b2f4eec1914 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -289,12 +289,87 @@ ShapeExport& ShapeExport::WriteGroupShape(uno::Reference<drawing::XShape> xShape
return *this;
}
+static bool lcl_IsOnBlacklist(OUString& rShapeType)
+{
+ OUString aBlacklist[] = {
+ "ring",
+ "can",
+ "cube",
+ "paper",
+ "frame",
+ "smiley",
+ "sun",
+ "flower",
+ "forbidden",
+ "bracket-pair",
+ "brace-pair",
+ "col-60da8460",
+ "col-502ad400",
+ "quad-bevel",
+ "cloud-callout",
+ "line-callout-1",
+ "line-callout-2",
+ "line-callout-3",
+ "paper",
+ "vertical-scroll",
+ "horizontal-scroll",
+ "mso-spt34",
+ "mso-spt75",
+ "mso-spt164",
+ "mso-spt180",
+ "flowchart-process",
+ "flowchart-alternate-process",
+ "flowchart-decision",
+ "flowchart-data",
+ "flowchart-predefined-process",
+ "flowchart-internal-storage",
+ "flowchart-document",
+ "flowchart-multidocument",
+ "flowchart-terminator",
+ "flowchart-preparation",
+ "flowchart-manual-input",
+ "flowchart-manual-operation",
+ "flowchart-connector",
+ "flowchart-off-page-connector",
+ "flowchart-card",
+ "flowchart-punched-tape",
+ "flowchart-summing-junction",
+ "flowchart-or",
+ "flowchart-collate",
+ "flowchart-sort",
+ "flowchart-extract",
+ "flowchart-merge",
+ "flowchart-stored-data",
+ "flowchart-delay",
+ "flowchart-sequential-access",
+ "flowchart-magnetic-disk",
+ "flowchart-direct-access-storage",
+ "flowchart-display"
+ };
+ std::vector<OUString> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist));
+
+ return std::find(vBlacklist.begin(), vBlacklist.end(), rShapeType) != vBlacklist.end();
+}
+
+static bool lcl_IsOnWhitelist(OUString& rShapeType)
+{
+ OUString aWhitelist[] = {
+ "heart",
+ "puzzle"
+ };
+ std::vector<OUString> vWhitelist(aWhitelist, aWhitelist + SAL_N_ELEMENTS(aWhitelist));
+
+ return std::find(vWhitelist.begin(), vWhitelist.end(), rShapeType) != vWhitelist.end();
+}
+
+
ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
{
DBG(fprintf(stderr, "write custom shape\n"));
Reference< XPropertySet > rXPropSet( xShape, UNO_QUERY );
bool bPredefinedHandlesUsed = true;
+ bool bHasHandles = false;
OUString sShapeType;
sal_uInt32 nMirrorFlags = 0;
MSO_SPT eShapeType = EscherPropertyContainer::GetCustomShapeType( xShape, nMirrorFlags, sShapeType );
@@ -325,6 +400,7 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
if ( rProp.Name == "AdjustmentValues" )
nAdjustmentValuesIndex = i;
else if ( rProp.Name == "Handles" ) {
+ bHasHandles = true;
if( !bIsDefaultObject )
bPredefinedHandlesUsed = false;
// TODO: update nAdjustmentsWhichNeedsToBeConverted here
@@ -353,11 +429,40 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
// visual shape properties
pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
- WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV, false);
-
- if( sShapeType == "ooxml-non-primitive" ) // non-primitiv -> custom geometry
+ // moon is flipped in MSO, and mso-spt89 (right up arrow) is mapped to leftUpArrow
+ if ( sShapeType == "moon" || sShapeType == "mso-spt89" )
+ WriteShapeTransformation( xShape, XML_a, !bFlipH, bFlipV, false);
+ else
+ WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV, false);
+
+ // we export non-primitive shapes to custom geometry
+ // we also export non-ooxml shapes which have handles/equations to custom geometry, because
+ // we cannot convert ODF equations to DrawingML equations. TODO: see what binary DOC export filter does.
+ // but our WritePolyPolygon() function is incomplete, therefore we use a blacklist
+ // we use a whitelist for shapes where mapping to MSO preset shape is not optimal
+ bool bCustGeom = true;
+ if( sShapeType == "ooxml-non-primitive" )
+ bCustGeom = true;
+ else if( sShapeType.startsWith("ooxml") )
+ bCustGeom = false;
+ else if( lcl_IsOnWhitelist(sShapeType) )
+ bCustGeom = true;
+ else if( lcl_IsOnBlacklist(sShapeType) )
+ bCustGeom = false;
+ else if( bHasHandles )
+ bCustGeom = true;
+
+ if( bCustGeom )
{
- WritePolyPolygon( EscherPropertyContainer::GetPolyPolygon( xShape ) );
+ basegfx::B2DPolyPolygon aB2DPolyPolygon = SdrObjCustomShape::GetLineGeometry(pShape, true);
+ PolyPolygon aPolyPolygon;
+ for( sal_uInt32 i = 0; i < aB2DPolyPolygon.count(); ++i )
+ {
+ basegfx::B2DPolygon aB2DPolygon = aB2DPolyPolygon.getB2DPolygon(i);
+ aPolyPolygon.Insert( Polygon( aB2DPolygon ), POLYPOLY_APPEND );
+ }
+
+ WritePolyPolygon( aPolyPolygon );
}
else // preset geometry
{