add SimpleShape::createPictureObject to avoid code duplication
Change-Id: Id4bb0550ab2ce9bbb7edf568a086be18c1576b33
This commit is contained in:
@@ -272,6 +272,10 @@ protected:
|
|||||||
implConvertAndInsert(
|
implConvertAndInsert(
|
||||||
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
|
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
|
||||||
const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
|
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:
|
private:
|
||||||
::rtl::OUString maService; ///< Name of the UNO shape service.
|
::rtl::OUString maService; ///< Name of the UNO shape service.
|
||||||
|
@@ -447,6 +447,36 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
|
|||||||
return xShape;
|
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 ) :
|
RectangleShape::RectangleShape( Drawing& rDrawing ) :
|
||||||
@@ -456,21 +486,11 @@ RectangleShape::RectangleShape( Drawing& rDrawing ) :
|
|||||||
|
|
||||||
Reference<XShape> RectangleShape::implConvertAndInsert(const Reference<XShapes>& rxShapes, const Rectangle& rShapeRect) const
|
Reference<XShape> RectangleShape::implConvertAndInsert(const Reference<XShapes>& rxShapes, const Rectangle& rShapeRect) const
|
||||||
{
|
{
|
||||||
XmlFilterBase& rFilter = mrDrawing.getFilter();
|
|
||||||
OUString aGraphicPath = getGraphicPath();
|
OUString aGraphicPath = getGraphicPath();
|
||||||
|
|
||||||
// try to create a picture object
|
// try to create a picture object
|
||||||
if(!aGraphicPath.isEmpty())
|
if(!aGraphicPath.isEmpty())
|
||||||
{
|
return SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicPath);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// default: try to create a rectangle shape
|
// default: try to create a rectangle shape
|
||||||
return SimpleShape::implConvertAndInsert(rxShapes, rShapeRect);
|
return SimpleShape::implConvertAndInsert(rxShapes, rShapeRect);
|
||||||
@@ -632,33 +652,7 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
|
|||||||
|
|
||||||
// try to create a picture object
|
// try to create a picture object
|
||||||
if( !aGraphicPath.isEmpty() )
|
if( !aGraphicPath.isEmpty() )
|
||||||
{
|
return SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicPath);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// default: try to create a custom shape
|
// default: try to create a custom shape
|
||||||
return CustomShape::implConvertAndInsert( rxShapes, rShapeRect );
|
return CustomShape::implConvertAndInsert( rxShapes, rShapeRect );
|
||||||
|
Reference in New Issue
Block a user