/src/libreoffice/chart2/inc/ChartView.hxx
Line | Count | Source |
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/implbase.hxx> |
22 | | #include <comphelper/interfacecontainer4.hxx> |
23 | | |
24 | | #include <svl/lstner.hxx> |
25 | | #include <com/sun/star/awt/Size.hpp> |
26 | | #include <com/sun/star/awt/Rectangle.hpp> |
27 | | #include <com/sun/star/beans/XPropertySet.hpp> |
28 | | #include <com/sun/star/datatransfer/XTransferable.hpp> |
29 | | #include <com/sun/star/lang/XInitialization.hpp> |
30 | | #include <com/sun/star/lang/XMultiServiceFactory.hpp> |
31 | | #include <com/sun/star/lang/XServiceInfo.hpp> |
32 | | #include <com/sun/star/qa/XDumper.hpp> |
33 | | #include <com/sun/star/util/XModeChangeBroadcaster.hpp> |
34 | | #include <com/sun/star/util/XModifyListener.hpp> |
35 | | #include <com/sun/star/util/XUpdatable2.hpp> |
36 | | #include <rtl/ref.hxx> |
37 | | #include <svx/unopage.hxx> |
38 | | #include <svx/unoshape.hxx> |
39 | | |
40 | | #include <vector> |
41 | | #include <memory> |
42 | | #include <mutex> |
43 | | |
44 | | #include <vcl/timer.hxx> |
45 | | |
46 | | namespace com::sun::star::io { class XOutputStream; } |
47 | | namespace com::sun::star::uno { class XComponentContext; } |
48 | | namespace com::sun::star::util { class XUpdatable2; } |
49 | | namespace com::sun::star::util { class XNumberFormatsSupplier; } |
50 | | |
51 | | class SdrPage; |
52 | | |
53 | | namespace chart { |
54 | | |
55 | | class Axis; |
56 | | class BaseCoordinateSystem; |
57 | | class ChartModel; |
58 | | struct CreateShapeParam2D; |
59 | | class DrawModelWrapper; |
60 | | struct ExplicitIncrementData; |
61 | | struct ExplicitScaleData; |
62 | | class VCoordinateSystem; |
63 | | class VDataSeries; |
64 | | |
65 | | struct TimeBasedInfo |
66 | | { |
67 | | TimeBasedInfo(): |
68 | 0 | bTimeBased(false), |
69 | 0 | nFrame(0) {} |
70 | | |
71 | | bool bTimeBased; |
72 | | size_t nFrame; |
73 | | Timer maTimer { "chart2 TimeBasedInfo" }; |
74 | | |
75 | | // only valid when we are in the time based mode |
76 | | std::vector< std::vector< VDataSeries* > > m_aDataSeriesList; |
77 | | }; |
78 | | |
79 | | /** |
80 | | * The ChartView is responsible to manage the generation of Drawing Objects |
81 | | * for visualization on a given OutputDevice. The ChartModel is responsible |
82 | | * to notify changes to the view. The view than changes to state dirty. The |
83 | | * view can be updated with call 'update'. |
84 | | * |
85 | | * The View is not responsible to handle single user events (that is instead |
86 | | * done by the ChartWindow). |
87 | | */ |
88 | | class ChartView final : public ::cppu::WeakImplHelper< |
89 | | css::lang::XInitialization |
90 | | ,css::lang::XServiceInfo |
91 | | ,css::datatransfer::XTransferable |
92 | | ,css::util::XModifyListener |
93 | | ,css::util::XModeChangeBroadcaster |
94 | | ,css::util::XUpdatable2 |
95 | | ,css::beans::XPropertySet |
96 | | ,css::lang::XMultiServiceFactory |
97 | | ,css::qa::XDumper |
98 | | > |
99 | | , private SfxListener |
100 | | { |
101 | | private: |
102 | | void init(); |
103 | | |
104 | | public: |
105 | | ChartView() = delete; |
106 | | ChartView(css::uno::Reference<css::uno::XComponentContext> xContext, ChartModel& rModel); |
107 | | |
108 | | virtual ~ChartView() override; |
109 | | |
110 | | // ___lang::XServiceInfo___ |
111 | | virtual OUString SAL_CALL getImplementationName() override; |
112 | | virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; |
113 | | virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
114 | | |
115 | | // ___lang::XInitialization___ |
116 | | virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; |
117 | | |
118 | | /** Gives calculated scale and increment values for a given xAxis in the current view. |
119 | | In contrast to the model data these explicit values are always complete as missing auto properties are calculated. |
120 | | If the given Axis could not be found or for another reason no correct output can be given false is returned. |
121 | | */ |
122 | | bool getExplicitValuesForAxis( |
123 | | const rtl::Reference< Axis > & xAxis |
124 | | , ExplicitScaleData& rExplicitScale |
125 | | , ExplicitIncrementData& rExplicitIncrement ); |
126 | | rtl::Reference< SvxShape > |
127 | | getShapeForCID( const OUString& rObjectCID ); |
128 | | |
129 | | /** for rotated objects the shape size and position differs from the visible rectangle |
130 | | if bSnapRect is set to true you get the resulting visible position (left-top) and size |
131 | | */ |
132 | | css::awt::Rectangle getRectangleOfObject( const OUString& rObjectCID, bool bSnapRect=false ); |
133 | | |
134 | | const css::awt::Rectangle & getDiagramRectangleExcludingAxes(); |
135 | | |
136 | | const std::shared_ptr< DrawModelWrapper > & getDrawModelWrapper(); |
137 | | |
138 | | // ___XTransferable___ |
139 | | virtual css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override; |
140 | | virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) override; |
141 | | virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override; |
142 | | |
143 | | // css::util::XEventListener (base of XCloseListener and XModifyListener) |
144 | | virtual void SAL_CALL |
145 | | disposing( const css::lang::EventObject& Source ) override; |
146 | | |
147 | | // css::util::XModifyListener |
148 | | virtual void SAL_CALL modified( |
149 | | const css::lang::EventObject& aEvent ) override; |
150 | | |
151 | | //SfxListener |
152 | | virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; |
153 | | |
154 | | // css::util::XModeChangeBroadcaster |
155 | | |
156 | | virtual void SAL_CALL addModeChangeListener( const css::uno::Reference< css::util::XModeChangeListener >& _rxListener ) override; |
157 | | virtual void SAL_CALL removeModeChangeListener( const css::uno::Reference< css::util::XModeChangeListener >& _rxListener ) override; |
158 | | virtual void SAL_CALL addModeChangeApproveListener( const css::uno::Reference< css::util::XModeChangeApproveListener >& _rxListener ) override; |
159 | | virtual void SAL_CALL removeModeChangeApproveListener( const css::uno::Reference< css::util::XModeChangeApproveListener >& _rxListener ) override; |
160 | | |
161 | | // css::util::XUpdatable |
162 | | virtual void SAL_CALL update() override; |
163 | | |
164 | | // util::XUpdatable2 |
165 | | virtual void SAL_CALL updateSoft() override; |
166 | | virtual void SAL_CALL updateHard() override; |
167 | | |
168 | | // css::beans::XPropertySet |
169 | | virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; |
170 | | virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; |
171 | | virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; |
172 | | virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; |
173 | | virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; |
174 | | virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; |
175 | | virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; |
176 | | |
177 | | // css::lang::XMultiServiceFactory |
178 | | virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override; |
179 | | virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( |
180 | | const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) override; |
181 | | virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override; |
182 | | |
183 | | // XDumper |
184 | | virtual OUString SAL_CALL dump(OUString const & kind) override; |
185 | | |
186 | | void setViewDirty(); |
187 | | |
188 | 0 | css::uno::Reference<css::uno::XComponentContext> const& getComponentContext() { return m_xCC;} |
189 | | |
190 | | void dumpAsXml(xmlTextWriterPtr pWriter) const; |
191 | | |
192 | | static css::awt::Rectangle |
193 | | AddSubtractAxisTitleSizes( |
194 | | ChartModel& rModel |
195 | | , ChartView* pChartView |
196 | | , const css::awt::Rectangle& rPositionAndSize, bool bSubtract ); |
197 | | |
198 | | static sal_Int32 getExplicitNumberFormatKeyForAxis( |
199 | | const rtl::Reference< ::chart::Axis >& xAxis |
200 | | , const rtl::Reference< ::chart::BaseCoordinateSystem > & xCorrespondingCoordinateSystem |
201 | | , const rtl::Reference<::chart::ChartModel>& xChartDoc); |
202 | | |
203 | | static sal_Int32 getExplicitPercentageNumberFormatKeyForDataLabel( |
204 | | const css::uno::Reference< css::beans::XPropertySet >& xSeriesOrPointProp |
205 | | , const css::uno::Reference< css::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); |
206 | | |
207 | | private: //methods |
208 | | void createShapes(); |
209 | | void createShapes2D( const css::awt::Size& rPageSize ); |
210 | | bool createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css::awt::Size& rPageSize, bool bHasRelativeSize ); |
211 | | void getMetaFile( const css::uno::Reference< css::io::XOutputStream >& xOutStream |
212 | | , bool bUseHighContrast ); |
213 | | SdrPage* getSdrPage(); |
214 | | |
215 | | void impl_deleteCoordinateSystems(); |
216 | | void impl_notifyModeChangeListener( const OUString& rNewMode ); |
217 | | |
218 | | void impl_refreshAddIn(); |
219 | | |
220 | | void impl_updateView( bool bCheckLockedCtrler = true ); |
221 | | |
222 | | css::awt::Rectangle impl_createDiagramAndContent( const CreateShapeParam2D& rParam, const css::awt::Size& rPageSize ); |
223 | | |
224 | | DECL_LINK( UpdateTimeBased, Timer*, void ); |
225 | | |
226 | | private: //member |
227 | | std::mutex m_aMutex; |
228 | | |
229 | | css::uno::Reference< css::uno::XComponentContext> m_xCC; |
230 | | |
231 | | ChartModel& mrChartModel; |
232 | | |
233 | | css::uno::Reference< css::lang::XMultiServiceFactory> |
234 | | m_xShapeFactory; |
235 | | rtl::Reference<SvxDrawPage> |
236 | | m_xDrawPage; |
237 | | rtl::Reference<SvxShapeGroupAnyD> |
238 | | mxRootShape; |
239 | | |
240 | | css::uno::Reference< css::uno::XInterface > m_xDashTable; |
241 | | css::uno::Reference< css::uno::XInterface > m_xGradientTable; |
242 | | css::uno::Reference< css::uno::XInterface > m_xHatchTable; |
243 | | css::uno::Reference< css::uno::XInterface > m_xBitmapTable; |
244 | | css::uno::Reference< css::uno::XInterface > m_xTransGradientTable; |
245 | | css::uno::Reference< css::uno::XInterface > m_xMarkerTable; |
246 | | |
247 | | std::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper; |
248 | | |
249 | | std::vector< std::unique_ptr<VCoordinateSystem> > m_aVCooSysList; |
250 | | |
251 | | comphelper::OInterfaceContainerHelper4<css::util::XModeChangeListener> |
252 | | m_aModeChangeListeners; |
253 | | |
254 | | bool m_bViewDirty; //states whether the view needs to be rebuild |
255 | | bool m_bInViewUpdate; |
256 | | bool m_bViewUpdatePending; |
257 | | bool m_bRefreshAddIn; |
258 | | |
259 | | //better performance for big data |
260 | | css::awt::Size m_aPageResolution; |
261 | | bool m_bPointsWereSkipped; |
262 | | |
263 | | //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100% |
264 | | sal_Int32 m_nScaleXNumerator; |
265 | | sal_Int32 m_nScaleXDenominator; |
266 | | sal_Int32 m_nScaleYNumerator; |
267 | | sal_Int32 m_nScaleYDenominator; |
268 | | |
269 | | bool m_bSdrViewIsInEditMode; |
270 | | |
271 | | css::awt::Rectangle m_aResultingDiagramRectangleExcludingAxes; |
272 | | |
273 | | TimeBasedInfo maTimeBased; |
274 | | std::mutex maTimeMutex; |
275 | | }; |
276 | | |
277 | | } |
278 | | |
279 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |