1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <chartview/ExplicitValueProvider.hxx>
22 #include <cppuhelper/implbase.hxx>
23 #include <comphelper/interfacecontainer4.hxx>
25 #include <svl/lstner.hxx>
26 #include <com/sun/star/awt/Size.hpp>
27 #include <com/sun/star/awt/Rectangle.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/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>
37 #include <rtl/ref.hxx>
38 #include <svx/unopage.hxx>
39 #include <svx/unoshape.hxx>
45 #include <vcl/timer.hxx>
47 namespace com::sun::star::drawing
{ class XDrawPage
; }
48 namespace com::sun::star::drawing
{ class XShapes
; }
49 namespace com::sun::star::io
{ class XOutputStream
; }
50 namespace com::sun::star::uno
{ class XComponentContext
; }
51 namespace com::sun::star::util
{ class XUpdatable2
; }
57 class VCoordinateSystem
;
58 class DrawModelWrapper
;
60 struct CreateShapeParam2D
;
70 Timer maTimer
{ "chart2 TimeBasedInfo" };
72 // only valid when we are in the time based mode
73 std::vector
< std::vector
< VDataSeries
* > > m_aDataSeriesList
;
77 * The ChartView is responsible to manage the generation of Drawing Objects
78 * for visualization on a given OutputDevice. The ChartModel is responsible
79 * to notify changes to the view. The view than changes to state dirty. The
80 * view can be updated with call 'update'.
82 * The View is not responsible to handle single user events (that is instead
83 * done by the ChartWindow).
85 class UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTVIEW
) ChartView final
: public ::cppu::WeakImplHelper
<
86 css::lang::XInitialization
87 ,css::lang::XServiceInfo
88 ,css::datatransfer::XTransferable
89 ,css::util::XModifyListener
90 ,css::util::XModeChangeBroadcaster
91 ,css::util::XUpdatable2
92 ,css::beans::XPropertySet
93 ,css::lang::XMultiServiceFactory
96 , public ExplicitValueProvider
103 ChartView() = delete;
104 ChartView(css::uno::Reference
<css::uno::XComponentContext
> xContext
, 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 rtl::Reference
< Axis
> xAxis
119 , ExplicitScaleData
& rExplicitScale
120 , ExplicitIncrementData
& rExplicitIncrement
) override
;
121 virtual rtl::Reference
< SvxShape
>
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
;
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
;
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
;
176 virtual OUString SAL_CALL
dump(OUString
const & kind
) override
;
180 css::uno::Reference
<css::uno::XComponentContext
> const& getComponentContext() { return m_xCC
;}
182 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
186 void createShapes2D( const css::awt::Size
& rPageSize
);
187 bool createAxisTitleShapes2D( CreateShapeParam2D
& rParam
, const css::awt::Size
& rPageSize
, bool bHasRelativeSize
);
188 void getMetaFile( const css::uno::Reference
< css::io::XOutputStream
>& xOutStream
189 , bool bUseHighContrast
);
190 SdrPage
* getSdrPage();
192 void impl_deleteCoordinateSystems();
193 void impl_notifyModeChangeListener( const OUString
& rNewMode
);
195 void impl_refreshAddIn();
197 void impl_updateView( bool bCheckLockedCtrler
= true );
199 css::awt::Rectangle
impl_createDiagramAndContent( const CreateShapeParam2D
& rParam
, const css::awt::Size
& rPageSize
);
201 DECL_LINK( UpdateTimeBased
, Timer
*, void );
206 css::uno::Reference
< css::uno::XComponentContext
> m_xCC
;
208 ChartModel
& mrChartModel
;
210 css::uno::Reference
< css::lang::XMultiServiceFactory
>
212 rtl::Reference
<SvxDrawPage
>
214 rtl::Reference
<SvxShapeGroupAnyD
>
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 comphelper::OInterfaceContainerHelper4
<css::util::XModeChangeListener
>
229 m_aModeChangeListeners
;
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 std::mutex maTimeMutex
;
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */