Line data Source code
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 "macros.hxx"
22 : #include "DiagramHelper.hxx"
23 : #include "servicenames_charttypes.hxx"
24 : #include "BaseGFXHelper.hxx"
25 :
26 : using namespace ::com::sun::star;
27 : using ::com::sun::star::uno::Any;
28 : using ::com::sun::star::uno::Reference;
29 : using ::com::sun::star::uno::Sequence;
30 :
31 : namespace chart
32 : {
33 : namespace wrapper
34 : {
35 :
36 580 : void WrappedSceneProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList
37 : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
38 : {
39 580 : rList.push_back( new WrappedD3DTransformMatrixProperty( spChart2ModelContact ) );
40 580 : }
41 :
42 580 : WrappedD3DTransformMatrixProperty::WrappedD3DTransformMatrixProperty(
43 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
44 : : WrappedProperty("D3DTransformMatrix","D3DTransformMatrix")
45 580 : , m_spChart2ModelContact( spChart2ModelContact )
46 : {
47 580 : }
48 :
49 1160 : WrappedD3DTransformMatrixProperty::~WrappedD3DTransformMatrixProperty()
50 : {
51 1160 : }
52 :
53 64 : void WrappedD3DTransformMatrixProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
54 : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
55 : {
56 64 : if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) )
57 : {
58 8 : drawing::HomogenMatrix aHM;
59 8 : if( rOuterValue >>= aHM )
60 : {
61 : ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
62 8 : BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
63 :
64 16 : ::basegfx::B3DHomMatrix aMatrix;
65 8 : aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
66 16 : ::basegfx::B3DHomMatrix aObjectMatrix;
67 16 : ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
68 :
69 8 : aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
70 :
71 8 : WrappedProperty::setPropertyValue( uno::makeAny(aHM), xInnerPropertySet );
72 80 : return;
73 : }
74 : }
75 :
76 56 : WrappedProperty::setPropertyValue( rOuterValue, xInnerPropertySet );
77 : }
78 :
79 204 : Any WrappedD3DTransformMatrixProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
80 : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
81 : {
82 204 : if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) )
83 : {
84 36 : uno::Any aAMatrix( WrappedProperty::getPropertyValue( xInnerPropertySet ) );
85 36 : drawing::HomogenMatrix aHM;
86 36 : if( aAMatrix >>= aHM )
87 : {
88 : ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
89 36 : BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
90 :
91 72 : ::basegfx::B3DHomMatrix aMatrix;
92 36 : aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
93 72 : ::basegfx::B3DHomMatrix aObjectMatrix;
94 72 : ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
95 :
96 36 : aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
97 :
98 72 : return uno::makeAny(aHM);
99 0 : }
100 : }
101 :
102 168 : return WrappedProperty::getPropertyValue( xInnerPropertySet );
103 : }
104 :
105 0 : Any WrappedD3DTransformMatrixProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
106 : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
107 : {
108 0 : return WrappedProperty::getPropertyDefault( xInnerPropertyState );
109 : }
110 :
111 : } //namespace wrapper
112 102 : } //namespace chart
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|