Tag: cws_dev300_dba31c
User: fs      
Date: 2008-09-06 20:35:11+0000
Modified:
   dba/dbaccess/source/ui/app/AppController.cxx
   dba/dbaccess/source/ui/app/AppController.hxx
   dba/dbaccess/source/ui/app/AppControllerDnD.cxx
   dba/dbaccess/source/ui/app/AppControllerGen.cxx
   dba/dbaccess/source/ui/app/makefile.mk

Log:
 #i91830# outsourced the handling of sub components into a dedicated class 
(which also fixes the bug which triggered this re-factoring)

File Changes:

Directory: /dba/dbaccess/source/ui/app/
=======================================

File [changed]: AppController.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppController.cxx?r1=1.65.2.2&r2=1.65.2.3
Delta lines:  +31 -87
---------------------
--- AppController.cxx   2008-09-03 12:04:00+0000        1.65.2.2
+++ AppController.cxx   2008-09-06 20:35:08+0000        1.65.2.3
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: AppController.cxx,v $
- * $Revision: 1.65.2.2 $
+ * $Revision: 1.65.2.3 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -34,6 +34,7 @@
 #include "AppController.hxx"
 #include "dbustrings.hrc"
 #include "advancedsettingsdlg.hxx"
+#include "subcomponentmanager.hxx"
 
 /** === begin UNO includes === **/
 #include <com/sun/star/beans/NamedValue.hpp>
@@ -404,7 +405,8 @@
 //--------------------------------------------------------------------
 OApplicationController::OApplicationController(const Reference< 
XMultiServiceFactory >& _rxORB)
        :OApplicationController_CBASE( _rxORB )
-    ,m_aContextMenuInterceptors( m_aMutex )
+    ,m_aContextMenuInterceptors( getMutex() )
+    ,m_pSubComponentManager( new SubComponentManager( getSharedMutex() ) )
     ,m_aTableCopyHelper(this)
        ,m_pClipbordNotifier(NULL)
        ,m_nAsyncDrop(0)
@@ -414,7 +416,7 @@
        ,m_eCurrentType(E_NONE)
        ,m_bNeedToReconnect(sal_False)
     ,m_bSuspended( sal_False )
-    ,m_pSelectionNotifier( new SelectionNotifier( m_aMutex, *this ) )
+    ,m_pSelectionNotifier( new SelectionNotifier( getMutex(), *this ) )
 {
     DBG_CTOR(OApplicationController,NULL);
 
@@ -469,8 +471,7 @@
 
        
::std::for_each(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),XContainerFunctor(this));
        m_aCurrentContainers.clear();
-    m_aSpecialSubFrames.clear();
-       m_aDocuments.clear();
+    m_pSubComponentManager->disposing();
     m_pSelectionNotifier->disposing();
 
        if ( getView() )
@@ -588,7 +589,7 @@
 //--------------------------------------------------------------------
 void SAL_CALL OApplicationController::disposing(const EventObject& _rSource) 
