LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/ui/misc - ToolBoxHelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 45 0.0 %
Date: 2012-12-27 Functions: 0 9 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 "ToolBoxHelper.hxx"
      21             : #include <vcl/toolbox.hxx>
      22             : #include <vcl/svapp.hxx>
      23             : #include <svtools/miscopt.hxx>
      24             : #include "UITools.hxx"
      25             : #include <svtools/imgdef.hxx>
      26             : #include <vcl/event.hxx>
      27             : 
      28             : namespace dbaui
      29             : {
      30             :     DBG_NAME(OToolBoxHelper)
      31           0 :     OToolBoxHelper::OToolBoxHelper()
      32             :         : m_nSymbolsSize(-1 )
      33           0 :         , m_pToolBox(NULL)
      34             :     {
      35             :         DBG_CTOR(OToolBoxHelper,NULL);
      36             : 
      37             :         OSL_ENSURE(m_nSymbolsSize != SvtMiscOptions().GetCurrentSymbolsSize(),"SymbolsSize should not be identical");
      38           0 :         SvtMiscOptions().AddListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) );
      39           0 :         Application::AddEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) );
      40           0 :     }
      41             :     // -----------------------------------------------------------------------------
      42           0 :     OToolBoxHelper::~OToolBoxHelper()
      43             :     {
      44           0 :         SvtMiscOptions().RemoveListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) );
      45           0 :         Application::RemoveEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) );
      46             :         DBG_DTOR(OToolBoxHelper,NULL);
      47           0 :     }
      48             : 
      49             :     // -----------------------------------------------------------------------------
      50           0 :     void OToolBoxHelper::checkImageList()
      51             :     {
      52           0 :         if ( m_pToolBox )
      53             :         {
      54           0 :             sal_Int16 nCurSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize();
      55           0 :             if ( nCurSymbolsSize != m_nSymbolsSize )
      56             :             {
      57           0 :                 m_nSymbolsSize  = nCurSymbolsSize;
      58             : 
      59           0 :                 m_pToolBox->SetImageList( getImageList(m_nSymbolsSize) );
      60           0 :                 Size aTbOldSize = m_pToolBox->GetSizePixel();
      61           0 :                 adjustToolBoxSize(m_pToolBox);
      62           0 :                 Size aTbNewSize = m_pToolBox->GetSizePixel();
      63           0 :                 resizeControls(Size(aTbNewSize.Width() - aTbOldSize.Width(),
      64           0 :                                     aTbNewSize.Height() - aTbOldSize.Height())
      65           0 :                                 );
      66             :             }
      67             :         }
      68           0 :     }
      69             :     // -----------------------------------------------------------------------------
      70           0 :     IMPL_LINK(OToolBoxHelper, ConfigOptionsChanged, SvtMiscOptions*, /*_pOptions*/)
      71             :     {
      72           0 :         if ( m_pToolBox )
      73             :         {
      74           0 :             SvtMiscOptions aOptions;
      75             :             // check if imagelist changed
      76           0 :             checkImageList();
      77           0 :             if ( aOptions.GetToolboxStyle() != m_pToolBox->GetOutStyle() )
      78           0 :                 m_pToolBox->SetOutStyle(aOptions.GetToolboxStyle());
      79             :         }
      80             : 
      81           0 :         return 0L;
      82             :     }
      83             :     // -----------------------------------------------------------------------------
      84           0 :     IMPL_LINK(OToolBoxHelper, SettingsChanged, VclWindowEvent*, _pEvt)
      85             :     {
      86           0 :         if ( m_pToolBox && _pEvt && _pEvt->GetId() == VCLEVENT_APPLICATION_DATACHANGED )
      87             :         {
      88           0 :             DataChangedEvent* pData = reinterpret_cast<DataChangedEvent*>(_pEvt->GetData());
      89           0 :             if ( pData && ((( pData->GetType() == DATACHANGED_SETTINGS  )   ||
      90           0 :             ( pData->GetType() == DATACHANGED_DISPLAY   ))  &&
      91           0 :             ( pData->GetFlags() & SETTINGS_STYLE        )))
      92             :                 // check if imagelist changed
      93           0 :                 checkImageList();
      94             :         }
      95             : 
      96           0 :         return 0L;
      97             :     }
      98             :     // -----------------------------------------------------------------------------
      99           0 :     void OToolBoxHelper::setToolBox(ToolBox* _pTB)
     100             :     {
     101           0 :         sal_Bool bFirstTime = (m_pToolBox == NULL);
     102           0 :         m_pToolBox = _pTB;
     103           0 :         if ( m_pToolBox )
     104             :         {
     105           0 :             ConfigOptionsChanged(NULL);
     106           0 :             if ( bFirstTime )
     107           0 :                 adjustToolBoxSize(m_pToolBox);
     108             :         }
     109           0 :     }
     110             : // -----------------------------------------------------------------------------
     111             : } // namespace
     112             : // -----------------------------------------------------------------------------
     113             : 
     114             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10