summaryrefslogtreecommitdiff
path: root/oox/source/vml
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2017-08-09 16:06:17 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2017-08-09 19:07:33 +0200
commit4a764319cbad4e2589cc105145ac27defbf49ff6 (patch)
tree9e020cfde1025dea3b1b1fc5839bba27b39ddd8e /oox/source/vml
parent286c27e805c4501451857abff19c23b3719146a3 (diff)
tdf#91384: DOCX: import ActiveX controls
Change-Id: Iebf2ff65fcec3231acfc962fb2f1abc2ed2dc67a Reviewed-on: https://gerrit.libreoffice.org/40930 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'oox/source/vml')
-rw-r--r--oox/source/vml/vmldrawing.cxx1
-rw-r--r--oox/source/vml/vmldrawingfragment.cxx3
-rw-r--r--oox/source/vml/vmlshape.cxx13
-rw-r--r--oox/source/vml/vmlshapecontext.cxx14
4 files changed, 25 insertions, 6 deletions
diff --git a/oox/source/vml/vmldrawing.cxx b/oox/source/vml/vmldrawing.cxx
index 85d6febc73c5..a222af59443c 100644
--- a/oox/source/vml/vmldrawing.cxx
+++ b/oox/source/vml/vmldrawing.cxx
@@ -79,6 +79,7 @@ void OleObjectInfo::setShapeId( sal_Int32 nShapeId )
}
ControlInfo::ControlInfo()
+ : mbTextContentShape(false)
{
}
diff --git a/oox/source/vml/vmldrawingfragment.cxx b/oox/source/vml/vmldrawingfragment.cxx
index c1bed09b73fd..5f7c91f24934 100644
--- a/oox/source/vml/vmldrawingfragment.cxx
+++ b/oox/source/vml/vmldrawingfragment.cxx
@@ -51,7 +51,8 @@ ContextHandlerRef DrawingFragment::onCreateContext( sal_Int32 nElement, const At
{
// DOCX filter handles plain shape elements with this fragment handler
case VMLDRAWING_WORD:
- if ( getNamespace( nElement ) == NMSP_vml )
+ if ( getNamespace( nElement ) == NMSP_vml
+ || nElement == W_TOKEN(control) ) // Control shape also defined as a vml shape
return ShapeContextBase::createShapeContext( *this, mrDrawing.getShapes(), nElement, rAttribs );
break;
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 2d03cb7e38e0..b51a9020393f 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1185,18 +1185,21 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
const ControlInfo* pControlInfo = mrDrawing.getControlInfo( maTypeModel.maShapeId );
if( pControlInfo && !pControlInfo->maFragmentPath.isEmpty() )
{
- OSL_ENSURE( nShapeType == VML_SHAPETYPE_HOSTCONTROL, "ComplexShape::implConvertAndInsert - unexpected shape type" );
- OUString aShapeName = getShapeName();
- if( !aShapeName.isEmpty() )
+ if( !pControlInfo->maName.isEmpty() )
{
- OSL_ENSURE( aShapeName == pControlInfo->maName, "ComplexShape::implConvertAndInsert - control name mismatch" );
// load the control properties from fragment
- ::oox::ole::EmbeddedControl aControl( aShapeName );
+ ::oox::ole::EmbeddedControl aControl(pControlInfo->maName);
if( rFilter.importFragment( new ::oox::ole::AxControlFragment( rFilter, pControlInfo->maFragmentPath, aControl ) ) )
{
// create and return the control shape (including control model)
sal_Int32 nCtrlIndex = -1;
Reference< XShape > xShape = mrDrawing.createAndInsertXControlShape( aControl, rxShapes, rShapeRect, nCtrlIndex );
+
+ if (pControlInfo->mbTextContentShape)
+ {
+ PropertySet aPropertySet(xShape);
+ lcl_SetAnchorType(aPropertySet, maTypeModel, mrDrawing.getFilter().getGraphicHelper());
+ }
// on error, proceed and try to create picture from replacement image
if( xShape.is() )
return xShape;
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index eed6154768a1..f49d0ddfae04 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -262,6 +262,9 @@ ContextHandlerRef ShapeContextBase::createShapeContext( ContextHandler2Helper co
case VML_TOKEN( diagram ):
case VML_TOKEN( image ):
return new ShapeContext( rParent, rShapes.createShape< ComplexShape >(), rAttribs );
+
+ case W_TOKEN(control):
+ return new ControlShapeContext( rParent, rShapes, rAttribs );
}
return nullptr;
}
@@ -556,6 +559,17 @@ ContextHandlerRef RectangleShapeContext::onCreateContext( sal_Int32 nElement, co
return ShapeContext::onCreateContext( nElement, rAttribs );
}
+ControlShapeContext::ControlShapeContext( ::oox::core::ContextHandler2Helper const & rParent, ShapeContainer& rShapes, const AttributeList& rAttribs )
+ : ShapeContextBase (rParent)
+{
+ ::oox::vml::ControlInfo aInfo;
+ aInfo.maShapeId = rAttribs.getXString( W_TOKEN( shapeid ), OUString() );
+ aInfo.maFragmentPath = getFragmentPathFromRelId(rAttribs.getString( R_TOKEN(id), OUString() ));
+ aInfo.maName = rAttribs.getString( W_TOKEN( name ), OUString() );
+ aInfo.mbTextContentShape = true;
+ rShapes.getDrawing().registerControl(aInfo);
+}
+
} // namespace vml
} // namespace oox