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

Generated by: LCOV version 1.11