1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include "EnhancedCustomShapeHandle.hxx"
27 #include "svx/EnhancedCustomShape2d.hxx"
28 #include "svx/unoapi.hxx"
29
30 // -----------------------------------------------------------------------------
31
EnhancedCustomShapeHandle(com::sun::star::uno::Reference<com::sun::star::drawing::XShape> & xCustomShape,sal_uInt32 nIndex)32 EnhancedCustomShapeHandle::EnhancedCustomShapeHandle( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xCustomShape, sal_uInt32 nIndex ) :
33 mnIndex ( nIndex ),
34 mxCustomShape ( xCustomShape )
35 {
36 }
37
38 // -----------------------------------------------------------------------------
39
~EnhancedCustomShapeHandle()40 EnhancedCustomShapeHandle::~EnhancedCustomShapeHandle()
41 {
42 }
43
44 // -----------------------------------------------------------------------------
45
acquire()46 void SAL_CALL EnhancedCustomShapeHandle::acquire() throw()
47 {
48 OWeakObject::acquire();
49 }
50
51 // -----------------------------------------------------------------------------
52
release()53 void SAL_CALL EnhancedCustomShapeHandle::release() throw()
54 {
55 OWeakObject::release();
56 }
57
58 // XCustomShapeHandle
getPosition()59 com::sun::star::awt::Point SAL_CALL EnhancedCustomShapeHandle::getPosition()
60 throw ( com::sun::star::uno::RuntimeException )
61 {
62 SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxCustomShape ) );
63 if ( !pSdrObjCustomShape )
64 throw com::sun::star::uno::RuntimeException();
65
66 Point aPosition;
67 EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
68 if ( !aCustomShape2d.GetHandlePosition( mnIndex, aPosition ) )
69 throw com::sun::star::uno::RuntimeException();
70 return com::sun::star::awt::Point( aPosition.X(), aPosition.Y() );
71 }
72
setControllerPosition(const com::sun::star::awt::Point & aPnt)73 void SAL_CALL EnhancedCustomShapeHandle::setControllerPosition( const com::sun::star::awt::Point& aPnt )
74 throw ( com::sun::star::uno::RuntimeException )
75 {
76 SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxCustomShape ) );
77 if ( !pSdrObjCustomShape )
78 throw com::sun::star::uno::RuntimeException();
79
80 EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
81 if ( !aCustomShape2d.SetHandleControllerPosition( mnIndex, aPnt ) )
82 throw com::sun::star::uno::RuntimeException();
83 }
84
85 // XInitialization
initialize(const com::sun::star::uno::Sequence<com::sun::star::uno::Any> &)86 void SAL_CALL EnhancedCustomShapeHandle::initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& /* aArguments */ )
87 throw ( com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException )
88 {
89 }
90