Tag: cws_dev300_odbmacros3
User: fs      
Date: 2008-07-24 05:34:17+0000
Modified:
   dba/dbaccess/source/core/dataaccess/databasedocument.cxx
   dba/dbaccess/source/core/dataaccess/databasedocument.hxx

Log:
 #i76128# implicit initialization in storeAsURL, to allow for API compatibility

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.40.6.10&r2=1.40.6.11
Delta lines:  +36 -8
--------------------
--- databasedocument.cxx        2008-07-23 11:50:05+0000        1.40.6.10
+++ databasedocument.cxx        2008-07-24 05:34:15+0000        1.40.6.11
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: databasedocument.cxx,v $
- * $Revision: 1.40.6.10 $
+ * $Revision: 1.40.6.11 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -381,8 +381,16 @@
         aResource.getOrDefault( "MacroExecutionMode", 
m_pImpl->getImposedMacroExecMode() ) );
 
     m_pImpl->setInitializing();
+    try
+    {
     if ( !impl_import_throw( aResource ) )
         impl_reset_nothrow();
+    }
+    catch( const Exception& )
+    {
+        impl_reset_nothrow();
+        throw;
+    }
     m_pImpl->setInitialized();
 
     impl_setModified_throw( sal_False, aGuard );
@@ -555,7 +563,6 @@
 void SAL_CALL ODatabaseDocument::store(  ) throw (IOException, 
RuntimeException)
 {
     ModelMethodGuard aGuard( *this );
-    //ModifyLock aLock( *this );
 
     if ( m_pImpl->getLocation() == m_pImpl->getURL() )
         if ( m_pImpl->m_bDocumentReadOnly )
@@ -607,6 +614,10 @@
     // create a document event (mutex still locked)
     document::EventObject aEvent( *this, ::rtl::OUString::createFromAscii( 
_pAsciiDocumentEventName ) );
 
+    // if we are in an initialization process, then this is finished, now that 
we stored the document
+    if ( m_pImpl->isInitializing() )
+        m_pImpl->setInitialized();
+
     // reset our "modified" flag, and clear the guard
     impl_setModified_throw( sal_False, _rGuard );
 
@@ -631,10 +642,27 @@
 // 
-----------------------------------------------------------------------------
 void SAL_CALL ODatabaseDocument::storeAsURL( const ::rtl::OUString& _rURL, 
const Sequence< PropertyValue >& _rArguments ) throw (IOException, 
RuntimeException)
 {
-    ModelMethodGuard aGuard( *this );
-    //ModifyLock aLock( *this );
+    ModelMethodGuard aGuard( *this, ModelMethodGuard::MethodWithoutInit );
+
+    // Normally, a document initialization is done via XLoadable::load or 
XLoadable::initNew. For convenience
+    // reasons, and to not break existing API clients, it's allowed to call 
storeAsURL without having initialized
+    // the document, in which case the initialization will be done implicitly.
+    if ( m_pImpl->isInitializing() )
+        // implicit initialization while another initialization is just 
running is not possible
+        throw DoubleInitializationException();
 
+    if ( !m_pImpl->isInitialized() )
+        m_pImpl->setInitializing();
+
+    try
+    {
     impl_storeAs_throw( _rURL, _rArguments, "OnSaveAsDone", aGuard );
+    }
+    catch( const Exception& )
+    {
+        impl_reset_nothrow();
+        throw;
+    }
 }
 
 // 
-----------------------------------------------------------------------------
@@ -1190,7 +1218,7 @@
 // 
-----------------------------------------------------------------------------
 Reference< XDataSource > SAL_CALL ODatabaseDocument::getDataSource() throw 
(RuntimeException)
 {
-    ModelMethodGuard aGuard( *this, ModelMethodGuard::MethodUsedDuringInit );
+    ModelMethodGuard aGuard( *this, ModelMethodGuard::MethodWithoutInit );
     return m_pImpl->getOrCreateDataSource();
 }
 
@@ -1210,7 +1238,6 @@
 void SAL_CALL ODatabaseDocument::storeToStorage( const Reference< XStorage >& 
_rxStorage, const Sequence< PropertyValue >& _rMediaDescriptor ) throw 
(IllegalArgumentException, IOException, Exception, RuntimeException)
 {
     ModelMethodGuard aGuard( *this );
-    //ModifyLock aLock( *this );
 
     impl_storeToStorage_throw( _rxStorage, _rMediaDescriptor );
 }
@@ -1300,6 +1327,7 @@
 // 
-----------------------------------------------------------------------------
 Reference< XNameReplace > SAL_CALL ODatabaseDocument::getEvents(  ) throw 
(RuntimeException)
 {
+    ModelMethodGuard aGuard( *this, ModelMethodGuard::MethodUsedDuringInit );
     return m_pEventContainer;
 }
 

File [changed]: databasedocument.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasedocument.hxx?r1=1.20.2.5&r2=1.20.2.6
Delta lines:  +17 -12
---------------------
--- databasedocument.hxx        2008-07-23 10:03:31+0000        1.20.2.5
+++ databasedocument.hxx        2008-07-24 05:34:15+0000        1.20.2.6
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: databasedocument.hxx,v $
- * $Revision: 1.20.2.5 $
+ * $Revision: 1.20.2.6 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -262,13 +262,13 @@
     virtual void SAL_CALL setCurrentController( const 
::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& 
Controller ) throw (::com::sun::star::container::NoSuchElementException, 
::com::sun::star::uno::RuntimeException) ;
     virtual ::com::sun::star::uno::Reference< 
::com::sun::star::uno::XInterface > SAL_CALL getCurrentSelection(  ) throw 
(::com::sun::star::uno::RuntimeException) ;
 
-// ::com::sun::star::frame::XModel2
+    // XModel2
     virtual ::com::sun::star::uno::Reference< 
::com::sun::star::container::XEnumeration > SAL_CALL getControllers(  ) throw 
(::com::sun::star::uno::RuntimeException) ;
     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 
getAvailableViewControllerNames(  ) throw 
(::com::sun::star::uno::RuntimeException) ;
     virtual ::com::sun::star::uno::Reference< 
::com::sun::star::frame::XController2 > SAL_CALL createDefaultViewController( 
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& 
Frame ) throw (::com::sun::star::lang::IllegalArgumentException, 
::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) ;
     virtual ::com::sun::star::uno::Reference< 
::com::sun::star::frame::XController2 > SAL_CALL createViewController( const 
::rtl::OUString& ViewName, const ::com::sun::star::uno::Sequence< 
::com::sun::star::beans::PropertyValue >& Arguments, const 
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& Frame ) 
throw (::com::sun::star::lang::IllegalArgumentException, 
::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) ;
 
-// ::com::sun::star::frame::XStorable
+    // XStorable
        virtual sal_Bool SAL_CALL hasLocation(  ) throw 
(::com::sun::star::uno::RuntimeException) ;
     virtual ::rtl::OUString SAL_CALL getLocation(  ) throw 
(::com::sun::star::uno::RuntimeException) ;
     virtual sal_Bool SAL_CALL isReadonly(  ) throw 
(::com::sun::star::uno::RuntimeException) ;
@@ -276,37 +276,38 @@
     virtual void SAL_CALL storeAsURL( const ::rtl::OUString& sURL, const 
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& 
lArguments ) throw (::com::sun::star::io::IOException, 
::com::sun::star::uno::RuntimeException) ;
     virtual void SAL_CALL storeToURL( const ::rtl::OUString& sURL, const 
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& 
lArguments ) throw (::com::sun::star::io::IOException, 
::com::sun::star::uno::RuntimeException) ;
 
-// ::com::sun::star::util::XModifyBroadcaster
+    // XModifyBroadcaster
        virtual void SAL_CALL addModifyListener( const 
::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& 
aListener ) throw (::com::sun::star::uno::RuntimeException);
     virtual void SAL_CALL removeModifyListener( const 
::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& 
aListener ) throw (::com::sun::star::uno::RuntimeException);
 
-// ::com::sun::star::util::XModifiable
+    // ::com::sun::star::util::XModifiable
        virtual sal_Bool SAL_CALL isModified(  ) throw 
(::com::sun::star::uno::RuntimeException) ;
     virtual void SAL_CALL setModified( sal_Bool bModified ) throw 
(::com::sun::star::beans::PropertyVetoException, 
::com::sun::star::uno::RuntimeException) ;
-// ::com::sun::star::document::XEventBroadcaster
+
+    // XEventBroadcaster
     virtual void SAL_CALL addEventListener( const 
::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& 
aListener ) throw (::com::sun::star::uno::RuntimeException);
     virtual void SAL_CALL removeEventListener( const 
::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& 
aListener ) throw (::com::sun::star::uno::RuntimeException);
     
-// ::com::sun::star::view::XPrintable
+    // XPrintable
        virtual ::com::sun::star::uno::Sequence< 
::com::sun::star::beans::PropertyValue > SAL_CALL getPrinter(  ) throw 
(::com::sun::star::uno::RuntimeException) ;
     virtual void SAL_CALL setPrinter( const ::com::sun::star::uno::Sequence< 
::com::sun::star::beans::PropertyValue >& aPrinter ) throw 
(::com::sun::star::lang::IllegalArgumentException, 
::com::sun::star::uno::RuntimeException) ;
     virtual void SAL_CALL print( const ::com::sun::star::uno::Sequence< 
::com::sun::star::beans::PropertyValue >& xOptions ) throw 
(::com::sun::star::lang::IllegalArgumentException, 
::com::sun::star::uno::RuntimeException) ;
 
-// XFormDocumentsSupplier
+    // XFormDocumentsSupplier
        virtual ::com::sun::star::uno::Reference< 
::com::sun::star::container::XNameAccess > SAL_CALL getFormDocuments(  ) throw 
(::com::sun::star::uno::RuntimeException);
 
-// XReportDocumentsSupplier
+    // XReportDocumentsSupplier
        virtual ::com::sun::star::uno::Reference< 
::com::sun::star::container::XNameAccess > SAL_CALL getReportDocuments(  ) 
throw (::com::sun::star::uno::RuntimeException);
 
-// XCloseable
+    // XCloseable
        virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw 
(::com::sun::star::util::CloseVetoException, 
::com::sun::star::uno::RuntimeException);
        virtual void SAL_CALL addCloseListener( const 
::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& 
Listener ) throw (::com::sun::star::uno::RuntimeException);
     virtual void SAL_CALL removeCloseListener( const 
::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& 
Listener ) throw (::com::sun::star::uno::RuntimeException);
 
-// XUIConfigurationManagerSupplier
+    // XUIConfigurationManagerSupplier
        virtual ::com::sun::star::uno::Reference< 
::com::sun::star::ui::XUIConfigurationManager > SAL_CALL 
getUIConfigurationManager(  ) throw (::com::sun::star::uno::RuntimeException);
 
-// XDocumentSubStorageSupplier
+    // XDocumentSubStorageSupplier
        virtual ::com::sun::star::uno::Reference< 
::com::sun::star::embed::XStorage > SAL_CALL getDocumentSubStorage( const 
::rtl::OUString& aStorageName, sal_Int32 nMode ) throw 
(::com::sun::star::uno::RuntimeException);
        virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 
getDocumentSubStoragesNames(  ) throw (::com::sun::star::io::IOException, 
::com::sun::star::uno::RuntimeException);
 
@@ -449,6 +450,10 @@
 
     /// determines whether we should disable the scripting related interfaces
     bool    impl_shouldDisallowScripting_nolck_nothrow() const;
+
+    /** checks whether we need to implicitly initialize the document
+
+    */
 };
 
 //........................................................................




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

Reply via email to