xref: /trunk/main/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chartcontroller.hxx"
26 
27 #include "WrappedSceneProperty.hxx"
28 #include "macros.hxx"
29 #include "DiagramHelper.hxx"
30 #include "servicenames_charttypes.hxx"
31 #include "BaseGFXHelper.hxx"
32 
33 using namespace ::com::sun::star;
34 using ::com::sun::star::uno::Any;
35 using ::com::sun::star::uno::Reference;
36 using ::com::sun::star::uno::Sequence;
37 using ::rtl::OUString;
38 
39 //.............................................................................
40 namespace chart
41 {
42 namespace wrapper
43 {
44 
addWrappedProperties(std::vector<WrappedProperty * > & rList,::boost::shared_ptr<Chart2ModelContact> spChart2ModelContact)45 void WrappedSceneProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList
46                 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
47 {
48     rList.push_back( new WrappedD3DTransformMatrixProperty( spChart2ModelContact ) );
49 }
50 
51 //----------------------------------------------------------------------------------------------------------------------
52 //----------------------------------------------------------------------------------------------------------------------
53 //----------------------------------------------------------------------------------------------------------------------
54 
WrappedD3DTransformMatrixProperty(::boost::shared_ptr<Chart2ModelContact> spChart2ModelContact)55 WrappedD3DTransformMatrixProperty::WrappedD3DTransformMatrixProperty(
56             ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
57             : WrappedProperty(C2U("D3DTransformMatrix"),C2U("D3DTransformMatrix"))
58             , m_spChart2ModelContact( spChart2ModelContact )
59 {
60 }
61 
~WrappedD3DTransformMatrixProperty()62 WrappedD3DTransformMatrixProperty::~WrappedD3DTransformMatrixProperty()
63 {
64 }
65 
setPropertyValue(const Any & rOuterValue,const Reference<beans::XPropertySet> & xInnerPropertySet) const66 void WrappedD3DTransformMatrixProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
67 {
68     if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) )
69     {
70         drawing::HomogenMatrix aHM;
71         if( rOuterValue >>= aHM )
72         {
73             ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
74                 BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
75 
76             ::basegfx::B3DHomMatrix aMatrix;
77             aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
78             ::basegfx::B3DHomMatrix aObjectMatrix;
79             ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
80 
81             aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
82 
83             WrappedProperty::setPropertyValue( uno::makeAny(aHM), xInnerPropertySet );
84             return;
85         }
86     }
87 
88     WrappedProperty::setPropertyValue( rOuterValue, xInnerPropertySet );
89 }
90 
getPropertyValue(const Reference<beans::XPropertySet> & xInnerPropertySet) const91 Any WrappedD3DTransformMatrixProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
92 {
93     if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) )
94     {
95         uno::Any aAMatrix( WrappedProperty::getPropertyValue( xInnerPropertySet ) );
96         drawing::HomogenMatrix aHM;
97         if( aAMatrix >>= aHM )
98         {
99             ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
100                 BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
101 
102             ::basegfx::B3DHomMatrix aMatrix;
103             aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
104             ::basegfx::B3DHomMatrix aObjectMatrix;
105             ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
106 
107             aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
108 
109             return uno::makeAny(aHM);
110         }
111     }
112 
113     return WrappedProperty::getPropertyValue( xInnerPropertySet );
114 }
115 
getPropertyDefault(const Reference<beans::XPropertyState> & xInnerPropertyState) const116 Any WrappedD3DTransformMatrixProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
117 {
118     return WrappedProperty::getPropertyDefault( xInnerPropertyState );
119 }
120 
121 } //namespace wrapper
122 } //namespace chart
123 //.............................................................................
124