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 #ifndef SC_CHARTUNO_HXX 29 #define SC_CHARTUNO_HXX 30 31 #include "address.hxx" 32 #include <svl/lstner.hxx> 33 #include <tools/string.hxx> 34 #include <comphelper/proparrhlp.hxx> 35 #include <comphelper/propertycontainer.hxx> 36 37 #include <com/sun/star/table/XTableChart.hpp> 38 #include <com/sun/star/table/XTableCharts.hpp> 39 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp> 40 #include <com/sun/star/lang/XServiceInfo.hpp> 41 #include <com/sun/star/container/XEnumerationAccess.hpp> 42 #include <com/sun/star/container/XIndexAccess.hpp> 43 #include <com/sun/star/container/XNamed.hpp> 44 #include <cppuhelper/compbase4.hxx> 45 #include <cppuhelper/implbase4.hxx> 46 47 48 class ScDocShell; 49 class ScRangeListRef; 50 class ScChartObj; 51 52 53 class ScChartsObj : public cppu::WeakImplHelper4< 54 com::sun::star::table::XTableCharts, 55 com::sun::star::container::XEnumerationAccess, 56 com::sun::star::container::XIndexAccess, 57 com::sun::star::lang::XServiceInfo >, 58 public SfxListener 59 { 60 private: 61 ScDocShell* pDocShell; 62 SCTAB nTab; // Charts sind pro Sheet 63 64 ScChartObj* GetObjectByIndex_Impl(long nIndex) const; 65 ScChartObj* GetObjectByName_Impl(const ::rtl::OUString& aName) const; 66 67 public: 68 ScChartsObj(ScDocShell* pDocSh, SCTAB nT); 69 virtual ~ScChartsObj(); 70 71 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 72 73 // XTableCharts 74 virtual void SAL_CALL addNewByName( const ::rtl::OUString& aName, 75 const ::com::sun::star::awt::Rectangle& aRect, 76 const ::com::sun::star::uno::Sequence< 77 ::com::sun::star::table::CellRangeAddress >& aRanges, 78 sal_Bool bColumnHeaders, sal_Bool bRowHeaders ) 79 throw(::com::sun::star::uno::RuntimeException); 80 virtual void SAL_CALL removeByName( const ::rtl::OUString& aName ) 81 throw(::com::sun::star::uno::RuntimeException); 82 83 // XNameAccess 84 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) 85 throw(::com::sun::star::container::NoSuchElementException, 86 ::com::sun::star::lang::WrappedTargetException, 87 ::com::sun::star::uno::RuntimeException); 88 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() 89 throw(::com::sun::star::uno::RuntimeException); 90 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) 91 throw(::com::sun::star::uno::RuntimeException); 92 93 // XIndexAccess 94 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException); 95 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) 96 throw(::com::sun::star::lang::IndexOutOfBoundsException, 97 ::com::sun::star::lang::WrappedTargetException, 98 ::com::sun::star::uno::RuntimeException); 99 100 // XEnumerationAccess 101 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL 102 createEnumeration() throw(::com::sun::star::uno::RuntimeException); 103 104 // XElementAccess 105 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() 106 throw(::com::sun::star::uno::RuntimeException); 107 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); 108 109 // XServiceInfo 110 virtual ::rtl::OUString SAL_CALL getImplementationName() 111 throw(::com::sun::star::uno::RuntimeException); 112 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 113 throw(::com::sun::star::uno::RuntimeException); 114 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 115 throw(::com::sun::star::uno::RuntimeException); 116 }; 117 118 119 typedef ::cppu::WeakComponentImplHelper4< 120 ::com::sun::star::table::XTableChart, 121 ::com::sun::star::document::XEmbeddedObjectSupplier, 122 ::com::sun::star::container::XNamed, 123 ::com::sun::star::lang::XServiceInfo > ScChartObj_Base; 124 125 typedef ::comphelper::OPropertyContainer ScChartObj_PBase; 126 typedef ::comphelper::OPropertyArrayUsageHelper< ScChartObj > ScChartObj_PABase; 127 128 class ScChartObj : public ::comphelper::OBaseMutex 129 ,public ScChartObj_Base 130 ,public ScChartObj_PBase 131 ,public ScChartObj_PABase 132 ,public SfxListener 133 { 134 private: 135 ScDocShell* pDocShell; 136 SCTAB nTab; // Charts sind pro Sheet 137 String aChartName; 138 139 void Update_Impl( const ScRangeListRef& rRanges, bool bColHeaders, bool bRowHeaders ); 140 void GetData_Impl( ScRangeListRef& rRanges, bool& rColHeaders, bool& rRowHeaders ) const; 141 142 protected: 143 // ::comphelper::OPropertySetHelper 144 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 145 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) 146 throw (::com::sun::star::uno::Exception); 147 using ::cppu::OPropertySetHelper::getFastPropertyValue; 148 virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; 149 150 // ::comphelper::OPropertyArrayUsageHelper 151 virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; 152 153 public: 154 ScChartObj(ScDocShell* pDocSh, SCTAB nT, const String& rN); 155 virtual ~ScChartObj(); 156 157 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 158 159 // XInterface 160 DECLARE_XINTERFACE() 161 162 // XTypeProvider 163 DECLARE_XTYPEPROVIDER() 164 165 // XComponent 166 virtual void SAL_CALL disposing(); 167 168 // XTableChart 169 virtual sal_Bool SAL_CALL getHasColumnHeaders() throw(::com::sun::star::uno::RuntimeException); 170 virtual void SAL_CALL setHasColumnHeaders( sal_Bool bHasColumnHeaders ) 171 throw(::com::sun::star::uno::RuntimeException); 172 virtual sal_Bool SAL_CALL getHasRowHeaders() throw(::com::sun::star::uno::RuntimeException); 173 virtual void SAL_CALL setHasRowHeaders( sal_Bool bHasRowHeaders ) 174 throw(::com::sun::star::uno::RuntimeException); 175 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::table::CellRangeAddress > SAL_CALL 176 getRanges( ) throw(::com::sun::star::uno::RuntimeException); 177 virtual void SAL_CALL setRanges( const ::com::sun::star::uno::Sequence< 178 ::com::sun::star::table::CellRangeAddress >& aRanges ) 179 throw(::com::sun::star::uno::RuntimeException); 180 181 // XEmbeddedObjectSupplier 182 virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL 183 getEmbeddedObject() throw(::com::sun::star::uno::RuntimeException); 184 185 // XNamed 186 virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException); 187 virtual void SAL_CALL setName( const ::rtl::OUString& aName ) 188 throw(::com::sun::star::uno::RuntimeException); 189 190 // XServiceInfo 191 virtual ::rtl::OUString SAL_CALL getImplementationName() 192 throw(::com::sun::star::uno::RuntimeException); 193 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 194 throw(::com::sun::star::uno::RuntimeException); 195 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 196 throw(::com::sun::star::uno::RuntimeException); 197 198 // XPropertySet 199 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() 200 throw (::com::sun::star::uno::RuntimeException); 201 }; 202 203 #endif 204 205