1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _CHARTVIEWIMPL_HXX 24 #define _CHARTVIEWIMPL_HXX 25 26 #include "chartview/ExplicitValueProvider.hxx" 27 #include "ServiceMacros.hxx" 28 #include <cppuhelper/implbase9.hxx> 29 #include <cppuhelper/interfacecontainer.hxx> 30 31 // header for class SfxListener 32 #include <svl/lstner.hxx> 33 #include <com/sun/star/datatransfer/XTransferable.hpp> 34 #include <com/sun/star/drawing/XDrawPage.hpp> 35 #include <com/sun/star/frame/XModel.hpp> 36 #include <com/sun/star/io/XOutputStream.hpp> 37 #include <com/sun/star/lang/XInitialization.hpp> 38 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 39 #include <com/sun/star/lang/XServiceInfo.hpp> 40 #include <com/sun/star/lang/XUnoTunnel.hpp> 41 #include <com/sun/star/uno/XComponentContext.hpp> 42 #include <com/sun/star/util/XModifyListener.hpp> 43 #include <com/sun/star/util/XModeChangeBroadcaster.hpp> 44 #include <com/sun/star/util/XUpdatable.hpp> 45 46 #include <vector> 47 #include <boost/shared_ptr.hpp> 48 49 class SdrPage; 50 51 //............................................................................. 52 namespace chart 53 { 54 //............................................................................. 55 56 class VCoordinateSystem; 57 class DrawModelWrapper; 58 class SeriesPlotterContainer; 59 60 //----------------------------------------------------------------------------- 61 /** The ChartView is responsible to manage the generation of Drawing Objects 62 for visualization on a given OutputDevice. The ChartModel is responsible to notify changes to the view. 63 The view than changes to state dirty. The view can be updated with call 'update'. 64 65 The View is not responsible to handle single user events (that is instead done by the ChartWindow). 66 */ 67 68 class ChartView : public ::cppu::WeakImplHelper9< 69 ::com::sun::star::lang::XInitialization 70 , ::com::sun::star::lang::XServiceInfo 71 , ::com::sun::star::datatransfer::XTransferable 72 ,::com::sun::star::lang::XUnoTunnel 73 //::com::sun::star::lang::XComponent ??? 74 //::com::sun::star::uno::XWeak // implemented by WeakImplHelper(optional interface) 75 //::com::sun::star::uno::XInterface // implemented by WeakImplHelper(optional interface) 76 //::com::sun::star::lang::XTypeProvider // implemented by WeakImplHelper 77 ,::com::sun::star::util::XModifyListener 78 ,::com::sun::star::util::XModeChangeBroadcaster 79 ,::com::sun::star::util::XUpdatable 80 ,::com::sun::star::beans::XPropertySet 81 ,::com::sun::star::lang::XMultiServiceFactory 82 > 83 , public ExplicitValueProvider 84 , private SfxListener 85 { 86 public: 87 ChartView(::com::sun::star::uno::Reference< 88 ::com::sun::star::uno::XComponentContext > const & xContext); 89 virtual ~ChartView(); 90 91 // ___lang::XServiceInfo___ 92 APPHELPER_XSERVICEINFO_DECL() 93 APPHELPER_SERVICE_FACTORY_HELPER(ChartView) 94 95 // ___lang::XInitialization___ 96 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ); 97 98 // ___ExplicitValueProvider___ 99 virtual sal_Bool getExplicitValuesForAxis( 100 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > xAxis 101 , ExplicitScaleData& rExplicitScale 102 , ExplicitIncrementData& rExplicitIncrement ); 103 virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > 104 getShapeForCID( const rtl::OUString& rObjectCID ); 105 106 virtual ::com::sun::star::awt::Rectangle getRectangleOfObject( const rtl::OUString& rObjectCID, bool bSnapRect=false ); 107 108 virtual ::com::sun::star::awt::Rectangle getDiagramRectangleExcludingAxes(); 109 110 ::boost::shared_ptr< DrawModelWrapper > getDrawModelWrapper(); 111 112 // ___XTransferable___ 113 virtual ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ); 114 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ); 115 virtual ::sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ); 116 117 //------------------------------------------------------------------------------------- 118 // ::com::sun::star::util::XEventListener (base of XCloseListener and XModifyListener) 119 //------------------------------------------------------------------------------------- 120 virtual void SAL_CALL 121 disposing( const ::com::sun::star::lang::EventObject& Source ); 122 123 //----------------------------------------------------------------- 124 // ::com::sun::star::util::XModifyListener 125 //----------------------------------------------------------------- 126 virtual void SAL_CALL modified( 127 const ::com::sun::star::lang::EventObject& aEvent ); 128 129 //SfxListener 130 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 131 132 //----------------------------------------------------------------- 133 // ::com::sun::star::util::XModeChangeBroadcaster 134 //----------------------------------------------------------------- 135 136 virtual void SAL_CALL addModeChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeListener >& _rxListener ); 137 virtual void SAL_CALL removeModeChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeListener >& _rxListener ); 138 virtual void SAL_CALL addModeChangeApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeApproveListener >& _rxListener ); 139 virtual void SAL_CALL removeModeChangeApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeApproveListener >& _rxListener ); 140 141 //----------------------------------------------------------------- 142 // ::com::sun::star::util::XUpdatable 143 //----------------------------------------------------------------- 144 virtual void SAL_CALL update(); 145 146 //----------------------------------------------------------------- 147 // ::com::sun::star::beans::XPropertySet 148 //----------------------------------------------------------------- 149 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ); 150 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ); 151 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ); 152 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ); 153 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ); 154 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ); 155 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ); 156 157 //----------------------------------------------------------------- 158 // ::com::sun::star::lang::XMultiServiceFactory 159 //----------------------------------------------------------------- 160 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ); 161 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( 162 const ::rtl::OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ); 163 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames(); 164 165 // for ExplicitValueProvider 166 // ____ XUnoTunnel ___ 167 virtual ::sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aIdentifier ); 168 169 private: //methods 170 ChartView(); 171 172 void createShapes(); 173 void getMetaFile( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutStream 174 , bool bUseHighContrast ); 175 SdrPage* getSdrPage(); 176 177 void impl_setChartModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel ); 178 void impl_deleteCoordinateSystems(); 179 void impl_notifyModeChangeListener( const rtl::OUString& rNewMode ); 180 181 void impl_refreshAddIn(); 182 bool impl_AddInDrawsAllByItself(); 183 184 void impl_updateView(); 185 186 ::com::sun::star::awt::Rectangle impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlotterContainer 187 , const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes>& xDiagramPlusAxes_Shapes 188 , const ::com::sun::star::awt::Point& rAvailablePos 189 , const ::com::sun::star::awt::Size& rAvailableSize 190 , const ::com::sun::star::awt::Size& rPageSize 191 , bool bUseFixedInnerSize 192 , const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& xDiagram_MarkHandles ); 193 194 195 private: //member 196 ::osl::Mutex m_aMutex; 197 198 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> 199 m_xCC; 200 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > 201 m_xChartModel; 202 203 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> 204 m_xShapeFactory; 205 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage> 206 m_xDrawPage; 207 208 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xDashTable; 209 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xGradientTable; 210 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xHatchTable; 211 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xBitmapTable; 212 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xTransGradientTable; 213 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xMarkerTable; 214 215 ::boost::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper; 216 217 std::vector< VCoordinateSystem* > m_aVCooSysList; 218 219 ::cppu::OMultiTypeInterfaceContainerHelper 220 m_aListenerContainer; 221 222 bool volatile m_bViewDirty; //states whether the view needs to be rebuild 223 bool volatile m_bInViewUpdate; 224 bool volatile m_bViewUpdatePending; 225 bool volatile m_bRefreshAddIn; 226 227 //better performance for big data 228 ::com::sun::star::awt::Size m_aPageResolution; 229 bool m_bPointsWereSkipped; 230 231 //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100% 232 sal_Int32 m_nScaleXNumerator; 233 sal_Int32 m_nScaleXDenominator; 234 sal_Int32 m_nScaleYNumerator; 235 sal_Int32 m_nScaleYDenominator; 236 237 sal_Bool m_bSdrViewIsInEditMode; 238 239 ::com::sun::star::awt::Rectangle m_aResultingDiagramRectangleExcludingAxes; 240 }; 241 242 //............................................................................. 243 } //namespace chart 244 //............................................................................. 245 246 #endif 247