Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / chart2 / inc / ChartView.hxx
blob5ae3930ebd0104d164f6670d0b38b3c9c73c2f83
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_CHART2_INC_CHARTVIEW_HXX
20 #define INCLUDED_CHART2_INC_CHARTVIEW_HXX
22 #include <chartview/ExplicitValueProvider.hxx>
23 #include <cppuhelper/implbase.hxx>
24 #include <cppuhelper/interfacecontainer.h>
26 #include <svl/lstner.hxx>
27 #include <com/sun/star/awt/Size.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/datatransfer/XTransferable.hpp>
30 #include <com/sun/star/lang/XInitialization.hpp>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/lang/XUnoTunnel.hpp>
34 #include <com/sun/star/qa/XDumper.hpp>
35 #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
36 #include <com/sun/star/util/XModifyListener.hpp>
37 #include <com/sun/star/util/XUpdatable2.hpp>
39 #include <vector>
40 #include <memory>
42 #include <vcl/timer.hxx>
44 namespace com { namespace sun { namespace star { namespace drawing { class XDrawPage; } } } }
45 namespace com { namespace sun { namespace star { namespace drawing { class XShapes; } } } }
46 namespace com { namespace sun { namespace star { namespace io { class XOutputStream; } } } }
47 namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } } } }
48 namespace com { namespace sun { namespace star { namespace util { class XUpdatable2; } } } }
50 class SdrPage;
52 namespace chart {
54 class VCoordinateSystem;
55 class DrawModelWrapper;
56 class VDataSeries;
57 struct CreateShapeParam2D;
59 struct TimeBasedInfo
61 TimeBasedInfo():
62 bTimeBased(false),
63 nFrame(0) {}
65 bool bTimeBased;
66 size_t nFrame;
67 Timer maTimer;
69 // only valid when we are in the time based mode
70 std::vector< std::vector< VDataSeries* > > m_aDataSeriesList;
73 /**
74 * The ChartView is responsible to manage the generation of Drawing Objects
75 * for visualization on a given OutputDevice. The ChartModel is responsible
76 * to notify changes to the view. The view than changes to state dirty. The
77 * view can be updated with call 'update'.
79 * The View is not responsible to handle single user events (that is instead
80 * done by the ChartWindow).
82 class ChartView : public ::cppu::WeakImplHelper<
83 css::lang::XInitialization
84 ,css::lang::XServiceInfo
85 ,css::datatransfer::XTransferable
86 ,css::lang::XUnoTunnel
87 ,css::util::XModifyListener
88 ,css::util::XModeChangeBroadcaster
89 ,css::util::XUpdatable2
90 ,css::beans::XPropertySet
91 ,css::lang::XMultiServiceFactory
92 ,css::qa::XDumper
94 , public ExplicitValueProvider
95 , private SfxListener
97 private:
98 void init();
100 public:
101 ChartView() = delete;
102 ChartView(css::uno::Reference< css::uno::XComponentContext > const & xContext,
103 ChartModel& rModel);
105 virtual ~ChartView() override;
107 // ___lang::XServiceInfo___
108 virtual OUString SAL_CALL getImplementationName() override;
109 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
110 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
112 // ___lang::XInitialization___
113 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
115 // ___ExplicitValueProvider___
116 virtual bool getExplicitValuesForAxis(
117 css::uno::Reference< css::chart2::XAxis > xAxis
118 , ExplicitScaleData& rExplicitScale
119 , ExplicitIncrementData& rExplicitIncrement ) override;
120 virtual css::uno::Reference< css::drawing::XShape >
121 getShapeForCID( const OUString& rObjectCID ) override;
123 virtual css::awt::Rectangle getRectangleOfObject( const OUString& rObjectCID, bool bSnapRect=false ) override;
125 virtual css::awt::Rectangle getDiagramRectangleExcludingAxes() override;
127 std::shared_ptr< DrawModelWrapper > getDrawModelWrapper() override;
129 // ___XTransferable___
130 virtual css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override;
131 virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) override;
132 virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override;
134 // css::util::XEventListener (base of XCloseListener and XModifyListener)
135 virtual void SAL_CALL
136 disposing( const css::lang::EventObject& Source ) override;
138 // css::util::XModifyListener
139 virtual void SAL_CALL modified(
140 const css::lang::EventObject& aEvent ) override;
142 //SfxListener
143 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
145 // css::util::XModeChangeBroadcaster
147 virtual void SAL_CALL addModeChangeListener( const css::uno::Reference< css::util::XModeChangeListener >& _rxListener ) override;
148 virtual void SAL_CALL removeModeChangeListener( const css::uno::Reference< css::util::XModeChangeListener >& _rxListener ) override;
149 virtual void SAL_CALL addModeChangeApproveListener( const css::uno::Reference< css::util::XModeChangeApproveListener >& _rxListener ) override;
150 virtual void SAL_CALL removeModeChangeApproveListener( const css::uno::Reference< css::util::XModeChangeApproveListener >& _rxListener ) override;
152 // css::util::XUpdatable
153 virtual void SAL_CALL update() override;
155 // util::XUpdatable2
156 virtual void SAL_CALL updateSoft() override;
157 virtual void SAL_CALL updateHard() override;
159 // css::beans::XPropertySet
160 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
161 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
162 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
163 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
164 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
165 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
166 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
168 // css::lang::XMultiServiceFactory
169 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override;
170 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(
171 const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) override;
172 virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override;
174 // for ExplicitValueProvider
175 // ____ XUnoTunnel ___
176 virtual ::sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< ::sal_Int8 >& aIdentifier ) override;
178 // XDumper
179 virtual OUString SAL_CALL dump() override;
181 void setViewDirty();
183 private: //methods
184 void createShapes();
185 void createShapes2D( const css::awt::Size& rPageSize );
186 bool createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css::awt::Size& rPageSize );
187 void getMetaFile( const css::uno::Reference< css::io::XOutputStream >& xOutStream
188 , bool bUseHighContrast );
189 SdrPage* getSdrPage();
191 void impl_deleteCoordinateSystems();
192 void impl_notifyModeChangeListener( const OUString& rNewMode );
194 void impl_refreshAddIn();
196 void impl_updateView( bool bCheckLockedCtrler = true );
198 css::awt::Rectangle impl_createDiagramAndContent( const CreateShapeParam2D& rParam, const css::awt::Size& rPageSize );
200 DECL_LINK( UpdateTimeBased, Timer*, void );
202 private: //member
203 ::osl::Mutex m_aMutex;
205 css::uno::Reference< css::uno::XComponentContext>
206 m_xCC;
208 chart::ChartModel& mrChartModel;
210 css::uno::Reference< css::lang::XMultiServiceFactory>
211 m_xShapeFactory;
212 css::uno::Reference< css::drawing::XDrawPage>
213 m_xDrawPage;
214 css::uno::Reference< css::drawing::XShapes >
215 mxRootShape;
217 css::uno::Reference< css::uno::XInterface > m_xDashTable;
218 css::uno::Reference< css::uno::XInterface > m_xGradientTable;
219 css::uno::Reference< css::uno::XInterface > m_xHatchTable;
220 css::uno::Reference< css::uno::XInterface > m_xBitmapTable;
221 css::uno::Reference< css::uno::XInterface > m_xTransGradientTable;
222 css::uno::Reference< css::uno::XInterface > m_xMarkerTable;
224 std::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper;
226 std::vector< std::unique_ptr<VCoordinateSystem> > m_aVCooSysList;
228 ::cppu::OMultiTypeInterfaceContainerHelper
229 m_aListenerContainer;
231 bool m_bViewDirty; //states whether the view needs to be rebuild
232 bool m_bInViewUpdate;
233 bool m_bViewUpdatePending;
234 bool m_bRefreshAddIn;
236 //better performance for big data
237 css::awt::Size m_aPageResolution;
238 bool m_bPointsWereSkipped;
240 //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100%
241 sal_Int32 m_nScaleXNumerator;
242 sal_Int32 m_nScaleXDenominator;
243 sal_Int32 m_nScaleYNumerator;
244 sal_Int32 m_nScaleYDenominator;
246 bool m_bSdrViewIsInEditMode;
248 css::awt::Rectangle m_aResultingDiagramRectangleExcludingAxes;
250 TimeBasedInfo maTimeBased;
251 osl::Mutex maTimeMutex;
256 #endif
258 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */