LCOV - code coverage report
Current view: top level - dbaccess/source/ui/browser - dsEntriesNoExp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 44 109 40.4 %
Date: 2012-08-25 Functions: 6 10 60.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 106 9.4 %

           Branch data     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                 :            : 
      21                 :            : #include "unodatbr.hxx"
      22                 :            : #include "browserids.hxx"
      23                 :            : #include "listviewitems.hxx"
      24                 :            : #include "imageprovider.hxx"
      25                 :            : #include <osl/diagnose.h>
      26                 :            : #include "dbtreeview.hxx"
      27                 :            : #include "dbtreelistbox.hxx"
      28                 :            : #include "dbu_brw.hrc"
      29                 :            : #include "dbtreemodel.hxx"
      30                 :            : 
      31                 :            : using namespace ::com::sun::star::frame;
      32                 :            : using namespace ::dbtools;
      33                 :            : using namespace ::svx;
      34                 :            : 
      35                 :            : // .........................................................................
      36                 :            : namespace dbaui
      37                 :            : {
      38                 :            : // .........................................................................
      39                 :            : // -----------------------------------------------------------------------------
      40                 :          0 : SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getChildType( SvLBoxEntry* _pEntry ) const
      41                 :            : {
      42                 :            :     OSL_ENSURE(isContainer(_pEntry), "SbaTableQueryBrowser::getChildType: invalid entry!");
      43      [ #  #  # ]:          0 :     switch (getEntryType(_pEntry))
      44                 :            :     {
      45                 :            :         case etTableContainer:
      46                 :          0 :             return etTableOrView;
      47                 :            :         case etQueryContainer:
      48                 :          0 :             return etQuery;
      49                 :            :         default:
      50                 :          0 :             break;
      51                 :            :     }
      52                 :          0 :     return etUnknown;
      53                 :            : }
      54                 :            : 
      55                 :            : // -----------------------------------------------------------------------------
      56                 :         10 : String SbaTableQueryBrowser::GetEntryText( SvLBoxEntry* _pEntry ) const
      57                 :            : {
      58                 :         10 :     return m_pTreeView->getListBox().GetEntryText(_pEntry);
      59                 :            : }
      60                 :            : 
      61                 :            : // -----------------------------------------------------------------------------
      62                 :          4 : SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getEntryType( SvLBoxEntry* _pEntry ) const
      63                 :            : {
      64         [ -  + ]:          4 :     if (!_pEntry)
      65                 :          0 :         return etUnknown;
      66                 :            : 
      67                 :          4 :     SvLBoxEntry* pRootEntry     = m_pTreeView->getListBox().GetRootLevelParent(_pEntry);
      68                 :          4 :     SvLBoxEntry* pEntryParent   = m_pTreeView->getListBox().GetParent(_pEntry);
      69                 :          4 :     SvLBoxEntry* pTables        = m_pTreeView->getListBox().GetEntry(pRootEntry, CONTAINER_TABLES);
      70                 :          4 :     SvLBoxEntry* pQueries       = m_pTreeView->getListBox().GetEntry(pRootEntry, CONTAINER_QUERIES);
      71                 :            : 
      72                 :            : #ifdef DBG_UTIL
      73                 :            :     String sTest;
      74                 :            :     if (pTables) sTest = m_pTreeView->getListBox().GetEntryText(pTables);
      75                 :            :     if (pQueries) sTest = m_pTreeView->getListBox().GetEntryText(pQueries);
      76                 :            : #endif
      77                 :            : 
      78         [ -  + ]:          4 :     if (pRootEntry == _pEntry)
      79                 :          0 :         return etDatasource;
      80                 :            : 
      81         [ -  + ]:          4 :     if (pTables == _pEntry)
      82                 :          0 :         return etTableContainer;
      83                 :            : 
      84         [ +  - ]:          4 :     if (pQueries == _pEntry)
      85                 :          4 :         return etQueryContainer;
      86                 :            : 
      87         [ #  # ]:          0 :     if (pTables == pEntryParent)
      88                 :          0 :         return etTableOrView;
      89                 :            : 
      90         [ #  # ]:          0 :     if (pQueries == pEntryParent)
      91                 :            :     {
      92                 :          0 :         DBTreeListUserData* pEntryData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData());
      93         [ #  # ]:          0 :         if ( pEntryData )
      94                 :          0 :             return pEntryData->eType;
      95                 :            : 
      96                 :          0 :         return etQuery;
      97                 :            :     }
      98         [ #  # ]:          0 :     while( pEntryParent != pQueries )
      99                 :            :     {
     100                 :          0 :         pEntryParent = m_pTreeView->getListBox().GetParent(pEntryParent);
     101         [ #  # ]:          0 :         if ( !pEntryParent )
     102                 :          0 :             return etUnknown;
     103                 :            :     }
     104                 :            : 
     105                 :          4 :     return etQueryContainer;
     106                 :            : }
     107                 :            : //------------------------------------------------------------------------------
     108                 :          6 : void SbaTableQueryBrowser::select(SvLBoxEntry* _pEntry, sal_Bool _bSelect)
     109                 :            : {
     110         [ +  - ]:          6 :     SvLBoxItem* pTextItem = _pEntry ? _pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING) : NULL;
     111         [ +  - ]:          6 :     if (pTextItem)
     112                 :            :     {
     113                 :          6 :         static_cast<OBoldListboxString*>(pTextItem)->emphasize(_bSelect);
     114                 :          6 :         m_pTreeModel->InvalidateEntry(_pEntry);
     115                 :            :     }
     116                 :            :     else {
     117                 :            :         OSL_FAIL("SbaTableQueryBrowser::select: invalid entry!");
     118                 :            :     }
     119                 :          6 : }
     120                 :            : 
     121                 :            : //------------------------------------------------------------------------------
     122                 :          4 : void SbaTableQueryBrowser::selectPath(SvLBoxEntry* _pEntry, sal_Bool _bSelect)
     123                 :            : {
     124         [ +  + ]:         10 :     while (_pEntry)
     125                 :            :     {
     126                 :          6 :         select(_pEntry, _bSelect);
     127                 :          6 :         _pEntry = m_pTreeModel->GetParent(_pEntry);
     128                 :            :     }
     129                 :          4 : }
     130                 :            : //------------------------------------------------------------------------------
     131                 :          0 : sal_Bool SbaTableQueryBrowser::isSelected(SvLBoxEntry* _pEntry) const
     132                 :            : {
     133         [ #  # ]:          0 :     SvLBoxItem* pTextItem = _pEntry ? _pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING) : NULL;
     134         [ #  # ]:          0 :     if (pTextItem)
     135                 :          0 :         return static_cast<OBoldListboxString*>(pTextItem)->isEmphasized();
     136                 :            :     else {
     137                 :            :         OSL_FAIL("SbaTableQueryBrowser::isSelected: invalid entry!");
     138                 :            :     }
     139                 :          0 :     return sal_False;
     140                 :            : }
     141                 :            : //------------------------------------------------------------------------------
     142                 :          0 : void SbaTableQueryBrowser::SelectionChanged()
     143                 :            : {
     144         [ #  # ]:          0 :     if ( !m_bShowMenu )
     145                 :            :     {
     146         [ #  # ]:          0 :         InvalidateFeature(ID_BROWSER_INSERTCOLUMNS);
     147         [ #  # ]:          0 :         InvalidateFeature(ID_BROWSER_INSERTCONTENT);
     148         [ #  # ]:          0 :         InvalidateFeature(ID_BROWSER_FORMLETTER);
     149                 :            :     }
     150         [ #  # ]:          0 :     InvalidateFeature(ID_BROWSER_COPY);
     151         [ #  # ]:          0 :     InvalidateFeature(ID_BROWSER_CUT);
     152                 :          0 : }
     153                 :            : //------------------------------------------------------------------------------
     154                 :          2 : void SbaTableQueryBrowser::describeSupportedFeatures()
     155                 :            : {
     156                 :          2 :     SbaXDataBrowserController::describeSupportedFeatures();
     157                 :            : 
     158                 :          2 :     implDescribeSupportedFeature( ".uno:Title",                             ID_BROWSER_TITLE );
     159         [ +  - ]:          2 :     if ( !m_bShowMenu )
     160                 :            :     {
     161                 :          2 :         implDescribeSupportedFeature( ".uno:DSBrowserExplorer",                 ID_BROWSER_EXPLORER, CommandGroup::VIEW );
     162                 :            : 
     163                 :          2 :         implDescribeSupportedFeature( ".uno:DSBFormLetter",                     ID_BROWSER_FORMLETTER, CommandGroup::DOCUMENT );
     164                 :          2 :         implDescribeSupportedFeature( ".uno:DSBInsertColumns",                  ID_BROWSER_INSERTCOLUMNS, CommandGroup::INSERT );
     165                 :          2 :         implDescribeSupportedFeature( ".uno:DSBInsertContent",                  ID_BROWSER_INSERTCONTENT, CommandGroup::INSERT );
     166                 :          2 :         implDescribeSupportedFeature( ".uno:DSBDocumentDataSource",             ID_BROWSER_DOCUMENT_DATASOURCE, CommandGroup::VIEW );
     167                 :            : 
     168                 :          2 :         implDescribeSupportedFeature( ".uno:DataSourceBrowser/FormLetter",          ID_BROWSER_FORMLETTER );
     169                 :          2 :         implDescribeSupportedFeature( ".uno:DataSourceBrowser/InsertColumns",       ID_BROWSER_INSERTCOLUMNS );
     170                 :          2 :         implDescribeSupportedFeature( ".uno:DataSourceBrowser/InsertContent",       ID_BROWSER_INSERTCONTENT );
     171                 :          2 :         implDescribeSupportedFeature( ".uno:DataSourceBrowser/DocumentDataSource",  ID_BROWSER_DOCUMENT_DATASOURCE );
     172                 :            :     }
     173                 :            : 
     174                 :          2 :     implDescribeSupportedFeature( ".uno:CloseWin",      ID_BROWSER_CLOSE, CommandGroup::DOCUMENT );
     175                 :          2 :     implDescribeSupportedFeature( ".uno:DBRebuildData", ID_BROWSER_REFRESH_REBUILD, CommandGroup::DATA );
     176                 :          2 : }
     177                 :            : 
     178                 :            : // -----------------------------------------------------------------------------
     179                 :          2 : sal_Int32 SbaTableQueryBrowser::getDatabaseObjectType( EntryType _eType )
     180                 :            : {
     181      [ -  +  - ]:          2 :     switch ( _eType )
     182                 :            :     {
     183                 :            :     case etQuery:
     184                 :            :     case etQueryContainer:
     185                 :          0 :         return DatabaseObject::QUERY;
     186                 :            :     case etTableOrView:
     187                 :            :     case etTableContainer:
     188                 :          2 :         return DatabaseObject::TABLE;
     189                 :            :     default:
     190                 :          0 :         break;
     191                 :            :     }
     192                 :            :     OSL_FAIL( "SbaTableQueryBrowser::getDatabaseObjectType: folder types and 'Unknown' not allowed here!" );
     193                 :          2 :     return DatabaseObject::TABLE;
     194                 :            : }
     195                 :            : 
     196                 :            : // -----------------------------------------------------------------------------
     197                 :          0 : void SbaTableQueryBrowser::notifyHiContrastChanged()
     198                 :            : {
     199         [ #  # ]:          0 :     if ( m_pTreeView )
     200                 :            :     {
     201                 :            :         // change all bitmap entries
     202                 :          0 :         SvLBoxEntry* pEntryLoop = m_pTreeModel->First();
     203         [ #  # ]:          0 :         while ( pEntryLoop )
     204                 :            :         {
     205                 :          0 :             DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pEntryLoop->GetUserData());
     206         [ #  # ]:          0 :             if ( !pData )
     207                 :            :             {
     208         [ #  # ]:          0 :                 pEntryLoop = m_pTreeModel->Next(pEntryLoop);
     209                 :          0 :                 continue;
     210                 :            :             }
     211                 :            : 
     212                 :            :             // the connection to which this entry belongs, if any
     213 [ #  # ][ #  # ]:          0 :             ::std::auto_ptr< ImageProvider > pImageProvider( getImageProviderFor( pEntryLoop ) );
     214                 :            : 
     215                 :            :             // the images for this entry
     216         [ #  # ]:          0 :             Image aImage;
     217         [ #  # ]:          0 :             if ( pData->eType == etDatasource )
     218 [ #  # ][ #  # ]:          0 :                 aImage = pImageProvider->getDatabaseImage();
                 [ #  # ]
     219                 :            :             else
     220                 :            :             {
     221                 :          0 :                 bool bIsFolder = !isObject( pData->eType );
     222         [ #  # ]:          0 :                 if ( bIsFolder )
     223                 :            :                 {
     224                 :          0 :                     sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) );
     225 [ #  # ][ #  # ]:          0 :                     aImage = pImageProvider->getFolderImage( nObjectType );
                 [ #  # ]
     226                 :            :                 }
     227                 :            :                 else
     228                 :            :                 {
     229                 :          0 :                     sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) );
     230 [ #  # ][ #  # ]:          0 :                     pImageProvider->getImages( GetEntryText( pEntryLoop ), nObjectType, aImage );
                 [ #  # ]
     231                 :            :                 }
     232                 :            :             }
     233                 :            : 
     234                 :            :             // find the proper item, and set its icons
     235                 :          0 :             sal_uInt16 nCount = pEntryLoop->ItemCount();
     236         [ #  # ]:          0 :             for (sal_uInt16 i=0;i<nCount;++i)
     237                 :            :             {
     238         [ #  # ]:          0 :                 SvLBoxItem* pItem = pEntryLoop->GetItem(i);
     239 [ #  # ][ #  # ]:          0 :                 if ( !pItem || ( pItem->IsA() != SV_ITEM_ID_LBOXCONTEXTBMP ) )
         [ #  # ][ #  # ]
     240                 :          0 :                     continue;
     241                 :            : 
     242                 :          0 :                 SvLBoxContextBmp* pContextBitmapItem = static_cast< SvLBoxContextBmp* >( pItem );
     243                 :            : 
     244         [ #  # ]:          0 :                 pContextBitmapItem->SetBitmap1( aImage );
     245         [ #  # ]:          0 :                 pContextBitmapItem->SetBitmap2( aImage );
     246                 :          0 :                 break;
     247                 :            :             }
     248                 :            : 
     249         [ #  # ]:          0 :             pEntryLoop = m_pTreeModel->Next(pEntryLoop);
     250 [ #  # ][ #  # ]:          0 :         }
     251                 :            :     }
     252                 :          0 : }
     253                 :            : // -----------------------------------------------------------------------------
     254                 :            : // .........................................................................
     255                 :            : }   // namespace dbaui
     256                 :            : // .........................................................................
     257                 :            : 
     258                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10