throw( RuntimeException )
 {
-    ::osl::MutexGuard aGuard(m_aMutex);
+    ::osl::MutexGuard aGuard( getMutex() );
        Reference<XConnection> xCon(_rSource.Source, UNO_QUERY);
        if ( xCon.is() )
        {
@@ -614,22 +615,7 @@
        }
        else
        {
-               Reference<XComponent> xComp(_rSource.Source,UNO_QUERY);
-               Reference<XContainer> xContainer(_rSource.Source,UNO_QUERY);
-               if ( xComp.is() )
-               {
-                       TDocuments::iterator aFind = 
::std::find_if(m_aDocuments.begin(),m_aDocuments.end(),
-                               
::std::compose1(::std::bind2nd(::std::equal_to<Reference<XComponent> 
>(),xComp),::std::select1st<TDocuments::value_type>()));
-                       if ( aFind != m_aDocuments.end() )
-                               m_aDocuments.erase(aFind);
-
-            TFrames::iterator aFind2 = 
::std::find_if(m_aSpecialSubFrames.begin(),m_aSpecialSubFrames.end(),
-                               
::std::compose1(::std::bind2nd(::std::equal_to<Reference<XComponent> >(),xComp),
-                    
::std::compose1(::std::select2nd<TTypeFrame>(),::std::select2nd<TFrames::value_type>())));
-                       if ( aFind2 != m_aSpecialSubFrames.end() )
-                               m_aSpecialSubFrames.erase(aFind2);
-            
-               }
+               Reference<XContainer> xContainer( _rSource.Source, UNO_QUERY );
                if ( xContainer.is() )
                {
                        TContainerVector::iterator aFind = 
::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer);
@@ -643,7 +629,7 @@
 sal_Bool SAL_CALL OApplicationController::suspend(sal_Bool bSuspend) throw( 
RuntimeException )
 {
     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
-    ::osl::MutexGuard aGuard(m_aMutex);
+    ::osl::MutexGuard aGuard( getMutex() );
 
     if ( getView() && getView()->IsInModalMode() )
         return sal_False;
@@ -1125,7 +1111,7 @@
 void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< 
PropertyValue >& aArgs)
 {
        ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
 
     if ( isUserDefinedFeature( _nId ) )
     {
@@ -1400,7 +1386,7 @@
 
                         Reference< XDataSource > xDataSource( m_xDataSource, 
UNO_QUERY );
                                                Reference< XComponent > 
xComponent( aDesigner.createNew( xDataSource ), UNO_QUERY );
-                                               addDocumentListener( 
xComponent, NULL );
+                        onDocumentOpened( ::rtl::OUString(), E_QUERY, 
E_OPEN_DESIGN, xComponent, NULL );
                                        }
                                }
                                break;
@@ -1441,18 +1427,17 @@
                                InvalidateAll();
                                break;
                        case SID_DB_APP_DSRELDESIGN:
-                if ( 
!impl_activateSubFrame_throw(::rtl::OUString(),SID_DB_APP_DSRELDESIGN,E_OPEN_DESIGN)
 )
+                if ( !m_pSubComponentManager->activateSubFrame( 
::rtl::OUString(), SID_DB_APP_DSRELDESIGN, E_OPEN_DESIGN ) )
                 {
                                    SharedConnection xConnection( 
ensureConnection() );
                                    if ( xConnection.is() )
                                    {
                                            RelationDesigner aDesigner( 
getORB(), this, m_aCurrentFrame.getFrame() );
+
                         Reference< XDataSource > xDataSource( m_xDataSource, 
UNO_QUERY );
                                            Reference< XComponent > xComponent( 
aDesigner.createNew( xDataSource ), UNO_QUERY );
-                                           addDocumentListener( xComponent, 
NULL );
-                        
m_aSpecialSubFrames.insert(TFrames::value_type(::rtl::OUString(),
-                            
TTypeFrame(TTypeOpenMode(SID_DB_APP_DSRELDESIGN,E_OPEN_DESIGN),xComponent)));
-                                   } // if ( xConnection.is() )
+                        onDocumentOpened( ::rtl::OUString(), 
SID_DB_APP_DSRELDESIGN, E_OPEN_DESIGN, xComponent, NULL );
+                                   }
                 }
                                break;
                        case SID_DB_APP_DSUSERADMIN:
@@ -1651,7 +1636,7 @@
 void SAL_CALL OApplicationController::elementInserted( const ContainerEvent& 
_rEvent ) throw(RuntimeException)
 {
        ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
 
        Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
        if ( 
::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) 
!= m_aCurrentContainers.end() )
@@ -1687,7 +1672,7 @@
 void SAL_CALL OApplicationController::elementRemoved( const ContainerEvent& 
_rEvent ) throw(RuntimeException)
 {
        ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
 
        Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
        if ( 
::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) 
!= m_aCurrentContainers.end() )
@@ -1721,7 +1706,7 @@
 void SAL_CALL OApplicationController::elementReplaced( const ContainerEvent& 
_rEvent ) throw(RuntimeException)
 {
        ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
 
        Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
        if ( 
::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) 
!= m_aCurrentContainers.end() )
@@ -1946,16 +1931,15 @@
                Reference< XComponent > xDefinition;
                xRet = aHelper->open( _sName, xDefinition, _eOpenMode, 
_rAdditionalArguments );
 
-               addDocumentListener(xRet,xDefinition);
+               onDocumentOpened( _sName, _eType, _eOpenMode, xRet, xDefinition 
);
        }
        break;
 
        case E_QUERY:
        case E_TABLE:
        {
-        if ( !impl_activateSubFrame_throw(_sName,_eType,_eOpenMode) )
+        if ( !m_pSubComponentManager->activateSubFrame( _sName, _eType, 
_eOpenMode ) )
         {
-
                    SharedConnection xConnection( ensureConnection() );
                    if ( !xConnection.is() )
                 break;
@@ -1992,9 +1976,7 @@
                    }
 
                    Reference< XComponent > xComponent( 
pDesigner->openExisting( aDataSource, _sName, aArguments.getPropertyValues() ), 
UNO_QUERY );
-                   addDocumentListener( xComponent, NULL );
-            m_aSpecialSubFrames.insert(TFrames::value_type(_sName,
-                            
TTypeFrame(TTypeOpenMode(_eType,_eOpenMode),xComponent)));
+               onDocumentOpened( _sName, _eType, _eOpenMode, xComponent, NULL 
);
         }
        }
        break;
