LCOV - code coverage report
Current view: top level - dbaccess/source/ui/app - AppIconControl.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 22 35 62.9 %
Date: 2015-06-13 12:38:46 Functions: 4 6 66.7 %
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 "AppIconControl.hxx"
      21             : #include <tools/debug.hxx>
      22             : #include "dbaccess_helpid.hrc"
      23             : #include "moduledbu.hxx"
      24             : #include "dbu_app.hrc"
      25             : #include <vcl/image.hxx>
      26             : #include "callbacks.hxx"
      27             : #include "AppElementType.hxx"
      28             : #include <boost/scoped_ptr.hpp>
      29             : 
      30             : using namespace ::dbaui;
      31             : // class OApplicationIconControl
      32           7 : OApplicationIconControl::OApplicationIconControl(vcl::Window* _pParent)
      33             :     : SvtIconChoiceCtrl(_pParent,WB_ICON | WB_NOCOLUMNHEADER | WB_HIGHLIGHTFRAME | /*!WB_NOSELECTION |*/
      34             :                                 WB_TABSTOP | WB_CLIPCHILDREN | WB_NOVSCROLL | WB_SMART_ARRANGE | WB_NOHSCROLL | WB_CENTER)
      35             :     ,DropTargetHelper(this)
      36           7 :     ,m_pActionListener(NULL)
      37             : {
      38             : 
      39             :     struct CategoryDescriptor
      40             :     {
      41             :         sal_uInt16      nLabelResId;
      42             :         ElementType eType;
      43             :         sal_uInt16      nImageResId;
      44             :     }   aCategories[] = {
      45             :         { RID_STR_TABLES_CONTAINER,     E_TABLE,    IMG_TABLEFOLDER_TREE_L  },
      46             :         { RID_STR_QUERIES_CONTAINER,    E_QUERY,    IMG_QUERYFOLDER_TREE_L  },
      47             :         { RID_STR_FORMS_CONTAINER,      E_FORM,     IMG_FORMFOLDER_TREE_L   },
      48             :         { RID_STR_REPORTS_CONTAINER,    E_REPORT,   IMG_REPORTFOLDER_TREE_L }
      49           7 :     };
      50          35 :     for ( size_t i=0; i < sizeof(aCategories)/sizeof(aCategories[0]); ++i)
      51             :     {
      52             :         SvxIconChoiceCtrlEntry* pEntry = InsertEntry(
      53             :             OUString( ModuleRes( aCategories[i].nLabelResId ) ) ,
      54          28 :             Image(  ModuleRes( aCategories[i].nImageResId ) ) );
      55          28 :         if ( pEntry )
      56          28 :             pEntry->SetUserData( new ElementType( aCategories[i].eType ) );
      57             :     }
      58             : 
      59           7 :     SetChoiceWithCursor( true );
      60           7 :     SetSelectionMode(SINGLE_SELECTION);
      61           7 : }
      62             : 
      63          15 : OApplicationIconControl::~OApplicationIconControl()
      64             : {
      65           5 :     disposeOnce();
      66          10 : }
      67             : 
      68           5 : void OApplicationIconControl::dispose()
      69             : {
      70           5 :     sal_uLong nCount = GetEntryCount();
      71          25 :     for ( sal_uLong i = 0; i < nCount; ++i )
      72             :     {
      73          20 :         SvxIconChoiceCtrlEntry* pEntry = GetEntry( i );
      74          20 :         if ( pEntry )
      75             :         {
      76          20 :             boost::scoped_ptr<ElementType> aType(static_cast<ElementType*>(pEntry->GetUserData()));
      77          20 :             pEntry->SetUserData(NULL);
      78             :         }
      79             :     }
      80           5 :     SvtIconChoiceCtrl::dispose();
      81           5 : }
      82             : 
      83           0 : sal_Int8 OApplicationIconControl::AcceptDrop( const AcceptDropEvent& _rEvt )
      84             : {
      85           0 :     sal_Int8 nDropOption = DND_ACTION_NONE;
      86           0 :     if ( m_pActionListener )
      87             :     {
      88             : 
      89           0 :         SvxIconChoiceCtrlEntry* pEntry = GetEntry(_rEvt.maPosPixel);
      90           0 :         if ( pEntry )
      91             :         {
      92           0 :             SetCursor(pEntry);
      93           0 :             nDropOption = m_pActionListener->queryDrop( _rEvt, GetDataFlavorExVector() );
      94           0 :             m_aMousePos = _rEvt.maPosPixel;
      95             :         }
      96             :     }
      97             : 
      98           0 :     return nDropOption;
      99             : }
     100             : 
     101           0 : sal_Int8 OApplicationIconControl::ExecuteDrop( const ExecuteDropEvent& _rEvt )
     102             : {
     103           0 :     if ( m_pActionListener )
     104           0 :         return m_pActionListener->executeDrop( _rEvt );
     105             : 
     106           0 :     return DND_ACTION_NONE;
     107             : }
     108             : 
     109             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11