1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/svdoashp.hxx>
26 EnhancedCustomShapeHandle::EnhancedCustomShapeHandle( css::uno::Reference
< css::drawing::XShape
> xCustomShape
, sal_uInt32 nIndex
) :
28 mxCustomShape (std::move( xCustomShape
))
33 EnhancedCustomShapeHandle::~EnhancedCustomShapeHandle()
38 void SAL_CALL
EnhancedCustomShapeHandle::acquire() noexcept
40 OWeakObject::acquire();
44 void SAL_CALL
EnhancedCustomShapeHandle::release() noexcept
46 OWeakObject::release();
50 css::awt::Point SAL_CALL
EnhancedCustomShapeHandle::getPosition()
52 auto pSdrObjCustomShape
= dynamic_cast< SdrObjCustomShape
* >(SdrObject::getSdrObjectFromXShape(mxCustomShape
));
54 if(!pSdrObjCustomShape
)
56 throw css::uno::RuntimeException();
60 EnhancedCustomShape2d
aCustomShape2d(*pSdrObjCustomShape
);
62 if(!aCustomShape2d
.GetHandlePosition(mnIndex
, aPosition
))
64 throw css::uno::RuntimeException();
67 return css::awt::Point( aPosition
.X(), aPosition
.Y() );
70 void SAL_CALL
EnhancedCustomShapeHandle::setControllerPosition( const css::awt::Point
& aPnt
)
72 auto pSdrObjCustomShape
= dynamic_cast< SdrObjCustomShape
* >(SdrObject::getSdrObjectFromXShape(mxCustomShape
));
74 if(!pSdrObjCustomShape
)
76 throw css::uno::RuntimeException();
79 EnhancedCustomShape2d
aCustomShape2d(*pSdrObjCustomShape
);
81 if(!aCustomShape2d
.SetHandleControllerPosition(mnIndex
, aPnt
))
83 throw css::uno::RuntimeException();
88 void SAL_CALL
EnhancedCustomShapeHandle::initialize( const css::uno::Sequence
< css::uno::Any
>& /* aArguments */ )
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */