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 .
20 #ifndef INCLUDED_CHART2_SOURCE_INC_DATASOURCEHELPER_HXX
21 #define INCLUDED_CHART2_SOURCE_INC_DATASOURCEHELPER_HXX
23 #include <com/sun/star/chart2/XChartDocument.hpp>
24 #include <com/sun/star/chart2/XDiagram.hpp>
25 #include <com/sun/star/chart2/data/XDataSource.hpp>
26 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
27 #include <com/sun/star/beans/PropertyValue.hpp>
28 #include <com/sun/star/frame/XModel.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
31 #include "ChartModel.hxx"
33 #include "charttoolsdllapi.hxx"
43 class OOO_DLLPUBLIC_CHARTTOOLS DataSourceHelper
46 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSource
>
47 createDataSource( const ::com::sun::star::uno::Sequence
<
48 ::com::sun::star::uno::Reference
<
49 ::com::sun::star::chart2::data::XLabeledDataSequence
> > & rSequences
);
51 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>
52 createCachedDataSequence();
54 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>
55 createCachedDataSequence( const OUString
& rSingleText
);
57 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
>
58 createLabeledDataSequence(
59 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>& xValues
,
60 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>& xLabels
);
62 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
>
63 createLabeledDataSequence(
64 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>& xValues
);
66 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
>
67 createLabeledDataSequence(
68 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xContext
);
70 static ::com::sun::star::uno::Sequence
<
71 ::com::sun::star::beans::PropertyValue
> createArguments(
72 bool bUseColumns
, bool bFirstCellAsLabel
, bool bHasCategories
);
74 static ::com::sun::star::uno::Sequence
<
75 ::com::sun::star::beans::PropertyValue
> createArguments(
76 const OUString
& rRangeRepresentation
,
77 const ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
,
78 bool bUseColumns
, bool bFirstCellAsLabel
, bool bHasCategories
);
80 SAL_DLLPRIVATE
static void readArguments( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rArguments
81 , OUString
& rRangeRepresentation
, ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
82 , bool& bUseColumns
, bool& bFirstCellAsLabel
, bool& bHasCategories
);
84 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSource
>
85 pressUsedDataIntoRectangularFormat( const ::com::sun::star::uno::Reference
<
86 ::com::sun::star::chart2::XChartDocument
>& xChartDoc
,
87 bool bWithCategories
= true );
89 static void addRangeRepresentationsFromLabeledDataSequence(
90 const ::com::sun::star::uno::Reference
<
91 ::com::sun::star::chart2::data::XLabeledDataSequence
>& xLabeledDataSequence
92 , ::std::vector
< OUString
>& rOutRangeRepresentations
);
94 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< OUString
> getUsedDataRanges(
95 const ::com::sun::star::uno::Reference
<
96 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
98 static ::com::sun::star::uno::Sequence
< OUString
> getUsedDataRanges(
99 const ::com::sun::star::uno::Reference
<
100 ::com::sun::star::frame::XModel
> & xChartModel
);
102 static ::com::sun::star::uno::Reference
<
103 ::com::sun::star::chart2::data::XDataSource
> getUsedData(
104 ChartModel
& rModel
);
106 static ::com::sun::star::uno::Reference
<
107 ::com::sun::star::chart2::data::XDataSource
> getUsedData(
108 const ::com::sun::star::uno::Reference
<
109 ::com::sun::star::frame::XModel
>& xChartModel
);
111 static ::com::sun::star::uno::Reference
<
112 ::com::sun::star::chart2::data::XDataSource
> getUsedData(
113 const ::com::sun::star::uno::Reference
<
114 ::com::sun::star::chart2::XChartDocument
>& xChartDoc
);
116 static bool detectRangeSegmentation(
117 const ::com::sun::star::uno::Reference
<
118 ::com::sun::star::frame::XModel
>& xChartModel
119 , OUString
& rOutRangeString
120 , ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
121 , bool& rOutUseColumns
122 , bool& rOutFirstCellAsLabel
123 , bool& rOutHasCategories
);
125 static void setRangeSegmentation(
126 const ::com::sun::star::uno::Reference
<
127 ::com::sun::star::frame::XModel
>& xChartModel
128 , const ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
130 , bool bFirstCellAsLabel
131 , bool bUseCategories
);
133 /** Returns true, if all arguments necessary for getting all data by a
134 rectangular region are returned by detectArguments at the given
135 document's data provider.
137 Currently, this is: CellRangeRepresentation, DataRowSource,
138 HasCategories and FirstCellAsLabel.
140 static bool allArgumentsForRectRangeDetected(
141 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XChartDocument
>& xChartDocument
);
143 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< OUString
> getRangesFromLabeledDataSequence(
144 const ::com::sun::star::uno::Reference
<
145 ::com::sun::star::chart2::data::XLabeledDataSequence
> & xLSeq
);
147 SAL_DLLPRIVATE
static OUString
getRangeFromValues(
148 const ::com::sun::star::uno::Reference
<
149 ::com::sun::star::chart2::data::XLabeledDataSequence
> & xLSeq
);
151 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< OUString
> getRangesFromDataSource(
152 const ::com::sun::star::uno::Reference
<
153 ::com::sun::star::chart2::data::XDataSource
> & xSource
);
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */