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

Generated by: LCOV version 1.10