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 "TitleWrapper.hxx" 27cdf0e10cSrcweir #include "macros.hxx" 28cdf0e10cSrcweir #include "ContainerHelper.hxx" 29cdf0e10cSrcweir #include "ControllerLockGuard.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <comphelper/InlineContainer.hxx> 32cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 33cdf0e10cSrcweir #include <com/sun/star/chart2/RelativePosition.hpp> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include "CharacterProperties.hxx" 36cdf0e10cSrcweir #include "LineProperties.hxx" 37cdf0e10cSrcweir #include "FillProperties.hxx" 38cdf0e10cSrcweir #include "UserDefinedProperties.hxx" 39cdf0e10cSrcweir #include "WrappedCharacterHeightProperty.hxx" 40cdf0e10cSrcweir #include "WrappedTextRotationProperty.hxx" 41cdf0e10cSrcweir #include "WrappedAutomaticPositionProperties.hxx" 42cdf0e10cSrcweir #include "WrappedScaleTextProperties.hxx" 43cdf0e10cSrcweir 44cdf0e10cSrcweir #include <algorithm> 45cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 46cdf0e10cSrcweir 47cdf0e10cSrcweir using namespace ::com::sun::star; 48cdf0e10cSrcweir using ::com::sun::star::beans::Property; 49cdf0e10cSrcweir using ::osl::MutexGuard; 50cdf0e10cSrcweir using ::rtl::OUString; 51cdf0e10cSrcweir using ::com::sun::star::uno::Any; 52cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 53cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 54cdf0e10cSrcweir 55cdf0e10cSrcweir 56cdf0e10cSrcweir namespace chart 57cdf0e10cSrcweir { 58cdf0e10cSrcweir class WrappedTitleStringProperty : public WrappedProperty 59cdf0e10cSrcweir { 60cdf0e10cSrcweir public: 61cdf0e10cSrcweir WrappedTitleStringProperty( const Reference< uno::XComponentContext >& xContext ); 62cdf0e10cSrcweir virtual ~WrappedTitleStringProperty(); 63cdf0e10cSrcweir 64cdf0e10cSrcweir virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const 65cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException); 66cdf0e10cSrcweir virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const 67cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); 68cdf0e10cSrcweir virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const 69cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); 70cdf0e10cSrcweir 71cdf0e10cSrcweir protected: 72cdf0e10cSrcweir Reference< uno::XComponentContext > m_xContext; 73cdf0e10cSrcweir }; 74cdf0e10cSrcweir 75cdf0e10cSrcweir WrappedTitleStringProperty::WrappedTitleStringProperty( const Reference< uno::XComponentContext >& xContext ) 76cdf0e10cSrcweir : ::chart::WrappedProperty( C2U( "String" ), OUString() ) 77cdf0e10cSrcweir , m_xContext( xContext ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir } 80cdf0e10cSrcweir WrappedTitleStringProperty::~WrappedTitleStringProperty() 81cdf0e10cSrcweir { 82cdf0e10cSrcweir } 83cdf0e10cSrcweir 84cdf0e10cSrcweir void WrappedTitleStringProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const 85cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir Reference< chart2::XTitle > xTitle(xInnerPropertySet,uno::UNO_QUERY); 88cdf0e10cSrcweir if(xTitle.is()) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir OUString aString; 91cdf0e10cSrcweir rOuterValue >>= aString; 92cdf0e10cSrcweir TitleHelper::setCompleteString( aString, xTitle, m_xContext ); 93cdf0e10cSrcweir } 94cdf0e10cSrcweir } 95cdf0e10cSrcweir Any WrappedTitleStringProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const 96cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) ); 99cdf0e10cSrcweir Reference< chart2::XTitle > xTitle(xInnerPropertySet,uno::UNO_QUERY); 100cdf0e10cSrcweir if(xTitle.is()) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); 103cdf0e10cSrcweir 104cdf0e10cSrcweir ::rtl::OUStringBuffer aBuf; 105cdf0e10cSrcweir for( sal_Int32 i = 0; i < aStrings.getLength(); ++i ) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir aBuf.append( aStrings[ i ]->getString()); 108cdf0e10cSrcweir } 109cdf0e10cSrcweir aRet <<= aBuf.makeStringAndClear(); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir return aRet; 112cdf0e10cSrcweir } 113cdf0e10cSrcweir Any WrappedTitleStringProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const 114cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir return uno::makeAny( rtl::OUString() );//default title is a empty String 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir //----------------------------------------------------------------------------- 120cdf0e10cSrcweir //----------------------------------------------------------------------------- 121cdf0e10cSrcweir 122cdf0e10cSrcweir class WrappedStackedTextProperty : public WrappedProperty 123cdf0e10cSrcweir { 124cdf0e10cSrcweir public: 125cdf0e10cSrcweir WrappedStackedTextProperty(); 126cdf0e10cSrcweir virtual ~WrappedStackedTextProperty(); 127cdf0e10cSrcweir }; 128cdf0e10cSrcweir 129cdf0e10cSrcweir WrappedStackedTextProperty::WrappedStackedTextProperty() 130cdf0e10cSrcweir : ::chart::WrappedProperty( C2U( "StackedText" ), C2U( "StackCharacters" ) ) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir } 133cdf0e10cSrcweir WrappedStackedTextProperty::~WrappedStackedTextProperty() 134cdf0e10cSrcweir { 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir }// end namespace chart 138cdf0e10cSrcweir 139cdf0e10cSrcweir 140cdf0e10cSrcweir //----------------------------------------------------------------------------- 141cdf0e10cSrcweir //----------------------------------------------------------------------------- 142cdf0e10cSrcweir //----------------------------------------------------------------------------- 143cdf0e10cSrcweir //----------------------------------------------------------------------------- 144cdf0e10cSrcweir 145cdf0e10cSrcweir namespace 146cdf0e10cSrcweir { 147cdf0e10cSrcweir static const OUString lcl_aServiceName( 148cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Title" )); 149cdf0e10cSrcweir 150cdf0e10cSrcweir enum 151cdf0e10cSrcweir { 152cdf0e10cSrcweir PROP_TITLE_STRING, 153cdf0e10cSrcweir PROP_TITLE_TEXT_ROTATION, 154cdf0e10cSrcweir PROP_TITLE_TEXT_STACKED 155cdf0e10cSrcweir }; 156cdf0e10cSrcweir 157cdf0e10cSrcweir void lcl_AddPropertiesToVector( 158cdf0e10cSrcweir ::std::vector< Property > & rOutProperties ) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir rOutProperties.push_back( 161cdf0e10cSrcweir Property( C2U( "String" ), 162cdf0e10cSrcweir PROP_TITLE_STRING, 163cdf0e10cSrcweir ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)), 164cdf0e10cSrcweir beans::PropertyAttribute::BOUND 165cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEVOID )); 166cdf0e10cSrcweir 167cdf0e10cSrcweir rOutProperties.push_back( 168cdf0e10cSrcweir Property( C2U( "TextRotation" ), 169cdf0e10cSrcweir PROP_TITLE_TEXT_ROTATION, 170cdf0e10cSrcweir ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 171cdf0e10cSrcweir beans::PropertyAttribute::BOUND 172cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT )); 173cdf0e10cSrcweir rOutProperties.push_back( 174cdf0e10cSrcweir Property( C2U( "StackedText" ), 175cdf0e10cSrcweir PROP_TITLE_TEXT_STACKED, 176cdf0e10cSrcweir ::getBooleanCppuType(), 177cdf0e10cSrcweir beans::PropertyAttribute::BOUND 178cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT )); 179cdf0e10cSrcweir } 180cdf0e10cSrcweir 181cdf0e10cSrcweir struct StaticTitleWrapperPropertyArray_Initializer 182cdf0e10cSrcweir { 183cdf0e10cSrcweir Sequence< Property >* operator()() 184cdf0e10cSrcweir { 185cdf0e10cSrcweir static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); 186cdf0e10cSrcweir return &aPropSeq; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir private: 190cdf0e10cSrcweir Sequence< Property > lcl_GetPropertySequence() 191cdf0e10cSrcweir { 192cdf0e10cSrcweir ::std::vector< beans::Property > aProperties; 193cdf0e10cSrcweir lcl_AddPropertiesToVector( aProperties ); 194cdf0e10cSrcweir ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); 195cdf0e10cSrcweir ::chart::LineProperties::AddPropertiesToVector( aProperties ); 196cdf0e10cSrcweir ::chart::FillProperties::AddPropertiesToVector( aProperties ); 197cdf0e10cSrcweir //::chart::NamedProperties::AddPropertiesToVector( aProperties ); 198cdf0e10cSrcweir ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); 199cdf0e10cSrcweir ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); 200cdf0e10cSrcweir ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); 201cdf0e10cSrcweir 202cdf0e10cSrcweir ::std::sort( aProperties.begin(), aProperties.end(), 203cdf0e10cSrcweir ::chart::PropertyNameLess() ); 204cdf0e10cSrcweir 205cdf0e10cSrcweir return ::chart::ContainerHelper::ContainerToSequence( aProperties ); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir }; 208cdf0e10cSrcweir 209cdf0e10cSrcweir struct StaticTitleWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticTitleWrapperPropertyArray_Initializer > 210cdf0e10cSrcweir { 211cdf0e10cSrcweir }; 212cdf0e10cSrcweir 213cdf0e10cSrcweir } // anonymous namespace 214cdf0e10cSrcweir 215cdf0e10cSrcweir // -------------------------------------------------------------------------------- 216cdf0e10cSrcweir 217cdf0e10cSrcweir namespace chart 218cdf0e10cSrcweir { 219cdf0e10cSrcweir namespace wrapper 220cdf0e10cSrcweir { 221cdf0e10cSrcweir 222cdf0e10cSrcweir TitleWrapper::TitleWrapper( ::chart::TitleHelper::eTitleType eTitleType, 223cdf0e10cSrcweir ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : 224cdf0e10cSrcweir m_spChart2ModelContact( spChart2ModelContact ), 225cdf0e10cSrcweir m_aEventListenerContainer( m_aMutex ), 226cdf0e10cSrcweir m_eTitleType(eTitleType) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY )); 229cdf0e10cSrcweir if( !getTitleObject().is() ) //#i83831# create an empty title at the model, thus references to properties can be mapped mapped correctly 230cdf0e10cSrcweir TitleHelper::createTitle( m_eTitleType, OUString(), m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext ); 231cdf0e10cSrcweir } 232cdf0e10cSrcweir 233cdf0e10cSrcweir TitleWrapper::~TitleWrapper() 234cdf0e10cSrcweir { 235cdf0e10cSrcweir } 236cdf0e10cSrcweir 237cdf0e10cSrcweir // ____ XShape ____ 238cdf0e10cSrcweir awt::Point SAL_CALL TitleWrapper::getPosition() 239cdf0e10cSrcweir throw (uno::RuntimeException) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir return m_spChart2ModelContact->GetTitlePosition( this->getTitleObject() ); 242cdf0e10cSrcweir } 243cdf0e10cSrcweir 244cdf0e10cSrcweir void SAL_CALL TitleWrapper::setPosition( const awt::Point& aPosition ) 245cdf0e10cSrcweir throw (uno::RuntimeException) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir Reference< beans::XPropertySet > xPropertySet( this->getInnerPropertySet() ); 248cdf0e10cSrcweir if(xPropertySet.is()) 249cdf0e10cSrcweir { 250cdf0e10cSrcweir awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); 251cdf0e10cSrcweir 252cdf0e10cSrcweir chart2::RelativePosition aRelativePosition; 253cdf0e10cSrcweir aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; 254cdf0e10cSrcweir aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); 255cdf0e10cSrcweir aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); 256cdf0e10cSrcweir xPropertySet->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) ); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir awt::Size SAL_CALL TitleWrapper::getSize() 261cdf0e10cSrcweir throw (uno::RuntimeException) 262cdf0e10cSrcweir { 263cdf0e10cSrcweir return m_spChart2ModelContact->GetTitleSize( this->getTitleObject() ); 264cdf0e10cSrcweir } 265cdf0e10cSrcweir 266cdf0e10cSrcweir void SAL_CALL TitleWrapper::setSize( const awt::Size& /*aSize*/ ) 267cdf0e10cSrcweir throw (beans::PropertyVetoException, 268cdf0e10cSrcweir uno::RuntimeException) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir OSL_ENSURE( false, "trying to set size of title" ); 271cdf0e10cSrcweir } 272cdf0e10cSrcweir 273cdf0e10cSrcweir // ____ XShapeDescriptor (base of XShape) ____ 274cdf0e10cSrcweir OUString SAL_CALL TitleWrapper::getShapeType() 275cdf0e10cSrcweir throw (uno::RuntimeException) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir return C2U( "com.sun.star.chart.ChartTitle" ); 278cdf0e10cSrcweir } 279cdf0e10cSrcweir 280cdf0e10cSrcweir // ____ XComponent ____ 281cdf0e10cSrcweir void SAL_CALL TitleWrapper::dispose() 282cdf0e10cSrcweir throw (uno::RuntimeException) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); 285cdf0e10cSrcweir m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); 286cdf0e10cSrcweir 287cdf0e10cSrcweir // /-- 288cdf0e10cSrcweir MutexGuard aGuard( GetMutex()); 289cdf0e10cSrcweir clearWrappedPropertySet(); 290cdf0e10cSrcweir // \-- 291cdf0e10cSrcweir } 292cdf0e10cSrcweir 293cdf0e10cSrcweir void SAL_CALL TitleWrapper::addEventListener( 294cdf0e10cSrcweir const Reference< lang::XEventListener >& xListener ) 295cdf0e10cSrcweir throw (uno::RuntimeException) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir m_aEventListenerContainer.addInterface( xListener ); 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir void SAL_CALL TitleWrapper::removeEventListener( 301cdf0e10cSrcweir const Reference< lang::XEventListener >& aListener ) 302cdf0e10cSrcweir throw (uno::RuntimeException) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir m_aEventListenerContainer.removeInterface( aListener ); 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir // ================================================================================ 308cdf0e10cSrcweir 309cdf0e10cSrcweir Reference< beans::XPropertySet > TitleWrapper::getFirstCharacterPropertySet() 310cdf0e10cSrcweir { 311cdf0e10cSrcweir Reference< beans::XPropertySet > xProp; 312cdf0e10cSrcweir 313cdf0e10cSrcweir Reference< chart2::XTitle > xTitle( this->getTitleObject() ); 314cdf0e10cSrcweir if( xTitle.is()) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); 317cdf0e10cSrcweir if( aStrings.getLength() > 0 ) 318cdf0e10cSrcweir xProp.set( aStrings[0], uno::UNO_QUERY ); 319cdf0e10cSrcweir } 320cdf0e10cSrcweir 321cdf0e10cSrcweir return xProp; 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir void TitleWrapper::getFastCharacterPropertyValue( sal_Int32 nHandle, Any& rValue ) 325cdf0e10cSrcweir { 326cdf0e10cSrcweir OSL_ASSERT( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle && 327cdf0e10cSrcweir nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP ); 328cdf0e10cSrcweir 329cdf0e10cSrcweir Reference< beans::XPropertySet > xProp( getFirstCharacterPropertySet(), uno::UNO_QUERY ); 330cdf0e10cSrcweir Reference< beans::XFastPropertySet > xFastProp( xProp, uno::UNO_QUERY ); 331cdf0e10cSrcweir if(xProp.is()) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle ); 334cdf0e10cSrcweir if( pWrappedProperty ) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir rValue = pWrappedProperty->getPropertyValue( xProp ); 337cdf0e10cSrcweir } 338cdf0e10cSrcweir else if( xFastProp.is() ) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir rValue = xFastProp->getFastPropertyValue( nHandle ); 341cdf0e10cSrcweir } 342cdf0e10cSrcweir } 343cdf0e10cSrcweir 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir void TitleWrapper::setFastCharacterPropertyValue( 347cdf0e10cSrcweir sal_Int32 nHandle, const Any& rValue ) throw (uno::Exception) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir OSL_ASSERT( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle && 350cdf0e10cSrcweir nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP ); 351cdf0e10cSrcweir 352cdf0e10cSrcweir Reference< chart2::XTitle > xTitle( this->getTitleObject() ); 353cdf0e10cSrcweir if( xTitle.is()) 354cdf0e10cSrcweir { 355cdf0e10cSrcweir Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); 356cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle ); 357cdf0e10cSrcweir 358cdf0e10cSrcweir for( sal_Int32 i = 0; i < aStrings.getLength(); ++i ) 359cdf0e10cSrcweir { 360cdf0e10cSrcweir Reference< beans::XFastPropertySet > xFastPropertySet( aStrings[ i ], uno::UNO_QUERY ); 361cdf0e10cSrcweir Reference< beans::XPropertySet > xPropSet( xFastPropertySet, uno::UNO_QUERY ); 362cdf0e10cSrcweir 363cdf0e10cSrcweir if( pWrappedProperty ) 364cdf0e10cSrcweir pWrappedProperty->setPropertyValue( rValue, xPropSet ); 365cdf0e10cSrcweir else if( xFastPropertySet.is() ) 366cdf0e10cSrcweir xFastPropertySet->setFastPropertyValue( nHandle, rValue ); 367cdf0e10cSrcweir } 368cdf0e10cSrcweir } 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir // ================================================================================ 372cdf0e10cSrcweir // WrappedPropertySet 373cdf0e10cSrcweir 374cdf0e10cSrcweir void SAL_CALL TitleWrapper::setPropertyValue( const OUString& rPropertyName, const Any& rValue ) 375cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 376cdf0e10cSrcweir { 377cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); 378cdf0e10cSrcweir if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir setFastCharacterPropertyValue( nHandle, rValue ); 381cdf0e10cSrcweir } 382cdf0e10cSrcweir else 383cdf0e10cSrcweir WrappedPropertySet::setPropertyValue( rPropertyName, rValue ); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir 386cdf0e10cSrcweir Any SAL_CALL TitleWrapper::getPropertyValue( const OUString& rPropertyName ) 387cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir Any aRet; 390cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); 391cdf0e10cSrcweir if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) 392cdf0e10cSrcweir getFastCharacterPropertyValue( nHandle, aRet ); 393cdf0e10cSrcweir else 394cdf0e10cSrcweir aRet = WrappedPropertySet::getPropertyValue( rPropertyName ); 395cdf0e10cSrcweir return aRet; 396cdf0e10cSrcweir } 397cdf0e10cSrcweir 398cdf0e10cSrcweir beans::PropertyState SAL_CALL TitleWrapper::getPropertyState( const OUString& rPropertyName ) 399cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE ); 402cdf0e10cSrcweir 403cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); 404cdf0e10cSrcweir if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) 405cdf0e10cSrcweir { 406cdf0e10cSrcweir Reference< beans::XPropertyState > xPropState( getFirstCharacterPropertySet(), uno::UNO_QUERY ); 407cdf0e10cSrcweir if( xPropState.is() ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); 410cdf0e10cSrcweir if( pWrappedProperty ) 411cdf0e10cSrcweir aState = pWrappedProperty->getPropertyState( xPropState ); 412cdf0e10cSrcweir else 413cdf0e10cSrcweir aState = xPropState->getPropertyState( rPropertyName ); 414cdf0e10cSrcweir } 415cdf0e10cSrcweir } 416cdf0e10cSrcweir else 417cdf0e10cSrcweir aState = WrappedPropertySet::getPropertyState( rPropertyName ); 418cdf0e10cSrcweir 419cdf0e10cSrcweir return aState; 420cdf0e10cSrcweir } 421cdf0e10cSrcweir void SAL_CALL TitleWrapper::setPropertyToDefault( const OUString& rPropertyName ) 422cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); 425cdf0e10cSrcweir if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir Any aDefault = getPropertyDefault( rPropertyName ); 428cdf0e10cSrcweir setFastCharacterPropertyValue( nHandle, aDefault ); 429cdf0e10cSrcweir } 430cdf0e10cSrcweir else 431cdf0e10cSrcweir WrappedPropertySet::setPropertyToDefault( rPropertyName ); 432cdf0e10cSrcweir } 433cdf0e10cSrcweir Any SAL_CALL TitleWrapper::getPropertyDefault( const OUString& rPropertyName ) 434cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 435cdf0e10cSrcweir { 436cdf0e10cSrcweir Any aRet; 437cdf0e10cSrcweir 438cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); 439cdf0e10cSrcweir if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir Reference< beans::XPropertyState > xPropState( getFirstCharacterPropertySet(), uno::UNO_QUERY ); 442cdf0e10cSrcweir if( xPropState.is() ) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); 445cdf0e10cSrcweir if( pWrappedProperty ) 446cdf0e10cSrcweir aRet = pWrappedProperty->getPropertyDefault(xPropState); 447cdf0e10cSrcweir else 448cdf0e10cSrcweir aRet = xPropState->getPropertyDefault( rPropertyName ); 449cdf0e10cSrcweir } 450cdf0e10cSrcweir } 451cdf0e10cSrcweir else 452cdf0e10cSrcweir aRet = WrappedPropertySet::getPropertyDefault( rPropertyName ); 453cdf0e10cSrcweir 454cdf0e10cSrcweir return aRet; 455cdf0e10cSrcweir } 456cdf0e10cSrcweir 457cdf0e10cSrcweir void SAL_CALL TitleWrapper::addPropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& xListener ) 458cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); 461cdf0e10cSrcweir if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir Reference< beans::XPropertySet > xPropSet( getFirstCharacterPropertySet(), uno::UNO_QUERY ); 464cdf0e10cSrcweir if( xPropSet.is() ) 465cdf0e10cSrcweir xPropSet->addPropertyChangeListener( rPropertyName, xListener ); 466cdf0e10cSrcweir } 467cdf0e10cSrcweir else 468cdf0e10cSrcweir WrappedPropertySet::addPropertyChangeListener( rPropertyName, xListener ); 469cdf0e10cSrcweir } 470cdf0e10cSrcweir void SAL_CALL TitleWrapper::removePropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& xListener ) 471cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 472cdf0e10cSrcweir { 473cdf0e10cSrcweir sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); 474cdf0e10cSrcweir if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) 475cdf0e10cSrcweir { 476cdf0e10cSrcweir Reference< beans::XPropertySet > xPropSet( getFirstCharacterPropertySet(), uno::UNO_QUERY ); 477cdf0e10cSrcweir if( xPropSet.is() ) 478cdf0e10cSrcweir xPropSet->removePropertyChangeListener( rPropertyName, xListener ); 479cdf0e10cSrcweir } 480cdf0e10cSrcweir else 481cdf0e10cSrcweir WrappedPropertySet::removePropertyChangeListener( rPropertyName, xListener ); 482cdf0e10cSrcweir } 483cdf0e10cSrcweir 484cdf0e10cSrcweir // ================================================================================ 485cdf0e10cSrcweir 486cdf0e10cSrcweir //ReferenceSizePropertyProvider 487cdf0e10cSrcweir void TitleWrapper::updateReferenceSize() 488cdf0e10cSrcweir { 489cdf0e10cSrcweir Reference< beans::XPropertySet > xProp( this->getTitleObject(), uno::UNO_QUERY ); 490cdf0e10cSrcweir if( xProp.is() ) 491cdf0e10cSrcweir { 492cdf0e10cSrcweir if( xProp->getPropertyValue( C2U("ReferencePageSize") ).hasValue() ) 493cdf0e10cSrcweir xProp->setPropertyValue( C2U("ReferencePageSize"), uno::makeAny( 494cdf0e10cSrcweir m_spChart2ModelContact->GetPageSize() )); 495cdf0e10cSrcweir } 496cdf0e10cSrcweir } 497cdf0e10cSrcweir Any TitleWrapper::getReferenceSize() 498cdf0e10cSrcweir { 499cdf0e10cSrcweir Any aRet; 500cdf0e10cSrcweir Reference< beans::XPropertySet > xProp( this->getTitleObject(), uno::UNO_QUERY ); 501cdf0e10cSrcweir if( xProp.is() ) 502cdf0e10cSrcweir aRet = xProp->getPropertyValue( C2U("ReferencePageSize") ); 503cdf0e10cSrcweir 504cdf0e10cSrcweir return aRet; 505cdf0e10cSrcweir } 506cdf0e10cSrcweir awt::Size TitleWrapper::getCurrentSizeForReference() 507cdf0e10cSrcweir { 508cdf0e10cSrcweir return m_spChart2ModelContact->GetPageSize(); 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir // ================================================================================ 512cdf0e10cSrcweir 513cdf0e10cSrcweir Reference< chart2::XTitle > TitleWrapper::getTitleObject() 514cdf0e10cSrcweir { 515cdf0e10cSrcweir return TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() ); 516cdf0e10cSrcweir } 517cdf0e10cSrcweir 518cdf0e10cSrcweir // WrappedPropertySet 519cdf0e10cSrcweir 520cdf0e10cSrcweir Reference< beans::XPropertySet > TitleWrapper::getInnerPropertySet() 521cdf0e10cSrcweir { 522cdf0e10cSrcweir return Reference< beans::XPropertySet >( this->getTitleObject(), uno::UNO_QUERY ); 523cdf0e10cSrcweir } 524cdf0e10cSrcweir 525cdf0e10cSrcweir const Sequence< beans::Property >& TitleWrapper::getPropertySequence() 526cdf0e10cSrcweir { 527cdf0e10cSrcweir return *StaticTitleWrapperPropertyArray::get(); 528cdf0e10cSrcweir } 529cdf0e10cSrcweir 530cdf0e10cSrcweir const std::vector< WrappedProperty* > TitleWrapper::createWrappedProperties() 531cdf0e10cSrcweir { 532cdf0e10cSrcweir ::std::vector< ::chart::WrappedProperty* > aWrappedProperties; 533cdf0e10cSrcweir 534cdf0e10cSrcweir aWrappedProperties.push_back( new WrappedTitleStringProperty( m_spChart2ModelContact->m_xContext ) ); 535cdf0e10cSrcweir aWrappedProperties.push_back( new WrappedTextRotationProperty( m_eTitleType==TitleHelper::Y_AXIS_TITLE || m_eTitleType==TitleHelper::X_AXIS_TITLE ) ); 536cdf0e10cSrcweir aWrappedProperties.push_back( new WrappedStackedTextProperty() ); 537cdf0e10cSrcweir WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this ); 538cdf0e10cSrcweir WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties ); 539cdf0e10cSrcweir WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); 540cdf0e10cSrcweir 541cdf0e10cSrcweir return aWrappedProperties; 542cdf0e10cSrcweir } 543cdf0e10cSrcweir 544cdf0e10cSrcweir // ================================================================================ 545cdf0e10cSrcweir 546cdf0e10cSrcweir Sequence< OUString > TitleWrapper::getSupportedServiceNames_Static() 547cdf0e10cSrcweir { 548cdf0e10cSrcweir Sequence< OUString > aServices( 4 ); 549cdf0e10cSrcweir aServices[ 0 ] = C2U( "com.sun.star.chart.ChartTitle" ); 550cdf0e10cSrcweir aServices[ 1 ] = C2U( "com.sun.star.drawing.Shape" ); 551cdf0e10cSrcweir aServices[ 2 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); 552cdf0e10cSrcweir aServices[ 3 ] = C2U( "com.sun.star.style.CharacterProperties" ); 553cdf0e10cSrcweir // aServices[ 4 ] = C2U( "com.sun.star.beans.PropertySet" ); 554cdf0e10cSrcweir // aServices[ 5 ] = C2U( "com.sun.star.drawing.FillProperties" ); 555cdf0e10cSrcweir // aServices[ 6 ] = C2U( "com.sun.star.drawing.LineProperties" ); 556cdf0e10cSrcweir 557cdf0e10cSrcweir return aServices; 558cdf0e10cSrcweir } 559cdf0e10cSrcweir 560cdf0e10cSrcweir // implement XServiceInfo methods basing upon getSupportedServiceNames_Static 561cdf0e10cSrcweir APPHELPER_XSERVICEINFO_IMPL( TitleWrapper, lcl_aServiceName ); 562cdf0e10cSrcweir 563cdf0e10cSrcweir } // namespace wrapper 564cdf0e10cSrcweir } // namespace chart 565