summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2017-08-23 16:21:29 +0200
committerAndras Timar <andras.timar@collabora.com>2017-08-25 15:10:57 +0200
commit8170245a9d9b9aeff913e0b3477fc2a9d508af80 (patch)
tree25dd7bbbf1421fb01bcd8e3105c302fdde1bbcc2 /oox
parent813cb3dabe38c5920f26f6c3ce0b32ae19393886 (diff)
tdf#91384: DOCX: import ActiveX controls
Reviewed-on: https://gerrit.libreoffice.org/40930 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> (cherry picked from commit 4a764319cbad4e2589cc105145ac27defbf49ff6) Change-Id: Iebf2ff65fcec3231acfc962fb2f1abc2ed2dc67a Avoid warning in OleHandler Related to ActiveX controls. Change-Id: Ief7ee67ca8e4f086a1d5e0400d0eaf3ebc8cdaaf Reviewed-on: https://gerrit.libreoffice.org/40934 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> (cherry picked from commit 368b583b992f2e9cad46c2362c9529a07c36d7a9) Reviewed-on: https://gerrit.libreoffice.org/41483 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/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 1a7d2e096376..56bf5034376a 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 11d08754c01a..9f9903a04e88 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1171,18 +1171,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 9311351601d5..800ec9ad0582 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -262,6 +262,9 @@ ContextHandlerRef ShapeContextBase::createShapeContext( ContextHandler2Helper& r
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;
}
@@ -554,6 +557,17 @@ ContextHandlerRef RectangleShapeContext::onCreateContext( sal_Int32 nElement, co
return ShapeContext::onCreateContext( nElement, rAttribs );
}
+ControlShapeContext::ControlShapeContext( ::oox::core::ContextHandler2Helper& 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