1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef CHART2_DATASOURCETABPAGE_HXX
24 #define CHART2_DATASOURCETABPAGE_HXX
25 
26 #include <svtools/wizardmachine.hxx>
27 
28 #include "DialogModel.hxx"
29 #include "TabPageNotifiable.hxx"
30 
31 // header for class Edit
32 #include <vcl/edit.hxx>
33 // header for class ListBox
34 #include <vcl/lstbox.hxx>
35 // header for class PushButton, OKButton, CancelButton, HelpButton
36 #ifndef _SV_BUTTON_HXX
37 #include <vcl/button.hxx>
38 #endif
39 // header for class FixedText, FixedLine
40 #include <vcl/fixed.hxx>
41 // header for class SvTabListBox
42 #include <svtools/svtabbx.hxx>
43 // header for class SvTreeListBox
44 #include <svtools/svtreebx.hxx>
45 #include <com/sun/star/chart2/XChartDocument.hpp>
46 #include <com/sun/star/chart2/XDiagram.hpp>
47 #include <com/sun/star/chart2/data/XDataProvider.hpp>
48 #include <com/sun/star/chart2/XDataSeries.hpp>
49 #include <com/sun/star/sheet/XRangeSelection.hpp>
50 
51 #include <utility>
52 #include <vector>
53 #include <memory>
54 
55 #include "RangeSelectionListener.hxx"
56 #include "RangeSelectionButton.hxx"
57 #include "RangeEdit.hxx"
58 
59 namespace com { namespace sun { namespace star {
60     namespace chart2 {
61         class XChartType;
62 }}}}
63 
64 namespace chart
65 {
66 
67 class ChartTypeTemplateProvider;
68 class DialogModel;
69 
70 class DataSourceTabPage :
71         public ::svt::OWizardPage,
72         public RangeSelectionListenerParent
73 {
74 public:
75     explicit DataSourceTabPage(
76         Window * pParent,
77         DialogModel & rDialogModel,
78         ChartTypeTemplateProvider* pTemplateProvider,
79         Dialog * pParentDialog,
80         bool bHideDescription = false );
81 	virtual ~DataSourceTabPage();
82 
83     void commitPage();
84 
85 protected:
86     // OWizardPage
87     virtual void ActivatePage();
88     virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason eReason );
89 
90     //TabPage
91     virtual void DeactivatePage();
92 
93     virtual void		initializePage();
94 
95     DECL_LINK( SeriesSelectionChangedHdl, void* );
96     DECL_LINK( RoleSelectionChangedHdl, void* );
97     DECL_LINK( MainRangeButtonClickedHdl, void* );
98     DECL_LINK( CategoriesRangeButtonClickedHdl, void* );
99     DECL_LINK( AddButtonClickedHdl, void* );
100     DECL_LINK( RemoveButtonClickedHdl, void* );
101     DECL_LINK( RangeModifiedHdl, Edit* );
102     DECL_LINK( RangeUpdateDataHdl, Edit* );
103     DECL_LINK( UpButtonClickedHdl, void* );
104     DECL_LINK( DownButtonClickedHdl, void* );
105 
106     // ____ RangeSelectionListenerParent ____
107     virtual void listeningFinished( const ::rtl::OUString & rNewRange );
108     virtual void disposingRangeSelection();
109 
110     void updateControlState();
111 
112 protected:
113     /** updates the internal data according to the content of the given edit
114         field.  If pField is 0, all relevant fields are used
115 
116         @return
117             <TRUE/> if the text from the field is a valid format to the internal
118             data was valid
119      */
120     bool updateModelFromControl( Edit * pField = 0 );
121 
122     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelectionListener >
123         getSelectionRangeListener();
124 
125     /** @return </sal_True>, if the edit field contains a valid range entry. if no
126         XCellRangesAccess can be obtained, </sal_True> is returned.
127      */
128     bool isRangeFieldContentValid( Edit & rEdit );
129 
130     /** @return </sal_True>, if the tab-page is in a consistent (commitable) state
131      */
132     bool isValid();
133     void setDirty();
134 
135     void updateControlsFromDialogModel();
136 
137     void fillSeriesListBox();
138     void fillRoleListBox();
139 
140 private:
141     FixedText               m_aFT_CAPTION;
142     FixedText               m_aFT_SERIES;
143     ::std::auto_ptr< SvTreeListBox > m_apLB_SERIES;
144     PushButton              m_aBTN_ADD;
145     PushButton              m_aBTN_REMOVE;
146     PushButton              m_aBTN_UP;
147     PushButton              m_aBTN_DOWN;
148 
149     FixedText               m_aFT_ROLE;
150     SvTabListBox            m_aLB_ROLE;
151     FixedText               m_aFT_RANGE;
152     RangeEdit               m_aEDT_RANGE;
153     RangeSelectionButton    m_aIMB_RANGE_MAIN;
154 
155     FixedText               m_aFT_CATEGORIES;
156     FixedText               m_aFT_DATALABELS;//used for xy charts
157     RangeEdit               m_aEDT_CATEGORIES;
158     RangeSelectionButton    m_aIMB_RANGE_CAT;
159 
160     ::rtl::OUString         m_aFixedTextRange;
161 
162     ChartTypeTemplateProvider * m_pTemplateProvider;
163     DialogModel &               m_rDialogModel;
164     Edit *                      m_pCurrentRangeChoosingField;
165     bool                        m_bIsDirty;
166     sal_Int32                   m_nLastChartTypeGroupIndex;
167 
168     Dialog *                    m_pParentDialog;
169     TabPageNotifiable *         m_pTabPageNotifiable;
170 };
171 
172 } //  namespace chart
173 
174 // CHART2_DATASOURCETABPAGE_HXX
175 #endif
176