summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/browser/unodatbr.cxx
diff options
context:
space:
mode:
authorOcke Janssen [oj] <Ocke.Janssen@sun.com>2009-12-17 17:25:59 +0100
committerOcke Janssen [oj] <Ocke.Janssen@sun.com>2009-12-17 17:25:59 +0100
commit01b25b739dccf58edc50a28f4ce74111c50994f9 (patch)
tree1d342abd0c49ce8bdc86b19e22489baeca33888c /dbaccess/source/ui/browser/unodatbr.cxx
parent1806dfd473c3753064d8f5d40e760783912195ab (diff)
parentc88d53d9d3484ba3cb641c2b722c4d4dfcd590fa (diff)
Automated merge with http://hg.services.openoffice.org/cws/dba33e
Diffstat (limited to 'dbaccess/source/ui/browser/unodatbr.cxx')
-rw-r--r--dbaccess/source/ui/browser/unodatbr.cxx142
1 files changed, 107 insertions, 35 deletions
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index b2cfbe04a515..8377edda3017 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -519,6 +519,8 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun::
DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
OSL_ENSURE( pData->xObjectProperties.is(), "SbaTableQueryBrowser::InitializeGridModel: No table available!" );
+ if ( !pData->xObjectProperties.is() )
+ return sal_False;
::rtl::OUString* pStringIter = aProperties.getArray();
Any* pValueIter = aValues.getArray();
@@ -732,7 +734,7 @@ Reference<XPropertySet> getColumnHelper(SvLBoxEntry* _pCurrentlyDisplayed,const
::rtl::OUString aName;
_rxSource->getPropertyValue(PROPERTY_NAME) >>= aName;
if(xNames.is() && xNames->hasByName(aName))
- ::cppu::extractInterface(xRet,xNames->getByName(aName));
+ xRet.set(xNames->getByName(aName),UNO_QUERY);
}
return xRet;
}
@@ -1100,7 +1102,17 @@ SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::rtl::OUString& _rDataS
m_pTreeView->getListBox().Expand(pCommandType);
// look for the object
- pObject = m_pTreeView->getListBox().GetEntryPosByName(_rCommand, pCommandType);
+ ::rtl::OUString sCommand = _rCommand;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ::rtl::OUString sPath = sCommand.getToken( 0, '/', nIndex );
+ pObject = m_pTreeView->getListBox().GetEntryPosByName(sPath, pCommandType);
+ pCommandType = pObject;
+ if (_bExpandAncestors && nIndex >= 0 )
+ m_pTreeView->getListBox().Expand(pCommandType);
+ }
+ while ( nIndex >= 0 );
}
}
}
@@ -1991,7 +2003,7 @@ void SbaTableQueryBrowser::initializeTreeModel()
}
}
// -------------------------------------------------------------------------
-sal_Bool SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAccess,
+void SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAccess,
SvLBoxEntry* _pParent,
EntryType _eEntryType)
{
@@ -2008,34 +2020,39 @@ sal_Bool SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xName
{
if(!m_pTreeView->getListBox().GetEntryPosByName(*pIter,_pParent))
{
+ Reference<XNameAccess> xChild(_xNameAccess->getByName(*pIter),UNO_QUERY);
DBTreeListUserData* pEntryData = new DBTreeListUserData;
pEntryData->eType = _eEntryType;
- implAppendEntry( _pParent, *pIter, pEntryData, _eEntryType );
+ if ( _eEntryType == etQuery && xChild.is() )
+ {
+ pEntryData->eType = etQueryContainer;
+ }
+ implAppendEntry( _pParent, *pIter, pEntryData, pEntryData->eType );
}
}
}
catch(Exception&)
{
DBG_ERROR("SbaTableQueryBrowser::populateTree: could not fill the tree");
- return sal_False;
}
- return sal_True;
}
//------------------------------------------------------------------------------
-void SbaTableQueryBrowser::implAppendEntry( SvLBoxEntry* _pParent, const String& _rName, void* _pUserData, EntryType _eEntryType )
+SvLBoxEntry* SbaTableQueryBrowser::implAppendEntry( SvLBoxEntry* _pParent, const String& _rName, void* _pUserData, EntryType _eEntryType )
{
::std::auto_ptr< ImageProvider > pImageProvider( getImageProviderFor( _pParent ) );
Image aImage, aImageHC;
pImageProvider->getImages( _rName, getDatabaseObjectType( _eEntryType ), aImage, aImageHC );
- SvLBoxEntry* pNewEntry = m_pTreeView->getListBox().InsertEntry( _rName, _pParent, sal_False, LIST_APPEND, _pUserData );
+ SvLBoxEntry* pNewEntry = m_pTreeView->getListBox().InsertEntry( _rName, _pParent, _eEntryType == etQueryContainer , LIST_APPEND, _pUserData );
m_pTreeView->getListBox().SetExpandedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL );
m_pTreeView->getListBox().SetCollapsedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL );
m_pTreeView->getListBox().SetExpandedEntryBmp( pNewEntry, aImageHC, BMP_COLOR_HIGHCONTRAST );
m_pTreeView->getListBox().SetCollapsedEntryBmp( pNewEntry, aImageHC, BMP_COLOR_HIGHCONTRAST );
+
+ return pNewEntry;
}
//------------------------------------------------------------------------------
@@ -2166,29 +2183,54 @@ sal_Bool SbaTableQueryBrowser::ensureEntryObject( SvLBoxEntry* _pEntry )
break;
}
- try
{
- Reference< XQueryDefinitionsSupplier > xQuerySup;
- m_xDatabaseContext->getByName( getDataSourceAcessor( pDataSourceEntry ) ) >>= xQuerySup;
- if (xQuerySup.is())
+ SvLBoxEntry* pParent = m_pTreeView->getListBox().GetParent(_pEntry);
+ if ( pParent != pDataSourceEntry )
{
- Reference< XNameAccess > xQueryDefs = xQuerySup->getQueryDefinitions();
- Reference< XContainer > xCont(xQueryDefs, UNO_QUERY);
- if (xCont.is())
- // add as listener to get notified if elements are inserted or removed
- xCont->addContainerListener(this);
+ SvLBoxString* pString = (SvLBoxString*)_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
+ OSL_ENSURE(pString,"There must be a string item!");
+ ::rtl::OUString aName(pString->GetText());
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pParent->GetUserData());
+ try
+ {
+ Reference< XNameAccess > xNameAccess(pData->xContainer,UNO_QUERY);
+ if ( xNameAccess.is() )
+ pEntryData->xContainer.set(xNameAccess->getByName(aName),UNO_QUERY);
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
- pEntryData->xContainer = xQueryDefs;
bSuccess = pEntryData->xContainer.is();
}
- else {
- DBG_ERROR("SbaTableQueryBrowser::ensureEntryObject: no XQueryDefinitionsSupplier interface!");
+ else
+ {
+ try
+ {
+ Reference< XQueryDefinitionsSupplier > xQuerySup;
+ m_xDatabaseContext->getByName( getDataSourceAcessor( pDataSourceEntry ) ) >>= xQuerySup;
+ if (xQuerySup.is())
+ {
+ Reference< XNameAccess > xQueryDefs = xQuerySup->getQueryDefinitions();
+ Reference< XContainer > xCont(xQueryDefs, UNO_QUERY);
+ if (xCont.is())
+ // add as listener to get notified if elements are inserted or removed
+ xCont->addContainerListener(this);
+
+ pEntryData->xContainer = xQueryDefs;
+ bSuccess = pEntryData->xContainer.is();
+ }
+ else {
+ DBG_ERROR("SbaTableQueryBrowser::ensureEntryObject: no XQueryDefinitionsSupplier interface!");
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
}
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
break;
default:
@@ -2343,7 +2385,18 @@ IMPL_LINK(SbaTableQueryBrowser, OnSelectionChange, void*, /*NOINTERESTEDIN*/)
{
return implSelect( m_pTreeView->getListBox().FirstSelected() ) ? 1L : 0L;
}
-
+//------------------------------------------------------------------------------
+SvLBoxEntry* SbaTableQueryBrowser::implGetConnectionEntry(SvLBoxEntry* _pEntry) const
+{
+ SvLBoxEntry* pCurrentEntry = _pEntry;
+ DBTreeListUserData* pEntryData = static_cast< DBTreeListUserData* >( pCurrentEntry->GetUserData() );
+ while(pEntryData->eType != etDatasource )
+ {
+ pCurrentEntry = m_pTreeModel->GetParent(pCurrentEntry);
+ pEntryData = static_cast< DBTreeListUserData* >( pCurrentEntry->GetUserData() );
+ }
+ return pCurrentEntry;
+}
//------------------------------------------------------------------------------
bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry )
{
@@ -2369,7 +2422,7 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry )
DBTreeListUserData* pContainerData = static_cast<DBTreeListUserData*>(pContainer->GetUserData());
// get the entry for the datasource
- SvLBoxEntry* pConnection = m_pTreeModel->GetParent(pContainer);
+ SvLBoxEntry* pConnection = implGetConnectionEntry(pContainer);
DBTreeListUserData* pConData = static_cast<DBTreeListUserData*>(pConnection->GetUserData());
// reinitialize the rowset
@@ -2380,12 +2433,26 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry )
xRowSetProps->getPropertyValue(PROPERTY_COMMAND) >>= aOldName;
sal_Int32 nOldType = 0;
xRowSetProps->getPropertyValue(PROPERTY_COMMAND_TYPE) >>= nOldType;
- Reference<XConnection> xOldConnection;
- ::cppu::extractInterface(xOldConnection,xRowSetProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION));
+ Reference<XConnection> xOldConnection(xRowSetProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
+
// the name of the table or query
SvLBoxString* pString = (SvLBoxString*)_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
OSL_ENSURE(pString,"There must be a string item!");
- ::rtl::OUString aName(pString->GetText().GetBuffer());
+ const ::rtl::OUString sSimpleName = pString->GetText();
+ ::rtl::OUStringBuffer sNameBuffer(sSimpleName);
+ if ( etQueryContainer == pContainerData->eType )
+ {
+ SvLBoxEntry* pTemp = pContainer;
+ while( m_pTreeModel->GetParent(pTemp) != pConnection )
+ {
+ sNameBuffer.insert(0,sal_Unicode('/'));
+ pString = (SvLBoxString*)pTemp->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
+ OSL_ENSURE(pString,"There must be a string item!");
+ sNameBuffer.insert(0,pString->GetText());
+ pTemp = m_pTreeModel->GetParent(pTemp);
+ }
+ }
+ ::rtl::OUString aName = sNameBuffer.makeStringAndClear();
sal_Int32 nCommandType = ( etTableContainer == pContainerData->eType)
? CommandType::TABLE
@@ -2443,9 +2510,14 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry )
break;
case CommandType::QUERY:
{
- Reference<XQueriesSupplier> xSup( pConData->xConnection, UNO_QUERY );
- if(xSup.is())
- xNameAccess = xSup->getQueries();
+ if ( pContainerData->xContainer.is() )
+ xNameAccess.set( pContainerData->xContainer, UNO_QUERY );
+ else
+ {
+ Reference<XQueriesSupplier> xSup( pConData->xConnection, UNO_QUERY );
+ if(xSup.is())
+ xNameAccess = xSup->getQueries();
+ }
}
break;
}
@@ -2453,13 +2525,13 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry )
sStatus.SearchAndReplaceAscii("$name$", aName);
BrowserViewStatusDisplay aShowStatus(static_cast<UnoDataBrowserView*>(getView()), sStatus);
- if(xNameAccess.is() && xNameAccess->hasByName(aName))
+ if(xNameAccess.is() && xNameAccess->hasByName(sSimpleName))
{
DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData());
if ( !pData->xObjectProperties.is() )
{
Reference<XInterface> xObject;
- if(xNameAccess->getByName(aName) >>= xObject) // remember the table or query object
+ if(xNameAccess->getByName(sSimpleName) >>= xObject) // remember the table or query object
{
pData->xObjectProperties = pData->xObjectProperties.query( xObject );
// if the query contains a parameterized statement and preview is enabled we won't get any data.
@@ -3499,7 +3571,7 @@ void SbaTableQueryBrowser::loadMenu(const Reference< XFrame >& _xFrame)
{
SvLBoxEntry* pContainer = m_pTreeModel->GetParent(m_pCurrentlyDisplayed);
// get the entry for the datasource
- SvLBoxEntry* pConnection = m_pTreeModel->GetParent(pContainer);
+ SvLBoxEntry* pConnection = implGetConnectionEntry(pContainer);
::rtl::OUString sName = m_pTreeView->getListBox().GetEntryText(m_pCurrentlyDisplayed);
sTitle = GetEntryText( pConnection );
INetURLObject aURL(sTitle);