LCOV - code coverage report
Current view: top level - dbaccess/source/ui/browser - dsEntriesNoExp.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 109 0.0 %
Date: 2014-04-14 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "unodatbr.hxx"
      21             : #include "browserids.hxx"
      22             : #include "listviewitems.hxx"
      23             : #include "imageprovider.hxx"
      24             : #include <osl/diagnose.h>
      25             : #include "dbtreeview.hxx"
      26             : #include "dbtreelistbox.hxx"
      27             : #include "dbu_brw.hrc"
      28             : #include "dbtreemodel.hxx"
      29             : #include "svtools/treelistentry.hxx"
      30             : #include <boost/scoped_ptr.hpp>
      31             : 
      32             : using namespace ::com::sun::star::frame;
      33             : using namespace ::dbtools;
      34             : using namespace ::svx;
      35             : 
      36             : namespace dbaui
      37             : {
      38           0 : SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getChildType( SvTreeListEntry* _pEntry ) const
      39             : {
      40             :     OSL_ENSURE(isContainer(_pEntry), "SbaTableQueryBrowser::getChildType: invalid entry!");
      41           0 :     switch (getEntryType(_pEntry))
      42             :     {
      43             :         case etTableContainer:
      44           0 :             return etTableOrView;
      45             :         case etQueryContainer:
      46           0 :             return etQuery;
      47             :         default:
      48           0 :             break;
      49             :     }
      50           0 :     return etUnknown;
      51             : }
      52             : 
      53           0 : OUString SbaTableQueryBrowser::GetEntryText( SvTreeListEntry* _pEntry ) const
      54             : {
      55           0 :     return m_pTreeView->getListBox().GetEntryText(_pEntry);
      56             : }
      57             : 
      58           0 : SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getEntryType( const SvTreeListEntry* _pEntry ) const
      59             : {
      60           0 :     if (!_pEntry)
      61           0 :         return etUnknown;
      62             : 
      63           0 :     SvTreeListEntry* pRootEntry     = m_pTreeView->getListBox().GetRootLevelParent(const_cast<SvTreeListEntry*>(_pEntry));
      64           0 :     SvTreeListEntry* pEntryParent   = m_pTreeView->getListBox().GetParent(const_cast<SvTreeListEntry*>(_pEntry));
      65           0 :     SvTreeListEntry* pTables        = m_pTreeView->getListBox().GetEntry(pRootEntry, CONTAINER_TABLES);
      66           0 :     SvTreeListEntry* pQueries       = m_pTreeView->getListBox().GetEntry(pRootEntry, CONTAINER_QUERIES);
      67             : 
      68             : #ifdef DBG_UTIL
      69             :     OUString sTest;
      70             :     if (pTables) sTest = m_pTreeView->getListBox().GetEntryText(pTables);
      71             :     if (pQueries) sTest = m_pTreeView->getListBox().GetEntryText(pQueries);
      72             : #endif
      73             : 
      74           0 :     if (pRootEntry == _pEntry)
      75           0 :         return etDatasource;
      76             : 
      77           0 :     if (pTables == _pEntry)
      78           0 :         return etTableContainer;
      79             : 
      80           0 :     if (pQueries == _pEntry)
      81           0 :         return etQueryContainer;
      82             : 
      83           0 :     if (pTables == pEntryParent)
      84           0 :         return etTableOrView;
      85             : 
      86           0 :     if (pQueries == pEntryParent)
      87             :     {
      88           0 :         DBTreeListUserData* pEntryData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData());
      89           0 :         if ( pEntryData )
      90           0 :             return pEntryData->eType;
      91             : 
      92           0 :         return etQuery;
      93             :     }
      94           0 :     while( pEntryParent != pQueries )
      95             :     {
      96           0 :         pEntryParent = m_pTreeView->getListBox().GetParent(pEntryParent);
      97           0 :         if ( !pEntryParent )
      98           0 :             return etUnknown;
      99             :     }
     100             : 
     101           0 :     return etQueryContainer;
     102             : }
     103             : 
     104           0 : void SbaTableQueryBrowser::select(SvTreeListEntry* _pEntry, sal_Bool _bSelect)
     105             : {
     106           0 :     SvLBoxItem* pTextItem = _pEntry ? _pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING) : NULL;
     107           0 :     if (pTextItem)
     108             :     {
     109           0 :         static_cast<OBoldListboxString*>(pTextItem)->emphasize(_bSelect);
     110           0 :         m_pTreeModel->InvalidateEntry(_pEntry);
     111             :     }
     112             :     else {
     113             :         OSL_FAIL("SbaTableQueryBrowser::select: invalid entry!");
     114             :     }
     115           0 : }
     116             : 
     117           0 : void SbaTableQueryBrowser::selectPath(SvTreeListEntry* _pEntry, sal_Bool _bSelect)
     118             : {
     119           0 :     while (_pEntry)
     120             :     {
     121           0 :         select(_pEntry, _bSelect);
     122           0 :         _pEntry = m_pTreeModel->GetParent(_pEntry);
     123             :     }
     124           0 : }
     125             : 
     126           0 : sal_Bool SbaTableQueryBrowser::isSelected(SvTreeListEntry* _pEntry) const
     127             : {
     128           0 :     SvLBoxItem* pTextItem = _pEntry ? _pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING) : NULL;
     129           0 :     if (pTextItem)
     130           0 :         return static_cast<OBoldListboxString*>(pTextItem)->isEmphasized();
     131             :     else {
     132             :         OSL_FAIL("SbaTableQueryBrowser::isSelected: invalid entry!");
     133             :     }
     134           0 :     return sal_False;
     135             : }
     136             : 
     137           0 : void SbaTableQueryBrowser::SelectionChanged()
     138             : {
     139           0 :     if ( !m_bShowMenu )
     140             :     {
     141           0 :         InvalidateFeature(ID_BROWSER_INSERTCOLUMNS);
     142           0 :         InvalidateFeature(ID_BROWSER_INSERTCONTENT);
     143           0 :         InvalidateFeature(ID_BROWSER_FORMLETTER);
     144             :     }
     145           0 :     InvalidateFeature(ID_BROWSER_COPY);
     146           0 :     InvalidateFeature(ID_BROWSER_CUT);
     147           0 : }
     148             : 
     149           0 : void SbaTableQueryBrowser::describeSupportedFeatures()
     150             : {
     151           0 :     SbaXDataBrowserController::describeSupportedFeatures();
     152             : 
     153           0 :     implDescribeSupportedFeature( ".uno:Title",                             ID_BROWSER_TITLE );
     154           0 :     if ( !m_bShowMenu )
     155             :     {
     156           0 :         implDescribeSupportedFeature( ".uno:DSBrowserExplorer",                 ID_BROWSER_EXPLORER, CommandGroup::VIEW );
     157             : 
     158           0 :         implDescribeSupportedFeature( ".uno:DSBFormLetter",                     ID_BROWSER_FORMLETTER, CommandGroup::DOCUMENT );
     159           0 :         implDescribeSupportedFeature( ".uno:DSBInsertColumns",                  ID_BROWSER_INSERTCOLUMNS, CommandGroup::INSERT );
     160           0 :         implDescribeSupportedFeature( ".uno:DSBInsertContent",                  ID_BROWSER_INSERTCONTENT, CommandGroup::INSERT );
     161           0 :         implDescribeSupportedFeature( ".uno:DSBDocumentDataSource",             ID_BROWSER_DOCUMENT_DATASOURCE, CommandGroup::VIEW );
     162             : 
     163           0 :         implDescribeSupportedFeature( ".uno:DataSourceBrowser/FormLetter",          ID_BROWSER_FORMLETTER );
     164           0 :         implDescribeSupportedFeature( ".uno:DataSourceBrowser/InsertColumns",       ID_BROWSER_INSERTCOLUMNS );
     165           0 :         implDescribeSupportedFeature( ".uno:DataSourceBrowser/InsertContent",       ID_BROWSER_INSERTCONTENT );
     166           0 :         implDescribeSupportedFeature( ".uno:DataSourceBrowser/DocumentDataSource",  ID_BROWSER_DOCUMENT_DATASOURCE );
     167             :     }
     168             : 
     169           0 :     implDescribeSupportedFeature( ".uno:CloseWin",      ID_BROWSER_CLOSE, CommandGroup::DOCUMENT );
     170           0 :     implDescribeSupportedFeature( ".uno:DBRebuildData", ID_BROWSER_REFRESH_REBUILD, CommandGroup::DATA );
     171           0 : }
     172             : 
     173           0 : sal_Int32 SbaTableQueryBrowser::getDatabaseObjectType( EntryType _eType )
     174             : {
     175           0 :     switch ( _eType )
     176             :     {
     177             :     case etQuery:
     178             :     case etQueryContainer:
     179           0 :         return DatabaseObject::QUERY;
     180             :     case etTableOrView:
     181             :     case etTableContainer:
     182           0 :         return DatabaseObject::TABLE;
     183             :     default:
     184           0 :         break;
     185             :     }
     186             :     OSL_FAIL( "SbaTableQueryBrowser::getDatabaseObjectType: folder types and 'Unknown' not allowed here!" );
     187           0 :     return DatabaseObject::TABLE;
     188             : }
     189             : 
     190           0 : void SbaTableQueryBrowser::notifyHiContrastChanged()
     191             : {
     192           0 :     if ( m_pTreeView )
     193             :     {
     194             :         // change all bitmap entries
     195           0 :         SvTreeListEntry* pEntryLoop = m_pTreeModel->First();
     196           0 :         while ( pEntryLoop )
     197             :         {
     198           0 :             DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pEntryLoop->GetUserData());
     199           0 :             if ( !pData )
     200             :             {
     201           0 :                 pEntryLoop = m_pTreeModel->Next(pEntryLoop);
     202           0 :                 continue;
     203             :             }
     204             : 
     205             :             // the connection to which this entry belongs, if any
     206           0 :             boost::scoped_ptr< ImageProvider > pImageProvider( getImageProviderFor( pEntryLoop ) );
     207             : 
     208             :             // the images for this entry
     209           0 :             Image aImage;
     210           0 :             if ( pData->eType == etDatasource )
     211           0 :                 aImage = pImageProvider->getDatabaseImage();
     212             :             else
     213             :             {
     214           0 :                 bool bIsFolder = !isObject( pData->eType );
     215           0 :                 if ( bIsFolder )
     216             :                 {
     217           0 :                     sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) );
     218           0 :                     aImage = pImageProvider->getFolderImage( nObjectType );
     219             :                 }
     220             :                 else
     221             :                 {
     222           0 :                     sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) );
     223           0 :                     pImageProvider->getImages( GetEntryText( pEntryLoop ), nObjectType, aImage );
     224             :                 }
     225             :             }
     226             : 
     227             :             // find the proper item, and set its icons
     228           0 :             sal_uInt16 nCount = pEntryLoop->ItemCount();
     229           0 :             for (sal_uInt16 i=0;i<nCount;++i)
     230             :             {
     231           0 :                 SvLBoxItem* pItem = pEntryLoop->GetItem(i);
     232           0 :                 if (!pItem || pItem->GetType() != SV_ITEM_ID_LBOXCONTEXTBMP)
     233           0 :                     continue;
     234             : 
     235           0 :                 SvLBoxContextBmp* pContextBitmapItem = static_cast< SvLBoxContextBmp* >( pItem );
     236             : 
     237           0 :                 pContextBitmapItem->SetBitmap1( aImage );
     238           0 :                 pContextBitmapItem->SetBitmap2( aImage );
     239           0 :                 break;
     240             :             }
     241             : 
     242           0 :             pEntryLoop = m_pTreeModel->Next(pEntryLoop);
     243           0 :         }
     244             :     }
     245           0 : }
     246             : 
     247             : }   // namespace dbaui
     248             : 
     249             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10