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 
24 #ifndef _CHART2_MINIMUMANDMAXIMUMSUPPLIER_HXX
25 #define _CHART2_MINIMUMANDMAXIMUMSUPPLIER_HXX
26 
27 #include <sal/types.h>
28 #include <tools/date.hxx>
29 #include <set>
30 
31 //.............................................................................
32 namespace chart
33 {
34 //.............................................................................
35 
36 //-----------------------------------------------------------------------------
37 /**
38 */
39 
40 class MinimumAndMaximumSupplier
41 {
42 public:
43     virtual double getMinimumX() = 0;
44     virtual double getMaximumX() = 0;
45 
46     //problem y maybe not is always the second border to ask for
47     virtual double getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) = 0;
48     virtual double getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) = 0;
49 
50     //problem: z maybe not independent in future
51     virtual double getMinimumZ() = 0;
52     virtual double getMaximumZ() = 0;
53 
54     virtual bool isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex ) = 0;
55     virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex ) = 0;
56     virtual bool isExpandWideValuesToZero( sal_Int32 nDimensionIndex ) = 0;
57     virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex ) = 0;
58     virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex ) = 0;
59 
60     //return a constant out of ::com::sun::star::chart::TimeUnit that allows to display the smallest distance between occurring dates
61     virtual long calculateTimeResolutionOnXAxis() = 0;
62     virtual void setTimeResolutionOnXAxis( long nTimeResolution, const Date& rNullDate ) = 0;
63 };
64 
65 class MergedMinimumAndMaximumSupplier : public MinimumAndMaximumSupplier
66 {
67 public:
68     MergedMinimumAndMaximumSupplier();
69     virtual ~MergedMinimumAndMaximumSupplier();
70 
71     void addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier );
72     bool hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier );
73     void clearMinimumAndMaximumSupplierList();
74 
75     //--MinimumAndMaximumSupplier
76     virtual double getMinimumX();
77     virtual double getMaximumX();
78     virtual double getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex );
79     virtual double getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex );
80     virtual double getMinimumZ();
81     virtual double getMaximumZ();
82 
83     virtual bool isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex );
84     virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex );
85     virtual bool isExpandWideValuesToZero( sal_Int32 nDimensionIndex );
86     virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex );
87     virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex );
88 
89     virtual long calculateTimeResolutionOnXAxis();
90     virtual void setTimeResolutionOnXAxis( long nTimeResolution, const Date& rNullDate );
91 
92 private:
93     typedef ::std::set< MinimumAndMaximumSupplier* > MinimumAndMaximumSupplierSet;
94     MinimumAndMaximumSupplierSet m_aMinimumAndMaximumSupplierList;
95 
begin()96     inline MinimumAndMaximumSupplierSet::iterator begin() { return m_aMinimumAndMaximumSupplierList.begin(); }
end()97     inline MinimumAndMaximumSupplierSet::iterator end() { return m_aMinimumAndMaximumSupplierList.end(); }
98 };
99 
100 //.............................................................................
101 } //namespace chart
102 //.............................................................................
103 #endif
104