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

Generated by: LCOV version 1.10