Debian Codegraph @

chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx

raw
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 "WrappedSceneProperty.hxx"
21 #include "Chart2ModelContact.hxx"
22 #include <BaseGFXHelper.hxx>
23 #include <utility>
24
25 using namespace ::com::sun::star;
26 using ::com::sun::star::uno::Any;
27 using ::com::sun::star::uno::Reference;
28
29 namespace chart::wrapper
30 {
31
32 void WrappedSceneProperty::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
33 , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
34 {
35 rList.emplace_back( new WrappedD3DTransformMatrixProperty( spChart2ModelContact ) );
36 }
37
38 WrappedD3DTransformMatrixProperty::WrappedD3DTransformMatrixProperty(
39 std::shared_ptr<Chart2ModelContact> spChart2ModelContact )
40 : WrappedProperty(u"D3DTransformMatrix"_ustr,u"D3DTransformMatrix"_ustr)
41 , m_spChart2ModelContact(std::move( spChart2ModelContact ))
42 {
43 }
44
45 WrappedD3DTransformMatrixProperty::~WrappedD3DTransformMatrixProperty()
46 {
47 }
48
49 void WrappedD3DTransformMatrixProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
50 {
51 if( m_spChart2ModelContact->getDiagram()->isPieOrDonutChart() )
52 {
53 drawing::HomogenMatrix aHM;
54 if( rOuterValue >>= aHM )
55 {
56 ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
57 BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
58
59 ::basegfx::B3DHomMatrix aMatrix;
60 aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
61 ::basegfx::B3DHomMatrix aObjectMatrix;
62 ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
63
64 aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
65
66 WrappedProperty::setPropertyValue( uno::Any(aHM), xInnerPropertySet );
67 return;
68 }
69 }
70
71 WrappedProperty::setPropertyValue( rOuterValue, xInnerPropertySet );
72 }
73
74 Any WrappedD3DTransformMatrixProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
75 {
76 if( m_spChart2ModelContact->getDiagram()->isPieOrDonutChart() )
77 {
78 uno::Any aAMatrix( WrappedProperty::getPropertyValue( xInnerPropertySet ) );
79 drawing::HomogenMatrix aHM;
80 if( aAMatrix >>= aHM )
81 {
82 ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
83 BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
84
85 ::basegfx::B3DHomMatrix aMatrix;
86 aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
87 ::basegfx::B3DHomMatrix aObjectMatrix;
88 ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
89
90 aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
91
92 return uno::Any(aHM);
93 }
94 }
95
96 return WrappedProperty::getPropertyValue( xInnerPropertySet );
97 }
98
99 } //namespace chart::wrapper
100
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */