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