xref: /trunk/main/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_chart2.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "WrappedAxisAndGridExistenceProperties.hxx"
32*cdf0e10cSrcweir #include "AxisHelper.hxx"
33*cdf0e10cSrcweir #include "ChartModelHelper.hxx"
34*cdf0e10cSrcweir #include "TitleHelper.hxx"
35*cdf0e10cSrcweir #include "macros.hxx"
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir using namespace ::com::sun::star;
38*cdf0e10cSrcweir using ::com::sun::star::uno::Any;
39*cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
40*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
41*cdf0e10cSrcweir using ::rtl::OUString;
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir //.............................................................................
44*cdf0e10cSrcweir namespace chart
45*cdf0e10cSrcweir {
46*cdf0e10cSrcweir namespace wrapper
47*cdf0e10cSrcweir {
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir class WrappedAxisAndGridExistenceProperty : public WrappedProperty
50*cdf0e10cSrcweir {
51*cdf0e10cSrcweir public:
52*cdf0e10cSrcweir     WrappedAxisAndGridExistenceProperty( bool bAxis, bool bMain, sal_Int32 nDimensionIndex
53*cdf0e10cSrcweir         , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
54*cdf0e10cSrcweir     virtual ~WrappedAxisAndGridExistenceProperty();
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir     virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
57*cdf0e10cSrcweir                         throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
60*cdf0e10cSrcweir                         throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const
63*cdf0e10cSrcweir                         throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir private: //member
66*cdf0e10cSrcweir     ::boost::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
67*cdf0e10cSrcweir     bool        m_bAxis;
68*cdf0e10cSrcweir     bool        m_bMain;
69*cdf0e10cSrcweir     sal_Int32   m_nDimensionIndex;
70*cdf0e10cSrcweir };
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir void WrappedAxisAndGridExistenceProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList
73*cdf0e10cSrcweir             , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir     rList.push_back( new WrappedAxisAndGridExistenceProperty( true, true, 0, spChart2ModelContact ) );//x axis
76*cdf0e10cSrcweir     rList.push_back( new WrappedAxisAndGridExistenceProperty( true, false, 0, spChart2ModelContact ) );//x secondary axis
77*cdf0e10cSrcweir     rList.push_back( new WrappedAxisAndGridExistenceProperty( false, true, 0, spChart2ModelContact ) );//x grid
78*cdf0e10cSrcweir     rList.push_back( new WrappedAxisAndGridExistenceProperty( false, false, 0, spChart2ModelContact ) );//x help grid
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     rList.push_back( new WrappedAxisAndGridExistenceProperty( true, true, 1, spChart2ModelContact ) );//y axis
81*cdf0e10cSrcweir     rList.push_back( new WrappedAxisAndGridExistenceProperty( true, false, 1, spChart2ModelContact ) );//y secondary axis
82*cdf0e10cSrcweir     rList.push_back( new WrappedAxisAndGridExistenceProperty( false, true, 1, spChart2ModelContact ) );//y grid
83*cdf0e10cSrcweir     rList.push_back( new WrappedAxisAndGridExistenceProperty( false, false, 1, spChart2ModelContact ) );//y help grid
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     rList.push_back( new WrappedAxisAndGridExistenceProperty( true, true, 2, spChart2ModelContact ) );//z axis
86*cdf0e10cSrcweir     rList.push_back( new WrappedAxisAndGridExistenceProperty( false, true, 2, spChart2ModelContact ) );//z grid
87*cdf0e10cSrcweir     rList.push_back( new WrappedAxisAndGridExistenceProperty( false, false, 2, spChart2ModelContact ) );//z help grid
88*cdf0e10cSrcweir }
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir WrappedAxisAndGridExistenceProperty::WrappedAxisAndGridExistenceProperty( bool bAxis, bool bMain, sal_Int32 nDimensionIndex
91*cdf0e10cSrcweir                 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
92*cdf0e10cSrcweir             : WrappedProperty(OUString(),OUString())
93*cdf0e10cSrcweir             , m_spChart2ModelContact( spChart2ModelContact )
94*cdf0e10cSrcweir             , m_bAxis( bAxis )
95*cdf0e10cSrcweir             , m_bMain( bMain )
96*cdf0e10cSrcweir             , m_nDimensionIndex( nDimensionIndex )
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir     switch( m_nDimensionIndex )
99*cdf0e10cSrcweir     {
100*cdf0e10cSrcweir         case 0:
101*cdf0e10cSrcweir         {
102*cdf0e10cSrcweir             if( m_bAxis )
103*cdf0e10cSrcweir             {
104*cdf0e10cSrcweir                 if( m_bMain )
105*cdf0e10cSrcweir                     m_aOuterName = C2U( "HasXAxis" );
106*cdf0e10cSrcweir                 else
107*cdf0e10cSrcweir                     m_aOuterName = C2U( "HasSecondaryXAxis" );
108*cdf0e10cSrcweir             }
109*cdf0e10cSrcweir             else
110*cdf0e10cSrcweir             {
111*cdf0e10cSrcweir                 if( m_bMain )
112*cdf0e10cSrcweir                     m_aOuterName = C2U( "HasXAxisGrid" );
113*cdf0e10cSrcweir                 else
114*cdf0e10cSrcweir                     m_aOuterName = C2U( "HasXAxisHelpGrid" );
115*cdf0e10cSrcweir             }
116*cdf0e10cSrcweir         }
117*cdf0e10cSrcweir         break;
118*cdf0e10cSrcweir         case 2:
119*cdf0e10cSrcweir         {
120*cdf0e10cSrcweir             if( m_bAxis )
121*cdf0e10cSrcweir             {
122*cdf0e10cSrcweir                 OSL_ENSURE(m_bMain == true,"there is no secondary z axis at the old api");
123*cdf0e10cSrcweir                 m_bMain = true;
124*cdf0e10cSrcweir                 m_aOuterName = C2U( "HasZAxis" );
125*cdf0e10cSrcweir             }
126*cdf0e10cSrcweir             else
127*cdf0e10cSrcweir             {
128*cdf0e10cSrcweir                 if( m_bMain )
129*cdf0e10cSrcweir                     m_aOuterName = C2U( "HasZAxisGrid" );
130*cdf0e10cSrcweir                 else
131*cdf0e10cSrcweir                     m_aOuterName = C2U( "HasZAxisHelpGrid" );
132*cdf0e10cSrcweir             }
133*cdf0e10cSrcweir         }
134*cdf0e10cSrcweir         break;
135*cdf0e10cSrcweir         default:
136*cdf0e10cSrcweir         {
137*cdf0e10cSrcweir             if( m_bAxis )
138*cdf0e10cSrcweir             {
139*cdf0e10cSrcweir                 if( m_bMain )
140*cdf0e10cSrcweir                     m_aOuterName = C2U( "HasYAxis" );
141*cdf0e10cSrcweir                 else
142*cdf0e10cSrcweir                     m_aOuterName = C2U( "HasSecondaryYAxis" );
143*cdf0e10cSrcweir             }
144*cdf0e10cSrcweir             else
145*cdf0e10cSrcweir             {
146*cdf0e10cSrcweir                 if( m_bMain )
147*cdf0e10cSrcweir                     m_aOuterName = C2U( "HasYAxisGrid" );
148*cdf0e10cSrcweir                 else
149*cdf0e10cSrcweir                     m_aOuterName = C2U( "HasYAxisHelpGrid" );
150*cdf0e10cSrcweir             }
151*cdf0e10cSrcweir         }
152*cdf0e10cSrcweir         break;
153*cdf0e10cSrcweir     }
154*cdf0e10cSrcweir }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir WrappedAxisAndGridExistenceProperty::~WrappedAxisAndGridExistenceProperty()
157*cdf0e10cSrcweir {
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir void WrappedAxisAndGridExistenceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
161*cdf0e10cSrcweir                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir     sal_Bool bNewValue = false;
164*cdf0e10cSrcweir     if( ! (rOuterValue >>= bNewValue) )
165*cdf0e10cSrcweir         throw lang::IllegalArgumentException( C2U("Has axis or grid properties require boolean values"), 0, 0 );
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir     sal_Bool bOldValue = sal_False;
168*cdf0e10cSrcweir     getPropertyValue( xInnerPropertySet ) >>= bOldValue;
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     if( bOldValue == bNewValue )
171*cdf0e10cSrcweir         return;
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
174*cdf0e10cSrcweir     if( bNewValue )
175*cdf0e10cSrcweir     {
176*cdf0e10cSrcweir         if( m_bAxis )
177*cdf0e10cSrcweir             AxisHelper::showAxis( m_nDimensionIndex, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext );
178*cdf0e10cSrcweir         else
179*cdf0e10cSrcweir             AxisHelper::showGrid( m_nDimensionIndex, 0, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext );
180*cdf0e10cSrcweir     }
181*cdf0e10cSrcweir     else
182*cdf0e10cSrcweir     {
183*cdf0e10cSrcweir         if( m_bAxis )
184*cdf0e10cSrcweir             AxisHelper::hideAxis( m_nDimensionIndex, m_bMain, xDiagram );
185*cdf0e10cSrcweir         else
186*cdf0e10cSrcweir             AxisHelper::hideGrid( m_nDimensionIndex, 0, m_bMain, xDiagram );
187*cdf0e10cSrcweir     }
188*cdf0e10cSrcweir }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir Any WrappedAxisAndGridExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /* xInnerPropertySet */ ) const
191*cdf0e10cSrcweir                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
192*cdf0e10cSrcweir {
193*cdf0e10cSrcweir     Any aRet;
194*cdf0e10cSrcweir     Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
195*cdf0e10cSrcweir     if(m_bAxis)
196*cdf0e10cSrcweir     {
197*cdf0e10cSrcweir         sal_Bool bShown = AxisHelper::isAxisShown( m_nDimensionIndex, m_bMain, xDiagram );
198*cdf0e10cSrcweir         aRet <<= bShown;
199*cdf0e10cSrcweir     }
200*cdf0e10cSrcweir     else
201*cdf0e10cSrcweir     {
202*cdf0e10cSrcweir         sal_Bool bShown = AxisHelper::isGridShown( m_nDimensionIndex, 0, m_bMain, xDiagram );
203*cdf0e10cSrcweir         aRet <<= bShown;
204*cdf0e10cSrcweir     }
205*cdf0e10cSrcweir     return aRet;
206*cdf0e10cSrcweir }
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir Any WrappedAxisAndGridExistenceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
209*cdf0e10cSrcweir                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
210*cdf0e10cSrcweir {
211*cdf0e10cSrcweir     Any aRet;
212*cdf0e10cSrcweir     aRet <<= false;
213*cdf0e10cSrcweir     return aRet;
214*cdf0e10cSrcweir }
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------------
217*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------------
218*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------------
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir class WrappedAxisTitleExistenceProperty : public WrappedProperty
221*cdf0e10cSrcweir {
222*cdf0e10cSrcweir public:
223*cdf0e10cSrcweir     WrappedAxisTitleExistenceProperty( sal_Int32 nTitleIndex
224*cdf0e10cSrcweir         , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
225*cdf0e10cSrcweir     virtual ~WrappedAxisTitleExistenceProperty();
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir     virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
228*cdf0e10cSrcweir                         throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
231*cdf0e10cSrcweir                         throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const
234*cdf0e10cSrcweir                         throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir private: //member
237*cdf0e10cSrcweir     ::boost::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
238*cdf0e10cSrcweir     TitleHelper::eTitleType             m_eTitleType;
239*cdf0e10cSrcweir };
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir void WrappedAxisTitleExistenceProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList
242*cdf0e10cSrcweir             , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
243*cdf0e10cSrcweir {
244*cdf0e10cSrcweir     rList.push_back( new WrappedAxisTitleExistenceProperty( 0, spChart2ModelContact ) );//x axis title
245*cdf0e10cSrcweir     rList.push_back( new WrappedAxisTitleExistenceProperty( 1, spChart2ModelContact ) );//y axis title
246*cdf0e10cSrcweir     rList.push_back( new WrappedAxisTitleExistenceProperty( 2, spChart2ModelContact ) );//z axis title
247*cdf0e10cSrcweir     rList.push_back( new WrappedAxisTitleExistenceProperty( 3, spChart2ModelContact ) );//secondary x axis title
248*cdf0e10cSrcweir     rList.push_back( new WrappedAxisTitleExistenceProperty( 4, spChart2ModelContact ) );//secondary y axis title
249*cdf0e10cSrcweir }
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir WrappedAxisTitleExistenceProperty::WrappedAxisTitleExistenceProperty( sal_Int32 nTitleIndex
252*cdf0e10cSrcweir                 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
253*cdf0e10cSrcweir             : WrappedProperty(OUString(),OUString())
254*cdf0e10cSrcweir             , m_spChart2ModelContact( spChart2ModelContact )
255*cdf0e10cSrcweir             , m_eTitleType( TitleHelper::Y_AXIS_TITLE )
256*cdf0e10cSrcweir {
257*cdf0e10cSrcweir     switch( nTitleIndex )
258*cdf0e10cSrcweir     {
259*cdf0e10cSrcweir         case 0:
260*cdf0e10cSrcweir             m_aOuterName = C2U( "HasXAxisTitle" );
261*cdf0e10cSrcweir             m_eTitleType = TitleHelper::X_AXIS_TITLE;
262*cdf0e10cSrcweir             break;
263*cdf0e10cSrcweir         case 2:
264*cdf0e10cSrcweir             m_aOuterName = C2U( "HasZAxisTitle" );
265*cdf0e10cSrcweir             m_eTitleType = TitleHelper::Z_AXIS_TITLE;
266*cdf0e10cSrcweir             break;
267*cdf0e10cSrcweir         case 3:
268*cdf0e10cSrcweir             m_aOuterName = C2U( "HasSecondaryXAxisTitle" );
269*cdf0e10cSrcweir             m_eTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE;
270*cdf0e10cSrcweir             break;
271*cdf0e10cSrcweir         case 4:
272*cdf0e10cSrcweir             m_aOuterName = C2U( "HasSecondaryYAxisTitle" );
273*cdf0e10cSrcweir             m_eTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE;
274*cdf0e10cSrcweir             break;
275*cdf0e10cSrcweir         default:
276*cdf0e10cSrcweir             m_aOuterName = C2U( "HasYAxisTitle" );
277*cdf0e10cSrcweir             m_eTitleType = TitleHelper::Y_AXIS_TITLE;
278*cdf0e10cSrcweir             break;
279*cdf0e10cSrcweir     }
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir WrappedAxisTitleExistenceProperty::~WrappedAxisTitleExistenceProperty()
283*cdf0e10cSrcweir {
284*cdf0e10cSrcweir }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir void WrappedAxisTitleExistenceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
287*cdf0e10cSrcweir                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
288*cdf0e10cSrcweir {
289*cdf0e10cSrcweir     sal_Bool bNewValue = false;
290*cdf0e10cSrcweir     if( ! (rOuterValue >>= bNewValue) )
291*cdf0e10cSrcweir         throw lang::IllegalArgumentException( C2U("Has axis or grid properties require boolean values"), 0, 0 );
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir     sal_Bool bOldValue = sal_False;
294*cdf0e10cSrcweir     getPropertyValue( xInnerPropertySet ) >>= bOldValue;
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir     if( bOldValue == bNewValue )
297*cdf0e10cSrcweir         return;
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir     if( bNewValue )
300*cdf0e10cSrcweir     {
301*cdf0e10cSrcweir         rtl::OUString aTitleText;
302*cdf0e10cSrcweir         TitleHelper::createTitle(  m_eTitleType, aTitleText
303*cdf0e10cSrcweir             , m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
304*cdf0e10cSrcweir     }
305*cdf0e10cSrcweir     else
306*cdf0e10cSrcweir     {
307*cdf0e10cSrcweir         TitleHelper::removeTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() );
308*cdf0e10cSrcweir     }
309*cdf0e10cSrcweir }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir Any WrappedAxisTitleExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
312*cdf0e10cSrcweir                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
313*cdf0e10cSrcweir {
314*cdf0e10cSrcweir     sal_Bool bHasTitle = sal_False;
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir     Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() ) );
317*cdf0e10cSrcweir     if( xTitle.is() && (TitleHelper::getCompleteString( xTitle ).getLength() != 0) )
318*cdf0e10cSrcweir         bHasTitle = sal_True;
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir     Any aRet;
321*cdf0e10cSrcweir     aRet <<= bHasTitle;
322*cdf0e10cSrcweir     return aRet;
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir }
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir Any WrappedAxisTitleExistenceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
327*cdf0e10cSrcweir                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
328*cdf0e10cSrcweir {
329*cdf0e10cSrcweir     Any aRet;
330*cdf0e10cSrcweir     aRet <<= sal_Bool( sal_False );
331*cdf0e10cSrcweir     return aRet;
332*cdf0e10cSrcweir }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------------
335*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------------
336*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------------
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir class WrappedAxisLabelExistenceProperty : public WrappedProperty
339*cdf0e10cSrcweir {
340*cdf0e10cSrcweir public:
341*cdf0e10cSrcweir     WrappedAxisLabelExistenceProperty( bool bMain, sal_Int32 nDimensionIndex
342*cdf0e10cSrcweir         , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
343*cdf0e10cSrcweir     virtual ~WrappedAxisLabelExistenceProperty();
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir     virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
346*cdf0e10cSrcweir                         throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
349*cdf0e10cSrcweir                         throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const
352*cdf0e10cSrcweir                         throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir private: //member
355*cdf0e10cSrcweir     ::boost::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
356*cdf0e10cSrcweir     bool        m_bMain;
357*cdf0e10cSrcweir     sal_Int32   m_nDimensionIndex;
358*cdf0e10cSrcweir };
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir void WrappedAxisLabelExistenceProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList
361*cdf0e10cSrcweir             , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
362*cdf0e10cSrcweir {
363*cdf0e10cSrcweir     rList.push_back( new WrappedAxisLabelExistenceProperty( true, 0, spChart2ModelContact ) );//x axis
364*cdf0e10cSrcweir     rList.push_back( new WrappedAxisLabelExistenceProperty( true, 1, spChart2ModelContact ) );//y axis
365*cdf0e10cSrcweir     rList.push_back( new WrappedAxisLabelExistenceProperty( true, 2, spChart2ModelContact ) );//z axis
366*cdf0e10cSrcweir     rList.push_back( new WrappedAxisLabelExistenceProperty( false, 0, spChart2ModelContact ) );//secondary x axis
367*cdf0e10cSrcweir     rList.push_back( new WrappedAxisLabelExistenceProperty( false, 1, spChart2ModelContact ) );//secondary y axis
368*cdf0e10cSrcweir }
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir WrappedAxisLabelExistenceProperty::WrappedAxisLabelExistenceProperty( bool bMain, sal_Int32 nDimensionIndex
371*cdf0e10cSrcweir                 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
372*cdf0e10cSrcweir             : WrappedProperty(OUString(),OUString())
373*cdf0e10cSrcweir             , m_spChart2ModelContact( spChart2ModelContact )
374*cdf0e10cSrcweir             , m_bMain( bMain )
375*cdf0e10cSrcweir             , m_nDimensionIndex( nDimensionIndex )
376*cdf0e10cSrcweir {
377*cdf0e10cSrcweir     switch( m_nDimensionIndex )
378*cdf0e10cSrcweir     {
379*cdf0e10cSrcweir         case 0:
380*cdf0e10cSrcweir             m_aOuterName = m_bMain ? C2U( "HasXAxisDescription" ) : C2U( "HasSecondaryXAxisDescription" );
381*cdf0e10cSrcweir             break;
382*cdf0e10cSrcweir         case 2:
383*cdf0e10cSrcweir             OSL_ENSURE(m_bMain,"there is no description available for a secondary z axis");
384*cdf0e10cSrcweir             m_aOuterName = C2U( "HasZAxisDescription" );
385*cdf0e10cSrcweir             break;
386*cdf0e10cSrcweir         default:
387*cdf0e10cSrcweir             m_aOuterName = m_bMain ? C2U( "HasYAxisDescription" ) : C2U( "HasSecondaryYAxisDescription" );
388*cdf0e10cSrcweir             break;
389*cdf0e10cSrcweir     }
390*cdf0e10cSrcweir }
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir WrappedAxisLabelExistenceProperty::~WrappedAxisLabelExistenceProperty()
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir }
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir void WrappedAxisLabelExistenceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
397*cdf0e10cSrcweir                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
398*cdf0e10cSrcweir {
399*cdf0e10cSrcweir     sal_Bool bNewValue = false;
400*cdf0e10cSrcweir     if( ! (rOuterValue >>= bNewValue) )
401*cdf0e10cSrcweir         throw lang::IllegalArgumentException( C2U("Has axis or grid properties require boolean values"), 0, 0 );
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir     sal_Bool bOldValue = sal_False;
404*cdf0e10cSrcweir     getPropertyValue( xInnerPropertySet ) >>= bOldValue;
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir     if( bOldValue == bNewValue )
407*cdf0e10cSrcweir         return;
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir     Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
410*cdf0e10cSrcweir     Reference< beans::XPropertySet > xProp( AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ), uno::UNO_QUERY );
411*cdf0e10cSrcweir     if( !xProp.is() && bNewValue )
412*cdf0e10cSrcweir     {
413*cdf0e10cSrcweir         //create axis if needed
414*cdf0e10cSrcweir         xProp.set( AxisHelper::createAxis( m_nDimensionIndex, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext ), uno::UNO_QUERY );
415*cdf0e10cSrcweir         if( xProp.is() )
416*cdf0e10cSrcweir             xProp->setPropertyValue( C2U( "Show" ), uno::makeAny( sal_False ) );
417*cdf0e10cSrcweir     }
418*cdf0e10cSrcweir     if( xProp.is() )
419*cdf0e10cSrcweir         xProp->setPropertyValue( C2U( "DisplayLabels" ), rOuterValue );
420*cdf0e10cSrcweir }
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir Any WrappedAxisLabelExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
423*cdf0e10cSrcweir                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
424*cdf0e10cSrcweir {
425*cdf0e10cSrcweir     Any aRet;
426*cdf0e10cSrcweir     Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
427*cdf0e10cSrcweir     Reference< beans::XPropertySet > xProp( AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ), uno::UNO_QUERY );
428*cdf0e10cSrcweir     if( xProp.is() )
429*cdf0e10cSrcweir         aRet = xProp->getPropertyValue( C2U( "DisplayLabels" ));
430*cdf0e10cSrcweir     else
431*cdf0e10cSrcweir         aRet <<= sal_False;
432*cdf0e10cSrcweir     return aRet;
433*cdf0e10cSrcweir }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir Any WrappedAxisLabelExistenceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
436*cdf0e10cSrcweir                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
437*cdf0e10cSrcweir {
438*cdf0e10cSrcweir     Any aRet;
439*cdf0e10cSrcweir     aRet <<= sal_Bool( sal_True );
440*cdf0e10cSrcweir     return aRet;
441*cdf0e10cSrcweir }
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir } //namespace wrapper
444*cdf0e10cSrcweir } //namespace chart
445*cdf0e10cSrcweir //.............................................................................
446