1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #pragma once
20 
21 #include <cppuhelper/weakref.hxx>
22 #include <com/sun/star/awt/Size.hpp>
23 #include <com/sun/star/awt/Point.hpp>
24 #include <com/sun/star/awt/Rectangle.hpp>
25 
26 #include <map>
27 
28 namespace chart { struct ExplicitIncrementData; }
29 namespace chart { struct ExplicitScaleData; }
30 namespace com::sun::star::chart2 { class XAxis; }
31 namespace com::sun::star::chart2 { class XChartDocument; }
32 namespace com::sun::star::chart2 { class XDataSeries; }
33 namespace com::sun::star::chart2 { class XDiagram; }
34 namespace com::sun::star::chart2 { class XTitle; }
35 namespace com::sun::star::container { class XNameContainer; }
36 namespace com::sun::star::drawing { class XDrawPage; }
37 namespace com::sun::star::frame { class XModel; }
38 namespace com::sun::star::lang { class XUnoTunnel; }
39 namespace com::sun::star::uno { class XComponentContext; }
40 
41 
42 namespace chart
43 {
44 class ExplicitValueProvider;
45 class ChartModel;
46 
47 namespace wrapper
48 {
49 
50 class Chart2ModelContact final
51 {
52 public:
53     explicit Chart2ModelContact( const css::uno::Reference< css::uno::XComponentContext >& xContext );
54     ~Chart2ModelContact();
55 
56 public:
57     void setModel( const css::uno::Reference< css::frame::XModel >& xChartModel );
58     void clear();
59 
60     css::uno::Reference< css::frame::XModel > getChartModel() const;
61 
getModel() const62     ChartModel* getModel() const { return mpModel;}
63 
64     css::uno::Reference< css::chart2::XChartDocument > getChart2Document() const;
65     css::uno::Reference< css::chart2::XDiagram > getChart2Diagram() const;
66 
67     css::uno::Reference< css::drawing::XDrawPage > getDrawPage() const;
68 
69     /** get the current values calculated for an axis in the current view in
70         case properties are 'auto'.
71      */
72     void getExplicitValuesForAxis(
73         const css::uno::Reference< css::chart2::XAxis > & xAxis,
74         ExplicitScaleData &  rOutExplicitScale,
75         ExplicitIncrementData & rOutExplicitIncrement );
76 
77     sal_Int32 getExplicitNumberFormatKeyForAxis(
78             const css::uno::Reference< css::chart2::XAxis >& xAxis );
79 
80     static sal_Int32 getExplicitNumberFormatKeyForSeries(
81             const css::uno::Reference< css::chart2::XDataSeries >& xSeries );
82 
83     /** Returns the size of the page in logic coordinates.  This value is used
84         for setting an appropriate "ReferencePageSize" for FontHeights.
85      */
86     css::awt::Size GetPageSize() const;
87 
88     /** calculates the current axes title sizes and subtract that space them from the given rectangle
89      */
90     css::awt::Rectangle SubstractAxisTitleSizes( const css::awt::Rectangle& rPositionRect );
91 
92     /** Returns the position and size of the diagram in logic coordinates (100th mm) including
93         the space used for axes including axes titles.
94      */
95     css::awt::Rectangle GetDiagramRectangleIncludingTitle() const;
96 
97     /** Returns the position and size of the diagram in logic coordinates (100th mm) including
98         the space used for axes excluding axes titles.
99      */
100     css::awt::Rectangle GetDiagramRectangleIncludingAxes() const;
101 
102     /** Returns the position and size of the diagram in logic coordinates (100th mm) excluding
103         the space used for axes (inner plot area).
104      */
105     css::awt::Rectangle GetDiagramRectangleExcludingAxes() const;
106 
107     /** Returns the size of the object in logic coordinates.
108      */
109     css::awt::Size GetLegendSize() const;
110 
111     /** Returns the position of the object in logic coordinates.
112      */
113     css::awt::Point GetLegendPosition() const;
114 
115     /** Returns the size of the object in logic coordinates.
116      */
117     css::awt::Size GetTitleSize( const css::uno::Reference< css::chart2::XTitle > & xTitle ) const;
118 
119     /** Returns the position of the object in logic coordinates.
120      */
121     css::awt::Point GetTitlePosition( const css::uno::Reference< css::chart2::XTitle > & xTitle ) const;
122 
123     /** Returns the size of the object in logic coordinates.
124      */
125     css::awt::Size GetAxisSize( const css::uno::Reference< css::chart2::XAxis > & xAxis ) const;
126 
127     /** Returns the position of the object in logic coordinates.
128      */
129     css::awt::Point GetAxisPosition( const css::uno::Reference< css::chart2::XAxis > & xAxis ) const;
130 
131 private: //methods
132     ExplicitValueProvider* getExplicitValueProvider() const;
133     css::uno::Reference< css::lang::XUnoTunnel > const & getChartView() const;
134 
135 public: //member
136     css::uno::Reference< css::uno::XComponentContext >  m_xContext;
137 
138 private: //member
139     css::uno::WeakReference< css::frame::XModel >   m_xChartModel;
140 
141     ChartModel* mpModel;
142 
143     mutable css::uno::Reference< css::lang::XUnoTunnel > m_xChartView;
144 
145     std::map< OUString, css::uno::Reference< css::container::XNameContainer > > m_aTableMap;
146 };
147 
148 } //  namespace wrapper
149 } //  namespace chart
150 
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
152