nss: upgrade to release 3.73
[LibreOffice.git] / chart2 / inc / ChartView.hxx
blob437d49527974fc868c01432ab18daaebb22fb48d
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 #pragma once
21 #include <chartview/ExplicitValueProvider.hxx>
22 #include <cppuhelper/implbase.hxx>
23 #include <cppuhelper/interfacecontainer.h>
25 #include <svl/lstner.hxx>
26 #include <com/sun/star/awt/Size.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/lang/XUnoTunnel.hpp>
33 #include <com/sun/star/qa/XDumper.hpp>
34 #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
35 #include <com/sun/star/util/XModifyListener.hpp>
36 #include <com/sun/star/util/XUpdatable2.hpp>
38 #include <vector>
39 #include <memory>
41 #include <vcl/timer.hxx>
42 #include <sfx2/xmldump.hxx>
44 namespace com::sun::star::drawing { class XDrawPage; }
45 namespace com::sun::star::drawing { class XShapes; }
46 namespace com::sun::star::io { class XOutputStream; }
47 namespace com::sun::star::uno { class XComponentContext; }
48 namespace com::sun::star::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 final : 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
96 , public sfx2::XmlDump
98 private:
99 void init();
101 public:
102 ChartView() = delete;
103 ChartView(css::uno::Reference< css::uno::XComponentContext > const & xContext,
104 ChartModel& rModel);
106 virtual ~ChartView() override;
108 // ___lang::XServiceInfo___
109 virtual OUString SAL_CALL getImplementationName() override;
110 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
111 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
113 // ___lang::XInitialization___
114 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
116 // ___ExplicitValueProvider___
117 virtual bool getExplicitValuesForAxis(
118 css::uno::Reference< css::chart2::XAxis > xAxis
119 , ExplicitScaleData& rExplicitScale
120 , ExplicitIncrementData& rExplicitIncrement ) override;
121 virtual css::uno::Reference< css::drawing::XShape >
122 getShapeForCID( const OUString& rObjectCID ) override;
124 virtual css::awt::Rectangle getRectangleOfObject( const OUString& rObjectCID, bool bSnapRect=false ) override;
126 virtual css::awt::Rectangle getDiagramRectangleExcludingAxes() override;
128 std::shared_ptr< DrawModelWrapper > getDrawModelWrapper() override;
130 // ___XTransferable___
131 virtual css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override;
132 virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) override;
133 virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override;
135 // css::util::XEventListener (base of XCloseListener and XModifyListener)
136 virtual void SAL_CALL
137 disposing( const css::lang::EventObject& Source ) override;
139 // css::util::XModifyListener
140 virtual void SAL_CALL modified(
141 const css::lang::EventObject& aEvent ) override;
143 //SfxListener
144 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
146 // css::util::XModeChangeBroadcaster
148 virtual void SAL_CALL addModeChangeListener( const css::uno::Reference< css::util::XModeChangeListener >& _rxListener ) override;
149 virtual void SAL_CALL removeModeChangeListener( const css::uno::Reference< css::util::XModeChangeListener >& _rxListener ) override;
150 virtual void SAL_CALL addModeChangeApproveListener( const css::uno::Reference< css::util::XModeChangeApproveListener >& _rxListener ) override;
151 virtual void SAL_CALL removeModeChangeApproveListener( const css::uno::Reference< css::util::XModeChangeApproveListener >& _rxListener ) override;
153 // css::util::XUpdatable
154 virtual void SAL_CALL update() override;
156 // util::XUpdatable2
157 virtual void SAL_CALL updateSoft() override;
158 virtual void SAL_CALL updateHard() override;
160 // css::beans::XPropertySet
161 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
162 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
163 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
164 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
165 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
166 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
167 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
169 // css::lang::XMultiServiceFactory
170 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override;
171 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(
172 const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) override;
173 virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override;
175 // for ExplicitValueProvider
176 // ____ XUnoTunnel ___
177 virtual ::sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< ::sal_Int8 >& aIdentifier ) override;
179 // XDumper
180 virtual OUString SAL_CALL dump() override;
182 void setViewDirty();
184 /// See sfx2::XmlDump::dumpAsXml().
185 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
187 private: //methods
188 void createShapes();
189 void createShapes2D( const css::awt::Size& rPageSize );
190 bool createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css::awt::Size& rPageSize, bool bHasRelativeSize );
191 void getMetaFile( const css::uno::Reference< css::io::XOutputStream >& xOutStream
192 , bool bUseHighContrast );
193 SdrPage* getSdrPage();
195 void impl_deleteCoordinateSystems();
196 void impl_notifyModeChangeListener( const OUString& rNewMode );
198 void impl_refreshAddIn();
200 void impl_updateView( bool bCheckLockedCtrler = true );
202 css::awt::Rectangle impl_createDiagramAndContent( const CreateShapeParam2D& rParam, const css::awt::Size& rPageSize );
204 DECL_LINK( UpdateTimeBased, Timer*, void );
206 private: //member
207 ::osl::Mutex m_aMutex;
209 css::uno::Reference< css::uno::XComponentContext>
210 m_xCC;
212 chart::ChartModel& mrChartModel;
214 css::uno::Reference< css::lang::XMultiServiceFactory>
215 m_xShapeFactory;
216 css::uno::Reference< css::drawing::XDrawPage>
217 m_xDrawPage;
218 css::uno::Reference< css::drawing::XShapes >
219 mxRootShape;
221 css::uno::Reference< css::uno::XInterface > m_xDashTable;
222 css::uno::Reference< css::uno::XInterface > m_xGradientTable;
223 css::uno::Reference< css::uno::XInterface > m_xHatchTable;
224 css::uno::Reference< css::uno::XInterface > m_xBitmapTable;
225 css::uno::Reference< css::uno::XInterface > m_xTransGradientTable;
226 css::uno::Reference< css::uno::XInterface > m_xMarkerTable;
228 std::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper;
230 std::vector< std::unique_ptr<VCoordinateSystem> > m_aVCooSysList;
232 ::cppu::OMultiTypeInterfaceContainerHelper
233 m_aListenerContainer;
235 bool m_bViewDirty; //states whether the view needs to be rebuild
236 bool m_bInViewUpdate;
237 bool m_bViewUpdatePending;
238 bool m_bRefreshAddIn;
240 //better performance for big data
241 css::awt::Size m_aPageResolution;
242 bool m_bPointsWereSkipped;
244 //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100%
245 sal_Int32 m_nScaleXNumerator;
246 sal_Int32 m_nScaleXDenominator;
247 sal_Int32 m_nScaleYNumerator;
248 sal_Int32 m_nScaleYDenominator;
250 bool m_bSdrViewIsInEditMode;
252 css::awt::Rectangle m_aResultingDiagramRectangleExcludingAxes;
254 TimeBasedInfo maTimeBased;
255 osl::Mutex maTimeMutex;
260 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */