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