[Libreoffice-commits] core.git: include/oox oox/source sw/qa
Grzegorz Araminowicz
g.araminowicz at gmail.com
Fri Jun 9 14:28:31 UTC 2017
include/oox/vml/vmlshape.hxx | 1
oox/source/export/drawingml.cxx | 9 ++---
oox/source/vml/vmlshape.cxx | 37 +++++++++++++++------
oox/source/vml/vmlshapecontext.cxx | 4 +-
sw/qa/extras/ooxmlimport/data/vml-adjustments.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 11 ++++++
6 files changed, 48 insertions(+), 14 deletions(-)
New commits:
commit c8e3fea4996436d1fd608cf5ef0fdc18f5a8fd7f
Author: Grzegorz Araminowicz <g.araminowicz at gmail.com>
Date: Tue Jun 6 08:53:39 2017 +0200
GSoC: import VML shape adjustments
Change-Id: Ifcd49f34b889b34eba2464de6e083f9021633bc6
Reviewed-on: https://gerrit.libreoffice.org/38427
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/include/oox/vml/vmlshape.hxx b/include/oox/vml/vmlshape.hxx
index abb4161ec5cd..44f973b57169 100644
--- a/include/oox/vml/vmlshape.hxx
+++ b/include/oox/vml/vmlshape.hxx
@@ -89,6 +89,7 @@ struct OOX_DLLPUBLIC ShapeTypeModel
OUString maWrapStyle; ///< Wrapping mode for text.
OUString maArcsize; ///< round rectangles arc size
OUString maEditAs; ///< Edit As type (e.g. "canvas" etc)
+ OUString maAdjustments; ///< Shape adjustment values
StrokeModel maStrokeModel; ///< Border line formatting.
FillModel maFillModel; ///< Shape fill formatting.
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 )
diff --git a/sw/qa/extras/ooxmlimport/data/vml-adjustments.docx b/sw/qa/extras/ooxmlimport/data/vml-adjustments.docx
new file mode 100755
index 000000000000..eac08e966c87
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/vml-adjustments.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 4f76f5f321cb..673a2b5861cc 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
#include <com/sun/star/drawing/PointSequenceSequence.hpp>
#include <com/sun/star/drawing/GraphicExportFilter.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
@@ -1290,6 +1291,16 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108408, "tdf108408.docx")
CPPUNIT_ASSERT_EQUAL(double(20), getProperty<double>(xRun, "CharHeight"));
}
+DECLARE_OOXMLIMPORT_TEST(testVmlAdjustments, "vml-adjustments.docx")
+{
+ uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
+ comphelper::SequenceAsHashMap aGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry"));
+ uno::Sequence<drawing::EnhancedCustomShapeAdjustmentValue> aAdjustmentValues =
+ aGeometry["AdjustmentValues"].get<uno::Sequence<drawing::EnhancedCustomShapeAdjustmentValue>>();
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aAdjustmentValues.getLength());
+ drawing::EnhancedCustomShapeAdjustmentValue aAdjustmentValue = *aAdjustmentValues.begin();
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(17639), aAdjustmentValue.Value.get<sal_Int32>());
+}
// tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
More information about the Libreoffice-commits
mailing list