1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef CHART_CHART2MODELCONTACT_HXX
28 #define CHART_CHART2MODELCONTACT_HXX
29 
30 #include <chartview/ExplicitScaleValues.hxx>
31 #include <com/sun/star/chart2/XAxis.hpp>
32 #include <com/sun/star/chart2/XChartDocument.hpp>
33 #include <com/sun/star/chart2/XDataSeries.hpp>
34 #include <com/sun/star/chart2/XDiagram.hpp>
35 #include <com/sun/star/chart2/XTitle.hpp>
36 #include <cppuhelper/weakref.hxx>
37 #include <com/sun/star/awt/Size.hpp>
38 #include <com/sun/star/container/XNameContainer.hpp>
39 #include <com/sun/star/drawing/XDrawPage.hpp>
40 #include <com/sun/star/frame/XModel.hpp>
41 #include <com/sun/star/lang/XUnoTunnel.hpp>
42 #include <com/sun/star/uno/XComponentContext.hpp>
43 
44 #include <map>
45 
46 namespace chart
47 {
48 class ExplicitValueProvider;
49 
50 namespace wrapper
51 {
52 
53 class Chart2ModelContact
54 {
55 public:
56     Chart2ModelContact( const ::com::sun::star::uno::Reference<
57                       ::com::sun::star::uno::XComponentContext >& xContext );
58 	virtual ~Chart2ModelContact();
59 
60 public:
61     void setModel( const ::com::sun::star::uno::Reference<
62                        ::com::sun::star::frame::XModel >& xChartModel );
63     void clear();
64 
65     ::com::sun::star::uno::Reference<
66         ::com::sun::star::frame::XModel > getChartModel() const;
67 
68     ::com::sun::star::uno::Reference<
69         ::com::sun::star::chart2::XChartDocument > getChart2Document() const;
70     ::com::sun::star::uno::Reference<
71         ::com::sun::star::chart2::XDiagram > getChart2Diagram() const;
72 
73     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > getDrawPage();
74 
75     /** get the current values calculated for an axis in the current view in
76         case properties are 'auto'.
77      */
78     sal_Bool getExplicitValuesForAxis(
79         const ::com::sun::star::uno::Reference<
80             ::com::sun::star::chart2::XAxis > & xAxis,
81         ExplicitScaleData &  rOutExplicitScale,
82         ExplicitIncrementData & rOutExplicitIncrement );
83 
84     sal_Int32 getExplicitNumberFormatKeyForAxis(
85             const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis );
86 
87     sal_Int32 getExplicitNumberFormatKeyForSeries(
88             const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& xSeries );
89 
90     /** Returns the size of the page in logic coordinates.  This value is used
91         for setting an appropriate "ReferencePageSize" for FontHeights.
92      */
93     ::com::sun::star::awt::Size GetPageSize() const;
94 
95     /** calculates the current axes title sizes and substract that space them from the given recangle
96      */
97     ::com::sun::star::awt::Rectangle SubstractAxisTitleSizes( const ::com::sun::star::awt::Rectangle& rPositionRect );
98 
99     /** Returns the position and size of the diagram in logic coordinates (100th mm) including
100         the space used for axes including axes titles.
101      */
102     ::com::sun::star::awt::Rectangle GetDiagramRectangleIncludingTitle() const;
103 
104     /** Returns the position and size of the diagram in logic coordinates (100th mm) including
105         the space used for axes excluding axes titles.
106      */
107     ::com::sun::star::awt::Rectangle GetDiagramRectangleIncludingAxes() const;
108 
109     /** Returns the position and size of the diagram in logic coordinates (100th mm) excluding
110         the space used for axes (inner plot area).
111      */
112     ::com::sun::star::awt::Rectangle GetDiagramRectangleExcludingAxes() const;
113 
114     /** Returns the size of the object in logic coordinates.
115      */
116     ::com::sun::star::awt::Size GetLegendSize() const;
117 
118     /** Returns the position of the object in logic coordinates.
119      */
120     ::com::sun::star::awt::Point GetLegendPosition() const;
121 
122     /** Returns the size of the object in logic coordinates.
123      */
124     ::com::sun::star::awt::Size GetTitleSize( const ::com::sun::star::uno::Reference<
125                       ::com::sun::star::chart2::XTitle > & xTitle ) const;
126 
127     /** Returns the position of the object in logic coordinates.
128      */
129     ::com::sun::star::awt::Point GetTitlePosition( const ::com::sun::star::uno::Reference<
130                       ::com::sun::star::chart2::XTitle > & xTitle ) const;
131 
132 
133     /** Returns the size of the object in logic coordinates.
134      */
135     ::com::sun::star::awt::Size GetAxisSize( const ::com::sun::star::uno::Reference<
136                       ::com::sun::star::chart2::XAxis > & xAxis ) const;
137 
138     /** Returns the position of the object in logic coordinates.
139      */
140     ::com::sun::star::awt::Point GetAxisPosition( const ::com::sun::star::uno::Reference<
141                       ::com::sun::star::chart2::XAxis > & xAxis ) const;
142 
143 private: //methods
144     ExplicitValueProvider* getExplicitValueProvider() const;
145     ::com::sun::star::uno::Reference<
146         ::com::sun::star::lang::XUnoTunnel > getChartView() const;
147 
148 public: //member
149     ::com::sun::star::uno::Reference<
150         ::com::sun::star::uno::XComponentContext >
151                         m_xContext;
152 
153 private: //member
154 	::com::sun::star::uno::WeakReference<
155         ::com::sun::star::frame::XModel >   m_xChartModel;
156 
157     mutable ::com::sun::star::uno::Reference<
158         ::com::sun::star::lang::XUnoTunnel >        m_xChartView;
159 
160     typedef std::map< ::rtl::OUString, ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > > tTableMap;//GradientTable, HatchTable etc.
161     tTableMap   m_aTableMap;
162 };
163 
164 } //  namespace wrapper
165 } //  namespace chart
166 
167 // CHART_CHART2MODELCONTACT_HXX
168 #endif
169