Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / controller / chartapiwrapper / WrappedSceneProperty.cxx
blob1f5b011c353817b85ec30953dac46fb43cd7af6f
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 "WrappedSceneProperty.hxx"
21 #include "Chart2ModelContact.hxx"
22 #include <DiagramHelper.hxx>
23 #include <BaseGFXHelper.hxx>
25 using namespace ::com::sun::star;
26 using ::com::sun::star::uno::Any;
27 using ::com::sun::star::uno::Reference;
29 namespace chart
31 namespace wrapper
34 void WrappedSceneProperty::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
35 , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
37 rList.emplace_back( new WrappedD3DTransformMatrixProperty( spChart2ModelContact ) );
40 WrappedD3DTransformMatrixProperty::WrappedD3DTransformMatrixProperty(
41 const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact )
42 : WrappedProperty("D3DTransformMatrix","D3DTransformMatrix")
43 , m_spChart2ModelContact( spChart2ModelContact )
47 WrappedD3DTransformMatrixProperty::~WrappedD3DTransformMatrixProperty()
51 void WrappedD3DTransformMatrixProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
53 if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) )
55 drawing::HomogenMatrix aHM;
56 if( rOuterValue >>= aHM )
58 ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
59 BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
61 ::basegfx::B3DHomMatrix aMatrix;
62 aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
63 ::basegfx::B3DHomMatrix aObjectMatrix;
64 ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
66 aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
68 WrappedProperty::setPropertyValue( uno::Any(aHM), xInnerPropertySet );
69 return;
73 WrappedProperty::setPropertyValue( rOuterValue, xInnerPropertySet );
76 Any WrappedD3DTransformMatrixProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
78 if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) )
80 uno::Any aAMatrix( WrappedProperty::getPropertyValue( xInnerPropertySet ) );
81 drawing::HomogenMatrix aHM;
82 if( aAMatrix >>= aHM )
84 ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
85 BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
87 ::basegfx::B3DHomMatrix aMatrix;
88 aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
89 ::basegfx::B3DHomMatrix aObjectMatrix;
90 ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
92 aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
94 return uno::Any(aHM);
98 return WrappedProperty::getPropertyValue( xInnerPropertySet );
101 } //namespace wrapper
102 } //namespace chart
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */