Tag: cws_src680_dba24
User: oj      
Date: 05/02/04 06:16:19

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

Log:
 #i42056# remember password if said so

File Changes:

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

File [changed]: databasecontext.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasecontext.cxx?r1=1.26.2.1&r2=1.26.2.2
Delta lines:  +15 -8
--------------------
--- databasecontext.cxx 2 Feb 2005 12:52:52 -0000       1.26.2.1
+++ databasecontext.cxx 4 Feb 2005 14:16:14 -0000       1.26.2.2
@@ -396,10 +396,16 @@
        Reference<XModel> xModel(xExistent,UNO_QUERY);
        xModel->attachResource(_sURL,aArgs);
 
+    setTransientProperties(_sURL,xExistent);
+       return xExistent;
+}
+// 
-----------------------------------------------------------------------------
+void ODatabaseContext::setTransientProperties(const ::rtl::OUString& _sURL, 
const Reference< XInterface > & _rxObject)
+{
        // check if we have any session persistent properties to initialize the 
new object with
        if ( m_aDatasourceProperties.end() != 
m_aDatasourceProperties.find(_sURL) )
        {       // yes, we do ....
-               Reference< XPropertySet > xDSProps(xExistent, UNO_QUERY);
+               Reference< XPropertySet > xDSProps(_rxObject, UNO_QUERY);
                if (xDSProps.is())
                {
                        const Sequence< PropertyValue >& 
rSessionPersistentProps = m_aDatasourceProperties[_sURL];
@@ -413,14 +419,13 @@
                                }
                                catch(Exception&)
                                {
-                                       
DBG_ERROR("ODatabaseContext::getRegisteredObject: could not set a 
session-persistent property on the data source!");
+                                       
DBG_ERROR("ODatabaseContext::setTransientProperties: could not set a 
session-persistent property on the data source!");
                                }
                        }
                }
                else
-                       DBG_ERROR("ODatabaseContext::getRegisteredObject: 
missing an interface!");
+                       DBG_ERROR("ODatabaseContext::setTransientProperties: 
missing an interface!");
        }
-       return xExistent;
 }
 
 
//------------------------------------------------------------------------------
@@ -714,6 +719,8 @@
                m_aDatabaseObjects.insert(
                                ObjectCache::value_type(_sName,
                                        
ObjectCacheType(WeakReferenceHelper(_xObject),WeakReferenceHelper(*this))));
+
+        setTransientProperties(_sName,_xObject);
                // add as dispose listener to the data source object, so we 
know when it's dying to save the session-persistent
                // properties
                Reference< XComponent > xComponent(_xObject,UNO_QUERY);

File [changed]: databasecontext.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasecontext.hxx?r1=1.11&r2=1.11.2.1
Delta lines:  +6 -0
-------------------
--- databasecontext.hxx 21 Jan 2005 17:03:15 -0000      1.11
+++ databasecontext.hxx 4 Feb 2005 14:16:15 -0000       1.11.2.1
@@ -152,6 +152,12 @@
     */
     bool    getURLForRegisteredObject( const ::rtl::OUString& 
_rRegisteredName, ::rtl::OUString& _rURL );
 
+    /** sets all properties which were transient at the data source. e.g. 
password
+        @param  _sURL       The file URL of the data source
+        @param  _xObject    The data source itself.
+    */
+    void setTransientProperties(const ::rtl::OUString& _sURL, const 
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& 
_xObject);
+
 protected:
        ::osl::Mutex    m_aMutex;
        ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XMultiServiceFactory >                        
m_xServiceManager;

File [changed]: databasedocument.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasedocument.cxx?r1=1.8&r2=1.8.2.1
Delta lines:  +221 -128
-----------------------
--- databasedocument.cxx        21 Jan 2005 17:03:37 -0000      1.8
+++ databasedocument.cxx        4 Feb 2005 14:16:15 -0000       1.8.2.1
@@ -88,6 +88,9 @@
 #ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_
 #include <com/sun/star/document/XFilter.hpp>
 #endif
+#ifndef _COM_SUN_STAR_TASK_ERRORCODEIOEXCEPTION_HPP_
+#include <com/sun/star/task/ErrorCodeIOException.hpp>
+#endif
 #ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
 #endif
@@ -100,6 +103,12 @@
 #ifndef _URLOBJ_HXX 
 #include <tools/urlobj.hxx>
 #endif
+#ifndef _ERRCODE_HXX
+#include <tools/errcode.hxx>
+#endif
+#ifndef _COMPHELPER_MEDIADESCRIPTOR_HXX_
+#include <comphelper/mediadescriptor.hxx>
+#endif
 #ifndef _DRAFTS_COM_SUN_STAR_UI_XUICONFIGURATIONSTORAGE_HPP_
 #include <drafts/com/sun/star/ui/XUIConfigurationStorage.hpp>
 #endif
@@ -109,6 +118,12 @@
 #ifndef _COM_SUN_STAR_EMBED_XTRANSACTIONBROADCASTER_HPP_
 #include <com/sun/star/embed/XTransactionBroadcaster.hpp>
 #endif
+#ifndef _COM_SUN_STAR_EMBED_XEMBEDPERSIST_HPP_
+#include <com/sun/star/embed/XEmbedPersist.hpp>
+#endif
+#ifndef _COM_SUN_STAR_EMBED_ENTRYINITMODES_HPP_
+#include <com/sun/star/embed/EntryInitModes.hpp>
+#endif
 #ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_
 #include <com/sun/star/view/XSelectionSupplier.hpp>
 #endif
@@ -136,6 +151,19 @@
 namespace dbaccess
 {
 //........................................................................
+// 
-----------------------------------------------------------------------------
+// local functions
+// 
-----------------------------------------------------------------------------
+void lcl_convertArguments(const Sequence< PropertyValue >& 
_aArguments,Sequence< PropertyValue >& _rArgs)
+{
+    static ::rtl::OUString 
s_sStatusIndicator(RTL_CONSTASCII_USTRINGPARAM("StatusIndicator"));
+    static ::rtl::OUString 
s_sInteractionHandler(RTL_CONSTASCII_USTRINGPARAM("InteractionHandler"));
+    ::comphelper::MediaDescriptor aMedia(_aArguments);
+    aMedia.erase(s_sStatusIndicator);
+    aMedia.erase(s_sInteractionHandler);
+    aMedia >> _rArgs;
+}
+// 
-----------------------------------------------------------------------------
 // XComponent
 void SAL_CALL ODatabaseSource::dispose(  ) throw (RuntimeException)
 {
@@ -187,6 +215,7 @@
                clearConnections();
         disposeStorages();
 
+        if ( m_bOwnStorage )
                ::comphelper::disposeComponent(m_xStorage);
                Reference< XNameAccess > xContainer = m_xForms;
                ::comphelper::disposeComponent(xContainer);
@@ -213,24 +242,26 @@
        
        m_bDocumentReadOnly = sal_False;
 
-       m_aArgs = _aArguments;
+    lcl_convertArguments(_aArguments,m_aArgs);
+
        m_sFileURL = _sURL;
        if ( !m_sName.getLength() )
                m_sName = m_sFileURL;
-       if ( m_pDBContext )
-               m_pDBContext->registerPrivate(_sURL,*this);
+       
        getStorage();
 
        try
        {
-               const PropertyValue* pValue 
=::std::find_if(m_aArgs.getConstArray(),
-                                                                               
                        m_aArgs.getConstArray() + m_aArgs.getLength(),
-                                                                               
                        
::std::bind2nd(::comphelper::TPropertyValueEqualFunctor(),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StatusIndicator"))));
+        static ::rtl::OUString 
s_sStatusIndicator(RTL_CONSTASCII_USTRINGPARAM("StatusIndicator"));
+               const PropertyValue* pValue 
=::std::find_if(_aArguments.getConstArray(),
+                                                                               
                        _aArguments.getConstArray() + _aArguments.getLength(),
+                                                                               
                        
::std::bind2nd(::comphelper::TPropertyValueEqualFunctor(),s_sStatusIndicator));
 
                Sequence<Any> aFilterArgs;
-               if ( pValue && pValue != (m_aArgs.getConstArray() + 
m_aArgs.getLength()) )
+        Reference<XStatusIndicator> xStatusIndicator;
+               if ( pValue && pValue != (_aArguments.getConstArray() + 
_aArguments.getLength()) )
                {
-                       Reference<XStatusIndicator> 
xStatusIndicator(pValue->Value,UNO_QUERY);
+                       xStatusIndicator.set(pValue->Value,UNO_QUERY);
 
                        // set progress range and start status indicator
                        sal_Int32 nProgressRange(1000000);
@@ -250,7 +281,9 @@
                        xImporter->setTargetDocument(xComponent);
                        Reference<XFilter> xFilter(xImporter,UNO_QUERY);
 
-                       xFilter->filter(m_aArgs);
+                       xFilter->filter(_aArguments);
+            if ( xStatusIndicator.is() )
+                xStatusIndicator->end();
                }
                else 
                        return sal_False;
@@ -263,6 +296,12 @@
        {
                return sal_False;
        }
+
+    if ( m_pDBContext )
+    {
+               m_pDBContext->registerPrivate(_sURL,*this);
+        setModified(sal_False);
+    }
        return sal_True;
 }
 // 
-----------------------------------------------------------------------------
@@ -281,16 +320,14 @@
 void SAL_CALL ODatabaseSource::connectController( const Reference< XController 
>& _xController ) throw (RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+    ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        m_aControllers.push_back(_xController);
 }
 // 
-----------------------------------------------------------------------------
 void SAL_CALL ODatabaseSource::disconnectController( const Reference< 
XController >& _xController ) throw (RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        
m_aControllers.erase(::std::find(m_aControllers.begin(),m_aControllers.end(),_xController));
        if ( m_xCurrentController == _xController )
                m_xCurrentController = NULL;
@@ -299,48 +336,42 @@
 void SAL_CALL ODatabaseSource::lockControllers(  ) throw (RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        ++m_nControllerLockCount;
 }
 // 
-----------------------------------------------------------------------------
 void SAL_CALL ODatabaseSource::unlockControllers(  ) throw (RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        --m_nControllerLockCount;
 }
 // 
-----------------------------------------------------------------------------
 sal_Bool SAL_CALL ODatabaseSource::hasControllersLocked(  ) throw 
(RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        return m_nControllerLockCount != 0;
 }
 // 
-----------------------------------------------------------------------------
 Reference< XController > SAL_CALL ODatabaseSource::getCurrentController() 
throw (RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        return m_xCurrentController.is() ? m_xCurrentController : ( 
m_aControllers.empty() ? Reference< XController >() : *m_aControllers.begin() );
 }
 // 
-----------------------------------------------------------------------------
 void SAL_CALL ODatabaseSource::setCurrentController( const Reference< 
XController >& _xController ) throw (NoSuchElementException, RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        m_xCurrentController = _xController;
 }
 // 
-----------------------------------------------------------------------------
 Reference< XInterface > SAL_CALL ODatabaseSource::getCurrentSelection(  ) 
throw (RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
        Reference< XInterface > xRet;
        Reference< XSelectionSupplier >  xDocView( getCurrentController(), 
UNO_QUERY );
@@ -355,34 +386,32 @@
 sal_Bool SAL_CALL ODatabaseSource::hasLocation(  ) throw (RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        return m_sFileURL.getLength() != 0;
 }
 // 
-----------------------------------------------------------------------------
 ::rtl::OUString SAL_CALL ODatabaseSource::getLocation(  ) throw 
(RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        return m_sFileURL;
 }
 // 
-----------------------------------------------------------------------------
 sal_Bool SAL_CALL ODatabaseSource::isReadonly(  ) throw (RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        return m_bDocumentReadOnly;
 }
 // 
-----------------------------------------------------------------------------
 void SAL_CALL ODatabaseSource::store(  ) throw (IOException, RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        
        store(m_sFileURL,m_aArgs);
+
+    notifyEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnSaveDone")));
 }
 // 
-----------------------------------------------------------------------------
 void ODatabaseSource::store(const ::rtl::OUString& sURL, const Sequence< 
PropertyValue >& lArguments )
@@ -392,20 +421,6 @@
 
        try
        {
-               
-//             if ( m_aContainer[E_FORM].get() )
-//             {
-//                     Reference<XTransactedObject> 
xForms(getFormDocuments(),UNO_QUERY);
-//                     if ( xForms.is() )
-//                             xForms->commit();
-//             }
-
-//             if ( m_aContainer[E_REPORT].get() )
-//             {
-//                     Reference<XTransactedObject> 
xReports(getReportDocuments(),UNO_QUERY);
-//                     if ( xReports.is() )
-//                             xReports->commit();
-//             }
                TStorages::iterator aIter = m_aStorages.begin();
                TStorages::iterator aEnd = m_aStorages.end();
                for (; aIter != aEnd ; ++aIter)
@@ -437,8 +452,7 @@
 void SAL_CALL ODatabaseSource::storeAsURL( const ::rtl::OUString& sURL, const 
Sequence< PropertyValue >& lArguments ) throw (IOException, RuntimeException) 
 {
        ClearableMutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        
        Reference<XSingleServiceFactory> 
xStorageFactory(m_xServiceFactory->createInstance( 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.StorageFactory"))
 ),UNO_QUERY);
        if ( xStorageFactory.is() )
@@ -467,7 +481,10 @@
             disposeStorages();
 
             m_xStorage = xStorage;
+            if ( m_bOwnStorage )
                        ::comphelper::disposeComponent(xMyStorage);
+            else
+                m_bOwnStorage = sal_True;
 
                        m_bDocumentReadOnly = sal_False;
                        if ( sURL != m_sFileURL )
@@ -482,8 +499,9 @@
                        m_sFileURL = sURL;
                        
                }
-               m_aArgs = lArguments;
-               store();
+               lcl_convertArguments(lArguments,m_aArgs);
+               store(m_sFileURL,lArguments);
+        
notifyEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnSaveAsDone")));
        }
        else
                throw IOException();
@@ -492,8 +510,7 @@
 void SAL_CALL ODatabaseSource::storeToURL( const ::rtl::OUString& sURL, const 
Sequence< PropertyValue >& lArguments ) throw (IOException, RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        Reference<XSingleServiceFactory> 
xStorageFactory(m_xServiceFactory->createInstance( 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.StorageFactory"))
 ),UNO_QUERY);
        if ( xStorageFactory.is() )
        {
@@ -531,21 +548,20 @@
 sal_Bool SAL_CALL ODatabaseSource::isModified(  ) throw (RuntimeException) 
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        return m_bModified;
 }
 // 
-----------------------------------------------------------------------------
 void SAL_CALL ODatabaseSource::setModified( sal_Bool _bModified ) throw 
(PropertyVetoException, RuntimeException) 
 {
        ResettableMutexGuard _rGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        if ( m_bModified != _bModified )
        {
                m_bModified = _bModified;
                lang::EventObject aEvt(*this);
                NOTIFY_LISTERNERS(m_aModifyListeners,XModifyListener,modified)
+        
notifyEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnModifyChanged")));
        }
 }
 // 
-----------------------------------------------------------------------------
@@ -565,8 +581,7 @@
 // 
-----------------------------------------------------------------------------
 void SAL_CALL ODatabaseSource::close( sal_Bool bDeliverOwnership ) throw 
(::com::sun::star::util::CloseVetoException, RuntimeException)
 {
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
        ResettableMutexGuard _rGuard(m_aMutex);
        lang::EventObject aEvt( static_cast< ::cppu::OWeakObject* >( this ) );
@@ -604,8 +619,7 @@
 Reference< XNameAccess > SAL_CALL ODatabaseSource::getFormDocuments(  ) throw 
(RuntimeException)
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
        Reference< XNameAccess > xContainer = m_xForms;
        if ( !xContainer.is() )
@@ -626,8 +640,7 @@
 Reference< XNameAccess > SAL_CALL ODatabaseSource::getReportDocuments(  ) 
throw (RuntimeException)
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
        Reference< XNameAccess > xContainer = m_xReports;
        if ( !xContainer.is() )
@@ -652,17 +665,28 @@
                Reference< XSingleServiceFactory> xStorageFactory;
                xStorageFactory.set(m_xServiceFactory->createInstance( 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.StorageFactory"))),UNO_QUERY);
 
-               if ( xStorageFactory.is() && m_sFileURL.getLength() )
+               if ( xStorageFactory.is() )
                {
                        Sequence<Any> aArgs(2);
+            const PropertyValue* pEnd = m_aArgs.getConstArray() + 
m_aArgs.getLength();
                        const PropertyValue* pValue 
=::std::find_if(m_aArgs.getConstArray(),
-                                                                               
                                m_aArgs.getConstArray() + m_aArgs.getLength(),
-                                                                               
                                
::std::bind2nd(::comphelper::TPropertyValueEqualFunctor(),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream"))));
-                       if ( pValue && pValue != (m_aArgs.getConstArray() + 
m_aArgs.getLength()) )
+                                                                               
                                pEnd,
+                                                                               
                                
::std::bind2nd(::comphelper::TPropertyValueEqualFunctor(),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Stream"))));
+            if ( pValue && pValue != pEnd )
                                aArgs[0] = pValue->Value;
                        else
+            {
+                pValue =::std::find_if(m_aArgs.getConstArray(),
+                                                                               
                                    pEnd,
+                                                                               
                                    
::std::bind2nd(::comphelper::TPropertyValueEqualFunctor(),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream"))));
+                           if ( pValue && pValue != pEnd )
+                                   aArgs[0] = pValue->Value;
+                           else if ( m_sFileURL.getLength() )
                                aArgs[0] <<= m_sFileURL;
+            }
 
+            if ( aArgs[0].hasValue() )
+            {
                        aArgs[1] <<= ElementModes::READWRITE;
                                
                        try
@@ -681,6 +705,8 @@
                                {
                                }
                        }
+                m_bOwnStorage = m_xStorage.is();
+            }
                }
        }
        return m_xStorage;
@@ -717,7 +743,6 @@
        return xStorage;
 }
 // 
-----------------------------------------------------------------------------
-// 
-----------------------------------------------------------------------------
 sal_Bool ODatabaseSource::WriteThroughComponent(
        const Reference<XComponent> & xComponent,
        const sal_Char* pStreamName,
@@ -837,11 +862,11 @@
        Reference<XStatusIndicator> xStatusIndicator;
        try
        {
-               const PropertyValue* pValue 
=::std::find_if(m_aArgs.getConstArray(),
-                                                                               
                        m_aArgs.getConstArray() + m_aArgs.getLength(),
+               const PropertyValue* pValue 
=::std::find_if(lArguments.getConstArray(),
+                                                                               
                        lArguments.getConstArray() + lArguments.getLength(),
                                                                                
                        
::std::bind2nd(::comphelper::TPropertyValueEqualFunctor(),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StatusIndicator"))));
 
-               if ( pValue && pValue != (m_aArgs.getConstArray() + 
m_aArgs.getLength()) )
+               if ( pValue && pValue != (lArguments.getConstArray() + 
lArguments.getLength()) )
                {
                        xStatusIndicator.set(pValue->Value,UNO_QUERY);
 
@@ -886,30 +911,6 @@
        sal_Bool bWarn = sal_False, bErr = sal_False;
        String sWarnFile, sErrFile;
 
-//     if ( !bOrganizerMode && !bBlock &&
-//             SFX_CREATE_MODE_EMBEDDED != 
pDoc->GetDocShell()->GetCreateMode() )
-//     {
-//             if( !WriteThroughComponent(
-//                             xModelComp, "meta.xml", xServiceFactory,
-//                             "com.sun.star.comp.Writer.XMLMetaExporter",
-//                             aEmptyArgs, aProps, sal_True ) )
-//             {
-//                     bWarn = sal_True;
-//                     sWarnFile = String( 
RTL_CONSTASCII_STRINGPARAM("meta.xml"),
-//                                                             
RTL_TEXTENCODING_ASCII_US );
-//             }
-//     }
-
-//     if( !WriteThroughComponent(
-//                     xModelComp, "styles.xml", xServiceFactory,
-//                     "com.sun.star.comp.Writer.XMLStylesExporter",
-//                     aFilterArgs, aProps, sal_False ) )
-//     {
-//             bErr = sal_True;
-//             sErrFile = String( RTL_CONSTASCII_STRINGPARAM("styles.xml"),
-//                                                RTL_TEXTENCODING_ASCII_US );
-//     }
-
        Reference<XPropertySet> xProp(getStorage(),UNO_QUERY);
        if ( xProp.is() )
        {
@@ -972,8 +973,7 @@
 Reference< ::drafts::com::sun::star::ui::XUIConfigurationManager > SAL_CALL 
ODatabaseSource::getUIConfigurationManager(  ) throw (RuntimeException)
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
        if ( !m_xUIConfigurationManager.is() )
     {
         m_xUIConfigurationManager = Reference< 
::drafts::com::sun::star::ui::XUIConfigurationManager >(
@@ -1016,8 +1016,7 @@
 Reference< XStorage > SAL_CALL ODatabaseSource::getDocumentSubStorage( const 
::rtl::OUString& aStorageName, sal_Int32 nMode ) throw (RuntimeException)
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
        Reference< XStorage > xResult = getStorage(aStorageName,nMode);
        if ( xResult.is() )
@@ -1050,8 +1049,7 @@
        try
        {
                ResettableMutexGuard _rGuard(m_aMutex);
-               if (OComponentHelper::rBHelper.bDisposed)
-                       throw DisposedException();
+               
::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
                store(  );
                
                lang::EventObject aEvt(*this);
@@ -1090,6 +1088,101 @@
                OSL_ENSURE(0,"Exception Caught: Could not store embedded 
database!");
        }
        return bStore;
+}
+/*
+// 
-----------------------------------------------------------------------------
+void SAL_CALL ODatabaseSource::loadFromStorage( const Reference< XStorage >& 
xStorage, const Sequence< PropertyValue >& aMediaDescriptor ) throw 
(IllegalArgumentException, DoubleInitializationException, 
::com::sun::star::io::IOException, Exception, RuntimeException)
+{
+    MutexGuard aGuard(m_aMutex);
+    ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+    if ( m_xStorage.is() )
+        throw DoubleInitializationException();
+}
+// 
-----------------------------------------------------------------------------
+void SAL_CALL ODatabaseSource::storeToStorage( const Reference< XStorage >& 
xStorage, const Sequence< PropertyValue >& lArguments ) throw 
(IllegalArgumentException, ::com::sun::star::io::IOException, Exception, 
RuntimeException)
+{
+    MutexGuard aGuard(m_aMutex);
+    ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+    Reference<XStorage> xMyStorage = getStorage();
+    if ( xMyStorage.is() )
+    {
+        if ( !m_bDocumentReadOnly )
+            store(m_sFileURL,lArguments);
+        if ( xStorage != xMyStorage )
+            xMyStorage->copyToStorage( xStorage );
+    }
+}
+// 
-----------------------------------------------------------------------------
+void SAL_CALL ODatabaseSource::switchToStorage( const Reference< XStorage >& 
xStorage ) throw (IllegalArgumentException, ::com::sun::star::io::IOException, 
Exception, RuntimeException)
+{
+    MutexGuard aGuard(m_aMutex);
+    ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+    sal_Bool bResult = sal_False;
+    Reference<XStorage> xMyStorage = getStorage();
+    Reference<XNameAccess> xMyName(xMyStorage,UNO_QUERY);
+    if ( xMyName.is() )
+    {
+        Sequence< ::rtl::OUString> aSeq = xMyName->getElementNames();
+        const ::rtl::OUString* pIter = aSeq.getConstArray();
+        const ::rtl::OUString* pEnd     = pIter + aSeq.getLength();
+        for(;pIter != pEnd;++pIter)
+        {
+            Reference<XEmbedPersist> 
xPersist(xMyName->getByName(*pIter),UNO_QUERY);
+                   if ( xPersist.is() )
+            {
+                try
+                                   {
+                                           xPersist->setPersistentEntry( 
xStorage,
+                                                    *pIter,
+                                                                               
                    EntryInitModes::NO_INIT,
+                                                                               
                    Sequence< PropertyValue >(),
+                                                                               
                    Sequence< PropertyValue >() );
+
+                                   }
+                                   catch( uno::Exception& )
+                                   {
+                        // TODO/LATER: error handling
+                                           bResult = sal_False;
+                                           break;
+                                   }
+            }
+        }
+        bResult = sal_True;
+    }
+
+    if ( !bResult )
+        throw task::ErrorCodeIOException( ::rtl::OUString(),
+                                                                               
        Reference< XInterface >(),
+                                                                               
        ERRCODE_IO_GENERAL );
+    m_xStorage = xStorage;
+    m_bOwnStorage = sal_False;
+}
+// 
-----------------------------------------------------------------------------
+Reference< XStorage > SAL_CALL ODatabaseSource::getDocumentStorage(  ) throw 
(::com::sun::star::io::IOException, Exception, RuntimeException)
+{
+    MutexGuard aGuard(m_aMutex);
+    ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
+    return getStorage();
+}
+// 
-----------------------------------------------------------------------------
+void SAL_CALL ODatabaseSource::addStorageChangeListener( const Reference< 
::com::sun::star::document::XStorageChangeListener >& xListener ) throw 
(RuntimeException)
+{
+    m_aStorageListeners.addInterface(xListener);
+}
+// 
-----------------------------------------------------------------------------
+void SAL_CALL ODatabaseSource::removeStorageChangeListener( const Reference< 
::com::sun::star::document::XStorageChangeListener >& xListener ) throw 
(RuntimeException)
+{
+    m_aStorageListeners.removeInterface(xListener);
+}
+*/
+// 
-----------------------------------------------------------------------------
+void ODatabaseSource::notifyEvent(const ::rtl::OUString& _sEventName)
+{
+    if ( m_xDocEventBroadcaster.is() )
+    {
+        ::com::sun::star::document::EventObject aEvent(*this, _sEventName);
+        m_xDocEventBroadcaster->notifyEvent(aEvent);
+    }
 }
 //........................................................................
 }      // namespace dbaccess

File [changed]: datasource.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/datasource.cxx?r1=1.53&r2=1.53.2.1
Delta lines:  +24 -10
---------------------
--- datasource.cxx      21 Jan 2005 17:03:54 -0000      1.53
+++ datasource.cxx      4 Feb 2005 14:16:16 -0000       1.53.2.1
@@ -531,8 +531,10 @@
                        ,m_aModifyListeners(m_aMutex)
                        ,m_aCloseListener(m_aMutex)
                        ,m_aFlushListeners(m_aMutex)
+            ,m_aStorageListeners(m_aMutex)
                        ,m_pDBContext(_pDBContext)
                        ,m_nControllerLockCount(0)
+            ,m_bOwnStorage(sal_False)
 {
        // some kind of default
        DBG_CTOR(ODatabaseSource,NULL);
@@ -565,8 +567,10 @@
                        ,m_aModifyListeners(m_aMutex)
                        ,m_aCloseListener(m_aMutex)
                        ,m_aFlushListeners(m_aMutex)
+            ,m_aStorageListeners(m_aMutex)
                        ,m_pDBContext(_pDBContext)
                        ,m_nControllerLockCount(0)
+            ,m_bOwnStorage(sal_False)
 {
        DBG_CTOR(ODatabaseSource,NULL);
        // adjust our readonly flag
@@ -590,6 +594,15 @@
        m_bReadOnly = sal_False;
        m_aContainer.resize(4);
        m_pChildCommitListen = NULL;
+    try
+    {
+        
m_xDocEventBroadcaster.set(m_xServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.GlobalEventBroadcaster"))),
+            UNO_QUERY);
+    }
+    catch(Exception)
+    {
+        OSL_ENSURE(0,"Could not create GlobalEventBroadcaster!");
+    }
 }
 // 
-----------------------------------------------------------------------------
 void ODatabaseSource::setMeAsParent(const Reference< XNameAccess >& _xName)
@@ -786,6 +799,7 @@
 
//------------------------------------------------------------------------------
 void ODatabaseSource::disposing()
 {
+    notifyEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnUnload")));
        OSubComponent::disposing();
        OPropertySetHelper::disposing();
        
@@ -795,6 +809,7 @@
        m_aModifyListeners.disposeAndClear( aDisposeEvent );
        m_aCloseListener.disposeAndClear( aDisposeEvent );
        m_aFlushListeners.disposeAndClear( aDisposeEvent );
+    m_aStorageListeners.disposeAndClear( aDisposeEvent );
 
        ::std::vector<TContentPtr>::iterator aIter = m_aContainer.begin();
        ::std::vector<TContentPtr>::iterator aEnd = m_aContainer.end();
@@ -827,6 +842,7 @@
                        ::comphelper::disposeComponent(aIter->second);
                }
                m_aStorages.clear();
+        if ( m_bOwnStorage )
                ::comphelper::disposeComponent(m_xStorage);
        }
        catch(Exception&)
@@ -1187,8 +1203,7 @@
 Reference< XConnection > SAL_CALL ODatabaseSource::connectWithCompletion( 
const Reference< XInteractionHandler >& _rxHandler,sal_Bool _bIsolated ) 
throw(SQLException, RuntimeException)
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
        if (!_rxHandler.is())
        {
@@ -1282,8 +1297,7 @@
 Reference< XConnection > ODatabaseSource::getConnection(const rtl::OUString& 
user, const rtl::OUString& password,sal_Bool _bIsolated) throw( SQLException, 
RuntimeException )
 {
        MutexGuard aGuard(m_aMutex);
-       if (OComponentHelper::rBHelper.bDisposed)
-               throw DisposedException();
+       ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
        Reference< XConnection > xConn;
        if ( _bIsolated )

File [changed]: datasource.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/datasource.hxx?r1=1.24&r2=1.24.2.1
Delta lines:  +38 -4
--------------------
--- datasource.hxx      21 Jan 2005 17:04:11 -0000      1.24
+++ datasource.hxx      4 Feb 2005 14:16:16 -0000       1.24.2.1
@@ -92,6 +92,9 @@
 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
 #include <com/sun/star/util/XNumberFormatter.hpp>
 #endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTLISTENER_HPP_
+#include <com/sun/star/document/XEventListener.hpp>
+#endif
 #ifndef _COM_SUN_STAR_UTIL_XFLUSHABLE_HPP_
 #include <com/sun/star/util/XFlushable.hpp>
 #endif
@@ -107,6 +110,9 @@
 #ifndef _CPPUHELPER_IMPLBASE9_HXX_
 #include <cppuhelper/implbase9.hxx>
 #endif
+#ifndef _CPPUHELPER_IMPLBASE10_HXX_
+#include <cppuhelper/implbase10.hxx>
+#endif
 #ifndef _DBASHARED_APITOOLS_HXX_
 #include "apitools.hxx"
 #endif
@@ -173,6 +179,9 @@
 #ifndef _COM_SUN_STAR_DOCUMENT_XDOCUMENTSUBSTORAGESUPPLIER_HPP_
 #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
 #endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XSTORAGEBASEDDOCUMENT_HPP_
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#endif
 #ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_
 #include <com/sun/star/embed/ElementModes.hpp>
 #endif
@@ -208,7 +217,7 @@
                                                        >       
ODatabaseSource_Base;
 
 
-typedef ::cppu::ImplHelper9    <       ::com::sun::star::frame::XModel
+typedef ::cppu::ImplHelper9<   ::com::sun::star::frame::XModel
                                                        ,       
::com::sun::star::util::XModifiable
                                                        ,       
::com::sun::star::frame::XStorable
                                                        ,       
::com::sun::star::view::XPrintable
@@ -217,6 +226,7 @@
                                                        ,       
::com::sun::star::util::XCloseable
                                                        ,       
::drafts::com::sun::star::ui::XUIConfigurationManagerSupplier
                                                        ,       
::com::sun::star::document::XDocumentSubStorageSupplier
+                            //,        
::com::sun::star::document::XStorageBasedDocument
                                                        >       
ODatabaseSource_OfficeDocument; 
 
 
@@ -285,17 +295,20 @@
        ::cppu::OInterfaceContainerHelper                                       
m_aModifyListeners;
        ::cppu::OInterfaceContainerHelper                                       
m_aCloseListener;
        ::cppu::OInterfaceContainerHelper                                       
m_aFlushListeners;
+    ::cppu::OInterfaceContainerHelper                                  
m_aStorageListeners;
 
        ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XEventListener>                                       
m_xSharedConnectionManager;
        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController> 
                                        m_xCurrentController;
        ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >   
                                        m_xStorage;
        ::com::sun::star::uno::Reference< 
::drafts::com::sun::star::ui::XUIConfigurationManager>        
m_xUIConfigurationManager;
+    ::com::sun::star::uno::Reference< 
::com::sun::star::document::XEventListener >              
m_xDocEventBroadcaster;
 
 
        ODatabaseContext*                                                       
                m_pDBContext;
        OSharedConnectionManager*                                               
        m_pSharedConnectionManager;
        OChildCommitListen_Impl*                                                
        m_pChildCommitListen;
        sal_uInt16                                                              
                        m_nControllerLockCount;
+    sal_Bool                                            m_bOwnStorage;
 
 
        /// write a single XML stream into the package
@@ -345,6 +358,18 @@
        /** dispose all frames for registered controllers
        */
        void disposeControllerFrames();
+
+    /** notifies the global event broadcaster
+        @param  _sEventName
+            On of 
+            OnNew      => new document
+            OnLoad      => load document 
+            OnUnload   => close document 
+            OnSaveDone   => "Save" ended
+            OnSaveAsDone   => "SaveAs" ended
+            OnModifyChanged   => modified/unmodified 
+    */
+    void notifyEvent(const ::rtl::OUString& _sEventName);
 protected:
        ODatabaseSource(
                const ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XMultiServiceFactory >& _rxFactory
@@ -494,6 +519,15 @@
     virtual void SAL_CALL addFlushListener( const 
::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) 
throw (::com::sun::star::uno::RuntimeException);
     virtual void SAL_CALL removeFlushListener( const 
::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) 
throw (::com::sun::star::uno::RuntimeException);
 
+// XStorageBasedDocument
+/*
+    virtual void SAL_CALL loadFromStorage( const 
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& 
xStorage, const ::com::sun::star::uno::Sequence< 
::com::sun::star::beans::PropertyValue >& aMediaDescriptor ) throw 
(::com::sun::star::lang::IllegalArgumentException, 
::com::sun::star::frame::DoubleInitializationException, 
::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, 
::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL storeToStorage( const 
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& 
xStorage, const ::com::sun::star::uno::Sequence< 
::com::sun::star::beans::PropertyValue >& aMediaDescriptor ) throw 
(::com::sun::star::lang::IllegalArgumentException, 
::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, 
::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL switchToStorage( const 
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage 
) throw (::com::sun::star::lang::IllegalArgumentException, 
::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, 
::com::sun::star::uno::RuntimeException);
+    virtual ::com::sun::star::uno::Reference< 
::com::sun::star::embed::XStorage > SAL_CALL getDocumentStorage(  ) throw 
(::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, 
::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL addStorageChangeListener( const 
::com::sun::star::uno::Reference< 
::com::sun::star::document::XStorageChangeListener >& xListener ) throw 
(::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL removeStorageChangeListener( const 
::com::sun::star::uno::Reference< 
::com::sun::star::document::XStorageChangeListener >& xListener ) throw 
(::com::sun::star::uno::RuntimeException);
+*/
        ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage> 
getStorage(const ::rtl::OUString& _sStorageName, sal_Int32 nMode = 
::com::sun::star::embed::ElementModes::READWRITE);
 protected:
 // helper

File [changed]: documentdefinition.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentdefinition.cxx?r1=1.19.2.1&r2=1.19.2.2
Delta lines:  +4 -4
-------------------




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

Reply via email to