summaryrefslogtreecommitdiff
path: root/comphelper/source/container
diff options
context:
space:
mode:
authorMikhail Voitenko <mav@openoffice.org>2005-02-02 15:04:07 +0000
committerMikhail Voitenko <mav@openoffice.org>2005-02-02 15:04:07 +0000
commitcf45add7f3139d9cd7788fc34f86d5891d107ea8 (patch)
treef5502f56286966af7830fed9ce3f5b75814daae8 /comphelper/source/container
parentfcc319c93124f2f0d599cac8dafb2bd62725a8b9 (diff)
#i41899# cache the image replacement storage and allow to release it
Diffstat (limited to 'comphelper/source/container')
-rw-r--r--comphelper/source/container/embeddedobjectcontainer.cxx52
1 files changed, 38 insertions, 14 deletions
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx
index be1a6620bdde..09ea084a1e72 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: embeddedobjectcontainer.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: rt $ $Date: 2005-01-31 09:16:12 $
+ * last change: $Author: mav $ $Date: 2005-02-02 16:04:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -138,29 +138,34 @@ struct EmbedImpl
EmbeddedObjectContainerNameMap maObjectContainer;
uno::Reference < embed::XStorage > mxStorage;
EmbeddedObjectContainer* mpTempObjectContainer;
+ uno::Reference < embed::XStorage > mxImageStorage;
//EmbeddedObjectContainerNameMap maTempObjectContainer;
//uno::Reference < embed::XStorage > mxTempStorage;
sal_Bool bOwnsStorage;
- const uno::Reference < embed::XStorage > GetReplacements();
+ const uno::Reference < embed::XStorage >& GetReplacements();
};
-const uno::Reference < embed::XStorage > EmbedImpl::GetReplacements()
+const uno::Reference < embed::XStorage >& EmbedImpl::GetReplacements()
{
- uno::Reference < embed::XStorage > xImageStorage;
- try
- {
- xImageStorage = mxStorage->openStorageElement( ::rtl::OUString::createFromAscii( "ObjectReplacements" ), embed::ElementModes::READWRITE );
- }
- catch ( uno::Exception& )
+ if ( !mxImageStorage.is() )
{
- xImageStorage = mxStorage->openStorageElement( ::rtl::OUString::createFromAscii( "ObjectReplacements" ), embed::ElementModes::READ );
+ try
+ {
+ mxImageStorage = mxStorage->openStorageElement(
+ ::rtl::OUString::createFromAscii( "ObjectReplacements" ), embed::ElementModes::READWRITE );
+ }
+ catch ( uno::Exception& )
+ {
+ mxImageStorage = mxStorage->openStorageElement(
+ ::rtl::OUString::createFromAscii( "ObjectReplacements" ), embed::ElementModes::READ );
+ }
}
- if ( !xImageStorage.is() )
+ if ( !mxImageStorage.is() )
throw io::IOException();
- return xImageStorage;
+ return mxImageStorage;
}
EmbeddedObjectContainer::EmbeddedObjectContainer()
@@ -181,7 +186,8 @@ EmbeddedObjectContainer::EmbeddedObjectContainer( const uno::Reference < embed::
void EmbeddedObjectContainer::SwitchPersistence( const uno::Reference < embed::XStorage >& rStor )
{
- // the image storage will be disposed automatically when the parent is disposed
+ ReleaseImageSubStorage();
+
if ( pImpl->bOwnsStorage )
pImpl->mxStorage->dispose();
@@ -189,8 +195,26 @@ void EmbeddedObjectContainer::SwitchPersistence( const uno::Reference < embed::X
pImpl->bOwnsStorage = sal_False;
}
+void EmbeddedObjectContainer::ReleaseImageSubStorage()
+{
+ if ( pImpl->mxImageStorage.is() )
+ {
+ try
+ {
+ pImpl->mxImageStorage->dispose();
+ pImpl->mxImageStorage = uno::Reference< embed::XStorage >();
+ }
+ catch( uno::Exception& )
+ {
+ OSL_ASSERT( "Problems releasing image substorage!\n" );
+ }
+ }
+}
+
EmbeddedObjectContainer::~EmbeddedObjectContainer()
{
+ ReleaseImageSubStorage();
+
if ( pImpl->bOwnsStorage )
pImpl->mxStorage->dispose();