1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*cde9e8dcSAndrew Rist * distributed with this work for additional information
6*cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at
10*cde9e8dcSAndrew Rist *
11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*cde9e8dcSAndrew Rist *
13*cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the
17*cde9e8dcSAndrew Rist * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist * under the License.
19*cde9e8dcSAndrew Rist *
20*cde9e8dcSAndrew Rist *************************************************************/
21*cde9e8dcSAndrew Rist
22*cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "WrappedNumberFormatProperty.hxx"
28cdf0e10cSrcweir #include "macros.hxx"
29cdf0e10cSrcweir
30cdf0e10cSrcweir // header for define DBG_ERROR
31cdf0e10cSrcweir #include <tools/debug.hxx>
32cdf0e10cSrcweir
33cdf0e10cSrcweir using namespace ::com::sun::star;
34cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
35cdf0e10cSrcweir using ::com::sun::star::uno::Any;
36cdf0e10cSrcweir using ::rtl::OUString;
37cdf0e10cSrcweir
38cdf0e10cSrcweir //.............................................................................
39cdf0e10cSrcweir namespace chart
40cdf0e10cSrcweir {
41cdf0e10cSrcweir namespace wrapper
42cdf0e10cSrcweir {
43cdf0e10cSrcweir //.............................................................................
44cdf0e10cSrcweir
WrappedNumberFormatProperty(::boost::shared_ptr<Chart2ModelContact> spChart2ModelContact)45cdf0e10cSrcweir WrappedNumberFormatProperty::WrappedNumberFormatProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
46cdf0e10cSrcweir : WrappedDirectStateProperty( C2U("NumberFormat"), C2U("NumberFormat") )
47cdf0e10cSrcweir , m_spChart2ModelContact(spChart2ModelContact)
48cdf0e10cSrcweir {
49cdf0e10cSrcweir m_aOuterValue = getPropertyDefault( 0 );
50cdf0e10cSrcweir }
51cdf0e10cSrcweir
~WrappedNumberFormatProperty()52cdf0e10cSrcweir WrappedNumberFormatProperty::~WrappedNumberFormatProperty()
53cdf0e10cSrcweir {
54cdf0e10cSrcweir if( m_pWrappedLinkNumberFormatProperty )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir if( m_pWrappedLinkNumberFormatProperty->m_pWrappedNumberFormatProperty == this )
57cdf0e10cSrcweir m_pWrappedLinkNumberFormatProperty->m_pWrappedNumberFormatProperty = 0;
58cdf0e10cSrcweir }
59cdf0e10cSrcweir }
60cdf0e10cSrcweir
setPropertyValue(const Any & rOuterValue,const Reference<beans::XPropertySet> & xInnerPropertySet) const61cdf0e10cSrcweir void WrappedNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
62cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
63cdf0e10cSrcweir {
64cdf0e10cSrcweir sal_Int32 nFormat = 0;
65cdf0e10cSrcweir if( ! (rOuterValue >>= nFormat) )
66cdf0e10cSrcweir throw lang::IllegalArgumentException( C2U("Property 'NumberFormat' requires value of type sal_Int32"), 0, 0 );
67cdf0e10cSrcweir
68cdf0e10cSrcweir m_aOuterValue = rOuterValue;
69cdf0e10cSrcweir if(xInnerPropertySet.is())
70cdf0e10cSrcweir {
71cdf0e10cSrcweir bool bUseSourceFormat = !xInnerPropertySet->getPropertyValue( C2U("NumberFormat" )).hasValue();
72cdf0e10cSrcweir if( bUseSourceFormat )
73cdf0e10cSrcweir {
74cdf0e10cSrcweir uno::Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
75cdf0e10cSrcweir if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() )
76cdf0e10cSrcweir bUseSourceFormat = false;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir if( !bUseSourceFormat )
79cdf0e10cSrcweir xInnerPropertySet->setPropertyValue( m_aInnerName, this->convertOuterToInnerValue( rOuterValue ) );
80cdf0e10cSrcweir }
81cdf0e10cSrcweir }
82cdf0e10cSrcweir
getPropertyValue(const Reference<beans::XPropertySet> & xInnerPropertySet) const83cdf0e10cSrcweir Any WrappedNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
84cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
85cdf0e10cSrcweir {
86cdf0e10cSrcweir if( !xInnerPropertySet.is() )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir DBG_ERROR("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
89cdf0e10cSrcweir return Any();
90cdf0e10cSrcweir }
91cdf0e10cSrcweir Any aRet( xInnerPropertySet->getPropertyValue( m_aInnerName ));
92cdf0e10cSrcweir if( !aRet.hasValue() )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir sal_Int32 nKey = 0;
95cdf0e10cSrcweir Reference< chart2::XDataSeries > xSeries( xInnerPropertySet, uno::UNO_QUERY );
96cdf0e10cSrcweir if( xSeries.is() )
97cdf0e10cSrcweir nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForSeries( xSeries );
98cdf0e10cSrcweir else
99cdf0e10cSrcweir {
100cdf0e10cSrcweir Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY );
101cdf0e10cSrcweir nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForAxis( xAxis );
102cdf0e10cSrcweir }
103cdf0e10cSrcweir aRet <<= nKey;
104cdf0e10cSrcweir }
105cdf0e10cSrcweir return aRet;
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
getPropertyDefault(const Reference<beans::XPropertyState> &) const108cdf0e10cSrcweir Any WrappedNumberFormatProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
109cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
110cdf0e10cSrcweir {
111cdf0e10cSrcweir return uno::makeAny( sal_Int32( 0 ) );
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
114cdf0e10cSrcweir //-----------------------------------------------------------------------------
115cdf0e10cSrcweir //-----------------------------------------------------------------------------
116cdf0e10cSrcweir //-----------------------------------------------------------------------------
117cdf0e10cSrcweir
WrappedLinkNumberFormatProperty(WrappedNumberFormatProperty * pWrappedNumberFormatProperty)118cdf0e10cSrcweir WrappedLinkNumberFormatProperty::WrappedLinkNumberFormatProperty( WrappedNumberFormatProperty* pWrappedNumberFormatProperty )
119cdf0e10cSrcweir : WrappedProperty( C2U("LinkNumberFormatToSource"), C2U("") )
120cdf0e10cSrcweir , m_pWrappedNumberFormatProperty( pWrappedNumberFormatProperty )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir if( m_pWrappedNumberFormatProperty )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty = this;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir }
127cdf0e10cSrcweir
~WrappedLinkNumberFormatProperty()128cdf0e10cSrcweir WrappedLinkNumberFormatProperty::~WrappedLinkNumberFormatProperty()
129cdf0e10cSrcweir {
130cdf0e10cSrcweir if( m_pWrappedNumberFormatProperty )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir if( m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty == this )
133cdf0e10cSrcweir m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty = 0;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
setPropertyValue(const Any & rOuterValue,const Reference<beans::XPropertySet> & xInnerPropertySet) const137cdf0e10cSrcweir void WrappedLinkNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
138cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
139cdf0e10cSrcweir {
140cdf0e10cSrcweir if( !xInnerPropertySet.is() )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir DBG_ERROR("missing xInnerPropertySet in WrappedNumberFormatProperty::setPropertyValue");
143cdf0e10cSrcweir return;
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
146cdf0e10cSrcweir bool bLinkFormat = false;
147cdf0e10cSrcweir if( rOuterValue >>= bLinkFormat )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir Any aValue;
150cdf0e10cSrcweir if( bLinkFormat )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir if( m_pWrappedNumberFormatProperty )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir uno::Reference< chart2::XChartDocument > xChartDoc( m_pWrappedNumberFormatProperty->m_spChart2ModelContact->getChart2Document() );
155cdf0e10cSrcweir if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() )
156cdf0e10cSrcweir return;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir }
159cdf0e10cSrcweir else
160cdf0e10cSrcweir {
161cdf0e10cSrcweir if( m_pWrappedNumberFormatProperty )
162cdf0e10cSrcweir {
163cdf0e10cSrcweir aValue = m_pWrappedNumberFormatProperty->getPropertyValue( xInnerPropertySet );
164cdf0e10cSrcweir }
165cdf0e10cSrcweir else
166cdf0e10cSrcweir aValue <<= sal_Int32( 0 );
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
169cdf0e10cSrcweir xInnerPropertySet->setPropertyValue( C2U("NumberFormat"), aValue );
170cdf0e10cSrcweir }
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
getPropertyValue(const Reference<beans::XPropertySet> & xInnerPropertySet) const173cdf0e10cSrcweir Any WrappedLinkNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
174cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
175cdf0e10cSrcweir {
176cdf0e10cSrcweir if( !xInnerPropertySet.is() )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir DBG_ERROR("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
179cdf0e10cSrcweir return getPropertyDefault(0);
180cdf0e10cSrcweir }
181cdf0e10cSrcweir bool bLink = ! xInnerPropertySet->getPropertyValue( C2U("NumberFormat" )).hasValue();
182cdf0e10cSrcweir return uno::makeAny( bLink );
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
getPropertyDefault(const Reference<beans::XPropertyState> &) const185cdf0e10cSrcweir Any WrappedLinkNumberFormatProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
186cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir bool bLink = true;
189cdf0e10cSrcweir return uno::makeAny( bLink );
190cdf0e10cSrcweir }
191cdf0e10cSrcweir
192cdf0e10cSrcweir //.............................................................................
193cdf0e10cSrcweir } //namespace wrapper
194cdf0e10cSrcweir } //namespace chart
195cdf0e10cSrcweir //.............................................................................
196