1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _CHART2_DATASOURCEHELPER_HXX
29 #define _CHART2_DATASOURCEHELPER_HXX
31 #include <com/sun/star/chart2/XChartDocument.hpp>
32 #include <com/sun/star/chart2/XDiagram.hpp>
33 #include <com/sun/star/chart2/data/XDataSource.hpp>
34 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <com/sun/star/frame/XModel.hpp>
37 #include <com/sun/star/uno/XComponentContext.hpp>
39 #include "charttoolsdllapi.hxx"
43 //.............................................................................
46 //.............................................................................
48 //-----------------------------------------------------------------------------
52 class OOO_DLLPUBLIC_CHARTTOOLS DataSourceHelper
55 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSource
>
56 createDataSource( const ::com::sun::star::uno::Sequence
<
57 ::com::sun::star::uno::Reference
<
58 ::com::sun::star::chart2::data::XLabeledDataSequence
> > & rSequences
);
60 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>
61 createCachedDataSequence();
63 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>
64 createCachedDataSequence( const ::rtl::OUString
& rSingleText
);
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::chart2::data::XDataSequence
>& xValues
,
69 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>& xLabels
);
71 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
>
72 createLabeledDataSequence(
73 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>& xValues
);
75 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
>
76 createLabeledDataSequence(
77 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xContext
);
79 static ::com::sun::star::uno::Sequence
<
80 ::com::sun::star::beans::PropertyValue
> createArguments(
81 bool bUseColumns
, bool bFirstCellAsLabel
, bool bHasCategories
);
83 static ::com::sun::star::uno::Sequence
<
84 ::com::sun::star::beans::PropertyValue
> createArguments(
85 const ::rtl::OUString
& rRangeRepresentation
,
86 const ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
,
87 bool bUseColumns
, bool bFirstCellAsLabel
, bool bHasCategories
);
89 SAL_DLLPRIVATE
static void readArguments( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rArguments
90 , ::rtl::OUString
& rRangeRepresentation
, ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
91 , bool& bUseColumns
, bool& bFirstCellAsLabel
, bool& bHasCategories
);
93 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSource
>
94 pressUsedDataIntoRectangularFormat( const ::com::sun::star::uno::Reference
<
95 ::com::sun::star::chart2::XChartDocument
>& xChartDoc
,
96 bool bWithCategories
= true );
98 static void addRangeRepresentationsFromLabeledDataSequence(
99 const ::com::sun::star::uno::Reference
<
100 ::com::sun::star::chart2::data::XLabeledDataSequence
>& xLabeledDataSequence
101 , ::std::vector
< ::rtl::OUString
>& rOutRangeRepresentations
);
103 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getUsedDataRanges(
104 const ::com::sun::star::uno::Reference
<
105 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
107 static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getUsedDataRanges(
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::frame::XModel
>& xChartModel
);
116 static ::com::sun::star::uno::Reference
<
117 ::com::sun::star::chart2::data::XDataSource
> getUsedData(
118 const ::com::sun::star::uno::Reference
<
119 ::com::sun::star::chart2::XChartDocument
>& xChartDoc
);
121 static bool detectRangeSegmentation(
122 const ::com::sun::star::uno::Reference
<
123 ::com::sun::star::frame::XModel
>& xChartModel
124 , ::rtl::OUString
& rOutRangeString
125 , ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
126 , bool& rOutUseColumns
127 , bool& rOutFirstCellAsLabel
128 , bool& rOutHasCategories
);
130 static void setRangeSegmentation(
131 const ::com::sun::star::uno::Reference
<
132 ::com::sun::star::frame::XModel
>& xChartModel
133 , const ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
135 , bool bFirstCellAsLabel
136 , bool bUseCategories
);
138 /** Returns true, if all arguments necessary for getting all data by a
139 rectangular region are returned by detectArguments at the given
140 document's data provider.
142 Currently, this is: CellRangeRepresentation, DataRowSource,
143 HasCategories and FirstCellAsLabel.
145 static bool allArgumentsForRectRangeDetected(
146 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XChartDocument
>& xChartDocument
);
148 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getRangesFromLabeledDataSequence(
149 const ::com::sun::star::uno::Reference
<
150 ::com::sun::star::chart2::data::XLabeledDataSequence
> & xLSeq
);
152 SAL_DLLPRIVATE
static ::rtl::OUString
getRangeFromValues(
153 const ::com::sun::star::uno::Reference
<
154 ::com::sun::star::chart2::data::XLabeledDataSequence
> & xLSeq
);
156 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getRangesFromDataSource(
157 const ::com::sun::star::uno::Reference
<
158 ::com::sun::star::chart2::data::XDataSource
> & xSource
);
161 //.............................................................................
163 //.............................................................................