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 INCLUDED_CHART2_SOURCE_INC_CACHEDDATASEQUENCE_HXX
20 : #define INCLUDED_CHART2_SOURCE_INC_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 : namespace chart
44 : {
45 :
46 : namespace impl
47 : {
48 : typedef ::cppu::WeakComponentImplHelper7<
49 : ::com::sun::star::chart2::data::XDataSequence,
50 : ::com::sun::star::chart2::data::XNumericalDataSequence,
51 : ::com::sun::star::chart2::data::XTextualDataSequence,
52 : ::com::sun::star::util::XCloneable,
53 : ::com::sun::star::util::XModifyBroadcaster,
54 : ::com::sun::star::lang::XInitialization,
55 : ::com::sun::star::lang::XServiceInfo >
56 : CachedDataSequence_Base;
57 : }
58 :
59 : class CachedDataSequence :
60 : public ::comphelper::OMutexAndBroadcastHelper,
61 : public ::comphelper::OPropertyContainer,
62 : public ::comphelper::OPropertyArrayUsageHelper< CachedDataSequence >,
63 : public impl::CachedDataSequence_Base
64 : {
65 : public:
66 : /** constructs an empty sequence
67 : */
68 : CachedDataSequence();
69 :
70 : explicit CachedDataSequence(
71 : const ::com::sun::star::uno::Reference<
72 : ::com::sun::star::uno::XComponentContext > & xContext );
73 :
74 : /** creates a sequence and initializes it with the given string. This is
75 : especially useful for labels, which only have one element.
76 : */
77 : explicit CachedDataSequence( const OUString & rSingleText );
78 :
79 : /// Copy CTOR
80 : explicit CachedDataSequence( const CachedDataSequence & rSource );
81 :
82 : virtual ~CachedDataSequence();
83 :
84 : /// establish methods for factory instatiation
85 0 : APPHELPER_SERVICE_FACTORY_HELPER( CachedDataSequence )
86 : /// declare XServiceInfo methods
87 : APPHELPER_XSERVICEINFO_DECL()
88 :
89 : /// merge XInterface implementations
90 : DECLARE_XINTERFACE()
91 : /// merge XTypeProvider implementations
92 : DECLARE_XTYPEPROVIDER()
93 :
94 : protected:
95 : // ____ XPropertySet ____
96 : /// @see ::com::sun::star::beans::XPropertySet
97 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
98 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 : /// @see ::comphelper::OPropertySetHelper
100 : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
101 : /// @see ::comphelper::OPropertyArrayUsageHelper
102 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const SAL_OVERRIDE;
103 :
104 : // ____ XDataSequence ____
105 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getData()
106 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 : virtual OUString SAL_CALL getSourceRangeRepresentation()
108 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL generateLabel(
110 : ::com::sun::star::chart2::data::LabelOrigin nLabelOrigin )
111 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 : virtual ::sal_Int32 SAL_CALL getNumberFormatKeyByIndex( ::sal_Int32 nIndex )
113 : throw (::com::sun::star::lang::IndexOutOfBoundsException,
114 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 :
116 : // ____ XNumericalDataSequence ____
117 : /// @see ::com::sun::star::chart::data::XNumericalDataSequence
118 : virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getNumericalData() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 :
120 : // ____ XTextualDataSequence ____
121 : /// @see ::com::sun::star::chart::data::XTextualDataSequence
122 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getTextualData() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 :
124 : // ____ XCloneable ____
125 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone()
126 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 :
128 : // ____ XModifyBroadcaster ____
129 : virtual void SAL_CALL addModifyListener(
130 : const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
131 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
132 : virtual void SAL_CALL removeModifyListener(
133 : const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
134 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135 :
136 : // ::com::sun::star::lang::XInitialization:
137 : virtual void SAL_CALL initialize(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > & aArguments)
138 : throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
139 :
140 : // <properties>
141 : sal_Int32 m_nNumberFormatKey;
142 : OUString m_sRole;
143 : // </properties>
144 :
145 : enum DataType
146 : {
147 : NUMERICAL,
148 : TEXTUAL,
149 : MIXED
150 : };
151 :
152 : /** This method registers all properties. It should be called by all
153 : constructors.
154 : */
155 : void registerProperties();
156 :
157 : private:
158 : /** is used by interface method getNumericalData().
159 : */
160 : ::com::sun::star::uno::Sequence< double > Impl_getNumericalData() const;
161 : /** is used by interface method getTextualData().
162 : */
163 : ::com::sun::star::uno::Sequence< OUString > Impl_getTextualData() const;
164 : /** is used by interface method getData().
165 : */
166 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > Impl_getMixedData() const;
167 :
168 : private:
169 : enum DataType m_eCurrentDataType;
170 :
171 : ::com::sun::star::uno::Sequence< double > m_aNumericalSequence;
172 : ::com::sun::star::uno::Sequence< OUString > m_aTextualSequence;
173 : ::com::sun::star::uno::Sequence<
174 : ::com::sun::star::uno::Any > m_aMixedSequence;
175 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >
176 : m_xModifyEventForwarder;
177 : };
178 :
179 : } // namespace chart
180 :
181 : // INCLUDED_CHART2_SOURCE_INC_CACHEDDATASEQUENCE_HXX
182 : #endif
183 :
184 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|