1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_chartcontroller.hxx" 26 27 #include "AreaWrapper.hxx" 28 #include "macros.hxx" 29 #include "ContainerHelper.hxx" 30 #include "Chart2ModelContact.hxx" 31 #include "WrappedDirectStateProperty.hxx" 32 #include <comphelper/InlineContainer.hxx> 33 #include <com/sun/star/drawing/FillStyle.hpp> 34 35 #include "LineProperties.hxx" 36 #include "FillProperties.hxx" 37 #include "UserDefinedProperties.hxx" 38 39 #include <algorithm> 40 41 using namespace ::com::sun::star; 42 using ::com::sun::star::beans::Property; 43 using ::osl::MutexGuard; 44 using ::com::sun::star::uno::Any; 45 using ::com::sun::star::uno::Reference; 46 using ::com::sun::star::uno::Sequence; 47 48 //----------------------------------------------------------------------------- 49 //----------------------------------------------------------------------------- 50 51 namespace 52 { 53 static const ::rtl::OUString lcl_aServiceName( 54 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Area" )); 55 56 struct StaticAreaWrapperPropertyArray_Initializer 57 { 58 Sequence< Property >* operator()() 59 { 60 static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); 61 return &aPropSeq; 62 } 63 64 private: 65 Sequence< Property > lcl_GetPropertySequence() 66 { 67 ::std::vector< ::com::sun::star::beans::Property > aProperties; 68 ::chart::LineProperties::AddPropertiesToVector( aProperties ); 69 ::chart::FillProperties::AddPropertiesToVector( aProperties ); 70 //::chart::NamedProperties::AddPropertiesToVector( aProperties ); 71 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); 72 73 ::std::sort( aProperties.begin(), aProperties.end(), 74 ::chart::PropertyNameLess() ); 75 76 return ::chart::ContainerHelper::ContainerToSequence( aProperties ); 77 } 78 }; 79 80 struct StaticAreaWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAreaWrapperPropertyArray_Initializer > 81 { 82 }; 83 84 85 } // anonymous namespace 86 87 // -------------------------------------------------------------------------------- 88 // -------------------------------------------------------------------------------- 89 90 namespace chart 91 { 92 namespace wrapper 93 { 94 95 AreaWrapper::AreaWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : 96 m_spChart2ModelContact( spChart2ModelContact ), 97 m_aEventListenerContainer( m_aMutex ) 98 { 99 } 100 101 AreaWrapper::~AreaWrapper() 102 {} 103 104 // ____ XShape ____ 105 awt::Point SAL_CALL AreaWrapper::getPosition() 106 { 107 return awt::Point(0,0); 108 } 109 110 void SAL_CALL AreaWrapper::setPosition( const awt::Point& /*aPosition*/ ) 111 { 112 OSL_ENSURE( false, "trying to set position of chart area" ); 113 } 114 115 awt::Size SAL_CALL AreaWrapper::getSize() 116 { 117 return m_spChart2ModelContact->GetPageSize(); 118 } 119 120 void SAL_CALL AreaWrapper::setSize( const awt::Size& /*aSize*/ ) 121 { 122 OSL_ENSURE( false, "trying to set size of chart area" ); 123 } 124 125 // ____ XShapeDescriptor (base of XShape) ____ 126 ::rtl::OUString SAL_CALL AreaWrapper::getShapeType() 127 { 128 return C2U( "com.sun.star.chart.ChartArea" ); 129 } 130 131 // ____ XComponent ____ 132 void SAL_CALL AreaWrapper::dispose() 133 { 134 Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); 135 m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); 136 137 // /-- 138 MutexGuard aGuard( GetMutex()); 139 clearWrappedPropertySet(); 140 // \-- 141 } 142 143 void SAL_CALL AreaWrapper::addEventListener( 144 const Reference< lang::XEventListener >& xListener ) 145 { 146 m_aEventListenerContainer.addInterface( xListener ); 147 } 148 149 void SAL_CALL AreaWrapper::removeEventListener( 150 const Reference< lang::XEventListener >& aListener ) 151 { 152 m_aEventListenerContainer.removeInterface( aListener ); 153 } 154 155 // ================================================================================ 156 157 // WrappedPropertySet 158 Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet() 159 { 160 Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); 161 if( xChartDoc.is() ) 162 return xChartDoc->getPageBackground(); 163 OSL_ENSURE(false,"AreaWrapper::getInnerPropertySet() is NULL"); 164 return 0; 165 } 166 167 const Sequence< beans::Property >& AreaWrapper::getPropertySequence() 168 { 169 return *StaticAreaWrapperPropertyArray::get(); 170 } 171 172 const std::vector< WrappedProperty* > AreaWrapper::createWrappedProperties() 173 { 174 ::std::vector< ::chart::WrappedProperty* > aWrappedProperties; 175 176 aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("LineStyle"), C2U("LineStyle") ) ); 177 178 return aWrappedProperties; 179 } 180 181 // ================================================================================ 182 183 Sequence< ::rtl::OUString > AreaWrapper::getSupportedServiceNames_Static() 184 { 185 Sequence< ::rtl::OUString > aServices( 4 ); 186 aServices[ 0 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); 187 aServices[ 1 ] = C2U( "com.sun.star.beans.PropertySet" ); 188 aServices[ 2 ] = C2U( "com.sun.star.drawing.FillProperties" ); 189 aServices[ 3 ] = C2U( "com.sun.star.drawing.LineProperties" ); 190 191 return aServices; 192 } 193 194 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static 195 APPHELPER_XSERVICEINFO_IMPL( AreaWrapper, lcl_aServiceName ); 196 197 } // namespace wrapper 198 } // namespace chart 199