nss: upgrade to release 3.73
[LibreOffice.git] / chart2 / source / inc / InternalDataProvider.hxx
blob7e3291f2f5821d56282c8310d90a920026e90779
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #pragma once
21 #include "InternalData.hxx"
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/chart/XDateCategories.hpp>
25 #include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
26 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
27 #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
28 #include <com/sun/star/lang/XInitialization.hpp>
29 #include <com/sun/star/util/XCloneable.hpp>
30 #include <cppuhelper/implbase.hxx>
31 #include <cppuhelper/weakref.hxx>
33 #include <map>
35 namespace com::sun::star::chart2 { class XChartDocument; }
37 namespace chart
40 namespace impl
43 typedef ::cppu::WeakImplHelper<
44 css::chart2::XInternalDataProvider,
45 css::chart2::data::XRangeXMLConversion,
46 css::chart2::XAnyDescriptionAccess,
47 css::chart::XDateCategories,
48 css::util::XCloneable,
49 css::lang::XInitialization,
50 css::lang::XServiceInfo >
51 InternalDataProvider_Base;
54 /** Data provider that handles data internally. This is used for charts with
55 their own data.
57 <p>The format for single ranges is "categories|label n|n" where n is a
58 non-negative number. Meaning return all categories, the label of sequence n,
59 or the data of sequence n.</p>
61 <p>The format for a complete range is "all". (Do we need more than
62 that?)</p>
64 class InternalDataProvider :
65 public impl::InternalDataProvider_Base
67 public:
68 explicit InternalDataProvider();
70 // #i120559# allow handing over a default for data orientation
71 // (DataInColumns) that will be used when no data is available
72 explicit InternalDataProvider(
73 const css::uno::Reference< css::chart2::XChartDocument > & xChartDoc,
74 bool bConnectToModel,
75 bool bDefaultDataInColumns );
76 explicit InternalDataProvider( const InternalDataProvider & rOther );
77 virtual ~InternalDataProvider() override;
79 /// declare XServiceInfo methods
80 virtual OUString SAL_CALL getImplementationName() override;
81 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
82 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
84 // ____ XInternalDataProvider ____
85 virtual sal_Bool SAL_CALL hasDataByRangeRepresentation( const OUString& aRange ) override;
86 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
87 getDataByRangeRepresentation( const OUString& aRange ) override;
88 virtual void SAL_CALL setDataByRangeRepresentation(
89 const OUString& aRange,
90 const css::uno::Sequence< css::uno::Any >& aNewData ) override;
91 virtual void SAL_CALL insertSequence( ::sal_Int32 nAfterIndex ) override;
92 virtual void SAL_CALL deleteSequence( ::sal_Int32 nAtIndex ) override;
93 virtual void SAL_CALL appendSequence() override;
94 virtual void SAL_CALL insertComplexCategoryLevel( ::sal_Int32 nLevel ) override;
95 virtual void SAL_CALL deleteComplexCategoryLevel( ::sal_Int32 nLevel ) override;
96 virtual void SAL_CALL insertDataPointForAllSequences( ::sal_Int32 nAfterIndex ) override;
97 virtual void SAL_CALL deleteDataPointForAllSequences( ::sal_Int32 nAtIndex ) override;
98 virtual void SAL_CALL swapDataPointWithNextOneForAllSequences( ::sal_Int32 nAtIndex ) override;
99 virtual void SAL_CALL registerDataSequenceForChanges(
100 const css::uno::Reference< css::chart2::data::XDataSequence >& xSeq ) override;
102 // ____ XDataProvider (base of XInternalDataProvider) ____
103 virtual sal_Bool SAL_CALL createDataSourcePossible(
104 const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override;
105 virtual css::uno::Reference< css::chart2::data::XDataSource > SAL_CALL createDataSource(
106 const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override;
107 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL detectArguments(
108 const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource ) override;
109 virtual sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible(
110 const OUString& aRangeRepresentation ) override;
111 virtual css::uno::Reference< css::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation(
112 const OUString& aRangeRepresentation ) override;
114 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
115 createDataSequenceByValueArray( const OUString& aRole, const OUString& aRangeRepresentation ) override;
117 virtual css::uno::Reference< css::sheet::XRangeSelection > SAL_CALL getRangeSelection() override;
119 // ____ XRangeXMLConversion ____
120 virtual OUString SAL_CALL convertRangeToXML(
121 const OUString& aRangeRepresentation ) override;
122 virtual OUString SAL_CALL convertRangeFromXML(
123 const OUString& aXMLRange ) override;
125 // ____ XDateCategories ____
126 virtual css::uno::Sequence< double > SAL_CALL getDateCategories() override;
127 virtual void SAL_CALL setDateCategories( const css::uno::Sequence< double >& rDates ) override;
129 // ____ XAnyDescriptionAccess ____
130 virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL
131 getAnyRowDescriptions() override;
132 virtual void SAL_CALL setAnyRowDescriptions(
133 const css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& aRowDescriptions ) override;
134 virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL
135 getAnyColumnDescriptions() override;
136 virtual void SAL_CALL setAnyColumnDescriptions(
137 const css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& aColumnDescriptions ) override;
139 // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____
140 virtual css::uno::Sequence< css::uno::Sequence< OUString > > SAL_CALL
141 getComplexRowDescriptions() override;
142 virtual void SAL_CALL setComplexRowDescriptions(
143 const css::uno::Sequence< css::uno::Sequence< OUString > >& aRowDescriptions ) override;
144 virtual css::uno::Sequence< css::uno::Sequence< OUString > > SAL_CALL
145 getComplexColumnDescriptions() override;
146 virtual void SAL_CALL setComplexColumnDescriptions(
147 const css::uno::Sequence< css::uno::Sequence< OUString > >& aColumnDescriptions ) override;
149 // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
150 virtual css::uno::Sequence< css::uno::Sequence< double > > SAL_CALL getData() override;
151 virtual void SAL_CALL setData(
152 const css::uno::Sequence< css::uno::Sequence< double > >& aData ) override;
153 virtual css::uno::Sequence< OUString > SAL_CALL getRowDescriptions() override;
154 virtual void SAL_CALL setRowDescriptions(
155 const css::uno::Sequence< OUString >& aRowDescriptions ) override;
156 virtual css::uno::Sequence< OUString > SAL_CALL getColumnDescriptions() override;
157 virtual void SAL_CALL setColumnDescriptions(
158 const css::uno::Sequence< OUString >& aColumnDescriptions ) override;
160 // ____ XChartData (base of XChartDataArray) ____
161 virtual void SAL_CALL addChartDataChangeEventListener(
162 const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override;
163 virtual void SAL_CALL removeChartDataChangeEventListener(
164 const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override;
165 virtual double SAL_CALL getNotANumber() override;
166 virtual sal_Bool SAL_CALL isNotANumber(
167 double nNumber ) override;
169 // ____ XCloneable ____
170 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
171 // css::lang::XInitialization:
172 virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > & aArguments) override;
174 private:
175 void addDataSequenceToMap(
176 const OUString & rRangeRepresentation,
177 const css::uno::Reference< css::chart2::data::XDataSequence > & xSequence );
179 css::uno::Reference< css::chart2::data::XDataSequence >
180 createDataSequenceAndAddToMap( const OUString & rRangeRepresentation,
181 const OUString & rRole );
182 css::uno::Reference< css::chart2::data::XDataSequence >
183 createDataSequenceAndAddToMap( const OUString & rRangeRepresentation );
185 css::uno::Reference<css::chart2::data::XDataSequence>
186 createDataSequenceFromArray( const OUString& rArrayStr, const OUString& rRole );
188 void deleteMapReferences( const OUString & rRangeRepresentation );
190 void adaptMapReferences(
191 const OUString & rOldRangeRepresentation,
192 const OUString & rNewRangeRepresentation );
194 void increaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
195 void decreaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
197 typedef std::multimap< OUString,
198 css::uno::WeakReference< css::chart2::data::XDataSequence > >
199 tSequenceMap;
200 typedef std::pair< tSequenceMap::iterator, tSequenceMap::iterator > tSequenceMapRange;
202 /** cache for all sequences that have been returned.
204 If the range-representation of a sequence changes and it is still
205 referred to by some component (weak reference is valid), the range will
206 be adapted.
208 tSequenceMap m_aSequenceMap;
209 InternalData m_aInternalData;
210 bool m_bDataInColumns;
213 } // namespace chart
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */