Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : : #ifndef _CHART_CACHEDDATASEQUENCE_HXX
20 : : #define _CHART_CACHEDDATASEQUENCE_HXX
21 : :
22 : : // helper classes
23 : : #include <cppuhelper/compbase7.hxx>
24 : : #include <comphelper/uno3.hxx>
25 : : #include <comphelper/broadcasthelper.hxx>
26 : : #include <comphelper/propertycontainer.hxx>
27 : : #include <comphelper/proparrhlp.hxx>
28 : : #include "ServiceMacros.hxx"
29 : :
30 : : // interfaces and types
31 : : #include <com/sun/star/lang/XServiceInfo.hpp>
32 : : #include <com/sun/star/lang/XInitialization.hpp>
33 : : #include <com/sun/star/beans/XPropertySet.hpp>
34 : : #include <com/sun/star/uno/XComponentContext.hpp>
35 : : #include <com/sun/star/chart2/data/XDataSequence.hpp>
36 : : #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
37 : : #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
38 : : #include <com/sun/star/util/XCloneable.hpp>
39 : : #include <com/sun/star/util/XModifyBroadcaster.hpp>
40 : :
41 : : #include <vector>
42 : :
43 : : // ____________________
44 : : namespace chart
45 : : {
46 : :
47 : : namespace impl
48 : : {
49 : : typedef ::cppu::WeakComponentImplHelper7<
50 : : ::com::sun::star::chart2::data::XDataSequence,
51 : : ::com::sun::star::chart2::data::XNumericalDataSequence,
52 : : ::com::sun::star::chart2::data::XTextualDataSequence,
53 : : ::com::sun::star::util::XCloneable,
54 : : ::com::sun::star::util::XModifyBroadcaster,
55 : : ::com::sun::star::lang::XInitialization,
56 : : ::com::sun::star::lang::XServiceInfo >
57 : : CachedDataSequence_Base;
58 : : }
59 : :
60 : : class CachedDataSequence :
61 : : public ::comphelper::OMutexAndBroadcastHelper,
62 : : public ::comphelper::OPropertyContainer,
63 : : public ::comphelper::OPropertyArrayUsageHelper< CachedDataSequence >,
64 : : public impl::CachedDataSequence_Base
65 : : {
66 : : public:
67 : : /** constructs an empty sequence
68 : : */
69 : : CachedDataSequence();
70 : :
71 : : explicit CachedDataSequence(
72 : : const ::com::sun::star::uno::Reference<
73 : : ::com::sun::star::uno::XComponentContext > & xContext );
74 : :
75 : : /** creates a sequence and initializes it with the given string. This is
76 : : especially useful for labels, which only have one element.
77 : : */
78 : : explicit CachedDataSequence( const ::rtl::OUString & rSingleText );
79 : :
80 : : /// Copy CTOR
81 : : explicit CachedDataSequence( const CachedDataSequence & rSource );
82 : :
83 : : virtual ~CachedDataSequence();
84 : :
85 : : /// establish methods for factory instatiation
86 [ # # ][ # # ]: 0 : APPHELPER_SERVICE_FACTORY_HELPER( CachedDataSequence )
87 : : /// declare XServiceInfo methods
88 : : APPHELPER_XSERVICEINFO_DECL()
89 : :
90 : : /// merge XInterface implementations
91 : : DECLARE_XINTERFACE()
92 : : /// merge XTypeProvider implementations
93 : : DECLARE_XTYPEPROVIDER()
94 : :
95 : : protected:
96 : : // ____ XPropertySet ____
97 : : /// @see ::com::sun::star::beans::XPropertySet
98 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
99 : : throw (::com::sun::star::uno::RuntimeException);
100 : : /// @see ::comphelper::OPropertySetHelper
101 : : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
102 : : /// @see ::comphelper::OPropertyArrayUsageHelper
103 : : virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
104 : :
105 : : // ____ XDataSequence ____
106 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getData()
107 : : throw (::com::sun::star::uno::RuntimeException);
108 : : virtual ::rtl::OUString SAL_CALL getSourceRangeRepresentation()
109 : : throw (::com::sun::star::uno::RuntimeException);
110 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL generateLabel(
111 : : ::com::sun::star::chart2::data::LabelOrigin nLabelOrigin )
112 : : throw (::com::sun::star::uno::RuntimeException);
113 : : virtual ::sal_Int32 SAL_CALL getNumberFormatKeyByIndex( ::sal_Int32 nIndex )
114 : : throw (::com::sun::star::lang::IndexOutOfBoundsException,
115 : : ::com::sun::star::uno::RuntimeException);
116 : :
117 : : // ____ XNumericalDataSequence ____
118 : : /// @see ::com::sun::star::chart::data::XNumericalDataSequence
119 : : virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getNumericalData() throw (::com::sun::star::uno::RuntimeException);
120 : :
121 : : // ____ XTextualDataSequence ____
122 : : /// @see ::com::sun::star::chart::data::XTextualDataSequence
123 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getTextualData() throw (::com::sun::star::uno::RuntimeException);
124 : :
125 : : // ____ XCloneable ____
126 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone()
127 : : throw (::com::sun::star::uno::RuntimeException);
128 : :
129 : : // ____ XModifyBroadcaster ____
130 : : virtual void SAL_CALL addModifyListener(
131 : : const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
132 : : throw (::com::sun::star::uno::RuntimeException);
133 : : virtual void SAL_CALL removeModifyListener(
134 : : const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
135 : : throw (::com::sun::star::uno::RuntimeException);
136 : :
137 : : // ::com::sun::star::lang::XInitialization:
138 : : virtual void SAL_CALL initialize(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > & aArguments)
139 : : throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception);
140 : :
141 : : // <properties>
142 : : sal_Int32 m_nNumberFormatKey;
143 : : ::rtl::OUString m_sRole;
144 : : // </properties>
145 : :
146 : : enum DataType
147 : : {
148 : : NUMERICAL,
149 : : TEXTUAL,
150 : : MIXED
151 : : };
152 : :
153 : : /** This method registers all properties. It should be called by all
154 : : constructors.
155 : : */
156 : : void registerProperties();
157 : :
158 : : private:
159 : : /** is used by interface method getNumericalData().
160 : : */
161 : : ::com::sun::star::uno::Sequence< double > Impl_getNumericalData() const;
162 : : /** is used by interface method getTextualData().
163 : : */
164 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > Impl_getTextualData() const;
165 : : /** is used by interface method getData().
166 : : */
167 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > Impl_getMixedData() const;
168 : :
169 : : private:
170 : : enum DataType m_eCurrentDataType;
171 : :
172 : : ::com::sun::star::uno::Sequence< double > m_aNumericalSequence;
173 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTextualSequence;
174 : : ::com::sun::star::uno::Sequence<
175 : : ::com::sun::star::uno::Any > m_aMixedSequence;
176 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >
177 : : m_xModifyEventForwarder;
178 : : };
179 : :
180 : : } // namespace chart
181 : :
182 : :
183 : : // _CHART_CACHEDDATASEQUENCE_HXX
184 : : #endif
185 : :
186 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|