LCOV - code coverage report
Current view: top level - forms/source/component - Hidden.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 49 56 87.5 %
Date: 2015-06-13 12:38:46 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           7 : OHiddenModel::OHiddenModel(const Reference<XComponentContext>& _rxFactory)
      45           7 :     :OControlModel(_rxFactory, OUString())
      46             : {
      47           7 :     m_nClassId = FormComponentType::HIDDENCONTROL;
      48           7 : }
      49             : 
      50             : 
      51           0 : OHiddenModel::OHiddenModel( const OHiddenModel* _pOriginal, const Reference<XComponentContext>& _rxFactory )
      52           0 :     :OControlModel( _pOriginal, _rxFactory )
      53             : {
      54           0 :     m_sHiddenValue = _pOriginal->m_sHiddenValue;
      55           0 : }
      56             : 
      57             : 
      58          14 : OHiddenModel::~OHiddenModel( )
      59             : {
      60          14 : }
      61             : 
      62             : 
      63           0 : IMPLEMENT_DEFAULT_CLONING( OHiddenModel )
      64             : 
      65             : 
      66          42 : void OHiddenModel::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
      67             : {
      68          42 :     switch (_nHandle)
      69             :     {
      70          10 :         case PROPERTY_ID_HIDDEN_VALUE : _rValue <<= m_sHiddenValue; break;
      71             :         default:
      72          32 :             OControlModel::getFastPropertyValue(_rValue, _nHandle);
      73             :     }
      74          42 : }
      75             : 
      76             : 
      77          22 : void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (com::sun::star::uno::Exception, std::exception)
      78             : {
      79          22 :     switch (_nHandle)
      80             :     {
      81             :         case PROPERTY_ID_HIDDEN_VALUE :
      82             :             DBG_ASSERT(_rValue.getValueType().getTypeClass() == TypeClass_STRING, "OHiddenModel::setFastPropertyValue_NoBroadcast : invalid type !" );
      83           6 :             _rValue >>= m_sHiddenValue;
      84           6 :             break;
      85             :         default:
      86          16 :             OControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
      87             :     }
      88          22 : }
      89             : 
      90             : 
      91          23 : sal_Bool OHiddenModel::convertFastPropertyValue(
      92             :             Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue)
      93             :             throw (IllegalArgumentException)
      94             : {
      95          23 :     bool bModified(false);
      96          23 :     switch (_nHandle)
      97             :     {
      98             :         case PROPERTY_ID_HIDDEN_VALUE :
      99           6 :             bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sHiddenValue);
     100           6 :             break;
     101             :         default:
     102          17 :             bModified = OControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
     103          16 :             break;
     104             :     }
     105          22 :     return bModified;
     106             : }
     107             : 
     108             : 
     109           7 : void OHiddenModel::describeFixedProperties( Sequence< Property >& _rProps ) const
     110             : {
     111           7 :     BEGIN_DESCRIBE_BASE_PROPERTIES(4)
     112           7 :         DECL_PROP2(CLASSID,         sal_Int16,          READONLY, TRANSIENT);
     113           7 :         DECL_PROP1(HIDDEN_VALUE,    OUString,    BOUND);
     114           7 :         DECL_PROP1(NAME,            OUString,    BOUND);
     115           7 :         DECL_PROP1(TAG,             OUString,    BOUND);
     116             :     END_DESCRIBE_PROPERTIES();
     117           7 : }
     118             : 
     119             : // XServiceInfo
     120             : 
     121          30 : StringSequence SAL_CALL OHiddenModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception)
     122             : {
     123             :     return css::uno::Sequence<OUString>{
     124             :         FRM_SUN_COMPONENT_HIDDENCONTROL, FRM_SUN_FORMCOMPONENT,
     125          30 :         FRM_COMPONENT_HIDDEN, FRM_COMPONENT_HIDDENCONTROL };
     126             : }
     127             : 
     128             : 
     129           1 : OUString SAL_CALL OHiddenModel::getServiceName() throw(RuntimeException, std::exception)
     130             : {
     131           1 :     return OUString(FRM_COMPONENT_HIDDEN);    // old (non-sun) name for compatibility !
     132             : }
     133             : 
     134             : 
     135           1 : void SAL_CALL OHiddenModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
     136             :     throw(IOException, RuntimeException, std::exception)
     137             : {
     138             :     // Version
     139           1 :     _rxOutStream->writeShort(0x0002);
     140             : 
     141             :     // Value
     142           1 :     _rxOutStream << m_sHiddenValue;
     143             : 
     144           1 :     OControlModel::write(_rxOutStream);
     145           1 : }
     146             : 
     147             : 
     148           1 : void SAL_CALL OHiddenModel::read(const Reference<XObjectInputStream>& _rxInStream) throw(IOException, RuntimeException, std::exception)
     149             : {
     150             :     // Version
     151           1 :     sal_uInt16 nVersion = _rxInStream->readShort();
     152             : 
     153             :     // Name
     154             :     DBG_ASSERT(nVersion != 1, "OHiddenModel::read : this version is obsolete !");
     155           1 :     switch (nVersion)
     156             :     {
     157           0 :         case 1 : { OUString sDummy; _rxInStream >> sDummy; _rxInStream >> m_sHiddenValue; } break;
     158           1 :         case 2 : _rxInStream >> m_sHiddenValue; break;
     159           0 :         default : OSL_FAIL("OHiddenModel::read : unknown version !"); m_sHiddenValue.clear();
     160             :     }
     161           1 :     OControlModel::read(_rxInStream);
     162           1 : }
     163             : 
     164             : }
     165             : 
     166             : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
     167           7 : com_sun_star_form_OHiddenModel_get_implementation(::com::sun::star::uno::XComponentContext* component,
     168             :         ::com::sun::star::uno::Sequence<css::uno::Any> const &)
     169             : {
     170           7 :     return cppu::acquire(new frm::OHiddenModel(component));
     171             : }
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11