1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DataSourceHelper.hxx,v $
10 * $Revision: 1.3.44.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CHART2_DATASOURCEHELPER_HXX
32 #define _CHART2_DATASOURCEHELPER_HXX
34 #include <com/sun/star/chart2/XChartDocument.hpp>
35 #include <com/sun/star/chart2/XDiagram.hpp>
36 #include <com/sun/star/chart2/data/XDataSource.hpp>
37 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
38 #include <com/sun/star/beans/PropertyValue.hpp>
39 #include <com/sun/star/frame/XModel.hpp>
40 #include <com/sun/star/uno/XComponentContext.hpp>
42 #include "charttoolsdllapi.hxx"
46 //.............................................................................
49 //.............................................................................
51 //-----------------------------------------------------------------------------
55 class OOO_DLLPUBLIC_CHARTTOOLS DataSourceHelper
58 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSource
>
59 createDataSource( const ::com::sun::star::uno::Sequence
<
60 ::com::sun::star::uno::Reference
<
61 ::com::sun::star::chart2::data::XLabeledDataSequence
> > & rSequences
);
63 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>
64 createCachedDataSequence();
66 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>
67 createCachedDataSequence( const ::rtl::OUString
& rSingleText
);
69 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
>
70 createLabeledDataSequence(
71 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>& xValues
,
72 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>& xLabels
);
74 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
>
75 createLabeledDataSequence(
76 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>& xValues
);
78 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
>
79 createLabeledDataSequence(
80 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xContext
);
82 static ::com::sun::star::uno::Sequence
<
83 ::com::sun::star::beans::PropertyValue
> createArguments(
84 bool bUseColumns
, bool bFirstCellAsLabel
, bool bHasCategories
);
86 static ::com::sun::star::uno::Sequence
<
87 ::com::sun::star::beans::PropertyValue
> createArguments(
88 const ::rtl::OUString
& rRangeRepresentation
,
89 const ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
,
90 bool bUseColumns
, bool bFirstCellAsLabel
, bool bHasCategories
);
92 SAL_DLLPRIVATE
static void readArguments( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rArguments
93 , ::rtl::OUString
& rRangeRepresentation
, ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
94 , bool& bUseColumns
, bool& bFirstCellAsLabel
, bool& bHasCategories
);
96 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSource
>
97 pressUsedDataIntoRectangularFormat( const ::com::sun::star::uno::Reference
<
98 ::com::sun::star::chart2::XChartDocument
>& xChartDoc
,
99 bool bWithCategories
= true );
101 static void addRangeRepresentationsFromLabeledDataSequence(
102 const ::com::sun::star::uno::Reference
<
103 ::com::sun::star::chart2::data::XLabeledDataSequence
>& xLabeledDataSequence
104 , ::std::vector
< ::rtl::OUString
>& rOutRangeRepresentations
);
106 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getUsedDataRanges(
107 const ::com::sun::star::uno::Reference
<
108 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
110 static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getUsedDataRanges(
111 const ::com::sun::star::uno::Reference
<
112 ::com::sun::star::frame::XModel
> & xChartModel
);
114 static ::com::sun::star::uno::Reference
<
115 ::com::sun::star::chart2::data::XDataSource
> getUsedData(
116 const ::com::sun::star::uno::Reference
<
117 ::com::sun::star::frame::XModel
>& xChartModel
,
118 bool bIncludeUnusedData
= false );
120 static ::com::sun::star::uno::Reference
<
121 ::com::sun::star::chart2::data::XDataSource
> getUsedData(
122 const ::com::sun::star::uno::Reference
<
123 ::com::sun::star::chart2::XChartDocument
>& xChartDoc
,
124 bool bIncludeUnusedData
= false );
126 static bool detectRangeSegmentation(
127 const ::com::sun::star::uno::Reference
<
128 ::com::sun::star::frame::XModel
>& xChartModel
129 , ::rtl::OUString
& rOutRangeString
130 , ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
131 , bool& rOutUseColumns
132 , bool& rOutFirstCellAsLabel
133 , bool& rOutHasCategories
134 , bool bIncludeUnusedData
= false );
136 static void setRangeSegmentation(
137 const ::com::sun::star::uno::Reference
<
138 ::com::sun::star::frame::XModel
>& xChartModel
139 , const ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
141 , bool bFirstCellAsLabel
142 , bool bUseCategories
);
144 /** Returns true, if all arguments necessary for getting all data by a
145 rectangular region are returned by detectArguments at the given
146 document's data provider.
148 Currently, this is: CellRangeRepresentation, DataRowSource,
149 HasCategories and FirstCellAsLabel.
151 static bool allArgumentsForRectRangeDetected(
152 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XChartDocument
>& xChartDocument
);
154 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getRangesFromLabeledDataSequence(
155 const ::com::sun::star::uno::Reference
<
156 ::com::sun::star::chart2::data::XLabeledDataSequence
> & xLSeq
);
158 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getRangesFromDataSource(
159 const ::com::sun::star::uno::Reference
<
160 ::com::sun::star::chart2::data::XDataSource
> & xSource
);
163 //.............................................................................
165 //.............................................................................