LCOV - code coverage report
Current view: top level - svx/source/items - customshapeitem.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 142 0.0 %
Date: 2014-04-14 Functions: 0 27 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 <svx/sdasitm.hxx>
      21             : #include <svx/svdattr.hxx>
      22             : 
      23             : using namespace ::std;
      24             : using namespace com::sun::star;
      25             : 
      26           0 : SdrCustomShapeEngineItem::SdrCustomShapeEngineItem()
      27           0 : :   SfxStringItem( SDRATTR_CUSTOMSHAPE_ENGINE, "" )
      28           0 : {}
      29             : 
      30           0 : SdrCustomShapeDataItem::SdrCustomShapeDataItem()
      31           0 : :   SfxStringItem( SDRATTR_CUSTOMSHAPE_DATA, "" )
      32           0 : {}
      33             : 
      34           0 : TYPEINIT1_FACTORY( SdrCustomShapeGeometryItem, SfxPoolItem , new  SdrCustomShapeGeometryItem);
      35             : 
      36           0 : SdrCustomShapeGeometryItem::SdrCustomShapeGeometryItem()
      37           0 : :   SfxPoolItem( SDRATTR_CUSTOMSHAPE_GEOMETRY )
      38           0 : {}
      39             : 
      40           0 : SdrCustomShapeGeometryItem::SdrCustomShapeGeometryItem( const uno::Sequence< beans::PropertyValue >& rVal )
      41           0 : :   SfxPoolItem( SDRATTR_CUSTOMSHAPE_GEOMETRY )
      42             : {
      43             :     sal_Int32 i, j;
      44           0 :     aPropSeq = rVal;
      45             : 
      46           0 :     for ( i = 0; i < aPropSeq.getLength(); i++ )
      47             :     {
      48           0 :         beans::PropertyValue& rPropVal = aPropSeq[ i ];
      49           0 :         aPropHashMap[ rPropVal.Name ] = i;
      50           0 :         if ( rPropVal.Value.getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < beans::PropertyValue >*)0) )
      51             :         {
      52           0 :             uno::Sequence< beans::PropertyValue >& rPropSeq = *( uno::Sequence< beans::PropertyValue >*)rPropVal.Value.getValue();
      53           0 :             for ( j = 0; j < rPropSeq.getLength(); j++ )
      54             :             {
      55           0 :                 beans::PropertyValue& rPropVal2 = rPropSeq[ j ];
      56           0 :                 aPropPairHashMap[ PropertyPair( rPropVal.Name, rPropVal2.Name ) ] = j;
      57             :             }
      58             :         }
      59             :     }
      60           0 : }
      61             : 
      62           0 : com::sun::star::uno::Any* SdrCustomShapeGeometryItem::GetPropertyValueByName( const OUString& rPropName )
      63             : {
      64           0 :     com::sun::star::uno::Any* pRet = NULL;
      65           0 :     PropertyHashMap::iterator aHashIter( aPropHashMap.find( rPropName ) );
      66           0 :     if ( aHashIter != aPropHashMap.end() )
      67           0 :         pRet = &aPropSeq[ (*aHashIter).second ].Value;
      68           0 :     return pRet;
      69             : }
      70             : 
      71           0 : com::sun::star::uno::Any* SdrCustomShapeGeometryItem::GetPropertyValueByName( const OUString& rSequenceName, const OUString& rPropName )
      72             : {
      73           0 :     com::sun::star::uno::Any* pRet = NULL;
      74           0 :     com::sun::star::uno::Any* pSeqAny = GetPropertyValueByName( rSequenceName );
      75           0 :     if ( pSeqAny )
      76             :     {
      77           0 :         if ( pSeqAny->getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < beans::PropertyValue >*)0) )
      78             :         {
      79           0 :             PropertyPairHashMap::iterator aHashIter( aPropPairHashMap.find( PropertyPair( rSequenceName, rPropName ) ) );
      80           0 :             if ( aHashIter != aPropPairHashMap.end() )
      81             :             {
      82             :                 ::com::sun::star::uno::Sequence < beans::PropertyValue >& rSecSequence =
      83           0 :                     *((::com::sun::star::uno::Sequence < beans::PropertyValue >*)pSeqAny->getValue());
      84           0 :                 pRet = &rSecSequence[ (*aHashIter).second ].Value;
      85             :             }
      86             :         }
      87             :     }
      88           0 :     return pRet;
      89             : }
      90             : 
      91           0 : void SdrCustomShapeGeometryItem::SetPropertyValue( const com::sun::star::beans::PropertyValue& rPropVal )
      92             : {
      93           0 :     com::sun::star::uno::Any* pAny = GetPropertyValueByName( rPropVal.Name );
      94           0 :     if ( pAny )
      95             :     {   // property is already available
      96             :         sal_Int32 i;
      97           0 :         if ( pAny->getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < beans::PropertyValue >*)0) )
      98             :         {   // old property is a sequence->each entry has to be removed from the HashPairMap
      99             :             ::com::sun::star::uno::Sequence < beans::PropertyValue >& rSecSequence =
     100           0 :                 *((::com::sun::star::uno::Sequence < beans::PropertyValue >*)pAny->getValue());
     101           0 :             for ( i = 0; i < rSecSequence.getLength(); i++ )
     102             :             {
     103           0 :                 PropertyPairHashMap::iterator aHashIter( aPropPairHashMap.find( PropertyPair( rPropVal.Name, rSecSequence[ i ].Name ) ) );
     104           0 :                 if ( aHashIter != aPropPairHashMap.end() )
     105           0 :                     aPropPairHashMap.erase( aHashIter );
     106             :             }
     107             :         }
     108           0 :         *pAny = rPropVal.Value;
     109           0 :         if ( rPropVal.Value.getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < beans::PropertyValue >*)0) )
     110             :         {   // the new property is a sequence->each entry has to be inserted into the HashPairMap
     111             :             ::com::sun::star::uno::Sequence < beans::PropertyValue >& rSecSequence =
     112           0 :                 *((::com::sun::star::uno::Sequence < beans::PropertyValue >*)pAny->getValue());
     113           0 :             for ( i = 0; i < rSecSequence.getLength(); i++ )
     114             :             {
     115           0 :                 beans::PropertyValue& rPropVal2 = rSecSequence[ i ];
     116           0 :                 aPropPairHashMap[ PropertyPair( rPropVal.Name, rPropVal2.Name ) ] = i;
     117             :             }
     118             :         }
     119             :     }
     120             :     else
     121             :     {   // it's a new property
     122           0 :         sal_uInt32 nIndex = aPropSeq.getLength();
     123           0 :         aPropSeq.realloc( nIndex + 1 );
     124           0 :         aPropSeq[ nIndex ] = rPropVal ;
     125             : 
     126           0 :         aPropHashMap[ rPropVal.Name ] = nIndex;
     127             :     }
     128           0 : }
     129             : 
     130           0 : void SdrCustomShapeGeometryItem::SetPropertyValue( const OUString& rSequenceName, const com::sun::star::beans::PropertyValue& rPropVal )
     131             : {
     132           0 :     com::sun::star::uno::Any* pAny = GetPropertyValueByName( rSequenceName, rPropVal.Name );
     133           0 :     if ( pAny ) // just replacing
     134           0 :         *pAny = rPropVal.Value;
     135             :     else
     136             :     {
     137           0 :         com::sun::star::uno::Any* pSeqAny = GetPropertyValueByName( rSequenceName );
     138           0 :         if( pSeqAny == NULL )
     139             :         {
     140           0 :             ::com::sun::star::uno::Sequence < beans::PropertyValue > aSeq;
     141           0 :             beans::PropertyValue aValue;
     142           0 :             aValue.Name = rSequenceName;
     143           0 :             aValue.Value = ::com::sun::star::uno::makeAny( aSeq );
     144             : 
     145           0 :             sal_uInt32 nIndex = aPropSeq.getLength();
     146           0 :             aPropSeq.realloc( nIndex + 1 );
     147           0 :             aPropSeq[ nIndex ] = aValue;
     148           0 :             aPropHashMap[ rSequenceName ] = nIndex;
     149             : 
     150           0 :             pSeqAny = &aPropSeq[ nIndex ].Value;
     151             :         }
     152             : 
     153             :         DBG_ASSERT( pSeqAny, "SdrCustomShapeGeometryItem::SetPropertyValue() - No Value??" );
     154             : 
     155           0 :         if( pSeqAny )
     156             :         {
     157           0 :             if ( pSeqAny->getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < beans::PropertyValue >*)0) )
     158             :             {
     159           0 :                 PropertyPairHashMap::iterator aHashIter( aPropPairHashMap.find( PropertyPair( rSequenceName, rPropVal.Name ) ) );
     160           0 :                 if ( aHashIter != aPropPairHashMap.end() )
     161             :                 {
     162             :                     ::com::sun::star::uno::Sequence < beans::PropertyValue >& rSecSequence =
     163           0 :                         *((::com::sun::star::uno::Sequence < beans::PropertyValue >*)pSeqAny->getValue());
     164           0 :                     rSecSequence[ (*aHashIter).second ].Value = rPropVal.Value;
     165             :                 }
     166             :                 else
     167             :                 {
     168             :                     ::com::sun::star::uno::Sequence < beans::PropertyValue >& rSecSequence =
     169           0 :                         *((::com::sun::star::uno::Sequence < beans::PropertyValue >*)pSeqAny->getValue());
     170             : 
     171           0 :                     sal_Int32 nCount = rSecSequence.getLength();
     172           0 :                     rSecSequence.realloc( nCount + 1 );
     173           0 :                     rSecSequence[ nCount ] = rPropVal;
     174             : 
     175           0 :                     aPropPairHashMap[ PropertyPair( rSequenceName, rPropVal.Name ) ] = nCount;
     176             :                 }
     177             :             }
     178             :         }
     179             :     }
     180           0 : }
     181             : 
     182           0 : void SdrCustomShapeGeometryItem::ClearPropertyValue( const OUString& rPropName )
     183             : {
     184           0 :     if ( aPropSeq.getLength() )
     185             :     {
     186           0 :         PropertyHashMap::iterator aHashIter( aPropHashMap.find( rPropName ) );
     187           0 :         if ( aHashIter != aPropHashMap.end() )
     188             :         {
     189           0 :              com::sun::star::uno::Any* pSeqAny = &aPropSeq[ (*aHashIter).second ].Value;
     190           0 :             if ( pSeqAny )
     191             :             {
     192           0 :                 if ( pSeqAny->getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < beans::PropertyValue >*)0) )
     193             :                 {
     194             :                     ::com::sun::star::uno::Sequence < beans::PropertyValue >& rSecSequence =
     195           0 :                         *((::com::sun::star::uno::Sequence < beans::PropertyValue >*)pSeqAny->getValue());
     196             : 
     197             :                     sal_Int32 i;
     198           0 :                     for ( i = 0; i < rSecSequence.getLength(); i++ )
     199             :                     {
     200           0 :                         PropertyPairHashMap::iterator _aHashIter( aPropPairHashMap.find( PropertyPair( rPropName, rSecSequence[ i ].Name ) ) );
     201           0 :                         if ( _aHashIter != aPropPairHashMap.end() )
     202           0 :                             aPropPairHashMap.erase( _aHashIter );       // removing property from pair hashmap
     203             :                     }
     204             :                 }
     205             :             }
     206           0 :             sal_Int32 nLength = aPropSeq.getLength();
     207           0 :             if ( nLength )
     208             :             {
     209           0 :                 sal_Int32 nIndex  = (*aHashIter).second;
     210           0 :                 if ( nIndex != ( nLength - 1 ) )                        // resizing sequence
     211             :                 {
     212           0 :                     PropertyHashMap::iterator aHashIter2( aPropHashMap.find( aPropSeq[ nLength - 1 ].Name ) );
     213           0 :                     (*aHashIter2).second = nIndex;
     214           0 :                     aPropSeq[ (*aHashIter).second ] = aPropSeq[ aPropSeq.getLength() - 1 ];
     215             :                 }
     216           0 :                 aPropSeq.realloc( aPropSeq.getLength() - 1 );
     217             :             }
     218           0 :             aPropHashMap.erase( aHashIter );                            // removing property from hashmap
     219             :         }
     220             :     }
     221           0 : }
     222             : 
     223           0 : SdrCustomShapeGeometryItem::~SdrCustomShapeGeometryItem()
     224             : {
     225           0 : }
     226           0 : SdrCustomShapeGeometryItem::SdrCustomShapeGeometryItem( SvStream& /*rIn*/, sal_uInt16 nVersion ):
     227           0 :     SfxPoolItem( SDRATTR_CUSTOMSHAPE_GEOMETRY )
     228             : {
     229             :     if ( nVersion )
     230             :     {
     231             : 
     232             :     }
     233           0 : }
     234           0 : bool SdrCustomShapeGeometryItem::operator==( const SfxPoolItem& rCmp ) const
     235             : {
     236           0 :     bool bRet = SfxPoolItem::operator==( rCmp );
     237           0 :     if ( bRet )
     238           0 :         bRet = ((SdrCustomShapeGeometryItem&)rCmp).aPropSeq == aPropSeq;
     239           0 :     return bRet;
     240             : }
     241             : 
     242           0 : SfxItemPresentation SdrCustomShapeGeometryItem::GetPresentation(
     243             :     SfxItemPresentation ePresentation, SfxMapUnit /*eCoreMetric*/,
     244             :     SfxMapUnit /*ePresentationMetric*/, OUString &rText, const IntlWrapper *) const
     245             : {
     246           0 :     rText += " ";
     247           0 :     if ( ePresentation == SFX_ITEM_PRESENTATION_COMPLETE )
     248             :     {
     249           0 :         rText = " " + rText;
     250             :     }
     251           0 :     return ePresentation;
     252             : }
     253             : 
     254           0 : SfxPoolItem* SdrCustomShapeGeometryItem::Create( SvStream& rIn, sal_uInt16 nItemVersion ) const
     255             : {
     256           0 :     return new SdrCustomShapeGeometryItem( rIn, nItemVersion );
     257             : }
     258             : 
     259           0 : SvStream& SdrCustomShapeGeometryItem::Store( SvStream& rOut, sal_uInt16 nItemVersion ) const
     260             : {
     261             :     if ( nItemVersion )
     262             :     {
     263             : 
     264             :     }
     265           0 :     return rOut;
     266             : }
     267             : 
     268           0 : SfxPoolItem* SdrCustomShapeGeometryItem::Clone( SfxItemPool * /*pPool*/ ) const
     269             : {
     270           0 :     return new SdrCustomShapeGeometryItem( GetGeometry() );
     271             : }
     272             : 
     273           0 : sal_uInt16 SdrCustomShapeGeometryItem::GetVersion( sal_uInt16 /*nFileFormatVersion*/ ) const
     274             : {
     275           0 :     return 1;
     276             : }
     277           0 : bool SdrCustomShapeGeometryItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
     278             : {
     279           0 :     rVal <<= aPropSeq;
     280           0 :     return true;
     281             : }
     282           0 : bool SdrCustomShapeGeometryItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
     283             : {
     284           0 :     if ( ! ( rVal >>= aPropSeq ) )
     285           0 :         return false;
     286             :     else
     287           0 :         return true;
     288             : }
     289           0 : const uno::Sequence< beans::PropertyValue >& SdrCustomShapeGeometryItem::GetGeometry() const
     290             : {
     291           0 :     return aPropSeq;
     292             : }
     293             : 
     294           0 : SdrCustomShapeReplacementURLItem::SdrCustomShapeReplacementURLItem()
     295           0 : :   SfxStringItem( SDRATTR_CUSTOMSHAPE_REPLACEMENT_URL, "" )
     296           0 : {}
     297             : 
     298             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10