1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef CHART2_DIALOGMODEL_HXX
28*cdf0e10cSrcweir #define CHART2_DIALOGMODEL_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "TimerTriggeredControllerLock.hxx"
31*cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <vector>
36*cdf0e10cSrcweir #include <map>
37*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace chart2 {
40*cdf0e10cSrcweir     class XDataSeriesContainer;
41*cdf0e10cSrcweir     class XDataSeries;
42*cdf0e10cSrcweir     class XChartType;
43*cdf0e10cSrcweir     class XChartTypeTemplate;
44*cdf0e10cSrcweir     struct InterpretedData;
45*cdf0e10cSrcweir     namespace data {
46*cdf0e10cSrcweir         class XDataProvider;
47*cdf0e10cSrcweir         class XLabeledDataSequence;
48*cdf0e10cSrcweir     }
49*cdf0e10cSrcweir }}}}
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir namespace chart
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir class RangeSelectionHelper;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir class DialogModel
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir public:
59*cdf0e10cSrcweir 	explicit DialogModel(
60*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
61*cdf0e10cSrcweir             ::com::sun::star::chart2::XChartDocument > & xChartDocument,
62*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
63*cdf0e10cSrcweir             ::com::sun::star::uno::XComponentContext > & xContext );
64*cdf0e10cSrcweir 	~DialogModel();
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir     typedef ::std::pair<
67*cdf0e10cSrcweir                 ::rtl::OUString,
68*cdf0e10cSrcweir                 ::std::pair< ::com::sun::star::uno::Reference<
69*cdf0e10cSrcweir                                  ::com::sun::star::chart2::XDataSeries >,
70*cdf0e10cSrcweir                              ::com::sun::star::uno::Reference<
71*cdf0e10cSrcweir                                  ::com::sun::star::chart2::XChartType > > >
72*cdf0e10cSrcweir         tSeriesWithChartTypeByName;
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir     typedef ::std::map< ::rtl::OUString, ::rtl::OUString >
75*cdf0e10cSrcweir         tRolesWithRanges;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir     void setTemplate(
78*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
79*cdf0e10cSrcweir             ::com::sun::star::chart2::XChartTypeTemplate > & xTemplate );
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir     ::boost::shared_ptr< RangeSelectionHelper >
82*cdf0e10cSrcweir         getRangeSelectionHelper() const;
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
85*cdf0e10cSrcweir         ::com::sun::star::frame::XModel >
86*cdf0e10cSrcweir         getChartModel() const;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
89*cdf0e10cSrcweir             ::com::sun::star::chart2::data::XDataProvider >
90*cdf0e10cSrcweir         getDataProvider() const;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     ::std::vector< ::com::sun::star::uno::Reference<
93*cdf0e10cSrcweir             ::com::sun::star::chart2::XDataSeriesContainer > >
94*cdf0e10cSrcweir         getAllDataSeriesContainers() const;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     ::std::vector< tSeriesWithChartTypeByName >
97*cdf0e10cSrcweir         getAllDataSeriesWithLabel() const;
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     tRolesWithRanges getRolesWithRanges(
100*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
101*cdf0e10cSrcweir             ::com::sun::star::chart2::XDataSeries > & xSeries,
102*cdf0e10cSrcweir         const ::rtl::OUString & aRoleOfSequenceForLabel,
103*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
104*cdf0e10cSrcweir             ::com::sun::star::chart2::XChartType > & xChartType ) const;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     enum eMoveDirection
107*cdf0e10cSrcweir     {
108*cdf0e10cSrcweir         MOVE_DOWN,
109*cdf0e10cSrcweir         MOVE_UP
110*cdf0e10cSrcweir     };
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     void moveSeries( const ::com::sun::star::uno::Reference<
113*cdf0e10cSrcweir                          ::com::sun::star::chart2::XDataSeries > & xSeries,
114*cdf0e10cSrcweir                      eMoveDirection eDirection );
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     /// @return the newly inserted series
117*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
118*cdf0e10cSrcweir             ::com::sun::star::chart2::XDataSeries > insertSeriesAfter(
119*cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference<
120*cdf0e10cSrcweir                     ::com::sun::star::chart2::XDataSeries > & xSeries,
121*cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference<
122*cdf0e10cSrcweir                     ::com::sun::star::chart2::XChartType > & xChartType,
123*cdf0e10cSrcweir                 bool bCreateDataCachedSequences = false );
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir     void deleteSeries(
126*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
127*cdf0e10cSrcweir             ::com::sun::star::chart2::XDataSeries > & xSeries,
128*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
129*cdf0e10cSrcweir             ::com::sun::star::chart2::XChartType > & xChartType );
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
132*cdf0e10cSrcweir             ::com::sun::star::chart2::data::XLabeledDataSequence >
133*cdf0e10cSrcweir         getCategories() const;
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     void setCategories( const ::com::sun::star::uno::Reference<
136*cdf0e10cSrcweir                         ::com::sun::star::chart2::data::XLabeledDataSequence > & xCategories );
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir     ::rtl::OUString getCategoriesRange() const;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     bool isCategoryDiagram() const;
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir     void detectArguments(
143*cdf0e10cSrcweir         ::rtl::OUString & rOutRangeString,
144*cdf0e10cSrcweir         bool & rOutUseColumns, bool & rOutFirstCellAsLabel, bool & rOutHasCategories ) const;
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     bool allArgumentsForRectRangeDetected() const;
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     bool setData( const ::com::sun::star::uno::Sequence<
149*cdf0e10cSrcweir                       ::com::sun::star::beans::PropertyValue > & rArguments );
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir     void startControllerLockTimer();
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir     static ::rtl::OUString ConvertRoleFromInternalToUI( const ::rtl::OUString & rRoleString );
154*cdf0e10cSrcweir     static ::rtl::OUString GetRoleDataLabel();
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir     // pass a role string (not translated) and get an index that serves for
157*cdf0e10cSrcweir     // relative ordering, to get e.g. x-values and y-values in the right order
158*cdf0e10cSrcweir     static sal_Int32 GetRoleIndexForSorting( const ::rtl::OUString & rInternalRoleString );
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir private:
161*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
162*cdf0e10cSrcweir             ::com::sun::star::chart2::XChartDocument >
163*cdf0e10cSrcweir         m_xChartDocument;
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
166*cdf0e10cSrcweir             ::com::sun::star::chart2::XChartTypeTemplate >
167*cdf0e10cSrcweir         m_xTemplate;
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
170*cdf0e10cSrcweir             ::com::sun::star::uno::XComponentContext >
171*cdf0e10cSrcweir         m_xContext;
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     mutable ::boost::shared_ptr< RangeSelectionHelper >
174*cdf0e10cSrcweir         m_spRangeSelectionHelper;
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir     TimerTriggeredControllerLock   m_aTimerTriggeredControllerLock;
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir private:
179*cdf0e10cSrcweir     void createBackup();
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir     void applyInterpretedData(
182*cdf0e10cSrcweir         const ::com::sun::star::chart2::InterpretedData & rNewData,
183*cdf0e10cSrcweir         const ::std::vector< ::com::sun::star::uno::Reference<
184*cdf0e10cSrcweir             ::com::sun::star::chart2::XDataSeries > > & rSeriesToReUse,
185*cdf0e10cSrcweir         bool bSetStyles );
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir     sal_Int32 countSeries() const;
188*cdf0e10cSrcweir };
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir } //  namespace chart
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir // CHART2_DIALOGMODEL_HXX
193*cdf0e10cSrcweir #endif
194