summaryrefslogtreecommitdiff
path: root/svx/source/unodraw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-10-13 19:01:12 +0200
committerMichael Stahl <mstahl@redhat.com>2014-10-13 19:23:41 +0200
commit220a3686921847b71dc72b69ce98ba260b951610 (patch)
treec10fc83c4abc99dd1685a7542f954ce9f6f3388c /svx/source/unodraw
parent8b7f96d257724656ac4a4303b17285be2ed13886 (diff)
oox: refactor embedded media import
Currently the oox import creates a temp file and leaks it, and there is no way to clean it up afterwards. Unfortunately it turns out that SdrModel has no way to access the imported OOXML storage, so add a really ugly hack to get the embedded media into the SdrMediaObj by setting both MediaURL and PrivateStream properties (currently oox really wants to set the properties in alphabetical order too...) Change-Id: I5a235fbeb08e7bc17faf066de52b94867e9a79a2
Diffstat (limited to 'svx/source/unodraw')
-rw-r--r--svx/source/unodraw/unoprov.cxx2
-rw-r--r--svx/source/unodraw/unoshap4.cxx26
2 files changed, 27 insertions, 1 deletions
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index 655fa27d0089..92460cd80beb 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -730,7 +730,7 @@ SfxItemPropertyMapEntry const * ImplGetSvxMediaShapePropertyMap()
// #i68101#
{ OUString(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , cppu::UnoType<OUString>::get(), 0, 0},
{ OUString(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , cppu::UnoType<OUString>::get(), 0, 0},
- {OUString("PrivateStream"), OWN_ATTR_MEDIA_STREAM, cppu::UnoType<css::io::XInputStream>::get(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ {OUString("PrivateStream"), OWN_ATTR_MEDIA_STREAM, cppu::UnoType<css::io::XInputStream>::get(), 0, 0},
{OUString("PrivateTempFileURL"), OWN_ATTR_MEDIA_TEMPFILEURL, cppu::UnoType<OUString>::get(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
{ OUString("MediaMimeType"), OWN_ATTR_MEDIA_MIMETYPE, cppu::UnoType<OUString>::get(), 0, 0},
{ OUString("FallbackGraphic"), OWN_ATTR_FALLBACK_GRAPHIC, cppu::UnoType<css::graphic::XGraphic>::get(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
index 3fac4a0d2f7b..b78d3629b5e0 100644
--- a/svx/source/unodraw/unoshap4.cxx
+++ b/svx/source/unodraw/unoshap4.cxx
@@ -808,6 +808,7 @@ SvxMediaShape::~SvxMediaShape() throw()
bool SvxMediaShape::setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
{
if( ((pProperty->nWID >= OWN_ATTR_MEDIA_URL) && (pProperty->nWID <= OWN_ATTR_MEDIA_ZOOM))
+ || (pProperty->nWID == OWN_ATTR_MEDIA_STREAM)
|| (pProperty->nWID == OWN_ATTR_MEDIA_MIMETYPE) )
{
SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( mpObj.get() );
@@ -886,6 +887,31 @@ bool SvxMediaShape::setPropertyValueImpl( const OUString& rName, const SfxItemPr
}
break;
+ case OWN_ATTR_MEDIA_STREAM:
+ try
+ {
+ uno::Reference<io::XInputStream> xStream;
+ if (rValue >>= xStream)
+ {
+ pMedia->SetInputStream(xStream);
+ }
+ }
+ catch (const css::ucb::ContentCreationException& e)
+ {
+ throw css::lang::WrappedTargetException(
+ "ContentCreationException Setting InputStream!",
+ static_cast<OWeakObject *>(this),
+ makeAny(e));
+ }
+ catch (const css::ucb::CommandFailedException& e)
+ {
+ throw css::lang::WrappedTargetException(
+ "CommandFailedException Setting InputStream!",
+ static_cast<OWeakObject *>(this),
+ makeAny(e));
+ }
+ break;
+
default:
OSL_FAIL("SvxMediaShape::setPropertyValueImpl(), unknown argument!");
}