diff options
author | Michael Stahl <mstahl@redhat.com> | 2011-12-06 04:36:21 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2011-12-06 04:36:21 +0100 |
commit | f014ea59e9e6e24ffead1961e8b689237b3927f0 (patch) | |
tree | 5da8abd126e8b3a972784e7a2b0cd073c36f7a53 /comphelper | |
parent | c81b005921b39c54b33777af126b87e9f4e92860 (diff) |
comphelper::LifecycleProxy: make writing work:
The storage implementation forgets any writes unless all storages are
committed.
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/inc/comphelper/storagehelper.hxx | 2 | ||||
-rw-r--r-- | comphelper/source/misc/storagehelper.cxx | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/comphelper/inc/comphelper/storagehelper.hxx b/comphelper/inc/comphelper/storagehelper.hxx index 36ff7957f4bc..8bf26de44885 100644 --- a/comphelper/inc/comphelper/storagehelper.hxx +++ b/comphelper/inc/comphelper/storagehelper.hxx @@ -65,6 +65,8 @@ public: ::boost::scoped_ptr<Impl> m_pBadness; LifecycleProxy(); ~LifecycleProxy(); + // commit the storages: necessary for writes to streams to take effect! + void commitStorages(); }; class COMPHELPER_DLLPUBLIC OStorageHelper diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx index e429f2223069..773ec55440d7 100644 --- a/comphelper/source/misc/storagehelper.cxx +++ b/comphelper/source/misc/storagehelper.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/XEncryptionProtectedSource2.hpp> +#include <com/sun/star/embed/XTransactedObject.hpp> #include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/PropertyValue.hpp> @@ -551,6 +552,20 @@ LifecycleProxy::LifecycleProxy() : m_pBadness( new Impl() ) { } LifecycleProxy::~LifecycleProxy() { } +void LifecycleProxy::commitStorages() +{ + for (Impl::reverse_iterator iter = m_pBadness->rbegin(); + iter != m_pBadness->rend(); ++iter) // reverse order (outwards) + { + uno::Reference<embed::XTransactedObject> const xTransaction(*iter, + uno::UNO_QUERY); + if (xTransaction.is()) + { + xTransaction->commit(); + } + } +} + static void splitPath( std::vector<rtl::OUString> &rElems, const ::rtl::OUString& rPath ) { |