Tag: cws_dev300_dba30f
User: fs      
Date: 2008-06-30 20:54:59+0000
Modified:
   dba/dbaccess/source/core/dataaccess/documentdefinition.cxx
   dba/dbaccess/source/core/dataaccess/documentdefinition.hxx

Log:
 #i91223# implement XSubDocument

File Changes:

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

File [changed]: documentdefinition.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentdefinition.cxx?r1=1.62&r2=1.62.12.1
Delta lines:  +134 -15
----------------------
--- documentdefinition.cxx      2008-06-16 12:31:02+0000        1.62
+++ documentdefinition.cxx      2008-06-30 20:54:56+0000        1.62.12.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: documentdefinition.cxx,v $
- * $Revision: 1.62 $
+ * $Revision: 1.62.12.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -249,6 +249,8 @@
 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
 #endif
 #include <com/sun/star/io/WrongFormatException.hpp>
+#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::view;
@@ -274,6 +276,9 @@
 using namespace ::cppu;
 namespace css = ::com::sun::star;
 
+using ::com::sun::star::sdb::application::XDatabaseDocumentUI;
+namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
+
 
 #define DEFAULT_WIDTH  10000
 #define DEFAULT_HEIGHT  7500
@@ -1121,24 +1126,13 @@
                 ||  ( aCommand.Name.compareToAscii( "store" ) == 0 )
                 )
         {
-                   Reference<XEmbedPersist> 
xPersist(m_xEmbeddedObject,UNO_QUERY);
-                   if ( xPersist.is() )
-                   {
-                           xPersist->storeOwn();
-                           notifyDataSourceModified();
-                   }
+            impl_store_throw();
         }
         else if (   ( aCommand.Name.compareToAscii( "shutdown" ) == 0 ) // 
compatibility
                 ||  ( aCommand.Name.compareToAscii( "close" ) == 0 )
                 )
         {
-            bool bSuccess = prepareClose();
-            if ( bSuccess && m_xEmbeddedObject.is() )
-            {
-                m_xEmbeddedObject->changeState( EmbedStates::LOADED );
-                bSuccess = m_xEmbeddedObject->getCurrentState() == 
EmbedStates::LOADED;
-            }
-            aRet <<= bSuccess;
+            aRet <<= impl_close_throw();
                }
            else
                    aRet = 
OContentHelper::execute(aCommand,CommandId,Environment);
@@ -1808,6 +1802,131 @@
        }
        return xComp;
 }
+
+// 
-----------------------------------------------------------------------------
+namespace
+{
+    Reference< XDatabaseDocumentUI > lcl_getDatabaseDocumentUI( 
ODatabaseModelImpl& _rModelImpl )
+    {
+        Reference< XDatabaseDocumentUI > xUI;
+
+        Reference< XModel > xModel( _rModelImpl.getModel_noCreate() );
+        if ( xModel.is() )
+            xUI.set( xModel->getCurrentController(), UNO_QUERY );
+        return xUI;
+    }
+}
+
+// 
-----------------------------------------------------------------------------
+Reference< XComponent > ODocumentDefinition::impl_openUI_nolck_throw( bool 
_bForEditing )
+{
+    ::osl::ClearableMutexGuard aGuard( m_aMutex );
+    if ( !m_pImpl || !m_pImpl->m_pDataSource )
+        throw DisposedException();
+
+    Reference< XDatabaseDocumentUI > xUI( lcl_getDatabaseDocumentUI( 
*m_pImpl->m_pDataSource ) );
+    if ( !xUI.is() )
+    {
+        // no XDatabaseDocumentUI -> just execute the respective command
+        m_bOpenInDesign = _bForEditing;
+        Any aComponent;
+        onCommandOpenSomething( Any(), true, NULL, aComponent );
+        Reference< XComponent > xComponent;
+        OSL_VERIFY( aComponent >>= xComponent );
+        return xComponent;
+    }
+
+    Reference< XComponent > xComponent;
+    try
+    {
+        ::rtl::OUString sName( m_pImpl->m_aProps.aTitle );
+        sal_Int32 nObjectType = m_bForm ? DatabaseObject::FORM : 
DatabaseObject::REPORT;
+        aGuard.clear();
+
+        xComponent = xUI->loadComponent(
+            nObjectType, sName, _bForEditing
+        );
+    }
+    catch( RuntimeException& ) { throw; }
+    catch( const Exception& )
+    {
+        throw WrappedTargetException(
+            ::rtl::OUString(), *this, ::cppu::getCaughtException() );
+    }
+    return xComponent;
+}
+
+// 
-----------------------------------------------------------------------------
+void ODocumentDefinition::impl_store_throw()
+{
+    Reference<XEmbedPersist> xPersist( m_xEmbeddedObject, UNO_QUERY );
+    if ( xPersist.is() )
+    {
+        xPersist->storeOwn();
+        notifyDataSourceModified();
+    }
+}
+
+// 
-----------------------------------------------------------------------------
+bool ODocumentDefinition::impl_close_throw()
+{
+    bool bSuccess = prepareClose();
+    if ( bSuccess && m_xEmbeddedObject.is() )
+    {
+        m_xEmbeddedObject->changeState( EmbedStates::LOADED );
+        bSuccess = m_xEmbeddedObject->getCurrentState() == EmbedStates::LOADED;
+    }
+    return bSuccess;
+}
+
+// 
-----------------------------------------------------------------------------
+Reference< XComponent > SAL_CALL ODocumentDefinition::open(  ) throw 
(WrappedTargetException, RuntimeException)
+{
+    return impl_openUI_nolck_throw( false );
+}
+
+// 
-----------------------------------------------------------------------------
+Reference< XComponent > SAL_CALL ODocumentDefinition::openDesign(  ) throw 
(WrappedTargetException, RuntimeException)
+{
+    return impl_openUI_nolck_throw( true );
+}
+
+// 
-----------------------------------------------------------------------------
+void SAL_CALL ODocumentDefinition::store(  ) throw (WrappedTargetException, 
RuntimeException)
+{
+    ::osl::MutexGuard aGuard( m_aMutex );
+    try
+    {
+        impl_store_throw();
+    }
+    catch( RuntimeException& ) { throw; }
+    catch( const Exception& )
+    {
+        throw WrappedTargetException(
+            ::rtl::OUString(), *this, ::cppu::getCaughtException() );
+    }
+}
+
+// 
-----------------------------------------------------------------------------
+::sal_Bool SAL_CALL ODocumentDefinition::close(  ) throw 
(WrappedTargetException, RuntimeException)
+{
+    ::osl::MutexGuard aGuard( m_aMutex );
+
+    sal_Bool bSuccess = sal_False;
+    try
+    {
+        bSuccess = impl_close_throw();
+    }
+    catch( RuntimeException& ) { throw; }
+    catch( const Exception& )
+    {
+        throw WrappedTargetException(
+            ::rtl::OUString(), *this, ::cppu::getCaughtException() );
+    }
+    return bSuccess;
+}
+
+
 // 
