LCOV - code coverage report
Current view: top level - svx/source/unodraw - gluepts.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 223 0.0 %
Date: 2014-04-14 Functions: 0 18 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 <com/sun/star/container/XIdentifierContainer.hpp>
      21             : #include <com/sun/star/container/XIndexContainer.hpp>
      22             : #include <com/sun/star/drawing/GluePoint2.hpp>
      23             : 
      24             : #include <cppuhelper/implbase2.hxx>
      25             : 
      26             : #include <svx/svdmodel.hxx>
      27             : #include <svx/svdobj.hxx>
      28             : #include <svx/svdglue.hxx>
      29             : #include <svx/svdpage.hxx>
      30             : 
      31             : #include <gluepts.hxx>
      32             : 
      33             : using namespace ::com::sun::star;
      34             : using namespace ::rtl;
      35             : using namespace ::cppu;
      36             : 
      37             : const sal_uInt16 NON_USER_DEFINED_GLUE_POINTS = 4;
      38             : 
      39             : class SvxUnoGluePointAccess : public WeakImplHelper2< container::XIndexContainer, container::XIdentifierContainer >
      40             : {
      41             : private:
      42             :     SdrObjectWeakRef    mpObject;
      43             : 
      44             : public:
      45             :     SvxUnoGluePointAccess( SdrObject* pObject ) throw();
      46             :     virtual ~SvxUnoGluePointAccess() throw();
      47             : 
      48             :     // XIdentifierContainer
      49             :     virtual sal_Int32 SAL_CALL insert( const uno::Any& aElement ) throw (lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
      50             :     virtual void SAL_CALL removeByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
      51             : 
      52             :     // XIdentifierReplace
      53             :     virtual void SAL_CALL replaceByIdentifer( sal_Int32 Identifier, const uno::Any& aElement ) throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
      54             : 
      55             :     // XIdentifierReplace
      56             :     virtual uno::Any SAL_CALL getByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
      57             :     virtual uno::Sequence< sal_Int32 > SAL_CALL getIdentifiers(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      58             : 
      59             :     /* deprecated */
      60             :     // XIndexContainer
      61             :     virtual void SAL_CALL insertByIndex( sal_Int32 Index, const uno::Any& Element ) throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
      62             :     virtual void SAL_CALL removeByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
      63             : 
      64             :     /* deprecated */
      65             :     // XIndexReplace
      66             :     virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const uno::Any& Element ) throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
      67             : 
      68             :     /* deprecated */
      69             :     // XIndexAccess
      70             :     virtual sal_Int32 SAL_CALL getCount(  ) throw(uno::RuntimeException, std::exception) SAL_OVERRIDE;
      71             :     virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
      72             : 
      73             :     // XElementAccess
      74             :     virtual uno::Type SAL_CALL getElementType(  ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
      75             :     virtual sal_Bool SAL_CALL hasElements(  ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
      76             : };
      77             : 
      78           0 : static void convert( const SdrGluePoint& rSdrGlue, drawing::GluePoint2& rUnoGlue ) throw()
      79             : {
      80           0 :     rUnoGlue.Position.X = rSdrGlue.GetPos().X();
      81           0 :     rUnoGlue.Position.Y = rSdrGlue.GetPos().Y();
      82           0 :     rUnoGlue.IsRelative = rSdrGlue.IsPercent();
      83             : 
      84           0 :     switch( rSdrGlue.GetAlign() )
      85             :     {
      86             :     case SDRVERTALIGN_TOP|SDRHORZALIGN_LEFT:
      87           0 :         rUnoGlue.PositionAlignment = drawing::Alignment_TOP_LEFT;
      88           0 :         break;
      89             :     case SDRHORZALIGN_CENTER|SDRVERTALIGN_TOP:
      90           0 :         rUnoGlue.PositionAlignment = drawing::Alignment_TOP;
      91           0 :         break;
      92             :     case SDRVERTALIGN_TOP|SDRHORZALIGN_RIGHT:
      93           0 :         rUnoGlue.PositionAlignment = drawing::Alignment_TOP_RIGHT;
      94           0 :         break;
      95             :     case SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER:
      96           0 :         rUnoGlue.PositionAlignment = drawing::Alignment_CENTER;
      97           0 :         break;
      98             :     case SDRHORZALIGN_RIGHT|SDRVERTALIGN_CENTER:
      99           0 :         rUnoGlue.PositionAlignment = drawing::Alignment_RIGHT;
     100           0 :         break;
     101             :     case SDRHORZALIGN_LEFT|SDRVERTALIGN_BOTTOM:
     102           0 :         rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM_LEFT;
     103           0 :         break;
     104             :     case SDRHORZALIGN_CENTER|SDRVERTALIGN_BOTTOM:
     105           0 :         rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM;
     106           0 :         break;
     107             :     case SDRHORZALIGN_RIGHT|SDRVERTALIGN_BOTTOM:
     108           0 :         rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM_RIGHT;
     109           0 :         break;
     110             : //  case SDRHORZALIGN_LEFT:
     111             :     default:
     112           0 :         rUnoGlue.PositionAlignment = drawing::Alignment_LEFT;
     113           0 :         break;
     114             :     }
     115             : 
     116           0 :     switch( rSdrGlue.GetEscDir() )
     117             :     {
     118             :     case SDRESC_LEFT:
     119           0 :         rUnoGlue.Escape = drawing::EscapeDirection_LEFT;
     120           0 :         break;
     121             :     case SDRESC_RIGHT:
     122           0 :         rUnoGlue.Escape = drawing::EscapeDirection_RIGHT;
     123           0 :         break;
     124             :     case SDRESC_TOP:
     125           0 :         rUnoGlue.Escape = drawing::EscapeDirection_UP;
     126           0 :         break;
     127             :     case SDRESC_BOTTOM:
     128           0 :         rUnoGlue.Escape = drawing::EscapeDirection_DOWN;
     129           0 :         break;
     130             :     case SDRESC_HORZ:
     131           0 :         rUnoGlue.Escape = drawing::EscapeDirection_HORIZONTAL;
     132           0 :         break;
     133             :     case SDRESC_VERT:
     134           0 :         rUnoGlue.Escape = drawing::EscapeDirection_VERTICAL;
     135           0 :         break;
     136             : //          case SDRESC_SMART:
     137             :     default:
     138           0 :         rUnoGlue.Escape = drawing::EscapeDirection_SMART;
     139           0 :         break;
     140             :     }
     141           0 : }
     142             : 
     143           0 : static void convert( const drawing::GluePoint2& rUnoGlue, SdrGluePoint& rSdrGlue ) throw()
     144             : {
     145           0 :     rSdrGlue.SetPos( Point( rUnoGlue.Position.X, rUnoGlue.Position.Y ) );
     146           0 :     rSdrGlue.SetPercent( rUnoGlue.IsRelative );
     147             : 
     148           0 :     switch( rUnoGlue.PositionAlignment )
     149             :     {
     150             :     case drawing::Alignment_TOP_LEFT:
     151           0 :         rSdrGlue.SetAlign( SDRVERTALIGN_TOP|SDRHORZALIGN_LEFT );
     152           0 :         break;
     153             :     case drawing::Alignment_TOP:
     154           0 :         rSdrGlue.SetAlign( SDRHORZALIGN_CENTER|SDRVERTALIGN_TOP );
     155           0 :         break;
     156             :     case drawing::Alignment_TOP_RIGHT:
     157           0 :         rSdrGlue.SetAlign( SDRVERTALIGN_TOP|SDRHORZALIGN_RIGHT );
     158           0 :         break;
     159             :     case drawing::Alignment_CENTER:
     160           0 :         rSdrGlue.SetAlign( SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER );
     161           0 :         break;
     162             :     case drawing::Alignment_RIGHT:
     163           0 :         rSdrGlue.SetAlign( SDRHORZALIGN_RIGHT|SDRVERTALIGN_CENTER );
     164           0 :         break;
     165             :     case drawing::Alignment_BOTTOM_LEFT:
     166           0 :         rSdrGlue.SetAlign( SDRHORZALIGN_LEFT|SDRVERTALIGN_BOTTOM );
     167           0 :         break;
     168             :     case drawing::Alignment_BOTTOM:
     169           0 :         rSdrGlue.SetAlign( SDRHORZALIGN_CENTER|SDRVERTALIGN_BOTTOM );
     170           0 :         break;
     171             :     case drawing::Alignment_BOTTOM_RIGHT:
     172           0 :         rSdrGlue.SetAlign( SDRHORZALIGN_RIGHT|SDRVERTALIGN_BOTTOM );
     173           0 :         break;
     174             : //  case SDRHORZALIGN_LEFT:
     175             :     default:
     176           0 :         rSdrGlue.SetAlign( SDRHORZALIGN_LEFT );
     177           0 :         break;
     178             :     }
     179           0 :     switch( rUnoGlue.Escape )
     180             :     {
     181             :     case drawing::EscapeDirection_LEFT:
     182           0 :         rSdrGlue.SetEscDir(SDRESC_LEFT);
     183           0 :         break;
     184             :     case drawing::EscapeDirection_RIGHT:
     185           0 :         rSdrGlue.SetEscDir(SDRESC_RIGHT);
     186           0 :         break;
     187             :     case drawing::EscapeDirection_UP:
     188           0 :         rSdrGlue.SetEscDir(SDRESC_TOP);
     189           0 :         break;
     190             :     case drawing::EscapeDirection_DOWN:
     191           0 :         rSdrGlue.SetEscDir(SDRESC_BOTTOM);
     192           0 :         break;
     193             :     case drawing::EscapeDirection_HORIZONTAL:
     194           0 :         rSdrGlue.SetEscDir(SDRESC_HORZ);
     195           0 :         break;
     196             :     case drawing::EscapeDirection_VERTICAL:
     197           0 :         rSdrGlue.SetEscDir(SDRESC_VERT);
     198           0 :         break;
     199             : //  case drawing::EscapeDirection_SMART:
     200             :     default:
     201           0 :         rSdrGlue.SetEscDir(SDRESC_SMART);
     202           0 :         break;
     203             :     }
     204           0 : }
     205             : 
     206           0 : SvxUnoGluePointAccess::SvxUnoGluePointAccess( SdrObject* pObject ) throw()
     207           0 : : mpObject( pObject )
     208             : {
     209           0 : }
     210             : 
     211           0 : SvxUnoGluePointAccess::~SvxUnoGluePointAccess() throw()
     212             : {
     213           0 : }
     214             : 
     215             : // XIdentifierContainer
     216           0 : sal_Int32 SAL_CALL SvxUnoGluePointAccess::insert( const uno::Any& aElement ) throw (lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     217             : {
     218           0 :     if( mpObject.is() )
     219             :     {
     220           0 :         SdrGluePointList* pList = mpObject->ForceGluePointList();
     221           0 :         if( pList )
     222             :         {
     223             :             // second, insert the new glue point
     224           0 :             drawing::GluePoint2 aUnoGlue;
     225             : 
     226           0 :             if( aElement >>= aUnoGlue )
     227             :             {
     228           0 :                 SdrGluePoint aSdrGlue;
     229           0 :                 convert( aUnoGlue, aSdrGlue );
     230           0 :                 sal_uInt16 nId = pList->Insert( aSdrGlue );
     231             : 
     232             :                 // only repaint, no objectchange
     233           0 :                 mpObject->ActionChanged();
     234             :                 // mpObject->BroadcastObjectChange();
     235             : 
     236           0 :                 return (sal_Int32)((*pList)[nId].GetId() + NON_USER_DEFINED_GLUE_POINTS) - 1;
     237             :             }
     238             : 
     239           0 :             throw lang::IllegalArgumentException();
     240             :         }
     241             :     }
     242             : 
     243           0 :     return -1;
     244             : }
     245             : 
     246           0 : void SAL_CALL SvxUnoGluePointAccess::removeByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     247             : {
     248           0 :     if( mpObject.is() && ( Identifier >= NON_USER_DEFINED_GLUE_POINTS ))
     249             :     {
     250           0 :         const sal_uInt16 nId = (sal_uInt16)(Identifier - NON_USER_DEFINED_GLUE_POINTS) + 1;
     251             : 
     252           0 :         SdrGluePointList* pList = const_cast<SdrGluePointList*>(mpObject->GetGluePointList());
     253           0 :         const sal_uInt16 nCount = pList ? pList->GetCount() : 0;
     254             :         sal_uInt16 i;
     255             : 
     256           0 :         for( i = 0; i < nCount; i++ )
     257             :         {
     258           0 :             if( (*pList)[i].GetId() == nId )
     259             :             {
     260           0 :                 pList->Delete( i );
     261             : 
     262             :                 // only repaint, no objectchange
     263           0 :                 mpObject->ActionChanged();
     264             :                 // mpObject->BroadcastObjectChange();
     265             : 
     266           0 :                 return;
     267             :             }
     268             :         }
     269             :     }
     270             : 
     271           0 :     throw container::NoSuchElementException();
     272             : }
     273             : 
     274             : // XIdentifierReplace
     275           0 : void SAL_CALL SvxUnoGluePointAccess::replaceByIdentifer( sal_Int32 Identifier, const uno::Any& aElement ) throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     276             : {
     277           0 :     if( mpObject.is() && mpObject->IsNode() )
     278             :     {
     279           0 :         struct drawing::GluePoint2 aGluePoint;
     280           0 :         if( (Identifier < NON_USER_DEFINED_GLUE_POINTS) || !(aElement >>= aGluePoint))
     281           0 :             throw lang::IllegalArgumentException();
     282             : 
     283           0 :         const sal_uInt16 nId = (sal_uInt16)( Identifier - NON_USER_DEFINED_GLUE_POINTS ) + 1;
     284             : 
     285           0 :         SdrGluePointList* pList = const_cast< SdrGluePointList* >( mpObject->GetGluePointList() );
     286           0 :         const sal_uInt16 nCount = pList ? pList->GetCount() : 0;
     287             :         sal_uInt16 i;
     288           0 :         for( i = 0; i < nCount; i++ )
     289             :         {
     290           0 :             if( (*pList)[i].GetId() == nId )
     291             :             {
     292             :                 // change the glue point
     293           0 :                 SdrGluePoint& rTempPoint = (*pList)[i];
     294           0 :                 convert( aGluePoint, rTempPoint );
     295             : 
     296             :                 // only repaint, no objectchange
     297           0 :                 mpObject->ActionChanged();
     298             :                 // mpObject->BroadcastObjectChange();
     299             : 
     300           0 :                 return;
     301             :             }
     302             :         }
     303             : 
     304           0 :         throw container::NoSuchElementException();
     305             :     }
     306             : }
     307             : 
     308             : // XIdentifierAccess
     309           0 : uno::Any SAL_CALL SvxUnoGluePointAccess::getByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     310             : {
     311           0 :     if( mpObject.is() && mpObject->IsNode() )
     312             :     {
     313           0 :         struct drawing::GluePoint2 aGluePoint;
     314             : 
     315           0 :         if( Identifier < NON_USER_DEFINED_GLUE_POINTS ) // default glue point?
     316             :         {
     317           0 :             SdrGluePoint aTempPoint = mpObject->GetVertexGluePoint( (sal_uInt16)Identifier );
     318           0 :             aGluePoint.IsUserDefined = sal_False;
     319           0 :             convert( aTempPoint, aGluePoint );
     320           0 :             return uno::makeAny( aGluePoint );
     321             :         }
     322             :         else
     323             :         {
     324           0 :             const sal_uInt16 nId = (sal_uInt16)( Identifier - NON_USER_DEFINED_GLUE_POINTS ) + 1;
     325             : 
     326           0 :             const SdrGluePointList* pList = mpObject->GetGluePointList();
     327           0 :             const sal_uInt16 nCount = pList ? pList->GetCount() : 0;
     328           0 :             for( sal_uInt16 i = 0; i < nCount; i++ )
     329             :             {
     330           0 :                 const SdrGluePoint& rTempPoint = (*pList)[i];
     331           0 :                 if( rTempPoint.GetId() == nId )
     332             :                 {
     333             :                     // #i38892#
     334           0 :                     if(rTempPoint.IsUserDefined())
     335             :                     {
     336           0 :                         aGluePoint.IsUserDefined = sal_True;
     337             :                     }
     338             : 
     339           0 :                     convert( rTempPoint, aGluePoint );
     340           0 :                     return uno::makeAny( aGluePoint );
     341             :                 }
     342             :             }
     343             :         }
     344             :     }
     345             : 
     346           0 :     throw lang::IndexOutOfBoundsException();
     347             : }
     348             : 
     349           0 : uno::Sequence< sal_Int32 > SAL_CALL SvxUnoGluePointAccess::getIdentifiers() throw (uno::RuntimeException, std::exception)
     350             : {
     351           0 :     if( mpObject.is() )
     352             :     {
     353           0 :         const SdrGluePointList* pList = mpObject->GetGluePointList();
     354           0 :         const sal_uInt16 nCount = pList ? pList->GetCount() : 0;
     355             : 
     356             :         sal_uInt16 i;
     357             : 
     358           0 :         uno::Sequence< sal_Int32 > aIdSequence( nCount + NON_USER_DEFINED_GLUE_POINTS );
     359           0 :         sal_Int32 *pIdentifier = aIdSequence.getArray();
     360             : 
     361           0 :         for( i = 0; i < NON_USER_DEFINED_GLUE_POINTS; i++ )
     362           0 :             *pIdentifier++ = (sal_Int32)i;
     363             : 
     364           0 :         for( i = 0; i < nCount; i++ )
     365           0 :             *pIdentifier++ = (sal_Int32) ( (*pList)[i].GetId() + NON_USER_DEFINED_GLUE_POINTS ) - 1;
     366             : 
     367           0 :         return aIdSequence;
     368             :     }
     369             :     else
     370             :     {
     371           0 :         uno::Sequence< sal_Int32 > aEmpty;
     372           0 :         return aEmpty;
     373             :     }
     374             : }
     375             : 
     376             : /* deprecated */
     377             : 
     378             : // XIndexContainer
     379           0 : void SAL_CALL SvxUnoGluePointAccess::insertByIndex( sal_Int32, const uno::Any& Element )
     380             :     throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException,
     381             :             lang::WrappedTargetException, uno::RuntimeException, std::exception)
     382             : {
     383           0 :     if( mpObject.is() )
     384             :     {
     385           0 :         SdrGluePointList* pList = mpObject->ForceGluePointList();
     386           0 :         if( pList )
     387             :         {
     388           0 :             SdrGluePoint aSdrGlue;
     389           0 :             drawing::GluePoint2 aUnoGlue;
     390             : 
     391           0 :             if( Element >>= aUnoGlue )
     392             :             {
     393           0 :                 convert( aUnoGlue, aSdrGlue );
     394           0 :                 pList->Insert( aSdrGlue );
     395             : 
     396             :                 // only repaint, no objectchange
     397           0 :                 mpObject->ActionChanged();
     398             :                 // mpObject->BroadcastObjectChange();
     399             : 
     400           0 :                 return;
     401             :             }
     402             : 
     403           0 :             throw lang::IllegalArgumentException();
     404             :         }
     405             :     }
     406             : 
     407           0 :     throw lang::IndexOutOfBoundsException();
     408             : }
     409             : 
     410           0 : void SAL_CALL SvxUnoGluePointAccess::removeByIndex( sal_Int32 Index )
     411             :     throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     412             : {
     413           0 :     if( mpObject.is() )
     414             :     {
     415           0 :         SdrGluePointList* pList = mpObject->ForceGluePointList();
     416           0 :         if( pList )
     417             :         {
     418           0 :             Index -= 4;
     419           0 :             if( Index >= 0 && Index < pList->GetCount() )
     420             :             {
     421           0 :                 pList->Delete( (sal_uInt16)Index );
     422             : 
     423             :                 // only repaint, no objectchange
     424           0 :                 mpObject->ActionChanged();
     425             :                 // mpObject->BroadcastObjectChange();
     426             : 
     427           0 :                 return;
     428             :             }
     429             :         }
     430             :     }
     431             : 
     432           0 :     throw lang::IndexOutOfBoundsException();
     433             : }
     434             : 
     435             : // XIndexReplace
     436           0 : void SAL_CALL SvxUnoGluePointAccess::replaceByIndex( sal_Int32 Index, const uno::Any& Element )
     437             :     throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException,
     438             :     uno::RuntimeException, std::exception)
     439             : {
     440           0 :     drawing::GluePoint2 aUnoGlue;
     441           0 :     if(!(Element >>= aUnoGlue))
     442           0 :         throw lang::IllegalArgumentException();
     443             : 
     444           0 :     Index -= 4;
     445           0 :     if( mpObject.is() && Index >= 0 )
     446             :     {
     447           0 :         SdrGluePointList* pList = const_cast< SdrGluePointList* >( mpObject->GetGluePointList() );
     448           0 :         if( pList && Index < pList->GetCount() )
     449             :         {
     450           0 :             SdrGluePoint& rGlue = (*pList)[(sal_uInt16)Index];
     451           0 :             convert( aUnoGlue, rGlue );
     452             : 
     453             :             // only repaint, no objectchange
     454           0 :             mpObject->ActionChanged();
     455             :             // mpObject->BroadcastObjectChange();
     456             :         }
     457             :     }
     458             : 
     459           0 :     throw lang::IndexOutOfBoundsException();
     460             : }
     461             : 
     462             : // XIndexAccess
     463           0 : sal_Int32 SAL_CALL SvxUnoGluePointAccess::getCount()
     464             :     throw(uno::RuntimeException, std::exception)
     465             : {
     466           0 :     sal_Int32 nCount = 0;
     467           0 :     if( mpObject.is() )
     468             :     {
     469             :         // each node has a default of 4 glue points
     470             :         // and any number of user defined glue points
     471           0 :         if( mpObject->IsNode() )
     472             :         {
     473           0 :             nCount += 4;
     474             : 
     475           0 :             const SdrGluePointList* pList = mpObject->GetGluePointList();
     476           0 :             if( pList )
     477           0 :                 nCount += pList->GetCount();
     478             :         }
     479             :     }
     480             : 
     481           0 :     return nCount;
     482             : }
     483             : 
     484           0 : uno::Any SAL_CALL SvxUnoGluePointAccess::getByIndex( sal_Int32 Index )
     485             :     throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     486             : {
     487           0 :     if( Index >= 0 && mpObject.is() && mpObject->IsNode() )
     488             :     {
     489           0 :         struct drawing::GluePoint2 aGluePoint;
     490             : 
     491           0 :         if( Index < 4 ) // default glue point?
     492             :         {
     493           0 :             SdrGluePoint aTempPoint = mpObject->GetVertexGluePoint( (sal_uInt16)Index );
     494           0 :             aGluePoint.IsUserDefined = sal_False;
     495           0 :             convert( aTempPoint, aGluePoint );
     496           0 :             uno::Any aAny;
     497           0 :             aAny <<= aGluePoint;
     498           0 :             return aAny;
     499             :         }
     500             :         else
     501             :         {
     502           0 :             Index -= 4;
     503           0 :             const SdrGluePointList* pList = mpObject->GetGluePointList();
     504           0 :             if( pList && Index < pList->GetCount() )
     505             :             {
     506           0 :                 const SdrGluePoint& rTempPoint = (*pList)[(sal_uInt16)Index];
     507           0 :                 aGluePoint.IsUserDefined = sal_True;
     508           0 :                 convert( rTempPoint, aGluePoint );
     509           0 :                 uno::Any aAny;
     510           0 :                 aAny <<= aGluePoint;
     511           0 :                 return aAny;
     512             :             }
     513             :         }
     514             :     }
     515             : 
     516           0 :     throw lang::IndexOutOfBoundsException();
     517             : }
     518             : 
     519             : // XElementAccess
     520           0 : uno::Type SAL_CALL SvxUnoGluePointAccess::getElementType()
     521             :     throw( uno::RuntimeException, std::exception)
     522             : {
     523           0 :     return ::getCppuType((const struct drawing::GluePoint2*)0);
     524             : }
     525             : 
     526           0 : sal_Bool SAL_CALL SvxUnoGluePointAccess::hasElements()
     527             :     throw( uno::RuntimeException, std::exception)
     528             : {
     529           0 :     return mpObject.is() && mpObject->IsNode();
     530             : }
     531             : 
     532             : /**
     533             :  * Create a SvxUnoGluePointAccess
     534             :  */
     535           0 : uno::Reference< uno::XInterface > SAL_CALL SvxUnoGluePointAccess_createInstance( SdrObject* pObject )
     536             : {
     537           0 :     return *new SvxUnoGluePointAccess(pObject);
     538             : }
     539             : 
     540             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10