1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_chart2.hxx" 30 31 #include "WallFloorWrapper.hxx" 32 #include "macros.hxx" 33 #include "Chart2ModelContact.hxx" 34 #include "ContainerHelper.hxx" 35 #include <com/sun/star/beans/PropertyAttribute.hpp> 36 #include <com/sun/star/drawing/FillStyle.hpp> 37 38 #include "FillProperties.hxx" 39 #include "LineProperties.hxx" 40 #include "UserDefinedProperties.hxx" 41 #include "WrappedDirectStateProperty.hxx" 42 43 #include <algorithm> 44 #include <rtl/ustrbuf.hxx> 45 #include <rtl/math.hxx> 46 47 using namespace ::com::sun::star; 48 using namespace ::com::sun::star::chart2; 49 50 using ::com::sun::star::beans::Property; 51 using ::osl::MutexGuard; 52 using ::com::sun::star::uno::Any; 53 using ::com::sun::star::uno::Reference; 54 using ::com::sun::star::uno::Sequence; 55 using ::rtl::OUString; 56 57 namespace 58 { 59 static const OUString lcl_aServiceName( 60 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.WallOrFloor" )); 61 62 struct StaticWallFloorWrapperPropertyArray_Initializer 63 { 64 Sequence< Property >* operator()() 65 { 66 static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); 67 return &aPropSeq; 68 } 69 70 private: 71 Sequence< Property > lcl_GetPropertySequence() 72 { 73 ::std::vector< ::com::sun::star::beans::Property > aProperties; 74 ::chart::FillProperties::AddPropertiesToVector( aProperties ); 75 ::chart::LineProperties::AddPropertiesToVector( aProperties ); 76 //::chart::NamedProperties::AddPropertiesToVector( aProperties ); 77 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); 78 79 ::std::sort( aProperties.begin(), aProperties.end(), 80 ::chart::PropertyNameLess() ); 81 82 return ::chart::ContainerHelper::ContainerToSequence( aProperties ); 83 } 84 }; 85 86 struct StaticWallFloorWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticWallFloorWrapperPropertyArray_Initializer > 87 { 88 }; 89 90 } // anonymous namespace 91 92 // -------------------------------------------------------------------------------- 93 94 namespace chart 95 { 96 namespace wrapper 97 { 98 99 WallFloorWrapper::WallFloorWrapper( bool bWall, 100 ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : 101 m_spChart2ModelContact( spChart2ModelContact ), 102 m_aEventListenerContainer( m_aMutex ), 103 m_bWall( bWall ) 104 105 { 106 } 107 108 WallFloorWrapper::~WallFloorWrapper() 109 { 110 } 111 112 // ____ XComponent ____ 113 void SAL_CALL WallFloorWrapper::dispose() 114 throw (uno::RuntimeException) 115 { 116 Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); 117 m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); 118 119 // /-- 120 MutexGuard aGuard( GetMutex()); 121 clearWrappedPropertySet(); 122 // \-- 123 } 124 125 void SAL_CALL WallFloorWrapper::addEventListener( 126 const Reference< lang::XEventListener >& xListener ) 127 throw (uno::RuntimeException) 128 { 129 m_aEventListenerContainer.addInterface( xListener ); 130 } 131 132 void SAL_CALL WallFloorWrapper::removeEventListener( 133 const Reference< lang::XEventListener >& aListener ) 134 throw (uno::RuntimeException) 135 { 136 m_aEventListenerContainer.removeInterface( aListener ); 137 } 138 139 // ================================================================================ 140 141 // WrappedPropertySet 142 Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet() 143 { 144 Reference< beans::XPropertySet > xRet; 145 146 Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); 147 if( xDiagram.is() ) 148 { 149 if( m_bWall ) 150 xRet.set( xDiagram->getWall() ); 151 else 152 xRet.set( xDiagram->getFloor() ); 153 } 154 155 return xRet; 156 } 157 158 const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence() 159 { 160 return *StaticWallFloorWrapperPropertyArray::get(); 161 } 162 163 const std::vector< WrappedProperty* > WallFloorWrapper::createWrappedProperties() 164 { 165 ::std::vector< ::chart::WrappedProperty* > aWrappedProperties; 166 167 // use direct state always, so that in XML the value is always 168 // exported. Because in the old chart the defaults is as follows: 169 // Floor: SOLID (new and old model default), Wall: NONE, except for some chart types (line, scatter) 170 if( m_bWall ) 171 aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("FillStyle"), C2U("FillStyle") )); 172 aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("FillColor"), C2U("FillColor") )); 173 174 return aWrappedProperties; 175 } 176 177 // ================================================================================ 178 179 Sequence< OUString > WallFloorWrapper::getSupportedServiceNames_Static() 180 { 181 Sequence< OUString > aServices( 4 ); 182 aServices[ 0 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); 183 aServices[ 1 ] = C2U( "com.sun.star.drawing.FillProperties" ); 184 aServices[ 2 ] = C2U( "com.sun.star.drawing.LineProperties" ); 185 aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" ); 186 187 return aServices; 188 } 189 190 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static 191 APPHELPER_XSERVICEINFO_IMPL( WallFloorWrapper, lcl_aServiceName ); 192 193 } // namespace wrapper 194 } // namespace chart 195