1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ChartView.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _CHARTVIEWIMPL_HXX
31 #define _CHARTVIEWIMPL_HXX
33 #include "chartview/ExplicitValueProvider.hxx"
34 #include "ServiceMacros.hxx"
35 #include <cppuhelper/implbase8.hxx>
36 #include <cppuhelper/interfacecontainer.hxx>
38 // header for class SfxListener
39 #include <svtools/lstner.hxx>
40 #include <com/sun/star/datatransfer/XTransferable.hpp>
41 #include <com/sun/star/drawing/XDrawPage.hpp>
42 #include <com/sun/star/frame/XModel.hpp>
43 #include <com/sun/star/io/XOutputStream.hpp>
44 #include <com/sun/star/lang/XInitialization.hpp>
45 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
46 #include <com/sun/star/lang/XServiceInfo.hpp>
47 #include <com/sun/star/lang/XUnoTunnel.hpp>
48 #include <com/sun/star/uno/XComponentContext.hpp>
49 #include <com/sun/star/util/XModifyListener.hpp>
50 #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
51 #include <com/sun/star/util/XUpdatable.hpp>
54 #include <boost/shared_ptr.hpp>
58 //.............................................................................
61 //.............................................................................
63 class VCoordinateSystem
;
64 class DrawModelWrapper
;
65 class SeriesPlotterContainer
;
67 //-----------------------------------------------------------------------------
68 /** The ChartView is responsible to manage the generation of Drawing Objects
69 for visualization on a given OutputDevice. The ChartModel is responsible to notify changes to the view.
70 The view than changes to state dirty. The view can be updated with call 'update'.
72 The View is not responsible to handle single user events (that is instead done by the ChartWindow).
75 class ChartView
: public ::cppu::WeakImplHelper8
<
76 ::com::sun::star::lang::XInitialization
77 , ::com::sun::star::lang::XServiceInfo
78 , ::com::sun::star::datatransfer::XTransferable
79 ,::com::sun::star::lang::XUnoTunnel
80 //::com::sun::star::lang::XComponent ???
81 //::com::sun::star::uno::XWeak // implemented by WeakImplHelper(optional interface)
82 //::com::sun::star::uno::XInterface // implemented by WeakImplHelper(optional interface)
83 //::com::sun::star::lang::XTypeProvider // implemented by WeakImplHelper
84 ,::com::sun::star::util::XModifyListener
85 ,::com::sun::star::util::XModeChangeBroadcaster
86 ,::com::sun::star::util::XUpdatable
87 ,::com::sun::star::beans::XPropertySet
89 , public ExplicitValueProvider
93 ChartView(::com::sun::star::uno::Reference
<
94 ::com::sun::star::uno::XComponentContext
> const & xContext
);
97 // ___lang::XServiceInfo___
98 APPHELPER_XSERVICEINFO_DECL()
99 APPHELPER_SERVICE_FACTORY_HELPER(ChartView
)
101 // ___lang::XInitialization___
102 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
)
103 throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
105 // ___ExplicitValueProvider___
106 virtual sal_Bool
getExplicitValuesForAxis(
107 ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XAxis
> xAxis
108 , ::com::sun::star::chart2::ExplicitScaleData
& rExplicitScale
109 , ::com::sun::star::chart2::ExplicitIncrementData
& rExplicitIncrement
);
110 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
111 getShapeForCID( const rtl::OUString
& rObjectCID
);
113 virtual ::com::sun::star::awt::Rectangle
getRectangleOfObject( const rtl::OUString
& rObjectCID
, bool bSnapRect
=false );
115 ::boost::shared_ptr
< DrawModelWrapper
> getDrawModelWrapper();
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
);
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
);
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
);
142 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
144 //-----------------------------------------------------------------
145 // ::com::sun::star::util::XModeChangeBroadcaster
146 //-----------------------------------------------------------------
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
);
153 //-----------------------------------------------------------------
154 // ::com::sun::star::util::XUpdatable
155 //-----------------------------------------------------------------
156 virtual void SAL_CALL
update() throw (::com::sun::star::uno::RuntimeException
);
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
);
170 // for ExplicitValueProvider
171 // ____ XUnoTunnel ___
172 virtual ::sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< ::sal_Int8
>& aIdentifier
)
173 throw (::com::sun::star::uno::RuntimeException
);
179 void getMetaFile( const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XOutputStream
>& xOutStream
180 , bool bUseHighContrast
);
181 SdrPage
* getSdrPage();
183 void impl_setChartModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xChartModel
);
184 void impl_deleteCoordinateSystems();
185 void impl_notifyModeChangeListener( const rtl::OUString
& rNewMode
);
187 void impl_refreshAddIn();
188 bool impl_AddInDrawsAllByItself();
190 void impl_updateView();
192 void impl_createDiagramAndContent( SeriesPlotterContainer
& rSeriesPlotterContainer
193 , const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xDiagramPlusAxes_Shapes
194 , const ::com::sun::star::awt::Point
& rAvailablePos
195 , const ::com::sun::star::awt::Size
& rAvailableSize
196 , const ::com::sun::star::awt::Size
& rPageSize
);
200 ::osl::Mutex m_aMutex
;
202 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>
204 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>
207 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>
209 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>
212 ::boost::shared_ptr
< DrawModelWrapper
> m_pDrawModelWrapper
;
214 std::vector
< VCoordinateSystem
* > m_aVCooSysList
;
216 ::cppu::OMultiTypeInterfaceContainerHelper
217 m_aListenerContainer
;
219 bool volatile m_bViewDirty
; //states wether the view needs to be rebuild
220 bool volatile m_bInViewUpdate
;
221 bool volatile m_bViewUpdatePending
;
222 bool volatile m_bRefreshAddIn
;
224 //better performance for big data
225 ::com::sun::star::awt::Size m_aPageResolution
;
226 bool m_bPointsWereSkipped
;
228 //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100%
229 sal_Int32 m_nScaleXNumerator
;
230 sal_Int32 m_nScaleXDenominator
;
231 sal_Int32 m_nScaleYNumerator
;
232 sal_Int32 m_nScaleYDenominator
;
234 sal_Bool m_bSdrViewIsInEditMode
;
237 //.............................................................................
239 //.............................................................................