diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-08-29 09:25:40 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-08-29 09:26:14 +0200 |
commit | 7fe05dc95d0c9a584e07483c04b13c071d55293f (patch) | |
tree | 0dfc2daab7db98db5d42c34c90a0edbb7ff51119 /oox | |
parent | n#777345 import imagedata of v:rect elements inside OLE objects (diff) | |
download | core-7fe05dc95d0c9a584e07483c04b13c071d55293f.tar.gz core-7fe05dc95d0c9a584e07483c04b13c071d55293f.zip |
add SimpleShape::createPictureObject to avoid code duplication
Change-Id: Id4bb0550ab2ce9bbb7edf568a086be18c1576b33
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/vml/vmlshape.hxx | 4 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 70 |
2 files changed, 36 insertions, 38 deletions
diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index 728ca15e83b0..8fab5f7ec92d 100644 --- a/oox/inc/oox/vml/vmlshape.hxx +++ b/oox/inc/oox/vml/vmlshape.hxx @@ -272,6 +272,10 @@ protected: implConvertAndInsert( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, const ::com::sun::star::awt::Rectangle& rShapeRect ) const; + /** Used by both RectangleShape and ComplexShape. */ + com::sun::star::uno::Reference<com::sun::star::drawing::XShape>createPictureObject( + const com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rxShapes, + const com::sun::star::awt::Rectangle& rShapeRect, OUString& rGraphicPath ) const; private: ::rtl::OUString maService; ///< Name of the UNO shape service. diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 5c8e728e55f2..a32030b0fe23 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -447,6 +447,36 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes return xShape; } +Reference< XShape > SimpleShape::createPictureObject( const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect, OUString& rGraphicPath ) const +{ + Reference< XShape > xShape = mrDrawing.createAndInsertXShape( "com.sun.star.drawing.GraphicObjectShape", rxShapes, rShapeRect ); + if( xShape.is() ) + { + XmlFilterBase& rFilter = mrDrawing.getFilter(); + OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject( rGraphicPath ); + PropertySet aPropSet( xShape ); + if( !aGraphicUrl.isEmpty() ) + { + aPropSet.setProperty( PROP_GraphicURL, aGraphicUrl ); + } + // If the shape has an absolute position, set the properties accordingly. + if ( maTypeModel.maPosition == "absolute" ) + { + aPropSet.setProperty(PROP_HoriOrientPosition, rShapeRect.X); + aPropSet.setProperty(PROP_VertOrientPosition, rShapeRect.Y); + aPropSet.setProperty(PROP_Opaque, sal_False); + } + + lcl_SetAnchorType(aPropSet, maTypeModel); + + if ( maTypeModel.maPositionVerticalRelative == "page" ) + { + aPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_FRAME); + } + } + return xShape; +} + // ============================================================================ RectangleShape::RectangleShape( Drawing& rDrawing ) : @@ -456,21 +486,11 @@ RectangleShape::RectangleShape( Drawing& rDrawing ) : Reference<XShape> RectangleShape::implConvertAndInsert(const Reference<XShapes>& rxShapes, const Rectangle& rShapeRect) const { - XmlFilterBase& rFilter = mrDrawing.getFilter(); OUString aGraphicPath = getGraphicPath(); // try to create a picture object if(!aGraphicPath.isEmpty()) - { - Reference<XShape> xShape = mrDrawing.createAndInsertXShape("com.sun.star.drawing.GraphicObjectShape", rxShapes, rShapeRect); - if (xShape.is()) - { - OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject(aGraphicPath); - PropertySet aPropSet(xShape); - aPropSet.setProperty(PROP_GraphicURL, aGraphicUrl); - } - return xShape; - } + return SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicPath); // default: try to create a rectangle shape return SimpleShape::implConvertAndInsert(rxShapes, rShapeRect); @@ -632,33 +652,7 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes // try to create a picture object if( !aGraphicPath.isEmpty() ) - { - Reference< XShape > xShape = mrDrawing.createAndInsertXShape( CREATE_OUSTRING( "com.sun.star.drawing.GraphicObjectShape" ), rxShapes, rShapeRect ); - if( xShape.is() ) - { - OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject( aGraphicPath ); - PropertySet aPropSet( xShape ); - if( !aGraphicUrl.isEmpty() ) - { - aPropSet.setProperty( PROP_GraphicURL, aGraphicUrl ); - } - // If the shape has an absolute position, set the properties accordingly. - if ( maTypeModel.maPosition == "absolute" ) - { - aPropSet.setProperty(PROP_HoriOrientPosition, rShapeRect.X); - aPropSet.setProperty(PROP_VertOrientPosition, rShapeRect.Y); - aPropSet.setProperty(PROP_Opaque, sal_False); - } - - lcl_SetAnchorType(aPropSet, maTypeModel); - - if ( maTypeModel.maPositionVerticalRelative == "page" ) - { - aPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_FRAME); - } - } - return xShape; - } + return SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicPath); // default: try to create a custom shape return CustomShape::implConvertAndInsert( rxShapes, rShapeRect ); |