LibreOffice Module svx (master) 1
EnhancedCustomShapeHandle.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
22#include <svx/svdoashp.hxx>
23#include <utility>
24
25
26EnhancedCustomShapeHandle::EnhancedCustomShapeHandle( css::uno::Reference< css::drawing::XShape > xCustomShape, sal_uInt32 nIndex ) :
27 mnIndex ( nIndex ),
28 mxCustomShape (std::move( xCustomShape ))
29{
30}
31
32
34{
35}
36
37
38void SAL_CALL EnhancedCustomShapeHandle::acquire() noexcept
39{
40 OWeakObject::acquire();
41}
42
43
44void SAL_CALL EnhancedCustomShapeHandle::release() noexcept
45{
46 OWeakObject::release();
47}
48
49// XCustomShapeHandle
51{
52 auto pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxCustomShape));
53
54 if(!pSdrObjCustomShape)
55 {
56 throw css::uno::RuntimeException();
57 }
58
59 Point aPosition;
60 EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape);
61
62 if(!aCustomShape2d.GetHandlePosition(mnIndex, aPosition))
63 {
64 throw css::uno::RuntimeException();
65 }
66
67 return css::awt::Point( aPosition.X(), aPosition.Y() );
68}
69
70void SAL_CALL EnhancedCustomShapeHandle::setControllerPosition( const css::awt::Point& aPnt )
71{
72 auto pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxCustomShape));
73
74 if(!pSdrObjCustomShape)
75 {
76 throw css::uno::RuntimeException();
77 }
78
79 EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape);
80
81 if(!aCustomShape2d.SetHandleControllerPosition(mnIndex, aPnt))
82 {
83 throw css::uno::RuntimeException();
84 }
85}
86
87// XInitialization
88void SAL_CALL EnhancedCustomShapeHandle::initialize( const css::uno::Sequence< css::uno::Any >& /* aArguments */ )
89{
90}
91
92/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
int mnIndex
bool SetHandleControllerPosition(const sal_uInt32 nIndex, const css::awt::Point &rPosition)
bool GetHandlePosition(const sal_uInt32 nIndex, Point &rReturnPosition) const
EnhancedCustomShapeHandle(css::uno::Reference< css::drawing::XShape > xCustomShape, sal_uInt32 nIndex)
virtual void SAL_CALL setControllerPosition(const css::awt::Point &) override
virtual ~EnhancedCustomShapeHandle() override
css::uno::Reference< css::drawing::XShape > mxCustomShape
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual void SAL_CALL release() noexcept override
virtual css::awt::Point SAL_CALL getPosition() override
virtual void SAL_CALL acquire() noexcept override
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
Definition: unoshape.cxx:4024
sal_Int32 nIndex