Kaydet (Commit) cfc2715f authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

Use "Graphic" instead of "GraphicURL" property for SimpleShape

We don't need to create an URL when we get the XGraphic from the
signatures, that use SimpleShape. We can just use the XGraphic
directly and set the "Graphic" property on creation of
SimpleShape.

Change-Id: I82b1f76cd358fca29f5b9dfbed0e735bd1f38e15
Reviewed-on: https://gerrit.libreoffice.org/50141Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst e2d0945c
...@@ -35,6 +35,7 @@ namespace com { namespace sun { namespace star { ...@@ -35,6 +35,7 @@ namespace com { namespace sun { namespace star {
namespace awt { struct Rectangle; } namespace awt { struct Rectangle; }
namespace drawing { class XShape; } namespace drawing { class XShape; }
namespace drawing { class XShapes; } namespace drawing { class XShapes; }
namespace graphic { class XGraphic; }
} } } } } }
namespace oox { namespace oox {
...@@ -304,9 +305,11 @@ protected: ...@@ -304,9 +305,11 @@ protected:
css::uno::Reference<css::drawing::XShape>createEmbeddedPictureObject( css::uno::Reference<css::drawing::XShape>createEmbeddedPictureObject(
const css::uno::Reference< css::drawing::XShapes >& rxShapes, const css::uno::Reference< css::drawing::XShapes >& rxShapes,
const css::awt::Rectangle& rShapeRect, OUString const & rGraphicPath ) const; const css::awt::Rectangle& rShapeRect, OUString const & rGraphicPath ) const;
css::uno::Reference<css::drawing::XShape>createPictureObject( css::uno::Reference<css::drawing::XShape>createPictureObject(
const css::uno::Reference< css::drawing::XShapes >& rxShapes, const css::uno::Reference< css::drawing::XShapes >& rxShapes,
const css::awt::Rectangle& rShapeRect, OUString const & rGraphicUrl ) const; const css::awt::Rectangle& rShapeRect,
css::uno::Reference<css::graphic::XGraphic> const & rxGraphic) const;
private: private:
OUString maService; ///< Name of the UNO shape service. OUString maService; ///< Name of the UNO shape service.
......
...@@ -863,21 +863,21 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes ...@@ -863,21 +863,21 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
Reference< XShape > SimpleShape::createEmbeddedPictureObject( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect, OUString const & rGraphicPath ) const Reference< XShape > SimpleShape::createEmbeddedPictureObject( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect, OUString const & rGraphicPath ) const
{ {
XmlFilterBase& rFilter = mrDrawing.getFilter(); Reference<XGraphic> xGraphic = mrDrawing.getFilter().getGraphicHelper().importEmbeddedGraphic(rGraphicPath);
OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject( rGraphicPath ); return SimpleShape::createPictureObject(rxShapes, rShapeRect, xGraphic);
return SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicUrl);
} }
Reference< XShape > SimpleShape::createPictureObject( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect, OUString const & rGraphicUrl ) const Reference< XShape > SimpleShape::createPictureObject(const Reference< XShapes >& rxShapes,
const awt::Rectangle& rShapeRect,
uno::Reference<graphic::XGraphic> const & rxGraphic) const
{ {
Reference< XShape > xShape = mrDrawing.createAndInsertXShape( "com.sun.star.drawing.GraphicObjectShape", rxShapes, rShapeRect ); Reference< XShape > xShape = mrDrawing.createAndInsertXShape( "com.sun.star.drawing.GraphicObjectShape", rxShapes, rShapeRect );
if( xShape.is() ) if( xShape.is() )
{ {
PropertySet aPropSet(xShape);
PropertySet aPropSet( xShape ); if (rxGraphic.is())
if( !rGraphicUrl.isEmpty() )
{ {
aPropSet.setProperty( PROP_GraphicURL, rGraphicUrl ); aPropSet.setProperty(PROP_Graphic, rxGraphic);
} }
uno::Reference< lang::XServiceInfo > xServiceInfo(rxShapes, uno::UNO_QUERY); uno::Reference< lang::XServiceInfo > xServiceInfo(rxShapes, uno::UNO_QUERY);
// If the shape has an absolute position, set the properties accordingly, unless we're inside a group shape. // If the shape has an absolute position, set the properties accordingly, unless we're inside a group shape.
...@@ -897,9 +897,7 @@ Reference< XShape > SimpleShape::createPictureObject( const Reference< XShapes > ...@@ -897,9 +897,7 @@ Reference< XShape > SimpleShape::createPictureObject( const Reference< XShapes >
if (maTypeModel.moCropBottom.has() || maTypeModel.moCropLeft.has() || maTypeModel.moCropRight.has() || maTypeModel.moCropTop.has()) if (maTypeModel.moCropBottom.has() || maTypeModel.moCropLeft.has() || maTypeModel.moCropRight.has() || maTypeModel.moCropTop.has())
{ {
text::GraphicCrop aGraphicCrop; text::GraphicCrop aGraphicCrop;
uno::Reference<graphic::XGraphic> xGraphic; awt::Size aOriginalSize = rGraphicHelper.getOriginalSize(rxGraphic);
aPropSet.getProperty(xGraphic, PROP_Graphic);
awt::Size aOriginalSize = rGraphicHelper.getOriginalSize(xGraphic);
if (maTypeModel.moCropBottom.has()) if (maTypeModel.moCropBottom.has())
aGraphicCrop.Bottom = lclConvertCrop(maTypeModel.moCropBottom.get(), aOriginalSize.Height); aGraphicCrop.Bottom = lclConvertCrop(maTypeModel.moCropBottom.get(), aOriginalSize.Height);
...@@ -1249,7 +1247,7 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes ...@@ -1249,7 +1247,7 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
if( getShapeModel().mbIsSignatureLine ) if( getShapeModel().mbIsSignatureLine )
{ {
OUString aGraphicUrl; uno::Reference<graphic::XGraphic> xGraphic;
try try
{ {
// Get the document signatures // Get the document signatures
...@@ -1278,16 +1276,14 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes ...@@ -1278,16 +1276,14 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
// Signature is valid, use the 'valid' image // Signature is valid, use the 'valid' image
SAL_WARN_IF(!xSignatureInfo[i].ValidSignatureLineImage.is(), "oox.vml", SAL_WARN_IF(!xSignatureInfo[i].ValidSignatureLineImage.is(), "oox.vml",
"No ValidSignatureLineImage!"); "No ValidSignatureLineImage!");
aGraphicUrl = rFilter.getGraphicHelper().createGraphicObject( xGraphic = xSignatureInfo[i].ValidSignatureLineImage;
xSignatureInfo[i].ValidSignatureLineImage);
} }
else else
{ {
// Signature is invalid, use the 'invalid' image // Signature is invalid, use the 'invalid' image
SAL_WARN_IF(!xSignatureInfo[i].InvalidSignatureLineImage.is(), "oox.vml", SAL_WARN_IF(!xSignatureInfo[i].InvalidSignatureLineImage.is(), "oox.vml",
"No InvalidSignatureLineImage!"); "No InvalidSignatureLineImage!");
aGraphicUrl = rFilter.getGraphicHelper().createGraphicObject( xGraphic = xSignatureInfo[i].InvalidSignatureLineImage;
xSignatureInfo[i].InvalidSignatureLineImage);
} }
break; break;
} }
...@@ -1300,10 +1296,10 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes ...@@ -1300,10 +1296,10 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
} }
Reference< XShape > xShape; Reference< XShape > xShape;
if (!aGraphicUrl.isEmpty()) if (xGraphic.is())
{ {
// If available, use the signed image from the signature // If available, use the signed image from the signature
xShape = SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicUrl); xShape = SimpleShape::createPictureObject(rxShapes, rShapeRect, xGraphic);
} }
else else
{ {
...@@ -1337,10 +1333,8 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes ...@@ -1337,10 +1333,8 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
if (!aGraphicPath.isEmpty()) if (!aGraphicPath.isEmpty())
{ {
Reference< XGraphic > xGraphic xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic(aGraphicPath);
= rFilter.getGraphicHelper().importEmbeddedGraphic(aGraphicPath); xPropertySet->setPropertyValue("SignatureLineUnsignedImage", uno::makeAny(xGraphic));
xPropertySet->setPropertyValue("SignatureLineUnsignedImage",
uno::makeAny(xGraphic));
} }
return xShape; return xShape;
} }
...@@ -1348,7 +1342,7 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes ...@@ -1348,7 +1342,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() )
{ {
Reference< XShape > xShape = SimpleShape::createEmbeddedPictureObject(rxShapes, rShapeRect, aGraphicPath); Reference<XShape> xShape = SimpleShape::createEmbeddedPictureObject(rxShapes, rShapeRect, aGraphicPath);
// AS_CHARACTER shape: vertical orientation default is bottom, MSO default is top. // AS_CHARACTER shape: vertical orientation default is bottom, MSO default is top.
if ( maTypeModel.maPosition != "absolute" && maTypeModel.maPosition != "relative" ) if ( maTypeModel.maPosition != "absolute" && maTypeModel.maPosition != "relative" )
PropertySet( xShape ).setAnyProperty( PROP_VertOrient, makeAny(text::VertOrientation::TOP)); PropertySet( xShape ).setAnyProperty( PROP_VertOrient, makeAny(text::VertOrientation::TOP));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment