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