Kaydet (Commit) acef4b26 authored tarafından Andrzej J.R. Hunt's avatar Andrzej J.R. Hunt Kaydeden (comit) Lionel Elie Mamane

fdo#70144 Mark database document as modified when data inserted in firebird.

This only applies to embedded databases where any changes to the database
only affect the temporary extracted db which still has to be stored into
the .odb.

This only fixes the status for modification/insertion/deletion of data
in existing tables. Insertion of new tables still does not result
in the modified state being set.

Change-Id: I553f67127672f2cf49b98ddcdf7d25f22bef5074
Reviewed-on: https://gerrit.libreoffice.org/6621Reviewed-by: 's avatarLionel Elie Mamane <lionel@mamane.lu>
Tested-by: 's avatarLionel Elie Mamane <lionel@mamane.lu>
üst 5c7ede91
...@@ -302,6 +302,12 @@ void Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyV ...@@ -302,6 +302,12 @@ void Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyV
osl_atomic_decrement( &m_refCount ); osl_atomic_decrement( &m_refCount );
} }
void Connection::notifyDatabaseModified()
{
if (m_xParentDocument.is()) // Only true in embedded mode
m_xParentDocument->setModified(sal_True);
}
//----- XServiceInfo --------------------------------------------------------- //----- XServiceInfo ---------------------------------------------------------
IMPLEMENT_SERVICE_INFO(Connection, "com.sun.star.sdbc.drivers.firebird.Connection", IMPLEMENT_SERVICE_INFO(Connection, "com.sun.star.sdbc.drivers.firebird.Connection",
"com.sun.star.sdbc.Connection") "com.sun.star.sdbc.Connection")
......
...@@ -188,6 +188,16 @@ namespace connectivity ...@@ -188,6 +188,16 @@ namespace connectivity
isc_tr_handle& getTransaction() isc_tr_handle& getTransaction()
throw(::com::sun::star::sdbc::SQLException); throw(::com::sun::star::sdbc::SQLException);
/**
* Must be called anytime the underlying database is likely to have
* changed.
*
* This is used to notify the database document of any changes, so
* that the user is informed of any pending changes needing to be
* saved.
*/
void notifyDatabaseModified();
/** /**
* Create a new Blob tied to this connection. Blobs are tied to a * Create a new Blob tied to this connection. Blobs are tied to a
* transaction and not to a statement, hence the connection should * transaction and not to a statement, hence the connection should
......
...@@ -287,6 +287,9 @@ sal_Bool SAL_CALL OPreparedStatement::execute() ...@@ -287,6 +287,9 @@ sal_Bool SAL_CALL OPreparedStatement::execute()
m_aStatementHandle, m_aStatementHandle,
m_pOutSqlda); m_pOutSqlda);
if (getStatementChangeCount() > 0)
m_pConnection->notifyDatabaseModified();
return m_xResultSet.is(); return m_xResultSet.is();
// TODO: implement handling of multiple ResultSets. // TODO: implement handling of multiple ResultSets.
} }
......
...@@ -136,7 +136,14 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s ...@@ -136,7 +136,14 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
evaluateStatusVector(m_statusVector, sql, *this); evaluateStatusVector(m_statusVector, sql, *this);
if (isDDLStatement()) if (isDDLStatement())
{
m_pConnection->commit(); m_pConnection->commit();
m_pConnection->notifyDatabaseModified();
}
else if (getStatementChangeCount() > 0)
{
m_pConnection->notifyDatabaseModified();
}
return m_xResultSet; return m_xResultSet;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment