From 65d3418ee39d30b10989d34bdc73fc8c56de74d8 Mon Sep 17 00:00:00 2001 From: "Andrzej J.R. Hunt" Date: Thu, 11 Jul 2013 17:04:50 +0100 Subject: Write embedded .fdb into Storage for OnSave & OnSaveAs. Change-Id: I2534378c48253584904d11bf049d5d4a05c300dd --- .../source/drivers/firebird/FConnection.cxx | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'connectivity/source/drivers/firebird') 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 +#include #include #include @@ -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 -- cgit v1.2.3