Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/svx/source/customshapes/EnhancedCustomShapeHandle.cxx
Line
Count
Source (jump to first uncovered line)
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
20
#include "EnhancedCustomShapeHandle.hxx"
21
#include <svx/EnhancedCustomShape2d.hxx>
22
#include <svx/svdoashp.hxx>
23
#include <utility>
24
25
26
EnhancedCustomShapeHandle::EnhancedCustomShapeHandle( css::uno::Reference< css::drawing::XShape > xCustomShape, sal_uInt32 nIndex ) :
27
8
    mnIndex     ( nIndex ),
28
8
    mxCustomShape (std::move( xCustomShape ))
29
8
{
30
8
}
31
32
33
EnhancedCustomShapeHandle::~EnhancedCustomShapeHandle()
34
8
{
35
8
}
36
37
38
void SAL_CALL EnhancedCustomShapeHandle::acquire() noexcept
39
24
{
40
24
    OWeakObject::acquire();
41
24
}
42
43
44
void SAL_CALL EnhancedCustomShapeHandle::release() noexcept
45
24
{
46
24
    OWeakObject::release();
47
24
}
48
49
// XCustomShapeHandle
50
css::awt::Point SAL_CALL EnhancedCustomShapeHandle::getPosition()
51
8
{
52
8
    auto pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxCustomShape));
53
54
8
    if(!pSdrObjCustomShape)
55
0
    {
56
0
        throw css::uno::RuntimeException();
57
0
    }
58
59
8
    Point aPosition;
60
8
    EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape);
61
62
8
    if(!aCustomShape2d.GetHandlePosition(mnIndex, aPosition))
63
0
    {
64
0
        throw css::uno::RuntimeException();
65
0
    }
66
67
8
    return css::awt::Point( aPosition.X(), aPosition.Y() );
68
8
}
69
70
void SAL_CALL EnhancedCustomShapeHandle::setControllerPosition( const css::awt::Point& aPnt )
71
0
{
72
0
    auto pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxCustomShape));
73
74
0
    if(!pSdrObjCustomShape)
75
0
    {
76
0
        throw css::uno::RuntimeException();
77
0
    }
78
79
0
    EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape);
80
81
0
    if(!aCustomShape2d.SetHandleControllerPosition(mnIndex, aPnt))
82
0
    {
83
0
        throw css::uno::RuntimeException();
84
0
    }
85
0
}
86
87
// XInitialization
88
void SAL_CALL EnhancedCustomShapeHandle::initialize( const css::uno::Sequence< css::uno::Any >& /* aArguments */ )
89
0
{
90
0
}
91
92
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */