Branch data 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 : :
21 : : #include "WrappedNumberFormatProperty.hxx"
22 : : #include "macros.hxx"
23 : :
24 : : using namespace ::com::sun::star;
25 : : using ::com::sun::star::uno::Reference;
26 : : using ::com::sun::star::uno::Any;
27 : : using ::rtl::OUString;
28 : :
29 : : //.............................................................................
30 : : namespace chart
31 : : {
32 : : namespace wrapper
33 : : {
34 : : //.............................................................................
35 : :
36 : 122 : WrappedNumberFormatProperty::WrappedNumberFormatProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
37 : : : WrappedDirectStateProperty( "NumberFormat", "NumberFormat" )
38 [ + - ][ + - ]: 122 : , m_spChart2ModelContact(spChart2ModelContact)
39 : : {
40 [ + - ][ + - ]: 122 : m_aOuterValue = getPropertyDefault( 0 );
41 : 122 : }
42 : :
43 [ + - ]: 122 : WrappedNumberFormatProperty::~WrappedNumberFormatProperty()
44 : : {
45 [ + - ]: 122 : if( m_pWrappedLinkNumberFormatProperty )
46 : : {
47 [ + - ]: 122 : if( m_pWrappedLinkNumberFormatProperty->m_pWrappedNumberFormatProperty == this )
48 : 122 : m_pWrappedLinkNumberFormatProperty->m_pWrappedNumberFormatProperty = 0;
49 : : }
50 [ - + ]: 244 : }
51 : :
52 : 22 : void WrappedNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
53 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
54 : : {
55 : 22 : sal_Int32 nFormat = 0;
56 [ - + ]: 22 : if( ! (rOuterValue >>= nFormat) )
57 [ # # ][ # # ]: 0 : throw lang::IllegalArgumentException( "Property 'NumberFormat' requires value of type sal_Int32", 0, 0 );
58 : :
59 : 22 : m_aOuterValue = rOuterValue;
60 [ + - ]: 22 : if(xInnerPropertySet.is())
61 : : {
62 [ + - ][ + - ]: 22 : bool bUseSourceFormat = !xInnerPropertySet->getPropertyValue( "NumberFormat" ).hasValue();
63 [ + + ]: 22 : if( bUseSourceFormat )
64 : : {
65 [ + - ]: 14 : uno::Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
66 [ + - ][ + - ]: 14 : if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() )
[ + - ][ + - ]
[ + - ]
67 : 14 : bUseSourceFormat = false;
68 : : }
69 [ + - ]: 22 : if( !bUseSourceFormat )
70 [ + - ][ + - ]: 22 : xInnerPropertySet->setPropertyValue( m_aInnerName, this->convertOuterToInnerValue( rOuterValue ) );
[ + - ]
71 : : }
72 : 22 : }
73 : :
74 : 238 : Any WrappedNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
75 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
76 : : {
77 [ - + ]: 238 : if( !xInnerPropertySet.is() )
78 : : {
79 : : OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
80 : 0 : return Any();
81 : : }
82 [ + - ][ + - ]: 238 : Any aRet( xInnerPropertySet->getPropertyValue( m_aInnerName ));
83 [ + + ]: 238 : if( !aRet.hasValue() )
84 : : {
85 : 222 : sal_Int32 nKey = 0;
86 [ + - ]: 222 : Reference< chart2::XDataSeries > xSeries( xInnerPropertySet, uno::UNO_QUERY );
87 [ + + ]: 222 : if( xSeries.is() )
88 [ + - ]: 148 : nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForSeries( xSeries );
89 : : else
90 : : {
91 [ + - ]: 74 : Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY );
92 [ + - ]: 74 : nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForAxis( xAxis );
93 : : }
94 [ + - ]: 222 : aRet <<= nKey;
95 : : }
96 : 238 : return aRet;
97 : : }
98 : :
99 : 122 : Any WrappedNumberFormatProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
100 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
101 : : {
102 [ + - ]: 122 : return uno::makeAny( sal_Int32( 0 ) );
103 : : }
104 : :
105 : : //-----------------------------------------------------------------------------
106 : :
107 : 122 : WrappedLinkNumberFormatProperty::WrappedLinkNumberFormatProperty( WrappedNumberFormatProperty* pWrappedNumberFormatProperty )
108 : : : WrappedProperty( "LinkNumberFormatToSource", rtl::OUString() )
109 [ + - ]: 122 : , m_pWrappedNumberFormatProperty( pWrappedNumberFormatProperty )
110 : : {
111 [ + - ]: 122 : if( m_pWrappedNumberFormatProperty )
112 : : {
113 : 122 : m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty = this;
114 : : }
115 : 122 : }
116 : :
117 : 122 : WrappedLinkNumberFormatProperty::~WrappedLinkNumberFormatProperty()
118 : : {
119 [ - + ]: 122 : if( m_pWrappedNumberFormatProperty )
120 : : {
121 [ # # ]: 0 : if( m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty == this )
122 : 0 : m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty = 0;
123 : : }
124 [ - + ]: 244 : }
125 : :
126 : 2 : void WrappedLinkNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
127 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
128 : : {
129 [ + - ]: 2 : if( !xInnerPropertySet.is() )
130 : : {
131 : : OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::setPropertyValue");
132 : : return;
133 : : }
134 : :
135 : 2 : bool bLinkFormat = false;
136 [ + - ]: 2 : if( rOuterValue >>= bLinkFormat )
137 : : {
138 : 2 : Any aValue;
139 [ + - ]: 2 : if( bLinkFormat )
140 : : {
141 [ + - ]: 2 : if( m_pWrappedNumberFormatProperty )
142 : : {
143 [ + - ]: 2 : uno::Reference< chart2::XChartDocument > xChartDoc( m_pWrappedNumberFormatProperty->m_spChart2ModelContact->getChart2Document() );
144 [ + - ][ + - ]: 2 : if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() )
[ + - ][ + - ]
[ + - ]
145 [ - + ]: 2 : return;
146 : : }
147 : : }
148 : : else
149 : : {
150 [ # # ]: 0 : if( m_pWrappedNumberFormatProperty )
151 : : {
152 [ # # ]: 0 : aValue = m_pWrappedNumberFormatProperty->getPropertyValue( xInnerPropertySet );
153 : : }
154 : : else
155 [ # # ]: 0 : aValue <<= sal_Int32( 0 );
156 : : }
157 : :
158 [ # # ][ # # ]: 2 : xInnerPropertySet->setPropertyValue( "NumberFormat", aValue );
[ - + ]
159 : : }
160 : : }
161 : :
162 : 114 : Any WrappedLinkNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
163 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
164 : : {
165 [ - + ]: 114 : if( !xInnerPropertySet.is() )
166 : : {
167 : : OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
168 [ # # ][ # # ]: 0 : return getPropertyDefault(0);
169 : : }
170 [ + - ][ + - ]: 114 : bool bLink = ! xInnerPropertySet->getPropertyValue( "NumberFormat" ).hasValue();
171 [ + - ]: 114 : return uno::makeAny( bLink );
172 : : }
173 : :
174 : 110 : Any WrappedLinkNumberFormatProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
175 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
176 : : {
177 : 110 : bool bLink = true;
178 [ + - ]: 110 : return uno::makeAny( bLink );
179 : : }
180 : :
181 : : //.............................................................................
182 : : } //namespace wrapper
183 : : } //namespace chart
184 : : //.............................................................................
185 : :
186 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|