xref: /trunk/main/sc/inc/chartuno.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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     virtual void SAL_CALL   removeByName( const ::rtl::OUString& aName );
74 
75                             // XNameAccess
76     virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName );
77     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames();
78     virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName );
79 
80                             // XIndexAccess
81     virtual sal_Int32 SAL_CALL getCount();
82     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index );
83 
84                             // XEnumerationAccess
85     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
86                             createEnumeration();
87 
88                             // XElementAccess
89     virtual ::com::sun::star::uno::Type SAL_CALL getElementType();
90     virtual sal_Bool SAL_CALL hasElements();
91 
92                             // XServiceInfo
93     virtual ::rtl::OUString SAL_CALL getImplementationName();
94     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
95     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
96 };
97 
98 
99 typedef ::cppu::WeakComponentImplHelper4<
100     ::com::sun::star::table::XTableChart,
101     ::com::sun::star::document::XEmbeddedObjectSupplier,
102     ::com::sun::star::container::XNamedEx,  // #i121178#: support displaying name
103     ::com::sun::star::lang::XServiceInfo > ScChartObj_Base;
104 
105 typedef ::comphelper::OPropertyContainer ScChartObj_PBase;
106 typedef ::comphelper::OPropertyArrayUsageHelper< ScChartObj > ScChartObj_PABase;
107 
108 class ScChartObj : public ::comphelper::OBaseMutex
109                   ,public ScChartObj_Base
110                   ,public ScChartObj_PBase
111                   ,public ScChartObj_PABase
112                   ,public SfxListener
113 {
114 private:
115     ScDocShell*             pDocShell;
116     SCTAB                   nTab;           // Charts sind pro Sheet
117     String                  aChartName;
118     String                  aObjectName;    // #i121178#: the OLE object's name(displaying name)
119 
120     void    Update_Impl( const ScRangeListRef& rRanges, bool bColHeaders, bool bRowHeaders );
121     void    GetData_Impl( ScRangeListRef& rRanges, bool& rColHeaders, bool& rRowHeaders ) const;
122 
123 protected:
124     // ::comphelper::OPropertySetHelper
125     virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
126     virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue );
127     using ::cppu::OPropertySetHelper::getFastPropertyValue;
128     virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
129 
130     // ::comphelper::OPropertyArrayUsageHelper
131     virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
132 
133 public:
134                             ScChartObj(ScDocShell* pDocSh, SCTAB nT, const String& rN);
135     virtual                 ~ScChartObj();
136 
137     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
138 
139     // XInterface
140     DECLARE_XINTERFACE()
141 
142     // XTypeProvider
143     DECLARE_XTYPEPROVIDER()
144 
145     // XComponent
146     virtual void SAL_CALL disposing();
147 
148                             // XTableChart
149     virtual sal_Bool SAL_CALL getHasColumnHeaders();
150     virtual void SAL_CALL   setHasColumnHeaders( sal_Bool bHasColumnHeaders );
151     virtual sal_Bool SAL_CALL getHasRowHeaders();
152     virtual void SAL_CALL   setHasRowHeaders( sal_Bool bHasRowHeaders );
153     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::table::CellRangeAddress > SAL_CALL
154                             getRanges(  );
155     virtual void SAL_CALL   setRanges( const ::com::sun::star::uno::Sequence<
156                                     ::com::sun::star::table::CellRangeAddress >& aRanges );
157 
158                             // XEmbeddedObjectSupplier
159     virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL
160                             getEmbeddedObject();
161 
162                             // XNamed
163     virtual ::rtl::OUString SAL_CALL getName();
164     virtual void SAL_CALL   setName( const ::rtl::OUString& aName );
165 
166                             // XNamedEx
167     virtual ::rtl::OUString SAL_CALL getDisplayName();
168     virtual void SAL_CALL   setDisplayName( const ::rtl::OUString& aName );
169 
170                             // XServiceInfo
171     virtual ::rtl::OUString SAL_CALL getImplementationName();
172     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
173     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
174 
175     // XPropertySet
176     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo();
177 };
178 
179 #endif
180