LCOV - code coverage report
Current view: top level - forms/source/component - Hidden.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 52 59 88.1 %
Date: 2014-04-11 Functions: 12 14 85.7 %
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 "Hidden.hxx"
      21             : #include "property.hxx"
      22             : #include "property.hrc"
      23             : #include "services.hxx"
      24             : #include <tools/debug.hxx>
      25             : #include <comphelper/basicio.hxx>
      26             : #include <comphelper/processfactory.hxx>
      27             : 
      28             : 
      29             : namespace frm
      30             : {
      31             : using namespace ::com::sun::star::uno;
      32             : using namespace ::com::sun::star::sdb;
      33             : using namespace ::com::sun::star::sdbc;
      34             : using namespace ::com::sun::star::sdbcx;
      35             : using namespace ::com::sun::star::beans;
      36             : using namespace ::com::sun::star::container;
      37             : using namespace ::com::sun::star::form;
      38             : using namespace ::com::sun::star::awt;
      39             : using namespace ::com::sun::star::io;
      40             : using namespace ::com::sun::star::lang;
      41             : using namespace ::com::sun::star::util;
      42             : 
      43             : 
      44           6 : InterfaceRef SAL_CALL OHiddenModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) throw (RuntimeException)
      45             : {
      46           6 :     return *(new OHiddenModel( comphelper::getComponentContext(_rxFactory) ));
      47             : }
      48             : 
      49             : 
      50             : 
      51           6 : OHiddenModel::OHiddenModel(const Reference<XComponentContext>& _rxFactory)
      52           6 :     :OControlModel(_rxFactory, OUString())
      53             : {
      54           6 :     m_nClassId = FormComponentType::HIDDENCONTROL;
      55           6 : }
      56             : 
      57             : 
      58           0 : OHiddenModel::OHiddenModel( const OHiddenModel* _pOriginal, const Reference<XComponentContext>& _rxFactory )
      59           0 :     :OControlModel( _pOriginal, _rxFactory )
      60             : {
      61           0 :     m_sHiddenValue = _pOriginal->m_sHiddenValue;
      62           0 : }
      63             : 
      64             : 
      65          12 : OHiddenModel::~OHiddenModel( )
      66             : {
      67          12 : }
      68             : 
      69             : 
      70           0 : IMPLEMENT_DEFAULT_CLONING( OHiddenModel )
      71             : 
      72             : 
      73          42 : void OHiddenModel::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
      74             : {
      75          42 :     switch (_nHandle)
      76             :     {
      77          10 :         case PROPERTY_ID_HIDDEN_VALUE : _rValue <<= m_sHiddenValue; break;
      78             :         default:
      79          32 :             OControlModel::getFastPropertyValue(_rValue, _nHandle);
      80             :     }
      81          42 : }
      82             : 
      83             : 
      84          22 : void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (com::sun::star::uno::Exception, std::exception)
      85             : {
      86          22 :     switch (_nHandle)
      87             :     {
      88             :         case PROPERTY_ID_HIDDEN_VALUE :
      89             :             DBG_ASSERT(_rValue.getValueType().getTypeClass() == TypeClass_STRING, "OHiddenModel::setFastPropertyValue_NoBroadcast : invalid type !" );
      90           6 :             _rValue >>= m_sHiddenValue;
      91           6 :             break;
      92             :         default:
      93          16 :             OControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
      94             :     }
      95          22 : }
      96             : 
      97             : 
      98          23 : sal_Bool OHiddenModel::convertFastPropertyValue(
      99             :             Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue)
     100             :             throw (IllegalArgumentException)
     101             : {
     102          23 :     sal_Bool bModified(sal_False);
     103          23 :     switch (_nHandle)
     104             :     {
     105             :         case PROPERTY_ID_HIDDEN_VALUE :
     106           6 :             bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sHiddenValue);
     107           6 :             break;
     108             :         default:
     109          17 :             bModified = OControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
     110          16 :             break;
     111             :     }
     112          22 :     return bModified;
     113             : }
     114             : 
     115             : 
     116           7 : void OHiddenModel::describeFixedProperties( Sequence< Property >& _rProps ) const
     117             : {
     118           7 :     BEGIN_DESCRIBE_BASE_PROPERTIES(4)
     119           7 :         DECL_PROP2(CLASSID,         sal_Int16,          READONLY, TRANSIENT);
     120           7 :         DECL_PROP1(HIDDEN_VALUE,    OUString,    BOUND);
     121           7 :         DECL_PROP1(NAME,            OUString,    BOUND);
     122           7 :         DECL_PROP1(TAG,             OUString,    BOUND);
     123             :     END_DESCRIBE_PROPERTIES();
     124           7 : }
     125             : 
     126             : // XServiceInfo
     127             : 
     128          17 : StringSequence SAL_CALL OHiddenModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception)
     129             : {
     130          17 :     StringSequence aSupported( 2 );
     131          17 :     aSupported[ 0 ] = FRM_SUN_COMPONENT_HIDDENCONTROL;
     132          17 :     aSupported[ 1 ] = FRM_SUN_FORMCOMPONENT;
     133          17 :     return aSupported;
     134             : }
     135             : 
     136             : 
     137           1 : OUString SAL_CALL OHiddenModel::getServiceName() throw(RuntimeException, std::exception)
     138             : {
     139           1 :     return OUString(FRM_COMPONENT_HIDDEN);    // old (non-sun) name for compatibility !
     140             : }
     141             : 
     142             : 
     143           1 : void SAL_CALL OHiddenModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
     144             :     throw(IOException, RuntimeException, std::exception)
     145             : {
     146             :     // Version
     147           1 :     _rxOutStream->writeShort(0x0002);
     148             : 
     149             :     // Wert
     150           1 :     _rxOutStream << m_sHiddenValue;
     151             : 
     152           1 :     OControlModel::write(_rxOutStream);
     153           1 : }
     154             : 
     155             : 
     156           1 : void SAL_CALL OHiddenModel::read(const Reference<XObjectInputStream>& _rxInStream) throw(IOException, RuntimeException, std::exception)
     157             : {
     158             :     // Version
     159           1 :     sal_uInt16 nVersion = _rxInStream->readShort();
     160             : 
     161             :     // Name
     162             :     DBG_ASSERT(nVersion != 1, "OHiddenModel::read : this version is obsolete !");
     163           1 :     switch (nVersion)
     164             :     {
     165           0 :         case 1 : { OUString sDummy; _rxInStream >> sDummy; _rxInStream >> m_sHiddenValue; } break;
     166           1 :         case 2 : _rxInStream >> m_sHiddenValue; break;
     167           0 :         default : OSL_FAIL("OHiddenModel::read : unknown version !"); m_sHiddenValue = OUString();
     168             :     }
     169           1 :     OControlModel::read(_rxInStream);
     170           1 : }
     171             : 
     172             : 
     173             : }
     174             : 
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10