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

Generated by: LCOV version 1.10