@@ -2041,7 +2023,7 @@
                                else
                                        xComponent = 
aHelper->newFormWithPilot(xDefinition,nCommandType,sName);
 
-                               addDocumentListener(xComponent,xDefinition);
+                onDocumentOpened( ::rtl::OUString(), _eType, E_OPEN_DESIGN, 
xComponent, xDefinition );
                        }
         }
         break;
@@ -2051,12 +2033,13 @@
                    ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = 
getDocumentsAccess(_eType);
             if ( aHelper->isConnected() )
             {
-                Reference< XComponent > xComponent,xDefinition;
+                Reference< XComponent > xComponent;
                        if ( E_QUERY == _eType )
                                xComponent = aHelper->newQueryWithPilot();
                        else
                                xComponent = aHelper->newTableWithPilot();
-                addDocumentListener(xComponent,xDefinition);
+
+                onDocumentOpened( ::rtl::OUString(), _eType, E_OPEN_DESIGN, 
xComponent, NULL );
                    }
                }
                break;
@@ -2082,7 +2065,7 @@
                     sal_Int32 nCommandType = -1;
                     const ::rtl::OUString 
sName(getCurrentlySelectedName(nCommandType));
                     xComponent = aHelper->newDocument(_eType == E_FORM ? 
ID_FORM_NEW_TEXT : ID_REPORT_NEW_TEXT,xDefinition,nCommandType,sName);
-                                   addDocumentListener(xComponent,xDefinition);
+                    onDocumentOpened( ::rtl::OUString(), _eType, 
E_OPEN_DESIGN, xComponent, xDefinition );
                 }
                        }
                        break;
@@ -2104,7 +2087,7 @@
 
                     Reference< XDataSource > xDataSource( m_xDataSource, 
UNO_QUERY );
                                        Reference< XComponent > xComponent( 
pDesigner->createNew( xDataSource ), UNO_QUERY );
-                                       addDocumentListener(xComponent,NULL);
+                                       onDocumentOpened( ::rtl::OUString(), 
_eType, E_OPEN_DESIGN, xComponent, NULL );
                                }
                        }
                        break;
