User: hr      
Date: 05/04/11 03:05:04

Modified:
 /dba/dbaccess/source/ui/browser/
  unodatbr.cxx

Log:
 INTEGRATION: CWS dba32 (1.169.14); FILE MERGED
 2005/04/05 13:03:13 fs 1.169.14.1: #i46409# more intelligent handling of 
connections, properly determine connection ownership

File Changes:

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

File [changed]: unodatbr.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/browser/unodatbr.cxx?r1=1.169&r2=1.170
Delta lines:  +51 -25
---------------------
--- unodatbr.cxx        18 Mar 2005 10:08:40 -0000      1.169
+++ unodatbr.cxx        11 Apr 2005 10:05:01 -0000      1.170
@@ -3053,10 +3053,7 @@
                else if (0 == aValue.Name.compareToAscii(PROPERTY_COMMAND))
                        aValue.Value >>= sInitialCommand;
                else if (0 == 
aValue.Name.compareToAscii(PROPERTY_ACTIVECONNECTION))
-               {
                        xConnection.set(aValue.Value,UNO_QUERY);
-                       m_bOwnConnection = !xConnection.is();
-               }
                else if (0 == 
aValue.Name.compareToAscii(PROPERTY_UPDATE_CATALOGNAME))
                        aValue.Value >>= aCatalogName;
                else if (0 == 
aValue.Name.compareToAscii(PROPERTY_UPDATE_SCHEMANAME))
@@ -3149,37 +3146,66 @@
                }
        }
 
-
-       Reference<XConnection> xEmbeddedConnection;
-       sal_Bool bEmbedded = sal_False;
+    // are we loaded into a (sub)frame of an embedded document (i.e. a form 
belonging to a database
+    // document)?
+       sal_Bool bSubFrameOfEmbeddedDocument = sal_False;
        if ( xFrame.is() )
        {
                Reference<XFramesSupplier> xSup = xFrame->getCreator();
                Reference<XController> xCont = xSup.is() ? 
xSup->getController() : Reference<XController>();
 
-               if ( xCont.is() && 
::dbtools::isEmbeddedInDatabase(xCont->getModel(),xEmbeddedConnection) && 
xEmbeddedConnection.is() )
-               {
-                       xConnection = xEmbeddedConnection;
-                       bEmbedded = sal_True;
-               }
+        bSubFrameOfEmbeddedDocument = xCont.is() && 
::dbtools::isEmbeddedInDatabase( xCont->getModel(), xConnection );
        }
 
+    // if we have a connection at this point, it was either passed from 
outside, our
+    // determined from a outer DB document. In both cases, do not dispose it 
later on.
     if ( xConnection.is() )
-        startConnectionListening(xConnection);
-       Reference<XChild> xChild(xConnection,UNO_QUERY);
-       if ( !sInitialDataSourceName.getLength() && xChild.is() )
+        m_bOwnConnection = sal_False;
+
+    // should we display all registered databases in the left hand side tree?
+    // or only *one* special?
+    sal_Bool bLimitedTreeEntries = sal_False;
+    // if we're part of a frame which is a secondary frame of a database 
document, then only
+    // display the database for this document, not all registered ones
+    bLimitedTreeEntries |= bSubFrameOfEmbeddedDocument;
+    // if the tree view is not to be displayed at all, then only display the 
data source
+    // which was given as initial selection
+    bLimitedTreeEntries |= ( m_bEnableBrowser != sal_True );
+
+    if ( bLimitedTreeEntries )
+    {
+        if ( xConnection.is() )
+        {
+            startConnectionListening( xConnection );
+
+            // if no initial name was given, try to obtain one from the data 
source
+            if ( !sInitialDataSourceName.getLength() )
        {
-               Reference<XPropertySet> xProp(xChild->getParent(),UNO_QUERY);
-               if ( xProp.is() && (xProp->getPropertyValue(PROPERTY_NAME) >>= 
sInitialDataSourceName) && sInitialDataSourceName.getLength() && bEmbedded )
+                   Reference< XChild > xChild( xConnection, UNO_QUERY );
+                       Reference< XPropertySet > xDataSourceProperties;
+                if ( xChild.is() )
+                    xDataSourceProperties = xDataSourceProperties.query( 
xChild->getParent() );
+                       if ( xDataSourceProperties.is() )
                {
+                    try
+                    {
+                        OSL_VERIFY( xDataSourceProperties->getPropertyValue( 
PROPERTY_NAME ) >>= sInitialDataSourceName );
+                    }
+                    catch( const Exception& )
+                    {
+                           OSL_ENSURE( sal_False, 
"SbaTableQueryBrowser::impl_initialize: a connection parent which does not have 
a 'Name'!??" );
+                    }
+                }
+            }
+        }
+
                        Image aDBImage, aQueriesImage, aTablesImage;
                        String sQueriesName, sTablesName;
 
-                       implAddDatasource(sInitialDataSourceName, aDBImage, 
sQueriesName, aQueriesImage, sTablesName, aTablesImage,xConnection);
-                       
m_pTreeView->getListBox()->Expand(m_pTreeView->getListBox()->First());
+               implAddDatasource( sInitialDataSourceName, aDBImage, 
sQueriesName, aQueriesImage, sTablesName, aTablesImage, xConnection );
+               m_pTreeView->getListBox()->Expand( 
m_pTreeView->getListBox()->First() );
                }
-       }
-       if ( !bEmbedded )
+    else
                initializeTreeModel();
 
        if ( implSelect(sInitialDataSourceName, sInitialCommand, 
nInitialDisplayCommandType, bEsacpeProcessing,xConnection,sal_True) )




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

Reply via email to