summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorGrzegorz Araminowicz <g.araminowicz@gmail.com>2017-06-06 08:53:39 +0200
committerJan Holesovsky <kendy@collabora.com>2017-06-09 16:28:11 +0200
commitc8e3fea4996436d1fd608cf5ef0fdc18f5a8fd7f (patch)
tree4a29ae2713515c47afa87a3b2b64445e6a5099f2 /oox
parent9614f12bae668dfe848ae6cc0bac091be106fa8e (diff)
GSoC: import VML shape adjustments
Change-Id: Ifcd49f34b889b34eba2464de6e083f9021633bc6 Reviewed-on: https://gerrit.libreoffice.org/38427 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/drawingml.cxx9
-rw-r--r--oox/source/vml/vmlshape.cxx37
-rw-r--r--oox/source/vml/vmlshapecontext.cxx4
3 files changed, 36 insertions, 14 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index f1995e90b3a7..6270b30b8b2d 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2351,16 +2351,17 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool b
EscherPropertyContainer::LookForPolarHandles( eShapeType, nAdjustmentsWhichNeedsToBeConverted );
sal_Int32 nValue, nLength = aAdjustmentSeq.getLength();
- //aAdjustments will give info about the number of adj values for a particular geometry. For example for hexagon aAdjustments.size() will be 2 and for circular arrow it will be 5 as per lcl_getAdjNames.
- if(aAdjustments.size() == static_cast<sal_uInt32>(nLength))// In case there is a mismatch do not write the XML_gd tag.
+ // aAdjustments will give info about the number of adj values for a particular geometry. For example for hexagon aAdjustments.size() will be 2 and for circular arrow it will be 5 as per lcl_getAdjNames.
+ // Sometimes there are more values than needed, so we ignore the excessive ones.
+ if (aAdjustments.size() <= static_cast<sal_uInt32>(nLength))
{
- for( sal_Int32 i=0; i < nLength; i++ )
+ for (sal_Int32 i = 0; i < static_cast<sal_Int32>(aAdjustments.size()); i++)
{
if( EscherPropertyContainer::GetAdjustmentValue( aAdjustmentSeq[ i ], i, nAdjustmentsWhichNeedsToBeConverted, nValue ) )
{
// If the document model doesn't have an adjustment name (e.g. shape was created from VML), then take it from the predefined list.
OString aAdjName;
- if (static_cast<sal_uInt32>(i) < aAdjustments.size() && aAdjustmentSeq[i].Name.isEmpty())
+ if (aAdjustmentSeq[i].Name.isEmpty())
aAdjName = aAdjustments[i];
mpFS->singleElementNS( XML_a, XML_gd,
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 8d85b14701fb..b90bddafb7ef 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -789,25 +789,44 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
}
}
+ // custom shape geometry attributes
+ std::vector<css::beans::PropertyValue> aPropVec;
+
// When flip has 'x' or 'y', the associated ShapeRect will be changed but direction change doesn't occur.
// It might occur internally in SdrObject of "sw" module, not here.
// The associated properties "PROP_MirroredX" and "PROP_MirroredY" have to be set here so that direction change will occur internally.
if (bFlipX || bFlipY)
{
assert(!(bFlipX && bFlipY));
- css::uno::Sequence< css::beans::PropertyValue > aPropSequence (1);
+ css::beans::PropertyValue aProp;
if (bFlipX)
- {
- aPropSequence [0].Name = "MirroredX";
- aPropSequence [0].Value <<= bFlipX;
- }
+ aProp.Name = "MirroredX";
else
+ aProp.Name = "MirroredY";
+ aProp.Value <<= true;
+ aPropVec.push_back(aProp);
+ }
+
+ if (!maTypeModel.maAdjustments.isEmpty())
+ {
+ std::vector<drawing::EnhancedCustomShapeAdjustmentValue> aAdjustmentValues;
+ sal_Int32 nIndex = 0;
+ do
{
- aPropSequence [0].Name = "MirroredY";
- aPropSequence [0].Value <<= bFlipY;
- }
- aPropertySet.setAnyProperty(PROP_CustomShapeGeometry, makeAny( aPropSequence ) );
+ OUString aToken = maTypeModel.maAdjustments.getToken(0, ',', nIndex);
+ drawing::EnhancedCustomShapeAdjustmentValue aAdjustmentValue;
+ aAdjustmentValue.Value <<= aToken.toInt32();
+ aAdjustmentValues.push_back(aAdjustmentValue);
+ } while (nIndex >= 0);
+
+ css::beans::PropertyValue aProp;
+ aProp.Name = "AdjustmentValues";
+ aProp.Value <<= comphelper::containerToSequence(aAdjustmentValues);
+ aPropVec.push_back(aProp);
}
+
+ if (!aPropVec.empty())
+ aPropertySet.setAnyProperty(PROP_CustomShapeGeometry, makeAny(comphelper::containerToSequence(aPropVec)));
}
lcl_SetAnchorType(aPropertySet, maTypeModel, rGraphicHelper );
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index 02cf06e51429..7e9f2463157f 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -312,9 +312,11 @@ ShapeTypeContext::ShapeTypeContext( ContextHandler2Helper& rParent, ShapeType& r
mrTypeModel.maFillModel.moColor = rAttribs.getString( XML_fillcolor );
// For roundrect we may have a arcsize attribute to read
- mrTypeModel.maArcsize = rAttribs.getString( XML_arcsize,OUString( ) );
+ mrTypeModel.maArcsize = rAttribs.getString(XML_arcsize, OUString());
// editas
mrTypeModel.maEditAs = rAttribs.getString(XML_editas, OUString());
+
+ mrTypeModel.maAdjustments = rAttribs.getString(XML_adj, OUString());
}
ContextHandlerRef ShapeTypeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )