User: vg      
Date: 05/03/23 01:46:07

Modified:
 /dba/dbaccess/source/core/dataaccess/
  databasedocument.cxx

Log:
 INTEGRATION: CWS dba26 (1.14.4); FILE MERGED
 2005/03/18 08:16:55 fs 1.14.4.2: #i45153# +isEmbeddedDatabase
 2005/03/15 15:03:55 fs 1.14.4.1: #i44582# (patch provided by OJ) refined 
storage handling

File Changes:

Directory: /dba/dbaccess/source/core/dataaccess/
================================================

File [changed]: databasedocument.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasedocument.cxx?r1=1.14&r2=1.15
Delta lines:  +33 -18
---------------------
--- databasedocument.cxx        10 Mar 2005 16:33:50 -0000      1.14
+++ databasedocument.cxx        23 Mar 2005 09:46:04 -0000      1.15
@@ -195,7 +195,7 @@
             ,m_aModifyListeners(m_aMutex)
                        ,m_aCloseListener(m_aMutex)
             ,m_aDocEventListeners(m_aMutex)
-
+            ,m_bCommitMasterStorage(sal_True)
 {
        DBG_CTOR(ODatabaseDocument,NULL);
        // adjust our readonly flag     
@@ -292,8 +292,6 @@
        
        m_pImpl->getStorage();
 
-       Reference<XDataSource> xDs = m_pImpl->getDataSource();
-
        try
        {
         static ::rtl::OUString 
s_sStatusIndicator(RTL_CONSTASCII_USTRINGPARAM("StatusIndicator"));
@@ -487,7 +485,8 @@
     notifyEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnSaveDone")));
 }
 // 
-----------------------------------------------------------------------------
-void ODatabaseDocument::store(const ::rtl::OUString& sURL, const Sequence< 
PropertyValue >& lArguments )
+void ODatabaseDocument::store(const ::rtl::OUString& sURL
+                                                        ,const Sequence< 
PropertyValue >& lArguments)
 {
     OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
        if ( m_pImpl->m_bDocumentReadOnly )
@@ -495,7 +494,7 @@
 
     m_pImpl->commitStorages();
 
-       writeStorage(sURL,lArguments);
+       writeStorage(sURL,lArguments,m_pImpl->getStorage());
 
        try
        {
@@ -506,7 +505,7 @@
        catch(Exception)
        {
        }
-       m_pImpl->m_bModified = sal_False;
+       setModified(sal_False);
 }
 // 
-----------------------------------------------------------------------------
 void SAL_CALL ODatabaseDocument::storeAsURL( const ::rtl::OUString& sURL, 
const Sequence< PropertyValue >& lArguments ) throw (IOException, 
RuntimeException) 
@@ -535,7 +534,7 @@
                        if ( !xStorage.is() )
                                throw IOException();
 
-            if ( m_pImpl->m_sConnectURL.compareToAscii("sdbc:embedded:",14) == 
0 )
+            if ( m_pImpl->isEmbeddedDatabase() )
                 m_pImpl->clearConnections();
             m_pImpl->commitEmbeddedStorage();
 
@@ -598,9 +597,22 @@
                        if ( !xStorage.is() )
                                throw IOException();
                
-                       if ( ! m_pImpl->m_bDocumentReadOnly )
-                               store(sURL,lArguments);
+            m_bCommitMasterStorage = sal_False;
+                       m_pImpl->commitEmbeddedStorage();
+            m_bCommitMasterStorage = sal_True;
                        xMyStorage->copyToStorage( xStorage );
+                       writeStorage(sURL,lArguments,xStorage);
+                       try
+               {
+                       Reference<XTransactedObject> 
xTransact(xStorage,UNO_QUERY);
+                       if ( xTransact.is() )
+                               xTransact->commit();
+               }
+               catch(Exception)
+               {
+                       OSL_ENSURE(0,"Exception Caught: Could not store 
database!");
+                               throw IOException();
+               }
                }
                else
                        throw IOException();
@@ -770,12 +782,13 @@
        const sal_Char* pServiceName,
        const Sequence<Any> & rArguments,
        const Sequence<PropertyValue> & rMediaDesc,
-       sal_Bool bPlainStream )
+       sal_Bool bPlainStream
+       ,const Reference<XStorage>& _xStorageToSaveTo)
 {
        OSL_ENSURE( NULL != pStreamName, "Need stream name!" );
        OSL_ENSURE( NULL != pServiceName, "Need service name!" );
 
-       Reference<XStorage> xMyStorage = m_pImpl->getStorage();
+       Reference<XStorage> xMyStorage = _xStorageToSaveTo;
        // open stream
        ::rtl::OUString sStreamName = ::rtl::OUString::createFromAscii( 
pStreamName );
        Reference<XStream> xStream = xMyStorage->openStreamElement( 
sStreamName,ElementModes::READWRITE | ElementModes::TRUNCATE );
@@ -835,7 +848,7 @@
        const Reference<XComponent> & xComponent,
        const sal_Char* pServiceName,
        const Sequence<Any> & rArguments,
-       const Sequence<PropertyValue> & rMediaDesc )
+       const Sequence<PropertyValue> & rMediaDesc)
 {
        OSL_ENSURE( xOutputStream.is(), "I really need an output stream!" );
        OSL_ENSURE( xComponent.is(), "Need component!" );
@@ -877,7 +890,9 @@
        return xFilter->filter( rMediaDesc );
 }
 // 
