Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / svx / source / customshapes / EnhancedCustomShapeHandle.cxx
blobab4e0d93b460af2409c06265fad741b72fbf86a6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "EnhancedCustomShapeHandle.hxx"
21 #include "svx/EnhancedCustomShape2d.hxx"
22 #include "svx/unoapi.hxx"
25 EnhancedCustomShapeHandle::EnhancedCustomShapeHandle( css::uno::Reference< css::drawing::XShape >& xCustomShape, sal_uInt32 nIndex ) :
26 mnIndex ( nIndex ),
27 mxCustomShape ( xCustomShape )
32 EnhancedCustomShapeHandle::~EnhancedCustomShapeHandle()
37 void SAL_CALL EnhancedCustomShapeHandle::acquire() throw()
39 OWeakObject::acquire();
43 void SAL_CALL EnhancedCustomShapeHandle::release() throw()
45 OWeakObject::release();
48 // XCustomShapeHandle
49 css::awt::Point SAL_CALL EnhancedCustomShapeHandle::getPosition()
51 SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxCustomShape ) );
52 if ( !pSdrObjCustomShape )
53 throw css::uno::RuntimeException();
55 Point aPosition;
56 EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
57 if ( !aCustomShape2d.GetHandlePosition( mnIndex, aPosition ) )
58 throw css::uno::RuntimeException();
59 return css::awt::Point( aPosition.X(), aPosition.Y() );
62 void SAL_CALL EnhancedCustomShapeHandle::setControllerPosition( const css::awt::Point& aPnt )
64 SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxCustomShape ) );
65 if ( !pSdrObjCustomShape )
66 throw css::uno::RuntimeException();
68 EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
69 if ( !aCustomShape2d.SetHandleControllerPosition( mnIndex, aPnt ) )
70 throw css::uno::RuntimeException();
73 // XInitialization
74 void SAL_CALL EnhancedCustomShapeHandle::initialize( const css::uno::Sequence< css::uno::Any >& /* aArguments */ )
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */