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 10cdf0e10cSrcweir * 11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 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 #include "LegendWrapper.hxx" 27cdf0e10cSrcweir #include "macros.hxx" 28cdf0e10cSrcweir #include "Chart2ModelContact.hxx" 29cdf0e10cSrcweir #include "LegendHelper.hxx" 30cdf0e10cSrcweir #include "ContainerHelper.hxx" 31cdf0e10cSrcweir #include <comphelper/InlineContainer.hxx> 32cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 33cdf0e10cSrcweir #include <com/sun/star/chart2/XTitled.hpp> 34cdf0e10cSrcweir #include <com/sun/star/chart/ChartLegendPosition.hpp> 35cdf0e10cSrcweir #include <com/sun/star/chart2/LegendPosition.hpp> 36cdf0e10cSrcweir #include <com/sun/star/chart/ChartLegendExpansion.hpp> 37cdf0e10cSrcweir #include <com/sun/star/chart2/RelativePosition.hpp> 38cdf0e10cSrcweir #include <com/sun/star/drawing/FillStyle.hpp> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include "CharacterProperties.hxx" 41cdf0e10cSrcweir #include "LineProperties.hxx" 42cdf0e10cSrcweir #include "FillProperties.hxx" 43cdf0e10cSrcweir #include "UserDefinedProperties.hxx" 44cdf0e10cSrcweir #include "WrappedCharacterHeightProperty.hxx" 45cdf0e10cSrcweir #include "PositionAndSizeHelper.hxx" 46cdf0e10cSrcweir #include "WrappedDirectStateProperty.hxx" 47cdf0e10cSrcweir #include "WrappedAutomaticPositionProperties.hxx" 48cdf0e10cSrcweir #include "WrappedScaleTextProperties.hxx" 49cdf0e10cSrcweir 50cdf0e10cSrcweir #include <algorithm> 51cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 52cdf0e10cSrcweir 53cdf0e10cSrcweir using namespace ::com::sun::star; 54cdf0e10cSrcweir using ::com::sun::star::beans::Property; 55cdf0e10cSrcweir using ::osl::MutexGuard; 56cdf0e10cSrcweir using ::com::sun::star::uno::Any; 57cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 58cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 59cdf0e10cSrcweir 60cdf0e10cSrcweir //----------------------------------------------------------------------------- 61cdf0e10cSrcweir //----------------------------------------------------------------------------- 62cdf0e10cSrcweir 63cdf0e10cSrcweir namespace chart 64cdf0e10cSrcweir { 65cdf0e10cSrcweir class WrappedLegendAlignmentProperty : public WrappedProperty 66cdf0e10cSrcweir { 67cdf0e10cSrcweir public: 68cdf0e10cSrcweir WrappedLegendAlignmentProperty(); 69cdf0e10cSrcweir virtual ~WrappedLegendAlignmentProperty(); 70cdf0e10cSrcweir 71cdf0e10cSrcweir virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const 72cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException); 73cdf0e10cSrcweir virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const 74cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); 75cdf0e10cSrcweir 76cdf0e10cSrcweir protected: 77cdf0e10cSrcweir virtual Any convertInnerToOuterValue( const Any& rInnerValue ) const; 78cdf0e10cSrcweir virtual Any convertOuterToInnerValue( const Any& rOuterValue ) const; 79cdf0e10cSrcweir }; 80cdf0e10cSrcweir 81cdf0e10cSrcweir WrappedLegendAlignmentProperty::WrappedLegendAlignmentProperty() 82cdf0e10cSrcweir : ::chart::WrappedProperty( C2U( "Alignment" ), C2U( "AnchorPosition" ) ) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir } 85cdf0e10cSrcweir WrappedLegendAlignmentProperty::~WrappedLegendAlignmentProperty() 86cdf0e10cSrcweir { 87cdf0e10cSrcweir } 88cdf0e10cSrcweir 89cdf0e10cSrcweir Any WrappedLegendAlignmentProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const 90cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir Any aRet; 93cdf0e10cSrcweir if( xInnerPropertySet.is() ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir sal_Bool bShowLegend = sal_True; 96cdf0e10cSrcweir xInnerPropertySet->getPropertyValue( C2U( "Show" ) ) >>= bShowLegend; 97cdf0e10cSrcweir if(!bShowLegend) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir aRet = uno::makeAny( ::com::sun::star::chart::ChartLegendPosition_NONE ); 100cdf0e10cSrcweir } 101cdf0e10cSrcweir else 102cdf0e10cSrcweir { 103cdf0e10cSrcweir aRet = xInnerPropertySet->getPropertyValue( m_aInnerName ); 104cdf0e10cSrcweir aRet = this->convertInnerToOuterValue( aRet ); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir } 107cdf0e10cSrcweir return aRet; 108cdf0e10cSrcweir } 109cdf0e10cSrcweir 110cdf0e10cSrcweir void WrappedLegendAlignmentProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const 111cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir if(xInnerPropertySet.is()) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir sal_Bool bNewShowLegend = sal_True; 116cdf0e10cSrcweir sal_Bool bOldShowLegend = sal_True; 117cdf0e10cSrcweir { 118cdf0e10cSrcweir ::com::sun::star::chart::ChartLegendPosition eOuterPos(::com::sun::star::chart::ChartLegendPosition_NONE); 119cdf0e10cSrcweir if( (rOuterValue >>= eOuterPos) && eOuterPos == ::com::sun::star::chart::ChartLegendPosition_NONE ) 120cdf0e10cSrcweir bNewShowLegend = sal_False; 121cdf0e10cSrcweir xInnerPropertySet->getPropertyValue( C2U( "Show" ) ) >>= bOldShowLegend; 122cdf0e10cSrcweir } 123cdf0e10cSrcweir if(bNewShowLegend!=bOldShowLegend) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir xInnerPropertySet->setPropertyValue( C2U( "Show" ), uno::makeAny(bNewShowLegend) ); 126cdf0e10cSrcweir } 127cdf0e10cSrcweir if(!bNewShowLegend) 128cdf0e10cSrcweir return; 129cdf0e10cSrcweir 130cdf0e10cSrcweir //set corresponding LegendPosition 131cdf0e10cSrcweir Any aInnerValue = this->convertOuterToInnerValue( rOuterValue ); 132cdf0e10cSrcweir xInnerPropertySet->setPropertyValue( m_aInnerName, aInnerValue ); 133cdf0e10cSrcweir 134cdf0e10cSrcweir //correct LegendExpansion 135cdf0e10cSrcweir chart2::LegendPosition eNewInnerPos(chart2::LegendPosition_LINE_END); 136cdf0e10cSrcweir if( aInnerValue >>= eNewInnerPos ) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir ::com::sun::star::chart::ChartLegendExpansion eNewExpansion = 139cdf0e10cSrcweir ( eNewInnerPos == chart2::LegendPosition_LINE_END || 140cdf0e10cSrcweir eNewInnerPos == chart2::LegendPosition_LINE_START ) 141cdf0e10cSrcweir ? ::com::sun::star::chart::ChartLegendExpansion_HIGH 142cdf0e10cSrcweir : ::com::sun::star::chart::ChartLegendExpansion_WIDE; 143cdf0e10cSrcweir 144cdf0e10cSrcweir ::com::sun::star::chart::ChartLegendExpansion eOldExpansion( ::com::sun::star::chart::ChartLegendExpansion_HIGH ); 145cdf0e10cSrcweir bool bExpansionWasSet( 146cdf0e10cSrcweir xInnerPropertySet->getPropertyValue( C2U( "Expansion" ) ) >>= eOldExpansion ); 147cdf0e10cSrcweir 148cdf0e10cSrcweir if( !bExpansionWasSet || (eOldExpansion != eNewExpansion)) 149cdf0e10cSrcweir xInnerPropertySet->setPropertyValue( C2U( "Expansion" ), uno::makeAny( eNewExpansion )); 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir //correct RelativePosition 153cdf0e10cSrcweir Any aRelativePosition( xInnerPropertySet->getPropertyValue( C2U( "RelativePosition" ) ) ); 154cdf0e10cSrcweir if(aRelativePosition.hasValue()) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir xInnerPropertySet->setPropertyValue( C2U( "RelativePosition" ), Any() ); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir } 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir Any WrappedLegendAlignmentProperty::convertInnerToOuterValue( const Any& rInnerValue ) const 162cdf0e10cSrcweir { 163cdf0e10cSrcweir ::com::sun::star::chart::ChartLegendPosition ePos = ::com::sun::star::chart::ChartLegendPosition_NONE; 164cdf0e10cSrcweir 165cdf0e10cSrcweir chart2::LegendPosition eNewPos; 166cdf0e10cSrcweir if( rInnerValue >>= eNewPos ) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir switch( eNewPos ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir case chart2::LegendPosition_LINE_START: 171cdf0e10cSrcweir ePos = ::com::sun::star::chart::ChartLegendPosition_LEFT; 172cdf0e10cSrcweir break; 173cdf0e10cSrcweir case chart2::LegendPosition_LINE_END: 174cdf0e10cSrcweir ePos = ::com::sun::star::chart::ChartLegendPosition_RIGHT; 175cdf0e10cSrcweir break; 176cdf0e10cSrcweir case chart2::LegendPosition_PAGE_START: 177cdf0e10cSrcweir ePos = ::com::sun::star::chart::ChartLegendPosition_TOP; 178cdf0e10cSrcweir break; 179cdf0e10cSrcweir case chart2::LegendPosition_PAGE_END: 180cdf0e10cSrcweir ePos = ::com::sun::star::chart::ChartLegendPosition_BOTTOM; 181cdf0e10cSrcweir break; 182cdf0e10cSrcweir 183cdf0e10cSrcweir default: 184cdf0e10cSrcweir ePos = ::com::sun::star::chart::ChartLegendPosition_NONE; 185cdf0e10cSrcweir break; 186cdf0e10cSrcweir } 187cdf0e10cSrcweir } 188cdf0e10cSrcweir return uno::makeAny( ePos ); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir Any WrappedLegendAlignmentProperty::convertOuterToInnerValue( const Any& rOuterValue ) const 191cdf0e10cSrcweir { 192cdf0e10cSrcweir chart2::LegendPosition eNewPos = chart2::LegendPosition_LINE_END; 193cdf0e10cSrcweir 194cdf0e10cSrcweir ::com::sun::star::chart::ChartLegendPosition ePos; 195cdf0e10cSrcweir if( rOuterValue >>= ePos ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir switch( ePos ) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir case ::com::sun::star::chart::ChartLegendPosition_LEFT: 200cdf0e10cSrcweir eNewPos = chart2::LegendPosition_LINE_START; 201cdf0e10cSrcweir break; 202cdf0e10cSrcweir case ::com::sun::star::chart::ChartLegendPosition_RIGHT: 203cdf0e10cSrcweir eNewPos = chart2::LegendPosition_LINE_END; 204cdf0e10cSrcweir break; 205cdf0e10cSrcweir case ::com::sun::star::chart::ChartLegendPosition_TOP: 206cdf0e10cSrcweir eNewPos = chart2::LegendPosition_PAGE_START; 207cdf0e10cSrcweir break; 208cdf0e10cSrcweir case ::com::sun::star::chart::ChartLegendPosition_BOTTOM: 209cdf0e10cSrcweir eNewPos = chart2::LegendPosition_PAGE_END; 210cdf0e10cSrcweir break; 211cdf0e10cSrcweir default: // NONE 212cdf0e10cSrcweir break; 213cdf0e10cSrcweir } 214cdf0e10cSrcweir } 215cdf0e10cSrcweir 216cdf0e10cSrcweir return uno::makeAny( eNewPos ); 217cdf0e10cSrcweir } 218cdf0e10cSrcweir } 219cdf0e10cSrcweir //----------------------------------------------------------------------------- 220cdf0e10cSrcweir //----------------------------------------------------------------------------- 221cdf0e10cSrcweir //----------------------------------------------------------------------------- 222cdf0e10cSrcweir //----------------------------------------------------------------------------- 223cdf0e10cSrcweir 224cdf0e10cSrcweir namespace 225cdf0e10cSrcweir { 226cdf0e10cSrcweir static const ::rtl::OUString lcl_aServiceName( 227cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Legend" )); 228cdf0e10cSrcweir 229cdf0e10cSrcweir enum 230cdf0e10cSrcweir { 231cdf0e10cSrcweir PROP_LEGEND_ALIGNMENT, 232cdf0e10cSrcweir PROP_LEGEND_EXPANSION 233cdf0e10cSrcweir }; 234cdf0e10cSrcweir 235cdf0e10cSrcweir void lcl_AddPropertiesToVector( 236cdf0e10cSrcweir ::std::vector< Property > & rOutProperties ) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir rOutProperties.push_back( 239cdf0e10cSrcweir Property( C2U( "Alignment" ), 240cdf0e10cSrcweir PROP_LEGEND_ALIGNMENT, 241cdf0e10cSrcweir ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartLegendPosition * >(0)), 242cdf0e10cSrcweir //#i111967# no PropertyChangeEvent is fired on change so far 243cdf0e10cSrcweir beans::PropertyAttribute::MAYBEDEFAULT )); 244cdf0e10cSrcweir 245cdf0e10cSrcweir rOutProperties.push_back( 246cdf0e10cSrcweir Property( C2U( "Expansion" ), 247cdf0e10cSrcweir PROP_LEGEND_EXPANSION, 248cdf0e10cSrcweir ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartLegendExpansion * >(0)), 249cdf0e10cSrcweir //#i111967# no PropertyChangeEvent is fired on change so far 250cdf0e10cSrcweir beans::PropertyAttribute::MAYBEDEFAULT )); 251cdf0e10cSrcweir } 252cdf0e10cSrcweir 253cdf0e10cSrcweir struct StaticLegendWrapperPropertyArray_Initializer 254cdf0e10cSrcweir { 255cdf0e10cSrcweir Sequence< Property >* operator()() 256cdf0e10cSrcweir { 257cdf0e10cSrcweir static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); 258cdf0e10cSrcweir return &aPropSeq; 259cdf0e10cSrcweir } 260cdf0e10cSrcweir 261cdf0e10cSrcweir private: 262cdf0e10cSrcweir Sequence< Property > lcl_GetPropertySequence() 263cdf0e10cSrcweir { 264cdf0e10cSrcweir ::std::vector< ::com::sun::star::beans::Property > aProperties; 265cdf0e10cSrcweir lcl_AddPropertiesToVector( aProperties ); 266cdf0e10cSrcweir ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); 267cdf0e10cSrcweir ::chart::LineProperties::AddPropertiesToVector( aProperties ); 268cdf0e10cSrcweir ::chart::FillProperties::AddPropertiesToVector( aProperties ); 269cdf0e10cSrcweir //::chart::NamedProperties::AddPropertiesToVector( aProperties ); 270cdf0e10cSrcweir ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); 271cdf0e10cSrcweir ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); 272cdf0e10cSrcweir ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); 273cdf0e10cSrcweir 274cdf0e10cSrcweir ::std::sort( aProperties.begin(), aProperties.end(), 275cdf0e10cSrcweir ::chart::PropertyNameLess() ); 276cdf0e10cSrcweir 277cdf0e10cSrcweir return ::chart::ContainerHelper::ContainerToSequence( aProperties ); 278cdf0e10cSrcweir } 279cdf0e10cSrcweir }; 280cdf0e10cSrcweir 281cdf0e10cSrcweir struct StaticLegendWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticLegendWrapperPropertyArray_Initializer > 282cdf0e10cSrcweir { 283cdf0e10cSrcweir }; 284cdf0e10cSrcweir 285cdf0e10cSrcweir } // anonymous namespace 286cdf0e10cSrcweir 287cdf0e10cSrcweir // -------------------------------------------------------------------------------- 288cdf0e10cSrcweir // -------------------------------------------------------------------------------- 289cdf0e10cSrcweir 290cdf0e10cSrcweir namespace chart 291cdf0e10cSrcweir { 292cdf0e10cSrcweir namespace wrapper 293cdf0e10cSrcweir { 294cdf0e10cSrcweir 295cdf0e10cSrcweir LegendWrapper::LegendWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : 296cdf0e10cSrcweir m_spChart2ModelContact( spChart2ModelContact ), 297cdf0e10cSrcweir m_aEventListenerContainer( m_aMutex ) 298cdf0e10cSrcweir { 299cdf0e10cSrcweir } 300cdf0e10cSrcweir 301cdf0e10cSrcweir LegendWrapper::~LegendWrapper() 302cdf0e10cSrcweir { 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir // ____ XShape ____ 306cdf0e10cSrcweir awt::Point SAL_CALL LegendWrapper::getPosition() 307cdf0e10cSrcweir throw (uno::RuntimeException) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir return m_spChart2ModelContact->GetLegendPosition(); 310cdf0e10cSrcweir } 311cdf0e10cSrcweir 312cdf0e10cSrcweir void SAL_CALL LegendWrapper::setPosition( const awt::Point& aPosition ) 313cdf0e10cSrcweir throw (uno::RuntimeException) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); 316cdf0e10cSrcweir if( xProp.is() ) 317cdf0e10cSrcweir { 318cdf0e10cSrcweir awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); 319cdf0e10cSrcweir 320cdf0e10cSrcweir chart2::RelativePosition aRelativePosition; 321cdf0e10cSrcweir aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; 322cdf0e10cSrcweir aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); 323cdf0e10cSrcweir aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); 324cdf0e10cSrcweir xProp->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) ); 325cdf0e10cSrcweir } 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir awt::Size SAL_CALL LegendWrapper::getSize() 329cdf0e10cSrcweir throw (uno::RuntimeException) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir return m_spChart2ModelContact->GetLegendSize(); 332cdf0e10cSrcweir } 333cdf0e10cSrcweir 334cdf0e10cSrcweir void SAL_CALL LegendWrapper::setSize( const awt::Size& aSize ) 335cdf0e10cSrcweir throw (beans::PropertyVetoException, 336cdf0e10cSrcweir uno::RuntimeException) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); 339cdf0e10cSrcweir if( xProp.is() ) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); 342cdf0e10cSrcweir awt::Rectangle aPageRectangle( 0,0,aPageSize.Width,aPageSize.Height); 343cdf0e10cSrcweir 344cdf0e10cSrcweir awt::Point aPos( this->getPosition() ); 345cdf0e10cSrcweir awt::Rectangle aNewPositionAndSize(aPos.X,aPos.Y,aSize.Width,aSize.Height); 346cdf0e10cSrcweir 347cdf0e10cSrcweir PositionAndSizeHelper::moveObject( OBJECTTYPE_LEGEND 348cdf0e10cSrcweir , xProp, aNewPositionAndSize, aPageRectangle ); 349cdf0e10cSrcweir } 350cdf0e10cSrcweir } 351cdf0e10cSrcweir 352cdf0e10cSrcweir // ____ XShapeDescriptor (base of XShape) ____ 353cdf0e10cSrcweir ::rtl::OUString SAL_CALL LegendWrapper::getShapeType() 354cdf0e10cSrcweir throw (uno::RuntimeException) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir return C2U( "com.sun.star.chart.ChartLegend" ); 357cdf0e10cSrcweir } 358cdf0e10cSrcweir 359cdf0e10cSrcweir // ____ XComponent ____ 360cdf0e10cSrcweir void SAL_CALL LegendWrapper::dispose() 361cdf0e10cSrcweir throw (uno::RuntimeException) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); 364cdf0e10cSrcweir m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); 365cdf0e10cSrcweir 366cdf0e10cSrcweir // /-- 367cdf0e10cSrcweir MutexGuard aGuard( GetMutex()); 368cdf0e10cSrcweir clearWrappedPropertySet(); 369cdf0e10cSrcweir // \-- 370cdf0e10cSrcweir } 371cdf0e10cSrcweir 372cdf0e10cSrcweir void SAL_CALL LegendWrapper::addEventListener( 373cdf0e10cSrcweir const Reference< lang::XEventListener >& xListener ) 374cdf0e10cSrcweir throw (uno::RuntimeException) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir m_aEventListenerContainer.addInterface( xListener ); 377cdf0e10cSrcweir } 378cdf0e10cSrcweir 379cdf0e10cSrcweir void SAL_CALL LegendWrapper::removeEventListener( 380cdf0e10cSrcweir const Reference< lang::XEventListener >& aListener ) 381cdf0e10cSrcweir throw (uno::RuntimeException) 382cdf0e10cSrcweir { 383cdf0e10cSrcweir m_aEventListenerContainer.removeInterface( aListener ); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir 386cdf0e10cSrcweir // ================================================================================ 387cdf0e10cSrcweir 388cdf0e10cSrcweir //ReferenceSizePropertyProvider 389cdf0e10cSrcweir void LegendWrapper::updateReferenceSize() 390cdf0e10cSrcweir { 391cdf0e10cSrcweir Reference< beans::XPropertySet > xProp( this->getInnerPropertySet(), uno::UNO_QUERY ); 392cdf0e10cSrcweir if( xProp.is() ) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir if( xProp->getPropertyValue( C2U("ReferencePageSize") ).hasValue() ) 395cdf0e10cSrcweir xProp->setPropertyValue( C2U("ReferencePageSize"), uno::makeAny( 396cdf0e10cSrcweir m_spChart2ModelContact->GetPageSize() )); 397cdf0e10cSrcweir } 398cdf0e10cSrcweir } 399cdf0e10cSrcweir Any LegendWrapper::getReferenceSize() 400cdf0e10cSrcweir { 401cdf0e10cSrcweir Any aRet; 402cdf0e10cSrcweir Reference< beans::XPropertySet > xProp( this->getInnerPropertySet(), uno::UNO_QUERY ); 403cdf0e10cSrcweir if( xProp.is() ) 404cdf0e10cSrcweir aRet = xProp->getPropertyValue( C2U("ReferencePageSize") ); 405cdf0e10cSrcweir 406cdf0e10cSrcweir return aRet; 407cdf0e10cSrcweir } 408cdf0e10cSrcweir awt::Size LegendWrapper::getCurrentSizeForReference() 409cdf0e10cSrcweir { 410cdf0e10cSrcweir return m_spChart2ModelContact->GetPageSize(); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir // ================================================================================ 414cdf0e10cSrcweir 415cdf0e10cSrcweir // WrappedPropertySet 416cdf0e10cSrcweir Reference< beans::XPropertySet > LegendWrapper::getInnerPropertySet() 417cdf0e10cSrcweir { 418cdf0e10cSrcweir Reference< beans::XPropertySet > xRet; 419cdf0e10cSrcweir Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); 420cdf0e10cSrcweir if( xDiagram.is() ) 421cdf0e10cSrcweir xRet.set( xDiagram->getLegend(), uno::UNO_QUERY ); 422cdf0e10cSrcweir OSL_ENSURE(xRet.is(),"LegendWrapper::getInnerPropertySet() is NULL"); 423cdf0e10cSrcweir return xRet; 424cdf0e10cSrcweir } 425cdf0e10cSrcweir 426cdf0e10cSrcweir const Sequence< beans::Property >& LegendWrapper::getPropertySequence() 427cdf0e10cSrcweir { 428cdf0e10cSrcweir return *StaticLegendWrapperPropertyArray::get(); 429cdf0e10cSrcweir } 430cdf0e10cSrcweir 431cdf0e10cSrcweir const std::vector< WrappedProperty* > LegendWrapper::createWrappedProperties() 432cdf0e10cSrcweir { 433cdf0e10cSrcweir ::std::vector< ::chart::WrappedProperty* > aWrappedProperties; 434cdf0e10cSrcweir 435cdf0e10cSrcweir aWrappedProperties.push_back( new WrappedLegendAlignmentProperty() ); 436cdf0e10cSrcweir aWrappedProperties.push_back( new WrappedProperty( C2U("Expansion"), C2U("Expansion") )); 437cdf0e10cSrcweir WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this ); 438cdf0e10cSrcweir //same problem as for wall: thje defaults ion the old chart are different for different charttypes, so we need to export explicitly 439cdf0e10cSrcweir aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("FillStyle"), C2U("FillStyle") ) ); 440cdf0e10cSrcweir aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("FillColor"), C2U("FillColor") )); 441cdf0e10cSrcweir WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties ); 442cdf0e10cSrcweir WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); 443cdf0e10cSrcweir 444cdf0e10cSrcweir return aWrappedProperties; 445cdf0e10cSrcweir } 446cdf0e10cSrcweir 447cdf0e10cSrcweir // ================================================================================ 448cdf0e10cSrcweir 449cdf0e10cSrcweir Sequence< ::rtl::OUString > LegendWrapper::getSupportedServiceNames_Static() 450cdf0e10cSrcweir { 451cdf0e10cSrcweir Sequence< ::rtl::OUString > aServices( 4 ); 452cdf0e10cSrcweir aServices[ 0 ] = C2U( "com.sun.star.chart.ChartLegend" ); 453cdf0e10cSrcweir aServices[ 1 ] = C2U( "com.sun.star.drawing.Shape" ); 454cdf0e10cSrcweir aServices[ 2 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); 455cdf0e10cSrcweir aServices[ 3 ] = C2U( "com.sun.star.style.CharacterProperties" ); 456cdf0e10cSrcweir // aServices[ 4 ] = C2U( "com.sun.star.beans.PropertySet" ); 457cdf0e10cSrcweir // aServices[ 5 ] = C2U( "com.sun.star.drawing.FillProperties" ); 458cdf0e10cSrcweir // aServices[ 6 ] = C2U( "com.sun.star.drawing.LineProperties" ); 459cdf0e10cSrcweir 460cdf0e10cSrcweir return aServices; 461cdf0e10cSrcweir } 462cdf0e10cSrcweir 463cdf0e10cSrcweir // implement XServiceInfo methods basing upon getSupportedServiceNames_Static 464cdf0e10cSrcweir APPHELPER_XSERVICEINFO_IMPL( LegendWrapper, lcl_aServiceName ); 465cdf0e10cSrcweir 466cdf0e10cSrcweir } // namespace wrapper 467cdf0e10cSrcweir } // namespace chart 468