xref: /AOO41X/main/chart2/source/inc/UncachedDataSequence.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 #ifndef _CHART_UNCACHEDDATASEQUENCE_HXX
28 #define _CHART_UNCACHEDDATASEQUENCE_HXX
29 
30 // helper classes
31 #include <cppuhelper/compbase8.hxx>
32 #include <comphelper/uno3.hxx>
33 #include <comphelper/broadcasthelper.hxx>
34 #include <comphelper/propertycontainer.hxx>
35 #include <comphelper/proparrhlp.hxx>
36 #include "ServiceMacros.hxx"
37 #include "charttoolsdllapi.hxx"
38 
39 // interfaces and types
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/beans/XPropertySet.hpp>
42 #include <com/sun/star/uno/XComponentContext.hpp>
43 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
44 #include <com/sun/star/chart2/data/XDataSequence.hpp>
45 #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
46 #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
47 #include <com/sun/star/container/XIndexReplace.hpp>
48 #include <com/sun/star/container/XNamed.hpp>
49 #include <com/sun/star/util/XCloneable.hpp>
50 #include <com/sun/star/util/XModifyBroadcaster.hpp>
51 #include <com/sun/star/util/XModifiable.hpp>
52 
53 #include <vector>
54 
55 // ____________________
56 namespace chart
57 {
58 
59 namespace impl
60 {
61 typedef ::cppu::WeakComponentImplHelper8<
62     ::com::sun::star::chart2::data::XDataSequence,
63     ::com::sun::star::chart2::data::XNumericalDataSequence,
64     ::com::sun::star::chart2::data::XTextualDataSequence,
65     ::com::sun::star::util::XCloneable,
66     ::com::sun::star::util::XModifiable, // contains util::XModifyBroadcaster
67     ::com::sun::star::container::XIndexReplace,
68     ::com::sun::star::container::XNamed, // for setting a new range representation
69     ::com::sun::star::lang::XServiceInfo >
70     UncachedDataSequence_Base;
71 }
72 
73 class UncachedDataSequence :
74         public ::comphelper::OMutexAndBroadcastHelper,
75         public ::comphelper::OPropertyContainer,
76         public ::comphelper::OPropertyArrayUsageHelper< UncachedDataSequence >,
77         public impl::UncachedDataSequence_Base
78 {
79 public:
80     /** The referring data provider is held as uno reference to ensure its
81         lifetime is at least as long as the one of this object.
82      */
83     UncachedDataSequence(
84         const ::com::sun::star::uno::Reference<
85             ::com::sun::star::chart2::XInternalDataProvider > & xIntDataProv,
86         const ::rtl::OUString & rRangeRepresentation );
87     UncachedDataSequence(
88         const ::com::sun::star::uno::Reference<
89             ::com::sun::star::chart2::XInternalDataProvider > & xIntDataProv,
90         const ::rtl::OUString & rRangeRepresentation,
91         const ::rtl::OUString & rRole );
92     UncachedDataSequence( const UncachedDataSequence & rSource );
93 	virtual ~UncachedDataSequence();
94 
95     /// declare XServiceInfo methods
96     APPHELPER_XSERVICEINFO_DECL()
97 
98     /// merge XInterface implementations
99 	DECLARE_XINTERFACE()
100     /// merge XTypeProvider implementations
101 	DECLARE_XTYPEPROVIDER()
102 
103 protected:
104     // ____ XPropertySet ____
105     /// @see ::com::sun::star::beans::XPropertySet
106     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
107         throw (::com::sun::star::uno::RuntimeException);
108     /// @see ::comphelper::OPropertySetHelper
109 	virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
110     /// @see ::comphelper::OPropertyArrayUsageHelper
111 	virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
112 
113     // ____ XDataSequence ____
114     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getData()
115         throw (::com::sun::star::uno::RuntimeException);
116     virtual ::rtl::OUString SAL_CALL getSourceRangeRepresentation()
117         throw (::com::sun::star::uno::RuntimeException);
118     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL generateLabel(
119         ::com::sun::star::chart2::data::LabelOrigin nLabelOrigin )
120         throw (::com::sun::star::uno::RuntimeException);
121     virtual ::sal_Int32 SAL_CALL getNumberFormatKeyByIndex( ::sal_Int32 nIndex )
122         throw (::com::sun::star::lang::IndexOutOfBoundsException,
123                ::com::sun::star::uno::RuntimeException);
124 
125     // ____ XNumericalDataSequence ____
126     /// @see ::com::sun::star::chart::data::XNumericalDataSequence
127     virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getNumericalData() throw (::com::sun::star::uno::RuntimeException);
128 
129     // ____ XTextualDataSequence ____
130     /// @see ::com::sun::star::chart::data::XTextualDataSequence
131     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getTextualData() throw (::com::sun::star::uno::RuntimeException);
132 
133     // ____ XIndexReplace ____
134     virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
135         throw (::com::sun::star::lang::IllegalArgumentException,
136                ::com::sun::star::lang::IndexOutOfBoundsException,
137                ::com::sun::star::lang::WrappedTargetException,
138                ::com::sun::star::uno::RuntimeException);
139 
140     // ____ XIndexAccess (base of XIndexReplace) ____
141     virtual ::sal_Int32 SAL_CALL getCount()
142         throw (::com::sun::star::uno::RuntimeException);
143     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index )
144         throw (::com::sun::star::lang::IndexOutOfBoundsException,
145                ::com::sun::star::lang::WrappedTargetException,
146                ::com::sun::star::uno::RuntimeException);
147 
148     // ____ XElementAccess (base of XIndexAccess) ____
149     virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
150         throw (::com::sun::star::uno::RuntimeException);
151     virtual ::sal_Bool SAL_CALL hasElements()
152         throw (::com::sun::star::uno::RuntimeException);
153 
154     // ____ XNamed (for setting a new range representation) ____
155     virtual ::rtl::OUString SAL_CALL getName()
156         throw (::com::sun::star::uno::RuntimeException);
157     virtual void SAL_CALL setName( const ::rtl::OUString& aName )
158         throw (::com::sun::star::uno::RuntimeException);
159 
160     // ____ XCloneable ____
161     virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone()
162         throw (::com::sun::star::uno::RuntimeException);
163 
164     // ____ XModifiable ____
165     virtual ::sal_Bool SAL_CALL isModified()
166         throw (::com::sun::star::uno::RuntimeException);
167     virtual void SAL_CALL setModified( ::sal_Bool bModified )
168         throw (::com::sun::star::beans::PropertyVetoException,
169                ::com::sun::star::uno::RuntimeException);
170 
171     // ____ XModifyBroadcaster (base of XModifiable) ____
172     virtual void SAL_CALL addModifyListener(
173         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
174         throw (::com::sun::star::uno::RuntimeException);
175     virtual void SAL_CALL removeModifyListener(
176         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
177         throw (::com::sun::star::uno::RuntimeException);
178 
179     void fireModifyEvent();
180 
181     mutable ::osl::Mutex                  m_aMutex;
182 
183     // <properties>
184     sal_Int32                                       m_nNumberFormatKey;
185     ::rtl::OUString                                 m_sRole;
186     ::rtl::OUString                                 m_aXMLRange;
187     // </properties>
188 
189     /** This method registers all properties.  It should be called by all
190         constructors.
191      */
192     void registerProperties();
193 
194 private:
195     ::com::sun::star::uno::Reference<
196             ::com::sun::star::chart2::XInternalDataProvider > m_xDataProvider;
197     ::rtl::OUString                 m_aSourceRepresentation;
198     ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >
199         m_xModifyEventForwarder;
200 };
201 
202 }  // namespace chart
203 
204 
205 // _CHART_UNCACHEDDATASEQUENCE_HXX
206 #endif
207