summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2017-08-03 19:58:22 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2017-08-04 02:12:32 +0200
commitc8e3633a352c2fda3aebb9781288a926e7a88c42 (patch)
tree68236e614bf64dd3522c0226806b2e4b3386d3e2 /oox
parent345994dad91765e5356f95786146bf8aca5a4aa3 (diff)
Make ActiveX controls import working again (PPTX / XLSX)
It used to work earlier, but there were an issue with the shape id and so controls were not find. Also in PPTX import the persistStorage attribute was handled only for parent controls and not for other kind of controls. Change-Id: I9784166b65407b79b6dfed8a38087b55b1b69835 Reviewed-on: https://gerrit.libreoffice.org/40751 Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/ole/axcontrolfragment.cxx19
-rw-r--r--oox/source/ppt/slidefragmenthandler.cxx1
-rw-r--r--oox/source/vml/vmldrawing.cxx10
3 files changed, 21 insertions, 9 deletions
diff --git a/oox/source/ole/axcontrolfragment.cxx b/oox/source/ole/axcontrolfragment.cxx
index fb8a4652c01b..351a4bd2aec7 100644
--- a/oox/source/ole/axcontrolfragment.cxx
+++ b/oox/source/ole/axcontrolfragment.cxx
@@ -130,11 +130,30 @@ ContextHandlerRef AxControlFragment::onCreateContext( sal_Int32 nElement, const
Reference< XInputStream > xStrgStrm = getFilter().openInputStream( aFragmentPath );
if( xStrgStrm.is() )
{
+ // Try to import as a parent control
+ bool bImportedAsParent = false;
OleStorage aStorage( getFilter().getComponentContext(), xStrgStrm, false );
BinaryXInputStream aInStrm( aStorage.openInputStream( "f" ), true );
if( !aInStrm.isEof() )
+ {
if( AxContainerModelBase* pModel = dynamic_cast< AxContainerModelBase* >( mrControl.createModelFromGuid( aClassId ) ) )
+ {
pModel->importBinaryModel( aInStrm );
+ bImportedAsParent = true;
+ }
+ }
+ // Import it as a non-parent control
+ if(!bImportedAsParent)
+ {
+ BinaryXInputStream aInStrm2(aStorage.openInputStream("contents"), true);
+ if (!aInStrm2.isEof())
+ {
+ if (ControlModelBase* pModel = mrControl.createModelFromGuid(aClassId))
+ {
+ pModel->importBinaryModel(aInStrm2);
+ }
+ }
+ }
}
}
}
diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx
index 9d6fcf16aa99..3a967eea14ce 100644
--- a/oox/source/ppt/slidefragmenthandler.cxx
+++ b/oox/source/ppt/slidefragmenthandler.cxx
@@ -139,7 +139,6 @@ SlideFragmentHandler::~SlideFragmentHandler()
case PPT_TOKEN( control ):
{
::oox::vml::ControlInfo aInfo;
- aInfo.setShapeId( rAttribs.getInteger( XML_spid, 0 ) );
aInfo.maFragmentPath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) );
aInfo.maName = rAttribs.getXString( XML_name, OUString() );
mpSlidePersistPtr->getDrawing()->registerControl( aInfo );
diff --git a/oox/source/vml/vmldrawing.cxx b/oox/source/vml/vmldrawing.cxx
index 34d798b62d10..6cb8f4dc7ebe 100644
--- a/oox/source/vml/vmldrawing.cxx
+++ b/oox/source/vml/vmldrawing.cxx
@@ -82,11 +82,6 @@ ControlInfo::ControlInfo()
{
}
-void ControlInfo::setShapeId( sal_Int32 nShapeId )
-{
- maShapeId = lclGetShapeId( nShapeId );
-}
-
Drawing::Drawing( XmlFilterBase& rFilter, const Reference< XDrawPage >& rxDrawPage, DrawingType eType ) :
mrFilter( rFilter ),
mxDrawPage( rxDrawPage ),
@@ -129,10 +124,9 @@ void Drawing::registerOleObject( const OleObjectInfo& rOleObject )
void Drawing::registerControl( const ControlInfo& rControl )
{
- OSL_ENSURE( !rControl.maShapeId.isEmpty(), "Drawing::registerControl - missing form control shape id" );
OSL_ENSURE( !rControl.maName.isEmpty(), "Drawing::registerControl - missing form control name" );
- OSL_ENSURE( maControls.count( rControl.maShapeId ) == 0, "Drawing::registerControl - form control already registered" );
- maControls.insert( ControlInfoMap::value_type( rControl.maShapeId, rControl ) );
+ OSL_ENSURE( maControls.count( rControl.maName ) == 0, "Drawing::registerControl - form control already registered" );
+ maControls.insert( ControlInfoMap::value_type( rControl.maName, rControl ) );
}
void Drawing::finalizeFragmentImport()