LibreOffice Module chart2 (master) 1
ChartView.hxx
Go to the documentation of this file.
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
24
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>
40
41#include <vector>
42#include <memory>
43#include <mutex>
44
45#include <vcl/timer.hxx>
46
47namespace com::sun::star::drawing { class XDrawPage; }
48namespace com::sun::star::drawing { class XShapes; }
49namespace com::sun::star::io { class XOutputStream; }
50namespace com::sun::star::uno { class XComponentContext; }
51namespace com::sun::star::util { class XUpdatable2; }
52
53class SdrPage;
54
55namespace chart {
56
57class VCoordinateSystem;
58class DrawModelWrapper;
59class VDataSeries;
60struct CreateShapeParam2D;
61
63{
65 bTimeBased(false),
66 nFrame(0) {}
67
69 size_t nFrame;
70 Timer maTimer { "chart2 TimeBasedInfo" };
71
72 // only valid when we are in the time based mode
73 std::vector< std::vector< VDataSeries* > > m_aDataSeriesList;
74};
75
85class 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
94 ,css::qa::XDumper
95 >
96 , public ExplicitValueProvider
97 , private SfxListener
98{
99private:
100 void init();
101
102public:
103 ChartView() = delete;
104 ChartView(css::uno::Reference<css::uno::XComponentContext> xContext, ChartModel& rModel);
105
106 virtual ~ChartView() override;
107
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;
112
113 // ___lang::XInitialization___
114 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
115
116 // ___ExplicitValueProvider___
117 virtual bool getExplicitValuesForAxis(
119 , ExplicitScaleData& rExplicitScale
120 , ExplicitIncrementData& rExplicitIncrement ) override;
122 getShapeForCID( const OUString& rObjectCID ) override;
123
124 virtual css::awt::Rectangle getRectangleOfObject( const OUString& rObjectCID, bool bSnapRect=false ) override;
125
126 virtual css::awt::Rectangle getDiagramRectangleExcludingAxes() override;
127
128 std::shared_ptr< DrawModelWrapper > getDrawModelWrapper() override;
129
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;
134
135 // css::util::XEventListener (base of XCloseListener and XModifyListener)
136 virtual void SAL_CALL
137 disposing( const css::lang::EventObject& Source ) override;
138
139 // css::util::XModifyListener
140 virtual void SAL_CALL modified(
141 const css::lang::EventObject& aEvent ) override;
142
143 //SfxListener
144 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
145
146 // css::util::XModeChangeBroadcaster
147
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;
152
153 // css::util::XUpdatable
154 virtual void SAL_CALL update() override;
155
156 // util::XUpdatable2
157 virtual void SAL_CALL updateSoft() override;
158 virtual void SAL_CALL updateHard() override;
159
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;
168
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;
174
175 // XDumper
176 virtual OUString SAL_CALL dump(OUString const & kind) override;
177
178 void setViewDirty();
179
180 css::uno::Reference<css::uno::XComponentContext> const& getComponentContext() { return m_xCC;}
181
182 void dumpAsXml(xmlTextWriterPtr pWriter) const;
183
184private: //methods
185 void createShapes();
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();
191
192 void impl_deleteCoordinateSystems();
193 void impl_notifyModeChangeListener( const OUString& rNewMode );
194
195 void impl_refreshAddIn();
196
197 void impl_updateView( bool bCheckLockedCtrler = true );
198
199 css::awt::Rectangle impl_createDiagramAndContent( const CreateShapeParam2D& rParam, const css::awt::Size& rPageSize );
200
201 DECL_LINK( UpdateTimeBased, Timer*, void );
202
203private: //member
204 std::mutex m_aMutex;
205
206 css::uno::Reference< css::uno::XComponentContext> m_xCC;
207
208 chart::ChartModel& mrChartModel;
209
210 css::uno::Reference< css::lang::XMultiServiceFactory>
216
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;
223
224 std::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper;
225
226 std::vector< std::unique_ptr<VCoordinateSystem> > m_aVCooSysList;
227
230
231 bool m_bViewDirty; //states whether the view needs to be rebuild
235
236 //better performance for big data
237 css::awt::Size m_aPageResolution;
239
240 //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100%
245
247
249
251 std::mutex maTimeMutex;
252};
253
254}
255
256/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
FILE * init(int, char **)
#define OOO_DLLPUBLIC_CHARTVIEW
The ChartView is responsible to manage the generation of Drawing Objects for visualization on a given...
Definition: ChartView.hxx:98
ChartView(css::uno::Reference< css::uno::XComponentContext > xContext, ChartModel &rModel)
DECL_LINK(UpdateTimeBased, Timer *, void)
comphelper::OInterfaceContainerHelper4< css::util::XModeChangeListener > m_aModeChangeListeners
Definition: ChartView.hxx:229
chart::ChartModel & mrChartModel
Definition: ChartView.hxx:208
bool m_bViewUpdatePending
Definition: ChartView.hxx:233
rtl::Reference< SvxShapeGroupAnyD > mxRootShape
Definition: ChartView.hxx:215
css::awt::Size m_aPageResolution
Definition: ChartView.hxx:237
sal_Int32 m_nScaleYDenominator
Definition: ChartView.hxx:244
std::mutex m_aMutex
Definition: ChartView.hxx:204
css::awt::Rectangle m_aResultingDiagramRectangleExcludingAxes
Definition: ChartView.hxx:248
sal_Int32 m_nScaleXNumerator
Definition: ChartView.hxx:241
css::uno::Reference< css::lang::XMultiServiceFactory > m_xShapeFactory
Definition: ChartView.hxx:211
css::uno::Reference< css::uno::XComponentContext > const & getComponentContext()
Definition: ChartView.hxx:180
css::uno::Reference< css::uno::XInterface > m_xHatchTable
Definition: ChartView.hxx:219
css::uno::Reference< css::uno::XInterface > m_xGradientTable
Definition: ChartView.hxx:218
bool m_bPointsWereSkipped
Definition: ChartView.hxx:238
sal_Int32 m_nScaleXDenominator
Definition: ChartView.hxx:242
css::uno::Reference< css::uno::XInterface > m_xMarkerTable
Definition: ChartView.hxx:222
std::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper
Definition: ChartView.hxx:224
css::uno::Reference< css::uno::XComponentContext > m_xCC
Definition: ChartView.hxx:206
css::uno::Reference< css::uno::XInterface > m_xBitmapTable
Definition: ChartView.hxx:220
std::mutex maTimeMutex
Definition: ChartView.hxx:251
bool m_bSdrViewIsInEditMode
Definition: ChartView.hxx:246
css::uno::Reference< css::uno::XInterface > m_xTransGradientTable
Definition: ChartView.hxx:221
std::vector< std::unique_ptr< VCoordinateSystem > > m_aVCooSysList
Definition: ChartView.hxx:226
TimeBasedInfo maTimeBased
Definition: ChartView.hxx:250
rtl::Reference< SvxDrawPage > m_xDrawPage
Definition: ChartView.hxx:213
sal_Int32 m_nScaleYNumerator
Definition: ChartView.hxx:243
ChartView()=delete
css::uno::Reference< css::uno::XInterface > m_xDashTable
Definition: ChartView.hxx:217
struct _xmlTextWriter * xmlTextWriterPtr
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
VCL_DLLPUBLIC void dump(const SkBitmap &bitmap, const char *file)
void setPropertyValue(tPropertyValueMap &rOutMap, tPropertyValueMapKey key, const Value &value)
Set a property to a certain value in the given map.
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
GDIMetaFileSharedPtr getMetaFile(const uno::Reference< lang::XComponent > &xSource, const uno::Reference< drawing::XDrawPage > &xContainingPage, int mtfLoadFlags, const uno::Reference< uno::XComponentContext > &rxContext)
describes how tickmarks are positioned on the scale of an axis.
This structure contains the explicit values for a scale like Minimum and Maximum.
std::vector< std::vector< VDataSeries * > > m_aDataSeriesList
Definition: ChartView.hxx:73
unsigned char sal_Bool
bool update()