-----------------------------------------------------------------------------
-void ODatabaseDocument::writeStorage(const ::rtl::OUString& _sURL, const 
Sequence< PropertyValue >& lArguments )
+void ODatabaseDocument::writeStorage(const ::rtl::OUString& _sURL
+                                                                       ,const 
Sequence< PropertyValue >& lArguments
+                                                                       ,const 
Reference<XStorage>& _xStorageToSaveTo)
 {
        // create XStatusIndicator
        Reference<XStatusIndicator> xStatusIndicator;
@@ -932,7 +947,7 @@
        sal_Bool bWarn = sal_False, bErr = sal_False;
        String sWarnFile, sErrFile;
 
-       Reference<XPropertySet> xProp(m_pImpl->getStorage(),UNO_QUERY);
+       Reference<XPropertySet> xProp(_xStorageToSaveTo,UNO_QUERY);
        if ( xProp.is() )
        {
                static const ::rtl::OUString sPropName = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MediaType"));
@@ -947,7 +962,7 @@
                if( !WriteThroughComponent(
                        xCom, "settings.xml", 
                        "com.sun.star.comp.sdb.XMLSettingsExporter",
-                       aEmptyArgs, aProps, sal_True ) )
+                       aEmptyArgs, aProps, sal_True,_xStorageToSaveTo ) )
                {
                        if( !bWarn )
                        {
@@ -963,7 +978,7 @@
                if( !WriteThroughComponent(
                                xCom, "content.xml", 
                                "com.sun.star.comp.sdb.DBExportFilter",
-                               aFilterArgs, aProps, sal_True ) )
+                               aFilterArgs, aProps, sal_True,_xStorageToSaveTo 
) )
                {
                        bErr = sal_True;
                        sErrFile = String( 
RTL_CONSTASCII_STRINGPARAM("content.xml"),
@@ -1271,7 +1286,7 @@
 //------------------------------------------------------------------
 void SAL_CALL ODatabaseDocument::commited( const 
::com::sun::star::lang::EventObject& aEvent ) throw 
(::com::sun::star::uno::RuntimeException)
 {
-    if ( m_pImpl.is() )
+    if ( m_pImpl.is() && m_bCommitMasterStorage )
     {
         ::osl::MutexGuard aGuard(m_aMutex);
         TStorages::iterator aFind = 
m_pImpl->m_aStorages.find(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("database")));




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to