comphelper::LifecycleProxy: make writing work:

The storage implementation forgets any writes unless all storages are
committed.
This commit is contained in:
Michael Stahl
2011-12-06 04:36:21 +01:00
parent c81b005921
commit f014ea59e9
2 changed files with 17 additions and 0 deletions

View File

@@ -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

View File

@@ -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 )
{