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-12 16:34:27 +0100
commit65d3418ee39d30b10989d34bdc73fc8c56de74d8 (patch)
treef2792abde552d7c4a746e289a2211aeb6ca4974b
parent8f6e969c71d8693aece01ad4b769c9ba6ec6dd6e (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