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_RES_ERRORBAR_HXX
24 #define CHART2_RES_ERRORBAR_HXX
25 
26 #include <vcl/button.hxx>
27 #include <vcl/fixed.hxx>
28 #include <vcl/field.hxx>
29 #include <vcl/lstbox.hxx>
30 #include <svtools/valueset.hxx>
31 #include <svl/itemset.hxx>
32 #include <svx/chrtitem.hxx>
33 #include "chartview/ChartSfxItemIds.hxx"
34 #include "RangeSelectionButton.hxx"
35 #include "RangeSelectionListener.hxx"
36 #include "RangeEdit.hxx"
37 
38 #include <com/sun/star/chart2/XChartDocument.hpp>
39 
40 #include <memory>
41 
42 class Dialog;
43 
44 //.............................................................................
45 namespace chart
46 {
47 //.............................................................................
48 
49 class RangeSelectionHelper;
50 
51 class ErrorBarResources : public RangeSelectionListenerParent
52 {
53 public:
54     enum tErrorBarType
55     {
56         ERROR_BAR_X,
57         ERROR_BAR_Y
58     };
59 
60     ErrorBarResources(
61         Window* pParent, Dialog * pParentDialog, const SfxItemSet& rInAttrst,
62         bool bNoneAvailable,
63         tErrorBarType eType = ERROR_BAR_Y );
64     virtual ~ErrorBarResources();
65 
66     void SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth );
67     void SetErrorBarType( tErrorBarType eNewType );
68     void SetChartDocumentForRangeChoosing(
69         const ::com::sun::star::uno::Reference<
70             ::com::sun::star::chart2::XChartDocument > & xChartDocument );
71     void Reset(const SfxItemSet& rInAttrs);
72     sal_Bool FillItemSet(SfxItemSet& rOutAttrs) const;
73 
74     void FillValueSets();
75 
76     // ____ RangeSelectionListenerParent ____
77     virtual void listeningFinished( const ::rtl::OUString & rNewRange );
78     virtual void disposingRangeSelection();
79 
80 private:
81     // category
82     FixedLine            m_aFlErrorCategory;
83     RadioButton          m_aRbNone;
84     RadioButton          m_aRbConst;
85     RadioButton          m_aRbPercent;
86     RadioButton          m_aRbFunction;
87     RadioButton          m_aRbRange;
88     ListBox              m_aLbFunction;
89 
90     // parameters
91     FixedLine            m_aFlParameters;
92     FixedText            m_aFtPositive;
93     MetricField          m_aMfPositive;
94     RangeEdit            m_aEdRangePositive;
95     RangeSelectionButton m_aIbRangePositive;
96     FixedText            m_aFtNegative;
97     MetricField          m_aMfNegative;
98     RangeEdit            m_aEdRangeNegative;
99     RangeSelectionButton m_aIbRangeNegative;
100     CheckBox             m_aCbSyncPosNeg;
101 
102     // indicator
103     FixedLine            m_aFlIndicate;
104     RadioButton          m_aRbBoth;
105     RadioButton          m_aRbPositive;
106     RadioButton          m_aRbNegative;
107     FixedImage           m_aFiBoth;
108     FixedImage           m_aFiPositive;
109     FixedImage           m_aFiNegative;
110 
111     SvxChartKindError    m_eErrorKind;
112     SvxChartIndicate     m_eIndicate;
113     SvxChartRegress      m_eTrendLineType;
114 
115     bool                 m_bErrorKindUnique;
116     bool                 m_bIndicatorUnique;
117     bool                 m_bPlusUnique;
118     bool                 m_bMinusUnique;
119     bool                 m_bRangePosUnique;
120     bool                 m_bRangeNegUnique;
121 
122     bool                 m_bNoneAvailable;
123 
124     tErrorBarType        m_eErrorBarType;
125     sal_uInt16           m_nConstDecimalDigits;
126     sal_Int64            m_nConstSpinSize;
127 
128     Window *             m_pParentWindow;
129     Dialog *             m_pParentDialog;
130     ::std::auto_ptr< RangeSelectionHelper >
131                          m_apRangeSelectionHelper;
132     Edit *               m_pCurrentRangeChoosingField;
133     bool                 m_bHasInternalDataProvider;
134     bool                 m_bDisableDataTableDialog;
135 
136     DECL_LINK( CategoryChosen, void * );
137     DECL_LINK( SynchronizePosAndNeg, void * );
138     DECL_LINK( PosValueChanged, void * );
139     DECL_LINK( IndicatorChanged, void * );
140     DECL_LINK( ChooseRange, RangeSelectionButton * );
141     DECL_LINK( RangeChanged, Edit * );
142 
143     void UpdateControlStates();
144     bool isRangeFieldContentValid( Edit & rEdit );
145 };
146 
147 //.............................................................................
148 } //namespace chart
149 //.............................................................................
150 
151 #endif
152