summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2013-07-11 17:04:50 +0100
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2013-07-16 16:40:12 +0200
commit7c3560f50fe3199cc24961a2a9b89b6d13405925 (patch)
tree3f6968e4efb8974b548977fed6f596fcaa18ea71
parent031009ef27b3dccbb97c9f22f6c59b8808aef34c (diff)
Write embedded .fdb into Storage for OnSave & OnSaveAs.
Change-Id: I2534378c48253584904d11bf049d5d4a05c300dd
-rw-r--r--connectivity/source/drivers/firebird/FConnection.cxx24
1 files changed, 22 insertions, 2 deletions
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index e9594f9b3b7d..8c818471634f 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -64,6 +64,7 @@
#include "resource/sharedresources.hxx"
#include <comphelper/processfactory.hxx>
+#include <comphelper/storagehelper.hxx>
#include <unotools/tempfile.hxx>
#include <unotools/ucbstreamhelper.hxx>
@@ -498,9 +499,28 @@ void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeExceptio
void SAL_CALL OConnection::documentEventOccured( const DocumentEvent& _Event )
throw(RuntimeException)
{
- if (_Event.EventName == "onSave" || _Event.EventName == "onSaveAs")
+ if (_Event.EventName == "OnSave" || _Event.EventName == "OnSaveAs")
{
- // TODO: write to storage
+ if ( m_bIsEmbedded && m_xEmbeddedStorage.is() )
+ {
+ const OUString sDBName( "firebird.fdb" ); // Location within .odb container
+
+ SAL_INFO("connectivity.firebird", "Writing .fdb into .odb" );
+
+ Reference< XStream > xDBStream(m_xEmbeddedStorage->openStreamElement(sDBName,
+ ElementModes::WRITE));
+
+ using namespace ::comphelper;
+ Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
+ Reference< XInputStream > xInputStream;
+ if (xContext.is())
+ xInputStream =
+ OStorageHelper::GetInputStreamFromURL(m_aURL, xContext);
+ if (xInputStream.is())
+ OStorageHelper::CopyInputToOutput( xInputStream,
+ xDBStream->getOutputStream());
+ // TODO: ensure db is in safe state
+ }
}
}
// XEventListener