1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 
31 #include "WrappedSceneProperty.hxx"
32 #include "macros.hxx"
33 #include "DiagramHelper.hxx"
34 #include "servicenames_charttypes.hxx"
35 #include "BaseGFXHelper.hxx"
36 
37 using namespace ::com::sun::star;
38 using ::com::sun::star::uno::Any;
39 using ::com::sun::star::uno::Reference;
40 using ::com::sun::star::uno::Sequence;
41 using ::rtl::OUString;
42 
43 //.............................................................................
44 namespace chart
45 {
46 namespace wrapper
47 {
48 
49 void WrappedSceneProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList
50                 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
51 {
52     rList.push_back( new WrappedD3DTransformMatrixProperty( spChart2ModelContact ) );
53 }
54 
55 //----------------------------------------------------------------------------------------------------------------------
56 //----------------------------------------------------------------------------------------------------------------------
57 //----------------------------------------------------------------------------------------------------------------------
58 
59 WrappedD3DTransformMatrixProperty::WrappedD3DTransformMatrixProperty(
60             ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
61             : WrappedProperty(C2U("D3DTransformMatrix"),C2U("D3DTransformMatrix"))
62             , m_spChart2ModelContact( spChart2ModelContact )
63 {
64 }
65 
66 WrappedD3DTransformMatrixProperty::~WrappedD3DTransformMatrixProperty()
67 {
68 }
69 
70 void WrappedD3DTransformMatrixProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
71                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
72 {
73     if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) )
74     {
75         drawing::HomogenMatrix aHM;
76         if( rOuterValue >>= aHM )
77         {
78             ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
79                 BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
80 
81             ::basegfx::B3DHomMatrix aMatrix;
82             aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
83             ::basegfx::B3DHomMatrix aObjectMatrix;
84             ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
85 
86             aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
87 
88             WrappedProperty::setPropertyValue( uno::makeAny(aHM), xInnerPropertySet );
89             return;
90         }
91     }
92 
93     WrappedProperty::setPropertyValue( rOuterValue, xInnerPropertySet );
94 }
95 
96 Any WrappedD3DTransformMatrixProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
97                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
98 {
99     if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) )
100     {
101         uno::Any aAMatrix( WrappedProperty::getPropertyValue( xInnerPropertySet ) );
102         drawing::HomogenMatrix aHM;
103         if( aAMatrix >>= aHM )
104         {
105             ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
106                 BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
107 
108             ::basegfx::B3DHomMatrix aMatrix;
109             aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
110             ::basegfx::B3DHomMatrix aObjectMatrix;
111             ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
112 
113             aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
114 
115             return uno::makeAny(aHM);
116         }
117     }
118 
119     return WrappedProperty::getPropertyValue( xInnerPropertySet );
120 }
121 
122 Any WrappedD3DTransformMatrixProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
123                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
124 {
125     return WrappedProperty::getPropertyDefault( xInnerPropertyState );
126 }
127 
128 } //namespace wrapper
129 } //namespace chart
130 //.............................................................................
131