Bump version to 6.4-15
[LibreOffice.git] / svx / source / customshapes / EnhancedCustomShapeHandle.cxx
blobee7143459b9cc8e64f2f26f337c84109b281460b
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>
23 #include <svx/svdoashp.hxx>
26 EnhancedCustomShapeHandle::EnhancedCustomShapeHandle( css::uno::Reference< css::drawing::XShape > const & xCustomShape, sal_uInt32 nIndex ) :
27 mnIndex ( nIndex ),
28 mxCustomShape ( xCustomShape )
33 EnhancedCustomShapeHandle::~EnhancedCustomShapeHandle()
38 void SAL_CALL EnhancedCustomShapeHandle::acquire() throw()
40 OWeakObject::acquire();
44 void SAL_CALL EnhancedCustomShapeHandle::release() throw()
46 OWeakObject::release();
49 // XCustomShapeHandle
50 css::awt::Point SAL_CALL EnhancedCustomShapeHandle::getPosition()
52 const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(mxCustomShape)));
54 if(!bIsSdrObjCustomShape)
56 throw css::uno::RuntimeException();
59 SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*GetSdrObjectFromXShape(mxCustomShape)));
60 Point aPosition;
61 EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
63 if(!aCustomShape2d.GetHandlePosition(mnIndex, aPosition))
65 throw css::uno::RuntimeException();
68 return css::awt::Point( aPosition.X(), aPosition.Y() );
71 void SAL_CALL EnhancedCustomShapeHandle::setControllerPosition( const css::awt::Point& aPnt )
73 const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(mxCustomShape)));
75 if(!bIsSdrObjCustomShape)
77 throw css::uno::RuntimeException();
80 SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*GetSdrObjectFromXShape(mxCustomShape)));
81 EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
83 if(!aCustomShape2d.SetHandleControllerPosition(mnIndex, aPnt))
85 throw css::uno::RuntimeException();
89 // XInitialization
90 void SAL_CALL EnhancedCustomShapeHandle::initialize( const css::uno::Sequence< css::uno::Any >& /* aArguments */ )
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */