LCOV - code coverage report
Current view: top level - chart2/inc - ChartView.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 3 3 100.0 %
Date: 2014-11-03 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef INCLUDED_CHART2_INC_CHARTVIEW_HXX
      20             : #define INCLUDED_CHART2_INC_CHARTVIEW_HXX
      21             : 
      22             : #include "ChartModel.hxx"
      23             : #include "chartview/ExplicitValueProvider.hxx"
      24             : #include "ServiceMacros.hxx"
      25             : #include <cppuhelper/implbase10.hxx>
      26             : #include <cppuhelper/interfacecontainer.hxx>
      27             : 
      28             : #include <svl/lstner.hxx>
      29             : #include <com/sun/star/datatransfer/XTransferable.hpp>
      30             : #include <com/sun/star/drawing/XDrawPage.hpp>
      31             : #include <com/sun/star/frame/XModel.hpp>
      32             : #include <com/sun/star/io/XOutputStream.hpp>
      33             : #include <com/sun/star/lang/XInitialization.hpp>
      34             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      35             : #include <com/sun/star/lang/XServiceInfo.hpp>
      36             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      37             : #include <com/sun/star/uno/XComponentContext.hpp>
      38             : #include <com/sun/star/util/XModifyListener.hpp>
      39             : #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
      40             : #include <com/sun/star/util/XUpdatable.hpp>
      41             : #include <com/sun/star/qa/XDumper.hpp>
      42             : 
      43             : #include <vector>
      44             : #include <boost/shared_ptr.hpp>
      45             : #include <boost/ptr_container/ptr_vector.hpp>
      46             : 
      47             : #include <vcl/timer.hxx>
      48             : 
      49             : class SdrPage;
      50             : 
      51             : namespace chart {
      52             : 
      53             : class VCoordinateSystem;
      54             : class DrawModelWrapper;
      55             : class VDataSeries;
      56             : class GL3DPlotterBase;
      57             : class GL2DRenderer;
      58             : struct CreateShapeParam2D;
      59             : 
      60             : enum TimeBasedMode
      61             : {
      62             :     MANUAL,
      63             :     AUTOMATIC,
      64             :     AUTOMATIC_WRAP
      65             : };
      66             : 
      67         574 : struct TimeBasedInfo
      68             : {
      69         606 :     TimeBasedInfo():
      70             :         bTimeBased(false),
      71             :         nFrame(0),
      72         606 :         eMode(AUTOMATIC) {}
      73             : 
      74             :     bool bTimeBased;
      75             :     size_t nFrame;
      76             :     TimeBasedMode eMode;
      77             :     Timer maTimer;
      78             : 
      79             :     // only valid when we are in the time based mode
      80             :     ::std::vector< std::vector< VDataSeries* > > m_aDataSeriesList;
      81             : };
      82             : 
      83             : /**
      84             :  * The ChartView is responsible to manage the generation of Drawing Objects
      85             :  * for visualization on a given OutputDevice. The ChartModel is responsible
      86             :  * to notify changes to the view. The view than changes to state dirty. The
      87             :  * view can be updated with call 'update'.
      88             :  *
      89             :  * The View is not responsible to handle single user events (that is instead
      90             :  * done by the ChartWindow).
      91             :  */
      92             : class ChartView : public ::cppu::WeakImplHelper10<
      93             :     ::com::sun::star::lang::XInitialization
      94             :         ,::com::sun::star::lang::XServiceInfo
      95             :         ,::com::sun::star::datatransfer::XTransferable
      96             :         ,::com::sun::star::lang::XUnoTunnel
      97             :         ,::com::sun::star::util::XModifyListener
      98             :         ,::com::sun::star::util::XModeChangeBroadcaster
      99             :         ,::com::sun::star::util::XUpdatable
     100             :         ,::com::sun::star::beans::XPropertySet
     101             :         ,::com::sun::star::lang::XMultiServiceFactory
     102             :         ,::com::sun::star::qa::XDumper
     103             :         >
     104             :         , public ExplicitValueProvider
     105             :         , private SfxListener
     106             : {
     107             :     friend class GL2DRenderer;
     108             : private:
     109             :     void init();
     110             : 
     111             : public:
     112             :     ChartView(::com::sun::star::uno::Reference<
     113             :                ::com::sun::star::uno::XComponentContext > const & xContext,
     114             :                ChartModel& rModel);
     115             : 
     116             :     virtual ~ChartView();
     117             : 
     118             :     // ___lang::XServiceInfo___
     119             :     APPHELPER_XSERVICEINFO_DECL()
     120             : 
     121             :     // ___lang::XInitialization___
     122             :     virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
     123             :                 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     124             : 
     125             :     // ___ExplicitValueProvider___
     126             :     virtual bool getExplicitValuesForAxis(
     127             :         ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > xAxis
     128             :         , ExplicitScaleData&  rExplicitScale
     129             :         , ExplicitIncrementData& rExplicitIncrement ) SAL_OVERRIDE;
     130             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     131             :         getShapeForCID( const OUString& rObjectCID ) SAL_OVERRIDE;
     132             : 
     133             :     virtual ::com::sun::star::awt::Rectangle getRectangleOfObject( const OUString& rObjectCID, bool bSnapRect=false ) SAL_OVERRIDE;
     134             : 
     135             :     virtual ::com::sun::star::awt::Rectangle getDiagramRectangleExcludingAxes() SAL_OVERRIDE;
     136             : 
     137             :     ::boost::shared_ptr< DrawModelWrapper > getDrawModelWrapper() SAL_OVERRIDE;
     138             : 
     139             :     // ___XTransferable___
     140             :     virtual ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
     141             :                 throw (::com::sun::star::datatransfer::UnsupportedFlavorException
     142             :                      , ::com::sun::star::io::IOException
     143             :                      , ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     144             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors(  )
     145             :                 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     146             :     virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
     147             :                 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     148             : 
     149             :     // ::com::sun::star::util::XEventListener (base of XCloseListener and XModifyListener)
     150             :     virtual void SAL_CALL
     151             :         disposing( const ::com::sun::star::lang::EventObject& Source )
     152             :                             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     153             : 
     154             :     // ::com::sun::star::util::XModifyListener
     155             :     virtual void SAL_CALL modified(
     156             :         const ::com::sun::star::lang::EventObject& aEvent )
     157             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     158             : 
     159             :     //SfxListener
     160             :     virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
     161             : 
     162             :     // ::com::sun::star::util::XModeChangeBroadcaster
     163             : 
     164             :     virtual void SAL_CALL addModeChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     165             :     virtual void SAL_CALL removeModeChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     166             :     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, std::exception) SAL_OVERRIDE;
     167             :     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, std::exception) SAL_OVERRIDE;
     168             : 
     169             :     // ::com::sun::star::util::XUpdatable
     170             :     virtual void SAL_CALL update() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     171             : 
     172             :     // ::com::sun::star::beans::XPropertySet
     173             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     174             :     virtual void SAL_CALL setPropertyValue( const 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, std::exception) SAL_OVERRIDE;
     175             :     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     176             :     virtual void SAL_CALL addPropertyChangeListener( const 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, std::exception) SAL_OVERRIDE;
     177             :     virtual void SAL_CALL removePropertyChangeListener( const 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, std::exception) SAL_OVERRIDE;
     178             :     virtual void SAL_CALL addVetoableChangeListener( const 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, std::exception) SAL_OVERRIDE;
     179             :     virtual void SAL_CALL removeVetoableChangeListener( const 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, std::exception) SAL_OVERRIDE;
     180             : 
     181             :     // ::com::sun::star::lang::XMultiServiceFactory
     182             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier )
     183             :         throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     184             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments(
     185             :         const OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments )
     186             :         throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     187             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     188             : 
     189             :     // for ExplicitValueProvider
     190             :     // ____ XUnoTunnel ___
     191             :     virtual ::sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aIdentifier )
     192             :             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     193             : 
     194             :     // XDumper
     195             :     virtual OUString SAL_CALL dump()
     196             :             throw(::com::sun::star::uno::RuntimeException,
     197             :                   std::exception) SAL_OVERRIDE;
     198             : 
     199             :     void setViewDirty();
     200             :     void updateOpenGLWindow();
     201             : 
     202             : private: //methods
     203             :     ChartView();
     204             : 
     205             :     void createShapes();
     206             :     void createShapes2D( const css::awt::Size& rPageSize );
     207             :     bool createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css::awt::Size& rPageSize );
     208             :     void createShapes3D();
     209             :     bool isReal3DChart();
     210             :     void getMetaFile( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutStream
     211             :                       , bool bUseHighContrast );
     212             :     SdrPage* getSdrPage();
     213             : 
     214             :     void impl_deleteCoordinateSystems();
     215             :     void impl_notifyModeChangeListener( const OUString& rNewMode );
     216             : 
     217             :     void impl_refreshAddIn();
     218             :     bool impl_AddInDrawsAllByItself();
     219             : 
     220             :     void impl_updateView();
     221             : 
     222             :     void render();
     223             : 
     224             :     css::awt::Rectangle impl_createDiagramAndContent( const CreateShapeParam2D& rParam, const css::awt::Size& rPageSize );
     225             : 
     226             :     DECL_LINK( UpdateTimeBased, void* );
     227             : 
     228             : private: //member
     229             :     ::osl::Mutex m_aMutex;
     230             : 
     231             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>
     232             :             m_xCC;
     233             : 
     234             :     chart::ChartModel& mrChartModel;
     235             : 
     236             :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>
     237             :             m_xShapeFactory;
     238             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage>
     239             :             m_xDrawPage;
     240             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
     241             :             mxRootShape;
     242             : 
     243             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xDashTable;
     244             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xGradientTable;
     245             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xHatchTable;
     246             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xBitmapTable;
     247             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xTransGradientTable;
     248             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xMarkerTable;
     249             : 
     250             :     ::boost::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper;
     251             : 
     252             :     std::vector< VCoordinateSystem* > m_aVCooSysList;
     253             : 
     254             :     ::cppu::OMultiTypeInterfaceContainerHelper
     255             :                         m_aListenerContainer;
     256             : 
     257             :     bool m_bViewDirty; //states whether the view needs to be rebuild
     258             :     bool m_bInViewUpdate;
     259             :     bool m_bViewUpdatePending;
     260             :     bool m_bRefreshAddIn;
     261             : 
     262             :     //better performance for big data
     263             :     ::com::sun::star::awt::Size m_aPageResolution;
     264             :     bool m_bPointsWereSkipped;
     265             : 
     266             :     //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100%
     267             :     sal_Int32 m_nScaleXNumerator;
     268             :     sal_Int32 m_nScaleXDenominator;
     269             :     sal_Int32 m_nScaleYNumerator;
     270             :     sal_Int32 m_nScaleYDenominator;
     271             : 
     272             :     bool m_bSdrViewIsInEditMode;
     273             : 
     274             :     ::com::sun::star::awt::Rectangle m_aResultingDiagramRectangleExcludingAxes;
     275             : 
     276             :     boost::shared_ptr<GL3DPlotterBase> m_pGL3DPlotter;
     277             :     TimeBasedInfo maTimeBased;
     278             :     osl::Mutex maTimeMutex;
     279             :     boost::scoped_ptr<GL2DRenderer> mp2DRenderer;
     280             : };
     281             : 
     282             : }
     283             : 
     284             : #endif
     285             : 
     286             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10