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