1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include "DataSeries.hxx"
22 #include <cppuhelper/implbase.hxx>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/beans/PropertyValue.hpp>
25 #include <com/sun/star/chart2/data/XDataSource.hpp>
26 #include <rtl/ref.hxx>
33 class LabeledDataSequence
;
35 /** offers tooling to interpret different data sources in a structural
36 and chart-type-dependent way.
38 struct InterpretedData
40 std::vector
< std::vector
< rtl::Reference
<::chart::DataSeries
> > > Series
;
41 css::uno::Reference
< css::chart2::data::XLabeledDataSequence
> Categories
;
44 /** offers tooling to interpret different data sources in a structural
45 and chart-type-dependent way.
47 class SAL_DLLPUBLIC_RTTI DataInterpreter
: public ::cppu::WeakImplHelper
<
48 css::lang::XServiceInfo
>
51 explicit DataInterpreter();
52 virtual ~DataInterpreter() override
;
54 /// XServiceInfo declarations
55 virtual OUString SAL_CALL
getImplementationName() override
;
56 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
57 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
59 // convenience methods
60 static OUString
GetRole( const css::uno::Reference
< css::chart2::data::XDataSequence
> & xSeq
);
63 const css::uno::Reference
< css::chart2::data::XDataSequence
> & xSeq
,
64 const OUString
& rRole
);
66 static css::uno::Any
GetProperty(
67 const css::uno::Sequence
<css::beans::PropertyValue
> & aArguments
,
68 std::u16string_view rName
);
70 static bool HasCategories(
71 const css::uno::Sequence
< css::beans::PropertyValue
> & rArguments
,
72 const std::vector
< css::uno::Reference
< css::chart2::data::XLabeledDataSequence
> > & rData
);
74 static bool UseCategoriesAsX(
75 const css::uno::Sequence
< css::beans::PropertyValue
> & rArguments
);
77 static std::vector
<css::uno::Reference
< css::chart2::data::XLabeledDataSequence
>> getDataSequences(
78 const css::uno::Reference
< css::chart2::data::XDataSource
>& xSource
);
80 // ____ DataInterpreter ____
81 /** Interprets the given data.
87 Arguments that tell the template how to slice the given
88 range. The properties should be defined in a separate
91 <p>For standard parameters that may be used, see the
92 service StandardDiagramCreationParameters.
96 use all the data series given here for the result before
99 virtual InterpretedData
interpretDataSource(
100 const css::uno::Reference
< css::chart2::data::XDataSource
>& xSource
,
101 const css::uno::Sequence
< css::beans::PropertyValue
>& aArguments
,
102 const std::vector
< rtl::Reference
< ::chart::DataSeries
> >& aSeriesToReUse
);
104 /** Re-interprets the data given in <code>aInterpretedData</code>
105 while keeping the number of data series and the categories.
107 virtual InterpretedData
reinterpretDataSeries(
108 const InterpretedData
& aInterpretedData
);
110 /** parses the given data and states, if a
111 reinterpretDataSeries() call can be done
115 `TRUE`, if the data given in
116 <code>aInterpretedData</code> has a similar structure than
117 the one required is used as output of the data interpreter.
119 virtual bool isDataCompatible(
120 const InterpretedData
& aInterpretedData
);
122 /** Try to reverse the operation done in
123 interpretDataSource().
125 <p>In case <code>aInterpretedData</code> is the result of
126 interpretDataSource()( <code>xSource</code> ),
127 the result of this method should be <code>xSource</code>.</p>
129 static rtl::Reference
< ::chart::DataSource
> mergeInterpretedData(
130 const InterpretedData
& aInterpretedData
);
132 /** Get chart information that is specific to a particular chart
136 name of the piece of data to retrieve.
138 <p>Supported key strings:</p>
140 <li><tt>"stock variant"</tt>: stock chart variant,
141 with 0 = neither Open Values nor volume, 1 = Open Values,
142 2 = volume, 3 = both. Valid for candlestick charts.</li>
146 The value requested, or nothing if not present.
148 virtual css::uno::Any
getChartTypeSpecificData(
149 const OUString
& sKey
);
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */