Tag: cws_src680_odbmacros2
User: fs      
Date: 2007-12-19 13:27:11+0000
Modified:
   dba/dbaccess/source/ui/browser/dbloader.cxx

Log:
 #i49133# some tweaking

File Changes:

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

File [changed]: dbloader.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/browser/dbloader.cxx?r1=1.31.64.2&r2=1.31.64.3
Delta lines:  +82 -85
---------------------
--- dbloader.cxx        2007-12-19 07:17:36+0000        1.31.64.2
+++ dbloader.cxx        2007-12-19 13:27:08+0000        1.31.64.3
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: dbloader.cxx,v $
  *
- *  $Revision: 1.31.64.2 $
+ *  $Revision: 1.31.64.3 $
  *
- *  last change: $Author: fs $ $Date: 2007/12/19 07:17:36 $
+ *  last change: $Author: fs $ $Date: 2007/12/19 13:27:08 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -82,8 +82,8 @@
 #ifndef _CPPUHELPER_IMPLBASE2_HXX_
 #include <cppuhelper/implbase2.hxx>
 #endif
-#ifndef _COMPHELPER_SEQUENCEASHASHMAP_HXX_
-#include <comphelper/sequenceashashmap.hxx>
+#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX
+#include <comphelper/namedvaluecollection.hxx>
 #endif
 #ifndef _DBU_REGHELPER_HXX_
 #include "dbu_reghelper.hxx"
@@ -97,6 +97,9 @@
 #ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
 #include <com/sun/star/sdbc/XDataSource.hpp>
 #endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
 #include "dbustrings.hrc"
 #endif
@@ -111,6 +114,7 @@
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::frame;
 using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
 using namespace ::com::sun::star::container;
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::registry;
@@ -239,7 +243,7 @@
        m_aArgs         = rArgs;
 
        INetURLObject aParser(rURL);
-       // ich benutze nicht maURL, sondern rURL, denn zwischen dem Constructor 
und diesem Load hier kann sich die ::com::sun::star::util::URL des Objektes
+       // ich benutze nicht maURL, sondern rURL, denn zwischen dem Constructor 
und diesem Load hier kann sich die URL des Objektes
        // schon geaendert haben (zum Beispiel durch Umbenennen)
        Reference< XController >        xController;
        if(aParser.GetMainURL(INetURLObject::DECODE_TO_IURI) == 
URL_COMPONENT_FORMGRIDVIEW)
@@ -254,23 +258,24 @@
                
xController.set(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.ORelationDesign")),UNO_QUERY);
        else if ( aParser.GetMainURL(INetURLObject::DECODE_TO_IURI) == 
URL_COMPONENT_REPORTDESIGN )
        {
-               ::comphelper::SequenceAsHashMap lDescriptor(rArgs);
-               sal_Bool bPreview = 
lDescriptor.getUnpackedValueOrDefault(INFO_PREVIEW, sal_False );
+        ::comphelper::NamedValueCollection aArgs( rArgs );
+               sal_Bool bPreview = aArgs.getOrDefault( "Preview", sal_False );
                if ( bPreview )
-               {
-                       if (rListener.is())
-                               rListener->loadCancelled(this);
+               {   // report designs cannot be previewed
+                       if ( rListener.is() )
+                               rListener->loadCancelled( this );
                        return;
                }
-               Reference< XModel > xModel   = 
lDescriptor.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Model")),
 Reference< XModel >());
-               if ( xModel.is() )
+        Reference< XModel > xReportModel( aArgs.getOrDefault( "Model", 
Reference< XModel >() ) );
+               if ( xReportModel.is() )
                {
-            
xController.set(m_xServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ReportDesign"))),UNO_QUERY);
                       
+            xController.set( m_xServiceFactory->createInstance(
+                ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 
"com.sun.star.sdb.ReportDesign" ) ) ), UNO_QUERY );
                        if ( xController.is() )
                        {
-                               xController->attachModel(xModel);
-                               xModel->connectController( xController );
-                               xModel->setCurrentController(xController);
+                               xController->attachModel( xReportModel );
+                               xReportModel->connectController( xController );
+                               xReportModel->setCurrentController( xController 
);
                        }
                }
        }
@@ -278,49 +283,34 @@
                OSL_ENSURE(0,"wrong dispatch url!");
        
        sal_Bool bSuccess = xController.is();
