From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- chart2/source/inc/DataInterpreter.hxx | 154 ++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 chart2/source/inc/DataInterpreter.hxx (limited to 'chart2/source/inc/DataInterpreter.hxx') diff --git a/chart2/source/inc/DataInterpreter.hxx b/chart2/source/inc/DataInterpreter.hxx new file mode 100644 index 000000000..7638e5cce --- /dev/null +++ b/chart2/source/inc/DataInterpreter.hxx @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "DataSeries.hxx" +#include +#include +#include +#include +#include +#include + +namespace chart +{ +class DataSeries; +class DataSource; +class LabeledDataSequence; + +/** offers tooling to interpret different data sources in a structural + and chart-type-dependent way. + */ +struct InterpretedData +{ + std::vector< std::vector< rtl::Reference<::chart::DataSeries> > > Series; + css::uno::Reference< css::chart2::data::XLabeledDataSequence > Categories; +}; + +/** offers tooling to interpret different data sources in a structural + and chart-type-dependent way. + */ +class SAL_DLLPUBLIC_RTTI DataInterpreter : public ::cppu::WeakImplHelper< + css::lang::XServiceInfo > +{ +public: + explicit DataInterpreter(); + virtual ~DataInterpreter() override; + + /// XServiceInfo declarations + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // convenience methods + static OUString GetRole( const css::uno::Reference< css::chart2::data::XDataSequence > & xSeq ); + + static void SetRole( + const css::uno::Reference< css::chart2::data::XDataSequence > & xSeq, + const OUString & rRole ); + + static css::uno::Any GetProperty( + const css::uno::Sequence & aArguments, + std::u16string_view rName ); + + static bool HasCategories( + const css::uno::Sequence< css::beans::PropertyValue > & rArguments, + const std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > & rData ); + + static bool UseCategoriesAsX( + const css::uno::Sequence< css::beans::PropertyValue > & rArguments ); + + static std::vector> getDataSequences( + const css::uno::Reference< css::chart2::data::XDataSource >& xSource); + + // ____ DataInterpreter ____ + /** Interprets the given data. + + @param xSource + the data source. + + @param aArguments + Arguments that tell the template how to slice the given + range. The properties should be defined in a separate + service. + +

For standard parameters that may be used, see the + service StandardDiagramCreationParameters. +

+ + @param aSeriesToReUse + use all the data series given here for the result before + creating new ones. + */ + virtual InterpretedData interpretDataSource( + const css::uno::Reference< css::chart2::data::XDataSource >& xSource, + const css::uno::Sequence< css::beans::PropertyValue >& aArguments, + const std::vector< rtl::Reference< ::chart::DataSeries > >& aSeriesToReUse ); + + /** Re-interprets the data given in aInterpretedData + while keeping the number of data series and the categories. + */ + virtual InterpretedData reinterpretDataSeries( + const InterpretedData& aInterpretedData ); + + /** parses the given data and states, if a + reinterpretDataSeries() call can be done + without data loss. + + @return + `TRUE`, if the data given in + aInterpretedData has a similar structure than + the one required is used as output of the data interpreter. + */ + virtual bool isDataCompatible( + const InterpretedData& aInterpretedData ); + + /** Try to reverse the operation done in + interpretDataSource(). + +

In case aInterpretedData is the result of + interpretDataSource()( xSource ), + the result of this method should be xSource.

+ */ + static rtl::Reference< ::chart::DataSource > mergeInterpretedData( + const InterpretedData& aInterpretedData ); + + /** Get chart information that is specific to a particular chart + type, by key. + + @param sKey + name of the piece of data to retrieve. + +

Supported key strings:

+
    +
  • "stock variant": stock chart variant, + with 0 = neither Open Values nor volume, 1 = Open Values, + 2 = volume, 3 = both. Valid for candlestick charts.
  • +
+ + @return + The value requested, or nothing if not present. + */ + virtual css::uno::Any getChartTypeSpecificData( + const OUString& sKey ); +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3