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_chart2.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                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
68 {
69     if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) )
70     {
71         drawing::HomogenMatrix aHM;
72         if( rOuterValue >>= aHM )
73         {
74             ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
75                 BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
76 
77             ::basegfx::B3DHomMatrix aMatrix;
78             aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
79             ::basegfx::B3DHomMatrix aObjectMatrix;
80             ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
81 
82             aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
83 
84             WrappedProperty::setPropertyValue( uno::makeAny(aHM), xInnerPropertySet );
85             return;
86         }
87     }
88 
89     WrappedProperty::setPropertyValue( rOuterValue, xInnerPropertySet );
90 }
91 
getPropertyValue(const Reference<beans::XPropertySet> & xInnerPropertySet) const92 Any WrappedD3DTransformMatrixProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
93                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
94 {
95     if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) )
96     {
97         uno::Any aAMatrix( WrappedProperty::getPropertyValue( xInnerPropertySet ) );
98         drawing::HomogenMatrix aHM;
99         if( aAMatrix >>= aHM )
100         {
101             ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
102                 BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
103 
104             ::basegfx::B3DHomMatrix aMatrix;
105             aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
106             ::basegfx::B3DHomMatrix aObjectMatrix;
107             ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
108 
109             aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
110 
111             return uno::makeAny(aHM);
112         }
113     }
114 
115     return WrappedProperty::getPropertyValue( xInnerPropertySet );
116 }
117 
getPropertyDefault(const Reference<beans::XPropertyState> & xInnerPropertyState) const118 Any WrappedD3DTransformMatrixProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
119                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
120 {
121     return WrappedProperty::getPropertyDefault( xInnerPropertyState );
122 }
123 
124 } //namespace wrapper
125 } //namespace chart
126 //.............................................................................
127