LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - commoncontrol.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 57 0.0 %
Date: 2014-04-14 Functions: 0 19 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 "commoncontrol.hxx"
      21             : #include "pcrcommon.hxx"
      22             : #include <tools/debug.hxx>
      23             : #include <tools/diagnose_ex.h>
      24             : #include <vcl/combobox.hxx>
      25             : #include <toolkit/helper/vclunohelper.hxx>
      26             : 
      27             : 
      28             : namespace pcr
      29             : {
      30             : 
      31             : 
      32             :     using ::com::sun::star::uno::RuntimeException;
      33             :     using ::com::sun::star::uno::Reference;
      34             :     using ::com::sun::star::inspection::XPropertyControlContext;
      35             :     using ::com::sun::star::awt::XWindow;
      36             :     using ::com::sun::star::uno::Exception;
      37             :     using ::com::sun::star::inspection::XPropertyControl;
      38             : 
      39             : 
      40             :     //= ControlHelper
      41             : 
      42             : 
      43           0 :     ControlHelper::ControlHelper( Window* _pControlWindow, sal_Int16 _nControlType, XPropertyControl& _rAntiImpl, IModifyListener* _pModifyListener )
      44             :         :m_pControlWindow( _pControlWindow )
      45             :         ,m_nControlType( _nControlType )
      46             :         ,m_rAntiImpl( _rAntiImpl )
      47             :         ,m_pModifyListener( _pModifyListener )
      48           0 :         ,m_bModified( sal_False )
      49             :     {
      50             :         DBG_ASSERT( m_pControlWindow != NULL, "ControlHelper::ControlHelper: invalid window!" );
      51           0 :     }
      52             : 
      53             : 
      54           0 :     ControlHelper::~ControlHelper()
      55             :     {
      56           0 :     }
      57             : 
      58             : 
      59           0 :     ::sal_Int16 SAL_CALL ControlHelper::getControlType() throw (RuntimeException)
      60             :     {
      61           0 :         return m_nControlType;
      62             :     }
      63             : 
      64             : 
      65           0 :     Reference< XPropertyControlContext > SAL_CALL ControlHelper::getControlContext() throw (RuntimeException)
      66             :     {
      67           0 :         return m_xContext;
      68             :     }
      69             : 
      70             : 
      71           0 :     void SAL_CALL ControlHelper::setControlContext( const Reference< XPropertyControlContext >& _controlcontext ) throw (RuntimeException)
      72             :     {
      73           0 :         m_xContext = _controlcontext;
      74           0 :     }
      75             : 
      76             : 
      77           0 :     Reference< XWindow > SAL_CALL ControlHelper::getControlWindow() throw (RuntimeException)
      78             :     {
      79           0 :         return VCLUnoHelper::GetInterface( m_pControlWindow );
      80             :     }
      81             : 
      82             : 
      83           0 :     sal_Bool SAL_CALL ControlHelper::isModified(  ) throw (RuntimeException)
      84             :     {
      85           0 :         return m_bModified;
      86             :     }
      87             : 
      88             : 
      89           0 :     void SAL_CALL ControlHelper::notifyModifiedValue(  ) throw (RuntimeException)
      90             :     {
      91           0 :         if ( isModified() && m_xContext.is() )
      92             :         {
      93             :             try
      94             :             {
      95           0 :                 m_xContext->valueChanged( &m_rAntiImpl );
      96           0 :                 m_bModified = sal_False;
      97             :             }
      98           0 :             catch( const Exception& )
      99             :             {
     100             :                 DBG_UNHANDLED_EXCEPTION();
     101             :             }
     102             :         }
     103           0 :     }
     104             : 
     105             : 
     106           0 :     void SAL_CALL ControlHelper::dispose()
     107             :     {
     108           0 :         DELETEZ( m_pControlWindow );
     109           0 :     }
     110             : 
     111             : 
     112           0 :     void ControlHelper::autoSizeWindow()
     113             :     {
     114             :         OSL_PRECOND( m_pControlWindow, "ControlHelper::autoSizeWindow: no window!" );
     115           0 :         if ( !m_pControlWindow )
     116           0 :             return;
     117             : 
     118           0 :         ComboBox aComboBox(m_pControlWindow, WB_DROPDOWN);
     119           0 :         aComboBox.SetPosSizePixel(Point(0,0), Size(100,100));
     120           0 :         m_pControlWindow->SetSizePixel(aComboBox.GetSizePixel());
     121             : 
     122             :         // TODO/UNOize: why do the controls this themselves? Shouldn't this be the task
     123             :         // of the browser listbox/line?
     124             :     }
     125             : 
     126             : 
     127           0 :     void ControlHelper::impl_activateNextControl_nothrow() const
     128             :     {
     129             :         try
     130             :         {
     131           0 :             if ( m_xContext.is() )
     132           0 :                 m_xContext->activateNextControl( const_cast< XPropertyControl* >( &m_rAntiImpl ) );
     133             :         }
     134           0 :         catch( const Exception& )
     135             :         {
     136             :             DBG_UNHANDLED_EXCEPTION();
     137             :         }
     138           0 :     }
     139             : 
     140             : 
     141           0 :     bool ControlHelper::handlePreNotify(NotifyEvent& rNEvt)
     142             :     {
     143           0 :         if (EVENT_KEYINPUT == rNEvt.GetType())
     144             :         {
     145           0 :             const KeyCode& aKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
     146           0 :             sal_uInt16 nKey = aKeyCode.GetCode();
     147             : 
     148           0 :             if (nKey == KEY_RETURN && !aKeyCode.IsShift())
     149             :             {
     150           0 :                 LoseFocusHdl(m_pControlWindow);
     151           0 :                 impl_activateNextControl_nothrow();
     152           0 :                 return true;
     153             :             }
     154             :         }
     155           0 :         return false;
     156             :     }
     157             : 
     158             : 
     159           0 :     IMPL_LINK( ControlHelper, ModifiedHdl, Window*, /*_pWin*/ )
     160             :     {
     161           0 :         if ( m_pModifyListener )
     162           0 :             m_pModifyListener->modified();
     163           0 :         return 0;
     164             :     }
     165             : 
     166             : 
     167           0 :     IMPL_LINK( ControlHelper, GetFocusHdl, Window*, /*_pWin*/ )
     168             :     {
     169             :         try
     170             :         {
     171           0 :             if ( m_xContext.is() )
     172           0 :                 m_xContext->focusGained( &m_rAntiImpl );
     173             :         }
     174           0 :         catch( const Exception& )
     175             :         {
     176             :             DBG_UNHANDLED_EXCEPTION();
     177             :         }
     178           0 :         return 0;
     179             :     }
     180             : 
     181             : 
     182           0 :     IMPL_LINK( ControlHelper, LoseFocusHdl, Window*, /*_pWin*/ )
     183             :     {
     184             :         // TODO/UNOize: should this be outside the default control's implementations? If somebody
     185             :         // has an own control implementation, which does *not* do this - would this be allowed?
     186             :         // If not, then we must move this logic out of here.
     187           0 :         notifyModifiedValue();
     188           0 :         return 0;
     189             :     }
     190             : 
     191             : 
     192             : } // namespace pcr
     193             : 
     194             : 
     195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10