@@ -2138,7 +2121,7 @@
 void OApplicationController::renameEntry()
 {
        ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
 
        OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
        ::std::vector< ::rtl::OUString> aList;
@@ -2766,7 +2749,7 @@
 // 
-----------------------------------------------------------------------------
 sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel 
> & _rxModel) throw( RuntimeException )
 {
-       ::osl::MutexGuard aGuard( m_aMutex );
+       ::osl::MutexGuard aGuard( getMutex() );
     Reference< XOfficeDatabaseDocument > xOfficeDoc( _rxModel, UNO_QUERY );
     if ( !xOfficeDoc.is() && _rxModel.is() )
     {
@@ -2890,7 +2873,7 @@
 ::sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) 
throw (IllegalArgumentException, RuntimeException)
 {
     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
     Sequence< ::rtl::OUString> aSelection;
     if ( !_aSelection.hasValue() || !getView() )
     {
@@ -3018,7 +3001,7 @@
 Any SAL_CALL OApplicationController::getSelection(  ) throw (RuntimeException)
 {
     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
-    ::osl::MutexGuard aGuard(m_aMutex);
+    ::osl::MutexGuard aGuard( getMutex() );
 
     Sequence< NamedDatabaseObject > aCurrentSelection;
     const ElementType eType( getContainer()->getElementType() );
@@ -3071,45 +3054,6 @@
     }
 }
 
-// 
-----------------------------------------------------------------------------
-bool OApplicationController::impl_activateSubFrame_throw(const 
::rtl::OUString& _sName,const sal_Int32 _nKind,const ElementOpenMode 
_eOpenMode) const
-{
-    bool bFound = false;
-    TFrames::const_iterator aFind = m_aSpecialSubFrames.find(_sName);
-    for(;aFind != m_aSpecialSubFrames.end();++aFind)
-    {
-        if ( aFind->second.first.first == _nKind && aFind->second.first.second 
== _eOpenMode )
-        {
-            const Reference< XFrame> xFrame(aFind->second.second,UNO_QUERY);
-            if ( xFrame.is() )
-            {
-                Reference< awt::XTopWindow> 
xTopWindow(xFrame->getContainerWindow(),UNO_QUERY);
-                if ( xTopWindow.is() )
-                    xTopWindow->toFront();
-                bFound = true;
-            }
-            break;
-        } // if ( aFind->second.first.first == _nKind && 
aFind->second.first.second == _eOpenMode )
-    }
-    return bFound;
-}
-// 
-----------------------------------------------------------------------------
-void OApplicationController::impl_deActivateSubFrame_throw(const 
::rtl::OUString& _sName,const sal_Int32 _nKind)
-{
-    TFrames aCopy = m_aSpecialSubFrames;
-    TFrames::iterator aFind = aCopy.find(_sName);
-    for(;aFind != aCopy.end();++aFind)
-    {
-        if ( aFind->second.first.first == _nKind )
-        {
-            Reference< XFrame> xFrame(aFind->second.second,UNO_QUERY);
-            if ( xFrame.is() )
-            {
-                ::comphelper::disposeComponent(xFrame);
-            }
-        } // if ( aFind->second.first.first == _nKind && 
aFind->second.first.second == _eOpenMode )
-    }
-}
 //........................................................................
 }      // namespace dbaui
 //........................................................................