-----------------------------------------------------------------------------
 void SAL_CALL ODocumentDefinition::rename( const ::rtl::OUString& _rNewName ) 
throw (SQLException, ElementExistException, RuntimeException)
 {

File [changed]: documentdefinition.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentdefinition.hxx?r1=1.30&r2=1.30.32.1
Delta lines:  +34 -10
---------------------
--- documentdefinition.hxx      2008-05-05 15:50:37+0000        1.30
+++ documentdefinition.hxx      2008-06-30 20:54:56+0000        1.30.32.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: documentdefinition.hxx,v $
- * $Revision: 1.30 $
+ * $Revision: 1.30.32.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -34,8 +34,8 @@
 #ifndef _CPPUHELPER_PROPSHLP_HXX
 #include <cppuhelper/propshlp.hxx>
 #endif
-#ifndef _CPPUHELPER_IMPLBASE1_HXX_
-#include <cppuhelper/implbase1.hxx>
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
 #endif
 #ifndef DBA_CONTENTHELPER_HXX
 #include "ContentHelper.hxx"
@@ -64,6 +64,7 @@
 #ifndef _COM_SUN_STAR_EMBED_XSTATECHANGELISTENER_HPP_
 #include <com/sun/star/embed/XStateChangeListener.hpp>
 #endif
+#include <com/sun/star/sdb/XSubDocument.hpp>
 
 //........................................................................
 namespace dbaccess
@@ -77,7 +78,8 @@
 //=                                      document
 //==========================================================================
 
-typedef ::cppu::ImplHelper1 <   ::com::sun::star::embed::XComponentSupplier
+typedef ::cppu::ImplHelper2 <   ::com::sun::star::embed::XComponentSupplier
+                            ,   ::com::sun::star::sdb::XSubDocument
                             >   ODocumentDefinition_Base;
 
 class ODocumentDefinition
@@ -126,6 +128,12 @@
        // XComponentSupplier
        virtual ::com::sun::star::uno::Reference< 
::com::sun::star::util::XCloseable > SAL_CALL getComponent(  ) throw 
(::com::sun::star::uno::RuntimeException);
 
+    // XSubDocument
+    virtual ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XComponent > SAL_CALL open(  ) throw 
(::com::sun::star::lang::WrappedTargetException, 
::com::sun::star::uno::RuntimeException);
+    virtual ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XComponent > SAL_CALL openDesign(  ) throw 
(::com::sun::star::lang::WrappedTargetException, 
::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL store(  ) throw 
(::com::sun::star::lang::WrappedTargetException, 
::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Bool SAL_CALL close(  ) throw 
(::com::sun::star::lang::WrappedTargetException, 
::com::sun::star::uno::RuntimeException);
+
 // OPropertySetHelper
        virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
 
@@ -160,6 +168,13 @@
 
     static ::com::sun::star::uno::Sequence< sal_Int8 > 
getDefaultDocumentTypeClassId();
 
+    static ::rtl::OUString GetDocumentServiceFromMediaType( const 
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage
+                                                                               
                        ,const ::rtl::OUString& sEntName 
+                                                                               
                        ,const ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XMultiServiceFactory >& _xORB
+                                                    
,::com::sun::star::uno::Sequence< sal_Int8 >& _rClassId
+                                                                               
                        );
+
+private:
     /** does necessary initializations after our embedded object has been 
switched to ACTIVE
         @param _bOpenedInDesignMode
             determines whether the embedded object has been opened for 
designing it or for data display
@@ -181,11 +196,20 @@
     */
     void impl_removeFrameFromDesktop_throw( const 
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame );
 
-    static ::rtl::OUString GetDocumentServiceFromMediaType( const 
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage
-                                                                               
                        ,const ::rtl::OUString& sEntName 
-                                                                               
                        ,const ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XMultiServiceFactory >& _xORB
-                                                    
,::com::sun::star::uno::Sequence< sal_Int8 >& _rClassId
-                                                                               
                        );
+    /** opens the UI for this sub document
+    */
+    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+        impl_openUI_nolck_throw( bool _bForEditing );
+
+    /** stores our document, if it's already loaded
+    */
+    void
+        impl_store_throw();
+
+    /** closes our document, if it's open
+    */
+    bool
+        impl_close_throw();
 
 protected:
        // OPropertyArrayUsageHelper




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

Reply via email to