LCOV - code coverage report
Current view: top level - libreoffice/extensions/source/propctrlr - propertycontrolextender.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 24 0.0 %
Date: 2012-12-17 Functions: 0 8 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             : 
      21             : #include "propertycontrolextender.hxx"
      22             : 
      23             : #include <com/sun/star/awt/KeyFunction.hpp>
      24             : 
      25             : #include <tools/diagnose_ex.h>
      26             : 
      27             : //........................................................................
      28             : namespace pcr
      29             : {
      30             : //........................................................................
      31             : 
      32             :     /** === begin UNO using === **/
      33             :     using ::com::sun::star::uno::Reference;
      34             :     using ::com::sun::star::uno::XInterface;
      35             :     using ::com::sun::star::uno::UNO_QUERY;
      36             :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      37             :     using ::com::sun::star::uno::UNO_SET_THROW;
      38             :     using ::com::sun::star::uno::Exception;
      39             :     using ::com::sun::star::uno::RuntimeException;
      40             :     using ::com::sun::star::uno::Any;
      41             :     using ::com::sun::star::uno::makeAny;
      42             :     using ::com::sun::star::uno::Sequence;
      43             :     using ::com::sun::star::uno::Type;
      44             :     using ::com::sun::star::awt::XWindow;
      45             :     using ::com::sun::star::awt::KeyEvent;
      46             :     using ::com::sun::star::inspection::XPropertyControl;
      47             :     using ::com::sun::star::lang::EventObject;
      48             :     using ::com::sun::star::inspection::XPropertyControlContext;
      49             :     /** === end UNO using === **/
      50             :     namespace KeyFunction = ::com::sun::star::awt::KeyFunction;
      51             : 
      52             :     //====================================================================
      53             :     //= PropertyControlExtender_Data
      54             :     //====================================================================
      55           0 :     struct PropertyControlExtender_Data
      56             :     {
      57             :         Reference< XPropertyControl >   xControl;
      58             :         Reference< XWindow >            xControlWindow;
      59             :     };
      60             : 
      61             :     //====================================================================
      62             :     //= PropertyControlExtender
      63             :     //====================================================================
      64             :     //--------------------------------------------------------------------
      65           0 :     PropertyControlExtender::PropertyControlExtender( const Reference< XPropertyControl >& _rxObservedControl )
      66           0 :         :m_pData( new PropertyControlExtender_Data )
      67             :     {
      68             :         try
      69             :         {
      70           0 :             m_pData->xControl.set( _rxObservedControl, UNO_SET_THROW );
      71           0 :             m_pData->xControlWindow.set( m_pData->xControl->getControlWindow(), UNO_SET_THROW );
      72           0 :             m_pData->xControlWindow->addKeyListener( this );
      73             :         }
      74           0 :         catch( const Exception& )
      75             :         {
      76             :             DBG_UNHANDLED_EXCEPTION();
      77             :         }
      78           0 :     }
      79             : 
      80             :     //--------------------------------------------------------------------
      81           0 :     PropertyControlExtender::~PropertyControlExtender()
      82             :     {
      83           0 :     }
      84             : 
      85             :     //--------------------------------------------------------------------
      86           0 :     void SAL_CALL PropertyControlExtender::keyPressed( const KeyEvent& _event ) throw (RuntimeException)
      87             :     {
      88             :         OSL_ENSURE( _event.Source == m_pData->xControlWindow, "PropertyControlExtender::keyPressed: where does this come from?" );
      89           0 :         if  (   ( _event.KeyFunc == KeyFunction::DELETE )
      90             :             &&  ( _event.Modifiers == 0 )
      91             :             )
      92             :         {
      93             :             try
      94             :             {
      95           0 :                 Reference< XPropertyControl > xControl( m_pData->xControl, UNO_SET_THROW );
      96             : 
      97             :                 // reset the value
      98           0 :                 xControl->setValue( Any() );
      99             : 
     100             :                 // and notify the change
     101             :                 // don't use XPropertyControl::notifyModifiedValue. It only notifies when the control content
     102             :                 // is recognized as being modified by the user, which is not the case, since we just modified
     103             :                 // it programmatically.
     104           0 :                 Reference< XPropertyControlContext > xControlContext( xControl->getControlContext(), UNO_SET_THROW );
     105           0 :                 xControlContext->valueChanged( xControl );
     106             :             }
     107           0 :             catch( const Exception& )
     108             :             {
     109             :                 DBG_UNHANDLED_EXCEPTION();
     110             :             }
     111             :         }
     112           0 :     }
     113             : 
     114             :     //--------------------------------------------------------------------
     115           0 :     void SAL_CALL PropertyControlExtender::keyReleased( const KeyEvent& /*_event*/ ) throw (RuntimeException)
     116             :     {
     117             :         // not interested in
     118           0 :     }
     119             : 
     120             :     //--------------------------------------------------------------------
     121           0 :     void SAL_CALL PropertyControlExtender::disposing( const EventObject& Source ) throw (RuntimeException)
     122             :     {
     123             :         OSL_ENSURE( Source.Source == m_pData->xControlWindow, "PropertyControlExtender::disposing: where does this come from?" );
     124             :         (void)Source.Source;
     125           0 :         m_pData->xControlWindow.clear();
     126           0 :         m_pData->xControl.clear();
     127           0 :     }
     128             : 
     129             : 
     130             : //........................................................................
     131             : } // namespace pcr
     132             : //........................................................................
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10