xref: /AOO41X/main/chart2/source/view/main/ChartView.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _CHARTVIEWIMPL_HXX
28 #define _CHARTVIEWIMPL_HXX
29 
30 #include "chartview/ExplicitValueProvider.hxx"
31 #include "ServiceMacros.hxx"
32 #include <cppuhelper/implbase9.hxx>
33 #include <cppuhelper/interfacecontainer.hxx>
34 
35 // header for class SfxListener
36 #include <svl/lstner.hxx>
37 #include <com/sun/star/datatransfer/XTransferable.hpp>
38 #include <com/sun/star/drawing/XDrawPage.hpp>
39 #include <com/sun/star/frame/XModel.hpp>
40 #include <com/sun/star/io/XOutputStream.hpp>
41 #include <com/sun/star/lang/XInitialization.hpp>
42 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
43 #include <com/sun/star/lang/XServiceInfo.hpp>
44 #include <com/sun/star/lang/XUnoTunnel.hpp>
45 #include <com/sun/star/uno/XComponentContext.hpp>
46 #include <com/sun/star/util/XModifyListener.hpp>
47 #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
48 #include <com/sun/star/util/XUpdatable.hpp>
49 
50 #include <vector>
51 #include <boost/shared_ptr.hpp>
52 
53 class SdrPage;
54 
55 //.............................................................................
56 namespace chart
57 {
58 //.............................................................................
59 
60 class VCoordinateSystem;
61 class DrawModelWrapper;
62 class SeriesPlotterContainer;
63 
64 //-----------------------------------------------------------------------------
65 /** The ChartView is responsible to manage the generation of Drawing Objects
66 for visualization on a given OutputDevice. The ChartModel is responsible to notify changes to the view.
67 The view than changes to state dirty. The view can be updated with call 'update'.
68 
69 The View is not responsible to handle single user events (that is instead done by the ChartWindow).
70 */
71 
72 class ChartView : public ::cppu::WeakImplHelper9<
73 	::com::sun::star::lang::XInitialization
74 		, ::com::sun::star::lang::XServiceInfo
75         , ::com::sun::star::datatransfer::XTransferable
76         ,::com::sun::star::lang::XUnoTunnel
77 		//::com::sun::star::lang::XComponent ???
78 		//::com::sun::star::uno::XWeak			// implemented by WeakImplHelper(optional interface)
79 		//::com::sun::star::uno::XInterface		// implemented by WeakImplHelper(optional interface)
80 		//::com::sun::star::lang::XTypeProvider	// implemented by WeakImplHelper
81         ,::com::sun::star::util::XModifyListener
82         ,::com::sun::star::util::XModeChangeBroadcaster
83         ,::com::sun::star::util::XUpdatable
84         ,::com::sun::star::beans::XPropertySet
85         ,::com::sun::star::lang::XMultiServiceFactory
86 		>
87         , public ExplicitValueProvider
88         , private SfxListener
89 {
90 public:
91     ChartView(::com::sun::star::uno::Reference<
92 			   ::com::sun::star::uno::XComponentContext > const & xContext);
93 	virtual ~ChartView();
94 
95     // ___lang::XServiceInfo___
96 	APPHELPER_XSERVICEINFO_DECL()
97 	APPHELPER_SERVICE_FACTORY_HELPER(ChartView)
98 
99 	// ___lang::XInitialization___
100     virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
101                 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
102 
103     // ___ExplicitValueProvider___
104     virtual sal_Bool getExplicitValuesForAxis(
105         ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > xAxis
106         , ExplicitScaleData&  rExplicitScale
107         , ExplicitIncrementData& rExplicitIncrement );
108     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
109         getShapeForCID( const rtl::OUString& rObjectCID );
110 
111     virtual ::com::sun::star::awt::Rectangle getRectangleOfObject( const rtl::OUString& rObjectCID, bool bSnapRect=false );
112 
113     virtual ::com::sun::star::awt::Rectangle getDiagramRectangleExcludingAxes();
114 
115     ::boost::shared_ptr< DrawModelWrapper > getDrawModelWrapper();
116 
117     // ___XTransferable___
118     virtual ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
119                 throw (::com::sun::star::datatransfer::UnsupportedFlavorException
120                      , ::com::sun::star::io::IOException
121                      , ::com::sun::star::uno::RuntimeException);
122     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors(  )
123                 throw (::com::sun::star::uno::RuntimeException);
124     virtual ::sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
125                 throw (::com::sun::star::uno::RuntimeException);
126 
127     //-------------------------------------------------------------------------------------
128 	// ::com::sun::star::util::XEventListener (base of XCloseListener and XModifyListener)
129 	//-------------------------------------------------------------------------------------
130 	virtual void SAL_CALL
131 		disposing( const ::com::sun::star::lang::EventObject& Source )
132 							throw (::com::sun::star::uno::RuntimeException);
133 
134     //-----------------------------------------------------------------
135     // ::com::sun::star::util::XModifyListener
136     //-----------------------------------------------------------------
137     virtual void SAL_CALL modified(
138         const ::com::sun::star::lang::EventObject& aEvent )
139         throw (::com::sun::star::uno::RuntimeException);
140 
141     //SfxListener
142     virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
143 
144     //-----------------------------------------------------------------
145     // ::com::sun::star::util::XModeChangeBroadcaster
146     //-----------------------------------------------------------------
147 
148     virtual void SAL_CALL addModeChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
149     virtual void SAL_CALL removeModeChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
150     virtual void SAL_CALL addModeChangeApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeApproveListener >& _rxListener ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
151     virtual void SAL_CALL removeModeChangeApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeApproveListener >& _rxListener ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
152 
153     //-----------------------------------------------------------------
154     // ::com::sun::star::util::XUpdatable
155     //-----------------------------------------------------------------
156     virtual void SAL_CALL update() throw (::com::sun::star::uno::RuntimeException);
157 
158     //-----------------------------------------------------------------
159     // ::com::sun::star::beans::XPropertySet
160     //-----------------------------------------------------------------
161     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw (::com::sun::star::uno::RuntimeException);
162     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
163     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
164     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
165     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
166     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
167     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
168 
169     //-----------------------------------------------------------------
170     // ::com::sun::star::lang::XMultiServiceFactory
171     //-----------------------------------------------------------------
172     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier )
173         throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
174     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments(
175         const ::rtl::OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments )
176         throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
177     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames() throw (::com::sun::star::uno::RuntimeException);
178 
179     // for ExplicitValueProvider
180     // ____ XUnoTunnel ___
181     virtual ::sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aIdentifier )
182             throw (::com::sun::star::uno::RuntimeException);
183 
184 private: //methods
185     ChartView();
186 
187     void createShapes();
188     void getMetaFile( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutStream
189                       , bool bUseHighContrast );
190     SdrPage* getSdrPage();
191 
192     void impl_setChartModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel );
193     void impl_deleteCoordinateSystems();
194     void impl_notifyModeChangeListener( const rtl::OUString& rNewMode );
195 
196     void impl_refreshAddIn();
197     bool impl_AddInDrawsAllByItself();
198 
199     void impl_updateView();
200 
201     ::com::sun::star::awt::Rectangle impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlotterContainer
202         , const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes>& xDiagramPlusAxes_Shapes
203         , const ::com::sun::star::awt::Point& rAvailablePos
204         , const ::com::sun::star::awt::Size& rAvailableSize
205         , const ::com::sun::star::awt::Size& rPageSize
206         , bool bUseFixedInnerSize
207         , const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& xDiagram_MarkHandles );
208 
209 
210 private: //member
211     ::osl::Mutex m_aMutex;
212 
213 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>
214 			m_xCC;
215     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
216             m_xChartModel;
217 
218 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>
219 			m_xShapeFactory;
220 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage>
221 			m_xDrawPage;
222 
223     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xDashTable;
224     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xGradientTable;
225     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xHatchTable;
226     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xBitmapTable;
227     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xTransGradientTable;
228     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xMarkerTable;
229 
230     ::boost::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper;
231 
232     std::vector< VCoordinateSystem* > m_aVCooSysList;
233 
234     ::cppu::OMultiTypeInterfaceContainerHelper
235                         m_aListenerContainer;
236 
237     bool volatile       m_bViewDirty; //states wether the view needs to be rebuild
238     bool volatile       m_bInViewUpdate;
239     bool volatile       m_bViewUpdatePending;
240     bool volatile		m_bRefreshAddIn;
241 
242     //better performance for big data
243     ::com::sun::star::awt::Size m_aPageResolution;
244     bool m_bPointsWereSkipped;
245 
246     //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100%
247     sal_Int32 m_nScaleXNumerator;
248     sal_Int32 m_nScaleXDenominator;
249     sal_Int32 m_nScaleYNumerator;
250     sal_Int32 m_nScaleYDenominator;
251 
252     sal_Bool m_bSdrViewIsInEditMode;
253 
254     ::com::sun::star::awt::Rectangle m_aResultingDiagramRectangleExcludingAxes;
255 };
256 
257 //.............................................................................
258 } //namespace chart
259 //.............................................................................
260 
261 #endif
262