LCOV - code coverage report
Current view: top level - toolkit/source/controls - geometrycontrolmodel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 159 240 66.2 %
Date: 2012-08-25 Functions: 25 35 71.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 142 418 34.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "toolkit/controls/geometrycontrolmodel.hxx"
      30                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      31                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      32                 :            : #include <osl/diagnose.h>
      33                 :            : #include <rtl/instance.hxx>
      34                 :            : #include <comphelper/property.hxx>
      35                 :            : #include <comphelper/sequence.hxx>
      36                 :            : #include <toolkit/controls/eventcontainer.hxx>
      37                 :            : #include <toolkit/helper/property.hxx>
      38                 :            : #include <algorithm>
      39                 :            : #include <functional>
      40                 :            : #include <comphelper/sequence.hxx>
      41                 :            : 
      42                 :            : 
      43                 :            : #define GCM_PROPERTY_ID_POS_X               1
      44                 :            : #define GCM_PROPERTY_ID_POS_Y               2
      45                 :            : #define GCM_PROPERTY_ID_WIDTH               3
      46                 :            : #define GCM_PROPERTY_ID_HEIGHT              4
      47                 :            : #define GCM_PROPERTY_ID_NAME                5
      48                 :            : #define GCM_PROPERTY_ID_TABINDEX            6
      49                 :            : #define GCM_PROPERTY_ID_STEP                7
      50                 :            : #define GCM_PROPERTY_ID_TAG                 8
      51                 :            : #define GCM_PROPERTY_ID_RESOURCERESOLVER    9
      52                 :            : 
      53                 :            : #define GCM_PROPERTY_POS_X              ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionX"))
      54                 :            : #define GCM_PROPERTY_POS_Y              ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionY"))
      55                 :            : #define GCM_PROPERTY_WIDTH              ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Width"))
      56                 :            : #define GCM_PROPERTY_HEIGHT             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Height"))
      57                 :            : #define GCM_PROPERTY_NAME               ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"))
      58                 :            : #define GCM_PROPERTY_TABINDEX           ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TabIndex"))
      59                 :            : #define GCM_PROPERTY_STEP               ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Step"))
      60                 :            : #define GCM_PROPERTY_TAG                ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Tag"))
      61                 :            : #define GCM_PROPERTY_RESOURCERESOLVER   ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ResourceResolver"))
      62                 :            : 
      63                 :            : #define DEFAULT_ATTRIBS()       PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT
      64                 :            : 
      65                 :            : //........................................................................
      66                 :            : // namespace toolkit
      67                 :            : // {
      68                 :            : //........................................................................
      69                 :            : 
      70                 :            :     using namespace ::com::sun::star;
      71                 :            :     using namespace ::com::sun::star::uno;
      72                 :            :     using namespace ::com::sun::star::lang;
      73                 :            :     using namespace ::com::sun::star::beans;
      74                 :            :     using namespace ::com::sun::star::util;
      75                 :            :     using namespace ::com::sun::star::container;
      76                 :            :     using namespace ::comphelper;
      77                 :            : 
      78                 :            :     //====================================================================
      79                 :            :     //= OGeometryControlModel_Base
      80                 :            :     //====================================================================
      81                 :            :     //--------------------------------------------------------------------
      82                 :         62 :     OGeometryControlModel_Base::OGeometryControlModel_Base(::com::sun::star::uno::XAggregation* _pAggregateInstance)
      83                 :            :         :OPropertySetAggregationHelper( m_aBHelper )
      84                 :            :         ,OPropertyContainer( m_aBHelper )
      85                 :            :         ,OGCM_Base( m_aMutex )
      86                 :            :         ,m_nPosX(0)
      87                 :            :         ,m_nPosY(0)
      88                 :            :         ,m_nWidth(0)
      89                 :            :         ,m_nHeight(0)
      90                 :            :         ,m_nTabIndex(-1)
      91                 :            :         ,m_nStep(0)
      92 [ +  - ][ +  - ]:         62 :         ,m_bCloneable(sal_False)
      93                 :            :     {
      94                 :            :         OSL_ENSURE(NULL != _pAggregateInstance, "OGeometryControlModel_Base::OGeometryControlModel_Base: invalid aggregate!");
      95                 :            : 
      96         [ +  - ]:         62 :         increment(m_refCount);
      97                 :            :         {
      98         [ +  - ]:         62 :             m_xAggregate = _pAggregateInstance;
      99                 :            : 
     100                 :            :             {   // check if the aggregat is cloneable
     101         [ +  - ]:         62 :                 Reference< XCloneable > xCloneAccess(m_xAggregate, UNO_QUERY);
     102                 :         62 :                 m_bCloneable = xCloneAccess.is();
     103                 :            :             }
     104                 :            : 
     105         [ +  - ]:         62 :             setAggregation(m_xAggregate);
     106 [ +  - ][ +  - ]:         62 :             m_xAggregate->setDelegator(static_cast< XWeak* >(this));
                 [ +  - ]
     107                 :            :         }
     108         [ +  - ]:         62 :         decrement(m_refCount);
     109                 :            : 
     110         [ +  - ]:         62 :         registerProperties();
     111                 :         62 :     }
     112                 :            : 
     113                 :            :     //--------------------------------------------------------------------
     114                 :         28 :     OGeometryControlModel_Base::OGeometryControlModel_Base(Reference< XCloneable >& _rxAggregateInstance)
     115                 :            :         :OPropertySetAggregationHelper( m_aBHelper )
     116                 :            :         ,OPropertyContainer( m_aBHelper )
     117                 :            :         ,OGCM_Base( m_aMutex )
     118                 :            :         ,m_nPosX(0)
     119                 :            :         ,m_nPosY(0)
     120                 :            :         ,m_nWidth(0)
     121                 :            :         ,m_nHeight(0)
     122                 :            :         ,m_nTabIndex(-1)
     123                 :            :         ,m_nStep(0)
     124 [ +  - ][ +  - ]:         28 :         ,m_bCloneable(_rxAggregateInstance.is())
     125                 :            :     {
     126         [ +  - ]:         28 :         increment(m_refCount);
     127                 :            :         {
     128                 :            :             {
     129                 :            :                 // ensure that the temporary gets destructed NOW
     130 [ +  - ][ +  - ]:         28 :                 m_xAggregate = Reference< XAggregation >(_rxAggregateInstance, UNO_QUERY);
     131                 :            :             }
     132                 :            :             OSL_ENSURE(m_xAggregate.is(), "OGeometryControlModel_Base::OGeometryControlModel_Base: invalid object given!");
     133                 :            : 
     134                 :            :             // now the aggregate has a ref count of 2, but before setting the delegator it must be 1
     135                 :         28 :             _rxAggregateInstance.clear();
     136                 :            :             // now it should be the 1 we need here ...
     137                 :            : 
     138         [ +  - ]:         28 :             setAggregation(m_xAggregate);
     139 [ +  - ][ +  - ]:         28 :             m_xAggregate->setDelegator(static_cast< XWeak* >(this));
                 [ +  - ]
     140                 :            :         }
     141         [ +  - ]:         28 :         decrement(m_refCount);
     142                 :            : 
     143         [ +  - ]:         28 :         registerProperties();
     144                 :         28 :     }
     145                 :            : 
     146                 :            :     //--------------------------------------------------------------------
     147                 :          0 :     Sequence< Type > SAL_CALL OGeometryControlModel_Base::getTypes(  ) throw (RuntimeException)
     148                 :            :     {
     149                 :            :         // our own types
     150                 :            :         Sequence< Type > aTypes = ::comphelper::concatSequences(
     151                 :            :             OPropertySetAggregationHelper::getTypes(),
     152                 :            :             OPropertyContainer::getTypes(),
     153                 :            :             OGCM_Base::getTypes()
     154 [ #  # ][ #  # ]:          0 :         );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     155                 :            : 
     156         [ #  # ]:          0 :         if ( m_xAggregate.is() )
     157                 :            :         {
     158                 :            :             // retrieve the types of the aggregate
     159                 :          0 :             Reference< XTypeProvider > xAggregateTypeProv;
     160 [ #  # ][ #  # ]:          0 :             m_xAggregate->queryAggregation( ::getCppuType( &xAggregateTypeProv ) ) >>= xAggregateTypeProv;
         [ #  # ][ #  # ]
     161                 :            :             OSL_ENSURE( xAggregateTypeProv.is(), "OGeometryControlModel_Base::getTypes: aggregate should be a type provider!" );
     162         [ #  # ]:          0 :             Sequence< Type > aAggTypes;
     163         [ #  # ]:          0 :             if ( xAggregateTypeProv.is() )
     164 [ #  # ][ #  # ]:          0 :                 aAggTypes = xAggregateTypeProv->getTypes();
         [ #  # ][ #  # ]
     165                 :            : 
     166                 :            :             // concat the sequences
     167                 :          0 :             sal_Int32 nOldSize = aTypes.getLength();
     168         [ #  # ]:          0 :             aTypes.realloc( nOldSize + aAggTypes.getLength() );
     169                 :            :             ::std::copy(
     170                 :            :                 aAggTypes.getConstArray(),
     171                 :          0 :                 aAggTypes.getConstArray() + aAggTypes.getLength(),
     172         [ #  # ]:          0 :                 aTypes.getArray() + nOldSize
     173 [ #  # ][ #  # ]:          0 :             );
     174                 :            :         }
     175                 :            : 
     176                 :          0 :         return aTypes;
     177                 :            :     }
     178                 :            : 
     179                 :            :     //--------------------------------------------------------------------
     180                 :         90 :     void OGeometryControlModel_Base::registerProperties()
     181                 :            :     {
     182                 :            :         // register our members for the property handling of the OPropertyContainer
     183         [ +  - ]:         90 :         registerProperty(GCM_PROPERTY_POS_X,    GCM_PROPERTY_ID_POS_X,      DEFAULT_ATTRIBS(), &m_nPosX, ::getCppuType(&m_nPosX));
     184         [ +  - ]:         90 :         registerProperty(GCM_PROPERTY_POS_Y,    GCM_PROPERTY_ID_POS_Y,      DEFAULT_ATTRIBS(), &m_nPosY, ::getCppuType(&m_nPosY));
     185         [ +  - ]:         90 :         registerProperty(GCM_PROPERTY_WIDTH,    GCM_PROPERTY_ID_WIDTH,      DEFAULT_ATTRIBS(), &m_nWidth, ::getCppuType(&m_nWidth));
     186         [ +  - ]:         90 :         registerProperty(GCM_PROPERTY_HEIGHT,   GCM_PROPERTY_ID_HEIGHT,     DEFAULT_ATTRIBS(), &m_nHeight, ::getCppuType(&m_nHeight));
     187         [ +  - ]:         90 :         registerProperty(GCM_PROPERTY_NAME,     GCM_PROPERTY_ID_NAME,       DEFAULT_ATTRIBS(), &m_aName, ::getCppuType(&m_aName));
     188         [ +  - ]:         90 :         registerProperty(GCM_PROPERTY_TABINDEX, GCM_PROPERTY_ID_TABINDEX,   DEFAULT_ATTRIBS(), &m_nTabIndex, ::getCppuType(&m_nTabIndex));
     189         [ +  - ]:         90 :         registerProperty(GCM_PROPERTY_STEP,     GCM_PROPERTY_ID_STEP,       DEFAULT_ATTRIBS(), &m_nStep, ::getCppuType(&m_nStep));
     190         [ +  - ]:         90 :         registerProperty(GCM_PROPERTY_TAG,      GCM_PROPERTY_ID_TAG,        DEFAULT_ATTRIBS(), &m_aTag, ::getCppuType(&m_aTag));
     191         [ +  - ]:         90 :         registerProperty(GCM_PROPERTY_RESOURCERESOLVER, GCM_PROPERTY_ID_RESOURCERESOLVER, DEFAULT_ATTRIBS(), &m_xStrResolver, ::getCppuType(&m_xStrResolver));
     192                 :         90 :     }
     193                 :            : 
     194                 :            :     //--------------------------------------------------------------------
     195                 :          0 :     ::com::sun::star::uno::Any OGeometryControlModel_Base::ImplGetDefaultValueByHandle(sal_Int32 nHandle) const
     196                 :            :     {
     197                 :          0 :         ::com::sun::star::uno::Any aDefault;
     198                 :            : 
     199   [ #  #  #  #  :          0 :         switch ( nHandle )
          #  #  #  #  #  
                      # ]
     200                 :            :         {
     201         [ #  # ]:          0 :             case GCM_PROPERTY_ID_POS_X:             aDefault <<= (sal_Int32) 0; break;
     202         [ #  # ]:          0 :             case GCM_PROPERTY_ID_POS_Y:             aDefault <<= (sal_Int32) 0; break;
     203         [ #  # ]:          0 :             case GCM_PROPERTY_ID_WIDTH:             aDefault <<= (sal_Int32) 0; break;
     204         [ #  # ]:          0 :             case GCM_PROPERTY_ID_HEIGHT:            aDefault <<= (sal_Int32) 0; break;
     205         [ #  # ]:          0 :             case GCM_PROPERTY_ID_NAME:              aDefault <<= ::rtl::OUString(); break;
     206         [ #  # ]:          0 :             case GCM_PROPERTY_ID_TABINDEX:          aDefault <<= (sal_Int16) -1; break;
     207         [ #  # ]:          0 :             case GCM_PROPERTY_ID_STEP:              aDefault <<= (sal_Int32) 0; break;
     208         [ #  # ]:          0 :             case GCM_PROPERTY_ID_TAG:               aDefault <<= ::rtl::OUString(); break;
     209         [ #  # ]:          0 :             case GCM_PROPERTY_ID_RESOURCERESOLVER:  aDefault <<= Reference< resource::XStringResourceResolver >(); break;
     210                 :            :             default:                            OSL_FAIL( "ImplGetDefaultValueByHandle - unknown Property" );
     211                 :            :         }
     212                 :            : 
     213                 :          0 :         return aDefault;
     214                 :            :     }
     215                 :            : 
     216                 :            :     //--------------------------------------------------------------------
     217                 :          0 :     ::com::sun::star::uno::Any OGeometryControlModel_Base::ImplGetPropertyValueByHandle(sal_Int32 nHandle) const
     218                 :            :     {
     219                 :          0 :         ::com::sun::star::uno::Any aValue;
     220                 :            : 
     221   [ #  #  #  #  :          0 :         switch ( nHandle )
          #  #  #  #  #  
                      # ]
     222                 :            :         {
     223         [ #  # ]:          0 :             case GCM_PROPERTY_ID_POS_X:         aValue <<= m_nPosX; break;
     224         [ #  # ]:          0 :             case GCM_PROPERTY_ID_POS_Y:         aValue <<= m_nPosY; break;
     225         [ #  # ]:          0 :             case GCM_PROPERTY_ID_WIDTH:         aValue <<= m_nWidth; break;
     226         [ #  # ]:          0 :             case GCM_PROPERTY_ID_HEIGHT:        aValue <<= m_nHeight; break;
     227         [ #  # ]:          0 :             case GCM_PROPERTY_ID_NAME:          aValue <<= m_aName; break;
     228         [ #  # ]:          0 :             case GCM_PROPERTY_ID_TABINDEX:      aValue <<= m_nTabIndex; break;
     229         [ #  # ]:          0 :             case GCM_PROPERTY_ID_STEP:          aValue <<= m_nStep; break;
     230         [ #  # ]:          0 :             case GCM_PROPERTY_ID_TAG:           aValue <<= m_aTag; break;
     231         [ #  # ]:          0 :             case GCM_PROPERTY_ID_RESOURCERESOLVER: aValue <<= m_xStrResolver; break;
     232                 :            :             default:                            OSL_FAIL( "ImplGetPropertyValueByHandle - unknown Property" );
     233                 :            :         }
     234                 :            : 
     235                 :          0 :         return aValue;
     236                 :            :     }
     237                 :            : 
     238                 :            :     //--------------------------------------------------------------------
     239                 :          0 :     void OGeometryControlModel_Base::ImplSetPropertyValueByHandle(sal_Int32 nHandle, const :: com::sun::star::uno::Any& aValue)
     240                 :            :     {
     241   [ #  #  #  #  :          0 :         switch ( nHandle )
          #  #  #  #  #  
                      # ]
     242                 :            :         {
     243                 :          0 :             case GCM_PROPERTY_ID_POS_X:         aValue >>= m_nPosX; break;
     244                 :          0 :             case GCM_PROPERTY_ID_POS_Y:         aValue >>= m_nPosY; break;
     245                 :          0 :             case GCM_PROPERTY_ID_WIDTH:         aValue >>= m_nWidth; break;
     246                 :          0 :             case GCM_PROPERTY_ID_HEIGHT:        aValue >>= m_nHeight; break;
     247                 :          0 :             case GCM_PROPERTY_ID_NAME:          aValue >>= m_aName; break;
     248                 :          0 :             case GCM_PROPERTY_ID_TABINDEX:      aValue >>= m_nTabIndex; break;
     249                 :          0 :             case GCM_PROPERTY_ID_STEP:          aValue >>= m_nStep; break;
     250                 :          0 :             case GCM_PROPERTY_ID_TAG:           aValue >>= m_aTag; break;
     251                 :          0 :             case GCM_PROPERTY_ID_RESOURCERESOLVER: aValue >>= m_xStrResolver; break;
     252                 :            :             default:                            OSL_FAIL( "ImplSetPropertyValueByHandle - unknown Property" );
     253                 :            :         }
     254                 :          0 :     }
     255                 :            : 
     256                 :            :     //--------------------------------------------------------------------
     257                 :       2944 :     Any SAL_CALL OGeometryControlModel_Base::queryAggregation( const Type& _rType ) throw(RuntimeException)
     258                 :            :     {
     259                 :       2944 :         Any aReturn;
     260 [ +  + ][ -  + ]:       2944 :         if (_rType.equals(::getCppuType(static_cast< Reference< XCloneable>* >(NULL))) && !m_bCloneable)
         [ -  + ][ +  - ]
     261                 :            :             // somebody is asking for the XCloneable interface, but our aggregate does not support it
     262                 :            :             // -> outta here
     263                 :            :             // (need this extra check, cause OGCM_Base::queryAggregation would return this interface
     264                 :            :             // in every case)
     265                 :          0 :             return aReturn;
     266                 :            : 
     267         [ +  - ]:       2944 :         aReturn = OGCM_Base::queryAggregation(_rType);
     268                 :            :             // the basic interfaces (XInterface, XAggregation etc)
     269                 :            : 
     270         [ +  + ]:       2944 :         if (!aReturn.hasValue())
     271         [ +  - ]:       1644 :             aReturn = OPropertySetAggregationHelper::queryInterface(_rType);
     272                 :            :             // the property set related interfaces
     273                 :            : 
     274 [ +  + ][ +  - ]:       2944 :         if (!aReturn.hasValue() && m_xAggregate.is())
                 [ +  + ]
     275 [ +  - ][ +  - ]:       1228 :             aReturn = m_xAggregate->queryAggregation(_rType);
     276                 :            :             // the interfaces our aggregate can provide
     277                 :            : 
     278                 :       2944 :         return aReturn;
     279                 :            :     }
     280                 :            : 
     281                 :            :     //--------------------------------------------------------------------
     282                 :       2944 :     Any SAL_CALL OGeometryControlModel_Base::queryInterface( const Type& _rType ) throw(RuntimeException)
     283                 :            :     {
     284                 :       2944 :         return OGCM_Base::queryInterface(_rType);
     285                 :            :     }
     286                 :            : 
     287                 :            :     //--------------------------------------------------------------------
     288                 :      28974 :     void SAL_CALL OGeometryControlModel_Base::acquire(  ) throw()
     289                 :            :     {
     290                 :      28974 :         OGCM_Base::acquire();
     291                 :      28974 :     }
     292                 :            : 
     293                 :            :     //--------------------------------------------------------------------
     294                 :      28862 :     void SAL_CALL OGeometryControlModel_Base::release(  ) throw()
     295                 :            :     {
     296                 :      28862 :         OGCM_Base::release();
     297                 :      28862 :     }
     298                 :            : 
     299                 :            :     //--------------------------------------------------------------------
     300                 :         64 :     void OGeometryControlModel_Base::releaseAggregation()
     301                 :            :     {
     302                 :            :         // release the aggregate (_before_ clearing m_xAggregate)
     303         [ +  - ]:         64 :         if (m_xAggregate.is())
     304         [ +  - ]:         64 :             m_xAggregate->setDelegator(NULL);
     305         [ +  - ]:         64 :         setAggregation(NULL);
     306                 :         64 :     }
     307                 :            : 
     308                 :            :     //--------------------------------------------------------------------
     309 [ +  - ][ +  - ]:         64 :     OGeometryControlModel_Base::~OGeometryControlModel_Base()
                 [ +  - ]
     310                 :            :     {
     311         [ +  - ]:         64 :         releaseAggregation();
     312         [ -  + ]:         64 :     }
     313                 :            : 
     314                 :            :     //--------------------------------------------------------------------
     315                 :        946 :     sal_Bool SAL_CALL OGeometryControlModel_Base::convertFastPropertyValue(Any& _rConvertedValue, Any& _rOldValue,
     316                 :            :             sal_Int32 _nHandle, const Any& _rValue) throw (IllegalArgumentException)
     317                 :            :     {
     318                 :        946 :         return OPropertyContainer::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
     319                 :            :     }
     320                 :            : 
     321                 :            :     //--------------------------------------------------------------------
     322                 :        212 :     void SAL_CALL OGeometryControlModel_Base::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (Exception)
     323                 :            :     {
     324                 :        212 :         OPropertyContainer::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
     325                 :        212 :     }
     326                 :            : 
     327                 :            :     //--------------------------------------------------------------------
     328                 :       4370 :     void SAL_CALL OGeometryControlModel_Base::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
     329                 :            :     {
     330         [ +  - ]:       4370 :         OPropertyArrayAggregationHelper& rPH = static_cast<OPropertyArrayAggregationHelper&>(const_cast<OGeometryControlModel_Base*>(this)->getInfoHelper());
     331                 :       4370 :         ::rtl::OUString sPropName;
     332                 :       4370 :         sal_Int32   nOriginalHandle = -1;
     333                 :            : 
     334 [ +  + ][ +  - ]:       4370 :         if (rPH.fillAggregatePropertyInfoByHandle(&sPropName, &nOriginalHandle, _nHandle))
     335         [ +  - ]:       3032 :             OPropertySetAggregationHelper::getFastPropertyValue(_rValue, _nHandle);
     336                 :            :         else
     337         [ +  - ]:       4370 :             OPropertyContainer::getFastPropertyValue(_rValue, _nHandle);
     338                 :       4370 :     }
     339                 :            : 
     340                 :            :     //--------------------------------------------------------------------
     341                 :          0 :     ::com::sun::star::beans::PropertyState OGeometryControlModel_Base::getPropertyStateByHandle(sal_Int32 nHandle)
     342                 :            :     {
     343         [ #  # ]:          0 :         ::com::sun::star::uno::Any aValue = ImplGetPropertyValueByHandle( nHandle );
     344         [ #  # ]:          0 :         ::com::sun::star::uno::Any aDefault = ImplGetDefaultValueByHandle( nHandle );
     345                 :            : 
     346 [ #  # ][ #  # ]:          0 :         return CompareProperties( aValue, aDefault ) ? ::com::sun::star::beans::PropertyState_DEFAULT_VALUE : ::com::sun::star::beans::PropertyState_DIRECT_VALUE;
     347                 :            :     }
     348                 :            : 
     349                 :            :     //--------------------------------------------------------------------
     350                 :          0 :     void OGeometryControlModel_Base::setPropertyToDefaultByHandle(sal_Int32 nHandle)
     351                 :            :     {
     352         [ #  # ]:          0 :         ImplSetPropertyValueByHandle( nHandle , ImplGetDefaultValueByHandle( nHandle ) );
     353                 :          0 :     }
     354                 :            : 
     355                 :            :     //--------------------------------------------------------------------
     356                 :          0 :     ::com::sun::star::uno::Any OGeometryControlModel_Base::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
     357                 :            :     {
     358                 :          0 :         return ImplGetDefaultValueByHandle( nHandle );
     359                 :            :     }
     360                 :            : 
     361                 :            :     //--------------------------------------------------------------------
     362                 :        224 :     Reference< XPropertySetInfo> SAL_CALL OGeometryControlModel_Base::getPropertySetInfo() throw(RuntimeException)
     363                 :            :     {
     364                 :        224 :         return OPropertySetAggregationHelper::createPropertySetInfo(getInfoHelper());
     365                 :            :     }
     366                 :            : 
     367                 :            :     //--------------------------------------------------------------------
     368                 :          6 :     Reference< XCloneable > SAL_CALL OGeometryControlModel_Base::createClone(  ) throw(RuntimeException)
     369                 :            :     {
     370                 :            :         OSL_ENSURE(m_bCloneable, "OGeometryControlModel_Base::createClone: invalid call!");
     371         [ -  + ]:          6 :         if (!m_bCloneable)
     372                 :          0 :             return Reference< XCloneable >();
     373                 :            : 
     374                 :            :         // let the aggregate create it's own clone
     375                 :            :         // the interface
     376                 :          6 :         Reference< XCloneable > xCloneAccess;
     377 [ +  - ][ +  - ]:          6 :         m_xAggregate->queryAggregation(::getCppuType(&xCloneAccess)) >>= xCloneAccess;
         [ +  - ][ +  - ]
     378                 :            :         OSL_ENSURE(xCloneAccess.is(), "OGeometryControlModel_Base::createClone: suspicious aggregate!");
     379         [ -  + ]:          6 :         if (!xCloneAccess.is())
     380                 :          0 :             return Reference< XCloneable >();
     381                 :            :         // the aggregate's clone
     382 [ +  - ][ +  - ]:          6 :         Reference< XCloneable > xAggregateClone = xCloneAccess->createClone();
     383                 :            :         OSL_ENSURE(xAggregateClone.is(), "OGeometryControlModel_Base::createClone: suspicious return of the aggregate!");
     384                 :            : 
     385                 :            :         // create a new wrapper aggregating this return value
     386         [ +  - ]:          6 :         OGeometryControlModel_Base* pOwnClone = createClone_Impl(xAggregateClone);
     387                 :            :         OSL_ENSURE(pOwnClone, "OGeometryControlModel_Base::createClone: invalid derivee behaviour!");
     388                 :            :         OSL_ENSURE(!xAggregateClone.is(), "OGeometryControlModel_Base::createClone: invalid ctor behaviour!");
     389                 :            :             // should have been reset
     390                 :            : 
     391                 :            :         // set properties
     392                 :          6 :         pOwnClone->m_nPosX      = m_nPosX;
     393                 :          6 :         pOwnClone->m_nPosY      = m_nPosY;
     394                 :          6 :         pOwnClone->m_nWidth     = m_nWidth;
     395                 :          6 :         pOwnClone->m_nHeight    = m_nHeight;
     396                 :          6 :         pOwnClone->m_aName      = m_aName;
     397                 :          6 :         pOwnClone->m_nTabIndex  = m_nTabIndex;
     398                 :          6 :         pOwnClone->m_nStep      = m_nStep;
     399                 :          6 :         pOwnClone->m_aTag       = m_aTag;
     400                 :            : 
     401                 :            : 
     402                 :            :         // Clone event container
     403                 :            :         Reference< ::com::sun::star::script::XScriptEventsSupplier > xEventsSupplier =
     404         [ +  - ]:          6 :             static_cast< ::com::sun::star::script::XScriptEventsSupplier* >( this );
     405                 :            :         Reference< ::com::sun::star::script::XScriptEventsSupplier > xCloneEventsSupplier =
     406 [ +  - ][ +  - ]:          6 :             static_cast< ::com::sun::star::script::XScriptEventsSupplier* >( pOwnClone );
     407                 :            : 
     408 [ +  - ][ +  - ]:          6 :         if( xEventsSupplier.is() && xCloneEventsSupplier.is() )
                 [ +  - ]
     409                 :            :         {
     410 [ +  - ][ +  - ]:          6 :             Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
     411 [ +  - ][ +  - ]:          6 :             Reference< XNameContainer > xCloneEventCont = xCloneEventsSupplier->getEvents();
     412                 :            : 
     413                 :            :             ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames =
     414 [ +  - ][ +  - ]:          6 :                 xEventCont->getElementNames();
     415                 :          6 :             const ::rtl::OUString* pNames = aNames.getConstArray();
     416                 :          6 :             sal_Int32 i, nNameCount = aNames.getLength();
     417                 :            : 
     418         [ -  + ]:          6 :             for( i = 0 ; i < nNameCount ; i++ )
     419                 :            :             {
     420                 :          0 :                 ::rtl::OUString aName = pNames[ i ];
     421 [ #  # ][ #  # ]:          0 :                 ::com::sun::star::uno::Any aElement = xEventCont->getByName( aName );
     422 [ #  # ][ #  # ]:          0 :                 xCloneEventCont->insertByName( aName, aElement );
     423         [ +  - ]:          6 :             }
     424                 :            :         }
     425                 :            : 
     426 [ +  - ][ +  - ]:          6 :         return pOwnClone;
     427                 :            :     }
     428                 :            : 
     429                 :            :     //--------------------------------------------------------------------
     430                 :         12 :     Reference< XNameContainer > SAL_CALL OGeometryControlModel_Base::getEvents() throw(RuntimeException)
     431                 :            :     {
     432         [ +  - ]:         12 :         if( !mxEventContainer.is() )
     433 [ +  - ][ +  - ]:         12 :             mxEventContainer = (XNameContainer*)new toolkit::ScriptEventContainer();
     434                 :         12 :         return mxEventContainer;
     435                 :            :     }
     436                 :            : 
     437                 :            :     //--------------------------------------------------------------------
     438                 :         64 :     void SAL_CALL OGeometryControlModel_Base::disposing()
     439                 :            :     {
     440         [ +  - ]:         64 :         OGCM_Base::disposing();
     441         [ +  - ]:         64 :         OPropertySetAggregationHelper::disposing();
     442                 :            : 
     443                 :         64 :         Reference<XComponent>  xComp;
     444 [ +  - ][ +  - ]:         64 :         if ( query_aggregation( m_xAggregate, xComp ) )
     445 [ +  - ][ +  - ]:         64 :             xComp->dispose();
     446                 :         64 :     }
     447                 :            : 
     448                 :            :     //====================================================================
     449                 :            :     //= OCommonGeometryControlModel
     450                 :            :     //====================================================================
     451                 :            :     //--------------------------------------------------------------------
     452                 :            : 
     453                 :            :     typedef ::boost::unordered_map< ::rtl::OUString, sal_Int32, ::rtl::OUStringHash > HashMapString2Int;
     454                 :            :     typedef ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > >   PropSeqArray;
     455                 :            :     typedef ::std::vector< ::std::vector< sal_Int32 > > IntArrayArray;
     456                 :            : 
     457                 :            :     // for creating class-unique PropertySetInfo's, we need some info:
     458                 :            :     namespace { struct ServiceSpecifierMap : public rtl::Static< HashMapString2Int, ServiceSpecifierMap > {}; }
     459                 :            :     // this one maps from a String, which is the service specifier for our
     460                 :            :     // aggregate, to a unique id
     461                 :            : 
     462                 :            :     namespace { struct AggregateProperties : public rtl::Static< PropSeqArray, AggregateProperties > {}; }
     463                 :            :     // this one contains the properties which belong to all the unique ids
     464                 :            :     // in ServiceSpecifierMap
     465                 :            : 
     466                 :            :     namespace { struct AmbiguousPropertyIds : public rtl::Static< IntArrayArray, AmbiguousPropertyIds > {}; }
     467                 :            :     // the ids of the properties which we as well as our aggregate supply
     468                 :            :     // For such props, we let our base class handle them, and whenever such
     469                 :            :     // a prop is set, we forward this to our aggregate.
     470                 :            : 
     471                 :            :     // With this, we can ensure that two instances of this class share the
     472                 :            :     // same PropertySetInfo if and only if both aggregates have the same
     473                 :            :     // service specifier.
     474                 :            : 
     475                 :            : 
     476                 :            :     //--------------------------------------------------------------------
     477                 :         24 :     OCommonGeometryControlModel::OCommonGeometryControlModel( Reference< XCloneable >& _rxAgg, const ::rtl::OUString& _rServiceSpecifier )
     478                 :            :         :OGeometryControlModel_Base( _rxAgg )
     479                 :            :         ,m_sServiceSpecifier( _rServiceSpecifier )
     480         [ +  - ]:         24 :         ,m_nPropertyMapId( 0 )
     481                 :            :     {
     482                 :         24 :         Reference< XPropertySetInfo > xPI;
     483         [ +  - ]:         24 :         if ( m_xAggregateSet.is() )
     484 [ +  - ][ +  - ]:         24 :             xPI = m_xAggregateSet->getPropertySetInfo();
                 [ +  - ]
     485         [ -  + ]:         24 :         if ( !xPI.is() )
     486                 :            :         {
     487         [ #  # ]:          0 :             releaseAggregation();
     488         [ #  # ]:          0 :             throw IllegalArgumentException();
     489                 :            :         }
     490                 :            : 
     491         [ +  - ]:         24 :             HashMapString2Int &rMap = ServiceSpecifierMap::get();
     492         [ +  - ]:         24 :         HashMapString2Int::iterator aPropMapIdPos = rMap.find( m_sServiceSpecifier );
     493 [ +  - ][ +  + ]:         24 :         if ( rMap.end() == aPropMapIdPos )
     494                 :            :         {
     495         [ +  - ]:          4 :             PropSeqArray &rAggProperties = AggregateProperties::get();
     496                 :          4 :             m_nPropertyMapId = rAggProperties.size();
     497 [ +  - ][ +  - ]:          4 :             rAggProperties.push_back( xPI->getProperties() );
         [ +  - ][ +  - ]
     498 [ +  - ][ +  - ]:          4 :             AmbiguousPropertyIds::get().push_back( IntArrayArray::value_type() );
                 [ +  - ]
     499                 :            : 
     500         [ +  - ]:          4 :             rMap[ m_sServiceSpecifier ] = m_nPropertyMapId;
     501                 :            :         }
     502                 :            :         else
     503         [ +  - ]:         24 :             m_nPropertyMapId = aPropMapIdPos->second;
     504                 :         24 :     }
     505                 :            : 
     506                 :            :     //--------------------------------------------------------------------
     507                 :            :     struct PropertyNameLess : public ::std::binary_function< Property, Property, bool >
     508                 :            :     {
     509                 :        328 :         bool operator()( const Property& _rLHS, const Property& _rRHS )
     510                 :            :         {
     511                 :        328 :             return _rLHS.Name < _rRHS.Name ? true : false;
     512                 :            :         }
     513                 :            :     };
     514                 :            : 
     515                 :            :     //--------------------------------------------------------------------
     516                 :            :     struct PropertyNameEqual : public ::std::unary_function< Property, bool >
     517                 :            :     {
     518                 :            :         const ::rtl::OUString&  m_rCompare;
     519                 :         18 :         PropertyNameEqual( const ::rtl::OUString& _rCompare ) : m_rCompare( _rCompare ) { }
     520                 :            : 
     521                 :        702 :         bool operator()( const Property& _rLHS )
     522                 :            :         {
     523                 :        702 :             return _rLHS.Name == m_rCompare ? true : false;
     524                 :            :         }
     525                 :            :     };
     526                 :            : 
     527                 :            :     //--------------------------------------------------------------------
     528                 :          2 :     ::cppu::IPropertyArrayHelper* OCommonGeometryControlModel::createArrayHelper( sal_Int32 _nId ) const
     529                 :            :     {
     530                 :            :         OSL_ENSURE( _nId == m_nPropertyMapId, "OCommonGeometryControlModel::createArrayHelper: invalid argument!" );
     531                 :            :         OSL_ENSURE( _nId < (sal_Int32)AggregateProperties::get().size(), "OCommonGeometryControlModel::createArrayHelper: invalid status info (1)!" );
     532                 :            :         OSL_ENSURE( _nId < (sal_Int32)AmbiguousPropertyIds::get().size(), "OCommonGeometryControlModel::createArrayHelper: invalid status info (2)!" );
     533                 :            : 
     534                 :            :         // our own properties
     535         [ +  - ]:          2 :         Sequence< Property > aProps;
     536         [ +  - ]:          2 :         OPropertyContainer::describeProperties( aProps );
     537                 :            : 
     538                 :            :         // the aggregate properties
     539         [ +  - ]:          2 :         Sequence< Property > aAggregateProps;
     540 [ +  - ][ +  - ]:          2 :         aAggregateProps = AggregateProperties::get()[ _nId ];
     541                 :            : 
     542                 :            :         // look for duplicates, and remember them
     543 [ +  - ][ +  - ]:          2 :         IntArrayArray::value_type& rDuplicateIds = AmbiguousPropertyIds::get()[ _nId ];
     544                 :            :         // for this, sort the aggregate properties
     545                 :            :         ::std::sort(
     546                 :            :             aAggregateProps.getArray(),
     547         [ +  - ]:          2 :             aAggregateProps.getArray() + aAggregateProps.getLength(),
     548                 :            :             PropertyNameLess()
     549 [ +  - ][ +  - ]:          2 :         );
     550                 :          2 :         const Property* pAggProps = aAggregateProps.getConstArray();
     551                 :          2 :         const Property* pAggPropsEnd = aAggregateProps.getConstArray() + aAggregateProps.getLength();
     552                 :            : 
     553                 :            :         // now loop through our own props
     554                 :          2 :         const Property* pProp = aProps.getConstArray();
     555                 :          2 :         const Property* pPropEnd = aProps.getConstArray() + aProps.getLength();
     556         [ +  + ]:         20 :         while ( pProp < pPropEnd )
     557                 :            :         {
     558                 :            :             // look for the current property in the properties of our aggregate
     559         [ +  - ]:         18 :             const Property* pAggPropPos = ::std::find_if( pAggProps, pAggPropsEnd, PropertyNameEqual( pProp->Name ) );
     560         [ -  + ]:         18 :             if ( pAggPropPos != pAggPropsEnd )
     561                 :            :             {   // found a duplicate
     562                 :            :                 // -> remove from the aggregate property sequence
     563         [ #  # ]:          0 :                 ::comphelper::removeElementAt( aAggregateProps, pAggPropPos - pAggProps );
     564                 :            :                 // which means we have to adjust the pointers
     565                 :            :                 pAggProps = aAggregateProps.getConstArray(),
     566                 :          0 :                 pAggPropsEnd = aAggregateProps.getConstArray() + aAggregateProps.getLength(),
     567                 :            : 
     568                 :            :                 // and additionally, remember the id of this property
     569         [ #  # ]:          0 :                 rDuplicateIds.push_back( pProp->Handle );
     570                 :            :             }
     571                 :            : 
     572                 :         18 :             ++pProp;
     573                 :            :         }
     574                 :            : 
     575                 :            :         // now, finally, sort the duplicates
     576         [ +  - ]:          2 :         ::std::sort( rDuplicateIds.begin(), rDuplicateIds.end(), ::std::less< sal_Int32 >() );
     577                 :            : 
     578 [ +  - ][ +  - ]:          2 :         return new OPropertyArrayAggregationHelper(aProps, aAggregateProps);
                 [ +  - ]
     579                 :            :     }
     580                 :            : 
     581                 :            :     //--------------------------------------------------------------------
     582                 :        608 :     ::cppu::IPropertyArrayHelper& SAL_CALL OCommonGeometryControlModel::getInfoHelper()
     583                 :            :     {
     584                 :        608 :         return *getArrayHelper( m_nPropertyMapId );
     585                 :            :     }
     586                 :            : 
     587                 :            :     //--------------------------------------------------------------------
     588                 :          2 :     OGeometryControlModel_Base* OCommonGeometryControlModel::createClone_Impl( Reference< XCloneable >& _rxAggregateInstance )
     589                 :            :     {
     590         [ +  - ]:          2 :         return new OCommonGeometryControlModel( _rxAggregateInstance, m_sServiceSpecifier );
     591                 :            :     }
     592                 :            : 
     593                 :            :     namespace
     594                 :            :     {
     595                 :            :         class theOCommonGeometryControlModelImplementationId :
     596                 :            :             public rtl::Static< ::cppu::OImplementationId, theOCommonGeometryControlModelImplementationId > {};
     597                 :            :     }
     598                 :            : 
     599                 :            :     //--------------------------------------------------------------------
     600                 :          0 :     Sequence< sal_Int8 > SAL_CALL OCommonGeometryControlModel::getImplementationId(  ) throw (RuntimeException)
     601                 :            :     {
     602                 :          0 :         return theOCommonGeometryControlModelImplementationId::get().getImplementationId();
     603                 :            :     }
     604                 :            : 
     605                 :            :     //--------------------------------------------------------------------
     606                 :            :     struct Int32Equal : public ::std::unary_function< sal_Int32, bool >
     607                 :            :     {
     608                 :            :         sal_Int32   m_nCompare;
     609                 :         36 :         Int32Equal( sal_Int32 _nCompare ) : m_nCompare( _nCompare ) { }
     610                 :            : 
     611                 :          0 :         bool operator()( sal_Int32 _nLHS )
     612                 :            :         {
     613                 :          0 :             return _nLHS == m_nCompare ? true  : false;
     614                 :            :         }
     615                 :            :     };
     616                 :            : 
     617                 :            :     //--------------------------------------------------------------------
     618                 :         36 :     void SAL_CALL OCommonGeometryControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw ( Exception )
     619                 :            :     {
     620         [ +  - ]:         36 :         OGeometryControlModel_Base::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
     621                 :            : 
     622                 :            :         // look if this id is one we recognized as duplicate
     623 [ +  - ][ +  - ]:         36 :         IntArrayArray::value_type& rDuplicateIds = AmbiguousPropertyIds::get()[ m_nPropertyMapId ];
     624                 :            : 
     625                 :            :         IntArrayArray::value_type::const_iterator aPos = ::std::find_if(
     626                 :            :             rDuplicateIds.begin(),
     627                 :            :             rDuplicateIds.end(),
     628                 :            :             Int32Equal( _nHandle )
     629 [ +  - ][ +  - ]:         36 :         );
     630                 :            : 
     631 [ +  - ][ -  + ]:         36 :         if ( rDuplicateIds.end() != aPos )
     632                 :            :         {
     633                 :            :             // yes, it is such a property
     634                 :          0 :             ::rtl::OUString sPropName;
     635                 :          0 :             sal_Int16 nAttributes(0);
     636 [ #  # ][ #  # ]:          0 :             static_cast< OPropertyArrayAggregationHelper* >( getArrayHelper( m_nPropertyMapId ) )->fillPropertyMembersByHandle( &sPropName, &nAttributes, _nHandle );
     637                 :            : 
     638 [ #  # ][ #  # ]:          0 :             if ( m_xAggregateSet.is() && !sPropName.isEmpty() )
                 [ #  # ]
     639 [ #  # ][ #  # ]:          0 :                 m_xAggregateSet->setPropertyValue( sPropName, _rValue );
     640                 :            :         }
     641                 :         36 :     }
     642                 :            : 
     643                 :            : //........................................................................
     644                 :            : // }    // namespace toolkit
     645                 :            : //........................................................................
     646                 :            : 
     647                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10