Tag: cws_src680_dba26
User: fs      
Date: 05/03/15 07:03:59

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

Log:
 #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.14.4.1
Delta lines:  +35 -18
---------------------
--- databasedocument.cxx        10 Mar 2005 16:33:50 -0000      1.14
+++ databasedocument.cxx        15 Mar 2005 15:03:55 -0000      1.14.4.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: databasedocument.cxx,v $
  *
- *  $Revision: 1.14 $
+ *  $Revision: 1.14.4.1 $
  *
- *  last change: $Author: vg $ $Date: 2005/03/10 16:33:50 $
+ *  last change: $Author: fs $ $Date: 2005/03/15 15:03:55 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -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     
@@ -487,7 +487,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 +496,7 @@
 
     m_pImpl->commitStorages();
 
-       writeStorage(sURL,lArguments);
+       writeStorage(sURL,lArguments,m_pImpl->getStorage());
 
        try
        {
@@ -506,7 +507,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) 
@@ -598,9 +599,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 +784,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 +850,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 +892,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 +949,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 +964,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 +980,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 +1288,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")));

File [changed]: databasedocument.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasedocument.hxx?r1=1.2&r2=1.2.4.1
Delta lines:  +22 -6
--------------------
--- databasedocument.hxx        10 Mar 2005 16:34:06 -0000      1.2
+++ databasedocument.hxx        15 Mar 2005 15:03:55 -0000      1.2.4.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: databasedocument.hxx,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.4.1 $
  *
- *  last change: $Author: vg $ $Date: 2005/03/10 16:34:06 $
+ *  last change: $Author: fs $ $Date: 2005/03/15 15:03:55 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -152,6 +152,7 @@
        ::cppu::OInterfaceContainerHelper                                       
m_aCloseListener;
     ::cppu::OInterfaceContainerHelper                                  
m_aDocEventListeners;
     ::rtl::Reference<ODatabaseModelImpl>                m_pImpl;
+    sal_Bool                                            m_bCommitMasterStorage;
 
        void setMeAsParent(const ::com::sun::star::uno::Reference< 
::com::sun::star::container::XNameAccess >& _xName);
 
@@ -160,8 +161,11 @@
                        The URL
                @param  lArguments
                        The media descriptor
+               @param  _xStorageToSaveTo
+                       The storage which should be used for saving
        */
-       void store(const ::rtl::OUString& sURL, const 
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& 
lArguments );
+       void store(const ::rtl::OUString& sURL
+                        , const ::com::sun::star::uno::Sequence< 
::com::sun::star::beans::PropertyValue>& lArguments);
 
     /** notifies the global event broadcaster
         @param  _sEventName
@@ -188,7 +192,8 @@
                /// output descriptor
                const ::com::sun::star::uno::Sequence<
                        ::com::sun::star::beans::PropertyValue> & rMediaDesc,
-               sal_Bool bPlainStream );                        /// neither 
compress nor encrypt
+               sal_Bool bPlainStream
+               , const ::com::sun::star::uno::Reference< 
::com::sun::star::embed::XStorage >& _xStorageToSaveTo);                      
/// neither compress nor encrypt
 
        /// write a single output stream
        /// (to be called either directly or by WriteThroughComponent(...))
@@ -201,8 +206,19 @@
                const ::com::sun::star::uno::Sequence<
                        ::com::sun::star::uno::Any> & rArguments,
                const ::com::sun::star::uno::Sequence<
-                       ::com::sun::star::beans::PropertyValue> & rMediaDesc );
-       void writeStorage(const ::rtl::OUString& _sURL, const 
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& 
lArguments);
+                       ::com::sun::star::beans::PropertyValue> & rMediaDesc);
+
+       /** writes the content and settings
+               @param  sURL
+                       The URL
+               @param  lArguments
+                       The media descriptor
+               @param  _xStorageToSaveTo
+                       The storage which should be used for saving
+       */
+       void writeStorage(const ::rtl::OUString& _sURL
+                                       , const 
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& 
lArguments
+                                       , const 
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& 
_xStorageToSaveTo);
 
 
 protected:




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

Reply via email to