-       Reference<XModel> xModel;
-       if(bSuccess)
-       {
-               PropertyValue aValue;
-               const PropertyValue* pArg = m_aArgs.getConstArray();
-               const PropertyValue* pArgsEnd = pArg + m_aArgs.getLength();
-
-               for ( ; ( pArg != pArgsEnd ) && !xModel.is(); ++pArg )
+    Reference< XModel > xDatabaseDocument;
+       if ( bSuccess )
                {
-                       if(0 == pArg->Name.compareToAscii(PROPERTY_DATASOURCE))
+        ::comphelper::NamedValueCollection aArgs( m_aArgs );
+        Reference< XDataSource > xDataSource    ( aArgs.getOrDefault( 
"DataSource",       Reference< XDataSource >() ) );
+        ::rtl::OUString          sDataSourceName( aArgs.getOrDefault( 
"DataSourceName",   ::rtl::OUString()          ) );
+        Reference< XConnection > xConnection    ( aArgs.getOrDefault( 
"ActiveConnection", Reference< XConnection >() ) );
+        if ( xDataSource.is() )
                        {
-                               Reference<XDataSource> 
xProp(pArg->Value,UNO_QUERY);
-                               
xModel.set(getDataSourceOrModel(xProp),UNO_QUERY);
-                               break;
+                       xDatabaseDocument.set( getDataSourceOrModel( 
xDataSource ), UNO_QUERY );
                        }
-                       else if(0 == 
pArg->Name.compareToAscii(PROPERTY_DATASOURCENAME))
+        else if ( sDataSourceName.getLength() )
                        {
-                               ::rtl::OUString sDataSource;
-                               pArg->Value >>= sDataSource;
-                
-                               Reference< XNameAccess > 
xDatabaseContext(m_xServiceFactory->createInstance(SERVICE_SDB_DATABASECONTEXT),
 UNO_QUERY);
-                               
xModel.set(getDataSourceOrModel(getDataSourceByName_displayError(xDatabaseContext,sDataSource,NULL,m_xServiceFactory,sal_False)),UNO_QUERY);
-                               break;
+                       xDatabaseDocument.set( getDataSourceOrModel( 
getDataSourceByName_displayError( sDataSourceName, NULL, m_xServiceFactory, 
sal_False ) ), UNO_QUERY );
                        }
-            else if ( 0 == pArg->Name.compareToAscii( 
PROPERTY_ACTIVECONNECTION ) )
+        else if ( xConnection.is() )
             {
-                Reference< XChild > xAsChild( pArg->Value, UNO_QUERY );
+            Reference< XChild > xAsChild( xConnection, UNO_QUERY );
                 if ( xAsChild.is() )
                 {
                     OSL_ENSURE( Reference< XDataSource >( 
xAsChild->getParent(), UNO_QUERY ).is(),
                         "DBContentLoader::load: a connection whose parent is 
no data source?" );
-                                       xModel.set(getDataSourceOrModel( 
xAsChild->getParent() ),UNO_QUERY);
-                }
+                               xDatabaseDocument.set( getDataSourceOrModel( 
xAsChild->getParent() ), UNO_QUERY );
             }
                }
-        OSL_ENSURE( ( xModel.is() && xModel->getURL().getLength() != 0 ),
-            "DBContentLoader::load: unable to find the database document 
belonging to the just loaded component!" );
 
         // init controller
-               if ( bSuccess )
-               {
                        ::vos::OGuard aGuard(Application::GetSolarMutex());
-                       // and initialize
                        try
                        {
                                Reference<XInitialization > 
xIni(xController,UNO_QUERY);
@@ -344,20 +334,27 @@
                        }
                }
 
-       }
-
        // assign controller and frame
-       if (bSuccess && rListener.is())
+       if ( bSuccess )
        {
                if ( xController.is() && rFrame.is() )
                        xController->attachFrame(rFrame);
+
+        if ( xDatabaseDocument.is() )
+        {
                Reference< document::XEventListener > 
xGlobalDocEventBroadcaster(m_xServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.GlobalEventBroadcaster"))),UNO_QUERY_THROW);
-        document::EventObject aEvent( xModel, 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnViewCreated")) );
+            document::EventObject aEvent( xDatabaseDocument, 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnViewCreated")) );
         xGlobalDocEventBroadcaster->notifyEvent(aEvent);
-               rListener->loadFinished(this);
+            // TODO: is this correct? The newly created view is not a view for 
the database document, at least not in
+            // the sense that its XController::getModel would return the 
database document
+        }
+
+        if ( rListener.is() )
+                   rListener->loadFinished( this );
        }
-       else if (!bSuccess && rListener.is())
-               rListener->loadCancelled(this);
+       else
+        if ( rListener.is() )
+               rListener->loadCancelled( this );
 }
 
 // -----------------------------------------------------------------------




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

Reply via email to