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