File [changed]: AppController.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppController.hxx?r1=1.32.2.1&r2=1.32.2.2
Delta lines:  +14 -29
---------------------
--- AppController.hxx   2008-09-03 12:04:01+0000        1.32.2.1
+++ AppController.hxx   2008-09-06 20:35:08+0000        1.32.2.2
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: AppController.hxx,v $
- * $Revision: 1.32.2.1 $
+ * $Revision: 1.32.2.2 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -76,6 +76,9 @@
 namespace dbaui
 {
 //........................................................................
+
+    class SubComponentManager;
+
        //====================================================================
        //= OApplicationController
        //====================================================================
@@ -101,13 +104,6 @@
         typedef ::com::sun::star::uno::Reference< 
::com::sun::star::container::XContainer > TContainer;
                typedef ::std::vector< TContainer >                             
                    TContainerVector;
 
-        typedef ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XComponent >      TComponent;
-               typedef ::std::map< TComponent, TComponent >                    
                    TDocuments;
-
-        typedef ::std::pair< sal_Int32, ElementOpenMode >                      
             TTypeOpenMode;
-        typedef ::std::pair< TTypeOpenMode , TComponent >                      
             TTypeFrame;
-        typedef ::std::multimap< ::rtl::OUString, TTypeFrame >                 
             TFrames;
-
        private:
 
         OTableCopyHelper::DropDescriptor                       m_aAsyncDrop;
@@ -130,8 +126,8 @@
         ModelControllerConnector
                                 m_aModelConnector;
                TContainerVector                m_aCurrentContainers;       // 
the containers where we are listener on
-               TDocuments                              m_aDocuments;
-        TFrames                 m_aSpecialSubFrames;        // contains the 
query, table and relation frame
+        ::rtl::Reference< SubComponentManager >
+                                m_pSubComponentManager;
                ODsnTypeCollection              m_aTypeCollection;
         OTableCopyHelper        m_aTableCopyHelper;
                TransferableClipboardListener*
@@ -155,18 +151,6 @@
                OApplicationView*               getContainer() const;
 
 
-        /** activates the current table, query or relation design frame when 
existing
-            @param  _sName  the name of the component
-            @param  _nKind  the kind of the component
-        */
-        bool impl_activateSubFrame_throw(const ::rtl::OUString& _sName,const 
sal_Int32 _nKind,const ElementOpenMode _eOpenMode) const;
-
-        /** deactivates the current table or query  frame when existing
-            @param  _sName  the name of the component
-            @param  _nKind  the kind of the component
-        */
-        void impl_deActivateSubFrame_throw(const ::rtl::OUString& _sName,const 
sal_Int32 _nKind);
-
                /** returns the database name
                        @return
                                the database name
@@ -358,14 +342,15 @@
                */
                void askToReconnect();
 
-               /** add event listener and remember the document
-                       @param  _xDocument
-                               the new document, may be <NULL/>
-                       @param  _xDefinition
-                               The defintion object.
+               /** remember a newly opened sub document for later access
                */
-               void addDocumentListener(const 
::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& 
_xDocument,
-                                                               const 
::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& 
_xDefinition);
+               void onDocumentOpened(
+            const ::rtl::OUString&  _rName,
+            const sal_Int32         _nType,
+            const ElementOpenMode   _eMode,
+            const ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XComponent >& _xDocument,
+                       const ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XComponent >& _xDefinition
+        );
 
                /** Inserts a new object into the hierachy given be the type.
                        @param  _eType

File [changed]: AppControllerDnD.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppControllerDnD.cxx?r1=1.29&r2=1.29.2.1
Delta lines:  +21 -15
---------------------
--- AppControllerDnD.cxx        2008-08-19 09:55:00+0000        1.29
+++ AppControllerDnD.cxx        2008-09-06 20:35:09+0000        1.29.2.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: AppControllerDnD.cxx,v $
- * $Revision: 1.29 $
+ * $Revision: 1.29.2.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -221,6 +221,7 @@
 #ifndef _VOS_MUTEX_HXX_
 #include <vos/mutex.hxx>
 #endif
+#include "subcomponentmanager.hxx"
 
 //........................................................................
 namespace dbaui
@@ -263,7 +264,11 @@
                                sal_Int32 nResult = RET_YES;
                                if ( bConfirm )
                                        nResult = 
::dbaui::askForUserAction(getView(),STR_TITLE_CONFIRM_DELETION 
,STR_QUERY_DELETE_TABLE,_rList.size() > 1 && (aIter+1) != 
_rList.end(),sTableName);
-                               if ( (RET_YES == nResult) || (RET_ALL == 
nResult) )
+
+                bool bUserConfirmedDelete =
+                            ( RET_YES == nResult )
+                        ||  ( RET_ALL == nResult );
+                               if ( bUserConfirmedDelete && 
m_pSubComponentManager->closeSubFrames( sTableName, E_TABLE ) )
                                {
                                        SQLExceptionInfo aErrorInfo;
                                        try
@@ -286,7 +291,6 @@
                                                                }
                                                        }
                                                }
-                        impl_deActivateSubFrame_throw(sTableName,E_TABLE);
                                        }
                                        catch(SQLContext& e) { aErrorInfo = e; }
                                        catch(SQLWarning& e) { aErrorInfo = e; }
@@ -370,8 +374,13 @@
 
             bool bSuccess = false;
 
-            if ( ( eResult == svtools::QUERYDELETE_ALL ) ||
-                                ( eResult == svtools::QUERYDELETE_YES ) )
+            bool bUserConfirmedDelete =
+                        ( eResult == svtools::QUERYDELETE_ALL )
+                    ||  ( eResult == svtools::QUERYDELETE_YES );
+
+            if  (   bUserConfirmedDelete
+                &&  (   ( _eType == E_QUERY ) ? 
m_pSubComponentManager->closeSubFrames( *aThisRound, _eType ) : true )
+                )
                        {
                                try
                                {
@@ -380,9 +389,6 @@
                                        else
                                                xNames->removeByName( 
*aThisRound );
 
-                    if ( _eType == E_QUERY )
-                        impl_deActivateSubFrame_throw(*aThisRound,_eType);
-
                     bSuccess = true;
 
                     // now that we removed the element, care for all it's 
child elements
@@ -438,7 +444,7 @@
 void OApplicationController::deleteEntries()
 {
        ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
 
        if ( getContainer() )
        {
@@ -468,7 +474,7 @@
 const SharedConnection& OApplicationController::ensureConnection()
 {
        ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
 
     if ( !m_xDataSourceConnection.is() )
     {
@@ -562,7 +568,7 @@
 void OApplicationController::getSelectionElementNames(::std::vector< 
::rtl::OUString>& _rNames) const
 {
        ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
 
        OSL_ENSURE(getContainer(),"View isn't valid! -> GPF");
 
@@ -595,7 +601,7 @@
        try
        {
                ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
-               ::osl::MutexGuard aGuard(m_aMutex);
+               ::osl::MutexGuard aGuard( getMutex() );
 
                ElementType eType = getContainer()->getElementType();
                TransferableHelper* pData = NULL;
@@ -865,7 +871,7 @@
 sal_Bool 
OApplicationController::copyTagTable(OTableCopyHelper::DropDescriptor& _rDesc, 
sal_Bool _bCheck)
 {
        // first get the dest connection
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
 
     SharedConnection xConnection( ensureConnection() );
        if ( !xConnection.is() )
@@ -878,7 +884,7 @@
 {
        m_nAsyncDrop = 0;
        ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
 
 
        if ( m_aAsyncDrop.nType == E_TABLE )

File [changed]: AppControllerGen.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppControllerGen.cxx?r1=1.37&r2=1.37.38.1
Delta lines:  +34 -121
----------------------
--- AppControllerGen.cxx        2008-06-25 12:36:04+0000        1.37
+++ AppControllerGen.cxx        2008-09-06 20:35:09+0000        1.37.38.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: AppControllerGen.cxx,v $
- * $Revision: 1.37 $
+ * $Revision: 1.37.38.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -40,6 +40,7 @@
 #include "defaultobjectnamecheck.hxx"
 #include "dlgsave.hxx"
 #include "UITools.hxx"
+#include "subcomponentmanager.hxx"
 
 /** === begin UNO includes === **/
 #include <com/sun/star/container/XChild.hpp>
@@ -216,7 +217,7 @@
        try
        {
                ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
-               ::osl::MutexGuard aGuard(m_aMutex);
+               ::osl::MutexGuard aGuard( getMutex() );
                WaitObject aWO(getView());
 
                Sequence< Any > aArgs(3);
@@ -306,7 +307,7 @@
 void SAL_CALL OApplicationController::propertyChange( const 
PropertyChangeEvent& evt ) throw (RuntimeException)
 {
        ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
        if ( evt.PropertyName == PROPERTY_USER )
     {
         m_bNeedToReconnect = sal_True;
@@ -347,7 +348,7 @@
 // 
-----------------------------------------------------------------------------
 Reference< XDataSource > SAL_CALL OApplicationController::getDataSource() 
throw (RuntimeException)
 {
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
     Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
     return xDataSource;
 }
@@ -355,7 +356,7 @@
 // 
-----------------------------------------------------------------------------
 Reference< XWindow > SAL_CALL 
OApplicationController::getApplicationMainWindow() throw (RuntimeException)
 {
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
     Reference< XFrame > xFrame( getFrame(), UNO_QUERY_THROW );
     Reference< XWindow > xWindow( xFrame->getContainerWindow(), 
UNO_QUERY_THROW );
     return xWindow;
@@ -364,23 +365,20 @@
 // 
-----------------------------------------------------------------------------
 Sequence< Reference< XComponent > > SAL_CALL 
OApplicationController::getSubComponents() throw (RuntimeException)
 {
-       ::osl::MutexGuard aGuard(m_aMutex);
-    Sequence< Reference< XComponent > > aComponents( m_aDocuments.size() );
-    ::std::transform( m_aDocuments.begin(), m_aDocuments.end(), 
aComponents.getArray(), ::std::select1st< TDocuments::value_type >() );
-    return aComponents;
+    return m_pSubComponentManager->getSubComponents();
 }
 
 // 
-----------------------------------------------------------------------------
 Reference< XConnection > SAL_CALL 
OApplicationController::getActiveConnection() throw (RuntimeException)
 {
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
     return m_xDataSourceConnection.getTyped();
 }
 
 // 
-----------------------------------------------------------------------------
 ::sal_Bool SAL_CALL OApplicationController::isConnected(  ) throw 
(RuntimeException)
 {
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
     return m_xDataSourceConnection.is();
 }
 
@@ -388,110 +386,19 @@
 ::sal_Bool SAL_CALL OApplicationController::connect(  ) throw 
(RuntimeException)
 {
        ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
 
     ensureConnection();
     return isConnected();
 }
 
 // 
-----------------------------------------------------------------------------
-namespace
-{
-    static Reference< XController > lcl_getController( const 
OApplicationController::TDocuments::iterator& _docPos )
-    {
-        Reference< XController > xController;
-
-        Reference< XComponent > xComponent( _docPos->first );
-           Reference< XModel > xModel( xComponent, UNO_QUERY );
-           if ( xModel.is() )
-                   xController = xModel->getCurrentController();
-           else
-           {
-                   xController.set( xComponent, UNO_QUERY );
-                   if ( !xController.is() )
-                   {
-                           Reference<XFrame> xFrame( xComponent, UNO_QUERY );
-                           if ( xFrame.is() )
-                                   xController = xFrame->getController();
-                   }
-           }
-        return xController;
-    }
-}
-
-// 
-----------------------------------------------------------------------------
 ::sal_Bool SAL_CALL OApplicationController::closeSubComponents(  ) throw 
(RuntimeException)
 {
-       ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
-       ::osl::MutexGuard aGuard( m_aMutex );
-
-       try
-       {
-        typedef ::std::vector< Reference< XComponent > > ComponentArray;
-        ComponentArray aClosedComponents;
-
-        TDocuments aDocuments( m_aDocuments );
-               for (   TDocuments::iterator doc = aDocuments.begin();
-                doc != aDocuments.end();
-                ++doc
-            )
-        {
-            Reference< XController > xController( lcl_getController( doc ) );
-            OSL_ENSURE( xController.is(), 
"OApplicationController::closeSubComponents: did not find the sub controller!" 
);
-
-            // suspend the controller in the document
-            if  (   !xController.is()
-                ||  !xController->suspend( sal_True )
-                )
-                // break complete operation, no sense in continueing
-                break;
-
-            // revoke event listener
-            Reference< XComponent > xDocument = doc->first;
-            if ( xDocument.is() )
-                xDocument->removeEventListener( static_cast< 
XFrameActionListener* >( this ) );
-
-            bool bClosedSubDoc = false;
-            try
-            {
-                Reference< XCloseable > xCloseable( xController->getFrame(), 
UNO_QUERY_THROW );
-                xCloseable->close( sal_True );
-                bClosedSubDoc = true;
-            }
-            catch( const Exception& )
-            {
-                DBG_UNHANDLED_EXCEPTION();
-            }
-
-            if ( !bClosedSubDoc )
-                // no sense in continueing with the other docs
-                break;
-
-            aClosedComponents.push_back( doc->first );
-        }
-
-        // now remove all the components which we could successfully close
-        // (this might be none, or all, or something inbetween) from 
m_aDocuments
-        for (   ComponentArray::const_iterator comp = 
aClosedComponents.begin();
-                comp != aClosedComponents.end();
-                ++comp
-            )
-        {
-            TDocuments::iterator pos = m_aDocuments.find( *comp );
-            OSL_ENSURE( pos != m_aDocuments.end(),
-                "OApplicationController::closeSubComponents: closed a 
component which doesn't exist anymore!" );
-            if ( pos !=m_aDocuments.end() )
-                m_aDocuments.erase( pos );
-        }
-       }
-       catch ( const Exception& )
-       {
-        DBG_UNHANDLED_EXCEPTION();
-       }
-
-       return m_aDocuments.empty();
+    return m_pSubComponentManager->closeSubComponents();
 }
 
+
 // 
-----------------------------------------------------------------------------
 namespace
 {
@@ -569,7 +476,7 @@
     const ::rtl::OUString& _ObjectName, ::sal_Bool _ForEditing, const 
Sequence< PropertyValue >& _Arguments ) throw (IllegalArgumentException, 
NoSuchElementException, SQLException, RuntimeException)
 {
        ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
-       ::osl::MutexGuard aGuard( m_aMutex );
+       ::osl::MutexGuard aGuard( getMutex() );
 
     impl_validateObjectTypeAndName_throw( _ObjectType, _ObjectName );
 
@@ -601,7 +508,7 @@
 void OApplicationController::previewChanged( sal_Int32 _nMode )
 {
        ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
-       ::osl::MutexGuard aGuard(m_aMutex);
+       ::osl::MutexGuard aGuard( getMutex() );
 
        if ( m_xDataSource.is() && !isDataSourceReadOnly() )
        {
@@ -645,7 +552,7 @@
        {
                m_bNeedToReconnect = sal_False;
                sal_Bool bClear = sal_True;
-               if ( !m_aDocuments.empty() )
+               if ( !m_pSubComponentManager->empty() )
                {
                        QueryBox aQry(getView(), ModuleRes(APP_CLOSEDOCUMENTS));
                        switch (aQry.Execute())
@@ -677,21 +584,27 @@
 }
 
 // 
-----------------------------------------------------------------------------
-void OApplicationController::addDocumentListener(const Reference< XComponent 
>& _xDocument,const Reference< XComponent >& _xDefintion)
+void OApplicationController::onDocumentOpened( const ::rtl::OUString& _rName, 
const sal_Int32 _nType,
+        const ElementOpenMode _eMode, const Reference< XComponent >& 
_xDocument, const Reference< XComponent >& _rxDefinition )
 {
-       if ( _xDocument.is() )
-       {
+    OSL_PRECOND( _xDocument.is(), "OApplicationController::onDocumentOpened: 
illegal document!" );
+       if ( !_xDocument.is() )
+        return;
+
         try
         {
-                   m_aDocuments[_xDocument] = _xDefintion;
-                   
_xDocument->addEventListener(static_cast<XFrameActionListener*>(this));
-            Reference<XPropertySet> xProp(_xDefintion,UNO_QUERY_THROW);
-            if ( xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) 
)
-                
xProp->addPropertyChangeListener(PROPERTY_NAME,static_cast<XPropertyChangeListener*>(this));
-        }
-               catch(Exception&)
+        m_pSubComponentManager->onSubComponentOpened( _rName, _nType, _eMode, 
_xDocument );
+
+        if ( _rxDefinition.is() )
                {
+            Reference< XPropertySet > xProp( _rxDefinition, UNO_QUERY_THROW );
+            Reference< XPropertySetInfo > xPSI( xProp->getPropertySetInfo(), 
UNO_SET_THROW );
+            xProp->addPropertyChangeListener( PROPERTY_NAME, static_cast< 
XPropertyChangeListener* >( this ) );
+        }
                }
+       catch( const Exception& )
+       {
+        DBG_UNHANDLED_EXCEPTION();
        }
 }
 // 
-----------------------------------------------------------------------------

File [changed]: makefile.mk
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/makefile.mk?r1=1.5&r2=1.5.80.1
Delta lines:  +4 -3
-------------------
--- makefile.mk 2008-04-10 14:03:24+0000        1.5
+++ makefile.mk 2008-09-06 20:35:09+0000        1.5.80.1
@@ -8,7 +8,7 @@
 #
 # $RCSfile: makefile.mk,v $
 #
-# $Revision: 1.5 $
+# $Revision: 1.5.80.1 $
 #
 # This file is part of OpenOffice.org.
 #
@@ -51,7 +51,8 @@
                        $(SLO)$/AppDetailPageHelper.obj \
                        $(SLO)$/AppSwapWindow.obj               \
                        $(SLO)$/AppTitleWindow.obj              \
-                       $(SLO)$/AppView.obj
+                       $(SLO)$/AppView.obj             \
+                       $(SLO)$/subcomponentmanager.obj
                        
 
 SLOFILES =\




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

Reply via email to