LCOV - code coverage report
Current view: top level - libreoffice/forms/source/component - File.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 109 0.0 %
Date: 2012-12-27 Functions: 0 22 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 "File.hxx"
      21             : 
      22             : #include <com/sun/star/form/FormComponentType.hpp>
      23             : 
      24             : #include "property.hrc"
      25             : #include "services.hxx"
      26             : #include <tools/debug.hxx>
      27             : #include <comphelper/container.hxx>
      28             : #include <comphelper/basicio.hxx>
      29             : #include <comphelper/guarding.hxx>
      30             : 
      31             : //.........................................................................
      32             : namespace frm
      33             : {
      34             : //.........................................................................
      35             : using namespace ::com::sun::star::uno;
      36             : using namespace ::com::sun::star::sdb;
      37             : using namespace ::com::sun::star::sdbc;
      38             : using namespace ::com::sun::star::sdbcx;
      39             : using namespace ::com::sun::star::beans;
      40             : using namespace ::com::sun::star::container;
      41             : using namespace ::com::sun::star::form;
      42             : using namespace ::com::sun::star::awt;
      43             : using namespace ::com::sun::star::io;
      44             : using namespace ::com::sun::star::lang;
      45             : using namespace ::com::sun::star::util;
      46             : 
      47             : //------------------------------------------------------------------
      48           0 : InterfaceRef SAL_CALL OFileControlModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
      49             : {
      50           0 :     return *(new OFileControlModel(_rxFactory));
      51             : }
      52             : 
      53             : //------------------------------------------------------------------------------
      54           0 : Sequence<Type> OFileControlModel::_getTypes()
      55             : {
      56           0 :     static Sequence<Type> aTypes;
      57           0 :     if (!aTypes.getLength())
      58             :     {
      59             :         // my base class
      60           0 :         Sequence<Type> aBaseClassTypes = OControlModel::_getTypes();
      61             : 
      62           0 :         Sequence<Type> aOwnTypes(1);
      63           0 :         Type* pOwnTypes = aOwnTypes.getArray();
      64           0 :         pOwnTypes[0] = getCppuType((Reference<XReset>*)NULL);
      65             : 
      66           0 :         aTypes = concatSequences(aBaseClassTypes, aOwnTypes);
      67             :     }
      68           0 :     return aTypes;
      69             : }
      70             : 
      71             : 
      72             : // XServiceInfo
      73             : //------------------------------------------------------------------------------
      74           0 : StringSequence  OFileControlModel::getSupportedServiceNames() throw(RuntimeException)
      75             : {
      76           0 :     StringSequence aSupported = OControlModel::getSupportedServiceNames();
      77           0 :     aSupported.realloc(aSupported.getLength() + 1);
      78             : 
      79           0 :     ::rtl::OUString*pArray = aSupported.getArray();
      80           0 :     pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_FILECONTROL;
      81           0 :     return aSupported;
      82             : }
      83             : 
      84             : //------------------------------------------------------------------
      85             : DBG_NAME( OFileControlModel )
      86             : //------------------------------------------------------------------
      87           0 : OFileControlModel::OFileControlModel(const Reference<XMultiServiceFactory>& _rxFactory)
      88             :                     :OControlModel(_rxFactory, VCL_CONTROLMODEL_FILECONTROL)
      89           0 :                     ,m_aResetListeners(m_aMutex)
      90             : {
      91             :     DBG_CTOR( OFileControlModel, NULL );
      92           0 :     m_nClassId = FormComponentType::FILECONTROL;
      93           0 : }
      94             : 
      95             : //------------------------------------------------------------------
      96           0 : OFileControlModel::OFileControlModel( const OFileControlModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory )
      97             :     :OControlModel( _pOriginal, _rxFactory )
      98           0 :     ,m_aResetListeners( m_aMutex )
      99             : {
     100             :     DBG_CTOR( OFileControlModel, NULL );
     101             : 
     102           0 :     m_sDefaultValue = _pOriginal->m_sDefaultValue;
     103           0 : }
     104             : 
     105             : //------------------------------------------------------------------
     106           0 : OFileControlModel::~OFileControlModel()
     107             : {
     108           0 :     if (!OComponentHelper::rBHelper.bDisposed)
     109             :     {
     110           0 :         acquire();
     111           0 :         dispose();
     112             :     }
     113             :     DBG_DTOR( OFileControlModel, NULL );
     114           0 : }
     115             : 
     116             : //------------------------------------------------------------------------------
     117           0 : IMPLEMENT_DEFAULT_CLONING( OFileControlModel )
     118             : 
     119             : //------------------------------------------------------------------------------
     120           0 : Any SAL_CALL OFileControlModel::queryAggregation(const Type& _rType) throw (RuntimeException)
     121             : {
     122           0 :     Any aReturn = OControlModel::queryAggregation(_rType);
     123           0 :     if (!aReturn.hasValue())
     124             :         aReturn = ::cppu::queryInterface(_rType
     125             :             ,static_cast<XReset*>(this)
     126           0 :         );
     127             : 
     128           0 :     return aReturn;
     129             : }
     130             : 
     131             : // OComponentHelper
     132             : //-----------------------------------------------------------------------------
     133           0 : void OFileControlModel::disposing()
     134             : {
     135           0 :     OControlModel::disposing();
     136             : 
     137           0 :     EventObject aEvt(static_cast<XWeak*>(this));
     138           0 :     m_aResetListeners.disposeAndClear(aEvt);
     139           0 : }
     140             : 
     141             : //------------------------------------------------------------------------------
     142           0 : Any OFileControlModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const
     143             : {
     144           0 :     Any aReturn;
     145           0 :     switch ( _nHandle )
     146             :     {
     147             :         case PROPERTY_ID_DEFAULT_TEXT:
     148           0 :             return makeAny( ::rtl::OUString() );
     149             :     }
     150           0 :     return OControlModel::getPropertyDefaultByHandle( _nHandle );
     151             : }
     152             : 
     153             : //------------------------------------------------------------------------------
     154           0 : void OFileControlModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const
     155             : {
     156           0 :     switch (nHandle)
     157             :     {
     158           0 :         case PROPERTY_ID_DEFAULT_TEXT : rValue <<= m_sDefaultValue; break;
     159             :         default:
     160           0 :             OControlModel::getFastPropertyValue(rValue, nHandle);
     161             :     }
     162           0 : }
     163             : 
     164             : //------------------------------------------------------------------------------
     165           0 : void OFileControlModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) throw ( ::com::sun::star::uno::Exception)
     166             : {
     167           0 :     switch (nHandle)
     168             :     {
     169             :         case PROPERTY_ID_DEFAULT_TEXT :
     170             :             DBG_ASSERT(rValue.getValueType().getTypeClass() == TypeClass_STRING, "OFileControlModel::setFastPropertyValue_NoBroadcast : invalid type !" );
     171           0 :             rValue >>= m_sDefaultValue;
     172           0 :             break;
     173             :         default:
     174           0 :             OControlModel::setFastPropertyValue_NoBroadcast(nHandle, rValue);
     175             :     }
     176           0 : }
     177             : 
     178             : //------------------------------------------------------------------------------
     179           0 : sal_Bool OFileControlModel::convertFastPropertyValue(Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue)
     180             :                             throw( IllegalArgumentException )
     181             : {
     182           0 :     switch (nHandle)
     183             :     {
     184             :         case PROPERTY_ID_DEFAULT_TEXT :
     185           0 :             return tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sDefaultValue);
     186             :         default:
     187           0 :             return OControlModel::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
     188             :     }
     189             : }
     190             : 
     191             : //------------------------------------------------------------------------------
     192           0 : void OFileControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const
     193             : {
     194           0 :     BEGIN_DESCRIBE_PROPERTIES( 2, OControlModel )
     195           0 :         DECL_PROP1(DEFAULT_TEXT,    ::rtl::OUString,    BOUND);
     196           0 :         DECL_PROP1(TABINDEX,        sal_Int16,          BOUND);
     197             :     END_DESCRIBE_PROPERTIES();
     198           0 : }
     199             : 
     200             : //------------------------------------------------------------------------------
     201           0 : ::rtl::OUString SAL_CALL OFileControlModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException)
     202             : {
     203           0 :     return FRM_COMPONENT_FILECONTROL;   // old (non-sun) name for compatibility !
     204             : }
     205             : 
     206             : //------------------------------------------------------------------------------
     207           0 : void OFileControlModel::write(const Reference<stario::XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
     208             : {
     209           0 :     OControlModel::write(_rxOutStream);
     210             : 
     211           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     212             : 
     213             :     // Version
     214           0 :     _rxOutStream->writeShort(0x0002);
     215             :     // Default-Wert
     216           0 :     _rxOutStream << m_sDefaultValue;
     217           0 :     writeHelpTextCompatibly(_rxOutStream);
     218           0 : }
     219             : 
     220             : //------------------------------------------------------------------------------
     221           0 : void OFileControlModel::read(const Reference<stario::XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
     222             : {
     223           0 :     OControlModel::read(_rxInStream);
     224           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     225             : 
     226             :     // Version
     227           0 :     sal_uInt16 nVersion = _rxInStream->readShort();
     228             :     // Default-Wert
     229           0 :     switch (nVersion)
     230             :     {
     231             :         case 1:
     232           0 :             _rxInStream >> m_sDefaultValue; break;
     233             :         case 2:
     234           0 :             _rxInStream >> m_sDefaultValue;
     235           0 :             readHelpTextCompatibly(_rxInStream);
     236           0 :             break;
     237             :         default:
     238             :             OSL_FAIL("OFileControlModel::read : unknown version !");
     239           0 :             m_sDefaultValue = ::rtl::OUString();
     240           0 :     }
     241             : 
     242             :     // Display default values after read
     243             : //  _reset();
     244           0 : }
     245             : 
     246             : //-----------------------------------------------------------------------------
     247           0 : void SAL_CALL OFileControlModel::reset() throw ( ::com::sun::star::uno::RuntimeException)
     248             : {
     249           0 :     ::cppu::OInterfaceIteratorHelper aIter(m_aResetListeners);
     250           0 :     EventObject aEvt(static_cast<XWeak*>(this));
     251           0 :     sal_Bool bContinue = sal_True;
     252           0 :     while (aIter.hasMoreElements() && bContinue)
     253           0 :         bContinue =((XResetListener*)aIter.next())->approveReset(aEvt);
     254             : 
     255           0 :     if (bContinue)
     256             :     {
     257             :         {
     258             :             // If Models are threadSave
     259           0 :             ::osl::MutexGuard aGuard(m_aMutex);
     260           0 :             _reset();
     261             :         }
     262           0 :         m_aResetListeners.notifyEach( &XResetListener::resetted, aEvt );
     263           0 :     }
     264           0 : }
     265             : 
     266             : //-----------------------------------------------------------------------------
     267           0 : void OFileControlModel::addResetListener(const Reference<XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException)
     268             : {
     269           0 :     m_aResetListeners.addInterface(_rxListener);
     270           0 : }
     271             : 
     272             : //-----------------------------------------------------------------------------
     273           0 : void OFileControlModel::removeResetListener(const Reference<XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException)
     274             : {
     275           0 :     m_aResetListeners.removeInterface(_rxListener);
     276           0 : }
     277             : 
     278             : //------------------------------------------------------------------------------
     279           0 : void OFileControlModel::_reset()
     280             : {
     281             :     {   // release our mutex once (it's acquired in the calling method !), as setting aggregate properties
     282             :         // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with
     283             :         // our own mutex locked
     284           0 :         MutexRelease aRelease(m_aMutex);
     285           0 :         m_xAggregateSet->setPropertyValue(PROPERTY_TEXT, makeAny(m_sDefaultValue));
     286             :     }
     287           0 : }
     288             : 
     289             : //.........................................................................
     290             : }   // namespace frm
     291             : //.........................................................................
     292             : 
     293             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10