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 CHART_CHART2MODELCONTACT_HXX
25 #define CHART_CHART2MODELCONTACT_HXX
26 
27 #include <chartview/ExplicitScaleValues.hxx>
28 #include <com/sun/star/chart2/XAxis.hpp>
29 #include <com/sun/star/chart2/XChartDocument.hpp>
30 #include <com/sun/star/chart2/XDataSeries.hpp>
31 #include <com/sun/star/chart2/XDiagram.hpp>
32 #include <com/sun/star/chart2/XTitle.hpp>
33 #include <cppuhelper/weakref.hxx>
34 #include <com/sun/star/awt/Size.hpp>
35 #include <com/sun/star/container/XNameContainer.hpp>
36 #include <com/sun/star/drawing/XDrawPage.hpp>
37 #include <com/sun/star/frame/XModel.hpp>
38 #include <com/sun/star/lang/XUnoTunnel.hpp>
39 #include <com/sun/star/uno/XComponentContext.hpp>
40 
41 #include <map>
42 
43 namespace chart
44 {
45 class ExplicitValueProvider;
46 
47 namespace wrapper
48 {
49 
50 class Chart2ModelContact
51 {
52 public:
53     Chart2ModelContact( const ::com::sun::star::uno::Reference<
54                       ::com::sun::star::uno::XComponentContext >& xContext );
55 	virtual ~Chart2ModelContact();
56 
57 public:
58     void setModel( const ::com::sun::star::uno::Reference<
59                        ::com::sun::star::frame::XModel >& xChartModel );
60     void clear();
61 
62     ::com::sun::star::uno::Reference<
63         ::com::sun::star::frame::XModel > getChartModel() const;
64 
65     ::com::sun::star::uno::Reference<
66         ::com::sun::star::chart2::XChartDocument > getChart2Document() const;
67     ::com::sun::star::uno::Reference<
68         ::com::sun::star::chart2::XDiagram > getChart2Diagram() const;
69 
70     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > getDrawPage();
71 
72     /** Get the current values calculated for an axis in the current view in
73         case properties are 'auto'.
74      */
75     sal_Bool getExplicitValuesForAxis(
76         const ::com::sun::star::uno::Reference<
77             ::com::sun::star::chart2::XAxis > & xAxis,
78         ExplicitScaleData & rOutExplicitScale,
79         ExplicitIncrementData & rOutExplicitIncrement );
80 
81     sal_Int32 getExplicitNumberFormatKeyForAxis(
82             const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis );
83 
84     sal_Int32 getExplicitNumberFormatKeyForSeries(
85             const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& xSeries );
86 
87     /** Returns the size of the page in logic coordinates. This value is used
88         for setting an appropriate "ReferencePageSize" for FontHeights.
89      */
90     ::com::sun::star::awt::Size GetPageSize() const;
91 
92     /** Calculates the current axes title sizes and subtract that space them from the given rectangle.
93      */
94     ::com::sun::star::awt::Rectangle SubstractAxisTitleSizes( const ::com::sun::star::awt::Rectangle& rPositionRect );
95 
96     /** Returns the position and size of the diagram in logic coordinates (100th mm) including
97         the space used for axes including axes titles.
98      */
99     ::com::sun::star::awt::Rectangle GetDiagramRectangleIncludingTitle() const;
100 
101     /** Returns the position and size of the diagram in logic coordinates (100th mm) including
102         the space used for axes excluding axes titles.
103      */
104     ::com::sun::star::awt::Rectangle GetDiagramRectangleIncludingAxes() const;
105 
106     /** Returns the position and size of the diagram in logic coordinates (100th mm) excluding
107         the space used for axes (inner plot area).
108      */
109     ::com::sun::star::awt::Rectangle GetDiagramRectangleExcludingAxes() const;
110 
111     /** Returns the size of the object in logic coordinates.
112      */
113     ::com::sun::star::awt::Size GetLegendSize() const;
114 
115     /** Returns the position of the object in logic coordinates.
116      */
117     ::com::sun::star::awt::Point GetLegendPosition() const;
118 
119     /** Returns the size of the object in logic coordinates.
120      */
121     ::com::sun::star::awt::Size GetTitleSize( const ::com::sun::star::uno::Reference<
122                       ::com::sun::star::chart2::XTitle > & xTitle ) const;
123 
124     /** Returns the position of the object in logic coordinates.
125      */
126     ::com::sun::star::awt::Point GetTitlePosition( const ::com::sun::star::uno::Reference<
127                       ::com::sun::star::chart2::XTitle > & xTitle ) const;
128 
129 
130     /** Returns the size of the object in logic coordinates.
131      */
132     ::com::sun::star::awt::Size GetAxisSize( const ::com::sun::star::uno::Reference<
133                       ::com::sun::star::chart2::XAxis > & xAxis ) const;
134 
135     /** Returns the position of the object in logic coordinates.
136      */
137     ::com::sun::star::awt::Point GetAxisPosition( const ::com::sun::star::uno::Reference<
138                       ::com::sun::star::chart2::XAxis > & xAxis ) const;
139 
140 private: // methods
141     ExplicitValueProvider* getExplicitValueProvider() const;
142     ::com::sun::star::uno::Reference<
143         ::com::sun::star::lang::XUnoTunnel > getChartView() const;
144 
145 public: // member
146     ::com::sun::star::uno::Reference<
147         ::com::sun::star::uno::XComponentContext >
148                         m_xContext;
149 
150 private: // member
151 	::com::sun::star::uno::WeakReference<
152         ::com::sun::star::frame::XModel > m_xChartModel;
153 
154     mutable ::com::sun::star::uno::Reference<
155         ::com::sun::star::lang::XUnoTunnel > m_xChartView;
156 
157     typedef std::map< ::rtl::OUString, ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > > tTableMap;// GradientTable, HatchTable, etc.
158     tTableMap m_aTableMap;
159 };
160 
161 } // namespace wrapper
162 } // namespace chart
163 
164 // CHART_CHART2MODELCONTACT_HXX
165 #endif
166