1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _CHART2_DATASOURCEHELPER_HXX
30 #define _CHART2_DATASOURCEHELPER_HXX
32 #include <com/sun/star/chart2/XChartDocument.hpp>
33 #include <com/sun/star/chart2/XDiagram.hpp>
34 #include <com/sun/star/chart2/data/XDataSource.hpp>
35 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
36 #include <com/sun/star/beans/PropertyValue.hpp>
37 #include <com/sun/star/frame/XModel.hpp>
38 #include <com/sun/star/uno/XComponentContext.hpp>
40 #include "charttoolsdllapi.hxx"
44 //.............................................................................
47 //.............................................................................
49 //-----------------------------------------------------------------------------
53 class OOO_DLLPUBLIC_CHARTTOOLS DataSourceHelper
56 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSource
>
57 createDataSource( const ::com::sun::star::uno::Sequence
<
58 ::com::sun::star::uno::Reference
<
59 ::com::sun::star::chart2::data::XLabeledDataSequence
> > & rSequences
);
61 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>
62 createCachedDataSequence();
64 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>
65 createCachedDataSequence( const ::rtl::OUString
& rSingleText
);
67 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
>
68 createLabeledDataSequence(
69 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>& xValues
,
70 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>& xLabels
);
72 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
>
73 createLabeledDataSequence(
74 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>& xValues
);
76 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
>
77 createLabeledDataSequence(
78 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xContext
);
80 static ::com::sun::star::uno::Sequence
<
81 ::com::sun::star::beans::PropertyValue
> createArguments(
82 bool bUseColumns
, bool bFirstCellAsLabel
, bool bHasCategories
);
84 static ::com::sun::star::uno::Sequence
<
85 ::com::sun::star::beans::PropertyValue
> createArguments(
86 const ::rtl::OUString
& rRangeRepresentation
,
87 const ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
,
88 bool bUseColumns
, bool bFirstCellAsLabel
, bool bHasCategories
);
90 SAL_DLLPRIVATE
static void readArguments( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rArguments
91 , ::rtl::OUString
& rRangeRepresentation
, ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
92 , bool& bUseColumns
, bool& bFirstCellAsLabel
, bool& bHasCategories
);
94 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSource
>
95 pressUsedDataIntoRectangularFormat( const ::com::sun::star::uno::Reference
<
96 ::com::sun::star::chart2::XChartDocument
>& xChartDoc
,
97 bool bWithCategories
= true );
99 static void addRangeRepresentationsFromLabeledDataSequence(
100 const ::com::sun::star::uno::Reference
<
101 ::com::sun::star::chart2::data::XLabeledDataSequence
>& xLabeledDataSequence
102 , ::std::vector
< ::rtl::OUString
>& rOutRangeRepresentations
);
104 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getUsedDataRanges(
105 const ::com::sun::star::uno::Reference
<
106 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
108 static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getUsedDataRanges(
109 const ::com::sun::star::uno::Reference
<
110 ::com::sun::star::frame::XModel
> & xChartModel
);
112 static ::com::sun::star::uno::Reference
<
113 ::com::sun::star::chart2::data::XDataSource
> getUsedData(
114 const ::com::sun::star::uno::Reference
<
115 ::com::sun::star::frame::XModel
>& xChartModel
);
117 static ::com::sun::star::uno::Reference
<
118 ::com::sun::star::chart2::data::XDataSource
> getUsedData(
119 const ::com::sun::star::uno::Reference
<
120 ::com::sun::star::chart2::XChartDocument
>& xChartDoc
);
122 static bool detectRangeSegmentation(
123 const ::com::sun::star::uno::Reference
<
124 ::com::sun::star::frame::XModel
>& xChartModel
125 , ::rtl::OUString
& rOutRangeString
126 , ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
127 , bool& rOutUseColumns
128 , bool& rOutFirstCellAsLabel
129 , bool& rOutHasCategories
);
131 static void setRangeSegmentation(
132 const ::com::sun::star::uno::Reference
<
133 ::com::sun::star::frame::XModel
>& xChartModel
134 , const ::com::sun::star::uno::Sequence
< sal_Int32
>& rSequenceMapping
136 , bool bFirstCellAsLabel
137 , bool bUseCategories
);
139 /** Returns true, if all arguments necessary for getting all data by a
140 rectangular region are returned by detectArguments at the given
141 document's data provider.
143 Currently, this is: CellRangeRepresentation, DataRowSource,
144 HasCategories and FirstCellAsLabel.
146 static bool allArgumentsForRectRangeDetected(
147 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XChartDocument
>& xChartDocument
);
149 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getRangesFromLabeledDataSequence(
150 const ::com::sun::star::uno::Reference
<
151 ::com::sun::star::chart2::data::XLabeledDataSequence
> & xLSeq
);
153 SAL_DLLPRIVATE
static ::rtl::OUString
getRangeFromValues(
154 const ::com::sun::star::uno::Reference
<
155 ::com::sun::star::chart2::data::XLabeledDataSequence
> & xLSeq
);
157 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getRangesFromDataSource(
158 const ::com::sun::star::uno::Reference
<
159 ::com::sun::star::chart2::data::XDataSource
> & xSource
);
162 //.............................................................................
164 //.............................................................................
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */